7af870a2357ccfb23947b5e4c3f3040da91935c6
[openwrt/openwrt.git] / target / linux / at91 / files / arch / arm / mach-at91 / board-netus-foxboard.c
1 /*
2 * Copyright (C) 2005 SAN People
3 * Copyright (C) 2006 Atmel
4 * Copyright (C) 2009-2010 Claudio Mignanti <c.mignanti@gmail.com>
5 *
6 * Strongly based on arch/arm/mach-at91/board-sam9260ek.c
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */
22
23 #include <linux/types.h>
24 #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>
29 #include <linux/gpio.h>
30 #include <linux/gpio_keys.h>
31 #include <linux/input.h>
32 #include <linux/clk.h>
33
34 #include <mach/hardware.h>
35 #include <asm/setup.h>
36 #include <asm/mach-types.h>
37 #include <asm/irq.h>
38
39 #include <asm/mach/arch.h>
40 #include <asm/mach/map.h>
41 #include <asm/mach/irq.h>
42
43 #include <mach/board.h>
44 #include <mach/at91sam9_smc.h>
45
46 #include "sam9_smc.h"
47 #include "generic.h"
48
49
50 static void __init ek_map_io(void)
51 {
52 /* Initialize processor: 18.432 MHz crystal */
53 at91sam9260_initialize(18432000);
54
55 /* DGBU on ttyS0. (Rx & Tx only) */
56 at91_register_uart(0, 0, 0);
57
58 #if defined(CONFIG_NETUS_SERIALS)
59 /* USART0 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */
60 at91_register_uart(AT91SAM9260_ID_US0, 1, ATMEL_UART_CTS | ATMEL_UART_RTS
61 | ATMEL_UART_DTR | ATMEL_UART_DSR | ATMEL_UART_DCD
62 | ATMEL_UART_RI);
63
64 /* USART1 on ttyS2. (Rx, Tx, RTS, CTS) */
65 at91_register_uart(AT91SAM9260_ID_US1, 2, ATMEL_UART_CTS | ATMEL_UART_RTS);
66
67 /* USART2 on ttyS3. (Rx, Tx) */
68 at91_register_uart(AT91SAM9260_ID_US2, 3, 0);
69 #endif
70
71 /* set serial console to ttyS0 (ie, DBGU) */
72 at91_set_serial_console(0);
73 }
74
75 static void __init ek_init_irq(void)
76 {
77 at91sam9260_init_interrupts(NULL);
78 }
79
80
81 /*
82 * USB Host port
83 */
84 static struct at91_usbh_data __initdata ek_usbh_data = {
85 .ports = 2,
86 };
87
88 /*
89 * USB Device port
90 */
91 static struct at91_udc_data __initdata ek_udc_data = {
92 .vbus_pin = AT91_PIN_PC6,
93 .pullup_pin = 0, /* pull-up driven by UDC */
94 };
95
96
97 /*
98 * SPI devices.
99 */
100 static struct spi_board_info ek_spi_devices[] = {
101 #if defined(CONFIG_NETUS_USE_DATAFLASH)
102 { /* DataFlash chip */
103 .modalias = "mtd_dataflash",
104 .chip_select = 1,
105 .max_speed_hz = 15 * 1000 * 1000,
106 .bus_num = 0,
107 },
108 #endif
109 };
110
111
112 /*
113 * MACB Ethernet device
114 */
115 static struct at91_eth_data __initdata ek_macb_data = {
116 .phy_irq_pin = AT91_PIN_PA29,
117 .is_rmii = 1,
118 };
119
120
121 /*
122 * MCI (SD/MMC)
123 * det_pin, wp_pin and vcc_pin are not connected
124 */
125 static struct at91_mmc_data __initdata ek_mmc_data = {
126 .slot_b = 1,
127 .wire4 = 1,
128 };
129
130 /*
131 * LEDs
132 */
133 static struct gpio_led ek_leds[] = {
134 {
135 .name = "led:red:user",
136 .gpio = AT91_PIN_PC7,
137 .active_low = 0,
138 #if defined(CONFIG_NETUS_HEARTBEAT_LED)
139 .default_trigger = "heartbeat",
140 #else
141 .default_trigger = "none",
142 #endif
143 },
144 };
145
146 /*
147 * GPIO Buttons
148 */
149 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
150
151 static struct gpio_keys_button ek_buttons[] = {
152 {
153 .gpio = AT91_PIN_PC4,
154 .code = BTN_1,
155 .desc = "Button 1",
156 .active_low = 1,
157 .wakeup = 1,
158 },
159 };
160
161 static struct gpio_keys_platform_data ek_button_data = {
162 .buttons = ek_buttons,
163 .nbuttons = ARRAY_SIZE(ek_buttons),
164 };
165
166 static struct platform_device ek_button_device = {
167 .name = "gpio-keys",
168 .id = -1,
169 .num_resources = 0,
170 .dev = {
171 .platform_data = &ek_button_data,
172 }
173 };
174
175 static void __init ek_add_device_buttons(void)
176 {
177 at91_set_gpio_input(AT91_PIN_PC4, 1); /* btn1 */
178 at91_set_deglitch(AT91_PIN_PC4, 1);
179
180 platform_device_register(&ek_button_device);
181 }
182 #else
183 static void __init ek_add_device_buttons(void) {}
184 #endif
185
186 static struct resource gpiodev_resource = {
187 .start = 0xFFFFFFFF,
188 };
189
190 static void __init ek_board_init(void)
191 {
192 /* Serial */
193 at91_add_device_serial();
194 /* USB Host */
195 at91_add_device_usbh(&ek_usbh_data);
196 /* USB Device */
197 at91_add_device_udc(&ek_udc_data);
198 /* SPI */
199 at91_add_device_spi(ek_spi_devices, ARRAY_SIZE(ek_spi_devices));
200 /* Ethernet */
201 at91_add_device_eth(&ek_macb_data);
202 /* MMC */
203 at91_add_device_mmc(0, &ek_mmc_data);
204 /* I2C */
205 at91_add_device_i2c(NULL, 0);
206 /* LEDs */
207 at91_gpio_leds(ek_leds, ARRAY_SIZE(ek_leds));
208 /* Push Buttons */
209 ek_add_device_buttons();
210 /* Register GPIODEV */
211 platform_device_register_simple("GPIODEV", 0, &gpiodev_resource, 1);
212
213 }
214
215 MACHINE_START(AT91SAM9G20EK, "Acmesystems Netus FoxBoardG20")
216 /* Maintainer: Claudio Mignanti */
217 .phys_io = AT91_BASE_SYS,
218 .io_pg_offst = (AT91_VA_BASE_SYS >> 18) & 0xfffc,
219 .boot_params = AT91_SDRAM_BASE + 0x100,
220 .timer = &at91sam926x_timer,
221 .map_io = ek_map_io,
222 .init_irq = ek_init_irq,
223 .init_machine = ek_board_init,
224 MACHINE_END
225
226