ARM: at91: drop at91_set_serial_console
[linux-2.6.git] / arch / arm / mach-at91 / board-usb-a926x.c
blobee482ebd07a9b66e1925f6ae66f2d79ebb798354
1 /*
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>
26 #include <linux/mm.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>
37 #include <asm/irq.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>
48 #include "sam9_smc.h"
49 #include "generic.h"
52 static void __init ek_init_early(void)
54 /* Initialize processor: 12.00 MHz crystal */
55 at91_initialize(12000000);
57 /* DBGU on ttyS0. (Rx & Tx only) */
58 at91_register_uart(0, 0, 0);
62 * USB Host port
64 static struct at91_usbh_data __initdata ek_usbh_data = {
65 .ports = 2,
66 .vbus_pin = {-EINVAL, -EINVAL},
67 .overcurrent_pin= {-EINVAL, -EINVAL},
71 * USB Device port
73 static struct at91_udc_data __initdata ek_udc_data = {
74 .vbus_pin = AT91_PIN_PB11,
75 .pullup_pin = -EINVAL, /* pull-up driven by UDC */
78 static void __init ek_add_device_udc(void)
80 if (machine_is_usb_a9260() || machine_is_usb_a9g20())
81 ek_udc_data.vbus_pin = AT91_PIN_PC5;
83 at91_add_device_udc(&ek_udc_data);
86 #if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
87 #define MMC_SPI_CARD_DETECT_INT AT91_PIN_PC4
88 static int at91_mmc_spi_init(struct device *dev,
89 irqreturn_t (*detect_int)(int, void *), void *data)
91 /* Configure Interrupt pin as input, no pull-up */
92 at91_set_gpio_input(MMC_SPI_CARD_DETECT_INT, 0);
93 return request_irq(gpio_to_irq(MMC_SPI_CARD_DETECT_INT), detect_int,
94 IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING,
95 "mmc-spi-detect", data);
98 static void at91_mmc_spi_exit(struct device *dev, void *data)
100 free_irq(gpio_to_irq(MMC_SPI_CARD_DETECT_INT), data);
103 static struct mmc_spi_platform_data at91_mmc_spi_pdata = {
104 .init = at91_mmc_spi_init,
105 .exit = at91_mmc_spi_exit,
106 .detect_delay = 100, /* msecs */
108 #endif
111 * SPI devices.
113 static struct spi_board_info usb_a9263_spi_devices[] = {
114 #if !defined(CONFIG_MMC_AT91)
115 { /* DataFlash chip */
116 .modalias = "mtd_dataflash",
117 .chip_select = 0,
118 .max_speed_hz = 15 * 1000 * 1000,
119 .bus_num = 0,
121 #endif
124 static struct spi_board_info usb_a9g20_spi_devices[] = {
125 #if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
127 .modalias = "mmc_spi",
128 .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */
129 .bus_num = 1,
130 .chip_select = 0,
131 .platform_data = &at91_mmc_spi_pdata,
132 .mode = SPI_MODE_3,
134 #endif
137 static void __init ek_add_device_spi(void)
139 if (machine_is_usb_a9263())
140 at91_add_device_spi(usb_a9263_spi_devices, ARRAY_SIZE(usb_a9263_spi_devices));
141 else if (machine_is_usb_a9g20())
142 at91_add_device_spi(usb_a9g20_spi_devices, ARRAY_SIZE(usb_a9g20_spi_devices));
146 * MACB Ethernet device
148 static struct macb_platform_data __initdata ek_macb_data = {
149 .phy_irq_pin = AT91_PIN_PE31,
150 .is_rmii = 1,
153 static void __init ek_add_device_eth(void)
155 if (machine_is_usb_a9260() || machine_is_usb_a9g20())
156 ek_macb_data.phy_irq_pin = AT91_PIN_PA31;
158 at91_add_device_eth(&ek_macb_data);
162 * NAND flash
164 static struct mtd_partition __initdata ek_nand_partition[] = {
166 .name = "barebox",
167 .offset = 0,
168 .size = 3 * SZ_128K,
169 }, {
170 .name = "bareboxenv",
171 .offset = MTDPART_OFS_NXTBLK,
172 .size = SZ_128K,
173 }, {
174 .name = "bareboxenv2",
175 .offset = MTDPART_OFS_NXTBLK,
176 .size = SZ_128K,
177 }, {
178 .name = "kernel",
179 .offset = MTDPART_OFS_NXTBLK,
180 .size = 4 * SZ_1M,
181 }, {
182 .name = "rootfs",
183 .offset = MTDPART_OFS_NXTBLK,
184 .size = 120 * SZ_1M,
185 }, {
186 .name = "data",
187 .offset = MTDPART_OFS_NXTBLK,
188 .size = MTDPART_SIZ_FULL,
192 static struct atmel_nand_data __initdata ek_nand_data = {
193 .ale = 21,
194 .cle = 22,
195 .det_pin = -EINVAL,
196 .rdy_pin = AT91_PIN_PA22,
197 .enable_pin = AT91_PIN_PD15,
198 .ecc_mode = NAND_ECC_SOFT,
199 .on_flash_bbt = 1,
200 .parts = ek_nand_partition,
201 .num_parts = ARRAY_SIZE(ek_nand_partition),
204 static struct sam9_smc_config __initdata usb_a9260_nand_smc_config = {
205 .ncs_read_setup = 0,
206 .nrd_setup = 1,
207 .ncs_write_setup = 0,
208 .nwe_setup = 1,
210 .ncs_read_pulse = 3,
211 .nrd_pulse = 3,
212 .ncs_write_pulse = 3,
213 .nwe_pulse = 3,
215 .read_cycle = 5,
216 .write_cycle = 5,
218 .mode = AT91_SMC_READMODE | AT91_SMC_WRITEMODE | AT91_SMC_EXNWMODE_DISABLE | AT91_SMC_DBW_8,
219 .tdf_cycles = 2,
222 static struct sam9_smc_config __initdata usb_a9g20_nand_smc_config = {
223 .ncs_read_setup = 0,
224 .nrd_setup = 2,
225 .ncs_write_setup = 0,
226 .nwe_setup = 2,
228 .ncs_read_pulse = 4,
229 .nrd_pulse = 4,
230 .ncs_write_pulse = 4,
231 .nwe_pulse = 4,
233 .read_cycle = 7,
234 .write_cycle = 7,
236 .mode = AT91_SMC_READMODE | AT91_SMC_WRITEMODE | AT91_SMC_EXNWMODE_DISABLE | AT91_SMC_DBW_8,
237 .tdf_cycles = 3,
240 static void __init ek_add_device_nand(void)
242 if (machine_is_usb_a9260() || machine_is_usb_a9g20()) {
243 ek_nand_data.rdy_pin = AT91_PIN_PC13;
244 ek_nand_data.enable_pin = AT91_PIN_PC14;
247 /* configure chip-select 3 (NAND) */
248 if (machine_is_usb_a9g20())
249 sam9_smc_configure(0, 3, &usb_a9g20_nand_smc_config);
250 else
251 sam9_smc_configure(0, 3, &usb_a9260_nand_smc_config);
253 at91_add_device_nand(&ek_nand_data);
258 * GPIO Buttons
260 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
261 static struct gpio_keys_button ek_buttons[] = {
262 { /* USER PUSH BUTTON */
263 .code = KEY_ENTER,
264 .gpio = AT91_PIN_PB10,
265 .active_low = 1,
266 .desc = "user_pb",
267 .wakeup = 1,
271 static struct gpio_keys_platform_data ek_button_data = {
272 .buttons = ek_buttons,
273 .nbuttons = ARRAY_SIZE(ek_buttons),
276 static struct platform_device ek_button_device = {
277 .name = "gpio-keys",
278 .id = -1,
279 .num_resources = 0,
280 .dev = {
281 .platform_data = &ek_button_data,
285 static void __init ek_add_device_buttons(void)
287 at91_set_GPIO_periph(AT91_PIN_PB10, 1); /* user push button, pull up enabled */
288 at91_set_deglitch(AT91_PIN_PB10, 1);
290 platform_device_register(&ek_button_device);
292 #else
293 static void __init ek_add_device_buttons(void) {}
294 #endif
297 * LEDs
299 static struct gpio_led ek_leds[] = {
300 { /* user_led (green) */
301 .name = "user_led",
302 .gpio = AT91_PIN_PB21,
303 .active_low = 1,
304 .default_trigger = "heartbeat",
308 static struct i2c_board_info __initdata ek_i2c_devices[] = {
310 I2C_BOARD_INFO("rv3029c2", 0x56),
314 static void __init ek_add_device_leds(void)
316 if (machine_is_usb_a9260() || machine_is_usb_a9g20())
317 ek_leds[0].active_low = 0;
319 at91_gpio_leds(ek_leds, ARRAY_SIZE(ek_leds));
322 static void __init ek_board_init(void)
324 /* Serial */
325 at91_add_device_serial();
326 /* USB Host */
327 at91_add_device_usbh(&ek_usbh_data);
328 /* USB Device */
329 ek_add_device_udc();
330 /* SPI */
331 ek_add_device_spi();
332 /* Ethernet */
333 ek_add_device_eth();
334 /* NAND */
335 ek_add_device_nand();
336 /* Push Buttons */
337 ek_add_device_buttons();
338 /* LEDs */
339 ek_add_device_leds();
341 if (machine_is_usb_a9g20()) {
342 /* I2C */
343 at91_add_device_i2c(ek_i2c_devices, ARRAY_SIZE(ek_i2c_devices));
344 } else {
345 /* I2C */
346 at91_add_device_i2c(NULL, 0);
347 /* shutdown controller, wakeup button (5 msec low) */
348 at91_shdwc_write(AT91_SHDW_MR, AT91_SHDW_CPTWK0_(10)
349 | AT91_SHDW_WKMODE0_LOW
350 | AT91_SHDW_RTTWKEN);
354 MACHINE_START(USB_A9263, "CALAO USB_A9263")
355 /* Maintainer: calao-systems */
356 .timer = &at91sam926x_timer,
357 .map_io = at91_map_io,
358 .init_early = ek_init_early,
359 .init_irq = at91_init_irq_default,
360 .init_machine = ek_board_init,
361 MACHINE_END
363 MACHINE_START(USB_A9260, "CALAO USB_A9260")
364 /* Maintainer: calao-systems */
365 .timer = &at91sam926x_timer,
366 .map_io = at91_map_io,
367 .init_early = ek_init_early,
368 .init_irq = at91_init_irq_default,
369 .init_machine = ek_board_init,
370 MACHINE_END
372 MACHINE_START(USB_A9G20, "CALAO USB_A92G0")
373 /* Maintainer: Jean-Christophe PLAGNIOL-VILLARD */
374 .timer = &at91sam926x_timer,
375 .map_io = at91_map_io,
376 .init_early = ek_init_early,
377 .init_irq = at91_init_irq_default,
378 .init_machine = ek_board_init,
379 MACHINE_END