lcd.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620
  1. /*
  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. /* ** HEADER FILES */
  25. /************************************************************************/
  26. /* #define DEBUG */
  27. #include <config.h>
  28. #include <common.h>
  29. #include <command.h>
  30. #include <watchdog.h>
  31. #include <version.h>
  32. #include <stdarg.h>
  33. #include <lcdvideo.h>
  34. #include <linux/types.h>
  35. #include <devices.h>
  36. #if defined(CONFIG_POST)
  37. #include <post.h>
  38. #endif
  39. #include <lcd.h>
  40. #ifdef CONFIG_LCD
  41. /************************************************************************/
  42. /* ** CONFIG STUFF -- should be moved to board config file */
  43. /************************************************************************/
  44. #define CONFIG_LCD_LOGO
  45. #define LCD_INFO /* Display Logo, (C) and system info */
  46. #if defined(CONFIG_V37) || defined(CONFIG_EDT32F10)
  47. #undef CONFIG_LCD_LOGO
  48. #undef LCD_INFO
  49. #endif
  50. /*----------------------------------------------------------------------*/
  51. #ifdef CONFIG_KYOCERA_KCS057QV1AJ
  52. /*
  53. * Kyocera KCS057QV1AJ-G23. Passive, color, single scan.
  54. */
  55. #define LCD_BPP LCD_COLOR4
  56. vidinfo_t panel_info = {
  57. 640, 480, 132, 99, CFG_HIGH, CFG_HIGH, CFG_HIGH, CFG_HIGH, CFG_HIGH,
  58. LCD_BPP, 1, 0, 1, 0, 5, 0, 0, 0
  59. /* wbl, vpw, lcdac, wbf */
  60. };
  61. #endif /* CONFIG_KYOCERA_KCS057QV1AJ */
  62. /*----------------------------------------------------------------------*/
  63. /*----------------------------------------------------------------------*/
  64. #ifdef CONFIG_HITACHI_SP19X001_Z1A
  65. /*
  66. * Hitachi SP19X001-. Active, color, single scan.
  67. */
  68. vidinfo_t panel_info = {
  69. 640, 480, 154, 116, CFG_HIGH, CFG_HIGH, CFG_HIGH, CFG_HIGH, CFG_HIGH,
  70. LCD_COLOR8, 1, 0, 1, 0, 0, 0, 0, 0
  71. /* wbl, vpw, lcdac, wbf */
  72. };
  73. #endif /* CONFIG_HITACHI_SP19X001_Z1A */
  74. /*----------------------------------------------------------------------*/
  75. /*----------------------------------------------------------------------*/
  76. #ifdef CONFIG_NEC_NL6448AC33
  77. /*
  78. * NEC NL6448AC33-18. Active, color, single scan.
  79. */
  80. vidinfo_t panel_info = {
  81. 640, 480, 132, 99, CFG_HIGH, CFG_HIGH, CFG_LOW, CFG_LOW, CFG_HIGH,
  82. 3, 0, 0, 1, 1, 144, 2, 0, 33
  83. /* wbl, vpw, lcdac, wbf */
  84. };
  85. #endif /* CONFIG_NEC_NL6448AC33 */
  86. /*----------------------------------------------------------------------*/
  87. #ifdef CONFIG_NEC_NL6448BC20
  88. /*
  89. * NEC NL6448BC20-08. 6.5", 640x480. Active, color, single scan.
  90. */
  91. vidinfo_t panel_info = {
  92. 640, 480, 132, 99, CFG_HIGH, CFG_HIGH, CFG_LOW, CFG_LOW, CFG_HIGH,
  93. 3, 0, 0, 1, 1, 144, 2, 0, 33
  94. /* wbl, vpw, lcdac, wbf */
  95. };
  96. #endif /* CONFIG_NEC_NL6448BC20 */
  97. /*----------------------------------------------------------------------*/
  98. #ifdef CONFIG_NEC_NL6448BC33_54
  99. /*
  100. * NEC NL6448BC33-54. 10.4", 640x480. Active, color, single scan.
  101. */
  102. vidinfo_t panel_info = {
  103. 640, 480, 212, 158, 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. };
  107. #endif /* CONFIG_NEC_NL6448BC33_54 */
  108. /*----------------------------------------------------------------------*/
  109. #ifdef CONFIG_SHARP_LQ104V7DS01
  110. /*
  111. * SHARP LQ104V7DS01. 6.5", 640x480. Active, color, single scan.
  112. */
  113. vidinfo_t panel_info = {
  114. 640, 480, 132, 99, CFG_HIGH, CFG_HIGH, CFG_LOW, CFG_LOW, CFG_LOW,
  115. 3, 0, 0, 1, 1, 25, 1, 0, 33
  116. /* wbl, vpw, lcdac, wbf */
  117. };
  118. #endif /* CONFIG_SHARP_LQ104V7DS01 */
  119. /*----------------------------------------------------------------------*/
  120. #ifdef CONFIG_SHARP_16x9
  121. /*
  122. * Sharp 320x240. Active, color, single scan. It isn't 16x9, and I am
  123. * not sure what it is.......
  124. */
  125. vidinfo_t panel_info = {
  126. 320, 240, 0, 0, CFG_HIGH, CFG_HIGH, CFG_HIGH, CFG_HIGH, CFG_HIGH,
  127. 3, 0, 0, 1, 1, 15, 4, 0, 3
  128. };
  129. #endif /* CONFIG_SHARP_16x9 */
  130. /*----------------------------------------------------------------------*/
  131. #ifdef CONFIG_SHARP_LQ057Q3DC02
  132. /*
  133. * Sharp LQ057Q3DC02 display. Active, color, single scan.
  134. */
  135. #undef LCD_DF
  136. #define LCD_DF 12
  137. vidinfo_t panel_info = {
  138. 320, 240, 0, 0, CFG_HIGH, CFG_HIGH, CFG_LOW, CFG_LOW, CFG_HIGH,
  139. 3, 0, 0, 1, 1, 15, 4, 0, 3
  140. /* wbl, vpw, lcdac, wbf */
  141. };
  142. #define LCD_INFO_BELOW_LOGO
  143. #endif /* CONFIG_SHARP_LQ057Q3DC02 */
  144. /*----------------------------------------------------------------------*/
  145. #ifdef CONFIG_SHARP_LQ64D341
  146. /*
  147. * Sharp LQ64D341 display, 640x480. Active, color, single scan.
  148. */
  149. vidinfo_t panel_info = {
  150. 640, 480, 0, 0, CFG_HIGH, CFG_HIGH, CFG_LOW, CFG_LOW, CFG_HIGH,
  151. 3, 0, 0, 1, 1, 128, 16, 0, 32
  152. /* wbl, vpw, lcdac, wbf */
  153. };
  154. #endif /* CONFIG_SHARP_LQ64D341 */
  155. #ifdef CONFIG_SHARP_LQ065T9DR51U
  156. /*
  157. * Sharp LQ065T9DR51U display, 400x240. Active, color, single scan.
  158. */
  159. vidinfo_t panel_info = {
  160. 400, 240, 143, 79, CFG_HIGH, CFG_HIGH, CFG_HIGH, CFG_HIGH, CFG_HIGH,
  161. 3, 0, 0, 1, 1, 248, 4, 0, 35
  162. /* wbl, vpw, lcdac, wbf */
  163. };
  164. #define LCD_INFO_BELOW_LOGO
  165. #endif /* CONFIG_SHARP_LQ065T9DR51U */
  166. #ifdef CONFIG_SHARP_LQ084V1DG21
  167. /*
  168. * Sharp LQ084V1DG21 display, 640x480. Active, color, single scan.
  169. */
  170. vidinfo_t panel_info = {
  171. 640, 480, 171, 129, CFG_HIGH, CFG_HIGH, CFG_LOW, CFG_LOW, CFG_LOW,
  172. 3, 0, 0, 1, 1, 160, 3, 0, 48
  173. /* wbl, vpw, lcdac, wbf */
  174. };
  175. #endif /* CONFIG_SHARP_LQ084V1DG21 */
  176. /*----------------------------------------------------------------------*/
  177. #ifdef CONFIG_HLD1045
  178. /*
  179. * HLD1045 display, 640x480. Active, color, single scan.
  180. */
  181. vidinfo_t panel_info = {
  182. 640, 480, 0, 0, CFG_HIGH, CFG_HIGH, CFG_LOW, CFG_LOW, CFG_HIGH,
  183. 3, 0, 0, 1, 1, 160, 3, 0, 48
  184. /* wbl, vpw, lcdac, wbf */
  185. };
  186. #endif /* CONFIG_HLD1045 */
  187. /*----------------------------------------------------------------------*/
  188. #ifdef CONFIG_PRIMEVIEW_V16C6448AC
  189. /*
  190. * Prime View V16C6448AC
  191. */
  192. vidinfo_t panel_info = {
  193. 640, 480, 130, 98, CFG_HIGH, CFG_HIGH, CFG_LOW, CFG_LOW, CFG_HIGH,
  194. 3, 0, 0, 1, 1, 144, 2, 0, 35
  195. /* wbl, vpw, lcdac, wbf */
  196. };
  197. #endif /* CONFIG_PRIMEVIEW_V16C6448AC */
  198. /*----------------------------------------------------------------------*/
  199. #ifdef CONFIG_OPTREX_BW
  200. /*
  201. * Optrex CBL50840-2 NF-FW 99 22 M5
  202. * or
  203. * Hitachi LMG6912RPFC-00T
  204. * or
  205. * Hitachi SP14Q002
  206. *
  207. * 320x240. Black & white.
  208. */
  209. #define OPTREX_BPP 0 /* 0 - monochrome, 1 bpp */
  210. /* 1 - 4 grey levels, 2 bpp */
  211. /* 2 - 16 grey levels, 4 bpp */
  212. vidinfo_t panel_info = {
  213. 320, 240, 0, 0, CFG_HIGH, CFG_HIGH, CFG_HIGH, CFG_HIGH, CFG_LOW,
  214. OPTREX_BPP, 0, 0, 0, 0, 0, 0, 0, 0, 4
  215. };
  216. #endif /* CONFIG_OPTREX_BW */
  217. /*-----------------------------------------------------------------*/
  218. #ifdef CONFIG_EDT32F10
  219. /*
  220. * Emerging Display Technologies 320x240. Passive, monochrome, single scan.
  221. */
  222. #define LCD_BPP LCD_MONOCHROME
  223. #define LCD_DF 10
  224. vidinfo_t panel_info = {
  225. 320, 240, 0, 0, CFG_HIGH, CFG_HIGH, CFG_HIGH, CFG_HIGH, CFG_LOW,
  226. LCD_BPP, 0, 0, 0, 0, 33, 0, 0, 0
  227. };
  228. #endif
  229. /*----------------------------------------------------------------------*/
  230. int lcd_line_length;
  231. int lcd_color_fg;
  232. int lcd_color_bg;
  233. /*
  234. * Frame buffer memory information
  235. */
  236. void *lcd_base; /* Start of framebuffer memory */
  237. void *lcd_console_address; /* Start of console buffer */
  238. short console_col;
  239. short console_row;
  240. /************************************************************************/
  241. void lcd_ctrl_init (void *lcdbase);
  242. void lcd_enable (void);
  243. #if LCD_BPP == LCD_COLOR8
  244. void lcd_setcolreg (ushort regno,
  245. ushort red, ushort green, ushort blue);
  246. #endif
  247. #if LCD_BPP == LCD_MONOCHROME
  248. void lcd_initcolregs (void);
  249. #endif
  250. #if defined(CONFIG_RBC823)
  251. void lcd_disable (void);
  252. #endif
  253. /************************************************************************/
  254. /************************************************************************/
  255. /* ----------------- chipset specific functions ----------------------- */
  256. /************************************************************************/
  257. /*
  258. * Calculate fb size for VIDEOLFB_ATAG.
  259. */
  260. ulong calc_fbsize (void)
  261. {
  262. ulong size;
  263. int line_length = (panel_info.vl_col * NBITS (panel_info.vl_bpix)) / 8;
  264. size = line_length * panel_info.vl_row;
  265. return size;
  266. }
  267. void lcd_ctrl_init (void *lcdbase)
  268. {
  269. volatile immap_t *immr = (immap_t *) CFG_IMMR;
  270. volatile lcd823_t *lcdp = &immr->im_lcd;
  271. uint lccrtmp;
  272. uint lchcr_hpc_tmp;
  273. /* Initialize the LCD control register according to the LCD
  274. * parameters defined. We do everything here but enable
  275. * the controller.
  276. */
  277. #ifdef CONFIG_RPXLITE
  278. /* This is special for RPXlite_DW Software Development Platform **[Sam]** */
  279. panel_info.vl_dp = CFG_LOW;
  280. #endif
  281. lccrtmp = LCDBIT (LCCR_BNUM_BIT,
  282. (((panel_info.vl_row * panel_info.vl_col) * (1 << LCD_BPP)) / 128));
  283. lccrtmp |= LCDBIT (LCCR_CLKP_BIT, panel_info.vl_clkp) |
  284. LCDBIT (LCCR_OEP_BIT, panel_info.vl_oep) |
  285. LCDBIT (LCCR_HSP_BIT, panel_info.vl_hsp) |
  286. LCDBIT (LCCR_VSP_BIT, panel_info.vl_vsp) |
  287. LCDBIT (LCCR_DP_BIT, panel_info.vl_dp) |
  288. LCDBIT (LCCR_BPIX_BIT, panel_info.vl_bpix) |
  289. LCDBIT (LCCR_LBW_BIT, panel_info.vl_lbw) |
  290. LCDBIT (LCCR_SPLT_BIT, panel_info.vl_splt) |
  291. LCDBIT (LCCR_CLOR_BIT, panel_info.vl_clor) |
  292. LCDBIT (LCCR_TFT_BIT, panel_info.vl_tft);
  293. #if 0
  294. lccrtmp |= ((SIU_LEVEL5 / 2) << 12);
  295. lccrtmp |= LCCR_EIEN;
  296. #endif
  297. lcdp->lcd_lccr = lccrtmp;
  298. lcdp->lcd_lcsr = 0xFF; /* Clear pending interrupts */
  299. /* Initialize LCD controller bus priorities.
  300. */
  301. #ifdef CONFIG_RBC823
  302. immr->im_siu_conf.sc_sdcr = (immr->im_siu_conf.sc_sdcr & ~0x0f) | 1; /* RAID = 01, LAID = 00 */
  303. #else
  304. immr->im_siu_conf.sc_sdcr &= ~0x0f; /* RAID = LAID = 0 */
  305. /* set SHFT/CLOCK division factor 4
  306. * This needs to be set based upon display type and processor
  307. * speed. The TFT displays run about 20 to 30 MHz.
  308. * I was running 64 MHz processor speed.
  309. * The value for this divider must be chosen so the result is
  310. * an integer of the processor speed (i.e., divide by 3 with
  311. * 64 MHz would be bad).
  312. */
  313. immr->im_clkrst.car_sccr &= ~0x1F;
  314. immr->im_clkrst.car_sccr |= LCD_DF; /* was 8 */
  315. #endif /* CONFIG_RBC823 */
  316. #if defined(CONFIG_RBC823)
  317. /* Enable LCD on port D.
  318. */
  319. immr->im_ioport.iop_pddat &= 0x0300;
  320. immr->im_ioport.iop_pdpar |= 0x1CFF;
  321. immr->im_ioport.iop_pddir |= 0x1CFF;
  322. /* Configure LCD_ON, VEE_ON, CCFL_ON on port B.
  323. */
  324. immr->im_cpm.cp_pbdat &= ~0x00005001;
  325. immr->im_cpm.cp_pbpar &= ~0x00005001;
  326. immr->im_cpm.cp_pbdir |= 0x00005001;
  327. #elif !defined(CONFIG_EDT32F10)
  328. /* Enable LCD on port D.
  329. */
  330. immr->im_ioport.iop_pdpar |= 0x1FFF;
  331. immr->im_ioport.iop_pddir |= 0x1FFF;
  332. /* Enable LCD_A/B/C on port B.
  333. */
  334. immr->im_cpm.cp_pbpar |= 0x00005001;
  335. immr->im_cpm.cp_pbdir |= 0x00005001;
  336. #else
  337. /* Enable LCD on port D.
  338. */
  339. immr->im_ioport.iop_pdpar |= 0x1DFF;
  340. immr->im_ioport.iop_pdpar &= ~0x0200;
  341. immr->im_ioport.iop_pddir |= 0x1FFF;
  342. immr->im_ioport.iop_pddat |= 0x0200;
  343. #endif
  344. /* Load the physical address of the linear frame buffer
  345. * into the LCD controller.
  346. * BIG NOTE: This has to be modified to load A and B depending
  347. * upon the split mode of the LCD.
  348. */
  349. lcdp->lcd_lcfaa = (ulong)lcd_base;
  350. lcdp->lcd_lcfba = (ulong)lcd_base;
  351. /* MORE HACKS...This must be updated according to 823 manual
  352. * for different panels.
  353. * Udi Finkelstein - done - see below:
  354. * Note: You better not try unsupported combinations such as
  355. * 4-bit wide passive dual scan LCD at 4/8 Bit color.
  356. */
  357. lchcr_hpc_tmp =
  358. (panel_info.vl_col *
  359. (panel_info.vl_tft ? 8 :
  360. (((2 - panel_info.vl_lbw) << /* 4 bit=2, 8-bit = 1 */
  361. /* use << to mult by: single scan = 1, dual scan = 2 */
  362. panel_info.vl_splt) *
  363. (panel_info.vl_bpix | 1)))) >> 3; /* 2/4 BPP = 1, 8/16 BPP = 3 */
  364. lcdp->lcd_lchcr = LCHCR_BO |
  365. LCDBIT (LCHCR_AT_BIT, 4) |
  366. LCDBIT (LCHCR_HPC_BIT, lchcr_hpc_tmp) |
  367. panel_info.vl_wbl;
  368. lcdp->lcd_lcvcr = LCDBIT (LCVCR_VPW_BIT, panel_info.vl_vpw) |
  369. LCDBIT (LCVCR_LCD_AC_BIT, panel_info.vl_lcdac) |
  370. LCDBIT (LCVCR_VPC_BIT, panel_info.vl_row) |
  371. panel_info.vl_wbf;
  372. }
  373. /*----------------------------------------------------------------------*/
  374. #ifdef NOT_USED_SO_FAR
  375. static void
  376. lcd_getcolreg (ushort regno, ushort *red, ushort *green, ushort *blue)
  377. {
  378. volatile immap_t *immr = (immap_t *) CFG_IMMR;
  379. volatile cpm8xx_t *cp = &(immr->im_cpm);
  380. unsigned short colreg, *cmap_ptr;
  381. cmap_ptr = (unsigned short *)&cp->lcd_cmap[regno * 2];
  382. colreg = *cmap_ptr;
  383. #ifdef CFG_INVERT_COLORS
  384. colreg ^= 0x0FFF;
  385. #endif
  386. *red = (colreg >> 8) & 0x0F;
  387. *green = (colreg >> 4) & 0x0F;
  388. *blue = colreg & 0x0F;
  389. }
  390. #endif /* NOT_USED_SO_FAR */
  391. /*----------------------------------------------------------------------*/
  392. #if LCD_BPP == LCD_COLOR8
  393. void
  394. lcd_setcolreg (ushort regno, ushort red, ushort green, ushort blue)
  395. {
  396. volatile immap_t *immr = (immap_t *) CFG_IMMR;
  397. volatile cpm8xx_t *cp = &(immr->im_cpm);
  398. unsigned short colreg, *cmap_ptr;
  399. cmap_ptr = (unsigned short *)&cp->lcd_cmap[regno * 2];
  400. colreg = ((red & 0x0F) << 8) |
  401. ((green & 0x0F) << 4) |
  402. (blue & 0x0F) ;
  403. #ifdef CFG_INVERT_COLORS
  404. colreg ^= 0x0FFF;
  405. #endif
  406. *cmap_ptr = colreg;
  407. debug ("setcolreg: reg %2d @ %p: R=%02X G=%02X B=%02X => %02X%02X\n",
  408. regno, &(cp->lcd_cmap[regno * 2]),
  409. red, green, blue,
  410. cp->lcd_cmap[ regno * 2 ], cp->lcd_cmap[(regno * 2) + 1]);
  411. }
  412. #endif /* LCD_COLOR8 */
  413. /*----------------------------------------------------------------------*/
  414. #if LCD_BPP == LCD_MONOCHROME
  415. static
  416. void lcd_initcolregs (void)
  417. {
  418. volatile immap_t *immr = (immap_t *) CFG_IMMR;
  419. volatile cpm8xx_t *cp = &(immr->im_cpm);
  420. ushort regno;
  421. for (regno = 0; regno < 16; regno++) {
  422. cp->lcd_cmap[regno * 2] = 0;
  423. cp->lcd_cmap[(regno * 2) + 1] = regno & 0x0f;
  424. }
  425. }
  426. #endif
  427. /*----------------------------------------------------------------------*/
  428. void lcd_enable (void)
  429. {
  430. volatile immap_t *immr = (immap_t *) CFG_IMMR;
  431. volatile lcd823_t *lcdp = &immr->im_lcd;
  432. /* Enable the LCD panel */
  433. #ifndef CONFIG_RBC823
  434. immr->im_siu_conf.sc_sdcr |= (1 << (31 - 25)); /* LAM = 1 */
  435. #endif
  436. lcdp->lcd_lccr |= LCCR_PON;
  437. #ifdef CONFIG_V37
  438. /* Turn on display backlight */
  439. immr->im_cpm.cp_pbpar |= 0x00008000;
  440. immr->im_cpm.cp_pbdir |= 0x00008000;
  441. #elif defined(CONFIG_RBC823)
  442. /* Turn on display backlight */
  443. immr->im_cpm.cp_pbdat |= 0x00004000;
  444. #endif
  445. #if defined(CONFIG_LWMON)
  446. { uchar c = pic_read (0x60);
  447. #if defined(CONFIG_LCD) && defined(CONFIG_LWMON) && (CONFIG_POST & CFG_POST_SYSMON)
  448. /* Enable LCD later in sysmon test, only if temperature is OK */
  449. #else
  450. c |= 0x07; /* Power on CCFL, Enable CCFL, Chip Enable LCD */
  451. #endif
  452. pic_write (0x60, c);
  453. }
  454. #endif /* CONFIG_LWMON */
  455. #if defined(CONFIG_R360MPI)
  456. {
  457. extern void r360_i2c_lcd_write (uchar data0, uchar data1);
  458. unsigned long bgi, ctr;
  459. char *p;
  460. if ((p = getenv("lcdbgi")) != NULL) {
  461. bgi = simple_strtoul (p, 0, 10) & 0xFFF;
  462. } else {
  463. bgi = 0xFFF;
  464. }
  465. if ((p = getenv("lcdctr")) != NULL) {
  466. ctr = simple_strtoul (p, 0, 10) & 0xFFF;
  467. } else {
  468. ctr=0x7FF;
  469. }
  470. r360_i2c_lcd_write(0x10, 0x01);
  471. r360_i2c_lcd_write(0x20, 0x01);
  472. r360_i2c_lcd_write(0x30 | ((bgi>>8) & 0xF), bgi & 0xFF);
  473. r360_i2c_lcd_write(0x40 | ((ctr>>8) & 0xF), ctr & 0xFF);
  474. }
  475. #endif /* CONFIG_R360MPI */
  476. #ifdef CONFIG_RBC823
  477. udelay(200000); /* wait 200ms */
  478. /* Turn VEE_ON first */
  479. immr->im_cpm.cp_pbdat |= 0x00000001;
  480. udelay(200000); /* wait 200ms */
  481. /* Now turn on LCD_ON */
  482. immr->im_cpm.cp_pbdat |= 0x00001000;
  483. #endif
  484. #ifdef CONFIG_RRVISION
  485. debug ("PC4->Output(1): enable LVDS\n");
  486. debug ("PC5->Output(0): disable PAL clock\n");
  487. immr->im_ioport.iop_pddir |= 0x1000;
  488. immr->im_ioport.iop_pcpar &= ~(0x0C00);
  489. immr->im_ioport.iop_pcdir |= 0x0C00 ;
  490. immr->im_ioport.iop_pcdat |= 0x0800 ;
  491. immr->im_ioport.iop_pcdat &= ~(0x0400);
  492. debug ("PDPAR=0x%04X PDDIR=0x%04X PDDAT=0x%04X\n",
  493. immr->im_ioport.iop_pdpar,
  494. immr->im_ioport.iop_pddir,
  495. immr->im_ioport.iop_pddat);
  496. debug ("PCPAR=0x%04X PCDIR=0x%04X PCDAT=0x%04X\n",
  497. immr->im_ioport.iop_pcpar,
  498. immr->im_ioport.iop_pcdir,
  499. immr->im_ioport.iop_pcdat);
  500. #endif
  501. }
  502. /*----------------------------------------------------------------------*/
  503. #if defined (CONFIG_RBC823)
  504. void lcd_disable (void)
  505. {
  506. volatile immap_t *immr = (immap_t *) CFG_IMMR;
  507. volatile lcd823_t *lcdp = &immr->im_lcd;
  508. #if defined(CONFIG_LWMON)
  509. { uchar c = pic_read (0x60);
  510. c &= ~0x07; /* Power off CCFL, Disable CCFL, Chip Disable LCD */
  511. pic_write (0x60, c);
  512. }
  513. #elif defined(CONFIG_R360MPI)
  514. {
  515. extern void r360_i2c_lcd_write (uchar data0, uchar data1);
  516. r360_i2c_lcd_write(0x10, 0x00);
  517. r360_i2c_lcd_write(0x20, 0x00);
  518. r360_i2c_lcd_write(0x30, 0x00);
  519. r360_i2c_lcd_write(0x40, 0x00);
  520. }
  521. #endif /* CONFIG_LWMON */
  522. /* Disable the LCD panel */
  523. lcdp->lcd_lccr &= ~LCCR_PON;
  524. #ifdef CONFIG_RBC823
  525. /* Turn off display backlight, VEE and LCD_ON */
  526. immr->im_cpm.cp_pbdat &= ~0x00005001;
  527. #else
  528. immr->im_siu_conf.sc_sdcr &= ~(1 << (31 - 25)); /* LAM = 0 */
  529. #endif /* CONFIG_RBC823 */
  530. }
  531. #endif /* NOT_USED_SO_FAR || CONFIG_RBC823 */
  532. /************************************************************************/
  533. #endif /* CONFIG_LCD */