2 * linux/arch/arm/mach-at91/board-usb-a926x.c
4 * Copyright (C) 2005 SAN People
5 * Copyright (C) 2007 Atmel Corporation.
6 * Copyright (C) 2007 Calao-systems
7 * Copyright (C) 2011 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 #include <linux/types.h>
25 #include <linux/init.h>
27 #include <linux/module.h>
28 #include <linux/platform_device.h>
29 #include <linux/spi/spi.h>
30 #include <linux/gpio_keys.h>
31 #include <linux/gpio.h>
32 #include <linux/input.h>
33 #include <linux/spi/mmc_spi.h>
35 #include <asm/setup.h>
36 #include <asm/mach-types.h>
39 #include <asm/mach/arch.h>
40 #include <asm/mach/map.h>
41 #include <asm/mach/irq.h>
43 #include <mach/hardware.h>
44 #include <mach/board.h>
45 #include <mach/at91sam9_smc.h>
46 #include <mach/at91_shdwc.h>
52 static void __init ek_init_early(void)
54 /* Initialize processor: 12.00 MHz crystal */
55 at91_initialize(12000000);
61 static struct at91_usbh_data __initdata ek_usbh_data = {
63 .vbus_pin = {-EINVAL, -EINVAL},
64 .overcurrent_pin= {-EINVAL, -EINVAL},
70 static struct at91_udc_data __initdata ek_udc_data = {
71 .vbus_pin = AT91_PIN_PB11,
72 .pullup_pin = -EINVAL, /* pull-up driven by UDC */
75 static void __init ek_add_device_udc(void)
77 if (machine_is_usb_a9260() || machine_is_usb_a9g20())
78 ek_udc_data.vbus_pin = AT91_PIN_PC5;
80 at91_add_device_udc(&ek_udc_data);
83 #if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
84 #define MMC_SPI_CARD_DETECT_INT AT91_PIN_PC4
85 static int at91_mmc_spi_init(struct device *dev,
86 irqreturn_t (*detect_int)(int, void *), void *data)
88 /* Configure Interrupt pin as input, no pull-up */
89 at91_set_gpio_input(MMC_SPI_CARD_DETECT_INT, 0);
90 return request_irq(gpio_to_irq(MMC_SPI_CARD_DETECT_INT), detect_int,
91 IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING,
92 "mmc-spi-detect", data);
95 static void at91_mmc_spi_exit(struct device *dev, void *data)
97 free_irq(gpio_to_irq(MMC_SPI_CARD_DETECT_INT), data);
100 static struct mmc_spi_platform_data at91_mmc_spi_pdata = {
101 .init = at91_mmc_spi_init,
102 .exit = at91_mmc_spi_exit,
103 .detect_delay = 100, /* msecs */
110 static struct spi_board_info usb_a9263_spi_devices[] = {
111 #if !defined(CONFIG_MMC_AT91)
112 { /* DataFlash chip */
113 .modalias = "mtd_dataflash",
115 .max_speed_hz = 15 * 1000 * 1000,
121 static struct spi_board_info usb_a9g20_spi_devices[] = {
122 #if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
124 .modalias = "mmc_spi",
125 .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */
128 .platform_data = &at91_mmc_spi_pdata,
134 static void __init ek_add_device_spi(void)
136 if (machine_is_usb_a9263())
137 at91_add_device_spi(usb_a9263_spi_devices, ARRAY_SIZE(usb_a9263_spi_devices));
138 else if (machine_is_usb_a9g20())
139 at91_add_device_spi(usb_a9g20_spi_devices, ARRAY_SIZE(usb_a9g20_spi_devices));
143 * MACB Ethernet device
145 static struct macb_platform_data __initdata ek_macb_data = {
146 .phy_irq_pin = AT91_PIN_PE31,
150 static void __init ek_add_device_eth(void)
152 if (machine_is_usb_a9260() || machine_is_usb_a9g20())
153 ek_macb_data.phy_irq_pin = AT91_PIN_PA31;
155 at91_add_device_eth(&ek_macb_data);
161 static struct mtd_partition __initdata ek_nand_partition[] = {
167 .name = "bareboxenv",
168 .offset = MTDPART_OFS_NXTBLK,
171 .name = "bareboxenv2",
172 .offset = MTDPART_OFS_NXTBLK,
176 .offset = MTDPART_OFS_NXTBLK,
180 .offset = MTDPART_OFS_NXTBLK,
184 .offset = MTDPART_OFS_NXTBLK,
188 .offset = MTDPART_OFS_NXTBLK,
189 .size = MTDPART_SIZ_FULL,
193 static struct atmel_nand_data __initdata ek_nand_data = {
197 .rdy_pin = AT91_PIN_PA22,
198 .enable_pin = AT91_PIN_PD15,
199 .ecc_mode = NAND_ECC_SOFT,
201 .parts = ek_nand_partition,
202 .num_parts = ARRAY_SIZE(ek_nand_partition),
205 static struct sam9_smc_config __initdata usb_a9260_nand_smc_config = {
208 .ncs_write_setup = 0,
213 .ncs_write_pulse = 3,
219 .mode = AT91_SMC_READMODE | AT91_SMC_WRITEMODE | AT91_SMC_EXNWMODE_DISABLE | AT91_SMC_DBW_8,
223 static struct sam9_smc_config __initdata usb_a9g20_nand_smc_config = {
226 .ncs_write_setup = 0,
231 .ncs_write_pulse = 4,
237 .mode = AT91_SMC_READMODE | AT91_SMC_WRITEMODE | AT91_SMC_EXNWMODE_DISABLE | AT91_SMC_DBW_8,
241 static void __init ek_add_device_nand(void)
243 if (machine_is_usb_a9260() || machine_is_usb_a9g20()) {
244 ek_nand_data.rdy_pin = AT91_PIN_PC13;
245 ek_nand_data.enable_pin = AT91_PIN_PC14;
248 /* configure chip-select 3 (NAND) */
249 if (machine_is_usb_a9g20())
250 sam9_smc_configure(0, 3, &usb_a9g20_nand_smc_config);
252 sam9_smc_configure(0, 3, &usb_a9260_nand_smc_config);
254 at91_add_device_nand(&ek_nand_data);
261 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
262 static struct gpio_keys_button ek_buttons[] = {
263 { /* USER PUSH BUTTON */
265 .gpio = AT91_PIN_PB10,
272 static struct gpio_keys_platform_data ek_button_data = {
273 .buttons = ek_buttons,
274 .nbuttons = ARRAY_SIZE(ek_buttons),
277 static struct platform_device ek_button_device = {
282 .platform_data = &ek_button_data,
286 static void __init ek_add_device_buttons(void)
288 at91_set_GPIO_periph(AT91_PIN_PB10, 1); /* user push button, pull up enabled */
289 at91_set_deglitch(AT91_PIN_PB10, 1);
291 platform_device_register(&ek_button_device);
294 static void __init ek_add_device_buttons(void) {}
300 static struct gpio_led ek_leds[] = {
301 { /* user_led (green) */
303 .gpio = AT91_PIN_PB21,
305 .default_trigger = "heartbeat",
309 static struct i2c_board_info __initdata ek_i2c_devices[] = {
311 I2C_BOARD_INFO("rv3029c2", 0x56),
315 static void __init ek_add_device_leds(void)
317 if (machine_is_usb_a9260() || machine_is_usb_a9g20())
318 ek_leds[0].active_low = 0;
320 at91_gpio_leds(ek_leds, ARRAY_SIZE(ek_leds));
323 static void __init ek_board_init(void)
326 /* DBGU on ttyS0. (Rx & Tx only) */
327 at91_register_uart(0, 0, 0);
328 at91_add_device_serial();
330 at91_add_device_usbh(&ek_usbh_data);
338 ek_add_device_nand();
340 ek_add_device_buttons();
342 ek_add_device_leds();
344 if (machine_is_usb_a9g20()) {
346 at91_add_device_i2c(ek_i2c_devices, ARRAY_SIZE(ek_i2c_devices));
349 at91_add_device_i2c(NULL, 0);
350 /* shutdown controller, wakeup button (5 msec low) */
351 at91_shdwc_write(AT91_SHDW_MR, AT91_SHDW_CPTWK0_(10)
352 | AT91_SHDW_WKMODE0_LOW
353 | AT91_SHDW_RTTWKEN);
357 MACHINE_START(USB_A9263, "CALAO USB_A9263")
358 /* Maintainer: calao-systems */
359 .timer = &at91sam926x_timer,
360 .map_io = at91_map_io,
361 .init_early = ek_init_early,
362 .init_irq = at91_init_irq_default,
363 .init_machine = ek_board_init,
366 MACHINE_START(USB_A9260, "CALAO USB_A9260")
367 /* Maintainer: calao-systems */
368 .timer = &at91sam926x_timer,
369 .map_io = at91_map_io,
370 .init_early = ek_init_early,
371 .init_irq = at91_init_irq_default,
372 .init_machine = ek_board_init,
375 MACHINE_START(USB_A9G20, "CALAO USB_A92G0")
376 /* Maintainer: Jean-Christophe PLAGNIOL-VILLARD */
377 .timer = &at91sam926x_timer,
378 .map_io = at91_map_io,
379 .init_early = ek_init_early,
380 .init_irq = at91_init_irq_default,
381 .init_machine = ek_board_init,