blob: f27d1a780cfa35ef815f6298519d69ea22105019 [file] [log] [blame]
Sergio Tanzilli0fb55d32010-10-14 02:06:26 +02001/*
2 * Copyright (C) 2005 SAN People
3 * Copyright (C) 2008 Atmel
4 * Copyright (C) 2010 Lee McLoughlin - lee@lmmrtech.com
5 * Copyright (C) 2010 Sergio Tanzilli - tanzilli@acmesystems.it
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>
23#include <linux/init.h>
24#include <linux/mm.h>
25#include <linux/module.h>
26#include <linux/platform_device.h>
27#include <linux/spi/spi.h>
28#include <linux/spi/at73c213.h>
29#include <linux/gpio.h>
30#include <linux/gpio_keys.h>
31#include <linux/input.h>
32#include <linux/clk.h>
33#include <linux/w1-gpio.h>
34
35#include <mach/hardware.h>
36#include <asm/setup.h>
37#include <asm/mach-types.h>
38#include <asm/irq.h>
39
40#include <asm/mach/arch.h>
41#include <asm/mach/map.h>
42#include <asm/mach/irq.h>
43
44#include <mach/board.h>
45#include <mach/at91sam9_smc.h>
46
47#include "sam9_smc.h"
48#include "generic.h"
49
50/*
51 * The FOX Board G20 hardware comes as the "Netus G20" board with
52 * just the cpu, ram, dataflash and two header connectors.
53 * This is plugged into the FOX Board which provides the ethernet,
54 * usb, rtc, leds, switch, ...
55 *
56 * For more info visit: http://www.acmesystems.it/foxg20
57 */
58
59
Jean-Christophe PLAGNIOL-VILLARD1b021a32011-04-28 20:19:32 +080060static void __init foxg20_init_early(void)
Sergio Tanzilli0fb55d32010-10-14 02:06:26 +020061{
62 /* Initialize processor: 18.432 MHz crystal */
Jean-Christophe PLAGNIOL-VILLARD21d08b92011-04-23 15:28:34 +080063 at91_initialize(18432000);
Sergio Tanzilli0fb55d32010-10-14 02:06:26 +020064
65 /* DBGU on ttyS0. (Rx & Tx only) */
66 at91_register_uart(0, 0, 0);
67
68 /* USART0 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */
69 at91_register_uart(AT91SAM9260_ID_US0, 1,
70 ATMEL_UART_CTS
71 | ATMEL_UART_RTS
72 | ATMEL_UART_DTR
73 | ATMEL_UART_DSR
74 | ATMEL_UART_DCD
75 | ATMEL_UART_RI);
76
77 /* USART1 on ttyS2. (Rx, Tx, RTS, CTS) */
78 at91_register_uart(AT91SAM9260_ID_US1, 2,
79 ATMEL_UART_CTS
80 | ATMEL_UART_RTS);
81
82 /* USART2 on ttyS3. (Rx & Tx only) */
83 at91_register_uart(AT91SAM9260_ID_US2, 3, 0);
84
85 /* USART3 on ttyS4. (Rx, Tx, RTS, CTS) */
86 at91_register_uart(AT91SAM9260_ID_US3, 4,
87 ATMEL_UART_CTS
88 | ATMEL_UART_RTS);
89
90 /* USART4 on ttyS5. (Rx & Tx only) */
91 at91_register_uart(AT91SAM9260_ID_US4, 5, 0);
92
93 /* USART5 on ttyS6. (Rx & Tx only) */
94 at91_register_uart(AT91SAM9260_ID_US5, 6, 0);
95
96 /* set serial console to ttyS0 (ie, DBGU) */
97 at91_set_serial_console(0);
98
99 /* Set the internal pull-up resistor on DRXD */
100 at91_set_A_periph(AT91_PIN_PB14, 1);
101
102}
103
Sergio Tanzilli0fb55d32010-10-14 02:06:26 +0200104/*
105 * USB Host port
106 */
107static struct at91_usbh_data __initdata foxg20_usbh_data = {
108 .ports = 2,
109};
110
111/*
112 * USB Device port
113 */
114static struct at91_udc_data __initdata foxg20_udc_data = {
115 .vbus_pin = AT91_PIN_PC6,
116 .pullup_pin = 0, /* pull-up driven by UDC */
117};
118
119
120/*
121 * SPI devices.
122 */
123static struct spi_board_info foxg20_spi_devices[] = {
124#if !defined(CONFIG_MMC_AT91)
125 {
126 .modalias = "mtd_dataflash",
127 .chip_select = 1,
128 .max_speed_hz = 15 * 1000 * 1000,
129 .bus_num = 0,
130 },
131#endif
132};
133
134
135/*
136 * MACB Ethernet device
137 */
138static struct at91_eth_data __initdata foxg20_macb_data = {
139 .phy_irq_pin = AT91_PIN_PA7,
140 .is_rmii = 1,
141};
142
143/*
144 * MCI (SD/MMC)
145 * det_pin, wp_pin and vcc_pin are not connected
146 */
147static struct at91_mmc_data __initdata foxg20_mmc_data = {
148 .slot_b = 1,
149 .wire4 = 1,
150};
151
152
153/*
154 * LEDs
155 */
156static struct gpio_led foxg20_leds[] = {
157 { /* user led, red */
158 .name = "user_led",
159 .gpio = AT91_PIN_PC7,
160 .active_low = 0,
161 .default_trigger = "heartbeat",
162 },
163};
164
165
166/*
167 * GPIO Buttons
168 */
169#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
170static struct gpio_keys_button foxg20_buttons[] = {
171 {
172 .gpio = AT91_PIN_PC4,
173 .code = BTN_1,
174 .desc = "Button 1",
175 .active_low = 1,
176 .wakeup = 1,
177 },
178};
179
180static struct gpio_keys_platform_data foxg20_button_data = {
181 .buttons = foxg20_buttons,
182 .nbuttons = ARRAY_SIZE(foxg20_buttons),
183};
184
185static struct platform_device foxg20_button_device = {
186 .name = "gpio-keys",
187 .id = -1,
188 .num_resources = 0,
189 .dev = {
190 .platform_data = &foxg20_button_data,
191 }
192};
193
194static void __init foxg20_add_device_buttons(void)
195{
196 at91_set_gpio_input(AT91_PIN_PC4, 1); /* btn1 */
197 at91_set_deglitch(AT91_PIN_PC4, 1);
198
199 platform_device_register(&foxg20_button_device);
200}
201#else
202static void __init foxg20_add_device_buttons(void) {}
203#endif
204
205
206#if defined(CONFIG_W1_MASTER_GPIO) || defined(CONFIG_W1_MASTER_GPIO_MODULE)
207static struct w1_gpio_platform_data w1_gpio_pdata = {
208 /* If you choose to use a pin other than PB16 it needs to be 3.3V */
209 .pin = AT91_PIN_PB16,
210 .is_open_drain = 1,
211};
212
213static struct platform_device w1_device = {
214 .name = "w1-gpio",
215 .id = -1,
216 .dev.platform_data = &w1_gpio_pdata,
217};
218
219static void __init at91_add_device_w1(void)
220{
221 at91_set_GPIO_periph(w1_gpio_pdata.pin, 1);
222 at91_set_multi_drive(w1_gpio_pdata.pin, 1);
223 platform_device_register(&w1_device);
224}
225
226#endif
227
228
229static struct i2c_board_info __initdata foxg20_i2c_devices[] = {
230 {
231 I2C_BOARD_INFO("24c512", 0x50),
232 },
233};
234
235
236static void __init foxg20_board_init(void)
237{
238 /* Serial */
239 at91_add_device_serial();
240 /* USB Host */
241 at91_add_device_usbh(&foxg20_usbh_data);
242 /* USB Device */
243 at91_add_device_udc(&foxg20_udc_data);
244 /* SPI */
245 at91_add_device_spi(foxg20_spi_devices, ARRAY_SIZE(foxg20_spi_devices));
246 /* Ethernet */
247 at91_add_device_eth(&foxg20_macb_data);
248 /* MMC */
249 at91_add_device_mmc(0, &foxg20_mmc_data);
250 /* I2C */
251 at91_add_device_i2c(foxg20_i2c_devices, ARRAY_SIZE(foxg20_i2c_devices));
252 /* LEDs */
253 at91_gpio_leds(foxg20_leds, ARRAY_SIZE(foxg20_leds));
254 /* Push Buttons */
255 foxg20_add_device_buttons();
256#if defined(CONFIG_W1_MASTER_GPIO) || defined(CONFIG_W1_MASTER_GPIO_MODULE)
257 at91_add_device_w1();
258#endif
259}
260
261MACHINE_START(ACMENETUSFOXG20, "Acme Systems srl FOX Board G20")
262 /* Maintainer: Sergio Tanzilli */
Sergio Tanzilli0fb55d32010-10-14 02:06:26 +0200263 .timer = &at91sam926x_timer,
Jean-Christophe PLAGNIOL-VILLARD21d08b92011-04-23 15:28:34 +0800264 .map_io = at91_map_io,
Jean-Christophe PLAGNIOL-VILLARD1b021a32011-04-28 20:19:32 +0800265 .init_early = foxg20_init_early,
Jean-Christophe PLAGNIOL-VILLARD92100c12011-04-23 15:28:34 +0800266 .init_irq = at91_init_irq_default,
Sergio Tanzilli0fb55d32010-10-14 02:06:26 +0200267 .init_machine = foxg20_board_init,
268MACHINE_END