]>
git.ipfire.org Git - people/ms/u-boot.git/blob - board/trab/vfd.c
3 * Wolfgang Denk, DENX Software Engineering -- wd@denx.de
5 * See file CREDITS for list of people who contributed to this
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
24 /************************************************************************/
25 /* ** DEBUG SETTINGS */
26 /************************************************************************/
30 /************************************************************************/
32 /************************************************************************/
38 #include <linux/types.h>
44 /************************************************************************/
45 /* ** CONFIG STUFF -- should be moved to board config file */
46 /************************************************************************/
48 /************************************************************************/
51 #define PAGE_SIZE 4096
59 #define frame_buf_offs 4
61 /* Supported VFD Types */
62 #define VFD_TYPE_T119C 1 /* Noritake T119C VFD */
63 #define VFD_TYPE_MN11236 2
65 /* taken from armboot/common/vfd.c */
66 unsigned long adr_vfd_table
[112][18][2][4][2];
67 unsigned char bit_vfd_table
[112][18][2][4][2];
70 * initialize the values for the VFD-grid-control in the framebuffer
72 void init_grid_ctrl(void)
74 DECLARE_GLOBAL_DATA_PTR
;
75 ulong adr
, grid_cycle
;
76 unsigned int bit
, display
;
77 unsigned char temp
, bit_nr
;
81 * clear frame buffer (logical clear => set to "black")
83 if (gd
->vfd_inv_data
== 0)
88 for (adr
= gd
->fb_base
; adr
<= (gd
->fb_base
+7168); adr
+= 4) {
89 (*(volatile ulong
*)(adr
)) = val
;
92 switch (gd
->vfd_type
) {
94 for (display
=0; display
<4; display
++) {
95 for(grid_cycle
=0; grid_cycle
<56; grid_cycle
++) {
96 bit
= grid_cycle
* 256 * 4 +
97 (grid_cycle
+ 200) * 4 +
98 frame_buf_offs
+ display
;
99 /* wrap arround if offset (see manual S3C2400) */
100 if (bit
>=frame_buf_size
*8)
101 bit
= bit
- (frame_buf_size
* 8);
102 adr
= gd
->fb_base
+ (bit
/32) * 4 + (3 - (bit
%32) / 8);
104 bit_nr
= (bit_nr
> 3) ? bit_nr
-4 : bit_nr
+4;
105 temp
=(*(volatile unsigned char*)(adr
));
106 if (gd
->vfd_inv_data
)
107 temp
&= ~(1<<bit_nr
);
110 (*(volatile unsigned char*)(adr
))=temp
;
113 bit
= grid_cycle
*256*4+(grid_cycle
+201)*4+frame_buf_offs
+display
;
115 bit
= grid_cycle
*256*4+200*4+frame_buf_offs
+display
-4; /* grid nr. 0 */
116 /* wrap arround if offset (see manual S3C2400) */
117 if (bit
>=frame_buf_size
*8)
118 bit
= bit
-(frame_buf_size
*8);
119 adr
= gd
->fb_base
+(bit
/32)*4+(3-(bit
%32)/8);
121 bit_nr
= (bit_nr
>3)?bit_nr
-4:bit_nr
+4;
122 temp
=(*(volatile unsigned char*)(adr
));
123 if (gd
->vfd_inv_data
)
124 temp
&= ~(1<<bit_nr
);
127 (*(volatile unsigned char*)(adr
))=temp
;
131 case VFD_TYPE_MN11236
:
132 for (display
=0; display
<4; display
++) {
133 for (grid_cycle
=0; grid_cycle
<38; grid_cycle
++) {
134 bit
= grid_cycle
* 256 * 4 +
135 (253 - grid_cycle
) * 4 +
136 frame_buf_offs
+ display
;
137 /* wrap arround if offset (see manual S3C2400) */
138 if (bit
>=frame_buf_size
*8)
139 bit
= bit
- (frame_buf_size
* 8);
140 adr
= gd
->fb_base
+ (bit
/32) * 4 + (3 - (bit
%32) / 8);
142 bit_nr
= (bit_nr
> 3) ? bit_nr
-4 : bit_nr
+4;
143 temp
=(*(volatile unsigned char*)(adr
));
144 if (gd
->vfd_inv_data
)
145 temp
&= ~(1<<bit_nr
);
148 (*(volatile unsigned char*)(adr
))=temp
;
151 bit
= grid_cycle
*256*4+(252-grid_cycle
)*4+frame_buf_offs
+display
;
153 /* wrap arround if offset (see manual S3C2400) */
154 if (bit
>=frame_buf_size
*8)
155 bit
= bit
-(frame_buf_size
*8);
156 adr
= gd
->fb_base
+(bit
/32)*4+(3-(bit
%32)/8);
158 bit_nr
= (bit_nr
>3)?bit_nr
-4:bit_nr
+4;
159 temp
=(*(volatile unsigned char*)(adr
));
160 if (gd
->vfd_inv_data
)
161 temp
&= ~(1<<bit_nr
);
164 (*(volatile unsigned char*)(adr
))=temp
;
169 printf ("Warning: unknown display type\n");
175 *create translation table for getting easy the right position in the
176 *physical framebuffer for some x/y-coordinates of the VFDs
178 void create_vfd_table(void)
180 DECLARE_GLOBAL_DATA_PTR
;
181 unsigned long vfd_table
[112][18][2][4][2];
182 unsigned int x
, y
, color
, display
, entry
, pixel
;
183 unsigned int x_abcdef
= 0;
185 switch (gd
->vfd_type
) {
187 for(y
=0; y
<=17; y
++) { /* Line */
188 for(x
=0; x
<=111; x
++) { /* Column */
189 for(display
=0; display
<=3; display
++) {
191 /* Display 0 blue pixels */
192 vfd_table
[x
][y
][0][display
][0] =
193 (x
==0) ? y
*16+display
194 : (x
%4)*4+y
*16+((x
-1)/2)*1024+display
;
195 /* Display 0 red pixels */
196 vfd_table
[x
][y
][1][display
][0] =
197 (x
==0) ? y
*16+512+display
198 : (x
%4)*4+y
*16+((x
-1)/2)*1024+512+display
;
203 case VFD_TYPE_MN11236
:
204 for(y
=0; y
<=17; y
++) { /* Line */
205 for(x
=0; x
<=111; x
++) { /* Column */
206 for(display
=0; display
<=3; display
++) {
208 vfd_table
[x
][y
][0][display
][0]=0;
209 vfd_table
[x
][y
][0][display
][1]=0;
210 vfd_table
[x
][y
][1][display
][0]=0;
211 vfd_table
[x
][y
][1][display
][1]=0;
214 case 0: x_abcdef
=0; break; /* a -> a */
215 case 1: x_abcdef
=2; break; /* b -> c */
216 case 2: x_abcdef
=4; break; /* c -> e */
217 case 3: x_abcdef
=5; break; /* d -> f */
218 case 4: x_abcdef
=3; break; /* e -> d */
219 case 5: x_abcdef
=1; break; /* f -> b */
223 vfd_table
[x
][y
][0][display
][0] =
224 (x
>1) ? x_abcdef
*4+((x
-1)/3)*1024+y
*48+display
225 : x_abcdef
*4+ 0+y
*48+display
;
228 vfd_table
[x
][y
][0][display
][1] = x_abcdef
*4+((x
-1)/3+1)*1024+y
*48+display
;
231 vfd_table
[x
][y
][1][display
][0] =
232 (x
>1) ? x_abcdef
*4+24+((x
-1)/3)*1024+y
*48+display
233 : x_abcdef
*4+24+ 0+y
*48+display
;
236 vfd_table
[x
][y
][1][display
][1] = x_abcdef
*4+24+((x
-1)/3+1)*1024+y
*48+display
;
247 * Create table with entries for physical byte adresses and
248 * bit-number within the byte
249 * from table with bit-numbers within the total framebuffer
253 for(color
=0;color
<2;color
++) {
254 for(display
=0;display
<4;display
++) {
255 for(entry
=0;entry
<2;entry
++) {
256 unsigned long adr
= gd
->fb_base
;
257 unsigned int bit_nr
= 0;
259 if (vfd_table
[x
][y
][color
][display
][entry
]) {
261 pixel
= vfd_table
[x
][y
][color
][display
][entry
] + frame_buf_offs
;
263 * wrap arround if offset
264 * (see manual S3C2400)
266 if (pixel
>=frame_buf_size
*8)
267 pixel
= pixel
-(frame_buf_size
*8);
268 adr
= gd
->fb_base
+(pixel
/32)*4+(3-(pixel
%32)/8);
270 bit_nr
= (bit_nr
>3)?bit_nr
-4:bit_nr
+4;
272 adr_vfd_table
[x
][y
][color
][display
][entry
] = adr
;
273 bit_vfd_table
[x
][y
][color
][display
][entry
] = bit_nr
;
282 * Set/clear pixel of the VFDs
284 void set_vfd_pixel(unsigned char x
, unsigned char y
,
285 unsigned char color
, unsigned char display
,
288 DECLARE_GLOBAL_DATA_PTR
;
290 unsigned char bit_nr
, temp
;
292 if (! gd
->vfd_type
) {
297 /* Pixel-Eintrag Nr. 1 */
298 adr
= adr_vfd_table
[x
][y
][color
][display
][0];
299 /* Pixel-Eintrag Nr. 1 */
300 bit_nr
= bit_vfd_table
[x
][y
][color
][display
][0];
301 temp
=(*(volatile unsigned char*)(adr
));
303 if (gd
->vfd_inv_data
) {
305 temp
&= ~(1<<bit_nr
);
312 temp
&= ~(1<<bit_nr
);
315 (*(volatile unsigned char*)(adr
))=temp
;
319 * transfer image from BMP-File
321 void transfer_pic(int display
, unsigned char *adr
, int height
, int width
)
326 for (; height
> 0; height
-= 18)
334 for (x
= 0; x
< width
; x
+= 2)
337 set_vfd_pixel(x
, y
-1, 0, display
, 0);
338 set_vfd_pixel(x
, y
-1, 1, display
, 0);
339 if ((temp
>> 4) == BLAU
)
340 set_vfd_pixel(x
, y
-1, 0, display
, 1);
341 else if ((temp
>> 4) == ROT
)
342 set_vfd_pixel(x
, y
-1, 1, display
, 1);
343 else if ((temp
>> 4) == VIOLETT
)
345 set_vfd_pixel(x
, y
-1, 0, display
, 1);
346 set_vfd_pixel(x
, y
-1, 1, display
, 1);
348 set_vfd_pixel(x
+1, y
-1, 0, display
, 0);
349 set_vfd_pixel(x
+1, y
-1, 1, display
, 0);
350 if ((temp
& 0x0F) == BLAU
)
351 set_vfd_pixel(x
+1, y
-1, 0, display
, 1);
352 else if ((temp
& 0x0F) == ROT
)
353 set_vfd_pixel(x
+1, y
-1, 1, display
, 1);
354 else if ((temp
& 0x0F) == VIOLETT
)
356 set_vfd_pixel(x
+1, y
-1, 0, display
, 1);
357 set_vfd_pixel(x
+1, y
-1, 1, display
, 1);
368 * This function initializes VFD clock that is needed for the CPLD that
369 * manages the keyboard.
371 int vfd_init_clocks(void)
373 /* Port-Pins als LCD-Ausgang */
374 rPCCON
= (rPCCON
& 0xFFFFFF00)| 0x000000AA;
375 /* Port-Pins als LCD-Ausgang */
376 rPDCON
= (rPDCON
& 0xFFFFFF03)| 0x000000A8;
377 #ifdef CFG_WITH_VFRAME
378 /* mit VFRAME zum Messen */
379 rPDCON
= (rPDCON
& 0xFFFFFF00)| 0x000000AA;
382 rLCDCON2
= 0x000DC000;
383 rLCDCON3
= 0x0051000A;
384 rLCDCON4
= 0x00000001;
385 rLCDCON5
= 0x00000440;
386 rLCDCON1
= 0x00000B75;
392 * initialize LCD-Controller of the S3C2400 for using VFDs
394 * VFD detection depends on the board revision:
395 * starting from Rev. 200 a type code can be read from the data pins,
396 * driven by some pull-up resistors; all earlier systems must be
397 * manually configured. The type is set in the "vfd_type" environment
400 int drv_vfd_init(void)
404 static int vfd_init_done
= 0;
407 DECLARE_GLOBAL_DATA_PTR
;
409 if (vfd_init_done
!= 0)
413 /* try to determine display type from the value
414 * defined by pull-ups
416 rPCUP
= (rPCUP
& 0xFFF0); /* activate GPC0...GPC3 pullups */
417 rPCCON
= (rPCCON
& 0xFFFFFF00); /* configure GPC0...GPC3 as inputs */
418 udelay(10); /* allow signals to settle */
420 vfd_id
= (~rPCDAT
) & 0x000F; /* read GPC0...GPC3 port pins */
421 debug("Detecting Revison of WA4-VFD: ID=0x%X\n", vfd_id
);
424 case 0: /* board revision < Rev.200 */
425 if ((tmp
= getenv ("vfd_type")) == NULL
) {
428 if (strcmp(tmp
, "T119C") == 0) {
429 gd
->vfd_type
= VFD_TYPE_T119C
;
430 } else if (strcmp(tmp
, "MN11236") == 0) {
431 gd
->vfd_type
= VFD_TYPE_MN11236
;
433 /* cannot use printf for a warning here */
434 gd
->vfd_type
= 0; /* unknown */
436 gd
->vfd_inv_data
= 0;
439 default: /* default to MN11236, data inverted */
440 gd
->vfd_type
= VFD_TYPE_MN11236
;
441 gd
->vfd_inv_data
= 1;
442 setenv ("vfd_type", "MN11236");
444 debug ("VFD type: %s%s\n",
445 (gd
->vfd_type
== VFD_TYPE_T119C
) ? "T119C" :
446 (gd
->vfd_type
== VFD_TYPE_MN11236
) ? "MN11236" :
448 gd
->vfd_inv_data
? ", inverted data" : "");
450 gd
->fb_base
= gd
->fb_base
;
454 for (palette
=0; palette
< 16; palette
++)
455 (*(volatile unsigned int*)(PALETTE
+(palette
*4)))=palette
;
456 for (palette
=16; palette
< 256; palette
++)
457 (*(volatile unsigned int*)(PALETTE
+(palette
*4)))=0x00;
460 * Hinweis: Der Framebuffer ist um genau ein Nibble verschoben
461 * Das erste angezeigte Pixel wird aus dem zweiten Nibble geholt
462 * das letzte angezeigte Pixel wird aus dem ersten Nibble geholt
466 /* frame buffer startadr */
467 rLCDSADDR1
= gd
->fb_base
>> 1;
468 /* frame buffer endadr */
469 rLCDSADDR2
= (gd
->fb_base
+ frame_buf_size
) >> 1;
470 rLCDSADDR3
= ((256/4));
472 debug ("LCDSADDR1: %lX\n", rLCDSADDR1
);
473 debug ("LCDSADDR2: %lX\n", rLCDSADDR2
);
474 debug ("LCDSADDR3: %lX\n", rLCDSADDR3
);
479 /************************************************************************/
480 /* ** ROM capable initialization part - needed to reserve FB memory */
481 /************************************************************************/
484 * This is called early in the system initialization to grab memory
485 * for the VFD controller.
487 * Note that this is running from ROM, so no write access to global data.
489 ulong
vfd_setmem (ulong addr
)
494 frame_buf_size
= (256*4*56)/8;
496 /* Round up to nearest full page */
497 size
= (frame_buf_size
+ (PAGE_SIZE
- 1)) & ~(PAGE_SIZE
- 1);
499 debug ("Reserving %ldk for VFD Framebuffer at: %08lx\n", size
>>10, addr
);
504 #endif /* CONFIG_VFD */