aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Purdie <rpurdie@net.rmk.(none)>2006-09-20 17:54:21 -0400
committerRussell King <rmk+kernel@arm.linux.org.uk>2006-10-02 08:33:37 -0400
commitd14b272bc63f35a8f20b4b1df16c080b8d24f8f1 (patch)
treef754f3b333388e0ab78c934fd492906688fab2a6
parentc5d311c7e93c7d84941028835bc6ae5e1bc4e73c (diff)
[ARM] 3848/1: pxafb: Add option of fixing video modes and spitz QVGA mode support
Add the ability to have pxafb use only certain fixed video modes (selected on a per platform basis). This is useful on production hardware such as the Zaurus cxx00 models where the valid modes are known in advance and any other modes could result in hardware damage. Following this, add support for the cxx00 QVGA mode. Mode information is passed to the lcd_power call to allowing the panel drivers to configure the display hardware accordingly (corgi_lcd already contains the functionality for the cxx00 panel). This mirrors the setup already used by w100fb. Signed-off-by: Richard Purdie <rpurdie@rpsys.net> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
-rw-r--r--arch/arm/mach-pxa/corgi_lcd.c4
-rw-r--r--arch/arm/mach-pxa/generic.c13
-rw-r--r--arch/arm/mach-pxa/idp.c9
-rw-r--r--arch/arm/mach-pxa/lpd270.c42
-rw-r--r--arch/arm/mach-pxa/lubbock.c7
-rw-r--r--arch/arm/mach-pxa/mainstone.c17
-rw-r--r--arch/arm/mach-pxa/poodle.c12
-rw-r--r--arch/arm/mach-pxa/spitz.c51
-rw-r--r--arch/arm/mach-pxa/trizeps4.c7
-rw-r--r--drivers/video/pxafb.c106
-rw-r--r--drivers/video/pxafb.h4
-rw-r--r--include/asm-arm/arch-pxa/pxafb.h14
-rw-r--r--include/asm-arm/arch-pxa/spitz.h4
13 files changed, 206 insertions, 84 deletions
diff --git a/arch/arm/mach-pxa/corgi_lcd.c b/arch/arm/mach-pxa/corgi_lcd.c
index 6dbcaf114ad7..d7815491b752 100644
--- a/arch/arm/mach-pxa/corgi_lcd.c
+++ b/arch/arm/mach-pxa/corgi_lcd.c
@@ -431,10 +431,10 @@ struct platform_device corgifb_device = {
431 431
432#include <asm/arch/pxafb.h> 432#include <asm/arch/pxafb.h>
433 433
434void spitz_lcd_power(int on) 434void spitz_lcd_power(int on, struct fb_var_screeninfo *var)
435{ 435{
436 if (on) 436 if (on)
437 lcdtg_hw_init(480); 437 lcdtg_hw_init(var->xres);
438 else 438 else
439 lcdtg_suspend(); 439 lcdtg_suspend();
440} 440}
diff --git a/arch/arm/mach-pxa/generic.c b/arch/arm/mach-pxa/generic.c
index 5efa84749f37..45fb2c3bcf82 100644
--- a/arch/arm/mach-pxa/generic.c
+++ b/arch/arm/mach-pxa/generic.c
@@ -204,13 +204,6 @@ static struct platform_device udc_device = {
204 } 204 }
205}; 205};
206 206
207static struct pxafb_mach_info pxa_fb_info;
208
209void __init set_pxa_fb_info(struct pxafb_mach_info *hard_pxa_fb_info)
210{
211 memcpy(&pxa_fb_info,hard_pxa_fb_info,sizeof(struct pxafb_mach_info));
212}
213
214static struct resource pxafb_resources[] = { 207static struct resource pxafb_resources[] = {
215 [0] = { 208 [0] = {
216 .start = 0x44000000, 209 .start = 0x44000000,
@@ -230,7 +223,6 @@ static struct platform_device pxafb_device = {
230 .name = "pxa2xx-fb", 223 .name = "pxa2xx-fb",
231 .id = -1, 224 .id = -1,
232 .dev = { 225 .dev = {
233 .platform_data = &pxa_fb_info,
234 .dma_mask = &fb_dma_mask, 226 .dma_mask = &fb_dma_mask,
235 .coherent_dma_mask = 0xffffffff, 227 .coherent_dma_mask = 0xffffffff,
236 }, 228 },
@@ -238,6 +230,11 @@ static struct platform_device pxafb_device = {
238 .resource = pxafb_resources, 230 .resource = pxafb_resources,
239}; 231};
240 232
233void __init set_pxa_fb_info(struct pxafb_mach_info *info)
234{
235 pxafb_device.dev.platform_data = info;
236}
237
241void __init set_pxa_fb_parent(struct device *parent_dev) 238void __init set_pxa_fb_parent(struct device *parent_dev)
242{ 239{
243 pxafb_device.dev.parent = parent_dev; 240 pxafb_device.dev.parent = parent_dev;
diff --git a/arch/arm/mach-pxa/idp.c b/arch/arm/mach-pxa/idp.c
index 6914d22bc20f..3e4b0ab71c66 100644
--- a/arch/arm/mach-pxa/idp.c
+++ b/arch/arm/mach-pxa/idp.c
@@ -82,7 +82,7 @@ static void idp_vlcd(int on)
82 } 82 }
83} 83}
84 84
85static void idp_lcd_power(int on) 85static void idp_lcd_power(int on, struct fb_var_screeninfo *var)
86{ 86{
87 if (on) { 87 if (on) {
88 IDP_CPLD_LCD |= (1<<0); 88 IDP_CPLD_LCD |= (1<<0);
@@ -99,7 +99,7 @@ static void idp_lcd_power(int on)
99 idp_vlcd(on); 99 idp_vlcd(on);
100} 100}
101 101
102static struct pxafb_mach_info sharp_lm8v31 __initdata = { 102static struct pxafb_mode_info sharp_lm8v31_mode = {
103 .pixclock = 270000, 103 .pixclock = 270000,
104 .xres = 640, 104 .xres = 640,
105 .yres = 480, 105 .yres = 480,
@@ -112,6 +112,11 @@ static struct pxafb_mach_info sharp_lm8v31 __initdata = {
112 .lower_margin = 0, 112 .lower_margin = 0,
113 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, 113 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
114 .cmap_greyscale = 0, 114 .cmap_greyscale = 0,
115};
116
117static struct pxafb_mach_info sharp_lm8v31 = {
118 .modes = &sharp_lm8v31_mode,
119 .num_modes = 1,
115 .cmap_inverse = 0, 120 .cmap_inverse = 0,
116 .cmap_static = 0, 121 .cmap_static = 0,
117 .lccr0 = LCCR0_SDS, 122 .lccr0 = LCCR0_SDS,
diff --git a/arch/arm/mach-pxa/lpd270.c b/arch/arm/mach-pxa/lpd270.c
index 12479ae26db2..eff2a91b2565 100644
--- a/arch/arm/mach-pxa/lpd270.c
+++ b/arch/arm/mach-pxa/lpd270.c
@@ -248,7 +248,7 @@ static void lpd270_backlight_power(int on)
248} 248}
249 249
250/* 5.7" TFT QVGA (LoLo display number 1) */ 250/* 5.7" TFT QVGA (LoLo display number 1) */
251static struct pxafb_mach_info sharp_lq057q3dc02 __initdata = { 251static struct pxafb_mode_info sharp_lq057q3dc02_mode = {
252 .pixclock = 150000, 252 .pixclock = 150000,
253 .xres = 320, 253 .xres = 320,
254 .yres = 240, 254 .yres = 240,
@@ -260,13 +260,18 @@ static struct pxafb_mach_info sharp_lq057q3dc02 __initdata = {
260 .upper_margin = 0x08, 260 .upper_margin = 0x08,
261 .lower_margin = 0x14, 261 .lower_margin = 0x14,
262 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, 262 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
263};
264
265static struct pxafb_mach_info sharp_lq057q3dc02 = {
266 .modes = &sharp_lq057q3dc02_mode,
267 .num_modes = 1,
263 .lccr0 = 0x07800080, 268 .lccr0 = 0x07800080,
264 .lccr3 = 0x00400000, 269 .lccr3 = 0x00400000,
265 .pxafb_backlight_power = lpd270_backlight_power, 270 .pxafb_backlight_power = lpd270_backlight_power,
266}; 271};
267 272
268/* 12.1" TFT SVGA (LoLo display number 2) */ 273/* 12.1" TFT SVGA (LoLo display number 2) */
269static struct pxafb_mach_info sharp_lq121s1dg31 __initdata = { 274static struct pxafb_mode_info sharp_lq121s1dg31_mode = {
270 .pixclock = 50000, 275 .pixclock = 50000,
271 .xres = 800, 276 .xres = 800,
272 .yres = 600, 277 .yres = 600,
@@ -278,13 +283,18 @@ static struct pxafb_mach_info sharp_lq121s1dg31 __initdata = {
278 .upper_margin = 0x14, 283 .upper_margin = 0x14,
279 .lower_margin = 0x0a, 284 .lower_margin = 0x0a,
280 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, 285 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
286};
287
288static struct pxafb_mach_info sharp_lq121s1dg31 = {
289 .modes = &sharp_lq121s1dg31_mode,
290 .num_modes = 1,
281 .lccr0 = 0x07800080, 291 .lccr0 = 0x07800080,
282 .lccr3 = 0x00400000, 292 .lccr3 = 0x00400000,
283 .pxafb_backlight_power = lpd270_backlight_power, 293 .pxafb_backlight_power = lpd270_backlight_power,
284}; 294};
285 295
286/* 3.6" TFT QVGA (LoLo display number 3) */ 296/* 3.6" TFT QVGA (LoLo display number 3) */
287static struct pxafb_mach_info sharp_lq036q1da01 __initdata = { 297static struct pxafb_mode_info sharp_lq036q1da01_mode = {
288 .pixclock = 150000, 298 .pixclock = 150000,
289 .xres = 320, 299 .xres = 320,
290 .yres = 240, 300 .yres = 240,
@@ -296,13 +306,18 @@ static struct pxafb_mach_info sharp_lq036q1da01 __initdata = {
296 .upper_margin = 0x03, 306 .upper_margin = 0x03,
297 .lower_margin = 0x03, 307 .lower_margin = 0x03,
298 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, 308 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
309};
310
311static struct pxafb_mach_info sharp_lq036q1da01 = {
312 .modes = &sharp_lq036q1da01_mode,
313 .num_modes = 1,
299 .lccr0 = 0x07800080, 314 .lccr0 = 0x07800080,
300 .lccr3 = 0x00400000, 315 .lccr3 = 0x00400000,
301 .pxafb_backlight_power = lpd270_backlight_power, 316 .pxafb_backlight_power = lpd270_backlight_power,
302}; 317};
303 318
304/* 6.4" TFT VGA (LoLo display number 5) */ 319/* 6.4" TFT VGA (LoLo display number 5) */
305static struct pxafb_mach_info sharp_lq64d343 __initdata = { 320static struct pxafb_mode_info sharp_lq64d343_mode = {
306 .pixclock = 25000, 321 .pixclock = 25000,
307 .xres = 640, 322 .xres = 640,
308 .yres = 480, 323 .yres = 480,
@@ -314,13 +329,18 @@ static struct pxafb_mach_info sharp_lq64d343 __initdata = {
314 .upper_margin = 0x22, 329 .upper_margin = 0x22,
315 .lower_margin = 0x00, 330 .lower_margin = 0x00,
316 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, 331 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
332};
333
334static struct pxafb_mach_info sharp_lq64d343 = {
335 .modes = &sharp_lq64d343_mode,
336 .num_modes = 1,
317 .lccr0 = 0x07800080, 337 .lccr0 = 0x07800080,
318 .lccr3 = 0x00400000, 338 .lccr3 = 0x00400000,
319 .pxafb_backlight_power = lpd270_backlight_power, 339 .pxafb_backlight_power = lpd270_backlight_power,
320}; 340};
321 341
322/* 10.4" TFT VGA (LoLo display number 7) */ 342/* 10.4" TFT VGA (LoLo display number 7) */
323static struct pxafb_mach_info sharp_lq10d368 __initdata = { 343static struct pxafb_mode_info sharp_lq10d368_mode = {
324 .pixclock = 25000, 344 .pixclock = 25000,
325 .xres = 640, 345 .xres = 640,
326 .yres = 480, 346 .yres = 480,
@@ -332,13 +352,18 @@ static struct pxafb_mach_info sharp_lq10d368 __initdata = {
332 .upper_margin = 0x22, 352 .upper_margin = 0x22,
333 .lower_margin = 0x00, 353 .lower_margin = 0x00,
334 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, 354 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
355};
356
357static struct pxafb_mach_info sharp_lq10d368 = {
358 .modes = &sharp_lq10d368_mode,
359 .num_modes = 1,
335 .lccr0 = 0x07800080, 360 .lccr0 = 0x07800080,
336 .lccr3 = 0x00400000, 361 .lccr3 = 0x00400000,
337 .pxafb_backlight_power = lpd270_backlight_power, 362 .pxafb_backlight_power = lpd270_backlight_power,
338}; 363};
339 364
340/* 3.5" TFT QVGA (LoLo display number 8) */ 365/* 3.5" TFT QVGA (LoLo display number 8) */
341static struct pxafb_mach_info sharp_lq035q7db02_20 __initdata = { 366static struct pxafb_mode_info sharp_lq035q7db02_20_mode = {
342 .pixclock = 150000, 367 .pixclock = 150000,
343 .xres = 240, 368 .xres = 240,
344 .yres = 320, 369 .yres = 320,
@@ -350,6 +375,11 @@ static struct pxafb_mach_info sharp_lq035q7db02_20 __initdata = {
350 .upper_margin = 0x05, 375 .upper_margin = 0x05,
351 .lower_margin = 0x14, 376 .lower_margin = 0x14,
352 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, 377 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
378};
379
380static struct pxafb_mach_info sharp_lq035q7db02_20 = {
381 .modes = &sharp_lq035q7db02_20_mode,
382 .num_modes = 1,
353 .lccr0 = 0x07800080, 383 .lccr0 = 0x07800080,
354 .lccr3 = 0x00400000, 384 .lccr3 = 0x00400000,
355 .pxafb_backlight_power = lpd270_backlight_power, 385 .pxafb_backlight_power = lpd270_backlight_power,
diff --git a/arch/arm/mach-pxa/lubbock.c b/arch/arm/mach-pxa/lubbock.c
index 83ff5cee64d9..157cf47cbe66 100644
--- a/arch/arm/mach-pxa/lubbock.c
+++ b/arch/arm/mach-pxa/lubbock.c
@@ -352,7 +352,7 @@ static struct platform_device *devices[] __initdata = {
352 &pxa_ssp, 352 &pxa_ssp,
353}; 353};
354 354
355static struct pxafb_mach_info sharp_lm8v31 __initdata = { 355static struct pxafb_mode_info sharp_lm8v31_mode = {
356 .pixclock = 270000, 356 .pixclock = 270000,
357 .xres = 640, 357 .xres = 640,
358 .yres = 480, 358 .yres = 480,
@@ -365,6 +365,11 @@ static struct pxafb_mach_info sharp_lm8v31 __initdata = {
365 .lower_margin = 0, 365 .lower_margin = 0,
366 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, 366 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
367 .cmap_greyscale = 0, 367 .cmap_greyscale = 0,
368};
369
370static struct pxafb_mach_info sharp_lm8v31 = {
371 .modes = &sharp_lm8v31_mode,
372 .num_modes = 1,
368 .cmap_inverse = 0, 373 .cmap_inverse = 0,
369 .cmap_static = 0, 374 .cmap_static = 0,
370 .lccr0 = LCCR0_SDS, 375 .lccr0 = LCCR0_SDS,
diff --git a/arch/arm/mach-pxa/mainstone.c b/arch/arm/mach-pxa/mainstone.c
index a7e9b96f258a..7ba0447d6fa3 100644
--- a/arch/arm/mach-pxa/mainstone.c
+++ b/arch/arm/mach-pxa/mainstone.c
@@ -279,7 +279,7 @@ static void mainstone_backlight_power(int on)
279 } 279 }
280} 280}
281 281
282static struct pxafb_mach_info toshiba_ltm04c380k __initdata = { 282static struct pxafb_mode_info toshiba_ltm04c380k_mode = {
283 .pixclock = 50000, 283 .pixclock = 50000,
284 .xres = 640, 284 .xres = 640,
285 .yres = 480, 285 .yres = 480,
@@ -291,12 +291,9 @@ static struct pxafb_mach_info toshiba_ltm04c380k __initdata = {
291 .upper_margin = 0, 291 .upper_margin = 0,
292 .lower_margin = 0, 292 .lower_margin = 0,
293 .sync = FB_SYNC_HOR_HIGH_ACT|FB_SYNC_VERT_HIGH_ACT, 293 .sync = FB_SYNC_HOR_HIGH_ACT|FB_SYNC_VERT_HIGH_ACT,
294 .lccr0 = LCCR0_Act,
295 .lccr3 = LCCR3_PCP,
296 .pxafb_backlight_power = mainstone_backlight_power,
297}; 294};
298 295
299static struct pxafb_mach_info toshiba_ltm035a776c __initdata = { 296static struct pxafb_mode_info toshiba_ltm035a776c_mode = {
300 .pixclock = 110000, 297 .pixclock = 110000,
301 .xres = 240, 298 .xres = 240,
302 .yres = 320, 299 .yres = 320,
@@ -308,6 +305,10 @@ static struct pxafb_mach_info toshiba_ltm035a776c __initdata = {
308 .upper_margin = 1, 305 .upper_margin = 1,
309 .lower_margin = 10, 306 .lower_margin = 10,
310 .sync = FB_SYNC_HOR_HIGH_ACT|FB_SYNC_VERT_HIGH_ACT, 307 .sync = FB_SYNC_HOR_HIGH_ACT|FB_SYNC_VERT_HIGH_ACT,
308};
309
310static struct pxafb_mach_info mainstone_pxafb_info = {
311 .num_modes = 1,
311 .lccr0 = LCCR0_Act, 312 .lccr0 = LCCR0_Act,
312 .lccr3 = LCCR3_PCP, 313 .lccr3 = LCCR3_PCP,
313 .pxafb_backlight_power = mainstone_backlight_power, 314 .pxafb_backlight_power = mainstone_backlight_power,
@@ -448,9 +449,11 @@ static void __init mainstone_init(void)
448 /* reading Mainstone's "Virtual Configuration Register" 449 /* reading Mainstone's "Virtual Configuration Register"
449 might be handy to select LCD type here */ 450 might be handy to select LCD type here */
450 if (0) 451 if (0)
451 set_pxa_fb_info(&toshiba_ltm04c380k); 452 mainstone_pxafb_info.modes = &toshiba_ltm04c380k_mode;
452 else 453 else
453 set_pxa_fb_info(&toshiba_ltm035a776c); 454 mainstone_pxafb_info.modes = &toshiba_ltm035a776c_mode;
455
456 set_pxa_fb_info(&mainstone_pxafb_info);
454 457
455 pxa_set_mci_info(&mainstone_mci_platform_data); 458 pxa_set_mci_info(&mainstone_mci_platform_data);
456 pxa_set_ficp_info(&mainstone_ficp_platform_data); 459 pxa_set_ficp_info(&mainstone_ficp_platform_data);
diff --git a/arch/arm/mach-pxa/poodle.c b/arch/arm/mach-pxa/poodle.c
index 6dbff6d94801..5e8c098ca139 100644
--- a/arch/arm/mach-pxa/poodle.c
+++ b/arch/arm/mach-pxa/poodle.c
@@ -296,27 +296,25 @@ static struct pxa2xx_udc_mach_info udc_info __initdata = {
296 296
297 297
298/* PXAFB device */ 298/* PXAFB device */
299static struct pxafb_mach_info poodle_fb_info __initdata = { 299static struct pxafb_mode_info poodle_fb_mode = {
300 .pixclock = 144700, 300 .pixclock = 144700,
301
302 .xres = 320, 301 .xres = 320,
303 .yres = 240, 302 .yres = 240,
304 .bpp = 16, 303 .bpp = 16,
305
306 .hsync_len = 7, 304 .hsync_len = 7,
307 .left_margin = 11, 305 .left_margin = 11,
308 .right_margin = 30, 306 .right_margin = 30,
309
310 .vsync_len = 2, 307 .vsync_len = 2,
311 .upper_margin = 2, 308 .upper_margin = 2,
312 .lower_margin = 0, 309 .lower_margin = 0,
313 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, 310 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
311};
314 312
313static struct pxafb_mach_info poodle_fb_info = {
314 .modes = &poodle_fb_mode,
315 .num_modes = 1,
315 .lccr0 = LCCR0_Act | LCCR0_Sngl | LCCR0_Color, 316 .lccr0 = LCCR0_Act | LCCR0_Sngl | LCCR0_Color,
316 .lccr3 = 0, 317 .lccr3 = 0,
317
318 .pxafb_backlight_power = NULL,
319 .pxafb_lcd_power = NULL,
320}; 318};
321 319
322static struct platform_device *devices[] __initdata = { 320static struct platform_device *devices[] __initdata = {
diff --git a/arch/arm/mach-pxa/spitz.c b/arch/arm/mach-pxa/spitz.c
index 1c32a9310dc2..401cdb850fbc 100644
--- a/arch/arm/mach-pxa/spitz.c
+++ b/arch/arm/mach-pxa/spitz.c
@@ -407,21 +407,42 @@ static struct pxaficp_platform_data spitz_ficp_platform_data = {
407/* 407/*
408 * Spitz PXA Framebuffer 408 * Spitz PXA Framebuffer
409 */ 409 */
410static struct pxafb_mach_info spitz_pxafb_info __initdata = { 410
411 .pixclock = 19231, 411static struct pxafb_mode_info spitz_pxafb_modes[] = {
412 .xres = 480, 412{
413 .yres = 640, 413 .pixclock = 19231,
414 .bpp = 16, 414 .xres = 480,
415 .hsync_len = 40, 415 .yres = 640,
416 .left_margin = 46, 416 .bpp = 16,
417 .right_margin = 125, 417 .hsync_len = 40,
418 .vsync_len = 3, 418 .left_margin = 46,
419 .upper_margin = 1, 419 .right_margin = 125,
420 .lower_margin = 0, 420 .vsync_len = 3,
421 .sync = 0, 421 .upper_margin = 1,
422 .lccr0 = LCCR0_Color | LCCR0_Sngl | LCCR0_Act | LCCR0_LDDALT | LCCR0_OUC | LCCR0_CMDIM | LCCR0_RDSTM, 422 .lower_margin = 0,
423 .lccr3 = LCCR3_PixRsEdg | LCCR3_OutEnH, 423 .sync = 0,
424 .pxafb_lcd_power = spitz_lcd_power, 424},{
425 .pixclock = 134617,
426 .xres = 240,
427 .yres = 320,
428 .bpp = 16,
429 .hsync_len = 20,
430 .left_margin = 20,
431 .right_margin = 46,
432 .vsync_len = 2,
433 .upper_margin = 1,
434 .lower_margin = 0,
435 .sync = 0,
436},
437};
438
439static struct pxafb_mach_info spitz_pxafb_info = {
440 .modes = &spitz_pxafb_modes[0],
441 .num_modes = 2,
442 .fixed_modes = 1,
443 .lccr0 = LCCR0_Color | LCCR0_Sngl | LCCR0_Act | LCCR0_LDDALT | LCCR0_OUC | LCCR0_CMDIM | LCCR0_RDSTM,
444 .lccr3 = LCCR3_PixRsEdg | LCCR3_OutEnH,
445 .pxafb_lcd_power = spitz_lcd_power,
425}; 446};
426 447
427 448
diff --git a/arch/arm/mach-pxa/trizeps4.c b/arch/arm/mach-pxa/trizeps4.c
index 7c3007df1bd6..910571e9a190 100644
--- a/arch/arm/mach-pxa/trizeps4.c
+++ b/arch/arm/mach-pxa/trizeps4.c
@@ -368,7 +368,7 @@ static struct map_desc trizeps4_io_desc[] __initdata = {
368 } 368 }
369}; 369};
370 370
371static struct pxafb_mach_info sharp_lcd __initdata = { 371static struct pxafb_mode_info sharp_lcd_mode = {
372 .pixclock = 78000, 372 .pixclock = 78000,
373 .xres = 640, 373 .xres = 640,
374 .yres = 480, 374 .yres = 480,
@@ -381,6 +381,11 @@ static struct pxafb_mach_info sharp_lcd __initdata = {
381 .lower_margin = 0, 381 .lower_margin = 0,
382 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, 382 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
383 .cmap_greyscale = 0, 383 .cmap_greyscale = 0,
384};
385
386static struct pxafb_mach_info sharp_lcd = {
387 .modes = &sharp_lcd_mode,
388 .num_modes = 1,
384 .cmap_inverse = 0, 389 .cmap_inverse = 0,
385 .cmap_static = 0, 390 .cmap_static = 0,
386 .lccr0 = LCCR0_Color | LCCR0_Pas | LCCR0_Dual, 391 .lccr0 = LCCR0_Color | LCCR0_Pas | LCCR0_Dual,
diff --git a/drivers/video/pxafb.c b/drivers/video/pxafb.c
index bbb07106cd54..3bc5da4a57ca 100644
--- a/drivers/video/pxafb.c
+++ b/drivers/video/pxafb.c
@@ -59,7 +59,7 @@
59#define LCCR3_INVALID_CONFIG_MASK (LCCR3_HSP|LCCR3_VSP|LCCR3_PCD|LCCR3_BPP) 59#define LCCR3_INVALID_CONFIG_MASK (LCCR3_HSP|LCCR3_VSP|LCCR3_PCD|LCCR3_BPP)
60 60
61static void (*pxafb_backlight_power)(int); 61static void (*pxafb_backlight_power)(int);
62static void (*pxafb_lcd_power)(int); 62static void (*pxafb_lcd_power)(int, struct fb_var_screeninfo *);
63 63
64static int pxafb_activate_var(struct fb_var_screeninfo *var, struct pxafb_info *); 64static int pxafb_activate_var(struct fb_var_screeninfo *var, struct pxafb_info *);
65static void set_ctrlr_state(struct pxafb_info *fbi, u_int state); 65static void set_ctrlr_state(struct pxafb_info *fbi, u_int state);
@@ -214,6 +214,48 @@ extern unsigned int get_clk_frequency_khz(int info);
214#endif 214#endif
215 215
216/* 216/*
217 * Select the smallest mode that allows the desired resolution to be
218 * displayed. If desired parameters can be rounded up.
219 */
220static struct pxafb_mode_info *pxafb_getmode(struct pxafb_mach_info *mach, struct fb_var_screeninfo *var)
221{
222 struct pxafb_mode_info *mode = NULL;
223 struct pxafb_mode_info *modelist = mach->modes;
224 unsigned int best_x = 0xffffffff, best_y = 0xffffffff;
225 unsigned int i;
226
227 for (i = 0 ; i < mach->num_modes ; i++) {
228 if (modelist[i].xres >= var->xres && modelist[i].yres >= var->yres &&
229 modelist[i].xres < best_x && modelist[i].yres < best_y &&
230 modelist[i].bpp >= var->bits_per_pixel ) {
231 best_x = modelist[i].xres;
232 best_y = modelist[i].yres;
233 mode = &modelist[i];
234 }
235 }
236
237 return mode;
238}
239
240static void pxafb_setmode(struct fb_var_screeninfo *var, struct pxafb_mode_info *mode)
241{
242 var->xres = mode->xres;
243 var->yres = mode->yres;
244 var->bits_per_pixel = mode->bpp;
245 var->pixclock = mode->pixclock;
246 var->hsync_len = mode->hsync_len;
247 var->left_margin = mode->left_margin;
248 var->right_margin = mode->right_margin;
249 var->vsync_len = mode->vsync_len;
250 var->upper_margin = mode->upper_margin;
251 var->lower_margin = mode->lower_margin;
252 var->sync = mode->sync;
253 var->grayscale = mode->cmap_greyscale;
254 var->xres_virtual = var->xres;
255 var->yres_virtual = var->yres;
256}
257
258/*
217 * pxafb_check_var(): 259 * pxafb_check_var():
218 * Get the video params out of 'var'. If a value doesn't fit, round it up, 260 * Get the video params out of 'var'. If a value doesn't fit, round it up,
219 * if it's too big, return -EINVAL. 261 * if it's too big, return -EINVAL.
@@ -225,15 +267,29 @@ extern unsigned int get_clk_frequency_khz(int info);
225static int pxafb_check_var(struct fb_var_screeninfo *var, struct fb_info *info) 267static int pxafb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
226{ 268{
227 struct pxafb_info *fbi = (struct pxafb_info *)info; 269 struct pxafb_info *fbi = (struct pxafb_info *)info;
270 struct pxafb_mach_info *inf = fbi->dev->platform_data;
228 271
229 if (var->xres < MIN_XRES) 272 if (var->xres < MIN_XRES)
230 var->xres = MIN_XRES; 273 var->xres = MIN_XRES;
231 if (var->yres < MIN_YRES) 274 if (var->yres < MIN_YRES)
232 var->yres = MIN_YRES; 275 var->yres = MIN_YRES;
233 if (var->xres > fbi->max_xres) 276
234 return -EINVAL; 277 if (inf->fixed_modes) {
235 if (var->yres > fbi->max_yres) 278 struct pxafb_mode_info *mode;
236 return -EINVAL; 279
280 mode = pxafb_getmode(inf, var);
281 if (!mode)
282 return -EINVAL;
283 pxafb_setmode(var, mode);
284 } else {
285 if (var->xres > inf->modes->xres)
286 return -EINVAL;
287 if (var->yres > inf->modes->yres)
288 return -EINVAL;
289 if (var->bits_per_pixel > inf->modes->bpp)
290 return -EINVAL;
291 }
292
237 var->xres_virtual = 293 var->xres_virtual =
238 max(var->xres_virtual, var->xres); 294 max(var->xres_virtual, var->xres);
239 var->yres_virtual = 295 var->yres_virtual =
@@ -693,7 +749,7 @@ static inline void __pxafb_lcd_power(struct pxafb_info *fbi, int on)
693 pr_debug("pxafb: LCD power o%s\n", on ? "n" : "ff"); 749 pr_debug("pxafb: LCD power o%s\n", on ? "n" : "ff");
694 750
695 if (pxafb_lcd_power) 751 if (pxafb_lcd_power)
696 pxafb_lcd_power(on); 752 pxafb_lcd_power(on, &fbi->fb.var);
697} 753}
698 754
699static void pxafb_setup_gpio(struct pxafb_info *fbi) 755static void pxafb_setup_gpio(struct pxafb_info *fbi)
@@ -869,9 +925,11 @@ static void set_ctrlr_state(struct pxafb_info *fbi, u_int state)
869 * registers. 925 * registers.
870 */ 926 */
871 if (old_state == C_ENABLE) { 927 if (old_state == C_ENABLE) {
928 __pxafb_lcd_power(fbi, 0);
872 pxafb_disable_controller(fbi); 929 pxafb_disable_controller(fbi);
873 pxafb_setup_gpio(fbi); 930 pxafb_setup_gpio(fbi);
874 pxafb_enable_controller(fbi); 931 pxafb_enable_controller(fbi);
932 __pxafb_lcd_power(fbi, 1);
875 } 933 }
876 break; 934 break;
877 935
@@ -1049,6 +1107,8 @@ static struct pxafb_info * __init pxafb_init_fbinfo(struct device *dev)
1049 struct pxafb_info *fbi; 1107 struct pxafb_info *fbi;
1050 void *addr; 1108 void *addr;
1051 struct pxafb_mach_info *inf = dev->platform_data; 1109 struct pxafb_mach_info *inf = dev->platform_data;
1110 struct pxafb_mode_info *mode = inf->modes;
1111 int i, smemlen;
1052 1112
1053 /* Alloc the pxafb_info and pseudo_palette in one step */ 1113 /* Alloc the pxafb_info and pseudo_palette in one step */
1054 fbi = kmalloc(sizeof(struct pxafb_info) + sizeof(u32) * 16, GFP_KERNEL); 1114 fbi = kmalloc(sizeof(struct pxafb_info) + sizeof(u32) * 16, GFP_KERNEL);
@@ -1082,31 +1142,21 @@ static struct pxafb_info * __init pxafb_init_fbinfo(struct device *dev)
1082 addr = addr + sizeof(struct pxafb_info); 1142 addr = addr + sizeof(struct pxafb_info);
1083 fbi->fb.pseudo_palette = addr; 1143 fbi->fb.pseudo_palette = addr;
1084 1144
1085 fbi->max_xres = inf->xres; 1145 pxafb_setmode(&fbi->fb.var, mode);
1086 fbi->fb.var.xres = inf->xres; 1146
1087 fbi->fb.var.xres_virtual = inf->xres;
1088 fbi->max_yres = inf->yres;
1089 fbi->fb.var.yres = inf->yres;
1090 fbi->fb.var.yres_virtual = inf->yres;
1091 fbi->max_bpp = inf->bpp;
1092 fbi->fb.var.bits_per_pixel = inf->bpp;
1093 fbi->fb.var.pixclock = inf->pixclock;
1094 fbi->fb.var.hsync_len = inf->hsync_len;
1095 fbi->fb.var.left_margin = inf->left_margin;
1096 fbi->fb.var.right_margin = inf->right_margin;
1097 fbi->fb.var.vsync_len = inf->vsync_len;
1098 fbi->fb.var.upper_margin = inf->upper_margin;
1099 fbi->fb.var.lower_margin = inf->lower_margin;
1100 fbi->fb.var.sync = inf->sync;
1101 fbi->fb.var.grayscale = inf->cmap_greyscale;
1102 fbi->cmap_inverse = inf->cmap_inverse; 1147 fbi->cmap_inverse = inf->cmap_inverse;
1103 fbi->cmap_static = inf->cmap_static; 1148 fbi->cmap_static = inf->cmap_static;
1149
1104 fbi->lccr0 = inf->lccr0; 1150 fbi->lccr0 = inf->lccr0;
1105 fbi->lccr3 = inf->lccr3; 1151 fbi->lccr3 = inf->lccr3;
1106 fbi->state = C_STARTUP; 1152 fbi->state = C_STARTUP;
1107 fbi->task_state = (u_char)-1; 1153 fbi->task_state = (u_char)-1;
1108 fbi->fb.fix.smem_len = fbi->max_xres * fbi->max_yres * 1154
1109 fbi->max_bpp / 8; 1155 for (i = 0; i < inf->num_modes; i++) {
1156 smemlen = mode[i].xres * mode[i].yres * mode[i].bpp / 8;
1157 if (smemlen > fbi->fb.fix.smem_len)
1158 fbi->fb.fix.smem_len = smemlen;
1159 }
1110 1160
1111 init_waitqueue_head(&fbi->ctrlr_wait); 1161 init_waitqueue_head(&fbi->ctrlr_wait);
1112 INIT_WORK(&fbi->task, pxafb_task, fbi); 1162 INIT_WORK(&fbi->task, pxafb_task, fbi);
@@ -1307,12 +1357,12 @@ int __init pxafb_probe(struct platform_device *dev)
1307 (inf->lccr0 & LCCR0_SDS) == LCCR0_Dual) 1357 (inf->lccr0 & LCCR0_SDS) == LCCR0_Dual)
1308 dev_warn(&dev->dev, "Dual panel only valid in passive mode\n"); 1358 dev_warn(&dev->dev, "Dual panel only valid in passive mode\n");
1309 if ((inf->lccr0 & LCCR0_PAS) == LCCR0_Pas && 1359 if ((inf->lccr0 & LCCR0_PAS) == LCCR0_Pas &&
1310 (inf->upper_margin || inf->lower_margin)) 1360 (inf->modes->upper_margin || inf->modes->lower_margin))
1311 dev_warn(&dev->dev, "Upper and lower margins must be 0 in passive mode\n"); 1361 dev_warn(&dev->dev, "Upper and lower margins must be 0 in passive mode\n");
1312#endif 1362#endif
1313 1363
1314 dev_dbg(&dev->dev, "got a %dx%dx%d LCD\n",inf->xres, inf->yres, inf->bpp); 1364 dev_dbg(&dev->dev, "got a %dx%dx%d LCD\n",inf->modes->xres, inf->modes->yres, inf->modes->bpp);
1315 if (inf->xres == 0 || inf->yres == 0 || inf->bpp == 0) { 1365 if (inf->modes->xres == 0 || inf->modes->yres == 0 || inf->modes->bpp == 0) {
1316 dev_err(&dev->dev, "Invalid resolution or bit depth\n"); 1366 dev_err(&dev->dev, "Invalid resolution or bit depth\n");
1317 ret = -EINVAL; 1367 ret = -EINVAL;
1318 goto failed; 1368 goto failed;
diff --git a/drivers/video/pxafb.h b/drivers/video/pxafb.h
index 47f41f70db7a..7499a1c4bf79 100644
--- a/drivers/video/pxafb.h
+++ b/drivers/video/pxafb.h
@@ -41,10 +41,6 @@ struct pxafb_info {
41 struct fb_info fb; 41 struct fb_info fb;
42 struct device *dev; 42 struct device *dev;
43 43
44 u_int max_bpp;
45 u_int max_xres;
46 u_int max_yres;
47
48 /* 44 /*
49 * These are the addresses we mapped 45 * These are the addresses we mapped
50 * the framebuffer memory region to. 46 * the framebuffer memory region to.
diff --git a/include/asm-arm/arch-pxa/pxafb.h b/include/asm-arm/arch-pxa/pxafb.h
index aba9b30f4249..81c3928d608c 100644
--- a/include/asm-arm/arch-pxa/pxafb.h
+++ b/include/asm-arm/arch-pxa/pxafb.h
@@ -12,12 +12,14 @@
12 * published by the Free Software Foundation. 12 * published by the Free Software Foundation.
13 */ 13 */
14 14
15#include <linux/fb.h>
16
15/* 17/*
16 * This structure describes the machine which we are running on. 18 * This structure describes the machine which we are running on.
17 * It is set in linux/arch/arm/mach-pxa/machine_name.c and used in the probe routine 19 * It is set in linux/arch/arm/mach-pxa/machine_name.c and used in the probe routine
18 * of linux/drivers/video/pxafb.c 20 * of linux/drivers/video/pxafb.c
19 */ 21 */
20struct pxafb_mach_info { 22struct pxafb_mode_info {
21 u_long pixclock; 23 u_long pixclock;
22 24
23 u_short xres; 25 u_short xres;
@@ -34,6 +36,14 @@ struct pxafb_mach_info {
34 u_char sync; 36 u_char sync;
35 37
36 u_int cmap_greyscale:1, 38 u_int cmap_greyscale:1,
39 unused:31;
40};
41
42struct pxafb_mach_info {
43 struct pxafb_mode_info *modes;
44 unsigned int num_modes;
45
46 u_int fixed_modes:1,
37 cmap_inverse:1, 47 cmap_inverse:1,
38 cmap_static:1, 48 cmap_static:1,
39 unused:29; 49 unused:29;
@@ -62,7 +72,7 @@ struct pxafb_mach_info {
62 u_int lccr3; 72 u_int lccr3;
63 73
64 void (*pxafb_backlight_power)(int); 74 void (*pxafb_backlight_power)(int);
65 void (*pxafb_lcd_power)(int); 75 void (*pxafb_lcd_power)(int, struct fb_var_screeninfo *);
66 76
67}; 77};
68void set_pxa_fb_info(struct pxafb_mach_info *hard_pxa_fb_info); 78void set_pxa_fb_info(struct pxafb_mach_info *hard_pxa_fb_info);
diff --git a/include/asm-arm/arch-pxa/spitz.h b/include/asm-arm/arch-pxa/spitz.h
index 62e1fe4d025f..4953dd324d4d 100644
--- a/include/asm-arm/arch-pxa/spitz.h
+++ b/include/asm-arm/arch-pxa/spitz.h
@@ -15,6 +15,8 @@
15#define __ASM_ARCH_SPITZ_H 1 15#define __ASM_ARCH_SPITZ_H 1
16#endif 16#endif
17 17
18#include <linux/fb.h>
19
18/* Spitz/Akita GPIOs */ 20/* Spitz/Akita GPIOs */
19 21
20#define SPITZ_GPIO_KEY_INT (0) /* Key Interrupt */ 22#define SPITZ_GPIO_KEY_INT (0) /* Key Interrupt */
@@ -155,4 +157,4 @@ extern struct platform_device spitzscoop2_device;
155extern struct platform_device spitzssp_device; 157extern struct platform_device spitzssp_device;
156extern struct sharpsl_charger_machinfo spitz_pm_machinfo; 158extern struct sharpsl_charger_machinfo spitz_pm_machinfo;
157 159
158extern void spitz_lcd_power(int on); 160extern void spitz_lcd_power(int on, struct fb_var_screeninfo *var);