2 * linux/arch/arm/mach-at91/board-sam9261ek.c
4 * Copyright (C) 2005 SAN People
5 * Copyright (C) 2006 Atmel
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.
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.
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
22 #include <linux/types.h>
23 #include <linux/init.h>
25 #include <linux/module.h>
26 #include <linux/platform_device.h>
27 #include <linux/spi/spi.h>
28 #include <linux/spi/ads7846.h>
29 #include <linux/spi/at73c213.h>
30 #include <linux/clk.h>
31 #include <linux/dm9000.h>
33 #include <linux/gpio_keys.h>
34 #include <linux/input.h>
36 #include <video/atmel_lcdc.h>
38 #include <asm/setup.h>
39 #include <asm/mach-types.h>
42 #include <asm/mach/arch.h>
43 #include <asm/mach/map.h>
44 #include <asm/mach/irq.h>
46 #include <mach/hardware.h>
47 #include <mach/board.h>
48 #include <mach/gpio.h>
49 #include <mach/at91sam9_smc.h>
54 static void __init ek_map_io(void)
56 /* Initialize processor: 18.432 MHz crystal */
57 at91sam9261_initialize(18432000);
60 at91_init_leds(AT91_PIN_PA13, AT91_PIN_PA14);
62 /* DGBU on ttyS0. (Rx & Tx only) */
63 at91_register_uart(0, 0, 0);
65 /* set serial console to ttyS0 (ie, DBGU) */
66 at91_set_serial_console(0);
69 static void __init ek_init_irq(void)
71 at91sam9261_init_interrupts(NULL);
76 * DM9000 ethernet device
78 #if defined(CONFIG_DM9000)
79 static struct resource at91sam9261_dm9000_resource[] = {
81 .start = AT91_CHIPSELECT_2,
82 .end = AT91_CHIPSELECT_2 + 3,
83 .flags = IORESOURCE_MEM
86 .start = AT91_CHIPSELECT_2 + 0x44,
87 .end = AT91_CHIPSELECT_2 + 0xFF,
88 .flags = IORESOURCE_MEM
91 .start = AT91_PIN_PC11,
93 .flags = IORESOURCE_IRQ
97 static struct dm9000_plat_data dm9000_platdata = {
98 .flags = DM9000_PLATF_16BITONLY,
101 static struct platform_device at91sam9261_dm9000_device = {
104 .num_resources = ARRAY_SIZE(at91sam9261_dm9000_resource),
105 .resource = at91sam9261_dm9000_resource,
107 .platform_data = &dm9000_platdata,
111 static void __init ek_add_device_dm9000(void)
114 * Configure Chip-Select 2 on SMC for the DM9000.
115 * Note: These timings were calculated for MASTER_CLOCK = 100000000
116 * according to the DM9000 timings.
118 at91_sys_write(AT91_SMC_SETUP(2), AT91_SMC_NWESETUP_(2) | AT91_SMC_NCS_WRSETUP_(0) | AT91_SMC_NRDSETUP_(2) | AT91_SMC_NCS_RDSETUP_(0));
119 at91_sys_write(AT91_SMC_PULSE(2), AT91_SMC_NWEPULSE_(4) | AT91_SMC_NCS_WRPULSE_(8) | AT91_SMC_NRDPULSE_(4) | AT91_SMC_NCS_RDPULSE_(8));
120 at91_sys_write(AT91_SMC_CYCLE(2), AT91_SMC_NWECYCLE_(16) | AT91_SMC_NRDCYCLE_(16));
121 at91_sys_write(AT91_SMC_MODE(2), AT91_SMC_READMODE | AT91_SMC_WRITEMODE | AT91_SMC_EXNWMODE_DISABLE | AT91_SMC_BAT_WRITE | AT91_SMC_DBW_16 | AT91_SMC_TDF_(1));
123 /* Configure Reset signal as output */
124 at91_set_gpio_output(AT91_PIN_PC10, 0);
126 /* Configure Interrupt pin as input, no pull-up */
127 at91_set_gpio_input(AT91_PIN_PC11, 0);
129 platform_device_register(&at91sam9261_dm9000_device);
132 static void __init ek_add_device_dm9000(void) {}
133 #endif /* CONFIG_DM9000 */
139 static struct at91_usbh_data __initdata ek_usbh_data = {
147 static struct at91_udc_data __initdata ek_udc_data = {
148 .vbus_pin = AT91_PIN_PB29,
149 .pullup_pin = 0, /* pull-up driven by UDC */
156 static struct at91_mmc_data __initdata ek_mmc_data = {
158 // .det_pin = ... not connected
159 // .wp_pin = ... not connected
160 // .vcc_pin = ... not connected
167 static struct mtd_partition __initdata ek_nand_partition[] = {
169 .name = "Partition 1",
174 .name = "Partition 2",
175 .offset = MTDPART_OFS_NXTBLK,
176 .size = MTDPART_SIZ_FULL,
180 static struct mtd_partition * __init nand_partitions(int size, int *num_partitions)
182 *num_partitions = ARRAY_SIZE(ek_nand_partition);
183 return ek_nand_partition;
186 static struct atmel_nand_data __initdata ek_nand_data = {
189 // .det_pin = ... not connected
190 .rdy_pin = AT91_PIN_PC15,
191 .enable_pin = AT91_PIN_PC14,
192 .partition_info = nand_partitions,
193 #if defined(CONFIG_MTD_NAND_ATMEL_BUSWIDTH_16)
201 * ADS7846 Touchscreen
203 #if defined(CONFIG_TOUCHSCREEN_ADS7846) || defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE)
205 static int ads7843_pendown_state(void)
207 return !at91_get_gpio_value(AT91_PIN_PC2); /* Touchscreen PENIRQ */
210 static struct ads7846_platform_data ads_info = {
216 .vref_delay_usecs = 100,
219 .pressure_max = 15000,
222 .debounce_tol = (~0),
223 .get_pendown_state = ads7843_pendown_state,
226 static void __init ek_add_device_ts(void)
228 at91_set_B_periph(AT91_PIN_PC2, 1); /* External IRQ0, with pullup */
229 at91_set_gpio_input(AT91_PIN_PA11, 1); /* Touchscreen BUSY signal */
232 static void __init ek_add_device_ts(void) {}
238 static struct at73c213_board_info at73c213_data = {
240 .shortname = "AT91SAM9261-EK external DAC",
243 #if defined(CONFIG_SND_AT73C213) || defined(CONFIG_SND_AT73C213_MODULE)
244 static void __init at73c213_set_clk(struct at73c213_board_info *info)
249 pck2 = clk_get(NULL, "pck2");
250 plla = clk_get(NULL, "plla");
252 /* AT73C213 MCK Clock */
253 at91_set_B_periph(AT91_PIN_PB31, 0); /* PCK2 */
255 clk_set_parent(pck2, plla);
258 info->dac_clk = pck2;
261 static void __init at73c213_set_clk(struct at73c213_board_info *info) {}
267 static struct spi_board_info ek_spi_devices[] = {
268 { /* DataFlash chip */
269 .modalias = "mtd_dataflash",
271 .max_speed_hz = 15 * 1000 * 1000,
274 #if defined(CONFIG_TOUCHSCREEN_ADS7846) || defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE)
276 .modalias = "ads7846",
278 .max_speed_hz = 125000 * 26, /* (max sample rate @ 3V) * (cmd + data + overhead) */
280 .platform_data = &ads_info,
281 .irq = AT91SAM9261_ID_IRQ0,
282 .controller_data = (void *) AT91_PIN_PA28, /* CS pin */
285 #if defined(CONFIG_MTD_AT91_DATAFLASH_CARD)
286 { /* DataFlash card - jumper (J12) configurable to CS3 or CS0 */
287 .modalias = "mtd_dataflash",
289 .max_speed_hz = 15 * 1000 * 1000,
292 #elif defined(CONFIG_SND_AT73C213) || defined(CONFIG_SND_AT73C213_MODULE)
294 .modalias = "at73c213",
296 .max_speed_hz = 10 * 1000 * 1000,
299 .platform_data = &at73c213_data,
300 .controller_data = (void*) AT91_PIN_PA29, /* default for CS3 is PA6, but it must be PA29 */
309 #if defined(CONFIG_FB_ATMEL) || defined(CONFIG_FB_ATMEL_MODULE)
311 #if defined(CONFIG_FB_ATMEL_STN)
314 static struct fb_videomode at91_stn_modes[] = {
316 .name = "SP06Q002 @ 75",
318 .xres = 320, .yres = 240,
319 .pixclock = KHZ2PICOS(1440),
321 .left_margin = 1, .right_margin = 1,
322 .upper_margin = 0, .lower_margin = 0,
323 .hsync_len = 1, .vsync_len = 1,
325 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
326 .vmode = FB_VMODE_NONINTERLACED,
330 static struct fb_monspecs at91fb_default_stn_monspecs = {
331 .manufacturer = "HIT",
332 .monitor = "SP06Q002",
334 .modedb = at91_stn_modes,
335 .modedb_len = ARRAY_SIZE(at91_stn_modes),
342 #define AT91SAM9261_DEFAULT_STN_LCDCON2 (ATMEL_LCDC_MEMOR_LITTLE \
343 | ATMEL_LCDC_DISTYPE_STNMONO \
344 | ATMEL_LCDC_CLKMOD_ALWAYSACTIVE \
345 | ATMEL_LCDC_IFWIDTH_4 \
346 | ATMEL_LCDC_SCANMOD_SINGLE)
348 static void at91_lcdc_stn_power_control(int on)
351 if (on) { /* power up */
352 at91_set_gpio_value(AT91_PIN_PC14, 0);
353 at91_set_gpio_value(AT91_PIN_PC15, 0);
354 } else { /* power down */
355 at91_set_gpio_value(AT91_PIN_PC14, 1);
356 at91_set_gpio_value(AT91_PIN_PC15, 1);
360 static struct atmel_lcdfb_info __initdata ek_lcdc_data = {
362 .default_dmacon = ATMEL_LCDC_DMAEN,
363 .default_lcdcon2 = AT91SAM9261_DEFAULT_STN_LCDCON2,
364 .default_monspecs = &at91fb_default_stn_monspecs,
365 .atmel_lcdfb_power_control = at91_lcdc_stn_power_control,
372 static struct fb_videomode at91_tft_vga_modes[] = {
374 .name = "TX09D50VM1CCA @ 60",
376 .xres = 240, .yres = 320,
377 .pixclock = KHZ2PICOS(4965),
379 .left_margin = 1, .right_margin = 33,
380 .upper_margin = 1, .lower_margin = 0,
381 .hsync_len = 5, .vsync_len = 1,
383 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
384 .vmode = FB_VMODE_NONINTERLACED,
388 static struct fb_monspecs at91fb_default_tft_monspecs = {
389 .manufacturer = "HIT",
390 .monitor = "TX09D50VM1CCA",
392 .modedb = at91_tft_vga_modes,
393 .modedb_len = ARRAY_SIZE(at91_tft_vga_modes),
400 #define AT91SAM9261_DEFAULT_TFT_LCDCON2 (ATMEL_LCDC_MEMOR_LITTLE \
401 | ATMEL_LCDC_DISTYPE_TFT \
402 | ATMEL_LCDC_CLKMOD_ALWAYSACTIVE)
404 static void at91_lcdc_tft_power_control(int on)
407 at91_set_gpio_value(AT91_PIN_PA12, 0); /* power up */
409 at91_set_gpio_value(AT91_PIN_PA12, 1); /* power down */
412 static struct atmel_lcdfb_info __initdata ek_lcdc_data = {
413 .lcdcon_is_backlight = true,
415 .default_dmacon = ATMEL_LCDC_DMAEN,
416 .default_lcdcon2 = AT91SAM9261_DEFAULT_TFT_LCDCON2,
417 .default_monspecs = &at91fb_default_tft_monspecs,
418 .atmel_lcdfb_power_control = at91_lcdc_tft_power_control,
424 static struct atmel_lcdfb_info __initdata ek_lcdc_data;
431 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
432 static struct gpio_keys_button ek_buttons[] = {
434 .gpio = AT91_PIN_PA27,
441 .gpio = AT91_PIN_PA26,
448 .gpio = AT91_PIN_PA25,
455 .gpio = AT91_PIN_PA24,
463 static struct gpio_keys_platform_data ek_button_data = {
464 .buttons = ek_buttons,
465 .nbuttons = ARRAY_SIZE(ek_buttons),
468 static struct platform_device ek_button_device = {
473 .platform_data = &ek_button_data,
477 static void __init ek_add_device_buttons(void)
479 at91_set_gpio_input(AT91_PIN_PA27, 1); /* btn0 */
480 at91_set_deglitch(AT91_PIN_PA27, 1);
481 at91_set_gpio_input(AT91_PIN_PA26, 1); /* btn1 */
482 at91_set_deglitch(AT91_PIN_PA26, 1);
483 at91_set_gpio_input(AT91_PIN_PA25, 1); /* btn2 */
484 at91_set_deglitch(AT91_PIN_PA25, 1);
485 at91_set_gpio_input(AT91_PIN_PA24, 1); /* btn3 */
486 at91_set_deglitch(AT91_PIN_PA24, 1);
488 platform_device_register(&ek_button_device);
491 static void __init ek_add_device_buttons(void) {}
497 static struct gpio_led ek_leds[] = {
498 { /* "bottom" led, green, userled1 to be defined */
500 .gpio = AT91_PIN_PA14,
502 .default_trigger = "none",
504 { /* "top" led, green, userled2 to be defined */
506 .gpio = AT91_PIN_PA13,
508 .default_trigger = "none",
510 { /* "power" led, yellow */
512 .gpio = AT91_PIN_PA23,
513 .default_trigger = "heartbeat",
517 static void __init ek_board_init(void)
520 at91_add_device_serial();
522 at91_add_device_usbh(&ek_usbh_data);
524 at91_add_device_udc(&ek_udc_data);
526 at91_add_device_i2c(NULL, 0);
528 at91_add_device_nand(&ek_nand_data);
529 /* DM9000 ethernet */
530 ek_add_device_dm9000();
532 /* spi0 and mmc/sd share the same PIO pins */
533 #if defined(CONFIG_SPI_ATMEL) || defined(CONFIG_SPI_ATMEL_MODULE)
535 at91_add_device_spi(ek_spi_devices, ARRAY_SIZE(ek_spi_devices));
538 /* SSC (to AT73C213) */
539 at73c213_set_clk(&at73c213_data);
540 at91_add_device_ssc(AT91SAM9261_ID_SSC1, ATMEL_SSC_TX);
543 at91_add_device_mmc(0, &ek_mmc_data);
546 at91_add_device_lcdc(&ek_lcdc_data);
548 ek_add_device_buttons();
550 at91_gpio_leds(ek_leds, ARRAY_SIZE(ek_leds));
553 MACHINE_START(AT91SAM9261EK, "Atmel AT91SAM9261-EK")
554 /* Maintainer: Atmel */
555 .phys_io = AT91_BASE_SYS,
556 .io_pg_offst = (AT91_VA_BASE_SYS >> 18) & 0xfffc,
557 .boot_params = AT91_SDRAM_BASE + 0x100,
558 .timer = &at91sam926x_timer,
560 .init_irq = ek_init_irq,
561 .init_machine = ek_board_init,