Andrew Victor | ca0a789 | 2008-05-24 17:47:04 +0100 | [diff] [blame] | 1 | /* |
Nico Erfurth | 6939fd4 | 2011-08-30 18:25:52 +0200 | [diff] [blame^] | 2 | * linux/arch/arm/mach-at91/board-usb-a926x.c |
Andrew Victor | ca0a789 | 2008-05-24 17:47:04 +0100 | [diff] [blame] | 3 | * |
| 4 | * Copyright (C) 2005 SAN People |
| 5 | * Copyright (C) 2007 Atmel Corporation. |
| 6 | * Copyright (C) 2007 Calao-systems |
| 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_keys.h> |
| 30 | #include <linux/input.h> |
| 31 | |
Andrew Victor | ca0a789 | 2008-05-24 17:47:04 +0100 | [diff] [blame] | 32 | #include <asm/setup.h> |
| 33 | #include <asm/mach-types.h> |
| 34 | #include <asm/irq.h> |
| 35 | |
| 36 | #include <asm/mach/arch.h> |
| 37 | #include <asm/mach/map.h> |
| 38 | #include <asm/mach/irq.h> |
| 39 | |
Andrew Victor | e505240 | 2008-09-21 21:30:02 +0100 | [diff] [blame] | 40 | #include <mach/hardware.h> |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 41 | #include <mach/board.h> |
| 42 | #include <mach/gpio.h> |
Andrew Victor | 8cdae51 | 2008-10-06 20:05:35 +0100 | [diff] [blame] | 43 | #include <mach/at91sam9_smc.h> |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 44 | #include <mach/at91_shdwc.h> |
Andrew Victor | ca0a789 | 2008-05-24 17:47:04 +0100 | [diff] [blame] | 45 | |
Andrew Victor | 8cdae51 | 2008-10-06 20:05:35 +0100 | [diff] [blame] | 46 | #include "sam9_smc.h" |
Andrew Victor | ca0a789 | 2008-05-24 17:47:04 +0100 | [diff] [blame] | 47 | #include "generic.h" |
| 48 | |
| 49 | |
Jean-Christophe PLAGNIOL-VILLARD | 1b021a3 | 2011-04-28 20:19:32 +0800 | [diff] [blame] | 50 | static void __init ek_init_early(void) |
Andrew Victor | ca0a789 | 2008-05-24 17:47:04 +0100 | [diff] [blame] | 51 | { |
| 52 | /* Initialize processor: 12.00 MHz crystal */ |
Jean-Christophe PLAGNIOL-VILLARD | 21d08b9 | 2011-04-23 15:28:34 +0800 | [diff] [blame] | 53 | at91_initialize(12000000); |
Andrew Victor | ca0a789 | 2008-05-24 17:47:04 +0100 | [diff] [blame] | 54 | |
Samuel R. C. Vale | 4f37940 | 2009-07-10 12:07:15 -0300 | [diff] [blame] | 55 | /* DBGU on ttyS0. (Rx & Tx only) */ |
Andrew Victor | ca0a789 | 2008-05-24 17:47:04 +0100 | [diff] [blame] | 56 | at91_register_uart(0, 0, 0); |
| 57 | |
| 58 | /* set serial console to ttyS0 (ie, DBGU) */ |
| 59 | at91_set_serial_console(0); |
| 60 | } |
| 61 | |
Andrew Victor | ca0a789 | 2008-05-24 17:47:04 +0100 | [diff] [blame] | 62 | /* |
| 63 | * USB Host port |
| 64 | */ |
| 65 | static struct at91_usbh_data __initdata ek_usbh_data = { |
| 66 | .ports = 2, |
| 67 | }; |
| 68 | |
| 69 | /* |
| 70 | * USB Device port |
| 71 | */ |
| 72 | static struct at91_udc_data __initdata ek_udc_data = { |
| 73 | .vbus_pin = AT91_PIN_PB11, |
| 74 | .pullup_pin = 0, /* pull-up driven by UDC */ |
| 75 | }; |
| 76 | |
Nico Erfurth | 6939fd4 | 2011-08-30 18:25:52 +0200 | [diff] [blame^] | 77 | void ek_add_device_udc(void) |
| 78 | { |
| 79 | if (machine_is_usb_a9260()) |
| 80 | ek_udc_data.vbus_pin = AT91_PIN_PC5; |
| 81 | |
| 82 | at91_add_device_udc(&ek_udc_data); |
| 83 | } |
| 84 | |
Andrew Victor | ca0a789 | 2008-05-24 17:47:04 +0100 | [diff] [blame] | 85 | /* |
| 86 | * SPI devices. |
| 87 | */ |
| 88 | static struct spi_board_info ek_spi_devices[] = { |
| 89 | #if !defined(CONFIG_MMC_AT91) |
| 90 | { /* DataFlash chip */ |
| 91 | .modalias = "mtd_dataflash", |
| 92 | .chip_select = 0, |
| 93 | .max_speed_hz = 15 * 1000 * 1000, |
| 94 | .bus_num = 0, |
| 95 | } |
| 96 | #endif |
| 97 | }; |
| 98 | |
Nico Erfurth | 6939fd4 | 2011-08-30 18:25:52 +0200 | [diff] [blame^] | 99 | void ek_add_device_spi(void) |
| 100 | { |
| 101 | if (machine_is_usb_a9263()) |
| 102 | at91_add_device_spi(ek_spi_devices, ARRAY_SIZE(ek_spi_devices)); |
| 103 | } |
| 104 | |
Andrew Victor | ca0a789 | 2008-05-24 17:47:04 +0100 | [diff] [blame] | 105 | /* |
| 106 | * MACB Ethernet device |
| 107 | */ |
| 108 | static struct at91_eth_data __initdata ek_macb_data = { |
| 109 | .phy_irq_pin = AT91_PIN_PE31, |
| 110 | .is_rmii = 1, |
| 111 | }; |
| 112 | |
Nico Erfurth | 6939fd4 | 2011-08-30 18:25:52 +0200 | [diff] [blame^] | 113 | void ek_add_device_eth(void) |
| 114 | { |
| 115 | if (machine_is_usb_a9260()) |
| 116 | ek_macb_data.phy_irq_pin = AT91_PIN_PA31; |
| 117 | |
| 118 | at91_add_device_eth(&ek_macb_data); |
| 119 | } |
| 120 | |
Andrew Victor | ca0a789 | 2008-05-24 17:47:04 +0100 | [diff] [blame] | 121 | /* |
| 122 | * NAND flash |
| 123 | */ |
| 124 | static struct mtd_partition __initdata ek_nand_partition[] = { |
| 125 | { |
Nico Erfurth | 6939fd4 | 2011-08-30 18:25:52 +0200 | [diff] [blame^] | 126 | .name = "Uboot & Kernel", |
Andrew Victor | e505240 | 2008-09-21 21:30:02 +0100 | [diff] [blame] | 127 | .offset = 0, |
| 128 | .size = SZ_16M, |
Andrew Victor | ca0a789 | 2008-05-24 17:47:04 +0100 | [diff] [blame] | 129 | }, |
| 130 | { |
| 131 | .name = "Root FS", |
Andrew Victor | e505240 | 2008-09-21 21:30:02 +0100 | [diff] [blame] | 132 | .offset = MTDPART_OFS_NXTBLK, |
| 133 | .size = 120 * SZ_1M, |
Andrew Victor | ca0a789 | 2008-05-24 17:47:04 +0100 | [diff] [blame] | 134 | }, |
| 135 | { |
| 136 | .name = "FS", |
Andrew Victor | e505240 | 2008-09-21 21:30:02 +0100 | [diff] [blame] | 137 | .offset = MTDPART_OFS_NXTBLK, |
| 138 | .size = 120 * SZ_1M, |
Andrew Victor | ca0a789 | 2008-05-24 17:47:04 +0100 | [diff] [blame] | 139 | } |
| 140 | }; |
| 141 | |
| 142 | static struct mtd_partition * __init nand_partitions(int size, int *num_partitions) |
| 143 | { |
| 144 | *num_partitions = ARRAY_SIZE(ek_nand_partition); |
| 145 | return ek_nand_partition; |
| 146 | } |
| 147 | |
Haavard Skinnemoen | 7c89683 | 2008-07-28 16:57:22 +0100 | [diff] [blame] | 148 | static struct atmel_nand_data __initdata ek_nand_data = { |
Andrew Victor | ca0a789 | 2008-05-24 17:47:04 +0100 | [diff] [blame] | 149 | .ale = 21, |
| 150 | .cle = 22, |
| 151 | // .det_pin = ... not connected |
| 152 | .rdy_pin = AT91_PIN_PA22, |
| 153 | .enable_pin = AT91_PIN_PD15, |
| 154 | .partition_info = nand_partitions, |
Andrew Victor | ca0a789 | 2008-05-24 17:47:04 +0100 | [diff] [blame] | 155 | }; |
| 156 | |
Andrew Victor | 8cdae51 | 2008-10-06 20:05:35 +0100 | [diff] [blame] | 157 | static struct sam9_smc_config __initdata ek_nand_smc_config = { |
| 158 | .ncs_read_setup = 0, |
| 159 | .nrd_setup = 1, |
| 160 | .ncs_write_setup = 0, |
| 161 | .nwe_setup = 1, |
| 162 | |
| 163 | .ncs_read_pulse = 3, |
| 164 | .nrd_pulse = 3, |
| 165 | .ncs_write_pulse = 3, |
| 166 | .nwe_pulse = 3, |
| 167 | |
| 168 | .read_cycle = 5, |
| 169 | .write_cycle = 5, |
| 170 | |
| 171 | .mode = AT91_SMC_READMODE | AT91_SMC_WRITEMODE | AT91_SMC_EXNWMODE_DISABLE | AT91_SMC_DBW_8, |
| 172 | .tdf_cycles = 2, |
| 173 | }; |
| 174 | |
| 175 | static void __init ek_add_device_nand(void) |
| 176 | { |
Nico Erfurth | 6939fd4 | 2011-08-30 18:25:52 +0200 | [diff] [blame^] | 177 | if (machine_is_usb_a9260()) { |
| 178 | ek_nand_data.rdy_pin = AT91_PIN_PC13; |
| 179 | ek_nand_data.enable_pin = AT91_PIN_PC14; |
| 180 | } |
| 181 | |
Andrew Victor | 8cdae51 | 2008-10-06 20:05:35 +0100 | [diff] [blame] | 182 | /* configure chip-select 3 (NAND) */ |
| 183 | sam9_smc_configure(3, &ek_nand_smc_config); |
| 184 | |
| 185 | at91_add_device_nand(&ek_nand_data); |
| 186 | } |
| 187 | |
| 188 | |
Andrew Victor | ca0a789 | 2008-05-24 17:47:04 +0100 | [diff] [blame] | 189 | /* |
| 190 | * GPIO Buttons |
| 191 | */ |
| 192 | #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE) |
| 193 | static struct gpio_keys_button ek_buttons[] = { |
| 194 | { /* USER PUSH BUTTON */ |
| 195 | .code = KEY_ENTER, |
| 196 | .gpio = AT91_PIN_PB10, |
| 197 | .active_low = 1, |
| 198 | .desc = "user_pb", |
| 199 | .wakeup = 1, |
| 200 | } |
| 201 | }; |
| 202 | |
| 203 | static struct gpio_keys_platform_data ek_button_data = { |
| 204 | .buttons = ek_buttons, |
| 205 | .nbuttons = ARRAY_SIZE(ek_buttons), |
| 206 | }; |
| 207 | |
| 208 | static struct platform_device ek_button_device = { |
| 209 | .name = "gpio-keys", |
| 210 | .id = -1, |
| 211 | .num_resources = 0, |
| 212 | .dev = { |
| 213 | .platform_data = &ek_button_data, |
| 214 | } |
| 215 | }; |
| 216 | |
| 217 | static void __init ek_add_device_buttons(void) |
| 218 | { |
| 219 | at91_set_GPIO_periph(AT91_PIN_PB10, 1); /* user push button, pull up enabled */ |
| 220 | at91_set_deglitch(AT91_PIN_PB10, 1); |
| 221 | |
| 222 | platform_device_register(&ek_button_device); |
| 223 | } |
| 224 | #else |
| 225 | static void __init ek_add_device_buttons(void) {} |
| 226 | #endif |
| 227 | |
| 228 | /* |
| 229 | * LEDs |
| 230 | */ |
| 231 | static struct gpio_led ek_leds[] = { |
| 232 | { /* user_led (green) */ |
| 233 | .name = "user_led", |
| 234 | .gpio = AT91_PIN_PB21, |
| 235 | .active_low = 1, |
| 236 | .default_trigger = "heartbeat", |
| 237 | } |
| 238 | }; |
| 239 | |
Nico Erfurth | 6939fd4 | 2011-08-30 18:25:52 +0200 | [diff] [blame^] | 240 | void ek_add_device_leds(void) |
| 241 | { |
| 242 | if (machine_is_usb_a9260()) |
| 243 | ek_leds[0].active_low = 0; |
| 244 | |
| 245 | at91_gpio_leds(ek_leds, ARRAY_SIZE(ek_leds)); |
| 246 | } |
| 247 | |
Andrew Victor | ca0a789 | 2008-05-24 17:47:04 +0100 | [diff] [blame] | 248 | |
| 249 | static void __init ek_board_init(void) |
| 250 | { |
| 251 | /* Serial */ |
| 252 | at91_add_device_serial(); |
| 253 | /* USB Host */ |
| 254 | at91_add_device_usbh(&ek_usbh_data); |
| 255 | /* USB Device */ |
Nico Erfurth | 6939fd4 | 2011-08-30 18:25:52 +0200 | [diff] [blame^] | 256 | ek_add_device_udc(); |
Andrew Victor | ca0a789 | 2008-05-24 17:47:04 +0100 | [diff] [blame] | 257 | /* SPI */ |
Nico Erfurth | 6939fd4 | 2011-08-30 18:25:52 +0200 | [diff] [blame^] | 258 | ek_add_device_spi(); |
Andrew Victor | ca0a789 | 2008-05-24 17:47:04 +0100 | [diff] [blame] | 259 | /* Ethernet */ |
Nico Erfurth | 6939fd4 | 2011-08-30 18:25:52 +0200 | [diff] [blame^] | 260 | ek_add_device_eth(); |
Andrew Victor | ca0a789 | 2008-05-24 17:47:04 +0100 | [diff] [blame] | 261 | /* NAND */ |
Andrew Victor | 8cdae51 | 2008-10-06 20:05:35 +0100 | [diff] [blame] | 262 | ek_add_device_nand(); |
Andrew Victor | ca0a789 | 2008-05-24 17:47:04 +0100 | [diff] [blame] | 263 | /* I2C */ |
| 264 | at91_add_device_i2c(NULL, 0); |
| 265 | /* Push Buttons */ |
| 266 | ek_add_device_buttons(); |
| 267 | /* LEDs */ |
Nico Erfurth | 6939fd4 | 2011-08-30 18:25:52 +0200 | [diff] [blame^] | 268 | ek_add_device_leds(); |
Andrew Victor | ca0a789 | 2008-05-24 17:47:04 +0100 | [diff] [blame] | 269 | /* shutdown controller, wakeup button (5 msec low) */ |
| 270 | at91_sys_write(AT91_SHDW_MR, AT91_SHDW_CPTWK0_(10) | AT91_SHDW_WKMODE0_LOW |
| 271 | | AT91_SHDW_RTTWKEN); |
| 272 | } |
| 273 | |
| 274 | MACHINE_START(USB_A9263, "CALAO USB_A9263") |
| 275 | /* Maintainer: calao-systems */ |
Andrew Victor | ca0a789 | 2008-05-24 17:47:04 +0100 | [diff] [blame] | 276 | .timer = &at91sam926x_timer, |
Jean-Christophe PLAGNIOL-VILLARD | 21d08b9 | 2011-04-23 15:28:34 +0800 | [diff] [blame] | 277 | .map_io = at91_map_io, |
Jean-Christophe PLAGNIOL-VILLARD | 1b021a3 | 2011-04-28 20:19:32 +0800 | [diff] [blame] | 278 | .init_early = ek_init_early, |
Jean-Christophe PLAGNIOL-VILLARD | 92100c1 | 2011-04-23 15:28:34 +0800 | [diff] [blame] | 279 | .init_irq = at91_init_irq_default, |
Andrew Victor | ca0a789 | 2008-05-24 17:47:04 +0100 | [diff] [blame] | 280 | .init_machine = ek_board_init, |
| 281 | MACHINE_END |
Nico Erfurth | 6939fd4 | 2011-08-30 18:25:52 +0200 | [diff] [blame^] | 282 | |
| 283 | MACHINE_START(USB_A9260, "CALAO USB_A9260") |
| 284 | /* Maintainer: calao-systems */ |
| 285 | .timer = &at91sam926x_timer, |
| 286 | .map_io = at91_map_io, |
| 287 | .init_early = ek_init_early, |
| 288 | .init_irq = at91_init_irq_default, |
| 289 | .init_machine = ek_board_init, |
| 290 | MACHINE_END |