Merge tag 'tiny/no-advice-fixup-3.18' of git://git.kernel.org/pub/scm/linux/kernel...
[sfrench/cifs-2.6.git] / arch / arm / mach-at91 / board-sam9rlek.c
1 /*
2  *  Copyright (C) 2005 SAN People
3  *  Copyright (C) 2007 Atmel Corporation
4  *
5  * This file is subject to the terms and conditions of the GNU General Public
6  * License.  See the file COPYING in the main directory of this archive for
7  * more details.
8  */
9
10 #include <linux/types.h>
11 #include <linux/gpio.h>
12 #include <linux/init.h>
13 #include <linux/mm.h>
14 #include <linux/module.h>
15 #include <linux/platform_device.h>
16 #include <linux/spi/spi.h>
17 #include <linux/fb.h>
18 #include <linux/clk.h>
19 #include <linux/input.h>
20 #include <linux/gpio_keys.h>
21 #include <linux/platform_data/at91_adc.h>
22
23 #include <video/atmel_lcdc.h>
24
25 #include <asm/setup.h>
26 #include <asm/mach-types.h>
27 #include <asm/irq.h>
28
29 #include <asm/mach/arch.h>
30 #include <asm/mach/map.h>
31 #include <asm/mach/irq.h>
32
33 #include <mach/hardware.h>
34 #include <mach/at91sam9_smc.h>
35
36
37 #include "at91_aic.h"
38 #include "board.h"
39 #include "sam9_smc.h"
40 #include "generic.h"
41 #include "gpio.h"
42
43
44 static void __init ek_init_early(void)
45 {
46         /* Initialize processor: 12.000 MHz crystal */
47         at91_initialize(12000000);
48 }
49
50 /*
51  * USB HS Device port
52  */
53 static struct usba_platform_data __initdata ek_usba_udc_data = {
54         .vbus_pin       = AT91_PIN_PA8,
55 };
56
57
58 /*
59  * MCI (SD/MMC)
60  */
61 static struct mci_platform_data __initdata mci0_data = {
62         .slot[0] = {
63                 .bus_width      = 4,
64                 .detect_pin     = AT91_PIN_PA15,
65                 .wp_pin         = -EINVAL,
66         },
67 };
68
69
70 /*
71  * NAND flash
72  */
73 static struct mtd_partition __initdata ek_nand_partition[] = {
74         {
75                 .name   = "Partition 1",
76                 .offset = 0,
77                 .size   = SZ_256K,
78         },
79         {
80                 .name   = "Partition 2",
81                 .offset = MTDPART_OFS_NXTBLK,
82                 .size   = MTDPART_SIZ_FULL,
83         },
84 };
85
86 static struct atmel_nand_data __initdata ek_nand_data = {
87         .ale            = 21,
88         .cle            = 22,
89         .det_pin        = -EINVAL,
90         .rdy_pin        = AT91_PIN_PD17,
91         .enable_pin     = AT91_PIN_PB6,
92         .ecc_mode       = NAND_ECC_SOFT,
93         .on_flash_bbt   = 1,
94         .parts          = ek_nand_partition,
95         .num_parts      = ARRAY_SIZE(ek_nand_partition),
96 };
97
98 static struct sam9_smc_config __initdata ek_nand_smc_config = {
99         .ncs_read_setup         = 0,
100         .nrd_setup              = 1,
101         .ncs_write_setup        = 0,
102         .nwe_setup              = 1,
103
104         .ncs_read_pulse         = 3,
105         .nrd_pulse              = 3,
106         .ncs_write_pulse        = 3,
107         .nwe_pulse              = 3,
108
109         .read_cycle             = 5,
110         .write_cycle            = 5,
111
112         .mode                   = AT91_SMC_READMODE | AT91_SMC_WRITEMODE | AT91_SMC_EXNWMODE_DISABLE | AT91_SMC_DBW_8,
113         .tdf_cycles             = 2,
114 };
115
116 static void __init ek_add_device_nand(void)
117 {
118         /* configure chip-select 3 (NAND) */
119         sam9_smc_configure(0, 3, &ek_nand_smc_config);
120
121         at91_add_device_nand(&ek_nand_data);
122 }
123
124
125 /*
126  * SPI devices
127  */
128 static struct spi_board_info ek_spi_devices[] = {
129         {       /* DataFlash chip */
130                 .modalias       = "mtd_dataflash",
131                 .chip_select    = 0,
132                 .max_speed_hz   = 15 * 1000 * 1000,
133                 .bus_num        = 0,
134         },
135 };
136
137
138 /*
139  * LCD Controller
140  */
141 #if defined(CONFIG_FB_ATMEL) || defined(CONFIG_FB_ATMEL_MODULE)
142 static struct fb_videomode at91_tft_vga_modes[] = {
143         {
144                 .name           = "TX09D50VM1CCA @ 60",
145                 .refresh        = 60,
146                 .xres           = 240,          .yres           = 320,
147                 .pixclock       = KHZ2PICOS(4965),
148
149                 .left_margin    = 1,            .right_margin   = 33,
150                 .upper_margin   = 1,            .lower_margin   = 0,
151                 .hsync_len      = 5,            .vsync_len      = 1,
152
153                 .sync           = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
154                 .vmode          = FB_VMODE_NONINTERLACED,
155         },
156 };
157
158 static struct fb_monspecs at91fb_default_monspecs = {
159         .manufacturer   = "HIT",
160         .monitor        = "TX09D50VM1CCA",
161
162         .modedb         = at91_tft_vga_modes,
163         .modedb_len     = ARRAY_SIZE(at91_tft_vga_modes),
164         .hfmin          = 15000,
165         .hfmax          = 64000,
166         .vfmin          = 50,
167         .vfmax          = 150,
168 };
169
170 #define AT91SAM9RL_DEFAULT_LCDCON2      (ATMEL_LCDC_MEMOR_LITTLE \
171                                         | ATMEL_LCDC_DISTYPE_TFT \
172                                         | ATMEL_LCDC_CLKMOD_ALWAYSACTIVE)
173
174 static void at91_lcdc_power_control(struct atmel_lcdfb_pdata *pdata, int on)
175 {
176         if (on)
177                 at91_set_gpio_value(AT91_PIN_PC1, 0);   /* power up */
178         else
179                 at91_set_gpio_value(AT91_PIN_PC1, 1);   /* power down */
180 }
181
182 /* Driver datas */
183 static struct atmel_lcdfb_pdata __initdata ek_lcdc_data = {
184         .lcdcon_is_backlight            = true,
185         .default_bpp                    = 16,
186         .default_dmacon                 = ATMEL_LCDC_DMAEN,
187         .default_lcdcon2                = AT91SAM9RL_DEFAULT_LCDCON2,
188         .default_monspecs               = &at91fb_default_monspecs,
189         .atmel_lcdfb_power_control      = at91_lcdc_power_control,
190         .guard_time                     = 1,
191         .lcd_wiring_mode                = ATMEL_LCDC_WIRING_RGB,
192 };
193
194 #else
195 static struct atmel_lcdfb_pdata __initdata ek_lcdc_data;
196 #endif
197
198
199 /*
200  * AC97
201  * reset_pin is not connected: NRST
202  */
203 static struct ac97c_platform_data ek_ac97_data = {
204         .reset_pin      = -EINVAL,
205 };
206
207
208 /*
209  * LEDs
210  */
211 static struct gpio_led ek_leds[] = {
212         {       /* "bottom" led, green, userled1 to be defined */
213                 .name                   = "ds1",
214                 .gpio                   = AT91_PIN_PD15,
215                 .active_low             = 1,
216                 .default_trigger        = "none",
217         },
218         {       /* "bottom" led, green, userled2 to be defined */
219                 .name                   = "ds2",
220                 .gpio                   = AT91_PIN_PD16,
221                 .active_low             = 1,
222                 .default_trigger        = "none",
223         },
224         {       /* "power" led, yellow */
225                 .name                   = "ds3",
226                 .gpio                   = AT91_PIN_PD14,
227                 .default_trigger        = "heartbeat",
228         }
229 };
230
231
232 /*
233  * ADC + Touchscreen
234  */
235 static struct at91_adc_data ek_adc_data = {
236         .channels_used = BIT(0) | BIT(1) | BIT(2) | BIT(3) | BIT(4) | BIT(5),
237         .use_external_triggers = true,
238         .vref = 3300,
239         .touchscreen_type = ATMEL_ADC_TOUCHSCREEN_4WIRE,
240 };
241
242
243 /*
244  * GPIO Buttons
245  */
246 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
247 static struct gpio_keys_button ek_buttons[] = {
248         {
249                 .gpio           = AT91_PIN_PB0,
250                 .code           = BTN_2,
251                 .desc           = "Right Click",
252                 .active_low     = 1,
253                 .wakeup         = 1,
254         },
255         {
256                 .gpio           = AT91_PIN_PB1,
257                 .code           = BTN_1,
258                 .desc           = "Left Click",
259                 .active_low     = 1,
260                 .wakeup         = 1,
261         }
262 };
263
264 static struct gpio_keys_platform_data ek_button_data = {
265         .buttons        = ek_buttons,
266         .nbuttons       = ARRAY_SIZE(ek_buttons),
267 };
268
269 static struct platform_device ek_button_device = {
270         .name           = "gpio-keys",
271         .id             = -1,
272         .num_resources  = 0,
273         .dev            = {
274                 .platform_data  = &ek_button_data,
275         }
276 };
277
278 static void __init ek_add_device_buttons(void)
279 {
280         at91_set_gpio_input(AT91_PIN_PB1, 1);   /* btn1 */
281         at91_set_deglitch(AT91_PIN_PB1, 1);
282         at91_set_gpio_input(AT91_PIN_PB0, 1);   /* btn2 */
283         at91_set_deglitch(AT91_PIN_PB0, 1);
284
285         platform_device_register(&ek_button_device);
286 }
287 #else
288 static void __init ek_add_device_buttons(void) {}
289 #endif
290
291
292 static void __init ek_board_init(void)
293 {
294         at91_register_devices();
295
296         /* Serial */
297         /* DBGU on ttyS0. (Rx & Tx only) */
298         at91_register_uart(0, 0, 0);
299
300         /* USART0 on ttyS1. (Rx, Tx, CTS, RTS) */
301         at91_register_uart(AT91SAM9RL_ID_US0, 1, ATMEL_UART_CTS | ATMEL_UART_RTS);
302         at91_add_device_serial();
303         /* USB HS */
304         at91_add_device_usba(&ek_usba_udc_data);
305         /* I2C */
306         at91_add_device_i2c(NULL, 0);
307         /* NAND */
308         ek_add_device_nand();
309         /* SPI */
310         at91_add_device_spi(ek_spi_devices, ARRAY_SIZE(ek_spi_devices));
311         /* MMC */
312         at91_add_device_mci(0, &mci0_data);
313         /* LCD Controller */
314         at91_add_device_lcdc(&ek_lcdc_data);
315         /* AC97 */
316         at91_add_device_ac97(&ek_ac97_data);
317         /* Touch Screen Controller + ADC */
318         at91_add_device_adc(&ek_adc_data);
319         /* LEDs */
320         at91_gpio_leds(ek_leds, ARRAY_SIZE(ek_leds));
321         /* Push Buttons */
322         ek_add_device_buttons();
323 }
324
325 MACHINE_START(AT91SAM9RLEK, "Atmel AT91SAM9RL-EK")
326         /* Maintainer: Atmel */
327         .init_time      = at91_init_time,
328         .map_io         = at91_map_io,
329         .handle_irq     = at91_aic_handle_irq,
330         .init_early     = ek_init_early,
331         .init_irq       = at91_init_irq_default,
332         .init_machine   = ek_board_init,
333 MACHINE_END