blob: 64cef37bc9c30158dd6e30daf0355c58f85f0bfc [file] [log] [blame]
wdenk71f95112003-06-15 22:40:42 +00001/*
wdenk8655b6f2004-10-09 23:25:58 +00002 * PXA LCD Controller
3 *
wdenk71f95112003-06-15 22:40:42 +00004 * (C) Copyright 2001-2002
5 * Wolfgang Denk, DENX Software Engineering -- wd@denx.de
6 *
Wolfgang Denk3765b3e2013-10-07 13:07:26 +02007 * SPDX-License-Identifier: GPL-2.0+
wdenk71f95112003-06-15 22:40:42 +00008 */
9
10/************************************************************************/
11/* ** HEADER FILES */
12/************************************************************************/
13
wdenk71f95112003-06-15 22:40:42 +000014#include <config.h>
15#include <common.h>
wdenk71f95112003-06-15 22:40:42 +000016#include <stdarg.h>
wdenk71f95112003-06-15 22:40:42 +000017#include <linux/types.h>
Jean-Christophe PLAGNIOL-VILLARD52cb4d42009-05-16 12:14:54 +020018#include <stdio_dev.h>
wdenk8655b6f2004-10-09 23:25:58 +000019#include <lcd.h>
wdenk71f95112003-06-15 22:40:42 +000020#include <asm/arch/pxa-regs.h>
Marek Vasut3ba8bf72010-09-09 09:50:39 +020021#include <asm/io.h>
wdenk71f95112003-06-15 22:40:42 +000022
wdenk8655b6f2004-10-09 23:25:58 +000023/* #define DEBUG */
24
wdenk71f95112003-06-15 22:40:42 +000025#ifdef CONFIG_LCD
26
wdenk71f95112003-06-15 22:40:42 +000027/*----------------------------------------------------------------------*/
wdenk71f95112003-06-15 22:40:42 +000028/*
wdenk8655b6f2004-10-09 23:25:58 +000029 * Define panel bpp, LCCR0, LCCR3 and panel_info video struct for
30 * your display.
wdenk71f95112003-06-15 22:40:42 +000031 */
32
wdenk8655b6f2004-10-09 23:25:58 +000033#ifdef CONFIG_PXA_VGA
34/* LCD outputs connected to a video DAC */
35# define LCD_BPP LCD_COLOR8
wdenk71f95112003-06-15 22:40:42 +000036
37/* you have to set lccr0 and lccr3 (including pcd) */
wdenk8655b6f2004-10-09 23:25:58 +000038# define REG_LCCR0 0x003008f8
39# define REG_LCCR3 0x0300FF01
wdenk71f95112003-06-15 22:40:42 +000040
41/* 640x480x16 @ 61 Hz */
wdenk8655b6f2004-10-09 23:25:58 +000042vidinfo_t panel_info = {
Marek Vasut9f80a202010-09-23 08:32:54 +020043 .vl_col = 640,
44 .vl_row = 480,
45 .vl_width = 640,
46 .vl_height = 480,
47 .vl_clkp = CONFIG_SYS_HIGH,
48 .vl_oep = CONFIG_SYS_HIGH,
49 .vl_hsp = CONFIG_SYS_HIGH,
50 .vl_vsp = CONFIG_SYS_HIGH,
51 .vl_dp = CONFIG_SYS_HIGH,
52 .vl_bpix = LCD_BPP,
53 .vl_lbw = 0,
54 .vl_splt = 0,
55 .vl_clor = 0,
56 .vl_tft = 1,
57 .vl_hpw = 40,
58 .vl_blw = 56,
59 .vl_elw = 56,
60 .vl_vpw = 20,
61 .vl_bfw = 8,
62 .vl_efw = 8,
wdenk71f95112003-06-15 22:40:42 +000063};
64#endif /* CONFIG_PXA_VIDEO */
65
wdenk8655b6f2004-10-09 23:25:58 +000066/*----------------------------------------------------------------------*/
wdenk71f95112003-06-15 22:40:42 +000067#ifdef CONFIG_SHARP_LM8V31
68
wdenk8655b6f2004-10-09 23:25:58 +000069# define LCD_BPP LCD_COLOR8
70# define LCD_INVERT_COLORS /* Needed for colors to be correct, but why? */
wdenk71f95112003-06-15 22:40:42 +000071
72/* you have to set lccr0 and lccr3 (including pcd) */
wdenk8655b6f2004-10-09 23:25:58 +000073# define REG_LCCR0 0x0030087C
74# define REG_LCCR3 0x0340FF08
wdenk71f95112003-06-15 22:40:42 +000075
wdenk8655b6f2004-10-09 23:25:58 +000076vidinfo_t panel_info = {
Marek Vasut9f80a202010-09-23 08:32:54 +020077 .vl_col = 640,
78 .vl_row = 480,
79 .vl_width = 157,
80 .vl_height = 118,
81 .vl_clkp = CONFIG_SYS_HIGH,
82 .vl_oep = CONFIG_SYS_HIGH,
83 .vl_hsp = CONFIG_SYS_HIGH,
84 .vl_vsp = CONFIG_SYS_HIGH,
85 .vl_dp = CONFIG_SYS_HIGH,
86 .vl_bpix = LCD_BPP,
87 .vl_lbw = 0,
88 .vl_splt = 1,
89 .vl_clor = 1,
90 .vl_tft = 0,
91 .vl_hpw = 1,
92 .vl_blw = 3,
93 .vl_elw = 3,
94 .vl_vpw = 1,
95 .vl_bfw = 0,
96 .vl_efw = 0,
wdenk71f95112003-06-15 22:40:42 +000097};
98#endif /* CONFIG_SHARP_LM8V31 */
Marek Vasut9b92cf02010-03-07 23:35:48 +010099/*----------------------------------------------------------------------*/
100#ifdef CONFIG_VOIPAC_LCD
101
102# define LCD_BPP LCD_COLOR8
103# define LCD_INVERT_COLORS
104
105/* you have to set lccr0 and lccr3 (including pcd) */
106# define REG_LCCR0 0x043008f8
107# define REG_LCCR3 0x0340FF08
108
109vidinfo_t panel_info = {
Marek Vasut9f80a202010-09-23 08:32:54 +0200110 .vl_col = 640,
111 .vl_row = 480,
112 .vl_width = 157,
113 .vl_height = 118,
114 .vl_clkp = CONFIG_SYS_HIGH,
115 .vl_oep = CONFIG_SYS_HIGH,
116 .vl_hsp = CONFIG_SYS_HIGH,
117 .vl_vsp = CONFIG_SYS_HIGH,
118 .vl_dp = CONFIG_SYS_HIGH,
119 .vl_bpix = LCD_BPP,
120 .vl_lbw = 0,
121 .vl_splt = 1,
122 .vl_clor = 1,
123 .vl_tft = 1,
124 .vl_hpw = 32,
125 .vl_blw = 144,
126 .vl_elw = 32,
127 .vl_vpw = 2,
128 .vl_bfw = 13,
129 .vl_efw = 30,
Marek Vasut9b92cf02010-03-07 23:35:48 +0100130};
131#endif /* CONFIG_VOIPAC_LCD */
wdenk71f95112003-06-15 22:40:42 +0000132
133/*----------------------------------------------------------------------*/
wdenk8655b6f2004-10-09 23:25:58 +0000134#ifdef CONFIG_HITACHI_SX14
135/* Hitachi SX14Q004-ZZA color STN LCD */
136#define LCD_BPP LCD_COLOR8
wdenk71f95112003-06-15 22:40:42 +0000137
wdenk8655b6f2004-10-09 23:25:58 +0000138/* you have to set lccr0 and lccr3 (including pcd) */
139#define REG_LCCR0 0x00301079
140#define REG_LCCR3 0x0340FF20
wdenk71f95112003-06-15 22:40:42 +0000141
wdenk8655b6f2004-10-09 23:25:58 +0000142vidinfo_t panel_info = {
Marek Vasut9f80a202010-09-23 08:32:54 +0200143 .vl_col = 320,
144 .vl_row = 240,
145 .vl_width = 167,
146 .vl_height = 109,
147 .vl_clkp = CONFIG_SYS_HIGH,
148 .vl_oep = CONFIG_SYS_HIGH,
149 .vl_hsp = CONFIG_SYS_HIGH,
150 .vl_vsp = CONFIG_SYS_HIGH,
151 .vl_dp = CONFIG_SYS_HIGH,
152 .vl_bpix = LCD_BPP,
153 .vl_lbw = 1,
154 .vl_splt = 0,
155 .vl_clor = 1,
156 .vl_tft = 0,
157 .vl_hpw = 1,
158 .vl_blw = 1,
159 .vl_elw = 1,
160 .vl_vpw = 7,
161 .vl_bfw = 0,
162 .vl_efw = 0,
wdenk71f95112003-06-15 22:40:42 +0000163};
wdenk8655b6f2004-10-09 23:25:58 +0000164#endif /* CONFIG_HITACHI_SX14 */
wdenk71f95112003-06-15 22:40:42 +0000165
166/*----------------------------------------------------------------------*/
Marek Vasut546cd602010-07-03 09:38:03 +0200167#ifdef CONFIG_LMS283GF05
168
169# define LCD_BPP LCD_COLOR8
Wolfgang Denk07517e72010-09-19 17:47:52 +0200170/*# define LCD_INVERT_COLORS*/
Marek Vasut546cd602010-07-03 09:38:03 +0200171
172/* you have to set lccr0 and lccr3 (including pcd) */
173# define REG_LCCR0 0x043008f8
174# define REG_LCCR3 0x03b00009
175
176vidinfo_t panel_info = {
Marek Vasut9f80a202010-09-23 08:32:54 +0200177 .vl_col = 240,
178 .vl_row = 320,
179 .vl_width = 240,
180 .vl_height = 320,
181 .vl_clkp = CONFIG_SYS_HIGH,
182 .vl_oep = CONFIG_SYS_LOW,
183 .vl_hsp = CONFIG_SYS_LOW,
184 .vl_vsp = CONFIG_SYS_LOW,
185 .vl_dp = CONFIG_SYS_HIGH,
186 .vl_bpix = LCD_BPP,
187 .vl_lbw = 0,
188 .vl_splt = 1,
189 .vl_clor = 1,
190 .vl_tft = 1,
191 .vl_hpw = 4,
192 .vl_blw = 4,
193 .vl_elw = 8,
194 .vl_vpw = 4,
195 .vl_bfw = 4,
196 .vl_efw = 8,
Marek Vasut546cd602010-07-03 09:38:03 +0200197};
198#endif /* CONFIG_LMS283GF05 */
199
200/*----------------------------------------------------------------------*/
wdenk71f95112003-06-15 22:40:42 +0000201
Marek Vasutf7d58d92010-07-18 04:46:55 +0200202#ifdef CONFIG_ACX517AKN
203
204# define LCD_BPP LCD_COLOR8
205
206/* you have to set lccr0 and lccr3 (including pcd) */
207# define REG_LCCR0 0x003008f9
208# define REG_LCCR3 0x03700006
209
210vidinfo_t panel_info = {
211 .vl_col = 320,
212 .vl_row = 320,
213 .vl_width = 320,
214 .vl_height = 320,
215 .vl_clkp = CONFIG_SYS_HIGH,
216 .vl_oep = CONFIG_SYS_LOW,
217 .vl_hsp = CONFIG_SYS_LOW,
218 .vl_vsp = CONFIG_SYS_LOW,
219 .vl_dp = CONFIG_SYS_HIGH,
220 .vl_bpix = LCD_BPP,
221 .vl_lbw = 0,
222 .vl_splt = 1,
223 .vl_clor = 1,
224 .vl_tft = 1,
225 .vl_hpw = 0x04,
226 .vl_blw = 0x1c,
227 .vl_elw = 0x08,
228 .vl_vpw = 0x01,
229 .vl_bfw = 0x07,
230 .vl_efw = 0x08,
231};
232#endif /* CONFIG_ACX517AKN */
233
Mike Dunn98eda332013-04-12 11:59:13 -0700234#ifdef CONFIG_ACX544AKN
235
236# define LCD_BPP LCD_COLOR16
237
238/* you have to set lccr0 and lccr3 (including pcd) */
239# define REG_LCCR0 0x003008f9
240# define REG_LCCR3 0x04700007 /* 16bpp */
241
242vidinfo_t panel_info = {
243 .vl_col = 320,
244 .vl_row = 320,
245 .vl_width = 320,
246 .vl_height = 320,
247 .vl_clkp = CONFIG_SYS_LOW,
248 .vl_oep = CONFIG_SYS_LOW,
249 .vl_hsp = CONFIG_SYS_LOW,
250 .vl_vsp = CONFIG_SYS_LOW,
251 .vl_dp = CONFIG_SYS_LOW,
252 .vl_bpix = LCD_BPP,
253 .vl_lbw = 0,
254 .vl_splt = 0,
255 .vl_clor = 1,
256 .vl_tft = 1,
257 .vl_hpw = 0x05,
258 .vl_blw = 0x13,
259 .vl_elw = 0x08,
260 .vl_vpw = 0x02,
261 .vl_bfw = 0x07,
262 .vl_efw = 0x05,
263};
264#endif /* CONFIG_ACX544AKN */
265
Marek Vasutf7d58d92010-07-18 04:46:55 +0200266/*----------------------------------------------------------------------*/
267
Marek Vasut42222be2010-07-19 11:21:38 +0200268#ifdef CONFIG_LQ038J7DH53
269
270# define LCD_BPP LCD_COLOR8
271
272/* you have to set lccr0 and lccr3 (including pcd) */
273# define REG_LCCR0 0x003008f9
274# define REG_LCCR3 0x03700004
275
276vidinfo_t panel_info = {
277 .vl_col = 320,
278 .vl_row = 480,
279 .vl_width = 320,
280 .vl_height = 480,
281 .vl_clkp = CONFIG_SYS_HIGH,
282 .vl_oep = CONFIG_SYS_LOW,
283 .vl_hsp = CONFIG_SYS_LOW,
284 .vl_vsp = CONFIG_SYS_LOW,
285 .vl_dp = CONFIG_SYS_HIGH,
286 .vl_bpix = LCD_BPP,
287 .vl_lbw = 0,
288 .vl_splt = 1,
289 .vl_clor = 1,
290 .vl_tft = 1,
291 .vl_hpw = 0x04,
292 .vl_blw = 0x20,
293 .vl_elw = 0x01,
294 .vl_vpw = 0x01,
295 .vl_bfw = 0x04,
296 .vl_efw = 0x01,
297};
298#endif /* CONFIG_ACX517AKN */
299
300/*----------------------------------------------------------------------*/
301
Marek Vasut8b71d2b2009-12-31 03:44:22 +0100302#ifdef CONFIG_LITTLETON_LCD
303# define LCD_BPP LCD_COLOR8
304
305/* you have to set lccr0 and lccr3 (including pcd) */
306# define REG_LCCR0 0x003008f8
307# define REG_LCCR3 0x0300FF04
308
309vidinfo_t panel_info = {
310 .vl_col = 480,
311 .vl_row = 640,
312 .vl_width = 480,
313 .vl_height = 640,
314 .vl_clkp = CONFIG_SYS_HIGH,
315 .vl_oep = CONFIG_SYS_HIGH,
316 .vl_hsp = CONFIG_SYS_HIGH,
317 .vl_vsp = CONFIG_SYS_HIGH,
318 .vl_dp = CONFIG_SYS_HIGH,
319 .vl_bpix = LCD_BPP,
320 .vl_lbw = 0,
321 .vl_splt = 0,
322 .vl_clor = 0,
323 .vl_tft = 1,
324 .vl_hpw = 9,
325 .vl_blw = 8,
326 .vl_elw = 24,
327 .vl_vpw = 2,
328 .vl_bfw = 2,
329 .vl_efw = 4,
330};
331#endif /* CONFIG_LITTLETON_LCD */
332
333/*----------------------------------------------------------------------*/
334
wdenk8655b6f2004-10-09 23:25:58 +0000335static int pxafb_init_mem (void *lcdbase, vidinfo_t *vid);
336static void pxafb_setup_gpio (vidinfo_t *vid);
337static void pxafb_enable_controller (vidinfo_t *vid);
338static int pxafb_init (vidinfo_t *vid);
wdenk71f95112003-06-15 22:40:42 +0000339
wdenk71f95112003-06-15 22:40:42 +0000340/************************************************************************/
wdenk8655b6f2004-10-09 23:25:58 +0000341/* --------------- PXA chipset specific functions ------------------- */
wdenk71f95112003-06-15 22:40:42 +0000342/************************************************************************/
343
Nikita Kiryanov38b55082015-02-03 13:32:21 +0200344ushort *configuration_get_cmap(void)
345{
346 struct pxafb_info *fbi = &panel_info.pxa;
347 return (ushort *)fbi->palette;
348}
349
wdenk8655b6f2004-10-09 23:25:58 +0000350void lcd_ctrl_init (void *lcdbase)
wdenk71f95112003-06-15 22:40:42 +0000351{
wdenk8bde7f72003-06-27 21:31:46 +0000352 pxafb_init_mem(lcdbase, &panel_info);
wdenk71f95112003-06-15 22:40:42 +0000353 pxafb_init(&panel_info);
354 pxafb_setup_gpio(&panel_info);
355 pxafb_enable_controller(&panel_info);
356}
357
358/*----------------------------------------------------------------------*/
wdenk71f95112003-06-15 22:40:42 +0000359#if LCD_BPP == LCD_COLOR8
wdenk8655b6f2004-10-09 23:25:58 +0000360void
wdenk71f95112003-06-15 22:40:42 +0000361lcd_setcolreg (ushort regno, ushort red, ushort green, ushort blue)
362{
363 struct pxafb_info *fbi = &panel_info.pxa;
364 unsigned short *palette = (unsigned short *)fbi->palette;
365 u_int val;
wdenk8bde7f72003-06-27 21:31:46 +0000366
wdenk71f95112003-06-15 22:40:42 +0000367 if (regno < fbi->palette_size) {
368 val = ((red << 8) & 0xf800);
369 val |= ((green << 4) & 0x07e0);
370 val |= (blue & 0x001f);
371
372#ifdef LCD_INVERT_COLORS
373 palette[regno] = ~val;
374#else
wdenk8655b6f2004-10-09 23:25:58 +0000375 palette[regno] = val;
wdenk71f95112003-06-15 22:40:42 +0000376#endif
377 }
378
379 debug ("setcolreg: reg %2d @ %p: R=%02X G=%02X B=%02X => %04X\n",
380 regno, &palette[regno],
381 red, green, blue,
382 palette[regno]);
383}
wdenk8655b6f2004-10-09 23:25:58 +0000384#endif /* LCD_COLOR8 */
wdenk71f95112003-06-15 22:40:42 +0000385
386/*----------------------------------------------------------------------*/
Mike Dunn86e929e2013-04-12 11:59:14 -0700387__weak void lcd_enable(void)
wdenk71f95112003-06-15 22:40:42 +0000388{
389}
390
wdenk8655b6f2004-10-09 23:25:58 +0000391/************************************************************************/
392/* ** PXA255 specific routines */
393/************************************************************************/
394
395/*
396 * Calculate fb size for VIDEOLFB_ATAG. Size returned contains fb,
397 * descriptors and palette areas.
398 */
399ulong calc_fbsize (void)
wdenk71f95112003-06-15 22:40:42 +0000400{
wdenk8655b6f2004-10-09 23:25:58 +0000401 ulong size;
402 int line_length = (panel_info.vl_col * NBITS (panel_info.vl_bpix)) / 8;
wdenk71f95112003-06-15 22:40:42 +0000403
wdenk8655b6f2004-10-09 23:25:58 +0000404 size = line_length * panel_info.vl_row;
405 size += PAGE_SIZE;
wdenk71f95112003-06-15 22:40:42 +0000406
wdenk8655b6f2004-10-09 23:25:58 +0000407 return size;
wdenk71f95112003-06-15 22:40:42 +0000408}
409
wdenk8655b6f2004-10-09 23:25:58 +0000410static int pxafb_init_mem (void *lcdbase, vidinfo_t *vid)
wdenk71f95112003-06-15 22:40:42 +0000411{
412 u_long palette_mem_size;
413 struct pxafb_info *fbi = &vid->pxa;
414 int fb_size = vid->vl_row * (vid->vl_col * NBITS (vid->vl_bpix)) / 8;
415
416 fbi->screen = (u_long)lcdbase;
417
418 fbi->palette_size = NBITS(vid->vl_bpix) == 8 ? 256 : 16;
419 palette_mem_size = fbi->palette_size * sizeof(u16);
wdenk8655b6f2004-10-09 23:25:58 +0000420
wdenk71f95112003-06-15 22:40:42 +0000421 debug("palette_mem_size = 0x%08lx\n", (u_long) palette_mem_size);
422 /* locate palette and descs at end of page following fb */
wdenk8655b6f2004-10-09 23:25:58 +0000423 fbi->palette = (u_long)lcdbase + fb_size + PAGE_SIZE - palette_mem_size;
wdenk71f95112003-06-15 22:40:42 +0000424
425 return 0;
426}
Marek Vasut8c35d0c2009-11-28 13:57:43 +0100427#ifdef CONFIG_CPU_MONAHANS
428static inline void pxafb_setup_gpio (vidinfo_t *vid) {}
429#else
wdenk8655b6f2004-10-09 23:25:58 +0000430static void pxafb_setup_gpio (vidinfo_t *vid)
wdenk71f95112003-06-15 22:40:42 +0000431{
432 u_long lccr0;
433
434 /*
435 * setup is based on type of panel supported
436 */
437
438 lccr0 = vid->pxa.reg_lccr0;
439
440 /* 4 bit interface */
441 if ((lccr0 & LCCR0_CMS) && (lccr0 & LCCR0_SDS) && !(lccr0 & LCCR0_DPD))
442 {
443 debug("Setting GPIO for 4 bit data\n");
444 /* bits 58-61 */
Marek Vasut3ba8bf72010-09-09 09:50:39 +0200445 writel(readl(GPDR1) | (0xf << 26), GPDR1);
446 writel((readl(GAFR1_U) & ~(0xff << 20)) | (0xaa << 20),
447 GAFR1_U);
wdenk71f95112003-06-15 22:40:42 +0000448
449 /* bits 74-77 */
Marek Vasut3ba8bf72010-09-09 09:50:39 +0200450 writel(readl(GPDR2) | (0xf << 10), GPDR2);
451 writel((readl(GAFR2_L) & ~(0xff << 20)) | (0xaa << 20),
452 GAFR2_L);
wdenk71f95112003-06-15 22:40:42 +0000453 }
454
455 /* 8 bit interface */
456 else if (((lccr0 & LCCR0_CMS) && ((lccr0 & LCCR0_SDS) || (lccr0 & LCCR0_DPD))) ||
wdenk8655b6f2004-10-09 23:25:58 +0000457 (!(lccr0 & LCCR0_CMS) && !(lccr0 & LCCR0_PAS) && !(lccr0 & LCCR0_SDS)))
wdenk71f95112003-06-15 22:40:42 +0000458 {
459 debug("Setting GPIO for 8 bit data\n");
460 /* bits 58-65 */
Marek Vasut3ba8bf72010-09-09 09:50:39 +0200461 writel(readl(GPDR1) | (0x3f << 26), GPDR1);
462 writel(readl(GPDR2) | (0x3), GPDR2);
wdenk71f95112003-06-15 22:40:42 +0000463
Marek Vasut3ba8bf72010-09-09 09:50:39 +0200464 writel((readl(GAFR1_U) & ~(0xfff << 20)) | (0xaaa << 20),
465 GAFR1_U);
466 writel((readl(GAFR2_L) & ~0xf) | (0xa), GAFR2_L);
wdenk71f95112003-06-15 22:40:42 +0000467
468 /* bits 74-77 */
Marek Vasut3ba8bf72010-09-09 09:50:39 +0200469 writel(readl(GPDR2) | (0xf << 10), GPDR2);
470 writel((readl(GAFR2_L) & ~(0xff << 20)) | (0xaa << 20),
471 GAFR2_L);
wdenk71f95112003-06-15 22:40:42 +0000472 }
473
474 /* 16 bit interface */
475 else if (!(lccr0 & LCCR0_CMS) && ((lccr0 & LCCR0_SDS) || (lccr0 & LCCR0_PAS)))
476 {
477 debug("Setting GPIO for 16 bit data\n");
478 /* bits 58-77 */
Marek Vasut3ba8bf72010-09-09 09:50:39 +0200479 writel(readl(GPDR1) | (0x3f << 26), GPDR1);
480 writel(readl(GPDR2) | 0x00003fff, GPDR2);
wdenk71f95112003-06-15 22:40:42 +0000481
Marek Vasut3ba8bf72010-09-09 09:50:39 +0200482 writel((readl(GAFR1_U) & ~(0xfff << 20)) | (0xaaa << 20),
483 GAFR1_U);
484 writel((readl(GAFR2_L) & 0xf0000000) | 0x0aaaaaaa, GAFR2_L);
wdenk71f95112003-06-15 22:40:42 +0000485 }
486 else
487 {
488 printf("pxafb_setup_gpio: unable to determine bits per pixel\n");
489 }
490}
Marek Vasut8c35d0c2009-11-28 13:57:43 +0100491#endif
wdenk71f95112003-06-15 22:40:42 +0000492
wdenk8655b6f2004-10-09 23:25:58 +0000493static void pxafb_enable_controller (vidinfo_t *vid)
wdenk71f95112003-06-15 22:40:42 +0000494{
495 debug("Enabling LCD controller\n");
496
497 /* Sequence from 11.7.10 */
Marek Vasut3ba8bf72010-09-09 09:50:39 +0200498 writel(vid->pxa.reg_lccr3, LCCR3);
499 writel(vid->pxa.reg_lccr2, LCCR2);
500 writel(vid->pxa.reg_lccr1, LCCR1);
501 writel(vid->pxa.reg_lccr0 & ~LCCR0_ENB, LCCR0);
502 writel(vid->pxa.fdadr0, FDADR0);
503 writel(vid->pxa.fdadr1, FDADR1);
504 writel(readl(LCCR0) | LCCR0_ENB, LCCR0);
wdenk71f95112003-06-15 22:40:42 +0000505
Marek Vasut8c35d0c2009-11-28 13:57:43 +0100506#ifdef CONFIG_CPU_MONAHANS
Marek Vasut3ba8bf72010-09-09 09:50:39 +0200507 writel(readl(CKENA) | CKENA_1_LCD, CKENA);
Marek Vasut8c35d0c2009-11-28 13:57:43 +0100508#else
Marek Vasut3ba8bf72010-09-09 09:50:39 +0200509 writel(readl(CKEN) | CKEN16_LCD, CKEN);
Marek Vasut8c35d0c2009-11-28 13:57:43 +0100510#endif
wdenk71f95112003-06-15 22:40:42 +0000511
Marek Vasut3ba8bf72010-09-09 09:50:39 +0200512 debug("FDADR0 = 0x%08x\n", readl(FDADR0));
513 debug("FDADR1 = 0x%08x\n", readl(FDADR1));
514 debug("LCCR0 = 0x%08x\n", readl(LCCR0));
515 debug("LCCR1 = 0x%08x\n", readl(LCCR1));
516 debug("LCCR2 = 0x%08x\n", readl(LCCR2));
517 debug("LCCR3 = 0x%08x\n", readl(LCCR3));
wdenk71f95112003-06-15 22:40:42 +0000518}
519
wdenk8655b6f2004-10-09 23:25:58 +0000520static int pxafb_init (vidinfo_t *vid)
wdenk71f95112003-06-15 22:40:42 +0000521{
522 struct pxafb_info *fbi = &vid->pxa;
523
524 debug("Configuring PXA LCD\n");
525
526 fbi->reg_lccr0 = REG_LCCR0;
527 fbi->reg_lccr3 = REG_LCCR3;
528
529 debug("vid: vl_col=%d hslen=%d lm=%d rm=%d\n",
530 vid->vl_col, vid->vl_hpw,
531 vid->vl_blw, vid->vl_elw);
532 debug("vid: vl_row=%d vslen=%d um=%d bm=%d\n",
533 vid->vl_row, vid->vl_vpw,
534 vid->vl_bfw, vid->vl_efw);
535
536 fbi->reg_lccr1 =
537 LCCR1_DisWdth(vid->vl_col) +
538 LCCR1_HorSnchWdth(vid->vl_hpw) +
539 LCCR1_BegLnDel(vid->vl_blw) +
540 LCCR1_EndLnDel(vid->vl_elw);
wdenk8bde7f72003-06-27 21:31:46 +0000541
wdenk71f95112003-06-15 22:40:42 +0000542 fbi->reg_lccr2 =
543 LCCR2_DisHght(vid->vl_row) +
544 LCCR2_VrtSnchWdth(vid->vl_vpw) +
545 LCCR2_BegFrmDel(vid->vl_bfw) +
546 LCCR2_EndFrmDel(vid->vl_efw);
547
wdenk8bde7f72003-06-27 21:31:46 +0000548 fbi->reg_lccr3 = REG_LCCR3 & ~(LCCR3_HSP | LCCR3_VSP);
wdenk8655b6f2004-10-09 23:25:58 +0000549 fbi->reg_lccr3 |= (vid->vl_hsp ? LCCR3_HorSnchL : LCCR3_HorSnchH)
550 | (vid->vl_vsp ? LCCR3_VrtSnchL : LCCR3_VrtSnchH);
wdenk8bde7f72003-06-27 21:31:46 +0000551
wdenk71f95112003-06-15 22:40:42 +0000552
553 /* setup dma descriptors */
554 fbi->dmadesc_fblow = (struct pxafb_dma_descriptor *)((unsigned int)fbi->palette - 3*16);
555 fbi->dmadesc_fbhigh = (struct pxafb_dma_descriptor *)((unsigned int)fbi->palette - 2*16);
556 fbi->dmadesc_palette = (struct pxafb_dma_descriptor *)((unsigned int)fbi->palette - 1*16);
557
558 #define BYTES_PER_PANEL ((fbi->reg_lccr0 & LCCR0_SDS) ? \
wdenk8bde7f72003-06-27 21:31:46 +0000559 (vid->vl_col * vid->vl_row * NBITS(vid->vl_bpix) / 8 / 2) : \
560 (vid->vl_col * vid->vl_row * NBITS(vid->vl_bpix) / 8))
561
wdenk71f95112003-06-15 22:40:42 +0000562 /* populate descriptors */
563 fbi->dmadesc_fblow->fdadr = (u_long)fbi->dmadesc_fblow;
564 fbi->dmadesc_fblow->fsadr = fbi->screen + BYTES_PER_PANEL;
565 fbi->dmadesc_fblow->fidr = 0;
566 fbi->dmadesc_fblow->ldcmd = BYTES_PER_PANEL;
567
568 fbi->fdadr1 = (u_long)fbi->dmadesc_fblow; /* only used in dual-panel mode */
wdenk8bde7f72003-06-27 21:31:46 +0000569
wdenk71f95112003-06-15 22:40:42 +0000570 fbi->dmadesc_fbhigh->fsadr = fbi->screen;
571 fbi->dmadesc_fbhigh->fidr = 0;
572 fbi->dmadesc_fbhigh->ldcmd = BYTES_PER_PANEL;
573
574 fbi->dmadesc_palette->fsadr = fbi->palette;
575 fbi->dmadesc_palette->fidr = 0;
576 fbi->dmadesc_palette->ldcmd = (fbi->palette_size * 2) | LDCMD_PAL;
577
578 if( NBITS(vid->vl_bpix) < 12)
579 {
580 /* assume any mode with <12 bpp is palette driven */
581 fbi->dmadesc_palette->fdadr = (u_long)fbi->dmadesc_fbhigh;
582 fbi->dmadesc_fbhigh->fdadr = (u_long)fbi->dmadesc_palette;
583 /* flips back and forth between pal and fbhigh */
wdenk8bde7f72003-06-27 21:31:46 +0000584 fbi->fdadr0 = (u_long)fbi->dmadesc_palette;
wdenk71f95112003-06-15 22:40:42 +0000585 }
586 else
587 {
588 /* palette shouldn't be loaded in true-color mode */
589 fbi->dmadesc_fbhigh->fdadr = (u_long)fbi->dmadesc_fbhigh;
590 fbi->fdadr0 = (u_long)fbi->dmadesc_fbhigh; /* no pal just fbhigh */
591 }
592
593 debug("fbi->dmadesc_fblow = 0x%lx\n", (u_long)fbi->dmadesc_fblow);
594 debug("fbi->dmadesc_fbhigh = 0x%lx\n", (u_long)fbi->dmadesc_fbhigh);
595 debug("fbi->dmadesc_palette = 0x%lx\n", (u_long)fbi->dmadesc_palette);
596
597 debug("fbi->dmadesc_fblow->fdadr = 0x%lx\n", fbi->dmadesc_fblow->fdadr);
598 debug("fbi->dmadesc_fbhigh->fdadr = 0x%lx\n", fbi->dmadesc_fbhigh->fdadr);
599 debug("fbi->dmadesc_palette->fdadr = 0x%lx\n", fbi->dmadesc_palette->fdadr);
600
601 debug("fbi->dmadesc_fblow->fsadr = 0x%lx\n", fbi->dmadesc_fblow->fsadr);
602 debug("fbi->dmadesc_fbhigh->fsadr = 0x%lx\n", fbi->dmadesc_fbhigh->fsadr);
603 debug("fbi->dmadesc_palette->fsadr = 0x%lx\n", fbi->dmadesc_palette->fsadr);
604
605 debug("fbi->dmadesc_fblow->ldcmd = 0x%lx\n", fbi->dmadesc_fblow->ldcmd);
606 debug("fbi->dmadesc_fbhigh->ldcmd = 0x%lx\n", fbi->dmadesc_fbhigh->ldcmd);
607 debug("fbi->dmadesc_palette->ldcmd = 0x%lx\n", fbi->dmadesc_palette->ldcmd);
wdenk8bde7f72003-06-27 21:31:46 +0000608
wdenk71f95112003-06-15 22:40:42 +0000609 return 0;
610}
611
612/************************************************************************/
613/************************************************************************/
614
615#endif /* CONFIG_LCD */