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