blob: d1d2d443dbbacb64a11cf2e71368b9423aa3e43c [file] [log] [blame]
wdenk7a428cc2003-06-15 22:40:42 +00001/*
wdenk9ca7bbc2004-10-09 23:25:58 +00002 * PXA LCD Controller
3 *
wdenk7a428cc2003-06-15 22:40:42 +00004 * (C) Copyright 2001-2002
5 * Wolfgang Denk, DENX Software Engineering -- wd@denx.de
6 *
7 * See file CREDITS for list of people who contributed to this
8 * project.
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License as
12 * published by the Free Software Foundation; either version 2 of
13 * the License, or (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
23 * MA 02111-1307 USA
24 */
25
26/************************************************************************/
27/* ** HEADER FILES */
28/************************************************************************/
29
wdenk7a428cc2003-06-15 22:40:42 +000030#include <config.h>
31#include <common.h>
32#include <version.h>
33#include <stdarg.h>
wdenk7a428cc2003-06-15 22:40:42 +000034#include <linux/types.h>
Jean-Christophe PLAGNIOL-VILLARD2a7a0312009-05-16 12:14:54 +020035#include <stdio_dev.h>
wdenk9ca7bbc2004-10-09 23:25:58 +000036#include <lcd.h>
wdenk7a428cc2003-06-15 22:40:42 +000037#include <asm/arch/pxa-regs.h>
38
wdenk9ca7bbc2004-10-09 23:25:58 +000039/* #define DEBUG */
wdenk7a428cc2003-06-15 22:40:42 +000040
wdenk9ca7bbc2004-10-09 23:25:58 +000041#ifdef CONFIG_LCD
wdenk7a428cc2003-06-15 22:40:42 +000042
43/*----------------------------------------------------------------------*/
wdenk7a428cc2003-06-15 22:40:42 +000044/*
wdenk9ca7bbc2004-10-09 23:25:58 +000045 * Define panel bpp, LCCR0, LCCR3 and panel_info video struct for
46 * your display.
wdenk7a428cc2003-06-15 22:40:42 +000047 */
48
wdenk9ca7bbc2004-10-09 23:25:58 +000049#ifdef CONFIG_PXA_VGA
50/* LCD outputs connected to a video DAC */
51# define LCD_BPP LCD_COLOR8
wdenk7a428cc2003-06-15 22:40:42 +000052
53/* you have to set lccr0 and lccr3 (including pcd) */
wdenk9ca7bbc2004-10-09 23:25:58 +000054# define REG_LCCR0 0x003008f8
55# define REG_LCCR3 0x0300FF01
wdenk7a428cc2003-06-15 22:40:42 +000056
57/* 640x480x16 @ 61 Hz */
wdenk9ca7bbc2004-10-09 23:25:58 +000058vidinfo_t panel_info = {
59 vl_col: 640,
60 vl_row: 480,
61 vl_width: 640,
62 vl_height: 480,
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020063 vl_clkp: CONFIG_SYS_HIGH,
64 vl_oep: CONFIG_SYS_HIGH,
65 vl_hsp: CONFIG_SYS_HIGH,
66 vl_vsp: CONFIG_SYS_HIGH,
67 vl_dp: CONFIG_SYS_HIGH,
wdenk9ca7bbc2004-10-09 23:25:58 +000068 vl_bpix: LCD_BPP,
69 vl_lbw: 0,
70 vl_splt: 0,
71 vl_clor: 0,
72 vl_tft: 1,
73 vl_hpw: 40,
74 vl_blw: 56,
75 vl_elw: 56,
76 vl_vpw: 20,
77 vl_bfw: 8,
78 vl_efw: 8,
wdenk7a428cc2003-06-15 22:40:42 +000079};
80#endif /* CONFIG_PXA_VIDEO */
81
wdenk9ca7bbc2004-10-09 23:25:58 +000082/*----------------------------------------------------------------------*/
wdenk7a428cc2003-06-15 22:40:42 +000083#ifdef CONFIG_SHARP_LM8V31
84
wdenk9ca7bbc2004-10-09 23:25:58 +000085# define LCD_BPP LCD_COLOR8
86# define LCD_INVERT_COLORS /* Needed for colors to be correct, but why? */
wdenk7a428cc2003-06-15 22:40:42 +000087
88/* you have to set lccr0 and lccr3 (including pcd) */
wdenk9ca7bbc2004-10-09 23:25:58 +000089# define REG_LCCR0 0x0030087C
90# define REG_LCCR3 0x0340FF08
wdenk7a428cc2003-06-15 22:40:42 +000091
wdenk9ca7bbc2004-10-09 23:25:58 +000092vidinfo_t panel_info = {
93 vl_col: 640,
94 vl_row: 480,
95 vl_width: 157,
96 vl_height: 118,
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020097 vl_clkp: CONFIG_SYS_HIGH,
98 vl_oep: CONFIG_SYS_HIGH,
99 vl_hsp: CONFIG_SYS_HIGH,
100 vl_vsp: CONFIG_SYS_HIGH,
101 vl_dp: CONFIG_SYS_HIGH,
wdenk9ca7bbc2004-10-09 23:25:58 +0000102 vl_bpix: LCD_BPP,
103 vl_lbw: 0,
104 vl_splt: 1,
105 vl_clor: 1,
106 vl_tft: 0,
107 vl_hpw: 1,
108 vl_blw: 3,
109 vl_elw: 3,
110 vl_vpw: 1,
111 vl_bfw: 0,
112 vl_efw: 0,
wdenk7a428cc2003-06-15 22:40:42 +0000113};
114#endif /* CONFIG_SHARP_LM8V31 */
Marek Vasut846d9b62010-03-07 23:35:48 +0100115/*----------------------------------------------------------------------*/
116#ifdef CONFIG_VOIPAC_LCD
117
118# define LCD_BPP LCD_COLOR8
119# define LCD_INVERT_COLORS
120
121/* you have to set lccr0 and lccr3 (including pcd) */
122# define REG_LCCR0 0x043008f8
123# define REG_LCCR3 0x0340FF08
124
125vidinfo_t panel_info = {
126 vl_col: 640,
127 vl_row: 480,
128 vl_width: 157,
129 vl_height: 118,
130 vl_clkp: CONFIG_SYS_HIGH,
131 vl_oep: CONFIG_SYS_HIGH,
132 vl_hsp: CONFIG_SYS_HIGH,
133 vl_vsp: CONFIG_SYS_HIGH,
134 vl_dp: CONFIG_SYS_HIGH,
135 vl_bpix: LCD_BPP,
136 vl_lbw: 0,
137 vl_splt: 1,
138 vl_clor: 1,
139 vl_tft: 1,
140 vl_hpw: 32,
141 vl_blw: 144,
142 vl_elw: 32,
143 vl_vpw: 2,
144 vl_bfw: 13,
145 vl_efw: 30,
146};
147#endif /* CONFIG_VOIPAC_LCD */
wdenk7a428cc2003-06-15 22:40:42 +0000148
149/*----------------------------------------------------------------------*/
wdenk9ca7bbc2004-10-09 23:25:58 +0000150#ifdef CONFIG_HITACHI_SX14
151/* Hitachi SX14Q004-ZZA color STN LCD */
152#define LCD_BPP LCD_COLOR8
wdenk7a428cc2003-06-15 22:40:42 +0000153
wdenk9ca7bbc2004-10-09 23:25:58 +0000154/* you have to set lccr0 and lccr3 (including pcd) */
155#define REG_LCCR0 0x00301079
156#define REG_LCCR3 0x0340FF20
wdenk7a428cc2003-06-15 22:40:42 +0000157
wdenk9ca7bbc2004-10-09 23:25:58 +0000158vidinfo_t panel_info = {
159 vl_col: 320,
160 vl_row: 240,
161 vl_width: 167,
162 vl_height: 109,
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200163 vl_clkp: CONFIG_SYS_HIGH,
164 vl_oep: CONFIG_SYS_HIGH,
165 vl_hsp: CONFIG_SYS_HIGH,
166 vl_vsp: CONFIG_SYS_HIGH,
167 vl_dp: CONFIG_SYS_HIGH,
wdenk9ca7bbc2004-10-09 23:25:58 +0000168 vl_bpix: LCD_BPP,
169 vl_lbw: 1,
170 vl_splt: 0,
171 vl_clor: 1,
172 vl_tft: 0,
173 vl_hpw: 1,
174 vl_blw: 1,
175 vl_elw: 1,
176 vl_vpw: 7,
177 vl_bfw: 0,
178 vl_efw: 0,
wdenk7a428cc2003-06-15 22:40:42 +0000179};
wdenk9ca7bbc2004-10-09 23:25:58 +0000180#endif /* CONFIG_HITACHI_SX14 */
wdenk7a428cc2003-06-15 22:40:42 +0000181
182/*----------------------------------------------------------------------*/
183
wdenk9ca7bbc2004-10-09 23:25:58 +0000184#if LCD_BPP == LCD_COLOR8
185void lcd_setcolreg (ushort regno, ushort red, ushort green, ushort blue);
186#endif
wdenk7a428cc2003-06-15 22:40:42 +0000187#if LCD_BPP == LCD_MONOCHROME
wdenk9ca7bbc2004-10-09 23:25:58 +0000188void lcd_initcolregs (void);
wdenk7a428cc2003-06-15 22:40:42 +0000189#endif
190
wdenk9ca7bbc2004-10-09 23:25:58 +0000191#ifdef NOT_USED_SO_FAR
192void lcd_disable (void);
193void lcd_getcolreg (ushort regno, ushort *red, ushort *green, ushort *blue);
194#endif /* NOT_USED_SO_FAR */
wdenk7a428cc2003-06-15 22:40:42 +0000195
wdenk9ca7bbc2004-10-09 23:25:58 +0000196void lcd_ctrl_init (void *lcdbase);
197void lcd_enable (void);
wdenk7a428cc2003-06-15 22:40:42 +0000198
wdenk9ca7bbc2004-10-09 23:25:58 +0000199int lcd_line_length;
200int lcd_color_fg;
201int lcd_color_bg;
wdenk7a428cc2003-06-15 22:40:42 +0000202
wdenk9ca7bbc2004-10-09 23:25:58 +0000203void *lcd_base; /* Start of framebuffer memory */
204void *lcd_console_address; /* Start of console buffer */
wdenk7a428cc2003-06-15 22:40:42 +0000205
wdenk9ca7bbc2004-10-09 23:25:58 +0000206short console_col;
207short console_row;
wdenk7a428cc2003-06-15 22:40:42 +0000208
wdenk9ca7bbc2004-10-09 23:25:58 +0000209static int pxafb_init_mem (void *lcdbase, vidinfo_t *vid);
210static void pxafb_setup_gpio (vidinfo_t *vid);
211static void pxafb_enable_controller (vidinfo_t *vid);
212static int pxafb_init (vidinfo_t *vid);
wdenk7a428cc2003-06-15 22:40:42 +0000213/************************************************************************/
214
wdenk7a428cc2003-06-15 22:40:42 +0000215/************************************************************************/
wdenk9ca7bbc2004-10-09 23:25:58 +0000216/* --------------- PXA chipset specific functions ------------------- */
wdenk7a428cc2003-06-15 22:40:42 +0000217/************************************************************************/
218
wdenk9ca7bbc2004-10-09 23:25:58 +0000219void lcd_ctrl_init (void *lcdbase)
wdenk7a428cc2003-06-15 22:40:42 +0000220{
wdenk57b2d802003-06-27 21:31:46 +0000221 pxafb_init_mem(lcdbase, &panel_info);
wdenk7a428cc2003-06-15 22:40:42 +0000222 pxafb_init(&panel_info);
223 pxafb_setup_gpio(&panel_info);
224 pxafb_enable_controller(&panel_info);
225}
226
227/*----------------------------------------------------------------------*/
wdenk9ca7bbc2004-10-09 23:25:58 +0000228#ifdef NOT_USED_SO_FAR
229void
wdenk7a428cc2003-06-15 22:40:42 +0000230lcd_getcolreg (ushort regno, ushort *red, ushort *green, ushort *blue)
231{
232}
wdenk9ca7bbc2004-10-09 23:25:58 +0000233#endif /* NOT_USED_SO_FAR */
wdenk7a428cc2003-06-15 22:40:42 +0000234
235/*----------------------------------------------------------------------*/
wdenk7a428cc2003-06-15 22:40:42 +0000236#if LCD_BPP == LCD_COLOR8
wdenk9ca7bbc2004-10-09 23:25:58 +0000237void
wdenk7a428cc2003-06-15 22:40:42 +0000238lcd_setcolreg (ushort regno, ushort red, ushort green, ushort blue)
239{
240 struct pxafb_info *fbi = &panel_info.pxa;
241 unsigned short *palette = (unsigned short *)fbi->palette;
242 u_int val;
wdenk57b2d802003-06-27 21:31:46 +0000243
wdenk7a428cc2003-06-15 22:40:42 +0000244 if (regno < fbi->palette_size) {
245 val = ((red << 8) & 0xf800);
246 val |= ((green << 4) & 0x07e0);
247 val |= (blue & 0x001f);
248
249#ifdef LCD_INVERT_COLORS
250 palette[regno] = ~val;
251#else
wdenk9ca7bbc2004-10-09 23:25:58 +0000252 palette[regno] = val;
wdenk7a428cc2003-06-15 22:40:42 +0000253#endif
254 }
255
256 debug ("setcolreg: reg %2d @ %p: R=%02X G=%02X B=%02X => %04X\n",
257 regno, &palette[regno],
258 red, green, blue,
259 palette[regno]);
260}
wdenk9ca7bbc2004-10-09 23:25:58 +0000261#endif /* LCD_COLOR8 */
wdenk7a428cc2003-06-15 22:40:42 +0000262
263/*----------------------------------------------------------------------*/
wdenk7a428cc2003-06-15 22:40:42 +0000264#if LCD_BPP == LCD_MONOCHROME
wdenk7a428cc2003-06-15 22:40:42 +0000265void lcd_initcolregs (void)
266{
wdenk9ca7bbc2004-10-09 23:25:58 +0000267 struct pxafb_info *fbi = &panel_info.pxa;
268 cmap = (ushort *)fbi->palette;
wdenk7a428cc2003-06-15 22:40:42 +0000269 ushort regno;
270
271 for (regno = 0; regno < 16; regno++) {
wdenk9ca7bbc2004-10-09 23:25:58 +0000272 cmap[regno * 2] = 0;
273 cmap[(regno * 2) + 1] = regno & 0x0f;
wdenk7a428cc2003-06-15 22:40:42 +0000274 }
275}
wdenk9ca7bbc2004-10-09 23:25:58 +0000276#endif /* LCD_MONOCHROME */
wdenk7a428cc2003-06-15 22:40:42 +0000277
278/*----------------------------------------------------------------------*/
wdenk9ca7bbc2004-10-09 23:25:58 +0000279void lcd_enable (void)
wdenk7a428cc2003-06-15 22:40:42 +0000280{
281}
282
283/*----------------------------------------------------------------------*/
wdenk7a428cc2003-06-15 22:40:42 +0000284#ifdef NOT_USED_SO_FAR
285static void lcd_disable (void)
286{
287}
wdenk9ca7bbc2004-10-09 23:25:58 +0000288#endif /* NOT_USED_SO_FAR */
wdenk7a428cc2003-06-15 22:40:42 +0000289
wdenk9ca7bbc2004-10-09 23:25:58 +0000290/*----------------------------------------------------------------------*/
wdenk7a428cc2003-06-15 22:40:42 +0000291
292/************************************************************************/
wdenk9ca7bbc2004-10-09 23:25:58 +0000293/* ** PXA255 specific routines */
wdenk7a428cc2003-06-15 22:40:42 +0000294/************************************************************************/
295
wdenk9ca7bbc2004-10-09 23:25:58 +0000296/*
297 * Calculate fb size for VIDEOLFB_ATAG. Size returned contains fb,
298 * descriptors and palette areas.
299 */
300ulong calc_fbsize (void)
wdenk7a428cc2003-06-15 22:40:42 +0000301{
wdenk9ca7bbc2004-10-09 23:25:58 +0000302 ulong size;
303 int line_length = (panel_info.vl_col * NBITS (panel_info.vl_bpix)) / 8;
wdenk7a428cc2003-06-15 22:40:42 +0000304
wdenk9ca7bbc2004-10-09 23:25:58 +0000305 size = line_length * panel_info.vl_row;
306 size += PAGE_SIZE;
wdenk7a428cc2003-06-15 22:40:42 +0000307
wdenk9ca7bbc2004-10-09 23:25:58 +0000308 return size;
wdenk7a428cc2003-06-15 22:40:42 +0000309}
310
wdenk9ca7bbc2004-10-09 23:25:58 +0000311static int pxafb_init_mem (void *lcdbase, vidinfo_t *vid)
wdenk7a428cc2003-06-15 22:40:42 +0000312{
313 u_long palette_mem_size;
314 struct pxafb_info *fbi = &vid->pxa;
315 int fb_size = vid->vl_row * (vid->vl_col * NBITS (vid->vl_bpix)) / 8;
316
317 fbi->screen = (u_long)lcdbase;
318
319 fbi->palette_size = NBITS(vid->vl_bpix) == 8 ? 256 : 16;
320 palette_mem_size = fbi->palette_size * sizeof(u16);
wdenk9ca7bbc2004-10-09 23:25:58 +0000321
wdenk7a428cc2003-06-15 22:40:42 +0000322 debug("palette_mem_size = 0x%08lx\n", (u_long) palette_mem_size);
323 /* locate palette and descs at end of page following fb */
wdenk9ca7bbc2004-10-09 23:25:58 +0000324 fbi->palette = (u_long)lcdbase + fb_size + PAGE_SIZE - palette_mem_size;
wdenk7a428cc2003-06-15 22:40:42 +0000325
326 return 0;
327}
Marek Vasut23cf8e42009-11-28 13:57:43 +0100328#ifdef CONFIG_CPU_MONAHANS
329static inline void pxafb_setup_gpio (vidinfo_t *vid) {}
330#else
wdenk9ca7bbc2004-10-09 23:25:58 +0000331static void pxafb_setup_gpio (vidinfo_t *vid)
wdenk7a428cc2003-06-15 22:40:42 +0000332{
333 u_long lccr0;
334
335 /*
336 * setup is based on type of panel supported
337 */
338
339 lccr0 = vid->pxa.reg_lccr0;
340
341 /* 4 bit interface */
342 if ((lccr0 & LCCR0_CMS) && (lccr0 & LCCR0_SDS) && !(lccr0 & LCCR0_DPD))
343 {
344 debug("Setting GPIO for 4 bit data\n");
345 /* bits 58-61 */
346 GPDR1 |= (0xf << 26);
347 GAFR1_U = (GAFR1_U & ~(0xff << 20)) | (0xaa << 20);
348
349 /* bits 74-77 */
350 GPDR2 |= (0xf << 10);
351 GAFR2_L = (GAFR2_L & ~(0xff << 20)) | (0xaa << 20);
352 }
353
354 /* 8 bit interface */
355 else if (((lccr0 & LCCR0_CMS) && ((lccr0 & LCCR0_SDS) || (lccr0 & LCCR0_DPD))) ||
wdenk9ca7bbc2004-10-09 23:25:58 +0000356 (!(lccr0 & LCCR0_CMS) && !(lccr0 & LCCR0_PAS) && !(lccr0 & LCCR0_SDS)))
wdenk7a428cc2003-06-15 22:40:42 +0000357 {
358 debug("Setting GPIO for 8 bit data\n");
359 /* bits 58-65 */
360 GPDR1 |= (0x3f << 26);
361 GPDR2 |= (0x3);
362
363 GAFR1_U = (GAFR1_U & ~(0xfff << 20)) | (0xaaa << 20);
364 GAFR2_L = (GAFR2_L & ~0xf) | (0xa);
365
366 /* bits 74-77 */
367 GPDR2 |= (0xf << 10);
368 GAFR2_L = (GAFR2_L & ~(0xff << 20)) | (0xaa << 20);
369 }
370
371 /* 16 bit interface */
372 else if (!(lccr0 & LCCR0_CMS) && ((lccr0 & LCCR0_SDS) || (lccr0 & LCCR0_PAS)))
373 {
374 debug("Setting GPIO for 16 bit data\n");
375 /* bits 58-77 */
376 GPDR1 |= (0x3f << 26);
377 GPDR2 |= 0x00003fff;
378
379 GAFR1_U = (GAFR1_U & ~(0xfff << 20)) | (0xaaa << 20);
380 GAFR2_L = (GAFR2_L & 0xf0000000) | 0x0aaaaaaa;
381 }
382 else
383 {
384 printf("pxafb_setup_gpio: unable to determine bits per pixel\n");
385 }
386}
Marek Vasut23cf8e42009-11-28 13:57:43 +0100387#endif
wdenk7a428cc2003-06-15 22:40:42 +0000388
wdenk9ca7bbc2004-10-09 23:25:58 +0000389static void pxafb_enable_controller (vidinfo_t *vid)
wdenk7a428cc2003-06-15 22:40:42 +0000390{
391 debug("Enabling LCD controller\n");
392
393 /* Sequence from 11.7.10 */
394 LCCR3 = vid->pxa.reg_lccr3;
395 LCCR2 = vid->pxa.reg_lccr2;
396 LCCR1 = vid->pxa.reg_lccr1;
397 LCCR0 = vid->pxa.reg_lccr0 & ~LCCR0_ENB;
398 FDADR0 = vid->pxa.fdadr0;
399 FDADR1 = vid->pxa.fdadr1;
400 LCCR0 |= LCCR0_ENB;
401
Marek Vasut23cf8e42009-11-28 13:57:43 +0100402#ifdef CONFIG_CPU_MONAHANS
403 CKENA |= CKENA_1_LCD;
404#else
wdenk7a428cc2003-06-15 22:40:42 +0000405 CKEN |= CKEN16_LCD;
Marek Vasut23cf8e42009-11-28 13:57:43 +0100406#endif
wdenk7a428cc2003-06-15 22:40:42 +0000407
408 debug("FDADR0 = 0x%08x\n", (unsigned int)FDADR0);
409 debug("FDADR1 = 0x%08x\n", (unsigned int)FDADR1);
410 debug("LCCR0 = 0x%08x\n", (unsigned int)LCCR0);
411 debug("LCCR1 = 0x%08x\n", (unsigned int)LCCR1);
412 debug("LCCR2 = 0x%08x\n", (unsigned int)LCCR2);
413 debug("LCCR3 = 0x%08x\n", (unsigned int)LCCR3);
414}
415
wdenk9ca7bbc2004-10-09 23:25:58 +0000416static int pxafb_init (vidinfo_t *vid)
wdenk7a428cc2003-06-15 22:40:42 +0000417{
418 struct pxafb_info *fbi = &vid->pxa;
419
420 debug("Configuring PXA LCD\n");
421
422 fbi->reg_lccr0 = REG_LCCR0;
423 fbi->reg_lccr3 = REG_LCCR3;
424
425 debug("vid: vl_col=%d hslen=%d lm=%d rm=%d\n",
426 vid->vl_col, vid->vl_hpw,
427 vid->vl_blw, vid->vl_elw);
428 debug("vid: vl_row=%d vslen=%d um=%d bm=%d\n",
429 vid->vl_row, vid->vl_vpw,
430 vid->vl_bfw, vid->vl_efw);
431
432 fbi->reg_lccr1 =
433 LCCR1_DisWdth(vid->vl_col) +
434 LCCR1_HorSnchWdth(vid->vl_hpw) +
435 LCCR1_BegLnDel(vid->vl_blw) +
436 LCCR1_EndLnDel(vid->vl_elw);
wdenk57b2d802003-06-27 21:31:46 +0000437
wdenk7a428cc2003-06-15 22:40:42 +0000438 fbi->reg_lccr2 =
439 LCCR2_DisHght(vid->vl_row) +
440 LCCR2_VrtSnchWdth(vid->vl_vpw) +
441 LCCR2_BegFrmDel(vid->vl_bfw) +
442 LCCR2_EndFrmDel(vid->vl_efw);
443
wdenk57b2d802003-06-27 21:31:46 +0000444 fbi->reg_lccr3 = REG_LCCR3 & ~(LCCR3_HSP | LCCR3_VSP);
wdenk9ca7bbc2004-10-09 23:25:58 +0000445 fbi->reg_lccr3 |= (vid->vl_hsp ? LCCR3_HorSnchL : LCCR3_HorSnchH)
446 | (vid->vl_vsp ? LCCR3_VrtSnchL : LCCR3_VrtSnchH);
wdenk57b2d802003-06-27 21:31:46 +0000447
wdenk7a428cc2003-06-15 22:40:42 +0000448
449 /* setup dma descriptors */
450 fbi->dmadesc_fblow = (struct pxafb_dma_descriptor *)((unsigned int)fbi->palette - 3*16);
451 fbi->dmadesc_fbhigh = (struct pxafb_dma_descriptor *)((unsigned int)fbi->palette - 2*16);
452 fbi->dmadesc_palette = (struct pxafb_dma_descriptor *)((unsigned int)fbi->palette - 1*16);
453
454 #define BYTES_PER_PANEL ((fbi->reg_lccr0 & LCCR0_SDS) ? \
wdenk57b2d802003-06-27 21:31:46 +0000455 (vid->vl_col * vid->vl_row * NBITS(vid->vl_bpix) / 8 / 2) : \
456 (vid->vl_col * vid->vl_row * NBITS(vid->vl_bpix) / 8))
457
wdenk7a428cc2003-06-15 22:40:42 +0000458 /* populate descriptors */
459 fbi->dmadesc_fblow->fdadr = (u_long)fbi->dmadesc_fblow;
460 fbi->dmadesc_fblow->fsadr = fbi->screen + BYTES_PER_PANEL;
461 fbi->dmadesc_fblow->fidr = 0;
462 fbi->dmadesc_fblow->ldcmd = BYTES_PER_PANEL;
463
464 fbi->fdadr1 = (u_long)fbi->dmadesc_fblow; /* only used in dual-panel mode */
wdenk57b2d802003-06-27 21:31:46 +0000465
wdenk7a428cc2003-06-15 22:40:42 +0000466 fbi->dmadesc_fbhigh->fsadr = fbi->screen;
467 fbi->dmadesc_fbhigh->fidr = 0;
468 fbi->dmadesc_fbhigh->ldcmd = BYTES_PER_PANEL;
469
470 fbi->dmadesc_palette->fsadr = fbi->palette;
471 fbi->dmadesc_palette->fidr = 0;
472 fbi->dmadesc_palette->ldcmd = (fbi->palette_size * 2) | LDCMD_PAL;
473
474 if( NBITS(vid->vl_bpix) < 12)
475 {
476 /* assume any mode with <12 bpp is palette driven */
477 fbi->dmadesc_palette->fdadr = (u_long)fbi->dmadesc_fbhigh;
478 fbi->dmadesc_fbhigh->fdadr = (u_long)fbi->dmadesc_palette;
479 /* flips back and forth between pal and fbhigh */
wdenk57b2d802003-06-27 21:31:46 +0000480 fbi->fdadr0 = (u_long)fbi->dmadesc_palette;
wdenk7a428cc2003-06-15 22:40:42 +0000481 }
482 else
483 {
484 /* palette shouldn't be loaded in true-color mode */
485 fbi->dmadesc_fbhigh->fdadr = (u_long)fbi->dmadesc_fbhigh;
486 fbi->fdadr0 = (u_long)fbi->dmadesc_fbhigh; /* no pal just fbhigh */
487 }
488
489 debug("fbi->dmadesc_fblow = 0x%lx\n", (u_long)fbi->dmadesc_fblow);
490 debug("fbi->dmadesc_fbhigh = 0x%lx\n", (u_long)fbi->dmadesc_fbhigh);
491 debug("fbi->dmadesc_palette = 0x%lx\n", (u_long)fbi->dmadesc_palette);
492
493 debug("fbi->dmadesc_fblow->fdadr = 0x%lx\n", fbi->dmadesc_fblow->fdadr);
494 debug("fbi->dmadesc_fbhigh->fdadr = 0x%lx\n", fbi->dmadesc_fbhigh->fdadr);
495 debug("fbi->dmadesc_palette->fdadr = 0x%lx\n", fbi->dmadesc_palette->fdadr);
496
497 debug("fbi->dmadesc_fblow->fsadr = 0x%lx\n", fbi->dmadesc_fblow->fsadr);
498 debug("fbi->dmadesc_fbhigh->fsadr = 0x%lx\n", fbi->dmadesc_fbhigh->fsadr);
499 debug("fbi->dmadesc_palette->fsadr = 0x%lx\n", fbi->dmadesc_palette->fsadr);
500
501 debug("fbi->dmadesc_fblow->ldcmd = 0x%lx\n", fbi->dmadesc_fblow->ldcmd);
502 debug("fbi->dmadesc_fbhigh->ldcmd = 0x%lx\n", fbi->dmadesc_fbhigh->ldcmd);
503 debug("fbi->dmadesc_palette->ldcmd = 0x%lx\n", fbi->dmadesc_palette->ldcmd);
wdenk57b2d802003-06-27 21:31:46 +0000504
wdenk7a428cc2003-06-15 22:40:42 +0000505 return 0;
506}
507
508/************************************************************************/
509/************************************************************************/
510
511#endif /* CONFIG_LCD */