aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManuel Lauss <manuel.lauss@googlemail.com>2011-11-10 07:06:21 -0500
committerRalf Baechle <ralf@linux-mips.org>2011-12-07 17:02:07 -0500
commita9b71a8f0f42efe1a21154667ca02305c950d30a (patch)
tree0081abc97e9fda1f27f48327b033316a77b35f5a
parent7c4b24da07d99b5473de7cc7ba3f67d85b889bc0 (diff)
MIPS: Alchemy: move au1200fb global functions to platform data
au1200fb calls 3 functions which have to be defined in board code. Fix this ugliness with the introduction of platform_data. Signed-off-by: Manuel Lauss <manuel.lauss@googlemail.com> Cc: linux-fbdev@vger.kernel.org To: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/2871/ Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
-rw-r--r--arch/mips/alchemy/devboards/db1200.c51
-rw-r--r--arch/mips/alchemy/devboards/db1300.c52
-rw-r--r--arch/mips/alchemy/devboards/pb1200.c55
-rw-r--r--arch/mips/include/asm/mach-au1x00/au1200fb.h14
-rw-r--r--drivers/video/au1200fb.c241
5 files changed, 213 insertions, 200 deletions
diff --git a/arch/mips/alchemy/devboards/db1200.c b/arch/mips/alchemy/devboards/db1200.c
index 43f5f1be9d6..e2cc5f92153 100644
--- a/arch/mips/alchemy/devboards/db1200.c
+++ b/arch/mips/alchemy/devboards/db1200.c
@@ -37,6 +37,7 @@
37#include <asm/mach-au1x00/au1000.h> 37#include <asm/mach-au1x00/au1000.h>
38#include <asm/mach-au1x00/au1100_mmc.h> 38#include <asm/mach-au1x00/au1100_mmc.h>
39#include <asm/mach-au1x00/au1xxx_dbdma.h> 39#include <asm/mach-au1x00/au1xxx_dbdma.h>
40#include <asm/mach-au1x00/au1200fb.h>
40#include <asm/mach-au1x00/au1550_spi.h> 41#include <asm/mach-au1x00/au1550_spi.h>
41#include <asm/mach-db1x00/bcsr.h> 42#include <asm/mach-db1x00/bcsr.h>
42#include <asm/mach-db1x00/db1200.h> 43#include <asm/mach-db1x00/db1200.h>
@@ -422,6 +423,33 @@ static struct platform_device db1200_mmc0_dev = {
422 423
423/**********************************************************************/ 424/**********************************************************************/
424 425
426static int db1200fb_panel_index(void)
427{
428 return (bcsr_read(BCSR_SWITCHES) >> 8) & 0x0f;
429}
430
431static int db1200fb_panel_init(void)
432{
433 /* Apply power */
434 bcsr_mod(BCSR_BOARD, 0, BCSR_BOARD_LCDVEE | BCSR_BOARD_LCDVDD |
435 BCSR_BOARD_LCDBL);
436 return 0;
437}
438
439static int db1200fb_panel_shutdown(void)
440{
441 /* Remove power */
442 bcsr_mod(BCSR_BOARD, BCSR_BOARD_LCDVEE | BCSR_BOARD_LCDVDD |
443 BCSR_BOARD_LCDBL, 0);
444 return 0;
445}
446
447static struct au1200fb_platdata db1200fb_pd = {
448 .panel_index = db1200fb_panel_index,
449 .panel_init = db1200fb_panel_init,
450 .panel_shutdown = db1200fb_panel_shutdown,
451};
452
425static struct resource au1200_lcd_res[] = { 453static struct resource au1200_lcd_res[] = {
426 [0] = { 454 [0] = {
427 .start = AU1200_LCD_PHYS_ADDR, 455 .start = AU1200_LCD_PHYS_ADDR,
@@ -443,6 +471,7 @@ static struct platform_device au1200_lcd_dev = {
443 .dev = { 471 .dev = {
444 .dma_mask = &au1200_lcd_dmamask, 472 .dma_mask = &au1200_lcd_dmamask,
445 .coherent_dma_mask = DMA_BIT_MASK(32), 473 .coherent_dma_mask = DMA_BIT_MASK(32),
474 .platform_data = &db1200fb_pd,
446 }, 475 },
447 .num_resources = ARRAY_SIZE(au1200_lcd_res), 476 .num_resources = ARRAY_SIZE(au1200_lcd_res),
448 .resource = au1200_lcd_res, 477 .resource = au1200_lcd_res,
@@ -681,25 +710,3 @@ static int __init db1200_dev_init(void)
681 return platform_add_devices(db1200_devs, ARRAY_SIZE(db1200_devs)); 710 return platform_add_devices(db1200_devs, ARRAY_SIZE(db1200_devs));
682} 711}
683device_initcall(db1200_dev_init); 712device_initcall(db1200_dev_init);
684
685/* au1200fb calls these: STERBT EINEN TRAGISCHEN TOD!!! */
686int board_au1200fb_panel(void)
687{
688 return (bcsr_read(BCSR_SWITCHES) >> 8) & 0x0f;
689}
690
691int board_au1200fb_panel_init(void)
692{
693 /* Apply power */
694 bcsr_mod(BCSR_BOARD, 0, BCSR_BOARD_LCDVEE | BCSR_BOARD_LCDVDD |
695 BCSR_BOARD_LCDBL);
696 return 0;
697}
698
699int board_au1200fb_panel_shutdown(void)
700{
701 /* Remove power */
702 bcsr_mod(BCSR_BOARD, BCSR_BOARD_LCDVEE | BCSR_BOARD_LCDVDD |
703 BCSR_BOARD_LCDBL, 0);
704 return 0;
705}
diff --git a/arch/mips/alchemy/devboards/db1300.c b/arch/mips/alchemy/devboards/db1300.c
index c41788c5927..7f3dacb60ea 100644
--- a/arch/mips/alchemy/devboards/db1300.c
+++ b/arch/mips/alchemy/devboards/db1300.c
@@ -23,6 +23,7 @@
23 23
24#include <asm/mach-au1x00/au1000.h> 24#include <asm/mach-au1x00/au1000.h>
25#include <asm/mach-au1x00/au1100_mmc.h> 25#include <asm/mach-au1x00/au1100_mmc.h>
26#include <asm/mach-au1x00/au1200fb.h>
26#include <asm/mach-au1x00/au1xxx_dbdma.h> 27#include <asm/mach-au1x00/au1xxx_dbdma.h>
27#include <asm/mach-au1x00/au1xxx_psc.h> 28#include <asm/mach-au1x00/au1xxx_psc.h>
28#include <asm/mach-db1x00/db1300.h> 29#include <asm/mach-db1x00/db1300.h>
@@ -636,6 +637,33 @@ static struct platform_device db1300_sndi2s_dev = {
636 637
637/**********************************************************************/ 638/**********************************************************************/
638 639
640static int db1300fb_panel_index(void)
641{
642 return 9; /* DB1300_800x480 */
643}
644
645static int db1300fb_panel_init(void)
646{
647 /* Apply power (Vee/Vdd logic is inverted on Panel DB1300_800x480) */
648 bcsr_mod(BCSR_BOARD, BCSR_BOARD_LCDVEE | BCSR_BOARD_LCDVDD,
649 BCSR_BOARD_LCDBL);
650 return 0;
651}
652
653static int db1300fb_panel_shutdown(void)
654{
655 /* Remove power (Vee/Vdd logic is inverted on Panel DB1300_800x480) */
656 bcsr_mod(BCSR_BOARD, BCSR_BOARD_LCDBL,
657 BCSR_BOARD_LCDVEE | BCSR_BOARD_LCDVDD);
658 return 0;
659}
660
661static struct au1200fb_platdata db1300fb_pd = {
662 .panel_index = db1300fb_panel_index,
663 .panel_init = db1300fb_panel_init,
664 .panel_shutdown = db1300fb_panel_shutdown,
665};
666
639static struct resource au1300_lcd_res[] = { 667static struct resource au1300_lcd_res[] = {
640 [0] = { 668 [0] = {
641 .start = AU1200_LCD_PHYS_ADDR, 669 .start = AU1200_LCD_PHYS_ADDR,
@@ -657,6 +685,7 @@ static struct platform_device db1300_lcd_dev = {
657 .dev = { 685 .dev = {
658 .dma_mask = &au1300_lcd_dmamask, 686 .dma_mask = &au1300_lcd_dmamask,
659 .coherent_dma_mask = DMA_BIT_MASK(32), 687 .coherent_dma_mask = DMA_BIT_MASK(32),
688 .platform_data = &db1300fb_pd,
660 }, 689 },
661 .num_resources = ARRAY_SIZE(au1300_lcd_res), 690 .num_resources = ARRAY_SIZE(au1300_lcd_res),
662 .resource = au1300_lcd_res, 691 .resource = au1300_lcd_res,
@@ -762,26 +791,3 @@ void __init board_setup(void)
762 alchemy_uart_enable(AU1300_UART1_PHYS_ADDR); 791 alchemy_uart_enable(AU1300_UART1_PHYS_ADDR);
763 alchemy_uart_enable(AU1300_UART3_PHYS_ADDR); 792 alchemy_uart_enable(AU1300_UART3_PHYS_ADDR);
764} 793}
765
766
767/* au1200fb calls these: STERBT EINEN TRAGISCHEN TOD!!! */
768int board_au1200fb_panel(void)
769{
770 return 9; /* DB1300_800x480 */
771}
772
773int board_au1200fb_panel_init(void)
774{
775 /* Apply power (Vee/Vdd logic is inverted on Panel DB1300_800x480) */
776 bcsr_mod(BCSR_BOARD, BCSR_BOARD_LCDVEE | BCSR_BOARD_LCDVDD,
777 BCSR_BOARD_LCDBL);
778 return 0;
779}
780
781int board_au1200fb_panel_shutdown(void)
782{
783 /* Remove power (Vee/Vdd logic is inverted on Panel DB1300_800x480) */
784 bcsr_mod(BCSR_BOARD, BCSR_BOARD_LCDBL,
785 BCSR_BOARD_LCDVEE | BCSR_BOARD_LCDVDD);
786 return 0;
787}
diff --git a/arch/mips/alchemy/devboards/pb1200.c b/arch/mips/alchemy/devboards/pb1200.c
index a1b64977b47..a2676c95053 100644
--- a/arch/mips/alchemy/devboards/pb1200.c
+++ b/arch/mips/alchemy/devboards/pb1200.c
@@ -26,6 +26,7 @@
26#include <linux/smc91x.h> 26#include <linux/smc91x.h>
27#include <asm/mach-au1x00/au1000.h> 27#include <asm/mach-au1x00/au1000.h>
28#include <asm/mach-au1x00/au1100_mmc.h> 28#include <asm/mach-au1x00/au1100_mmc.h>
29#include <asm/mach-au1x00/au1200fb.h>
29#include <asm/mach-au1x00/au1xxx_dbdma.h> 30#include <asm/mach-au1x00/au1xxx_dbdma.h>
30#include <asm/mach-db1x00/bcsr.h> 31#include <asm/mach-db1x00/bcsr.h>
31#include <asm/mach-pb1x00/pb1200.h> 32#include <asm/mach-pb1x00/pb1200.h>
@@ -351,6 +352,33 @@ static struct platform_device pb1200_i2c_dev = {
351 .resource = au1200_psc0_res, 352 .resource = au1200_psc0_res,
352}; 353};
353 354
355static int pb1200fb_panel_index(void)
356{
357 return (bcsr_read(BCSR_SWITCHES) >> 8) & 0x0f;
358}
359
360static int pb1200fb_panel_init(void)
361{
362 /* Apply power */
363 bcsr_mod(BCSR_BOARD, 0, BCSR_BOARD_LCDVEE | BCSR_BOARD_LCDVDD |
364 BCSR_BOARD_LCDBL);
365 return 0;
366}
367
368static int pb1200fb_panel_shutdown(void)
369{
370 /* Remove power */
371 bcsr_mod(BCSR_BOARD, BCSR_BOARD_LCDVEE | BCSR_BOARD_LCDVDD |
372 BCSR_BOARD_LCDBL, 0);
373 return 0;
374}
375
376static struct au1200fb_platdata pb1200fb_pd = {
377 .panel_index = pb1200fb_panel_index,
378 .panel_init = pb1200fb_panel_init,
379 .panel_shutdown = pb1200fb_panel_shutdown,
380};
381
354static struct resource au1200_lcd_res[] = { 382static struct resource au1200_lcd_res[] = {
355 [0] = { 383 [0] = {
356 .start = AU1200_LCD_PHYS_ADDR, 384 .start = AU1200_LCD_PHYS_ADDR,
@@ -366,12 +394,13 @@ static struct resource au1200_lcd_res[] = {
366 394
367static u64 au1200_lcd_dmamask = DMA_BIT_MASK(32); 395static u64 au1200_lcd_dmamask = DMA_BIT_MASK(32);
368 396
369static struct platform_device au1200_lcd_dev = { 397static struct platform_device pb1200_lcd_dev = {
370 .name = "au1200-lcd", 398 .name = "au1200-lcd",
371 .id = 0, 399 .id = 0,
372 .dev = { 400 .dev = {
373 .dma_mask = &au1200_lcd_dmamask, 401 .dma_mask = &au1200_lcd_dmamask,
374 .coherent_dma_mask = DMA_BIT_MASK(32), 402 .coherent_dma_mask = DMA_BIT_MASK(32),
403 .platform_data = &pb1200fb_pd,
375 }, 404 },
376 .num_resources = ARRAY_SIZE(au1200_lcd_res), 405 .num_resources = ARRAY_SIZE(au1200_lcd_res),
377 .resource = au1200_lcd_res, 406 .resource = au1200_lcd_res,
@@ -383,7 +412,7 @@ static struct platform_device *board_platform_devices[] __initdata = {
383 &pb1200_i2c_dev, 412 &pb1200_i2c_dev,
384 &pb1200_mmc0_dev, 413 &pb1200_mmc0_dev,
385 &pb1200_mmc1_dev, 414 &pb1200_mmc1_dev,
386 &au1200_lcd_dev, 415 &pb1200_lcd_dev,
387}; 416};
388 417
389static int __init board_register_devices(void) 418static int __init board_register_devices(void)
@@ -440,25 +469,3 @@ static int __init board_register_devices(void)
440 ARRAY_SIZE(board_platform_devices)); 469 ARRAY_SIZE(board_platform_devices));
441} 470}
442device_initcall(board_register_devices); 471device_initcall(board_register_devices);
443
444
445int board_au1200fb_panel(void)
446{
447 return (bcsr_read(BCSR_SWITCHES) >> 8) & 0x0f;
448}
449
450int board_au1200fb_panel_init(void)
451{
452 /* Apply power */
453 bcsr_mod(BCSR_BOARD, 0, BCSR_BOARD_LCDVEE | BCSR_BOARD_LCDVDD |
454 BCSR_BOARD_LCDBL);
455 return 0;
456}
457
458int board_au1200fb_panel_shutdown(void)
459{
460 /* Remove power */
461 bcsr_mod(BCSR_BOARD, BCSR_BOARD_LCDVEE | BCSR_BOARD_LCDVDD |
462 BCSR_BOARD_LCDBL, 0);
463 return 0;
464}
diff --git a/arch/mips/include/asm/mach-au1x00/au1200fb.h b/arch/mips/include/asm/mach-au1x00/au1200fb.h
new file mode 100644
index 00000000000..b3c87cc64bb
--- /dev/null
+++ b/arch/mips/include/asm/mach-au1x00/au1200fb.h
@@ -0,0 +1,14 @@
1/*
2 * platform data for au1200fb driver.
3 */
4
5#ifndef _AU1200FB_PLAT_H_
6#define _AU1200FB_PLAT_H_
7
8struct au1200fb_platdata {
9 int (*panel_index)(void);
10 int (*panel_init)(void);
11 int (*panel_shutdown)(void);
12};
13
14#endif
diff --git a/drivers/video/au1200fb.c b/drivers/video/au1200fb.c
index 6c4342f1d9b..04e4479d5af 100644
--- a/drivers/video/au1200fb.c
+++ b/drivers/video/au1200fb.c
@@ -44,6 +44,7 @@
44#include <linux/slab.h> 44#include <linux/slab.h>
45 45
46#include <asm/mach-au1x00/au1000.h> 46#include <asm/mach-au1x00/au1000.h>
47#include <asm/mach-au1x00/au1200fb.h> /* platform_data */
47#include "au1200fb.h" 48#include "au1200fb.h"
48 49
49#define DRIVER_NAME "au1200fb" 50#define DRIVER_NAME "au1200fb"
@@ -143,6 +144,7 @@ struct au1200_lcd_iodata_t {
143/* Private, per-framebuffer management information (independent of the panel itself) */ 144/* Private, per-framebuffer management information (independent of the panel itself) */
144struct au1200fb_device { 145struct au1200fb_device {
145 struct fb_info *fb_info; /* FB driver info record */ 146 struct fb_info *fb_info; /* FB driver info record */
147 struct au1200fb_platdata *pd;
146 148
147 int plane; 149 int plane;
148 unsigned char* fb_mem; /* FrameBuffer memory map */ 150 unsigned char* fb_mem; /* FrameBuffer memory map */
@@ -201,9 +203,6 @@ struct window_settings {
201#define LCD_WINCTRL1_PO_16BPP LCD_WINCTRL1_PO_01 203#define LCD_WINCTRL1_PO_16BPP LCD_WINCTRL1_PO_01
202#endif 204#endif
203 205
204extern int board_au1200fb_panel_init (void);
205extern int board_au1200fb_panel_shutdown (void);
206
207/* 206/*
208 * Default window configurations 207 * Default window configurations
209 */ 208 */
@@ -334,8 +333,6 @@ struct panel_settings
334 uint32 mode_toyclksrc; 333 uint32 mode_toyclksrc;
335 uint32 mode_backlight; 334 uint32 mode_backlight;
336 uint32 mode_auxpll; 335 uint32 mode_auxpll;
337 int (*device_init)(void);
338 int (*device_shutdown)(void);
339#define Xres min_xres 336#define Xres min_xres
340#define Yres min_yres 337#define Yres min_yres
341 u32 min_xres; /* Minimum horizontal resolution */ 338 u32 min_xres; /* Minimum horizontal resolution */
@@ -385,8 +382,6 @@ static struct panel_settings known_lcd_panels[] =
385 .mode_toyclksrc = 0x00000004, /* AUXPLL directly */ 382 .mode_toyclksrc = 0x00000004, /* AUXPLL directly */
386 .mode_backlight = 0x00000000, 383 .mode_backlight = 0x00000000,
387 .mode_auxpll = 8, /* 96MHz AUXPLL */ 384 .mode_auxpll = 8, /* 96MHz AUXPLL */
388 .device_init = NULL,
389 .device_shutdown = NULL,
390 320, 320, 385 320, 320,
391 240, 240, 386 240, 240,
392 }, 387 },
@@ -415,8 +410,6 @@ static struct panel_settings known_lcd_panels[] =
415 .mode_toyclksrc = 0x00000004, /* AUXPLL directly */ 410 .mode_toyclksrc = 0x00000004, /* AUXPLL directly */
416 .mode_backlight = 0x00000000, 411 .mode_backlight = 0x00000000,
417 .mode_auxpll = 8, /* 96MHz AUXPLL */ 412 .mode_auxpll = 8, /* 96MHz AUXPLL */
418 .device_init = NULL,
419 .device_shutdown = NULL,
420 640, 480, 413 640, 480,
421 640, 480, 414 640, 480,
422 }, 415 },
@@ -445,8 +438,6 @@ static struct panel_settings known_lcd_panels[] =
445 .mode_toyclksrc = 0x00000004, /* AUXPLL directly */ 438 .mode_toyclksrc = 0x00000004, /* AUXPLL directly */
446 .mode_backlight = 0x00000000, 439 .mode_backlight = 0x00000000,
447 .mode_auxpll = 8, /* 96MHz AUXPLL */ 440 .mode_auxpll = 8, /* 96MHz AUXPLL */
448 .device_init = NULL,
449 .device_shutdown = NULL,
450 800, 800, 441 800, 800,
451 600, 600, 442 600, 600,
452 }, 443 },
@@ -475,8 +466,6 @@ static struct panel_settings known_lcd_panels[] =
475 .mode_toyclksrc = 0x00000004, /* AUXPLL directly */ 466 .mode_toyclksrc = 0x00000004, /* AUXPLL directly */
476 .mode_backlight = 0x00000000, 467 .mode_backlight = 0x00000000,
477 .mode_auxpll = 6, /* 72MHz AUXPLL */ 468 .mode_auxpll = 6, /* 72MHz AUXPLL */
478 .device_init = NULL,
479 .device_shutdown = NULL,
480 1024, 1024, 469 1024, 1024,
481 768, 768, 470 768, 768,
482 }, 471 },
@@ -505,8 +494,6 @@ static struct panel_settings known_lcd_panels[] =
505 .mode_toyclksrc = 0x00000004, /* AUXPLL directly */ 494 .mode_toyclksrc = 0x00000004, /* AUXPLL directly */
506 .mode_backlight = 0x00000000, 495 .mode_backlight = 0x00000000,
507 .mode_auxpll = 10, /* 120MHz AUXPLL */ 496 .mode_auxpll = 10, /* 120MHz AUXPLL */
508 .device_init = NULL,
509 .device_shutdown = NULL,
510 1280, 1280, 497 1280, 1280,
511 1024, 1024, 498 1024, 1024,
512 }, 499 },
@@ -535,8 +522,6 @@ static struct panel_settings known_lcd_panels[] =
535 .mode_toyclksrc = 0x00000004, /* AUXPLL directly */ 522 .mode_toyclksrc = 0x00000004, /* AUXPLL directly */
536 .mode_backlight = 0x00000000, 523 .mode_backlight = 0x00000000,
537 .mode_auxpll = 8, /* 96MHz AUXPLL */ 524 .mode_auxpll = 8, /* 96MHz AUXPLL */
538 .device_init = board_au1200fb_panel_init,
539 .device_shutdown = board_au1200fb_panel_shutdown,
540 1024, 1024, 525 1024, 1024,
541 768, 768, 526 768, 768,
542 }, 527 },
@@ -568,8 +553,6 @@ static struct panel_settings known_lcd_panels[] =
568 .mode_toyclksrc = 0x00000004, /* AUXPLL directly */ 553 .mode_toyclksrc = 0x00000004, /* AUXPLL directly */
569 .mode_backlight = 0x00000000, 554 .mode_backlight = 0x00000000,
570 .mode_auxpll = 8, /* 96MHz AUXPLL */ 555 .mode_auxpll = 8, /* 96MHz AUXPLL */
571 .device_init = board_au1200fb_panel_init,
572 .device_shutdown = board_au1200fb_panel_shutdown,
573 640, 480, 556 640, 480,
574 640, 480, 557 640, 480,
575 }, 558 },
@@ -601,8 +584,6 @@ static struct panel_settings known_lcd_panels[] =
601 .mode_toyclksrc = 0x00000004, /* AUXPLL directly */ 584 .mode_toyclksrc = 0x00000004, /* AUXPLL directly */
602 .mode_backlight = 0x00000000, 585 .mode_backlight = 0x00000000,
603 .mode_auxpll = 8, /* 96MHz AUXPLL */ 586 .mode_auxpll = 8, /* 96MHz AUXPLL */
604 .device_init = board_au1200fb_panel_init,
605 .device_shutdown = board_au1200fb_panel_shutdown,
606 320, 320, 587 320, 320,
607 240, 240, 588 240, 240,
608 }, 589 },
@@ -634,8 +615,6 @@ static struct panel_settings known_lcd_panels[] =
634 .mode_toyclksrc = 0x00000004, /* AUXPLL directly */ 615 .mode_toyclksrc = 0x00000004, /* AUXPLL directly */
635 .mode_backlight = 0x00000000, 616 .mode_backlight = 0x00000000,
636 .mode_auxpll = 8, /* 96MHz AUXPLL */ 617 .mode_auxpll = 8, /* 96MHz AUXPLL */
637 .device_init = board_au1200fb_panel_init,
638 .device_shutdown = board_au1200fb_panel_shutdown,
639 856, 856, 618 856, 856,
640 480, 480, 619 480, 480,
641 }, 620 },
@@ -670,8 +649,6 @@ static struct panel_settings known_lcd_panels[] =
670 .mode_toyclksrc = 0x00000004, /* AUXPLL directly */ 649 .mode_toyclksrc = 0x00000004, /* AUXPLL directly */
671 .mode_backlight = 0x00000000, 650 .mode_backlight = 0x00000000,
672 .mode_auxpll = (48/12) * 2, 651 .mode_auxpll = (48/12) * 2,
673 .device_init = board_au1200fb_panel_init,
674 .device_shutdown = board_au1200fb_panel_shutdown,
675 800, 800, 652 800, 800,
676 480, 480, 653 480, 480,
677 }, 654 },
@@ -800,7 +777,8 @@ static int au1200_setlocation (struct au1200fb_device *fbdev, int plane,
800 return 0; 777 return 0;
801} 778}
802 779
803static void au1200_setpanel (struct panel_settings *newpanel) 780static void au1200_setpanel(struct panel_settings *newpanel,
781 struct au1200fb_platdata *pd)
804{ 782{
805 /* 783 /*
806 * Perform global setup/init of LCD controller 784 * Perform global setup/init of LCD controller
@@ -834,8 +812,8 @@ static void au1200_setpanel (struct panel_settings *newpanel)
834 the controller, the clock cannot be turned off before first 812 the controller, the clock cannot be turned off before first
835 shutting down the controller. 813 shutting down the controller.
836 */ 814 */
837 if (panel->device_shutdown != NULL) 815 if (pd->panel_shutdown)
838 panel->device_shutdown(); 816 pd->panel_shutdown();
839 } 817 }
840 818
841 /* Newpanel == NULL indicates a shutdown operation only */ 819 /* Newpanel == NULL indicates a shutdown operation only */
@@ -888,7 +866,8 @@ static void au1200_setpanel (struct panel_settings *newpanel)
888 au_sync(); 866 au_sync();
889 867
890 /* Call init of panel */ 868 /* Call init of panel */
891 if (panel->device_init != NULL) panel->device_init(); 869 if (pd->panel_init)
870 pd->panel_init();
892 871
893 /* FIX!!!! not appropriate on panel change!!! Global setup/init */ 872 /* FIX!!!! not appropriate on panel change!!! Global setup/init */
894 lcd->intenable = 0; 873 lcd->intenable = 0;
@@ -1221,6 +1200,8 @@ static int au1200fb_fb_setcolreg(unsigned regno, unsigned red, unsigned green,
1221 */ 1200 */
1222static int au1200fb_fb_blank(int blank_mode, struct fb_info *fbi) 1201static int au1200fb_fb_blank(int blank_mode, struct fb_info *fbi)
1223{ 1202{
1203 struct au1200fb_device *fbdev = fbi->par;
1204
1224 /* Short-circuit screen blanking */ 1205 /* Short-circuit screen blanking */
1225 if (noblanking) 1206 if (noblanking)
1226 return 0; 1207 return 0;
@@ -1230,13 +1211,13 @@ static int au1200fb_fb_blank(int blank_mode, struct fb_info *fbi)
1230 case FB_BLANK_UNBLANK: 1211 case FB_BLANK_UNBLANK:
1231 case FB_BLANK_NORMAL: 1212 case FB_BLANK_NORMAL:
1232 /* printk("turn on panel\n"); */ 1213 /* printk("turn on panel\n"); */
1233 au1200_setpanel(panel); 1214 au1200_setpanel(panel, fbdev->pd);
1234 break; 1215 break;
1235 case FB_BLANK_VSYNC_SUSPEND: 1216 case FB_BLANK_VSYNC_SUSPEND:
1236 case FB_BLANK_HSYNC_SUSPEND: 1217 case FB_BLANK_HSYNC_SUSPEND:
1237 case FB_BLANK_POWERDOWN: 1218 case FB_BLANK_POWERDOWN:
1238 /* printk("turn off panel\n"); */ 1219 /* printk("turn off panel\n"); */
1239 au1200_setpanel(NULL); 1220 au1200_setpanel(NULL, fbdev->pd);
1240 break; 1221 break;
1241 default: 1222 default:
1242 break; 1223 break;
@@ -1464,6 +1445,7 @@ static void get_window(unsigned int plane,
1464static int au1200fb_ioctl(struct fb_info *info, unsigned int cmd, 1445static int au1200fb_ioctl(struct fb_info *info, unsigned int cmd,
1465 unsigned long arg) 1446 unsigned long arg)
1466{ 1447{
1448 struct au1200fb_device *fbdev = info->par;
1467 int plane; 1449 int plane;
1468 int val; 1450 int val;
1469 1451
@@ -1508,7 +1490,7 @@ static int au1200fb_ioctl(struct fb_info *info, unsigned int cmd,
1508 struct panel_settings *newpanel; 1490 struct panel_settings *newpanel;
1509 panel_index = iodata.global.panel_choice; 1491 panel_index = iodata.global.panel_choice;
1510 newpanel = &known_lcd_panels[panel_index]; 1492 newpanel = &known_lcd_panels[panel_index];
1511 au1200_setpanel(newpanel); 1493 au1200_setpanel(newpanel, fbdev->pd);
1512 } 1494 }
1513 break; 1495 break;
1514 1496
@@ -1624,22 +1606,102 @@ static int au1200fb_init_fbinfo(struct au1200fb_device *fbdev)
1624 1606
1625/*-------------------------------------------------------------------------*/ 1607/*-------------------------------------------------------------------------*/
1626 1608
1627/* AU1200 LCD controller device driver */
1628 1609
1610static int au1200fb_setup(struct au1200fb_platdata *pd)
1611{
1612 char *options = NULL;
1613 char *this_opt, *endptr;
1614 int num_panels = ARRAY_SIZE(known_lcd_panels);
1615 int panel_idx = -1;
1616
1617 fb_get_options(DRIVER_NAME, &options);
1618
1619 if (!options)
1620 goto out;
1621
1622 while ((this_opt = strsep(&options, ",")) != NULL) {
1623 /* Panel option - can be panel name,
1624 * "bs" for board-switch, or number/index */
1625 if (!strncmp(this_opt, "panel:", 6)) {
1626 int i;
1627 long int li;
1628 char *endptr;
1629 this_opt += 6;
1630 /* First check for index, which allows
1631 * to short circuit this mess */
1632 li = simple_strtol(this_opt, &endptr, 0);
1633 if (*endptr == '\0')
1634 panel_idx = (int)li;
1635 else if (strcmp(this_opt, "bs") == 0)
1636 panel_idx = pd->panel_index();
1637 else {
1638 for (i = 0; i < num_panels; i++) {
1639 if (!strcmp(this_opt,
1640 known_lcd_panels[i].name)) {
1641 panel_idx = i;
1642 break;
1643 }
1644 }
1645 }
1646 if ((panel_idx < 0) || (panel_idx >= num_panels))
1647 print_warn("Panel %s not supported!", this_opt);
1648 else
1649 panel_index = panel_idx;
1650
1651 } else if (strncmp(this_opt, "nohwcursor", 10) == 0)
1652 nohwcursor = 1;
1653 else if (strncmp(this_opt, "devices:", 8) == 0) {
1654 this_opt += 8;
1655 device_count = simple_strtol(this_opt, &endptr, 0);
1656 if ((device_count < 0) ||
1657 (device_count > MAX_DEVICE_COUNT))
1658 device_count = MAX_DEVICE_COUNT;
1659 } else if (strncmp(this_opt, "wincfg:", 7) == 0) {
1660 this_opt += 7;
1661 window_index = simple_strtol(this_opt, &endptr, 0);
1662 if ((window_index < 0) ||
1663 (window_index >= ARRAY_SIZE(windows)))
1664 window_index = DEFAULT_WINDOW_INDEX;
1665 } else if (strncmp(this_opt, "off", 3) == 0)
1666 return 1;
1667 else
1668 print_warn("Unsupported option \"%s\"", this_opt);
1669 }
1670
1671out:
1672 return 0;
1673}
1674
1675/* AU1200 LCD controller device driver */
1629static int __devinit au1200fb_drv_probe(struct platform_device *dev) 1676static int __devinit au1200fb_drv_probe(struct platform_device *dev)
1630{ 1677{
1631 struct au1200fb_device *fbdev; 1678 struct au1200fb_device *fbdev;
1679 struct au1200fb_platdata *pd;
1632 struct fb_info *fbi = NULL; 1680 struct fb_info *fbi = NULL;
1633 unsigned long page; 1681 unsigned long page;
1634 int bpp, plane, ret, irq; 1682 int bpp, plane, ret, irq;
1635 1683
1684 print_info("" DRIVER_DESC "");
1685
1686 pd = dev->dev.platform_data;
1687 if (!pd)
1688 return -ENODEV;
1689
1690 /* Setup driver with options */
1691 if (au1200fb_setup(pd))
1692 return -ENODEV;
1693
1694 /* Point to the panel selected */
1695 panel = &known_lcd_panels[panel_index];
1696 win = &windows[window_index];
1697
1698 printk(DRIVER_NAME ": Panel %d %s\n", panel_index, panel->name);
1699 printk(DRIVER_NAME ": Win %d %s\n", window_index, win->name);
1700
1636 /* shut gcc up */ 1701 /* shut gcc up */
1637 ret = 0; 1702 ret = 0;
1638 fbdev = NULL; 1703 fbdev = NULL;
1639 1704
1640 /* Kickstart the panel */
1641 au1200_setpanel(panel);
1642
1643 for (plane = 0; plane < device_count; ++plane) { 1705 for (plane = 0; plane < device_count; ++plane) {
1644 bpp = winbpp(win->w[plane].mode_winctrl1); 1706 bpp = winbpp(win->w[plane].mode_winctrl1);
1645 if (win->w[plane].xres == 0) 1707 if (win->w[plane].xres == 0)
@@ -1655,6 +1717,7 @@ static int __devinit au1200fb_drv_probe(struct platform_device *dev)
1655 _au1200fb_infos[plane] = fbi; 1717 _au1200fb_infos[plane] = fbi;
1656 fbdev = fbi->par; 1718 fbdev = fbi->par;
1657 fbdev->fb_info = fbi; 1719 fbdev->fb_info = fbi;
1720 fbdev->pd = pd;
1658 1721
1659 fbdev->plane = plane; 1722 fbdev->plane = plane;
1660 1723
@@ -1716,6 +1779,11 @@ static int __devinit au1200fb_drv_probe(struct platform_device *dev)
1716 goto failed; 1779 goto failed;
1717 } 1780 }
1718 1781
1782 platform_set_drvdata(dev, pd);
1783
1784 /* Kickstart the panel */
1785 au1200_setpanel(panel, pd);
1786
1719 return 0; 1787 return 0;
1720 1788
1721failed: 1789failed:
@@ -1735,12 +1803,13 @@ failed:
1735 1803
1736static int __devexit au1200fb_drv_remove(struct platform_device *dev) 1804static int __devexit au1200fb_drv_remove(struct platform_device *dev)
1737{ 1805{
1806 struct au1200fb_platdata *pd = platform_get_drvdata(dev);
1738 struct au1200fb_device *fbdev; 1807 struct au1200fb_device *fbdev;
1739 struct fb_info *fbi; 1808 struct fb_info *fbi;
1740 int plane; 1809 int plane;
1741 1810
1742 /* Turn off the panel */ 1811 /* Turn off the panel */
1743 au1200_setpanel(NULL); 1812 au1200_setpanel(NULL, pd);
1744 1813
1745 for (plane = 0; plane < device_count; ++plane) { 1814 for (plane = 0; plane < device_count; ++plane) {
1746 fbi = _au1200fb_infos[plane]; 1815 fbi = _au1200fb_infos[plane];
@@ -1768,7 +1837,8 @@ static int __devexit au1200fb_drv_remove(struct platform_device *dev)
1768#ifdef CONFIG_PM 1837#ifdef CONFIG_PM
1769static int au1200fb_drv_suspend(struct device *dev) 1838static int au1200fb_drv_suspend(struct device *dev)
1770{ 1839{
1771 au1200_setpanel(NULL); 1840 struct au1200fb_platdata *pd = dev_get_drvdata(dev);
1841 au1200_setpanel(NULL, pd);
1772 1842
1773 lcd->outmask = 0; 1843 lcd->outmask = 0;
1774 au_sync(); 1844 au_sync();
@@ -1778,11 +1848,12 @@ static int au1200fb_drv_suspend(struct device *dev)
1778 1848
1779static int au1200fb_drv_resume(struct device *dev) 1849static int au1200fb_drv_resume(struct device *dev)
1780{ 1850{
1851 struct au1200fb_platdata *pd = dev_get_drvdata(dev);
1781 struct fb_info *fbi; 1852 struct fb_info *fbi;
1782 int i; 1853 int i;
1783 1854
1784 /* Kickstart the panel */ 1855 /* Kickstart the panel */
1785 au1200_setpanel(panel); 1856 au1200_setpanel(panel, pd);
1786 1857
1787 for (i = 0; i < device_count; i++) { 1858 for (i = 0; i < device_count; i++) {
1788 fbi = _au1200fb_infos[i]; 1859 fbi = _au1200fb_infos[i];
@@ -1817,100 +1888,8 @@ static struct platform_driver au1200fb_driver = {
1817 1888
1818/*-------------------------------------------------------------------------*/ 1889/*-------------------------------------------------------------------------*/
1819 1890
1820/* Kernel driver */
1821
1822static int au1200fb_setup(void)
1823{
1824 char *options = NULL;
1825 char *this_opt, *endptr;
1826 int num_panels = ARRAY_SIZE(known_lcd_panels);
1827 int panel_idx = -1;
1828
1829 fb_get_options(DRIVER_NAME, &options);
1830
1831 if (options) {
1832 while ((this_opt = strsep(&options,",")) != NULL) {
1833 /* Panel option - can be panel name,
1834 * "bs" for board-switch, or number/index */
1835 if (!strncmp(this_opt, "panel:", 6)) {
1836 int i;
1837 long int li;
1838 char *endptr;
1839 this_opt += 6;
1840 /* First check for index, which allows
1841 * to short circuit this mess */
1842 li = simple_strtol(this_opt, &endptr, 0);
1843 if (*endptr == '\0') {
1844 panel_idx = (int)li;
1845 }
1846 else if (strcmp(this_opt, "bs") == 0) {
1847 extern int board_au1200fb_panel(void);
1848 panel_idx = board_au1200fb_panel();
1849 }
1850
1851 else
1852 for (i = 0; i < num_panels; i++) {
1853 if (!strcmp(this_opt, known_lcd_panels[i].name)) {
1854 panel_idx = i;
1855 break;
1856 }
1857 }
1858
1859 if ((panel_idx < 0) || (panel_idx >= num_panels)) {
1860 print_warn("Panel %s not supported!", this_opt);
1861 }
1862 else
1863 panel_index = panel_idx;
1864 }
1865
1866 else if (strncmp(this_opt, "nohwcursor", 10) == 0) {
1867 nohwcursor = 1;
1868 }
1869
1870 else if (strncmp(this_opt, "devices:", 8) == 0) {
1871 this_opt += 8;
1872 device_count = simple_strtol(this_opt,
1873 &endptr, 0);
1874 if ((device_count < 0) ||
1875 (device_count > MAX_DEVICE_COUNT))
1876 device_count = MAX_DEVICE_COUNT;
1877 }
1878
1879 else if (strncmp(this_opt, "wincfg:", 7) == 0) {
1880 this_opt += 7;
1881 window_index = simple_strtol(this_opt,
1882 &endptr, 0);
1883 if ((window_index < 0) ||
1884 (window_index >= ARRAY_SIZE(windows)))
1885 window_index = DEFAULT_WINDOW_INDEX;
1886 }
1887
1888 else if (strncmp(this_opt, "off", 3) == 0)
1889 return 1;
1890 /* Unsupported option */
1891 else {
1892 print_warn("Unsupported option \"%s\"", this_opt);
1893 }
1894 }
1895 }
1896 return 0;
1897}
1898
1899static int __init au1200fb_init(void) 1891static int __init au1200fb_init(void)
1900{ 1892{
1901 print_info("" DRIVER_DESC "");
1902
1903 /* Setup driver with options */
1904 if (au1200fb_setup())
1905 return -ENODEV;
1906
1907 /* Point to the panel selected */
1908 panel = &known_lcd_panels[panel_index];
1909 win = &windows[window_index];
1910
1911 printk(DRIVER_NAME ": Panel %d %s\n", panel_index, panel->name);
1912 printk(DRIVER_NAME ": Win %d %s\n", window_index, win->name);
1913
1914 return platform_driver_register(&au1200fb_driver); 1893 return platform_driver_register(&au1200fb_driver);
1915} 1894}
1916 1895