Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux...
[sfrench/cifs-2.6.git] / arch / avr32 / boards / atngw100 / evklcd10x.c
1 /*
2  * Board-specific setup code for the ATEVKLCD10X addon board to the ATNGW100
3  * Network Gateway
4  *
5  * Copyright (C) 2008 Atmel Corporation
6  *
7  * This program is free software; you can redistribute it and/or modify it
8  * under the terms of the GNU General Public License version 2 as published by
9  * the Free Software Foundation.
10  */
11
12 #include <linux/init.h>
13 #include <linux/linkage.h>
14 #include <linux/gpio.h>
15 #include <linux/fb.h>
16 #include <linux/platform_device.h>
17
18 #include <video/atmel_lcdc.h>
19
20 #include <asm/setup.h>
21
22 #include <mach/at32ap700x.h>
23 #include <mach/portmux.h>
24 #include <mach/board.h>
25
26 static struct ac97c_platform_data __initdata ac97c0_data = {
27         .dma_rx_periph_id       = 3,
28         .dma_tx_periph_id       = 4,
29         .dma_controller_id      = 0,
30         .reset_pin              = GPIO_PIN_PB(19),
31 };
32
33 #ifdef CONFIG_BOARD_ATNGW100_EVKLCD10X_VGA
34 static struct fb_videomode __initdata tcg057vglad_modes[] = {
35         {
36                 .name           = "640x480 @ 50",
37                 .refresh        = 50,
38                 .xres           = 640,          .yres           = 480,
39                 .pixclock       = KHZ2PICOS(25180),
40
41                 .left_margin    = 64,           .right_margin   = 96,
42                 .upper_margin   = 34,           .lower_margin   = 11,
43                 .hsync_len      = 64,           .vsync_len      = 15,
44
45                 .sync           = 0,
46                 .vmode          = FB_VMODE_NONINTERLACED,
47         },
48 };
49
50 static struct fb_monspecs __initdata atevklcd10x_default_monspecs = {
51         .manufacturer           = "KYO",
52         .monitor                = "TCG057VGLAD",
53         .modedb                 = tcg057vglad_modes,
54         .modedb_len             = ARRAY_SIZE(tcg057vglad_modes),
55         .hfmin                  = 19948,
56         .hfmax                  = 31478,
57         .vfmin                  = 50,
58         .vfmax                  = 67,
59         .dclkmax                = 28330000,
60 };
61
62 static struct atmel_lcdfb_info __initdata atevklcd10x_lcdc_data = {
63         .default_bpp            = 16,
64         .default_dmacon         = ATMEL_LCDC_DMAEN | ATMEL_LCDC_DMA2DEN,
65         .default_lcdcon2        = (ATMEL_LCDC_DISTYPE_TFT
66                                    | ATMEL_LCDC_CLKMOD_ALWAYSACTIVE
67                                    | ATMEL_LCDC_MEMOR_BIG),
68         .default_monspecs       = &atevklcd10x_default_monspecs,
69         .guard_time             = 2,
70 };
71 #elif CONFIG_BOARD_ATNGW100_EVKLCD10X_QVGA
72 static struct fb_videomode __initdata tcg057qvlad_modes[] = {
73         {
74                 .name           = "320x240 @ 50",
75                 .refresh        = 50,
76                 .xres           = 320,          .yres           = 240,
77                 .pixclock       = KHZ2PICOS(6300),
78
79                 .left_margin    = 34,           .right_margin   = 46,
80                 .upper_margin   = 7,            .lower_margin   = 15,
81                 .hsync_len      = 64,           .vsync_len      = 12,
82
83                 .sync           = 0,
84                 .vmode          = FB_VMODE_NONINTERLACED,
85         },
86 };
87
88 static struct fb_monspecs __initdata atevklcd10x_default_monspecs = {
89         .manufacturer           = "KYO",
90         .monitor                = "TCG057QVLAD",
91         .modedb                 = tcg057qvlad_modes,
92         .modedb_len             = ARRAY_SIZE(tcg057qvlad_modes),
93         .hfmin                  = 19948,
94         .hfmax                  = 31478,
95         .vfmin                  = 50,
96         .vfmax                  = 67,
97         .dclkmax                = 7000000,
98 };
99
100 static struct atmel_lcdfb_info __initdata atevklcd10x_lcdc_data = {
101         .default_bpp            = 16,
102         .default_dmacon         = ATMEL_LCDC_DMAEN | ATMEL_LCDC_DMA2DEN,
103         .default_lcdcon2        = (ATMEL_LCDC_DISTYPE_TFT
104                                    | ATMEL_LCDC_CLKMOD_ALWAYSACTIVE
105                                    | ATMEL_LCDC_MEMOR_BIG),
106         .default_monspecs       = &atevklcd10x_default_monspecs,
107         .guard_time             = 2,
108 };
109 #elif CONFIG_BOARD_ATNGW100_EVKLCD10X_POW_QVGA
110 static struct fb_videomode __initdata ph320240t_modes[] = {
111         {
112                 .name           = "320x240 @ 60",
113                 .refresh        = 60,
114                 .xres           = 320,          .yres           = 240,
115                 .pixclock       = KHZ2PICOS(6300),
116
117                 .left_margin    = 38,           .right_margin   = 20,
118                 .upper_margin   = 15,           .lower_margin   = 5,
119                 .hsync_len      = 30,           .vsync_len      = 3,
120
121                 .sync           = 0,
122                 .vmode          = FB_VMODE_NONINTERLACED,
123         },
124 };
125
126 static struct fb_monspecs __initdata atevklcd10x_default_monspecs = {
127         .manufacturer           = "POW",
128         .monitor                = "PH320240T",
129         .modedb                 = ph320240t_modes,
130         .modedb_len             = ARRAY_SIZE(ph320240t_modes),
131         .hfmin                  = 14400,
132         .hfmax                  = 21600,
133         .vfmin                  = 50,
134         .vfmax                  = 90,
135         .dclkmax                = 6400000,
136 };
137
138 static struct atmel_lcdfb_info __initdata atevklcd10x_lcdc_data = {
139         .default_bpp            = 16,
140         .default_dmacon         = ATMEL_LCDC_DMAEN | ATMEL_LCDC_DMA2DEN,
141         .default_lcdcon2        = (ATMEL_LCDC_DISTYPE_TFT
142                                    | ATMEL_LCDC_CLKMOD_ALWAYSACTIVE
143                                    | ATMEL_LCDC_MEMOR_BIG),
144         .default_monspecs       = &atevklcd10x_default_monspecs,
145         .guard_time             = 2,
146 };
147 #endif
148
149 static void atevklcd10x_lcdc_power_control(int on)
150 {
151         gpio_set_value(GPIO_PIN_PB(15), on);
152 }
153
154 static int __init atevklcd10x_init(void)
155 {
156         /* PB15 is connected to the enable line on the boost regulator
157          * controlling the backlight for the LCD panel.
158          */
159         at32_select_gpio(GPIO_PIN_PB(15), AT32_GPIOF_OUTPUT);
160         gpio_request(GPIO_PIN_PB(15), "backlight");
161         gpio_direction_output(GPIO_PIN_PB(15), 0);
162
163         atevklcd10x_lcdc_data.atmel_lcdfb_power_control =
164                 atevklcd10x_lcdc_power_control;
165
166         at32_add_device_lcdc(0, &atevklcd10x_lcdc_data,
167                         fbmem_start, fbmem_size,
168                         ATMEL_LCDC_ALT_18BIT | ATMEL_LCDC_PE_DVAL);
169
170         at32_add_device_ac97c(0, &ac97c0_data);
171
172         return 0;
173 }
174 postcore_initcall(atevklcd10x_init);