blob: 4637432de08f32486e0345b71bc15af121e69d95 [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 Victor235227282007-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/at91sam9_smc.h>
Jean-Christophe PLAGNIOL-VILLARD76b2ab72011-04-14 00:34:03 +080049#include <mach/system_rev.h>
Andrew Victor022cbd72006-12-01 14:38:59 +010050
Jean-Christophe PLAGNIOL-VILLARDa510b9b2012-10-30 06:41:28 +080051#include "at91_aic.h"
Jean-Christophe PLAGNIOL-VILLARD176bdd22012-10-30 08:07:11 +080052#include "at91_shdwc.h"
Jean-Christophe PLAGNIOL-VILLARD43d2f532012-10-30 05:14:17 +080053#include "board.h"
Andrew Victor8cdae512008-10-06 20:05:35 +010054#include "sam9_smc.h"
Andrew Victor022cbd72006-12-01 14:38:59 +010055#include "generic.h"
Linus Walleijcf2e9332014-03-27 14:18:51 +010056#include "gpio.h"
Andrew Victor022cbd72006-12-01 14:38:59 +010057
58
Jean-Christophe PLAGNIOL-VILLARD1b021a32011-04-28 20:19:32 +080059static void __init ek_init_early(void)
Andrew Victor022cbd72006-12-01 14:38:59 +010060{
61 /* Initialize processor: 18.432 MHz crystal */
Jean-Christophe PLAGNIOL-VILLARD21d08b92011-04-23 15:28:34 +080062 at91_initialize(18432000);
Andrew Victor022cbd72006-12-01 14:38:59 +010063}
64
Andrew Victor022cbd72006-12-01 14:38:59 +010065/*
66 * DM9000 ethernet device
67 */
68#if defined(CONFIG_DM9000)
Andrew Victor8cdae512008-10-06 20:05:35 +010069static struct resource dm9000_resource[] = {
Andrew Victor022cbd72006-12-01 14:38:59 +010070 [0] = {
71 .start = AT91_CHIPSELECT_2,
72 .end = AT91_CHIPSELECT_2 + 3,
73 .flags = IORESOURCE_MEM
74 },
75 [1] = {
76 .start = AT91_CHIPSELECT_2 + 0x44,
77 .end = AT91_CHIPSELECT_2 + 0xFF,
78 .flags = IORESOURCE_MEM
79 },
80 [2] = {
Andrew Victor022cbd72006-12-01 14:38:59 +010081 .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{
Jean-Christophe PLAGNIOL-VILLARDee9dd762012-04-10 17:32:44 +0200124 struct resource *r = &dm9000_resource[2];
125
Andrew Victor8cdae512008-10-06 20:05:35 +0100126 /* Configure chip-select 2 (DM9000) */
Jean-Christophe PLAGNIOL-VILLARDfaee0cc2011-10-14 01:37:09 +0800127 sam9_smc_configure(0, 2, &dm9000_smc_config);
Andrew Victor022cbd72006-12-01 14:38:59 +0100128
129 /* Configure Reset signal as output */
130 at91_set_gpio_output(AT91_PIN_PC10, 0);
131
132 /* Configure Interrupt pin as input, no pull-up */
133 at91_set_gpio_input(AT91_PIN_PC11, 0);
134
Jean-Christophe PLAGNIOL-VILLARDee9dd762012-04-10 17:32:44 +0200135 r->start = r->end = gpio_to_irq(AT91_PIN_PC11);
Andrew Victor8cdae512008-10-06 20:05:35 +0100136 platform_device_register(&dm9000_device);
Andrew Victor022cbd72006-12-01 14:38:59 +0100137}
138#else
139static void __init ek_add_device_dm9000(void) {}
140#endif /* CONFIG_DM9000 */
141
142
143/*
144 * USB Host Port
145 */
146static struct at91_usbh_data __initdata ek_usbh_data = {
147 .ports = 2,
Jean-Christophe PLAGNIOL-VILLARD63b4c292011-11-25 01:51:06 +0800148 .vbus_pin = {-EINVAL, -EINVAL},
149 .overcurrent_pin= {-EINVAL, -EINVAL},
Andrew Victor022cbd72006-12-01 14:38:59 +0100150};
151
152
153/*
154 * USB Device Port
155 */
156static struct at91_udc_data __initdata ek_udc_data = {
157 .vbus_pin = AT91_PIN_PB29,
Jean-Christophe PLAGNIOL-VILLARD63b4c292011-11-25 01:51:06 +0800158 .pullup_pin = -EINVAL, /* pull-up driven by UDC */
Andrew Victor022cbd72006-12-01 14:38:59 +0100159};
160
161
162/*
Andrew Victor022cbd72006-12-01 14:38:59 +0100163 * NAND flash
164 */
165static struct mtd_partition __initdata ek_nand_partition[] = {
166 {
167 .name = "Partition 1",
168 .offset = 0,
Andrew Victore5052402008-09-21 21:30:02 +0100169 .size = SZ_256K,
Andrew Victor022cbd72006-12-01 14:38:59 +0100170 },
171 {
172 .name = "Partition 2",
Andrew Victore5052402008-09-21 21:30:02 +0100173 .offset = MTDPART_OFS_NXTBLK,
Andrew Victor022cbd72006-12-01 14:38:59 +0100174 .size = MTDPART_SIZ_FULL,
175 },
176};
177
HÃ¥vard Skinnemoen3c3796c2008-06-06 18:04:53 +0200178static struct atmel_nand_data __initdata ek_nand_data = {
Andrew Victor022cbd72006-12-01 14:38:59 +0100179 .ale = 22,
180 .cle = 21,
Jean-Christophe PLAGNIOL-VILLARD63b4c292011-11-25 01:51:06 +0800181 .det_pin = -EINVAL,
Andrew Victor022cbd72006-12-01 14:38:59 +0100182 .rdy_pin = AT91_PIN_PC15,
183 .enable_pin = AT91_PIN_PC14,
Jean-Christophe PLAGNIOL-VILLARDbf4289c2011-12-29 14:43:24 +0800184 .ecc_mode = NAND_ECC_SOFT,
Jean-Christophe PLAGNIOL-VILLARD98619dc2011-12-29 15:05:50 +0800185 .on_flash_bbt = 1,
Dmitry Eremin-Solenikov1754aab2011-05-29 17:49:22 +0400186 .parts = ek_nand_partition,
187 .num_parts = ARRAY_SIZE(ek_nand_partition),
Andrew Victor022cbd72006-12-01 14:38:59 +0100188};
189
Andrew Victor8cdae512008-10-06 20:05:35 +0100190static struct sam9_smc_config __initdata ek_nand_smc_config = {
191 .ncs_read_setup = 0,
192 .nrd_setup = 1,
193 .ncs_write_setup = 0,
194 .nwe_setup = 1,
195
196 .ncs_read_pulse = 3,
197 .nrd_pulse = 3,
198 .ncs_write_pulse = 3,
199 .nwe_pulse = 3,
200
201 .read_cycle = 5,
202 .write_cycle = 5,
203
204 .mode = AT91_SMC_READMODE | AT91_SMC_WRITEMODE | AT91_SMC_EXNWMODE_DISABLE,
205 .tdf_cycles = 2,
206};
207
208static void __init ek_add_device_nand(void)
209{
Nicolas Ferre64393b32011-07-01 12:25:24 +0200210 ek_nand_data.bus_width_16 = board_have_nand_16bit();
Andrew Victor8cdae512008-10-06 20:05:35 +0100211 /* setup bus-width (8 or 16) */
212 if (ek_nand_data.bus_width_16)
213 ek_nand_smc_config.mode |= AT91_SMC_DBW_16;
214 else
215 ek_nand_smc_config.mode |= AT91_SMC_DBW_8;
216
217 /* configure chip-select 3 (NAND) */
Jean-Christophe PLAGNIOL-VILLARDfaee0cc2011-10-14 01:37:09 +0800218 sam9_smc_configure(0, 3, &ek_nand_smc_config);
Andrew Victor8cdae512008-10-06 20:05:35 +0100219
220 at91_add_device_nand(&ek_nand_data);
221}
222
Nicolas Ferre64d72bb2010-09-10 11:26:42 +0200223/*
224 * SPI related devices
225 */
226#if defined(CONFIG_SPI_ATMEL) || defined(CONFIG_SPI_ATMEL_MODULE)
Andrew Victor8cdae512008-10-06 20:05:35 +0100227
Andrew Victor022cbd72006-12-01 14:38:59 +0100228/*
Andrew Victor235227282007-05-02 17:58:51 +0100229 * ADS7846 Touchscreen
230 */
231#if defined(CONFIG_TOUCHSCREEN_ADS7846) || defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE)
232
233static int ads7843_pendown_state(void)
234{
235 return !at91_get_gpio_value(AT91_PIN_PC2); /* Touchscreen PENIRQ */
236}
237
238static struct ads7846_platform_data ads_info = {
239 .model = 7843,
240 .x_min = 150,
241 .x_max = 3830,
242 .y_min = 190,
243 .y_max = 3830,
244 .vref_delay_usecs = 100,
245 .x_plate_ohms = 450,
246 .y_plate_ohms = 250,
247 .pressure_max = 15000,
248 .debounce_max = 1,
249 .debounce_rep = 0,
250 .debounce_tol = (~0),
251 .get_pendown_state = ads7843_pendown_state,
252};
253
254static void __init ek_add_device_ts(void)
255{
256 at91_set_B_periph(AT91_PIN_PC2, 1); /* External IRQ0, with pullup */
257 at91_set_gpio_input(AT91_PIN_PA11, 1); /* Touchscreen BUSY signal */
258}
259#else
260static void __init ek_add_device_ts(void) {}
261#endif
262
263/*
Andrew Victor5e9df922008-04-02 22:18:35 +0100264 * Audio
265 */
266static struct at73c213_board_info at73c213_data = {
267 .ssc_id = 1,
Jean-Christophe PLAGNIOL-VILLARDb3f442b2013-05-15 17:19:21 +0200268 .shortname = "AT91SAM9261/9G10-EK external DAC",
Andrew Victor5e9df922008-04-02 22:18:35 +0100269};
270
271#if defined(CONFIG_SND_AT73C213) || defined(CONFIG_SND_AT73C213_MODULE)
272static void __init at73c213_set_clk(struct at73c213_board_info *info)
273{
274 struct clk *pck2;
275 struct clk *plla;
276
277 pck2 = clk_get(NULL, "pck2");
278 plla = clk_get(NULL, "plla");
279
280 /* AT73C213 MCK Clock */
281 at91_set_B_periph(AT91_PIN_PB31, 0); /* PCK2 */
282
283 clk_set_parent(pck2, plla);
284 clk_put(plla);
285
286 info->dac_clk = pck2;
287}
288#else
289static void __init at73c213_set_clk(struct at73c213_board_info *info) {}
290#endif
291
292/*
Andrew Victor022cbd72006-12-01 14:38:59 +0100293 * SPI devices
294 */
295static struct spi_board_info ek_spi_devices[] = {
296 { /* DataFlash chip */
297 .modalias = "mtd_dataflash",
298 .chip_select = 0,
299 .max_speed_hz = 15 * 1000 * 1000,
300 .bus_num = 0,
301 },
Andrew Victor235227282007-05-02 17:58:51 +0100302#if defined(CONFIG_TOUCHSCREEN_ADS7846) || defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE)
303 {
304 .modalias = "ads7846",
305 .chip_select = 2,
306 .max_speed_hz = 125000 * 26, /* (max sample rate @ 3V) * (cmd + data + overhead) */
307 .bus_num = 0,
308 .platform_data = &ads_info,
Nicolas Ferre69e7ea02012-10-24 16:19:47 +0200309 .irq = NR_IRQS_LEGACY + AT91SAM9261_ID_IRQ0,
Andrew Victor5e9df922008-04-02 22:18:35 +0100310 .controller_data = (void *) AT91_PIN_PA28, /* CS pin */
Andrew Victor235227282007-05-02 17:58:51 +0100311 },
312#endif
Andrew Victor022cbd72006-12-01 14:38:59 +0100313#if defined(CONFIG_MTD_AT91_DATAFLASH_CARD)
314 { /* DataFlash card - jumper (J12) configurable to CS3 or CS0 */
315 .modalias = "mtd_dataflash",
316 .chip_select = 3,
317 .max_speed_hz = 15 * 1000 * 1000,
318 .bus_num = 0,
319 },
Andrew Victor235227282007-05-02 17:58:51 +0100320#elif defined(CONFIG_SND_AT73C213) || defined(CONFIG_SND_AT73C213_MODULE)
Andrew Victor022cbd72006-12-01 14:38:59 +0100321 { /* AT73C213 DAC */
Andrew Victor235227282007-05-02 17:58:51 +0100322 .modalias = "at73c213",
Andrew Victor022cbd72006-12-01 14:38:59 +0100323 .chip_select = 3,
324 .max_speed_hz = 10 * 1000 * 1000,
325 .bus_num = 0,
Andrew Victor5e9df922008-04-02 22:18:35 +0100326 .mode = SPI_MODE_1,
327 .platform_data = &at73c213_data,
328 .controller_data = (void*) AT91_PIN_PA29, /* default for CS3 is PA6, but it must be PA29 */
Andrew Victor022cbd72006-12-01 14:38:59 +0100329 },
330#endif
331};
332
Nicolas Ferre64d72bb2010-09-10 11:26:42 +0200333#else /* CONFIG_SPI_ATMEL_* */
Nicolas Ferre4deb22a2010-09-10 14:36:06 +0200334/* spi0 and mmc/sd share the same PIO pins: cannot be used at the same time */
Nicolas Ferre64d72bb2010-09-10 11:26:42 +0200335
336/*
337 * MCI (SD/MMC)
Nicolas Ferre4deb22a2010-09-10 14:36:06 +0200338 * det_pin, wp_pin and vcc_pin are not connected
Nicolas Ferre64d72bb2010-09-10 11:26:42 +0200339 */
Ludovic Desroches4cf33262012-05-21 12:23:27 +0200340static struct mci_platform_data __initdata mci0_data = {
341 .slot[0] = {
342 .bus_width = 4,
343 .detect_pin = -EINVAL,
344 .wp_pin = -EINVAL,
345 },
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
Jean-Christophe PLAGNIOL-VILLARDce3b64f2013-03-29 02:05:47 +0800393static void at91_lcdc_stn_power_control(struct atmel_lcdfb_pdata *pdata, int on)
Andrew Victor51708742007-11-20 09:40:12 +0100394{
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
Jean-Christophe PLAGNIOL-VILLARD8af2c282013-03-28 22:53:42 +0800405static struct atmel_lcdfb_pdata __initdata ek_lcdc_data = {
Andrew Victor51708742007-11-20 09:40:12 +0100406 .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,
412};
413
414#else
415
416/* TFT */
Andrew Victorcdf95c72007-05-14 15:08:21 +0100417static struct fb_videomode at91_tft_vga_modes[] = {
418 {
419 .name = "TX09D50VM1CCA @ 60",
420 .refresh = 60,
421 .xres = 240, .yres = 320,
422 .pixclock = KHZ2PICOS(4965),
423
424 .left_margin = 1, .right_margin = 33,
425 .upper_margin = 1, .lower_margin = 0,
426 .hsync_len = 5, .vsync_len = 1,
427
428 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
429 .vmode = FB_VMODE_NONINTERLACED,
430 },
431};
432
Andrew Victor51708742007-11-20 09:40:12 +0100433static struct fb_monspecs at91fb_default_tft_monspecs = {
Andrew Victorcdf95c72007-05-14 15:08:21 +0100434 .manufacturer = "HIT",
435 .monitor = "TX09D50VM1CCA",
436
437 .modedb = at91_tft_vga_modes,
438 .modedb_len = ARRAY_SIZE(at91_tft_vga_modes),
439 .hfmin = 15000,
440 .hfmax = 64000,
441 .vfmin = 50,
442 .vfmax = 150,
443};
444
Andrew Victor51708742007-11-20 09:40:12 +0100445#define AT91SAM9261_DEFAULT_TFT_LCDCON2 (ATMEL_LCDC_MEMOR_LITTLE \
Andrew Victorcdf95c72007-05-14 15:08:21 +0100446 | ATMEL_LCDC_DISTYPE_TFT \
447 | ATMEL_LCDC_CLKMOD_ALWAYSACTIVE)
448
Jean-Christophe PLAGNIOL-VILLARDce3b64f2013-03-29 02:05:47 +0800449static void at91_lcdc_tft_power_control(struct atmel_lcdfb_pdata *pdata, int on)
Andrew Victorcdf95c72007-05-14 15:08:21 +0100450{
451 if (on)
452 at91_set_gpio_value(AT91_PIN_PA12, 0); /* power up */
453 else
454 at91_set_gpio_value(AT91_PIN_PA12, 1); /* power down */
455}
456
Jean-Christophe PLAGNIOL-VILLARD8af2c282013-03-28 22:53:42 +0800457static struct atmel_lcdfb_pdata __initdata ek_lcdc_data = {
David Brownella9a84c32008-02-06 01:39:26 -0800458 .lcdcon_is_backlight = true,
Andrew Victorcdf95c72007-05-14 15:08:21 +0100459 .default_bpp = 16,
460 .default_dmacon = ATMEL_LCDC_DMAEN,
Andrew Victor51708742007-11-20 09:40:12 +0100461 .default_lcdcon2 = AT91SAM9261_DEFAULT_TFT_LCDCON2,
462 .default_monspecs = &at91fb_default_tft_monspecs,
463 .atmel_lcdfb_power_control = at91_lcdc_tft_power_control,
Andrew Victorcdf95c72007-05-14 15:08:21 +0100464 .guard_time = 1,
465};
Andrew Victor51708742007-11-20 09:40:12 +0100466#endif
Andrew Victorcdf95c72007-05-14 15:08:21 +0100467
468#else
Jean-Christophe PLAGNIOL-VILLARD8af2c282013-03-28 22:53:42 +0800469static struct atmel_lcdfb_pdata __initdata ek_lcdc_data;
Andrew Victorcdf95c72007-05-14 15:08:21 +0100470#endif
471
472
Andrew Victord0f9b552007-06-04 08:41:59 +0100473/*
474 * GPIO Buttons
475 */
476#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
477static struct gpio_keys_button ek_buttons[] = {
478 {
479 .gpio = AT91_PIN_PA27,
David Brownelleaf858a2008-01-14 08:53:22 +0100480 .code = BTN_0,
Andrew Victord0f9b552007-06-04 08:41:59 +0100481 .desc = "Button 0",
482 .active_low = 1,
Andrew Victor77789ad2008-09-21 21:34:06 +0100483 .wakeup = 1,
Andrew Victord0f9b552007-06-04 08:41:59 +0100484 },
485 {
486 .gpio = AT91_PIN_PA26,
David Brownelleaf858a2008-01-14 08:53:22 +0100487 .code = BTN_1,
Andrew Victord0f9b552007-06-04 08:41:59 +0100488 .desc = "Button 1",
489 .active_low = 1,
Andrew Victor77789ad2008-09-21 21:34:06 +0100490 .wakeup = 1,
Andrew Victord0f9b552007-06-04 08:41:59 +0100491 },
492 {
493 .gpio = AT91_PIN_PA25,
David Brownelleaf858a2008-01-14 08:53:22 +0100494 .code = BTN_2,
Andrew Victord0f9b552007-06-04 08:41:59 +0100495 .desc = "Button 2",
496 .active_low = 1,
Andrew Victor77789ad2008-09-21 21:34:06 +0100497 .wakeup = 1,
Andrew Victord0f9b552007-06-04 08:41:59 +0100498 },
499 {
500 .gpio = AT91_PIN_PA24,
David Brownelleaf858a2008-01-14 08:53:22 +0100501 .code = BTN_3,
Andrew Victord0f9b552007-06-04 08:41:59 +0100502 .desc = "Button 3",
503 .active_low = 1,
Andrew Victor77789ad2008-09-21 21:34:06 +0100504 .wakeup = 1,
Andrew Victord0f9b552007-06-04 08:41:59 +0100505 }
506};
507
508static struct gpio_keys_platform_data ek_button_data = {
509 .buttons = ek_buttons,
510 .nbuttons = ARRAY_SIZE(ek_buttons),
511};
512
513static struct platform_device ek_button_device = {
514 .name = "gpio-keys",
515 .id = -1,
516 .num_resources = 0,
517 .dev = {
518 .platform_data = &ek_button_data,
519 }
520};
521
522static void __init ek_add_device_buttons(void)
523{
Andrew Victor77789ad2008-09-21 21:34:06 +0100524 at91_set_gpio_input(AT91_PIN_PA27, 1); /* btn0 */
Andrew Victor302edfd2007-11-20 09:12:41 +0100525 at91_set_deglitch(AT91_PIN_PA27, 1);
Andrew Victor77789ad2008-09-21 21:34:06 +0100526 at91_set_gpio_input(AT91_PIN_PA26, 1); /* btn1 */
Andrew Victor302edfd2007-11-20 09:12:41 +0100527 at91_set_deglitch(AT91_PIN_PA26, 1);
Andrew Victor77789ad2008-09-21 21:34:06 +0100528 at91_set_gpio_input(AT91_PIN_PA25, 1); /* btn2 */
Andrew Victor302edfd2007-11-20 09:12:41 +0100529 at91_set_deglitch(AT91_PIN_PA25, 1);
Andrew Victor77789ad2008-09-21 21:34:06 +0100530 at91_set_gpio_input(AT91_PIN_PA24, 1); /* btn3 */
Andrew Victor302edfd2007-11-20 09:12:41 +0100531 at91_set_deglitch(AT91_PIN_PA24, 1);
Andrew Victord0f9b552007-06-04 08:41:59 +0100532
533 platform_device_register(&ek_button_device);
534}
535#else
536static void __init ek_add_device_buttons(void) {}
537#endif
538
Andrew Victor5b7659d2008-04-02 22:20:45 +0100539/*
540 * LEDs
541 */
542static struct gpio_led ek_leds[] = {
543 { /* "bottom" led, green, userled1 to be defined */
544 .name = "ds7",
545 .gpio = AT91_PIN_PA14,
546 .active_low = 1,
547 .default_trigger = "none",
548 },
549 { /* "top" led, green, userled2 to be defined */
550 .name = "ds8",
551 .gpio = AT91_PIN_PA13,
552 .active_low = 1,
553 .default_trigger = "none",
554 },
555 { /* "power" led, yellow */
556 .name = "ds1",
557 .gpio = AT91_PIN_PA23,
558 .default_trigger = "heartbeat",
559 }
560};
561
Andrew Victor022cbd72006-12-01 14:38:59 +0100562static void __init ek_board_init(void)
563{
564 /* Serial */
Jean-Christophe PLAGNIOL-VILLARD71b149b2012-04-05 14:14:28 +0800565 /* DBGU on ttyS0. (Rx & Tx only) */
566 at91_register_uart(0, 0, 0);
Andrew Victor022cbd72006-12-01 14:38:59 +0100567 at91_add_device_serial();
Jean-Christophe PLAGNIOL-VILLARDb3f442b2013-05-15 17:19:21 +0200568
569 if (cpu_is_at91sam9g10())
570 ek_lcdc_data.lcd_wiring_mode = ATMEL_LCDC_WIRING_RGB;
571
Andrew Victor022cbd72006-12-01 14:38:59 +0100572 /* USB Host */
573 at91_add_device_usbh(&ek_usbh_data);
574 /* USB Device */
575 at91_add_device_udc(&ek_udc_data);
576 /* I2C */
Andrew Victorf230d3f2007-11-19 13:47:20 +0100577 at91_add_device_i2c(NULL, 0);
Andrew Victor022cbd72006-12-01 14:38:59 +0100578 /* NAND */
Andrew Victor8cdae512008-10-06 20:05:35 +0100579 ek_add_device_nand();
Andrew Victor022cbd72006-12-01 14:38:59 +0100580 /* DM9000 ethernet */
581 ek_add_device_dm9000();
582
583 /* spi0 and mmc/sd share the same PIO pins */
584#if defined(CONFIG_SPI_ATMEL) || defined(CONFIG_SPI_ATMEL_MODULE)
585 /* SPI */
586 at91_add_device_spi(ek_spi_devices, ARRAY_SIZE(ek_spi_devices));
Andrew Victor235227282007-05-02 17:58:51 +0100587 /* Touchscreen */
588 ek_add_device_ts();
Andrew Victor5e9df922008-04-02 22:18:35 +0100589 /* SSC (to AT73C213) */
590 at73c213_set_clk(&at73c213_data);
591 at91_add_device_ssc(AT91SAM9261_ID_SSC1, ATMEL_SSC_TX);
Andrew Victor022cbd72006-12-01 14:38:59 +0100592#else
593 /* MMC */
Ludovic Desroches4cf33262012-05-21 12:23:27 +0200594 at91_add_device_mci(0, &mci0_data);
Andrew Victor022cbd72006-12-01 14:38:59 +0100595#endif
Andrew Victorcdf95c72007-05-14 15:08:21 +0100596 /* LCD Controller */
597 at91_add_device_lcdc(&ek_lcdc_data);
Andrew Victord0f9b552007-06-04 08:41:59 +0100598 /* Push Buttons */
599 ek_add_device_buttons();
Andrew Victor5b7659d2008-04-02 22:20:45 +0100600 /* LEDs */
601 at91_gpio_leds(ek_leds, ARRAY_SIZE(ek_leds));
Andrew Victor022cbd72006-12-01 14:38:59 +0100602}
603
604MACHINE_START(AT91SAM9261EK, "Atmel AT91SAM9261-EK")
Jean-Christophe PLAGNIOL-VILLARDb3f442b2013-05-15 17:19:21 +0200605 /* Maintainer: Atmel */
606 .init_time = at91sam926x_pit_init,
607 .map_io = at91_map_io,
608 .handle_irq = at91_aic_handle_irq,
609 .init_early = ek_init_early,
610 .init_irq = at91_init_irq_default,
611 .init_machine = ek_board_init,
612MACHINE_END
613
Nicolas Ferreb319ff82009-06-26 15:37:01 +0100614MACHINE_START(AT91SAM9G10EK, "Atmel AT91SAM9G10-EK")
Andrew Victor022cbd72006-12-01 14:38:59 +0100615 /* Maintainer: Atmel */
Stephen Warren6bb27d72012-11-08 12:40:59 -0700616 .init_time = at91sam926x_pit_init,
Jean-Christophe PLAGNIOL-VILLARD21d08b92011-04-23 15:28:34 +0800617 .map_io = at91_map_io,
Ludovic Desroches3e135462012-06-11 15:38:03 +0200618 .handle_irq = at91_aic_handle_irq,
Jean-Christophe PLAGNIOL-VILLARD1b021a32011-04-28 20:19:32 +0800619 .init_early = ek_init_early,
Jean-Christophe PLAGNIOL-VILLARD92100c12011-04-23 15:28:34 +0800620 .init_irq = at91_init_irq_default,
Andrew Victor022cbd72006-12-01 14:38:59 +0100621 .init_machine = ek_board_init,
622MACHINE_END