2 * (C) Copyright 2001-2002
5 * SPDX-License-Identifier: GPL-2.0+
8 /************************************************************************/
10 /************************************************************************/
21 #include <linux/types.h>
22 #include <stdio_dev.h>
23 #if defined(CONFIG_POST)
30 /************************************************************************/
31 /* ** CONFIG STUFF -- should be moved to board config file */
32 /************************************************************************/
33 #ifndef CONFIG_LCD_INFO
34 #define CONFIG_LCD_INFO /* Display Logo, (C) and system info */
37 #if defined(CONFIG_EDT32F10)
38 #undef CONFIG_LCD_LOGO
39 #undef CONFIG_LCD_INFO
42 /*----------------------------------------------------------------------*/
43 #ifdef CONFIG_KYOCERA_KCS057QV1AJ
45 * Kyocera KCS057QV1AJ-G23. Passive, color, single scan.
47 #define LCD_BPP LCD_COLOR4
49 vidinfo_t panel_info = {
50 640, 480, 132, 99, CONFIG_SYS_HIGH, CONFIG_SYS_HIGH, CONFIG_SYS_HIGH, CONFIG_SYS_HIGH, CONFIG_SYS_HIGH,
51 LCD_BPP, 1, 0, 1, 0, 5, 0, 0, 0
52 /* wbl, vpw, lcdac, wbf */
54 #endif /* CONFIG_KYOCERA_KCS057QV1AJ */
55 /*----------------------------------------------------------------------*/
57 /*----------------------------------------------------------------------*/
58 #ifdef CONFIG_HITACHI_SP19X001_Z1A
60 * Hitachi SP19X001-. Active, color, single scan.
62 vidinfo_t panel_info = {
63 640, 480, 154, 116, CONFIG_SYS_HIGH, CONFIG_SYS_HIGH, CONFIG_SYS_HIGH, CONFIG_SYS_HIGH, CONFIG_SYS_HIGH,
64 LCD_COLOR8, 1, 0, 1, 0, 0, 0, 0, 0
65 /* wbl, vpw, lcdac, wbf */
67 #endif /* CONFIG_HITACHI_SP19X001_Z1A */
68 /*----------------------------------------------------------------------*/
70 /*----------------------------------------------------------------------*/
71 #ifdef CONFIG_NEC_NL6448AC33
73 * NEC NL6448AC33-18. Active, color, single scan.
75 vidinfo_t panel_info = {
76 640, 480, 132, 99, CONFIG_SYS_HIGH, CONFIG_SYS_HIGH, CONFIG_SYS_LOW, CONFIG_SYS_LOW, CONFIG_SYS_HIGH,
77 3, 0, 0, 1, 1, 144, 2, 0, 33
78 /* wbl, vpw, lcdac, wbf */
80 #endif /* CONFIG_NEC_NL6448AC33 */
81 /*----------------------------------------------------------------------*/
83 #ifdef CONFIG_NEC_NL6448BC20
85 * NEC NL6448BC20-08. 6.5", 640x480. Active, color, single scan.
87 vidinfo_t panel_info = {
88 640, 480, 132, 99, CONFIG_SYS_HIGH, CONFIG_SYS_HIGH, CONFIG_SYS_LOW, CONFIG_SYS_LOW, CONFIG_SYS_HIGH,
89 3, 0, 0, 1, 1, 144, 2, 0, 33
90 /* wbl, vpw, lcdac, wbf */
92 #endif /* CONFIG_NEC_NL6448BC20 */
93 /*----------------------------------------------------------------------*/
95 #ifdef CONFIG_NEC_NL6448BC33_54
97 * NEC NL6448BC33-54. 10.4", 640x480. Active, color, single scan.
99 vidinfo_t panel_info = {
100 640, 480, 212, 158, CONFIG_SYS_HIGH, CONFIG_SYS_HIGH, CONFIG_SYS_LOW, CONFIG_SYS_LOW, CONFIG_SYS_HIGH,
101 3, 0, 0, 1, 1, 144, 2, 0, 33
102 /* wbl, vpw, lcdac, wbf */
104 #endif /* CONFIG_NEC_NL6448BC33_54 */
105 /*----------------------------------------------------------------------*/
107 #ifdef CONFIG_SHARP_LQ104V7DS01
109 * SHARP LQ104V7DS01. 6.5", 640x480. Active, color, single scan.
111 vidinfo_t panel_info = {
112 640, 480, 132, 99, CONFIG_SYS_HIGH, CONFIG_SYS_HIGH, CONFIG_SYS_LOW, CONFIG_SYS_LOW, CONFIG_SYS_LOW,
113 3, 0, 0, 1, 1, 25, 1, 0, 33
114 /* wbl, vpw, lcdac, wbf */
116 #endif /* CONFIG_SHARP_LQ104V7DS01 */
117 /*----------------------------------------------------------------------*/
119 #ifdef CONFIG_SHARP_16x9
121 * Sharp 320x240. Active, color, single scan. It isn't 16x9, and I am
122 * not sure what it is.......
124 vidinfo_t panel_info = {
125 320, 240, 0, 0, CONFIG_SYS_HIGH, CONFIG_SYS_HIGH, CONFIG_SYS_HIGH, CONFIG_SYS_HIGH, CONFIG_SYS_HIGH,
126 3, 0, 0, 1, 1, 15, 4, 0, 3
128 #endif /* CONFIG_SHARP_16x9 */
129 /*----------------------------------------------------------------------*/
131 #ifdef CONFIG_SHARP_LQ057Q3DC02
133 * Sharp LQ057Q3DC02 display. Active, color, single scan.
138 vidinfo_t panel_info = {
139 320, 240, 0, 0, CONFIG_SYS_HIGH, CONFIG_SYS_HIGH, CONFIG_SYS_LOW, CONFIG_SYS_LOW, CONFIG_SYS_HIGH,
140 3, 0, 0, 1, 1, 15, 4, 0, 3
141 /* wbl, vpw, lcdac, wbf */
143 #define CONFIG_LCD_INFO_BELOW_LOGO
144 #endif /* CONFIG_SHARP_LQ057Q3DC02 */
145 /*----------------------------------------------------------------------*/
147 #ifdef CONFIG_SHARP_LQ64D341
149 * Sharp LQ64D341 display, 640x480. Active, color, single scan.
151 vidinfo_t panel_info = {
152 640, 480, 0, 0, CONFIG_SYS_HIGH, CONFIG_SYS_HIGH, CONFIG_SYS_LOW, CONFIG_SYS_LOW, CONFIG_SYS_HIGH,
153 3, 0, 0, 1, 1, 128, 16, 0, 32
154 /* wbl, vpw, lcdac, wbf */
156 #endif /* CONFIG_SHARP_LQ64D341 */
158 #ifdef CONFIG_SHARP_LQ065T9DR51U
160 * Sharp LQ065T9DR51U display, 400x240. Active, color, single scan.
162 vidinfo_t panel_info = {
163 400, 240, 143, 79, CONFIG_SYS_HIGH, CONFIG_SYS_HIGH, CONFIG_SYS_HIGH, CONFIG_SYS_HIGH, CONFIG_SYS_HIGH,
164 3, 0, 0, 1, 1, 248, 4, 0, 35
165 /* wbl, vpw, lcdac, wbf */
167 #define CONFIG_LCD_INFO_BELOW_LOGO
168 #endif /* CONFIG_SHARP_LQ065T9DR51U */
170 #ifdef CONFIG_SHARP_LQ084V1DG21
172 * Sharp LQ084V1DG21 display, 640x480. Active, color, single scan.
174 vidinfo_t panel_info = {
175 640, 480, 171, 129, CONFIG_SYS_HIGH, CONFIG_SYS_HIGH, CONFIG_SYS_LOW, CONFIG_SYS_LOW, CONFIG_SYS_LOW,
176 3, 0, 0, 1, 1, 160, 3, 0, 48
177 /* wbl, vpw, lcdac, wbf */
179 #endif /* CONFIG_SHARP_LQ084V1DG21 */
181 /*----------------------------------------------------------------------*/
183 #ifdef CONFIG_HLD1045
185 * HLD1045 display, 640x480. Active, color, single scan.
187 vidinfo_t panel_info = {
188 640, 480, 0, 0, CONFIG_SYS_HIGH, CONFIG_SYS_HIGH, CONFIG_SYS_LOW, CONFIG_SYS_LOW, CONFIG_SYS_HIGH,
189 3, 0, 0, 1, 1, 160, 3, 0, 48
190 /* wbl, vpw, lcdac, wbf */
192 #endif /* CONFIG_HLD1045 */
193 /*----------------------------------------------------------------------*/
195 #ifdef CONFIG_PRIMEVIEW_V16C6448AC
197 * Prime View V16C6448AC
199 vidinfo_t panel_info = {
200 640, 480, 130, 98, CONFIG_SYS_HIGH, CONFIG_SYS_HIGH, CONFIG_SYS_LOW, CONFIG_SYS_LOW, CONFIG_SYS_HIGH,
201 3, 0, 0, 1, 1, 144, 2, 0, 35
202 /* wbl, vpw, lcdac, wbf */
204 #endif /* CONFIG_PRIMEVIEW_V16C6448AC */
206 /*----------------------------------------------------------------------*/
208 #ifdef CONFIG_OPTREX_BW
210 * Optrex CBL50840-2 NF-FW 99 22 M5
212 * Hitachi LMG6912RPFC-00T
216 * 320x240. Black & white.
218 #define OPTREX_BPP 0 /* 0 - monochrome, 1 bpp */
219 /* 1 - 4 grey levels, 2 bpp */
220 /* 2 - 16 grey levels, 4 bpp */
221 vidinfo_t panel_info = {
222 320, 240, 0, 0, CONFIG_SYS_HIGH, CONFIG_SYS_HIGH, CONFIG_SYS_HIGH, CONFIG_SYS_HIGH, CONFIG_SYS_LOW,
223 OPTREX_BPP, 0, 0, 0, 0, 0, 0, 0, 0, 4
225 #endif /* CONFIG_OPTREX_BW */
227 /*-----------------------------------------------------------------*/
228 #ifdef CONFIG_EDT32F10
230 * Emerging Display Technologies 320x240. Passive, monochrome, single scan.
232 #define LCD_BPP LCD_MONOCHROME
235 vidinfo_t panel_info = {
236 320, 240, 0, 0, CONFIG_SYS_HIGH, CONFIG_SYS_HIGH, CONFIG_SYS_HIGH, CONFIG_SYS_HIGH, CONFIG_SYS_LOW,
237 LCD_BPP, 0, 0, 0, 0, 33, 0, 0, 0
241 /************************************************************************/
242 /* ----------------- chipset specific functions ----------------------- */
243 /************************************************************************/
246 * Calculate fb size for VIDEOLFB_ATAG.
248 ulong calc_fbsize (void)
251 int line_length = (panel_info.vl_col * NBITS (panel_info.vl_bpix)) / 8;
253 size = line_length * panel_info.vl_row;
258 void lcd_ctrl_init (void *lcdbase)
260 volatile immap_t *immr = (immap_t *) CONFIG_SYS_IMMR;
261 volatile lcd823_t *lcdp = &immr->im_lcd;
266 /* Initialize the LCD control register according to the LCD
267 * parameters defined. We do everything here but enable
271 lccrtmp = LCDBIT (LCCR_BNUM_BIT,
272 (((panel_info.vl_row * panel_info.vl_col) * (1 << LCD_BPP)) / 128));
274 lccrtmp |= LCDBIT (LCCR_CLKP_BIT, panel_info.vl_clkp) |
275 LCDBIT (LCCR_OEP_BIT, panel_info.vl_oep) |
276 LCDBIT (LCCR_HSP_BIT, panel_info.vl_hsp) |
277 LCDBIT (LCCR_VSP_BIT, panel_info.vl_vsp) |
278 LCDBIT (LCCR_DP_BIT, panel_info.vl_dp) |
279 LCDBIT (LCCR_BPIX_BIT, panel_info.vl_bpix) |
280 LCDBIT (LCCR_LBW_BIT, panel_info.vl_lbw) |
281 LCDBIT (LCCR_SPLT_BIT, panel_info.vl_splt) |
282 LCDBIT (LCCR_CLOR_BIT, panel_info.vl_clor) |
283 LCDBIT (LCCR_TFT_BIT, panel_info.vl_tft);
286 lccrtmp |= ((SIU_LEVEL5 / 2) << 12);
287 lccrtmp |= LCCR_EIEN;
290 lcdp->lcd_lccr = lccrtmp;
291 lcdp->lcd_lcsr = 0xFF; /* Clear pending interrupts */
293 /* Initialize LCD controller bus priorities.
295 immr->im_siu_conf.sc_sdcr &= ~0x0f; /* RAID = LAID = 0 */
297 /* set SHFT/CLOCK division factor 4
298 * This needs to be set based upon display type and processor
299 * speed. The TFT displays run about 20 to 30 MHz.
300 * I was running 64 MHz processor speed.
301 * The value for this divider must be chosen so the result is
302 * an integer of the processor speed (i.e., divide by 3 with
303 * 64 MHz would be bad).
305 immr->im_clkrst.car_sccr &= ~0x1F;
306 immr->im_clkrst.car_sccr |= LCD_DF; /* was 8 */
308 #if !defined(CONFIG_EDT32F10)
309 /* Enable LCD on port D.
311 immr->im_ioport.iop_pdpar |= 0x1FFF;
312 immr->im_ioport.iop_pddir |= 0x1FFF;
314 /* Enable LCD_A/B/C on port B.
316 immr->im_cpm.cp_pbpar |= 0x00005001;
317 immr->im_cpm.cp_pbdir |= 0x00005001;
319 /* Enable LCD on port D.
321 immr->im_ioport.iop_pdpar |= 0x1DFF;
322 immr->im_ioport.iop_pdpar &= ~0x0200;
323 immr->im_ioport.iop_pddir |= 0x1FFF;
324 immr->im_ioport.iop_pddat |= 0x0200;
327 /* Load the physical address of the linear frame buffer
328 * into the LCD controller.
329 * BIG NOTE: This has to be modified to load A and B depending
330 * upon the split mode of the LCD.
332 lcdp->lcd_lcfaa = (ulong)lcdbase;
333 lcdp->lcd_lcfba = (ulong)lcdbase;
335 /* MORE HACKS...This must be updated according to 823 manual
336 * for different panels.
337 * Udi Finkelstein - done - see below:
338 * Note: You better not try unsupported combinations such as
339 * 4-bit wide passive dual scan LCD at 4/8 Bit color.
343 (panel_info.vl_tft ? 8 :
344 (((2 - panel_info.vl_lbw) << /* 4 bit=2, 8-bit = 1 */
345 /* use << to mult by: single scan = 1, dual scan = 2 */
346 panel_info.vl_splt) *
347 (panel_info.vl_bpix | 1)))) >> 3; /* 2/4 BPP = 1, 8/16 BPP = 3 */
349 lcdp->lcd_lchcr = LCHCR_BO |
350 LCDBIT (LCHCR_AT_BIT, 4) |
351 LCDBIT (LCHCR_HPC_BIT, lchcr_hpc_tmp) |
354 lcdp->lcd_lcvcr = LCDBIT (LCVCR_VPW_BIT, panel_info.vl_vpw) |
355 LCDBIT (LCVCR_LCD_AC_BIT, panel_info.vl_lcdac) |
356 LCDBIT (LCVCR_VPC_BIT, panel_info.vl_row) |
361 /*----------------------------------------------------------------------*/
363 #if LCD_BPP == LCD_COLOR8
365 lcd_setcolreg (ushort regno, ushort red, ushort green, ushort blue)
367 volatile immap_t *immr = (immap_t *) CONFIG_SYS_IMMR;
368 volatile cpm8xx_t *cp = &(immr->im_cpm);
369 unsigned short colreg, *cmap_ptr;
371 cmap_ptr = (unsigned short *)&cp->lcd_cmap[regno * 2];
373 colreg = ((red & 0x0F) << 8) |
374 ((green & 0x0F) << 4) |
379 debug ("setcolreg: reg %2d @ %p: R=%02X G=%02X B=%02X => %02X%02X\n",
380 regno, &(cp->lcd_cmap[regno * 2]),
382 cp->lcd_cmap[ regno * 2 ], cp->lcd_cmap[(regno * 2) + 1]);
384 #endif /* LCD_COLOR8 */
386 /*----------------------------------------------------------------------*/
388 #if LCD_BPP == LCD_MONOCHROME
390 void lcd_initcolregs (void)
392 volatile immap_t *immr = (immap_t *) CONFIG_SYS_IMMR;
393 volatile cpm8xx_t *cp = &(immr->im_cpm);
396 for (regno = 0; regno < 16; regno++) {
397 cp->lcd_cmap[regno * 2] = 0;
398 cp->lcd_cmap[(regno * 2) + 1] = regno & 0x0f;
403 /*----------------------------------------------------------------------*/
405 void lcd_enable (void)
407 volatile immap_t *immr = (immap_t *) CONFIG_SYS_IMMR;
408 volatile lcd823_t *lcdp = &immr->im_lcd;
410 /* Enable the LCD panel */
411 immr->im_siu_conf.sc_sdcr |= (1 << (31 - 25)); /* LAM = 1 */
412 lcdp->lcd_lccr |= LCCR_PON;
415 /************************************************************************/
417 #endif /* CONFIG_LCD */