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