Eric Bénard | 41a353d | 2009-07-30 07:20:03 +0100 | [diff] [blame] | 1 | /* |
| 2 | * linux/arch/arm/mach-at91/board-cpu9krea.c |
| 3 | * |
| 4 | * Copyright (C) 2005 SAN People |
| 5 | * Copyright (C) 2006 Atmel |
| 6 | * Copyright (C) 2009 Eric Benard - eric@eukrea.com |
| 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> |
Russell King | 2f8163b | 2011-07-26 10:53:52 +0100 | [diff] [blame] | 24 | #include <linux/gpio.h> |
Eric Bénard | 41a353d | 2009-07-30 07:20:03 +0100 | [diff] [blame] | 25 | #include <linux/init.h> |
| 26 | #include <linux/mm.h> |
| 27 | #include <linux/module.h> |
| 28 | #include <linux/platform_device.h> |
| 29 | #include <linux/clk.h> |
| 30 | #include <linux/gpio_keys.h> |
| 31 | #include <linux/input.h> |
| 32 | #include <linux/mtd/physmap.h> |
| 33 | |
| 34 | #include <asm/setup.h> |
| 35 | #include <asm/mach-types.h> |
| 36 | #include <asm/irq.h> |
| 37 | |
| 38 | #include <asm/mach/arch.h> |
| 39 | #include <asm/mach/map.h> |
| 40 | #include <asm/mach/irq.h> |
| 41 | |
| 42 | #include <mach/hardware.h> |
Eric Bénard | 41a353d | 2009-07-30 07:20:03 +0100 | [diff] [blame] | 43 | #include <mach/at91sam9_smc.h> |
| 44 | #include <mach/at91sam9260_matrix.h> |
Jean-Christophe PLAGNIOL-VILLARD | 4342d64 | 2011-11-27 23:15:50 +0800 | [diff] [blame] | 45 | #include <mach/at91_matrix.h> |
Eric Bénard | 41a353d | 2009-07-30 07:20:03 +0100 | [diff] [blame] | 46 | |
Jean-Christophe PLAGNIOL-VILLARD | a510b9b | 2012-10-30 06:41:28 +0800 | [diff] [blame] | 47 | #include "at91_aic.h" |
Jean-Christophe PLAGNIOL-VILLARD | 43d2f53 | 2012-10-30 05:14:17 +0800 | [diff] [blame] | 48 | #include "board.h" |
Eric Bénard | 41a353d | 2009-07-30 07:20:03 +0100 | [diff] [blame] | 49 | #include "sam9_smc.h" |
| 50 | #include "generic.h" |
| 51 | |
Jean-Christophe PLAGNIOL-VILLARD | 1b021a3 | 2011-04-28 20:19:32 +0800 | [diff] [blame] | 52 | static void __init cpu9krea_init_early(void) |
Eric Bénard | 41a353d | 2009-07-30 07:20:03 +0100 | [diff] [blame] | 53 | { |
| 54 | /* Initialize processor: 18.432 MHz crystal */ |
Jean-Christophe PLAGNIOL-VILLARD | 21d08b9 | 2011-04-23 15:28:34 +0800 | [diff] [blame] | 55 | at91_initialize(18432000); |
Eric Bénard | 41a353d | 2009-07-30 07:20:03 +0100 | [diff] [blame] | 56 | } |
| 57 | |
Eric Bénard | 41a353d | 2009-07-30 07:20:03 +0100 | [diff] [blame] | 58 | /* |
| 59 | * USB Host port |
| 60 | */ |
| 61 | static struct at91_usbh_data __initdata cpu9krea_usbh_data = { |
| 62 | .ports = 2, |
Jean-Christophe PLAGNIOL-VILLARD | 63b4c29 | 2011-11-25 01:51:06 +0800 | [diff] [blame] | 63 | .vbus_pin = {-EINVAL, -EINVAL}, |
| 64 | .overcurrent_pin= {-EINVAL, -EINVAL}, |
Eric Bénard | 41a353d | 2009-07-30 07:20:03 +0100 | [diff] [blame] | 65 | }; |
| 66 | |
| 67 | /* |
| 68 | * USB Device port |
| 69 | */ |
| 70 | static struct at91_udc_data __initdata cpu9krea_udc_data = { |
| 71 | .vbus_pin = AT91_PIN_PC8, |
Jean-Christophe PLAGNIOL-VILLARD | 63b4c29 | 2011-11-25 01:51:06 +0800 | [diff] [blame] | 72 | .pullup_pin = -EINVAL, /* pull-up driven by UDC */ |
Eric Bénard | 41a353d | 2009-07-30 07:20:03 +0100 | [diff] [blame] | 73 | }; |
| 74 | |
| 75 | /* |
| 76 | * MACB Ethernet device |
| 77 | */ |
Jamie Iles | 84e0cdb | 2011-03-08 20:17:06 +0000 | [diff] [blame] | 78 | static struct macb_platform_data __initdata cpu9krea_macb_data = { |
Jean-Christophe PLAGNIOL-VILLARD | 63b4c29 | 2011-11-25 01:51:06 +0800 | [diff] [blame] | 79 | .phy_irq_pin = -EINVAL, |
Eric Bénard | 41a353d | 2009-07-30 07:20:03 +0100 | [diff] [blame] | 80 | .is_rmii = 1, |
| 81 | }; |
| 82 | |
| 83 | /* |
| 84 | * NAND flash |
| 85 | */ |
| 86 | static struct atmel_nand_data __initdata cpu9krea_nand_data = { |
| 87 | .ale = 21, |
| 88 | .cle = 22, |
| 89 | .rdy_pin = AT91_PIN_PC13, |
| 90 | .enable_pin = AT91_PIN_PC14, |
| 91 | .bus_width_16 = 0, |
Jean-Christophe PLAGNIOL-VILLARD | 63b4c29 | 2011-11-25 01:51:06 +0800 | [diff] [blame] | 92 | .det_pin = -EINVAL, |
Jean-Christophe PLAGNIOL-VILLARD | bf4289c | 2011-12-29 14:43:24 +0800 | [diff] [blame] | 93 | .ecc_mode = NAND_ECC_SOFT, |
Eric Bénard | 41a353d | 2009-07-30 07:20:03 +0100 | [diff] [blame] | 94 | }; |
| 95 | |
| 96 | #ifdef CONFIG_MACH_CPU9260 |
| 97 | static struct sam9_smc_config __initdata cpu9krea_nand_smc_config = { |
| 98 | .ncs_read_setup = 0, |
| 99 | .nrd_setup = 1, |
| 100 | .ncs_write_setup = 0, |
| 101 | .nwe_setup = 1, |
| 102 | |
| 103 | .ncs_read_pulse = 3, |
| 104 | .nrd_pulse = 3, |
| 105 | .ncs_write_pulse = 3, |
| 106 | .nwe_pulse = 3, |
| 107 | |
| 108 | .read_cycle = 5, |
| 109 | .write_cycle = 5, |
| 110 | |
| 111 | .mode = AT91_SMC_READMODE | AT91_SMC_WRITEMODE |
| 112 | | AT91_SMC_EXNWMODE_DISABLE | AT91_SMC_DBW_8, |
| 113 | .tdf_cycles = 2, |
| 114 | }; |
| 115 | #else |
| 116 | static struct sam9_smc_config __initdata cpu9krea_nand_smc_config = { |
| 117 | .ncs_read_setup = 0, |
| 118 | .nrd_setup = 2, |
| 119 | .ncs_write_setup = 0, |
| 120 | .nwe_setup = 2, |
| 121 | |
| 122 | .ncs_read_pulse = 4, |
| 123 | .nrd_pulse = 4, |
| 124 | .ncs_write_pulse = 4, |
| 125 | .nwe_pulse = 4, |
| 126 | |
| 127 | .read_cycle = 7, |
| 128 | .write_cycle = 7, |
| 129 | |
| 130 | .mode = AT91_SMC_READMODE | AT91_SMC_WRITEMODE |
| 131 | | AT91_SMC_EXNWMODE_DISABLE | AT91_SMC_DBW_8, |
| 132 | .tdf_cycles = 3, |
| 133 | }; |
| 134 | #endif |
| 135 | |
| 136 | static void __init cpu9krea_add_device_nand(void) |
| 137 | { |
Jean-Christophe PLAGNIOL-VILLARD | faee0cc | 2011-10-14 01:37:09 +0800 | [diff] [blame] | 138 | sam9_smc_configure(0, 3, &cpu9krea_nand_smc_config); |
Eric Bénard | 41a353d | 2009-07-30 07:20:03 +0100 | [diff] [blame] | 139 | at91_add_device_nand(&cpu9krea_nand_data); |
| 140 | } |
| 141 | |
| 142 | /* |
| 143 | * NOR flash |
| 144 | */ |
| 145 | static struct physmap_flash_data cpuat9260_nor_data = { |
| 146 | .width = 2, |
| 147 | }; |
| 148 | |
| 149 | #define NOR_BASE AT91_CHIPSELECT_0 |
| 150 | #define NOR_SIZE SZ_64M |
| 151 | |
| 152 | static struct resource nor_flash_resources[] = { |
| 153 | { |
| 154 | .start = NOR_BASE, |
| 155 | .end = NOR_BASE + NOR_SIZE - 1, |
| 156 | .flags = IORESOURCE_MEM, |
| 157 | } |
| 158 | }; |
| 159 | |
| 160 | static struct platform_device cpu9krea_nor_flash = { |
| 161 | .name = "physmap-flash", |
| 162 | .id = 0, |
| 163 | .dev = { |
| 164 | .platform_data = &cpuat9260_nor_data, |
| 165 | }, |
| 166 | .resource = nor_flash_resources, |
| 167 | .num_resources = ARRAY_SIZE(nor_flash_resources), |
| 168 | }; |
| 169 | |
| 170 | #ifdef CONFIG_MACH_CPU9260 |
| 171 | static struct sam9_smc_config __initdata cpu9krea_nor_smc_config = { |
| 172 | .ncs_read_setup = 0, |
| 173 | .nrd_setup = 1, |
| 174 | .ncs_write_setup = 0, |
| 175 | .nwe_setup = 1, |
| 176 | |
| 177 | .ncs_read_pulse = 10, |
| 178 | .nrd_pulse = 10, |
| 179 | .ncs_write_pulse = 6, |
| 180 | .nwe_pulse = 6, |
| 181 | |
| 182 | .read_cycle = 12, |
| 183 | .write_cycle = 8, |
| 184 | |
| 185 | .mode = AT91_SMC_READMODE | AT91_SMC_WRITEMODE |
| 186 | | AT91_SMC_EXNWMODE_DISABLE | AT91_SMC_BAT_WRITE |
| 187 | | AT91_SMC_DBW_16, |
| 188 | .tdf_cycles = 2, |
| 189 | }; |
| 190 | #else |
| 191 | static struct sam9_smc_config __initdata cpu9krea_nor_smc_config = { |
| 192 | .ncs_read_setup = 0, |
| 193 | .nrd_setup = 1, |
| 194 | .ncs_write_setup = 0, |
| 195 | .nwe_setup = 1, |
| 196 | |
| 197 | .ncs_read_pulse = 13, |
| 198 | .nrd_pulse = 13, |
| 199 | .ncs_write_pulse = 8, |
| 200 | .nwe_pulse = 8, |
| 201 | |
| 202 | .read_cycle = 15, |
| 203 | .write_cycle = 10, |
| 204 | |
| 205 | .mode = AT91_SMC_READMODE | AT91_SMC_WRITEMODE |
| 206 | | AT91_SMC_EXNWMODE_DISABLE | AT91_SMC_BAT_WRITE |
| 207 | | AT91_SMC_DBW_16, |
| 208 | .tdf_cycles = 2, |
| 209 | }; |
| 210 | #endif |
| 211 | |
| 212 | static __init void cpu9krea_add_device_nor(void) |
| 213 | { |
| 214 | unsigned long csa; |
| 215 | |
Jean-Christophe PLAGNIOL-VILLARD | 4342d64 | 2011-11-27 23:15:50 +0800 | [diff] [blame] | 216 | csa = at91_matrix_read(AT91_MATRIX_EBICSA); |
| 217 | at91_matrix_write(AT91_MATRIX_EBICSA, csa | AT91_MATRIX_VDDIOMSEL_3_3V); |
Eric Bénard | 41a353d | 2009-07-30 07:20:03 +0100 | [diff] [blame] | 218 | |
| 219 | /* configure chip-select 0 (NOR) */ |
Jean-Christophe PLAGNIOL-VILLARD | faee0cc | 2011-10-14 01:37:09 +0800 | [diff] [blame] | 220 | sam9_smc_configure(0, 0, &cpu9krea_nor_smc_config); |
Eric Bénard | 41a353d | 2009-07-30 07:20:03 +0100 | [diff] [blame] | 221 | |
| 222 | platform_device_register(&cpu9krea_nor_flash); |
| 223 | } |
| 224 | |
| 225 | /* |
| 226 | * LEDs |
| 227 | */ |
| 228 | static struct gpio_led cpu9krea_leds[] = { |
| 229 | { /* LED1 */ |
| 230 | .name = "LED1", |
| 231 | .gpio = AT91_PIN_PC11, |
| 232 | .active_low = 1, |
| 233 | .default_trigger = "timer", |
| 234 | }, |
| 235 | { /* LED2 */ |
| 236 | .name = "LED2", |
| 237 | .gpio = AT91_PIN_PC12, |
| 238 | .active_low = 1, |
| 239 | .default_trigger = "heartbeat", |
| 240 | }, |
| 241 | { /* LED3 */ |
| 242 | .name = "LED3", |
| 243 | .gpio = AT91_PIN_PC7, |
| 244 | .active_low = 1, |
| 245 | .default_trigger = "none", |
| 246 | }, |
| 247 | { /* LED4 */ |
| 248 | .name = "LED4", |
| 249 | .gpio = AT91_PIN_PC9, |
| 250 | .active_low = 1, |
| 251 | .default_trigger = "none", |
| 252 | } |
| 253 | }; |
| 254 | |
| 255 | static struct i2c_board_info __initdata cpu9krea_i2c_devices[] = { |
| 256 | { |
Paul Bolle | c1cb59f | 2012-05-24 16:30:29 +0200 | [diff] [blame] | 257 | I2C_BOARD_INFO("ds1339", 0x68), |
Eric Bénard | 41a353d | 2009-07-30 07:20:03 +0100 | [diff] [blame] | 258 | }, |
| 259 | }; |
| 260 | |
| 261 | /* |
| 262 | * GPIO Buttons |
| 263 | */ |
| 264 | #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE) |
| 265 | static struct gpio_keys_button cpu9krea_buttons[] = { |
| 266 | { |
| 267 | .gpio = AT91_PIN_PC3, |
| 268 | .code = BTN_0, |
| 269 | .desc = "BP1", |
| 270 | .active_low = 1, |
| 271 | .wakeup = 1, |
| 272 | }, |
| 273 | { |
| 274 | .gpio = AT91_PIN_PB20, |
| 275 | .code = BTN_1, |
| 276 | .desc = "BP2", |
| 277 | .active_low = 1, |
| 278 | .wakeup = 1, |
| 279 | } |
| 280 | }; |
| 281 | |
| 282 | static struct gpio_keys_platform_data cpu9krea_button_data = { |
| 283 | .buttons = cpu9krea_buttons, |
| 284 | .nbuttons = ARRAY_SIZE(cpu9krea_buttons), |
| 285 | }; |
| 286 | |
| 287 | static struct platform_device cpu9krea_button_device = { |
| 288 | .name = "gpio-keys", |
| 289 | .id = -1, |
| 290 | .num_resources = 0, |
| 291 | .dev = { |
| 292 | .platform_data = &cpu9krea_button_data, |
| 293 | } |
| 294 | }; |
| 295 | |
| 296 | static void __init cpu9krea_add_device_buttons(void) |
| 297 | { |
| 298 | at91_set_gpio_input(AT91_PIN_PC3, 1); /* BP1 */ |
| 299 | at91_set_deglitch(AT91_PIN_PC3, 1); |
| 300 | at91_set_gpio_input(AT91_PIN_PB20, 1); /* BP2 */ |
| 301 | at91_set_deglitch(AT91_PIN_PB20, 1); |
| 302 | |
| 303 | platform_device_register(&cpu9krea_button_device); |
| 304 | } |
| 305 | #else |
| 306 | static void __init cpu9krea_add_device_buttons(void) |
| 307 | { |
| 308 | } |
| 309 | #endif |
| 310 | |
| 311 | /* |
| 312 | * MCI (SD/MMC) |
| 313 | */ |
Ludovic Desroches | 4cf3326 | 2012-05-21 12:23:27 +0200 | [diff] [blame] | 314 | static struct mci_platform_data __initdata cpu9krea_mci0_data = { |
| 315 | .slot[0] = { |
| 316 | .bus_width = 4, |
| 317 | .detect_pin = AT91_PIN_PA29, |
| 318 | .wp_pin = -EINVAL, |
| 319 | }, |
Eric Bénard | 41a353d | 2009-07-30 07:20:03 +0100 | [diff] [blame] | 320 | }; |
| 321 | |
| 322 | static void __init cpu9krea_board_init(void) |
| 323 | { |
| 324 | /* NOR */ |
| 325 | cpu9krea_add_device_nor(); |
| 326 | /* Serial */ |
Jean-Christophe PLAGNIOL-VILLARD | 71b149b | 2012-04-05 14:14:28 +0800 | [diff] [blame] | 327 | /* DGBU on ttyS0. (Rx & Tx only) */ |
| 328 | at91_register_uart(0, 0, 0); |
| 329 | |
| 330 | /* USART0 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */ |
| 331 | at91_register_uart(AT91SAM9260_ID_US0, 1, ATMEL_UART_CTS | |
| 332 | ATMEL_UART_RTS | ATMEL_UART_DTR | ATMEL_UART_DSR | |
| 333 | ATMEL_UART_DCD | ATMEL_UART_RI); |
| 334 | |
| 335 | /* USART1 on ttyS2. (Rx, Tx, RTS, CTS) */ |
| 336 | at91_register_uart(AT91SAM9260_ID_US1, 2, ATMEL_UART_CTS | |
| 337 | ATMEL_UART_RTS); |
| 338 | |
| 339 | /* USART2 on ttyS3. (Rx, Tx, RTS, CTS) */ |
| 340 | at91_register_uart(AT91SAM9260_ID_US2, 3, ATMEL_UART_CTS | |
| 341 | ATMEL_UART_RTS); |
| 342 | |
| 343 | /* USART3 on ttyS4. (Rx, Tx) */ |
| 344 | at91_register_uart(AT91SAM9260_ID_US3, 4, 0); |
| 345 | |
| 346 | /* USART4 on ttyS5. (Rx, Tx) */ |
| 347 | at91_register_uart(AT91SAM9260_ID_US4, 5, 0); |
| 348 | |
| 349 | /* USART5 on ttyS6. (Rx, Tx) */ |
| 350 | at91_register_uart(AT91SAM9260_ID_US5, 6, 0); |
Eric Bénard | 41a353d | 2009-07-30 07:20:03 +0100 | [diff] [blame] | 351 | at91_add_device_serial(); |
| 352 | /* USB Host */ |
| 353 | at91_add_device_usbh(&cpu9krea_usbh_data); |
| 354 | /* USB Device */ |
| 355 | at91_add_device_udc(&cpu9krea_udc_data); |
| 356 | /* NAND */ |
| 357 | cpu9krea_add_device_nand(); |
| 358 | /* Ethernet */ |
| 359 | at91_add_device_eth(&cpu9krea_macb_data); |
| 360 | /* MMC */ |
Ludovic Desroches | 4cf3326 | 2012-05-21 12:23:27 +0200 | [diff] [blame] | 361 | at91_add_device_mci(0, &cpu9krea_mci0_data); |
Eric Bénard | 41a353d | 2009-07-30 07:20:03 +0100 | [diff] [blame] | 362 | /* I2C */ |
| 363 | at91_add_device_i2c(cpu9krea_i2c_devices, |
| 364 | ARRAY_SIZE(cpu9krea_i2c_devices)); |
| 365 | /* LEDs */ |
| 366 | at91_gpio_leds(cpu9krea_leds, ARRAY_SIZE(cpu9krea_leds)); |
| 367 | /* Push Buttons */ |
| 368 | cpu9krea_add_device_buttons(); |
| 369 | } |
| 370 | |
| 371 | #ifdef CONFIG_MACH_CPU9260 |
| 372 | MACHINE_START(CPUAT9260, "Eukrea CPU9260") |
| 373 | #else |
| 374 | MACHINE_START(CPUAT9G20, "Eukrea CPU9G20") |
| 375 | #endif |
| 376 | /* Maintainer: Eric Benard - EUKREA Electromatique */ |
Eric Bénard | 41a353d | 2009-07-30 07:20:03 +0100 | [diff] [blame] | 377 | .timer = &at91sam926x_timer, |
Jean-Christophe PLAGNIOL-VILLARD | 21d08b9 | 2011-04-23 15:28:34 +0800 | [diff] [blame] | 378 | .map_io = at91_map_io, |
Ludovic Desroches | 3e13546 | 2012-06-11 15:38:03 +0200 | [diff] [blame] | 379 | .handle_irq = at91_aic_handle_irq, |
Jean-Christophe PLAGNIOL-VILLARD | 1b021a3 | 2011-04-28 20:19:32 +0800 | [diff] [blame] | 380 | .init_early = cpu9krea_init_early, |
Jean-Christophe PLAGNIOL-VILLARD | 92100c1 | 2011-04-23 15:28:34 +0800 | [diff] [blame] | 381 | .init_irq = at91_init_irq_default, |
Eric Bénard | 41a353d | 2009-07-30 07:20:03 +0100 | [diff] [blame] | 382 | .init_machine = cpu9krea_board_init, |
| 383 | MACHINE_END |