blob: cc58676868bf80215aa94ab9feca0fdb63478cc4 [file] [log] [blame]
wdenk5b1d7132002-11-03 00:07:02 +00001/*
2 * (C) Copyright 2001-2002
3 * Wolfgang Denk, DENX Software Engineering -- wd@denx.de
4 *
5 * See file CREDITS for list of people who contributed to this
6 * project.
7 *
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.
12 *
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.
17 *
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,
21 * MA 02111-1307 USA
22 */
23
24/************************************************************************/
25/* ** HEADER FILES */
26/************************************************************************/
27
wdenk8564acf2003-07-14 22:13:32 +000028/* #define DEBUG */
29
wdenk5b1d7132002-11-03 00:07:02 +000030#include <config.h>
31#include <common.h>
wdenkc3f4d172004-06-25 23:35:58 +000032#include <command.h>
wdenk7aa78612003-05-03 15:50:43 +000033#include <watchdog.h>
wdenk5b1d7132002-11-03 00:07:02 +000034#include <version.h>
35#include <stdarg.h>
36#include <lcdvideo.h>
37#include <linux/types.h>
38#include <devices.h>
wdenk4532cb62003-04-27 22:52:51 +000039#if defined(CONFIG_POST)
40#include <post.h>
41#endif
wdenk682011f2003-06-03 23:54:09 +000042#include <lcd.h>
wdenk5b1d7132002-11-03 00:07:02 +000043
44#ifdef CONFIG_LCD
45
46/************************************************************************/
47/* ** CONFIG STUFF -- should be moved to board config file */
48/************************************************************************/
wdenk5b1d7132002-11-03 00:07:02 +000049#define CONFIG_LCD_LOGO
50#define LCD_INFO /* Display Logo, (C) and system info */
wdenk608c9142003-01-13 23:54:46 +000051
wdenkd791b1d2003-04-20 14:04:18 +000052#if defined(CONFIG_V37) || defined(CONFIG_EDT32F10)
wdenk608c9142003-01-13 23:54:46 +000053#undef CONFIG_LCD_LOGO
54#undef LCD_INFO
55#endif
56
wdenk5b1d7132002-11-03 00:07:02 +000057/*----------------------------------------------------------------------*/
58#ifdef CONFIG_KYOCERA_KCS057QV1AJ
59/*
60 * Kyocera KCS057QV1AJ-G23. Passive, color, single scan.
61 */
62#define LCD_BPP LCD_COLOR4
63
wdenk8655b6f2004-10-09 23:25:58 +000064vidinfo_t panel_info = {
wdenk5b1d7132002-11-03 00:07:02 +000065 640, 480, 132, 99, CFG_HIGH, CFG_HIGH, CFG_HIGH, CFG_HIGH, CFG_HIGH,
66 LCD_BPP, 1, 0, 1, 0, 5, 0, 0, 0
67 /* wbl, vpw, lcdac, wbf */
68};
69#endif /* CONFIG_KYOCERA_KCS057QV1AJ */
70/*----------------------------------------------------------------------*/
71
72/*----------------------------------------------------------------------*/
wdenk682011f2003-06-03 23:54:09 +000073#ifdef CONFIG_HITACHI_SP19X001_Z1A
74/*
75 * Hitachi SP19X001-. Active, color, single scan.
76 */
wdenk8655b6f2004-10-09 23:25:58 +000077vidinfo_t panel_info = {
wdenk682011f2003-06-03 23:54:09 +000078 640, 480, 154, 116, CFG_HIGH, CFG_HIGH, CFG_HIGH, CFG_HIGH, CFG_HIGH,
79 LCD_COLOR8, 1, 0, 1, 0, 0, 0, 0, 0
80 /* wbl, vpw, lcdac, wbf */
81};
82#endif /* CONFIG_HITACHI_SP19X001_Z1A */
83/*----------------------------------------------------------------------*/
84
85/*----------------------------------------------------------------------*/
wdenkfd3103b2003-11-25 16:55:19 +000086#ifdef CONFIG_NEC_NL6448AC33
wdenk5b1d7132002-11-03 00:07:02 +000087/*
wdenkfd3103b2003-11-25 16:55:19 +000088 * NEC NL6448AC33-18. Active, color, single scan.
wdenk5b1d7132002-11-03 00:07:02 +000089 */
wdenk8655b6f2004-10-09 23:25:58 +000090vidinfo_t panel_info = {
wdenk5b1d7132002-11-03 00:07:02 +000091 640, 480, 132, 99, CFG_HIGH, CFG_HIGH, CFG_LOW, CFG_LOW, CFG_HIGH,
92 3, 0, 0, 1, 1, 144, 2, 0, 33
93 /* wbl, vpw, lcdac, wbf */
94};
wdenkfd3103b2003-11-25 16:55:19 +000095#endif /* CONFIG_NEC_NL6448AC33 */
wdenk5b1d7132002-11-03 00:07:02 +000096/*----------------------------------------------------------------------*/
97
wdenkfd3103b2003-11-25 16:55:19 +000098#ifdef CONFIG_NEC_NL6448BC20
wdenk5b1d7132002-11-03 00:07:02 +000099/*
wdenkfd3103b2003-11-25 16:55:19 +0000100 * NEC NL6448BC20-08. 6.5", 640x480. Active, color, single scan.
wdenk5b1d7132002-11-03 00:07:02 +0000101 */
wdenk8655b6f2004-10-09 23:25:58 +0000102vidinfo_t panel_info = {
wdenk5b1d7132002-11-03 00:07:02 +0000103 640, 480, 132, 99, CFG_HIGH, CFG_HIGH, CFG_LOW, CFG_LOW, CFG_HIGH,
104 3, 0, 0, 1, 1, 144, 2, 0, 33
105 /* wbl, vpw, lcdac, wbf */
106};
wdenkfd3103b2003-11-25 16:55:19 +0000107#endif /* CONFIG_NEC_NL6448BC20 */
108/*----------------------------------------------------------------------*/
109
110#ifdef CONFIG_NEC_NL6448BC33_54
111/*
112 * NEC NL6448BC33-54. 10.4", 640x480. Active, color, single scan.
113 */
wdenk8655b6f2004-10-09 23:25:58 +0000114vidinfo_t panel_info = {
wdenkfd3103b2003-11-25 16:55:19 +0000115 640, 480, 212, 158, CFG_HIGH, CFG_HIGH, CFG_LOW, CFG_LOW, CFG_HIGH,
116 3, 0, 0, 1, 1, 144, 2, 0, 33
117 /* wbl, vpw, lcdac, wbf */
118};
119#endif /* CONFIG_NEC_NL6448BC33_54 */
wdenk5b1d7132002-11-03 00:07:02 +0000120/*----------------------------------------------------------------------*/
121
122#ifdef CONFIG_SHARP_LQ104V7DS01
123/*
124 * SHARP LQ104V7DS01. 6.5", 640x480. Active, color, single scan.
125 */
wdenk8655b6f2004-10-09 23:25:58 +0000126vidinfo_t panel_info = {
wdenk5b1d7132002-11-03 00:07:02 +0000127 640, 480, 132, 99, CFG_HIGH, CFG_HIGH, CFG_LOW, CFG_LOW, CFG_LOW,
128 3, 0, 0, 1, 1, 25, 1, 0, 33
129 /* wbl, vpw, lcdac, wbf */
130};
131#endif /* CONFIG_SHARP_LQ104V7DS01 */
132/*----------------------------------------------------------------------*/
133
134#ifdef CONFIG_SHARP_16x9
135/*
136 * Sharp 320x240. Active, color, single scan. It isn't 16x9, and I am
137 * not sure what it is.......
138 */
wdenk8655b6f2004-10-09 23:25:58 +0000139vidinfo_t panel_info = {
wdenk5b1d7132002-11-03 00:07:02 +0000140 320, 240, 0, 0, CFG_HIGH, CFG_HIGH, CFG_HIGH, CFG_HIGH, CFG_HIGH,
141 3, 0, 0, 1, 1, 15, 4, 0, 3
142};
143#endif /* CONFIG_SHARP_16x9 */
144/*----------------------------------------------------------------------*/
145
146#ifdef CONFIG_SHARP_LQ057Q3DC02
147/*
148 * Sharp LQ057Q3DC02 display. Active, color, single scan.
149 */
wdenk8655b6f2004-10-09 23:25:58 +0000150#undef LCD_DF
wdenk4a6fd342003-04-12 23:38:12 +0000151#define LCD_DF 12
152
wdenk8655b6f2004-10-09 23:25:58 +0000153vidinfo_t panel_info = {
wdenk5b1d7132002-11-03 00:07:02 +0000154 320, 240, 0, 0, CFG_HIGH, CFG_HIGH, CFG_LOW, CFG_LOW, CFG_HIGH,
155 3, 0, 0, 1, 1, 15, 4, 0, 3
156 /* wbl, vpw, lcdac, wbf */
157};
158#define LCD_INFO_BELOW_LOGO
159#endif /* CONFIG_SHARP_LQ057Q3DC02 */
160/*----------------------------------------------------------------------*/
161
162#ifdef CONFIG_SHARP_LQ64D341
163/*
164 * Sharp LQ64D341 display, 640x480. Active, color, single scan.
165 */
wdenk8655b6f2004-10-09 23:25:58 +0000166vidinfo_t panel_info = {
wdenk5b1d7132002-11-03 00:07:02 +0000167 640, 480, 0, 0, CFG_HIGH, CFG_HIGH, CFG_LOW, CFG_LOW, CFG_HIGH,
168 3, 0, 0, 1, 1, 128, 16, 0, 32
169 /* wbl, vpw, lcdac, wbf */
170};
171#endif /* CONFIG_SHARP_LQ64D341 */
wdenk608c9142003-01-13 23:54:46 +0000172
dzu29127b62003-09-25 22:30:12 +0000173#ifdef CONFIG_SHARP_LQ065T9DR51U
174/*
175 * Sharp LQ065T9DR51U display, 400x240. Active, color, single scan.
176 */
wdenk8655b6f2004-10-09 23:25:58 +0000177vidinfo_t panel_info = {
dzu29127b62003-09-25 22:30:12 +0000178 400, 240, 143, 79, CFG_HIGH, CFG_HIGH, CFG_HIGH, CFG_HIGH, CFG_HIGH,
179 3, 0, 0, 1, 1, 248, 4, 0, 35
180 /* wbl, vpw, lcdac, wbf */
181};
182#define LCD_INFO_BELOW_LOGO
183#endif /* CONFIG_SHARP_LQ065T9DR51U */
184
wdenk608c9142003-01-13 23:54:46 +0000185#ifdef CONFIG_SHARP_LQ084V1DG21
186/*
187 * Sharp LQ084V1DG21 display, 640x480. Active, color, single scan.
188 */
wdenk8655b6f2004-10-09 23:25:58 +0000189vidinfo_t panel_info = {
wdenk608c9142003-01-13 23:54:46 +0000190 640, 480, 171, 129, CFG_HIGH, CFG_HIGH, CFG_LOW, CFG_LOW, CFG_LOW,
191 3, 0, 0, 1, 1, 160, 3, 0, 48
192 /* wbl, vpw, lcdac, wbf */
193};
194#endif /* CONFIG_SHARP_LQ084V1DG21 */
195
wdenk5b1d7132002-11-03 00:07:02 +0000196/*----------------------------------------------------------------------*/
197
198#ifdef CONFIG_HLD1045
199/*
200 * HLD1045 display, 640x480. Active, color, single scan.
201 */
wdenk8655b6f2004-10-09 23:25:58 +0000202vidinfo_t panel_info = {
wdenk5b1d7132002-11-03 00:07:02 +0000203 640, 480, 0, 0, CFG_HIGH, CFG_HIGH, CFG_LOW, CFG_LOW, CFG_HIGH,
204 3, 0, 0, 1, 1, 160, 3, 0, 48
205 /* wbl, vpw, lcdac, wbf */
206};
207#endif /* CONFIG_HLD1045 */
208/*----------------------------------------------------------------------*/
209
210#ifdef CONFIG_PRIMEVIEW_V16C6448AC
211/*
212 * Prime View V16C6448AC
213 */
wdenk8655b6f2004-10-09 23:25:58 +0000214vidinfo_t panel_info = {
wdenk5b1d7132002-11-03 00:07:02 +0000215 640, 480, 130, 98, CFG_HIGH, CFG_HIGH, CFG_LOW, CFG_LOW, CFG_HIGH,
216 3, 0, 0, 1, 1, 144, 2, 0, 35
217 /* wbl, vpw, lcdac, wbf */
218};
219#endif /* CONFIG_PRIMEVIEW_V16C6448AC */
220
221/*----------------------------------------------------------------------*/
222
223#ifdef CONFIG_OPTREX_BW
224/*
225 * Optrex CBL50840-2 NF-FW 99 22 M5
226 * or
227 * Hitachi LMG6912RPFC-00T
228 * or
229 * Hitachi SP14Q002
230 *
231 * 320x240. Black & white.
232 */
233#define OPTREX_BPP 0 /* 0 - monochrome, 1 bpp */
234 /* 1 - 4 grey levels, 2 bpp */
235 /* 2 - 16 grey levels, 4 bpp */
wdenk8655b6f2004-10-09 23:25:58 +0000236vidinfo_t panel_info = {
wdenk5b1d7132002-11-03 00:07:02 +0000237 320, 240, 0, 0, CFG_HIGH, CFG_HIGH, CFG_HIGH, CFG_HIGH, CFG_LOW,
238 OPTREX_BPP, 0, 0, 0, 0, 0, 0, 0, 0, 4
239};
240#endif /* CONFIG_OPTREX_BW */
241
242/*-----------------------------------------------------------------*/
243#ifdef CONFIG_EDT32F10
244/*
245 * Emerging Display Technologies 320x240. Passive, monochrome, single scan.
246 */
247#define LCD_BPP LCD_MONOCHROME
wdenk4a6fd342003-04-12 23:38:12 +0000248#define LCD_DF 10
wdenk5b1d7132002-11-03 00:07:02 +0000249
wdenk8655b6f2004-10-09 23:25:58 +0000250vidinfo_t panel_info = {
wdenk5b1d7132002-11-03 00:07:02 +0000251 320, 240, 0, 0, CFG_HIGH, CFG_HIGH, CFG_HIGH, CFG_HIGH, CFG_LOW,
wdenk4a6fd342003-04-12 23:38:12 +0000252 LCD_BPP, 0, 0, 0, 0, 33, 0, 0, 0
wdenk5b1d7132002-11-03 00:07:02 +0000253};
254#endif
255/*----------------------------------------------------------------------*/
256
wdenk5b1d7132002-11-03 00:07:02 +0000257
wdenk8655b6f2004-10-09 23:25:58 +0000258int lcd_line_length;
wdenk5b1d7132002-11-03 00:07:02 +0000259
wdenk8655b6f2004-10-09 23:25:58 +0000260int lcd_color_fg;
261int lcd_color_bg;
wdenk5b1d7132002-11-03 00:07:02 +0000262
263/*
264 * Frame buffer memory information
265 */
wdenk8655b6f2004-10-09 23:25:58 +0000266void *lcd_base; /* Start of framebuffer memory */
267void *lcd_console_address; /* Start of console buffer */
wdenk5b1d7132002-11-03 00:07:02 +0000268
wdenk8655b6f2004-10-09 23:25:58 +0000269short console_col;
270short console_row;
wdenk5b1d7132002-11-03 00:07:02 +0000271
272/************************************************************************/
273
wdenk8655b6f2004-10-09 23:25:58 +0000274void lcd_ctrl_init (void *lcdbase);
275void lcd_enable (void);
wdenk5b1d7132002-11-03 00:07:02 +0000276#if LCD_BPP == LCD_COLOR8
wdenk8655b6f2004-10-09 23:25:58 +0000277void lcd_setcolreg (ushort regno,
wdenk5b1d7132002-11-03 00:07:02 +0000278 ushort red, ushort green, ushort blue);
279#endif
280#if LCD_BPP == LCD_MONOCHROME
wdenk8655b6f2004-10-09 23:25:58 +0000281void lcd_initcolregs (void);
wdenk5b1d7132002-11-03 00:07:02 +0000282#endif
wdenk5b1d7132002-11-03 00:07:02 +0000283
wdenk682011f2003-06-03 23:54:09 +0000284#if defined(CONFIG_RBC823)
wdenk8655b6f2004-10-09 23:25:58 +0000285void lcd_disable (void);
wdenk682011f2003-06-03 23:54:09 +0000286#endif
287
wdenk5b1d7132002-11-03 00:07:02 +0000288/************************************************************************/
289
wdenk5b1d7132002-11-03 00:07:02 +0000290/************************************************************************/
291/* ----------------- chipset specific functions ----------------------- */
292/************************************************************************/
293
wdenk8655b6f2004-10-09 23:25:58 +0000294/*
295 * Calculate fb size for VIDEOLFB_ATAG.
296 */
297ulong calc_fbsize (void)
298{
299 ulong size;
300 int line_length = (panel_info.vl_col * NBITS (panel_info.vl_bpix)) / 8;
301
302 size = line_length * panel_info.vl_row;
303
304 return size;
305}
306
307void lcd_ctrl_init (void *lcdbase)
wdenk5b1d7132002-11-03 00:07:02 +0000308{
309 volatile immap_t *immr = (immap_t *) CFG_IMMR;
310 volatile lcd823_t *lcdp = &immr->im_lcd;
311
312 uint lccrtmp;
wdenk682011f2003-06-03 23:54:09 +0000313 uint lchcr_hpc_tmp;
wdenk5b1d7132002-11-03 00:07:02 +0000314
315 /* Initialize the LCD control register according to the LCD
316 * parameters defined. We do everything here but enable
317 * the controller.
318 */
319
wdenke63c8ee2004-06-09 21:04:48 +0000320#ifdef CONFIG_RPXLITE
321 /* This is special for RPXlite_DW Software Development Platform **[Sam]** */
322 panel_info.vl_dp = CFG_LOW;
323#endif
324
wdenk5b1d7132002-11-03 00:07:02 +0000325 lccrtmp = LCDBIT (LCCR_BNUM_BIT,
326 (((panel_info.vl_row * panel_info.vl_col) * (1 << LCD_BPP)) / 128));
327
328 lccrtmp |= LCDBIT (LCCR_CLKP_BIT, panel_info.vl_clkp) |
329 LCDBIT (LCCR_OEP_BIT, panel_info.vl_oep) |
330 LCDBIT (LCCR_HSP_BIT, panel_info.vl_hsp) |
331 LCDBIT (LCCR_VSP_BIT, panel_info.vl_vsp) |
332 LCDBIT (LCCR_DP_BIT, panel_info.vl_dp) |
333 LCDBIT (LCCR_BPIX_BIT, panel_info.vl_bpix) |
334 LCDBIT (LCCR_LBW_BIT, panel_info.vl_lbw) |
335 LCDBIT (LCCR_SPLT_BIT, panel_info.vl_splt) |
336 LCDBIT (LCCR_CLOR_BIT, panel_info.vl_clor) |
337 LCDBIT (LCCR_TFT_BIT, panel_info.vl_tft);
338
339#if 0
340 lccrtmp |= ((SIU_LEVEL5 / 2) << 12);
341 lccrtmp |= LCCR_EIEN;
342#endif
343
344 lcdp->lcd_lccr = lccrtmp;
345 lcdp->lcd_lcsr = 0xFF; /* Clear pending interrupts */
346
347 /* Initialize LCD controller bus priorities.
348 */
wdenk682011f2003-06-03 23:54:09 +0000349#ifdef CONFIG_RBC823
350 immr->im_siu_conf.sc_sdcr = (immr->im_siu_conf.sc_sdcr & ~0x0f) | 1; /* RAID = 01, LAID = 00 */
351#else
wdenk5b1d7132002-11-03 00:07:02 +0000352 immr->im_siu_conf.sc_sdcr &= ~0x0f; /* RAID = LAID = 0 */
353
354 /* set SHFT/CLOCK division factor 4
355 * This needs to be set based upon display type and processor
356 * speed. The TFT displays run about 20 to 30 MHz.
357 * I was running 64 MHz processor speed.
358 * The value for this divider must be chosen so the result is
359 * an integer of the processor speed (i.e., divide by 3 with
360 * 64 MHz would be bad).
361 */
362 immr->im_clkrst.car_sccr &= ~0x1F;
363 immr->im_clkrst.car_sccr |= LCD_DF; /* was 8 */
364
wdenk682011f2003-06-03 23:54:09 +0000365#endif /* CONFIG_RBC823 */
366
367#if defined(CONFIG_RBC823)
368 /* Enable LCD on port D.
369 */
370 immr->im_ioport.iop_pddat &= 0x0300;
371 immr->im_ioport.iop_pdpar |= 0x1CFF;
372 immr->im_ioport.iop_pddir |= 0x1CFF;
373
374 /* Configure LCD_ON, VEE_ON, CCFL_ON on port B.
375 */
376 immr->im_cpm.cp_pbdat &= ~0x00005001;
377 immr->im_cpm.cp_pbpar &= ~0x00005001;
378 immr->im_cpm.cp_pbdir |= 0x00005001;
379#elif !defined(CONFIG_EDT32F10)
wdenk5b1d7132002-11-03 00:07:02 +0000380 /* Enable LCD on port D.
381 */
382 immr->im_ioport.iop_pdpar |= 0x1FFF;
383 immr->im_ioport.iop_pddir |= 0x1FFF;
384
385 /* Enable LCD_A/B/C on port B.
386 */
387 immr->im_cpm.cp_pbpar |= 0x00005001;
388 immr->im_cpm.cp_pbdir |= 0x00005001;
389#else
390 /* Enable LCD on port D.
391 */
392 immr->im_ioport.iop_pdpar |= 0x1DFF;
393 immr->im_ioport.iop_pdpar &= ~0x0200;
394 immr->im_ioport.iop_pddir |= 0x1FFF;
395 immr->im_ioport.iop_pddat |= 0x0200;
396#endif
397
398 /* Load the physical address of the linear frame buffer
399 * into the LCD controller.
400 * BIG NOTE: This has to be modified to load A and B depending
401 * upon the split mode of the LCD.
402 */
403 lcdp->lcd_lcfaa = (ulong)lcd_base;
404 lcdp->lcd_lcfba = (ulong)lcd_base;
405
406 /* MORE HACKS...This must be updated according to 823 manual
407 * for different panels.
wdenk682011f2003-06-03 23:54:09 +0000408 * Udi Finkelstein - done - see below:
409 * Note: You better not try unsupported combinations such as
410 * 4-bit wide passive dual scan LCD at 4/8 Bit color.
wdenk5b1d7132002-11-03 00:07:02 +0000411 */
wdenk682011f2003-06-03 23:54:09 +0000412 lchcr_hpc_tmp =
wdenk8bde7f72003-06-27 21:31:46 +0000413 (panel_info.vl_col *
wdenk682011f2003-06-03 23:54:09 +0000414 (panel_info.vl_tft ? 8 :
415 (((2 - panel_info.vl_lbw) << /* 4 bit=2, 8-bit = 1 */
416 /* use << to mult by: single scan = 1, dual scan = 2 */
417 panel_info.vl_splt) *
418 (panel_info.vl_bpix | 1)))) >> 3; /* 2/4 BPP = 1, 8/16 BPP = 3 */
419
wdenk5b1d7132002-11-03 00:07:02 +0000420 lcdp->lcd_lchcr = LCHCR_BO |
421 LCDBIT (LCHCR_AT_BIT, 4) |
wdenk682011f2003-06-03 23:54:09 +0000422 LCDBIT (LCHCR_HPC_BIT, lchcr_hpc_tmp) |
wdenk5b1d7132002-11-03 00:07:02 +0000423 panel_info.vl_wbl;
wdenk5b1d7132002-11-03 00:07:02 +0000424
425 lcdp->lcd_lcvcr = LCDBIT (LCVCR_VPW_BIT, panel_info.vl_vpw) |
426 LCDBIT (LCVCR_LCD_AC_BIT, panel_info.vl_lcdac) |
427 LCDBIT (LCVCR_VPC_BIT, panel_info.vl_row) |
428 panel_info.vl_wbf;
429
430}
431
432/*----------------------------------------------------------------------*/
433
434#ifdef NOT_USED_SO_FAR
435static void
436lcd_getcolreg (ushort regno, ushort *red, ushort *green, ushort *blue)
437{
438 volatile immap_t *immr = (immap_t *) CFG_IMMR;
439 volatile cpm8xx_t *cp = &(immr->im_cpm);
440 unsigned short colreg, *cmap_ptr;
441
442 cmap_ptr = (unsigned short *)&cp->lcd_cmap[regno * 2];
443
444 colreg = *cmap_ptr;
445#ifdef CFG_INVERT_COLORS
446 colreg ^= 0x0FFF;
447#endif
448
449 *red = (colreg >> 8) & 0x0F;
450 *green = (colreg >> 4) & 0x0F;
451 *blue = colreg & 0x0F;
452}
453#endif /* NOT_USED_SO_FAR */
454
455/*----------------------------------------------------------------------*/
456
457#if LCD_BPP == LCD_COLOR8
wdenk8655b6f2004-10-09 23:25:58 +0000458void
wdenk5b1d7132002-11-03 00:07:02 +0000459lcd_setcolreg (ushort regno, ushort red, ushort green, ushort blue)
460{
461 volatile immap_t *immr = (immap_t *) CFG_IMMR;
462 volatile cpm8xx_t *cp = &(immr->im_cpm);
463 unsigned short colreg, *cmap_ptr;
464
465 cmap_ptr = (unsigned short *)&cp->lcd_cmap[regno * 2];
466
467 colreg = ((red & 0x0F) << 8) |
468 ((green & 0x0F) << 4) |
469 (blue & 0x0F) ;
470#ifdef CFG_INVERT_COLORS
471 colreg ^= 0x0FFF;
472#endif
473 *cmap_ptr = colreg;
474
475 debug ("setcolreg: reg %2d @ %p: R=%02X G=%02X B=%02X => %02X%02X\n",
476 regno, &(cp->lcd_cmap[regno * 2]),
477 red, green, blue,
wdenk8bde7f72003-06-27 21:31:46 +0000478 cp->lcd_cmap[ regno * 2 ], cp->lcd_cmap[(regno * 2) + 1]);
wdenk5b1d7132002-11-03 00:07:02 +0000479}
480#endif /* LCD_COLOR8 */
481
482/*----------------------------------------------------------------------*/
483
484#if LCD_BPP == LCD_MONOCHROME
485static
486void lcd_initcolregs (void)
487{
488 volatile immap_t *immr = (immap_t *) CFG_IMMR;
489 volatile cpm8xx_t *cp = &(immr->im_cpm);
490 ushort regno;
491
492 for (regno = 0; regno < 16; regno++) {
493 cp->lcd_cmap[regno * 2] = 0;
494 cp->lcd_cmap[(regno * 2) + 1] = regno & 0x0f;
495 }
496}
497#endif
498
499/*----------------------------------------------------------------------*/
500
wdenk8655b6f2004-10-09 23:25:58 +0000501void lcd_enable (void)
wdenk5b1d7132002-11-03 00:07:02 +0000502{
503 volatile immap_t *immr = (immap_t *) CFG_IMMR;
504 volatile lcd823_t *lcdp = &immr->im_lcd;
505
506 /* Enable the LCD panel */
wdenk682011f2003-06-03 23:54:09 +0000507#ifndef CONFIG_RBC823
wdenk5b1d7132002-11-03 00:07:02 +0000508 immr->im_siu_conf.sc_sdcr |= (1 << (31 - 25)); /* LAM = 1 */
wdenk682011f2003-06-03 23:54:09 +0000509#endif
wdenk5b1d7132002-11-03 00:07:02 +0000510 lcdp->lcd_lccr |= LCCR_PON;
wdenk608c9142003-01-13 23:54:46 +0000511
512#ifdef CONFIG_V37
513 /* Turn on display backlight */
514 immr->im_cpm.cp_pbpar |= 0x00008000;
515 immr->im_cpm.cp_pbdir |= 0x00008000;
wdenk682011f2003-06-03 23:54:09 +0000516#elif defined(CONFIG_RBC823)
517 /* Turn on display backlight */
518 immr->im_cpm.cp_pbdat |= 0x00004000;
wdenk608c9142003-01-13 23:54:46 +0000519#endif
520
wdenk5b1d7132002-11-03 00:07:02 +0000521#if defined(CONFIG_LWMON)
522 { uchar c = pic_read (0x60);
wdenk4532cb62003-04-27 22:52:51 +0000523#if defined(CONFIG_LCD) && defined(CONFIG_LWMON) && (CONFIG_POST & CFG_POST_SYSMON)
wdenk7d7ce412004-03-17 01:13:07 +0000524 /* Enable LCD later in sysmon test, only if temperature is OK */
wdenk4532cb62003-04-27 22:52:51 +0000525#else
wdenk8bde7f72003-06-27 21:31:46 +0000526 c |= 0x07; /* Power on CCFL, Enable CCFL, Chip Enable LCD */
wdenk4532cb62003-04-27 22:52:51 +0000527#endif
wdenk5b1d7132002-11-03 00:07:02 +0000528 pic_write (0x60, c);
529 }
wdenk5b1d7132002-11-03 00:07:02 +0000530#endif /* CONFIG_LWMON */
wdenk4a6fd342003-04-12 23:38:12 +0000531
532#if defined(CONFIG_R360MPI)
533 {
534 extern void r360_i2c_lcd_write (uchar data0, uchar data1);
wdenkcb4dbb72003-07-16 16:40:22 +0000535 unsigned long bgi, ctr;
536 char *p;
537
538 if ((p = getenv("lcdbgi")) != NULL) {
539 bgi = simple_strtoul (p, 0, 10) & 0xFFF;
540 } else {
541 bgi = 0xFFF;
542 }
543
544 if ((p = getenv("lcdctr")) != NULL) {
545 ctr = simple_strtoul (p, 0, 10) & 0xFFF;
546 } else {
547 ctr=0x7FF;
548 }
wdenk4a6fd342003-04-12 23:38:12 +0000549
550 r360_i2c_lcd_write(0x10, 0x01);
551 r360_i2c_lcd_write(0x20, 0x01);
wdenkcb4dbb72003-07-16 16:40:22 +0000552 r360_i2c_lcd_write(0x30 | ((bgi>>8) & 0xF), bgi & 0xFF);
553 r360_i2c_lcd_write(0x40 | ((ctr>>8) & 0xF), ctr & 0xFF);
wdenk4a6fd342003-04-12 23:38:12 +0000554 }
555#endif /* CONFIG_R360MPI */
wdenk682011f2003-06-03 23:54:09 +0000556#ifdef CONFIG_RBC823
557 udelay(200000); /* wait 200ms */
558 /* Turn VEE_ON first */
559 immr->im_cpm.cp_pbdat |= 0x00000001;
560 udelay(200000); /* wait 200ms */
561 /* Now turn on LCD_ON */
562 immr->im_cpm.cp_pbdat |= 0x00001000;
563#endif
wdenk8564acf2003-07-14 22:13:32 +0000564#ifdef CONFIG_RRVISION
565 debug ("PC4->Output(1): enable LVDS\n");
566 debug ("PC5->Output(0): disable PAL clock\n");
567 immr->im_ioport.iop_pddir |= 0x1000;
568 immr->im_ioport.iop_pcpar &= ~(0x0C00);
569 immr->im_ioport.iop_pcdir |= 0x0C00 ;
570 immr->im_ioport.iop_pcdat |= 0x0800 ;
571 immr->im_ioport.iop_pcdat &= ~(0x0400);
572 debug ("PDPAR=0x%04X PDDIR=0x%04X PDDAT=0x%04X\n",
573 immr->im_ioport.iop_pdpar,
574 immr->im_ioport.iop_pddir,
575 immr->im_ioport.iop_pddat);
576 debug ("PCPAR=0x%04X PCDIR=0x%04X PCDAT=0x%04X\n",
577 immr->im_ioport.iop_pcpar,
578 immr->im_ioport.iop_pcdir,
579 immr->im_ioport.iop_pcdat);
580#endif
wdenk5b1d7132002-11-03 00:07:02 +0000581}
582
583/*----------------------------------------------------------------------*/
584
wdenk682011f2003-06-03 23:54:09 +0000585#if defined (CONFIG_RBC823)
586void lcd_disable (void)
wdenk5b1d7132002-11-03 00:07:02 +0000587{
588 volatile immap_t *immr = (immap_t *) CFG_IMMR;
589 volatile lcd823_t *lcdp = &immr->im_lcd;
590
591#if defined(CONFIG_LWMON)
592 { uchar c = pic_read (0x60);
wdenk8bde7f72003-06-27 21:31:46 +0000593 c &= ~0x07; /* Power off CCFL, Disable CCFL, Chip Disable LCD */
wdenk5b1d7132002-11-03 00:07:02 +0000594 pic_write (0x60, c);
595 }
596#elif defined(CONFIG_R360MPI)
597 {
wdenk4a6fd342003-04-12 23:38:12 +0000598 extern void r360_i2c_lcd_write (uchar data0, uchar data1);
wdenk5b1d7132002-11-03 00:07:02 +0000599
wdenk4a6fd342003-04-12 23:38:12 +0000600 r360_i2c_lcd_write(0x10, 0x00);
601 r360_i2c_lcd_write(0x20, 0x00);
602 r360_i2c_lcd_write(0x30, 0x00);
603 r360_i2c_lcd_write(0x40, 0x00);
wdenk5b1d7132002-11-03 00:07:02 +0000604 }
605#endif /* CONFIG_LWMON */
606 /* Disable the LCD panel */
607 lcdp->lcd_lccr &= ~LCCR_PON;
wdenk682011f2003-06-03 23:54:09 +0000608#ifdef CONFIG_RBC823
609 /* Turn off display backlight, VEE and LCD_ON */
610 immr->im_cpm.cp_pbdat &= ~0x00005001;
611#else
wdenk5b1d7132002-11-03 00:07:02 +0000612 immr->im_siu_conf.sc_sdcr &= ~(1 << (31 - 25)); /* LAM = 0 */
wdenk682011f2003-06-03 23:54:09 +0000613#endif /* CONFIG_RBC823 */
wdenk5b1d7132002-11-03 00:07:02 +0000614}
wdenk682011f2003-06-03 23:54:09 +0000615#endif /* NOT_USED_SO_FAR || CONFIG_RBC823 */
wdenk5b1d7132002-11-03 00:07:02 +0000616
617
618/************************************************************************/
wdenk5b1d7132002-11-03 00:07:02 +0000619
620#endif /* CONFIG_LCD */