blob: 065b5ee35070e6da3bdce857a6988cb98853f962 [file] [log] [blame]
Andrew Victor022cbd72006-12-01 14:38:59 +01001/*
Andrew Victord0760b32007-02-08 09:00:39 +01002 * linux/arch/arm/mach-at91/board-sam9261ek.c
Andrew Victor022cbd72006-12-01 14:38:59 +01003 *
4 * Copyright (C) 2005 SAN People
5 * Copyright (C) 2006 Atmel
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */
21
22#include <linux/types.h>
Russell King2f8163b2011-07-26 10:53:52 +010023#include <linux/gpio.h>
Andrew Victor022cbd72006-12-01 14:38:59 +010024#include <linux/init.h>
25#include <linux/mm.h>
26#include <linux/module.h>
27#include <linux/platform_device.h>
28#include <linux/spi/spi.h>
Andrew Victor23522722007-05-02 17:58:51 +010029#include <linux/spi/ads7846.h>
Andrew Victor5e9df922008-04-02 22:18:35 +010030#include <linux/spi/at73c213.h>
31#include <linux/clk.h>
Andrew Victor022cbd72006-12-01 14:38:59 +010032#include <linux/dm9000.h>
Andrew Victorcdf95c72007-05-14 15:08:21 +010033#include <linux/fb.h>
Andrew Victord0f9b552007-06-04 08:41:59 +010034#include <linux/gpio_keys.h>
35#include <linux/input.h>
Andrew Victorcdf95c72007-05-14 15:08:21 +010036
37#include <video/atmel_lcdc.h>
Andrew Victor022cbd72006-12-01 14:38:59 +010038
Andrew Victor022cbd72006-12-01 14:38:59 +010039#include <asm/setup.h>
40#include <asm/mach-types.h>
41#include <asm/irq.h>
42
43#include <asm/mach/arch.h>
44#include <asm/mach/map.h>
45#include <asm/mach/irq.h>
46
Andrew Victore5052402008-09-21 21:30:02 +010047#include <mach/hardware.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010048#include <mach/board.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010049#include <mach/at91sam9_smc.h>
Andrew Victor8cdae512008-10-06 20:05:35 +010050#include <mach/at91_shdwc.h>
Jean-Christophe PLAGNIOL-VILLARD76b2ab72011-04-14 00:34:03 +080051#include <mach/system_rev.h>
Andrew Victor022cbd72006-12-01 14:38:59 +010052
Andrew Victor8cdae512008-10-06 20:05:35 +010053#include "sam9_smc.h"
Andrew Victor022cbd72006-12-01 14:38:59 +010054#include "generic.h"
55
56
Jean-Christophe PLAGNIOL-VILLARD1b021a32011-04-28 20:19:32 +080057static void __init ek_init_early(void)
Andrew Victor022cbd72006-12-01 14:38:59 +010058{
59 /* Initialize processor: 18.432 MHz crystal */
Jean-Christophe PLAGNIOL-VILLARD21d08b92011-04-23 15:28:34 +080060 at91_initialize(18432000);
Andrew Victor022cbd72006-12-01 14:38:59 +010061}
62
Andrew Victor022cbd72006-12-01 14:38:59 +010063/*
64 * DM9000 ethernet device
65 */
66#if defined(CONFIG_DM9000)
Andrew Victor8cdae512008-10-06 20:05:35 +010067static struct resource dm9000_resource[] = {
Andrew Victor022cbd72006-12-01 14:38:59 +010068 [0] = {
69 .start = AT91_CHIPSELECT_2,
70 .end = AT91_CHIPSELECT_2 + 3,
71 .flags = IORESOURCE_MEM
72 },
73 [1] = {
74 .start = AT91_CHIPSELECT_2 + 0x44,
75 .end = AT91_CHIPSELECT_2 + 0xFF,
76 .flags = IORESOURCE_MEM
77 },
78 [2] = {
79 .start = AT91_PIN_PC11,
80 .end = AT91_PIN_PC11,
81 .flags = IORESOURCE_IRQ
Nicolas Ferre1879c452010-09-10 11:38:43 +020082 | IORESOURCE_IRQ_LOWEDGE | IORESOURCE_IRQ_HIGHEDGE,
Andrew Victor022cbd72006-12-01 14:38:59 +010083 }
84};
85
86static struct dm9000_plat_data dm9000_platdata = {
Nicolas Ferre1879c452010-09-10 11:38:43 +020087 .flags = DM9000_PLATF_16BITONLY | DM9000_PLATF_NO_EEPROM,
Andrew Victor022cbd72006-12-01 14:38:59 +010088};
89
Andrew Victor8cdae512008-10-06 20:05:35 +010090static struct platform_device dm9000_device = {
Andrew Victor022cbd72006-12-01 14:38:59 +010091 .name = "dm9000",
92 .id = 0,
Andrew Victor8cdae512008-10-06 20:05:35 +010093 .num_resources = ARRAY_SIZE(dm9000_resource),
94 .resource = dm9000_resource,
Andrew Victor022cbd72006-12-01 14:38:59 +010095 .dev = {
96 .platform_data = &dm9000_platdata,
97 }
98};
99
Andrew Victor8cdae512008-10-06 20:05:35 +0100100/*
101 * SMC timings for the DM9000.
102 * Note: These timings were calculated for MASTER_CLOCK = 100000000 according to the DM9000 timings.
103 */
104static struct sam9_smc_config __initdata dm9000_smc_config = {
105 .ncs_read_setup = 0,
106 .nrd_setup = 2,
107 .ncs_write_setup = 0,
108 .nwe_setup = 2,
109
110 .ncs_read_pulse = 8,
111 .nrd_pulse = 4,
112 .ncs_write_pulse = 8,
113 .nwe_pulse = 4,
114
115 .read_cycle = 16,
116 .write_cycle = 16,
117
118 .mode = AT91_SMC_READMODE | AT91_SMC_WRITEMODE | AT91_SMC_EXNWMODE_DISABLE | AT91_SMC_BAT_WRITE | AT91_SMC_DBW_16,
119 .tdf_cycles = 1,
120};
121
Andrew Victor022cbd72006-12-01 14:38:59 +0100122static void __init ek_add_device_dm9000(void)
123{
Andrew Victor8cdae512008-10-06 20:05:35 +0100124 /* Configure chip-select 2 (DM9000) */
Jean-Christophe PLAGNIOL-VILLARDfaee0cc2011-10-14 01:37:09 +0800125 sam9_smc_configure(0, 2, &dm9000_smc_config);
Andrew Victor022cbd72006-12-01 14:38:59 +0100126
127 /* Configure Reset signal as output */
128 at91_set_gpio_output(AT91_PIN_PC10, 0);
129
130 /* Configure Interrupt pin as input, no pull-up */
131 at91_set_gpio_input(AT91_PIN_PC11, 0);
132
Andrew Victor8cdae512008-10-06 20:05:35 +0100133 platform_device_register(&dm9000_device);
Andrew Victor022cbd72006-12-01 14:38:59 +0100134}
135#else
136static void __init ek_add_device_dm9000(void) {}
137#endif /* CONFIG_DM9000 */
138
139
140/*
141 * USB Host Port
142 */
143static struct at91_usbh_data __initdata ek_usbh_data = {
144 .ports = 2,
Jean-Christophe PLAGNIOL-VILLARD63b4c292011-11-25 01:51:06 +0800145 .vbus_pin = {-EINVAL, -EINVAL},
146 .overcurrent_pin= {-EINVAL, -EINVAL},
Andrew Victor022cbd72006-12-01 14:38:59 +0100147};
148
149
150/*
151 * USB Device Port
152 */
153static struct at91_udc_data __initdata ek_udc_data = {
154 .vbus_pin = AT91_PIN_PB29,
Jean-Christophe PLAGNIOL-VILLARD63b4c292011-11-25 01:51:06 +0800155 .pullup_pin = -EINVAL, /* pull-up driven by UDC */
Andrew Victor022cbd72006-12-01 14:38:59 +0100156};
157
158
159/*
Andrew Victor022cbd72006-12-01 14:38:59 +0100160 * NAND flash
161 */
162static struct mtd_partition __initdata ek_nand_partition[] = {
163 {
164 .name = "Partition 1",
165 .offset = 0,
Andrew Victore5052402008-09-21 21:30:02 +0100166 .size = SZ_256K,
Andrew Victor022cbd72006-12-01 14:38:59 +0100167 },
168 {
169 .name = "Partition 2",
Andrew Victore5052402008-09-21 21:30:02 +0100170 .offset = MTDPART_OFS_NXTBLK,
Andrew Victor022cbd72006-12-01 14:38:59 +0100171 .size = MTDPART_SIZ_FULL,
172 },
173};
174
HÃ¥vard Skinnemoen3c3796c2008-06-06 18:04:53 +0200175static struct atmel_nand_data __initdata ek_nand_data = {
Andrew Victor022cbd72006-12-01 14:38:59 +0100176 .ale = 22,
177 .cle = 21,
Jean-Christophe PLAGNIOL-VILLARD63b4c292011-11-25 01:51:06 +0800178 .det_pin = -EINVAL,
Andrew Victor022cbd72006-12-01 14:38:59 +0100179 .rdy_pin = AT91_PIN_PC15,
180 .enable_pin = AT91_PIN_PC14,
Jean-Christophe PLAGNIOL-VILLARDbf4289c2011-12-29 14:43:24 +0800181 .ecc_mode = NAND_ECC_SOFT,
Jean-Christophe PLAGNIOL-VILLARD98619dc2011-12-29 15:05:50 +0800182 .on_flash_bbt = 1,
Dmitry Eremin-Solenikov1754aab2011-05-29 17:49:22 +0400183 .parts = ek_nand_partition,
184 .num_parts = ARRAY_SIZE(ek_nand_partition),
Andrew Victor022cbd72006-12-01 14:38:59 +0100185};
186
Andrew Victor8cdae512008-10-06 20:05:35 +0100187static struct sam9_smc_config __initdata ek_nand_smc_config = {
188 .ncs_read_setup = 0,
189 .nrd_setup = 1,
190 .ncs_write_setup = 0,
191 .nwe_setup = 1,
192
193 .ncs_read_pulse = 3,
194 .nrd_pulse = 3,
195 .ncs_write_pulse = 3,
196 .nwe_pulse = 3,
197
198 .read_cycle = 5,
199 .write_cycle = 5,
200
201 .mode = AT91_SMC_READMODE | AT91_SMC_WRITEMODE | AT91_SMC_EXNWMODE_DISABLE,
202 .tdf_cycles = 2,
203};
204
205static void __init ek_add_device_nand(void)
206{
Nicolas Ferre64393b32011-07-01 12:25:24 +0200207 ek_nand_data.bus_width_16 = board_have_nand_16bit();
Andrew Victor8cdae512008-10-06 20:05:35 +0100208 /* setup bus-width (8 or 16) */
209 if (ek_nand_data.bus_width_16)
210 ek_nand_smc_config.mode |= AT91_SMC_DBW_16;
211 else
212 ek_nand_smc_config.mode |= AT91_SMC_DBW_8;
213
214 /* configure chip-select 3 (NAND) */
Jean-Christophe PLAGNIOL-VILLARDfaee0cc2011-10-14 01:37:09 +0800215 sam9_smc_configure(0, 3, &ek_nand_smc_config);
Andrew Victor8cdae512008-10-06 20:05:35 +0100216
217 at91_add_device_nand(&ek_nand_data);
218}
219
Nicolas Ferre64d72bb2010-09-10 11:26:42 +0200220/*
221 * SPI related devices
222 */
223#if defined(CONFIG_SPI_ATMEL) || defined(CONFIG_SPI_ATMEL_MODULE)
Andrew Victor8cdae512008-10-06 20:05:35 +0100224
Andrew Victor022cbd72006-12-01 14:38:59 +0100225/*
Andrew Victor23522722007-05-02 17:58:51 +0100226 * ADS7846 Touchscreen
227 */
228#if defined(CONFIG_TOUCHSCREEN_ADS7846) || defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE)
229
230static int ads7843_pendown_state(void)
231{
232 return !at91_get_gpio_value(AT91_PIN_PC2); /* Touchscreen PENIRQ */
233}
234
235static struct ads7846_platform_data ads_info = {
236 .model = 7843,
237 .x_min = 150,
238 .x_max = 3830,
239 .y_min = 190,
240 .y_max = 3830,
241 .vref_delay_usecs = 100,
242 .x_plate_ohms = 450,
243 .y_plate_ohms = 250,
244 .pressure_max = 15000,
245 .debounce_max = 1,
246 .debounce_rep = 0,
247 .debounce_tol = (~0),
248 .get_pendown_state = ads7843_pendown_state,
249};
250
251static void __init ek_add_device_ts(void)
252{
253 at91_set_B_periph(AT91_PIN_PC2, 1); /* External IRQ0, with pullup */
254 at91_set_gpio_input(AT91_PIN_PA11, 1); /* Touchscreen BUSY signal */
255}
256#else
257static void __init ek_add_device_ts(void) {}
258#endif
259
260/*
Andrew Victor5e9df922008-04-02 22:18:35 +0100261 * Audio
262 */
263static struct at73c213_board_info at73c213_data = {
264 .ssc_id = 1,
Nicolas Ferreb319ff82009-06-26 15:37:01 +0100265#if defined(CONFIG_MACH_AT91SAM9261EK)
Andrew Victor5e9df922008-04-02 22:18:35 +0100266 .shortname = "AT91SAM9261-EK external DAC",
Nicolas Ferreb319ff82009-06-26 15:37:01 +0100267#else
268 .shortname = "AT91SAM9G10-EK external DAC",
269#endif
Andrew Victor5e9df922008-04-02 22:18:35 +0100270};
271
272#if defined(CONFIG_SND_AT73C213) || defined(CONFIG_SND_AT73C213_MODULE)
273static void __init at73c213_set_clk(struct at73c213_board_info *info)
274{
275 struct clk *pck2;
276 struct clk *plla;
277
278 pck2 = clk_get(NULL, "pck2");
279 plla = clk_get(NULL, "plla");
280
281 /* AT73C213 MCK Clock */
282 at91_set_B_periph(AT91_PIN_PB31, 0); /* PCK2 */
283
284 clk_set_parent(pck2, plla);
285 clk_put(plla);
286
287 info->dac_clk = pck2;
288}
289#else
290static void __init at73c213_set_clk(struct at73c213_board_info *info) {}
291#endif
292
293/*
Andrew Victor022cbd72006-12-01 14:38:59 +0100294 * SPI devices
295 */
296static struct spi_board_info ek_spi_devices[] = {
297 { /* DataFlash chip */
298 .modalias = "mtd_dataflash",
299 .chip_select = 0,
300 .max_speed_hz = 15 * 1000 * 1000,
301 .bus_num = 0,
302 },
Andrew Victor23522722007-05-02 17:58:51 +0100303#if defined(CONFIG_TOUCHSCREEN_ADS7846) || defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE)
304 {
305 .modalias = "ads7846",
306 .chip_select = 2,
307 .max_speed_hz = 125000 * 26, /* (max sample rate @ 3V) * (cmd + data + overhead) */
308 .bus_num = 0,
309 .platform_data = &ads_info,
310 .irq = AT91SAM9261_ID_IRQ0,
Andrew Victor5e9df922008-04-02 22:18:35 +0100311 .controller_data = (void *) AT91_PIN_PA28, /* CS pin */
Andrew Victor23522722007-05-02 17:58:51 +0100312 },
313#endif
Andrew Victor022cbd72006-12-01 14:38:59 +0100314#if defined(CONFIG_MTD_AT91_DATAFLASH_CARD)
315 { /* DataFlash card - jumper (J12) configurable to CS3 or CS0 */
316 .modalias = "mtd_dataflash",
317 .chip_select = 3,
318 .max_speed_hz = 15 * 1000 * 1000,
319 .bus_num = 0,
320 },
Andrew Victor23522722007-05-02 17:58:51 +0100321#elif defined(CONFIG_SND_AT73C213) || defined(CONFIG_SND_AT73C213_MODULE)
Andrew Victor022cbd72006-12-01 14:38:59 +0100322 { /* AT73C213 DAC */
Andrew Victor23522722007-05-02 17:58:51 +0100323 .modalias = "at73c213",
Andrew Victor022cbd72006-12-01 14:38:59 +0100324 .chip_select = 3,
325 .max_speed_hz = 10 * 1000 * 1000,
326 .bus_num = 0,
Andrew Victor5e9df922008-04-02 22:18:35 +0100327 .mode = SPI_MODE_1,
328 .platform_data = &at73c213_data,
329 .controller_data = (void*) AT91_PIN_PA29, /* default for CS3 is PA6, but it must be PA29 */
Andrew Victor022cbd72006-12-01 14:38:59 +0100330 },
331#endif
332};
333
Nicolas Ferre64d72bb2010-09-10 11:26:42 +0200334#else /* CONFIG_SPI_ATMEL_* */
Nicolas Ferre4deb22a2010-09-10 14:36:06 +0200335/* spi0 and mmc/sd share the same PIO pins: cannot be used at the same time */
Nicolas Ferre64d72bb2010-09-10 11:26:42 +0200336
337/*
338 * MCI (SD/MMC)
Nicolas Ferre4deb22a2010-09-10 14:36:06 +0200339 * det_pin, wp_pin and vcc_pin are not connected
Nicolas Ferre64d72bb2010-09-10 11:26:42 +0200340 */
341static struct at91_mmc_data __initdata ek_mmc_data = {
342 .wire4 = 1,
Jean-Christophe PLAGNIOL-VILLARD63b4c292011-11-25 01:51:06 +0800343 .det_pin = -EINVAL,
344 .wp_pin = -EINVAL,
345 .vcc_pin = -EINVAL,
Nicolas Ferre64d72bb2010-09-10 11:26:42 +0200346};
347
348#endif /* CONFIG_SPI_ATMEL_* */
349
Andrew Victor022cbd72006-12-01 14:38:59 +0100350
Andrew Victorcdf95c72007-05-14 15:08:21 +0100351/*
352 * LCD Controller
353 */
354#if defined(CONFIG_FB_ATMEL) || defined(CONFIG_FB_ATMEL_MODULE)
Andrew Victor51708742007-11-20 09:40:12 +0100355
356#if defined(CONFIG_FB_ATMEL_STN)
357
358/* STN */
359static struct fb_videomode at91_stn_modes[] = {
360 {
361 .name = "SP06Q002 @ 75",
362 .refresh = 75,
363 .xres = 320, .yres = 240,
364 .pixclock = KHZ2PICOS(1440),
365
366 .left_margin = 1, .right_margin = 1,
367 .upper_margin = 0, .lower_margin = 0,
368 .hsync_len = 1, .vsync_len = 1,
369
370 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
371 .vmode = FB_VMODE_NONINTERLACED,
372 },
373};
374
375static struct fb_monspecs at91fb_default_stn_monspecs = {
376 .manufacturer = "HIT",
377 .monitor = "SP06Q002",
378
379 .modedb = at91_stn_modes,
380 .modedb_len = ARRAY_SIZE(at91_stn_modes),
381 .hfmin = 15000,
382 .hfmax = 64000,
383 .vfmin = 50,
384 .vfmax = 150,
385};
386
387#define AT91SAM9261_DEFAULT_STN_LCDCON2 (ATMEL_LCDC_MEMOR_LITTLE \
388 | ATMEL_LCDC_DISTYPE_STNMONO \
389 | ATMEL_LCDC_CLKMOD_ALWAYSACTIVE \
390 | ATMEL_LCDC_IFWIDTH_4 \
391 | ATMEL_LCDC_SCANMOD_SINGLE)
392
393static void at91_lcdc_stn_power_control(int on)
394{
395 /* backlight */
396 if (on) { /* power up */
397 at91_set_gpio_value(AT91_PIN_PC14, 0);
398 at91_set_gpio_value(AT91_PIN_PC15, 0);
399 } else { /* power down */
400 at91_set_gpio_value(AT91_PIN_PC14, 1);
401 at91_set_gpio_value(AT91_PIN_PC15, 1);
402 }
403}
404
405static struct atmel_lcdfb_info __initdata ek_lcdc_data = {
406 .default_bpp = 1,
407 .default_dmacon = ATMEL_LCDC_DMAEN,
408 .default_lcdcon2 = AT91SAM9261_DEFAULT_STN_LCDCON2,
409 .default_monspecs = &at91fb_default_stn_monspecs,
410 .atmel_lcdfb_power_control = at91_lcdc_stn_power_control,
411 .guard_time = 1,
Nicolas Ferreb319ff82009-06-26 15:37:01 +0100412#if defined(CONFIG_MACH_AT91SAM9G10EK)
413 .lcd_wiring_mode = ATMEL_LCDC_WIRING_RGB,
414#endif
Andrew Victor51708742007-11-20 09:40:12 +0100415};
416
417#else
418
419/* TFT */
Andrew Victorcdf95c72007-05-14 15:08:21 +0100420static struct fb_videomode at91_tft_vga_modes[] = {
421 {
422 .name = "TX09D50VM1CCA @ 60",
423 .refresh = 60,
424 .xres = 240, .yres = 320,
425 .pixclock = KHZ2PICOS(4965),
426
427 .left_margin = 1, .right_margin = 33,
428 .upper_margin = 1, .lower_margin = 0,
429 .hsync_len = 5, .vsync_len = 1,
430
431 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
432 .vmode = FB_VMODE_NONINTERLACED,
433 },
434};
435
Andrew Victor51708742007-11-20 09:40:12 +0100436static struct fb_monspecs at91fb_default_tft_monspecs = {
Andrew Victorcdf95c72007-05-14 15:08:21 +0100437 .manufacturer = "HIT",
438 .monitor = "TX09D50VM1CCA",
439
440 .modedb = at91_tft_vga_modes,
441 .modedb_len = ARRAY_SIZE(at91_tft_vga_modes),
442 .hfmin = 15000,
443 .hfmax = 64000,
444 .vfmin = 50,
445 .vfmax = 150,
446};
447
Andrew Victor51708742007-11-20 09:40:12 +0100448#define AT91SAM9261_DEFAULT_TFT_LCDCON2 (ATMEL_LCDC_MEMOR_LITTLE \
Andrew Victorcdf95c72007-05-14 15:08:21 +0100449 | ATMEL_LCDC_DISTYPE_TFT \
450 | ATMEL_LCDC_CLKMOD_ALWAYSACTIVE)
451
Andrew Victor51708742007-11-20 09:40:12 +0100452static void at91_lcdc_tft_power_control(int on)
Andrew Victorcdf95c72007-05-14 15:08:21 +0100453{
454 if (on)
455 at91_set_gpio_value(AT91_PIN_PA12, 0); /* power up */
456 else
457 at91_set_gpio_value(AT91_PIN_PA12, 1); /* power down */
458}
459
Andrew Victorcdf95c72007-05-14 15:08:21 +0100460static struct atmel_lcdfb_info __initdata ek_lcdc_data = {
David Brownella9a84c32008-02-06 01:39:26 -0800461 .lcdcon_is_backlight = true,
Andrew Victorcdf95c72007-05-14 15:08:21 +0100462 .default_bpp = 16,
463 .default_dmacon = ATMEL_LCDC_DMAEN,
Andrew Victor51708742007-11-20 09:40:12 +0100464 .default_lcdcon2 = AT91SAM9261_DEFAULT_TFT_LCDCON2,
465 .default_monspecs = &at91fb_default_tft_monspecs,
466 .atmel_lcdfb_power_control = at91_lcdc_tft_power_control,
Andrew Victorcdf95c72007-05-14 15:08:21 +0100467 .guard_time = 1,
Nicolas Ferreb319ff82009-06-26 15:37:01 +0100468#if defined(CONFIG_MACH_AT91SAM9G10EK)
469 .lcd_wiring_mode = ATMEL_LCDC_WIRING_RGB,
470#endif
Andrew Victorcdf95c72007-05-14 15:08:21 +0100471};
Andrew Victor51708742007-11-20 09:40:12 +0100472#endif
Andrew Victorcdf95c72007-05-14 15:08:21 +0100473
474#else
475static struct atmel_lcdfb_info __initdata ek_lcdc_data;
476#endif
477
478
Andrew Victord0f9b552007-06-04 08:41:59 +0100479/*
480 * GPIO Buttons
481 */
482#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
483static struct gpio_keys_button ek_buttons[] = {
484 {
485 .gpio = AT91_PIN_PA27,
David Brownelleaf858a2008-01-14 08:53:22 +0100486 .code = BTN_0,
Andrew Victord0f9b552007-06-04 08:41:59 +0100487 .desc = "Button 0",
488 .active_low = 1,
Andrew Victor77789ad2008-09-21 21:34:06 +0100489 .wakeup = 1,
Andrew Victord0f9b552007-06-04 08:41:59 +0100490 },
491 {
492 .gpio = AT91_PIN_PA26,
David Brownelleaf858a2008-01-14 08:53:22 +0100493 .code = BTN_1,
Andrew Victord0f9b552007-06-04 08:41:59 +0100494 .desc = "Button 1",
495 .active_low = 1,
Andrew Victor77789ad2008-09-21 21:34:06 +0100496 .wakeup = 1,
Andrew Victord0f9b552007-06-04 08:41:59 +0100497 },
498 {
499 .gpio = AT91_PIN_PA25,
David Brownelleaf858a2008-01-14 08:53:22 +0100500 .code = BTN_2,
Andrew Victord0f9b552007-06-04 08:41:59 +0100501 .desc = "Button 2",
502 .active_low = 1,
Andrew Victor77789ad2008-09-21 21:34:06 +0100503 .wakeup = 1,
Andrew Victord0f9b552007-06-04 08:41:59 +0100504 },
505 {
506 .gpio = AT91_PIN_PA24,
David Brownelleaf858a2008-01-14 08:53:22 +0100507 .code = BTN_3,
Andrew Victord0f9b552007-06-04 08:41:59 +0100508 .desc = "Button 3",
509 .active_low = 1,
Andrew Victor77789ad2008-09-21 21:34:06 +0100510 .wakeup = 1,
Andrew Victord0f9b552007-06-04 08:41:59 +0100511 }
512};
513
514static struct gpio_keys_platform_data ek_button_data = {
515 .buttons = ek_buttons,
516 .nbuttons = ARRAY_SIZE(ek_buttons),
517};
518
519static struct platform_device ek_button_device = {
520 .name = "gpio-keys",
521 .id = -1,
522 .num_resources = 0,
523 .dev = {
524 .platform_data = &ek_button_data,
525 }
526};
527
528static void __init ek_add_device_buttons(void)
529{
Andrew Victor77789ad2008-09-21 21:34:06 +0100530 at91_set_gpio_input(AT91_PIN_PA27, 1); /* btn0 */
Andrew Victor302edfd2007-11-20 09:12:41 +0100531 at91_set_deglitch(AT91_PIN_PA27, 1);
Andrew Victor77789ad2008-09-21 21:34:06 +0100532 at91_set_gpio_input(AT91_PIN_PA26, 1); /* btn1 */
Andrew Victor302edfd2007-11-20 09:12:41 +0100533 at91_set_deglitch(AT91_PIN_PA26, 1);
Andrew Victor77789ad2008-09-21 21:34:06 +0100534 at91_set_gpio_input(AT91_PIN_PA25, 1); /* btn2 */
Andrew Victor302edfd2007-11-20 09:12:41 +0100535 at91_set_deglitch(AT91_PIN_PA25, 1);
Andrew Victor77789ad2008-09-21 21:34:06 +0100536 at91_set_gpio_input(AT91_PIN_PA24, 1); /* btn3 */
Andrew Victor302edfd2007-11-20 09:12:41 +0100537 at91_set_deglitch(AT91_PIN_PA24, 1);
Andrew Victord0f9b552007-06-04 08:41:59 +0100538
539 platform_device_register(&ek_button_device);
540}
541#else
542static void __init ek_add_device_buttons(void) {}
543#endif
544
Andrew Victor5b7659d2008-04-02 22:20:45 +0100545/*
546 * LEDs
547 */
548static struct gpio_led ek_leds[] = {
549 { /* "bottom" led, green, userled1 to be defined */
550 .name = "ds7",
551 .gpio = AT91_PIN_PA14,
552 .active_low = 1,
553 .default_trigger = "none",
554 },
555 { /* "top" led, green, userled2 to be defined */
556 .name = "ds8",
557 .gpio = AT91_PIN_PA13,
558 .active_low = 1,
559 .default_trigger = "none",
560 },
561 { /* "power" led, yellow */
562 .name = "ds1",
563 .gpio = AT91_PIN_PA23,
564 .default_trigger = "heartbeat",
565 }
566};
567
Andrew Victor022cbd72006-12-01 14:38:59 +0100568static void __init ek_board_init(void)
569{
Jean-Christophe PLAGNIOL-VILLARD7eb1dbb2012-04-05 14:27:57 +0800570 /* Setup the LEDs */
571 at91_init_leds(AT91_PIN_PA13, AT91_PIN_PA14);
572
Andrew Victor022cbd72006-12-01 14:38:59 +0100573 /* Serial */
Jean-Christophe PLAGNIOL-VILLARD71b149b2012-04-05 14:14:28 +0800574 /* DBGU on ttyS0. (Rx & Tx only) */
575 at91_register_uart(0, 0, 0);
Andrew Victor022cbd72006-12-01 14:38:59 +0100576 at91_add_device_serial();
577 /* USB Host */
578 at91_add_device_usbh(&ek_usbh_data);
579 /* USB Device */
580 at91_add_device_udc(&ek_udc_data);
581 /* I2C */
Andrew Victorf230d3f2007-11-19 13:47:20 +0100582 at91_add_device_i2c(NULL, 0);
Andrew Victor022cbd72006-12-01 14:38:59 +0100583 /* NAND */
Andrew Victor8cdae512008-10-06 20:05:35 +0100584 ek_add_device_nand();
Andrew Victor022cbd72006-12-01 14:38:59 +0100585 /* DM9000 ethernet */
586 ek_add_device_dm9000();
587
588 /* spi0 and mmc/sd share the same PIO pins */
589#if defined(CONFIG_SPI_ATMEL) || defined(CONFIG_SPI_ATMEL_MODULE)
590 /* SPI */
591 at91_add_device_spi(ek_spi_devices, ARRAY_SIZE(ek_spi_devices));
Andrew Victor23522722007-05-02 17:58:51 +0100592 /* Touchscreen */
593 ek_add_device_ts();
Andrew Victor5e9df922008-04-02 22:18:35 +0100594 /* SSC (to AT73C213) */
595 at73c213_set_clk(&at73c213_data);
596 at91_add_device_ssc(AT91SAM9261_ID_SSC1, ATMEL_SSC_TX);
Andrew Victor022cbd72006-12-01 14:38:59 +0100597#else
598 /* MMC */
Andrew Victord0760b32007-02-08 09:00:39 +0100599 at91_add_device_mmc(0, &ek_mmc_data);
Andrew Victor022cbd72006-12-01 14:38:59 +0100600#endif
Andrew Victorcdf95c72007-05-14 15:08:21 +0100601 /* LCD Controller */
602 at91_add_device_lcdc(&ek_lcdc_data);
Andrew Victord0f9b552007-06-04 08:41:59 +0100603 /* Push Buttons */
604 ek_add_device_buttons();
Andrew Victor5b7659d2008-04-02 22:20:45 +0100605 /* LEDs */
606 at91_gpio_leds(ek_leds, ARRAY_SIZE(ek_leds));
Andrew Victor022cbd72006-12-01 14:38:59 +0100607}
608
Nicolas Ferreb319ff82009-06-26 15:37:01 +0100609#if defined(CONFIG_MACH_AT91SAM9261EK)
Andrew Victor022cbd72006-12-01 14:38:59 +0100610MACHINE_START(AT91SAM9261EK, "Atmel AT91SAM9261-EK")
Nicolas Ferreb319ff82009-06-26 15:37:01 +0100611#else
612MACHINE_START(AT91SAM9G10EK, "Atmel AT91SAM9G10-EK")
613#endif
Andrew Victor022cbd72006-12-01 14:38:59 +0100614 /* Maintainer: Atmel */
Andrew Victor022cbd72006-12-01 14:38:59 +0100615 .timer = &at91sam926x_timer,
Jean-Christophe PLAGNIOL-VILLARD21d08b92011-04-23 15:28:34 +0800616 .map_io = at91_map_io,
Jean-Christophe PLAGNIOL-VILLARD1b021a32011-04-28 20:19:32 +0800617 .init_early = ek_init_early,
Jean-Christophe PLAGNIOL-VILLARD92100c12011-04-23 15:28:34 +0800618 .init_irq = at91_init_irq_default,
Andrew Victor022cbd72006-12-01 14:38:59 +0100619 .init_machine = ek_board_init,
620MACHINE_END