Boaz Harrosh - fix email in Documentation
[sfrench/cifs-2.6.git] / arch / arm / mach-at91 / board-foxg20.c
1 /*
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/at91sam9_smc.h>
45
46 #include "at91_aic.h"
47 #include "board.h"
48 #include "sam9_smc.h"
49 #include "generic.h"
50 #include "gpio.h"
51
52 /*
53  * The FOX Board G20 hardware comes as the "Netus G20" board with
54  * just the cpu, ram, dataflash and two header connectors.
55  * This is plugged into the FOX Board which provides the ethernet,
56  * usb, rtc, leds, switch, ...
57  *
58  * For more info visit: http://www.acmesystems.it/foxg20
59  */
60
61
62 static void __init foxg20_init_early(void)
63 {
64         /* Initialize processor: 18.432 MHz crystal */
65         at91_initialize(18432000);
66 }
67
68 /*
69  * USB Host port
70  */
71 static struct at91_usbh_data __initdata foxg20_usbh_data = {
72         .ports          = 2,
73         .vbus_pin       = {-EINVAL, -EINVAL},
74         .overcurrent_pin= {-EINVAL, -EINVAL},
75 };
76
77 /*
78  * USB Device port
79  */
80 static struct at91_udc_data __initdata foxg20_udc_data = {
81         .vbus_pin       = AT91_PIN_PC6,
82         .pullup_pin     = -EINVAL,              /* pull-up driven by UDC */
83 };
84
85
86 /*
87  * SPI devices.
88  */
89 static struct spi_board_info foxg20_spi_devices[] = {
90 #if !IS_ENABLED(CONFIG_MMC_ATMELMCI)
91         {
92                 .modalias       = "mtd_dataflash",
93                 .chip_select    = 1,
94                 .max_speed_hz   = 15 * 1000 * 1000,
95                 .bus_num        = 0,
96         },
97 #endif
98 };
99
100
101 /*
102  * MACB Ethernet device
103  */
104 static struct macb_platform_data __initdata foxg20_macb_data = {
105         .phy_irq_pin    = AT91_PIN_PA7,
106         .is_rmii        = 1,
107 };
108
109 /*
110  * MCI (SD/MMC)
111  * det_pin, wp_pin and vcc_pin are not connected
112  */
113 static struct mci_platform_data __initdata foxg20_mci0_data = {
114         .slot[1] = {
115                 .bus_width      = 4,
116                 .detect_pin     = -EINVAL,
117                 .wp_pin         = -EINVAL,
118         },
119 };
120
121
122 /*
123  * LEDs
124  */
125 static struct gpio_led foxg20_leds[] = {
126         {       /* user led, red */
127                 .name                   = "user_led",
128                 .gpio                   = AT91_PIN_PC7,
129                 .active_low             = 0,
130                 .default_trigger        = "heartbeat",
131         },
132 };
133
134
135 /*
136  * GPIO Buttons
137  */
138 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
139 static struct gpio_keys_button foxg20_buttons[] = {
140         {
141                 .gpio           = AT91_PIN_PC4,
142                 .code           = BTN_1,
143                 .desc           = "Button 1",
144                 .active_low     = 1,
145                 .wakeup         = 1,
146         },
147 };
148
149 static struct gpio_keys_platform_data foxg20_button_data = {
150         .buttons        = foxg20_buttons,
151         .nbuttons       = ARRAY_SIZE(foxg20_buttons),
152 };
153
154 static struct platform_device foxg20_button_device = {
155         .name           = "gpio-keys",
156         .id             = -1,
157         .num_resources  = 0,
158         .dev            = {
159                 .platform_data  = &foxg20_button_data,
160         }
161 };
162
163 static void __init foxg20_add_device_buttons(void)
164 {
165         at91_set_gpio_input(AT91_PIN_PC4, 1);   /* btn1 */
166         at91_set_deglitch(AT91_PIN_PC4, 1);
167
168         platform_device_register(&foxg20_button_device);
169 }
170 #else
171 static void __init foxg20_add_device_buttons(void) {}
172 #endif
173
174
175 #if defined(CONFIG_W1_MASTER_GPIO) || defined(CONFIG_W1_MASTER_GPIO_MODULE)
176 static struct w1_gpio_platform_data w1_gpio_pdata = {
177         /* If you choose to use a pin other than PB16 it needs to be 3.3V */
178         .pin            = AT91_PIN_PB16,
179         .is_open_drain  = 1,
180         .ext_pullup_enable_pin  = -EINVAL,
181 };
182
183 static struct platform_device w1_device = {
184         .name                   = "w1-gpio",
185         .id                     = -1,
186         .dev.platform_data      = &w1_gpio_pdata,
187 };
188
189 static void __init at91_add_device_w1(void)
190 {
191         at91_set_GPIO_periph(w1_gpio_pdata.pin, 1);
192         at91_set_multi_drive(w1_gpio_pdata.pin, 1);
193         platform_device_register(&w1_device);
194 }
195
196 #endif
197
198
199 static struct i2c_board_info __initdata foxg20_i2c_devices[] = {
200         {
201                 I2C_BOARD_INFO("24c512", 0x50),
202         },
203 };
204
205
206 static void __init foxg20_board_init(void)
207 {
208         /* Serial */
209         /* DBGU on ttyS0. (Rx & Tx only) */
210         at91_register_uart(0, 0, 0);
211
212         /* USART0 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */
213         at91_register_uart(AT91SAM9260_ID_US0, 1,
214                                 ATMEL_UART_CTS
215                                 | ATMEL_UART_RTS
216                                 | ATMEL_UART_DTR
217                                 | ATMEL_UART_DSR
218                                 | ATMEL_UART_DCD
219                                 | ATMEL_UART_RI);
220
221         /* USART1 on ttyS2. (Rx, Tx, RTS, CTS) */
222         at91_register_uart(AT91SAM9260_ID_US1, 2,
223                 ATMEL_UART_CTS
224                 | ATMEL_UART_RTS);
225
226         /* USART2 on ttyS3. (Rx & Tx only) */
227         at91_register_uart(AT91SAM9260_ID_US2, 3, 0);
228
229         /* USART3 on ttyS4. (Rx, Tx, RTS, CTS) */
230         at91_register_uart(AT91SAM9260_ID_US3, 4,
231                 ATMEL_UART_CTS
232                 | ATMEL_UART_RTS);
233
234         /* USART4 on ttyS5. (Rx & Tx only) */
235         at91_register_uart(AT91SAM9260_ID_US4, 5, 0);
236
237         /* USART5 on ttyS6. (Rx & Tx only) */
238         at91_register_uart(AT91SAM9260_ID_US5, 6, 0);
239
240         /* Set the internal pull-up resistor on DRXD */
241         at91_set_A_periph(AT91_PIN_PB14, 1);
242         at91_add_device_serial();
243         /* USB Host */
244         at91_add_device_usbh(&foxg20_usbh_data);
245         /* USB Device */
246         at91_add_device_udc(&foxg20_udc_data);
247         /* SPI */
248         at91_add_device_spi(foxg20_spi_devices, ARRAY_SIZE(foxg20_spi_devices));
249         /* Ethernet */
250         at91_add_device_eth(&foxg20_macb_data);
251         /* MMC */
252         at91_add_device_mci(0, &foxg20_mci0_data);
253         /* I2C */
254         at91_add_device_i2c(foxg20_i2c_devices, ARRAY_SIZE(foxg20_i2c_devices));
255         /* LEDs */
256         at91_gpio_leds(foxg20_leds, ARRAY_SIZE(foxg20_leds));
257         /* Push Buttons */
258         foxg20_add_device_buttons();
259 #if defined(CONFIG_W1_MASTER_GPIO) || defined(CONFIG_W1_MASTER_GPIO_MODULE)
260         at91_add_device_w1();
261 #endif
262 }
263
264 MACHINE_START(ACMENETUSFOXG20, "Acme Systems srl FOX Board G20")
265         /* Maintainer: Sergio Tanzilli */
266         .init_time      = at91sam926x_pit_init,
267         .map_io         = at91_map_io,
268         .handle_irq     = at91_aic_handle_irq,
269         .init_early     = foxg20_init_early,
270         .init_irq       = at91_init_irq_default,
271         .init_machine   = foxg20_board_init,
272 MACHINE_END