Andrew Victor | ffc63b7 | 2008-10-06 20:13:53 +0100 | [diff] [blame] | 1 | /* |
| 2 | * linux/arch/arm/mach-at91/board-neocore926.c |
| 3 | * |
| 4 | * Copyright (C) 2005 SAN People |
| 5 | * Copyright (C) 2007 Atmel Corporation |
| 6 | * Copyright (C) 2008 ADENEO. |
| 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> |
Andrew Victor | ffc63b7 | 2008-10-06 20:13:53 +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/spi/spi.h> |
| 30 | #include <linux/spi/ads7846.h> |
| 31 | #include <linux/fb.h> |
| 32 | #include <linux/gpio_keys.h> |
| 33 | #include <linux/input.h> |
| 34 | |
| 35 | #include <video/atmel_lcdc.h> |
| 36 | |
| 37 | #include <asm/setup.h> |
| 38 | #include <asm/mach-types.h> |
| 39 | #include <asm/irq.h> |
| 40 | #include <asm/sizes.h> |
| 41 | |
| 42 | #include <asm/mach/arch.h> |
| 43 | #include <asm/mach/map.h> |
| 44 | #include <asm/mach/irq.h> |
| 45 | |
| 46 | #include <mach/hardware.h> |
| 47 | #include <mach/board.h> |
Ludovic Desroches | 3e13546 | 2012-06-11 15:38:03 +0200 | [diff] [blame] | 48 | #include <mach/at91_aic.h> |
Andrew Victor | ffc63b7 | 2008-10-06 20:13:53 +0100 | [diff] [blame] | 49 | #include <mach/at91sam9_smc.h> |
| 50 | |
| 51 | #include "sam9_smc.h" |
| 52 | #include "generic.h" |
| 53 | |
| 54 | |
Jean-Christophe PLAGNIOL-VILLARD | 1b021a3 | 2011-04-28 20:19:32 +0800 | [diff] [blame] | 55 | static void __init neocore926_init_early(void) |
Andrew Victor | ffc63b7 | 2008-10-06 20:13:53 +0100 | [diff] [blame] | 56 | { |
| 57 | /* Initialize processor: 20 MHz crystal */ |
Jean-Christophe PLAGNIOL-VILLARD | 21d08b9 | 2011-04-23 15:28:34 +0800 | [diff] [blame] | 58 | at91_initialize(20000000); |
Andrew Victor | ffc63b7 | 2008-10-06 20:13:53 +0100 | [diff] [blame] | 59 | } |
| 60 | |
Andrew Victor | ffc63b7 | 2008-10-06 20:13:53 +0100 | [diff] [blame] | 61 | /* |
| 62 | * USB Host port |
| 63 | */ |
| 64 | static struct at91_usbh_data __initdata neocore926_usbh_data = { |
| 65 | .ports = 2, |
| 66 | .vbus_pin = { AT91_PIN_PA24, AT91_PIN_PA21 }, |
Jean-Christophe PLAGNIOL-VILLARD | 63b4c29 | 2011-11-25 01:51:06 +0800 | [diff] [blame] | 67 | .overcurrent_pin= {-EINVAL, -EINVAL}, |
Andrew Victor | ffc63b7 | 2008-10-06 20:13:53 +0100 | [diff] [blame] | 68 | }; |
| 69 | |
| 70 | /* |
| 71 | * USB Device port |
| 72 | */ |
| 73 | static struct at91_udc_data __initdata neocore926_udc_data = { |
| 74 | .vbus_pin = AT91_PIN_PA25, |
Jean-Christophe PLAGNIOL-VILLARD | 63b4c29 | 2011-11-25 01:51:06 +0800 | [diff] [blame] | 75 | .pullup_pin = -EINVAL, /* pull-up driven by UDC */ |
Andrew Victor | ffc63b7 | 2008-10-06 20:13:53 +0100 | [diff] [blame] | 76 | }; |
| 77 | |
| 78 | |
| 79 | /* |
| 80 | * ADS7846 Touchscreen |
| 81 | */ |
| 82 | #if defined(CONFIG_TOUCHSCREEN_ADS7846) || defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE) |
| 83 | static int ads7843_pendown_state(void) |
| 84 | { |
| 85 | return !at91_get_gpio_value(AT91_PIN_PA15); /* Touchscreen PENIRQ */ |
| 86 | } |
| 87 | |
| 88 | static struct ads7846_platform_data ads_info = { |
| 89 | .model = 7843, |
| 90 | .x_min = 150, |
| 91 | .x_max = 3830, |
| 92 | .y_min = 190, |
| 93 | .y_max = 3830, |
| 94 | .vref_delay_usecs = 100, |
| 95 | .x_plate_ohms = 450, |
| 96 | .y_plate_ohms = 250, |
| 97 | .pressure_max = 15000, |
| 98 | .debounce_max = 1, |
| 99 | .debounce_rep = 0, |
| 100 | .debounce_tol = (~0), |
| 101 | .get_pendown_state = ads7843_pendown_state, |
| 102 | }; |
| 103 | |
| 104 | static void __init neocore926_add_device_ts(void) |
| 105 | { |
| 106 | at91_set_B_periph(AT91_PIN_PA15, 1); /* External IRQ1, with pullup */ |
| 107 | at91_set_gpio_input(AT91_PIN_PC13, 1); /* Touchscreen BUSY signal */ |
| 108 | } |
| 109 | #else |
| 110 | static void __init neocore926_add_device_ts(void) {} |
| 111 | #endif |
| 112 | |
| 113 | /* |
| 114 | * SPI devices. |
| 115 | */ |
| 116 | static struct spi_board_info neocore926_spi_devices[] = { |
| 117 | #if defined(CONFIG_MTD_AT91_DATAFLASH_CARD) |
| 118 | { /* DataFlash card */ |
| 119 | .modalias = "mtd_dataflash", |
| 120 | .chip_select = 0, |
| 121 | .max_speed_hz = 15 * 1000 * 1000, |
| 122 | .bus_num = 0, |
| 123 | }, |
| 124 | #endif |
| 125 | #if defined(CONFIG_TOUCHSCREEN_ADS7846) || defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE) |
| 126 | { |
| 127 | .modalias = "ads7846", |
| 128 | .chip_select = 1, |
| 129 | .max_speed_hz = 125000 * 16, |
| 130 | .bus_num = 0, |
| 131 | .platform_data = &ads_info, |
| 132 | .irq = AT91SAM9263_ID_IRQ1, |
| 133 | }, |
| 134 | #endif |
| 135 | }; |
| 136 | |
| 137 | |
| 138 | /* |
| 139 | * MCI (SD/MMC) |
| 140 | */ |
Ludovic Desroches | 4cf3326 | 2012-05-21 12:23:27 +0200 | [diff] [blame] | 141 | static struct mci_platform_data __initdata neocore926_mci0_data = { |
| 142 | .slot[0] = { |
| 143 | .bus_width = 4, |
| 144 | .detect_pin = AT91_PIN_PE18, |
| 145 | .wp_pin = AT91_PIN_PE19, |
| 146 | }, |
Andrew Victor | ffc63b7 | 2008-10-06 20:13:53 +0100 | [diff] [blame] | 147 | }; |
| 148 | |
| 149 | |
| 150 | /* |
| 151 | * MACB Ethernet device |
| 152 | */ |
Jamie Iles | 84e0cdb | 2011-03-08 20:17:06 +0000 | [diff] [blame] | 153 | static struct macb_platform_data __initdata neocore926_macb_data = { |
Andrew Victor | ffc63b7 | 2008-10-06 20:13:53 +0100 | [diff] [blame] | 154 | .phy_irq_pin = AT91_PIN_PE31, |
| 155 | .is_rmii = 1, |
| 156 | }; |
| 157 | |
| 158 | |
| 159 | /* |
| 160 | * NAND flash |
| 161 | */ |
| 162 | static struct mtd_partition __initdata neocore926_nand_partition[] = { |
| 163 | { |
| 164 | .name = "Linux Kernel", /* "Partition 1", */ |
| 165 | .offset = 0, |
| 166 | .size = SZ_8M, |
| 167 | }, |
| 168 | { |
| 169 | .name = "Filesystem", /* "Partition 2", */ |
| 170 | .offset = MTDPART_OFS_NXTBLK, |
| 171 | .size = SZ_32M, |
| 172 | }, |
| 173 | { |
| 174 | .name = "Free", /* "Partition 3", */ |
| 175 | .offset = MTDPART_OFS_NXTBLK, |
| 176 | .size = MTDPART_SIZ_FULL, |
| 177 | }, |
| 178 | }; |
| 179 | |
Andrew Victor | ffc63b7 | 2008-10-06 20:13:53 +0100 | [diff] [blame] | 180 | static struct atmel_nand_data __initdata neocore926_nand_data = { |
| 181 | .ale = 21, |
| 182 | .cle = 22, |
| 183 | .rdy_pin = AT91_PIN_PB19, |
| 184 | .rdy_pin_active_low = 1, |
| 185 | .enable_pin = AT91_PIN_PD15, |
Jean-Christophe PLAGNIOL-VILLARD | bf4289c | 2011-12-29 14:43:24 +0800 | [diff] [blame] | 186 | .ecc_mode = NAND_ECC_SOFT, |
Dmitry Eremin-Solenikov | 1754aab | 2011-05-29 17:49:22 +0400 | [diff] [blame] | 187 | .parts = neocore926_nand_partition, |
| 188 | .num_parts = ARRAY_SIZE(neocore926_nand_partition), |
Jean-Christophe PLAGNIOL-VILLARD | 63b4c29 | 2011-11-25 01:51:06 +0800 | [diff] [blame] | 189 | .det_pin = -EINVAL, |
Andrew Victor | ffc63b7 | 2008-10-06 20:13:53 +0100 | [diff] [blame] | 190 | }; |
| 191 | |
| 192 | static struct sam9_smc_config __initdata neocore926_nand_smc_config = { |
| 193 | .ncs_read_setup = 0, |
| 194 | .nrd_setup = 1, |
| 195 | .ncs_write_setup = 0, |
| 196 | .nwe_setup = 1, |
| 197 | |
| 198 | .ncs_read_pulse = 4, |
| 199 | .nrd_pulse = 4, |
| 200 | .ncs_write_pulse = 4, |
| 201 | .nwe_pulse = 4, |
| 202 | |
| 203 | .read_cycle = 6, |
| 204 | .write_cycle = 6, |
| 205 | |
| 206 | .mode = AT91_SMC_READMODE | AT91_SMC_WRITEMODE | AT91_SMC_EXNWMODE_DISABLE | AT91_SMC_DBW_8, |
| 207 | .tdf_cycles = 2, |
| 208 | }; |
| 209 | |
| 210 | static void __init neocore926_add_device_nand(void) |
| 211 | { |
| 212 | /* configure chip-select 3 (NAND) */ |
Jean-Christophe PLAGNIOL-VILLARD | faee0cc | 2011-10-14 01:37:09 +0800 | [diff] [blame] | 213 | sam9_smc_configure(0, 3, &neocore926_nand_smc_config); |
Andrew Victor | ffc63b7 | 2008-10-06 20:13:53 +0100 | [diff] [blame] | 214 | |
| 215 | at91_add_device_nand(&neocore926_nand_data); |
| 216 | } |
| 217 | |
| 218 | |
| 219 | /* |
| 220 | * LCD Controller |
| 221 | */ |
| 222 | #if defined(CONFIG_FB_ATMEL) || defined(CONFIG_FB_ATMEL_MODULE) |
| 223 | static struct fb_videomode at91_tft_vga_modes[] = { |
| 224 | { |
| 225 | .name = "TX09D50VM1CCA @ 60", |
| 226 | .refresh = 60, |
| 227 | .xres = 240, .yres = 320, |
| 228 | .pixclock = KHZ2PICOS(5000), |
| 229 | |
| 230 | .left_margin = 1, .right_margin = 33, |
| 231 | .upper_margin = 1, .lower_margin = 0, |
| 232 | .hsync_len = 5, .vsync_len = 1, |
| 233 | |
| 234 | .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, |
| 235 | .vmode = FB_VMODE_NONINTERLACED, |
| 236 | }, |
| 237 | }; |
| 238 | |
| 239 | static struct fb_monspecs at91fb_default_monspecs = { |
| 240 | .manufacturer = "HIT", |
| 241 | .monitor = "TX09D70VM1CCA", |
| 242 | |
| 243 | .modedb = at91_tft_vga_modes, |
| 244 | .modedb_len = ARRAY_SIZE(at91_tft_vga_modes), |
| 245 | .hfmin = 15000, |
| 246 | .hfmax = 64000, |
| 247 | .vfmin = 50, |
| 248 | .vfmax = 150, |
| 249 | }; |
| 250 | |
| 251 | #define AT91SAM9263_DEFAULT_LCDCON2 (ATMEL_LCDC_MEMOR_LITTLE \ |
| 252 | | ATMEL_LCDC_DISTYPE_TFT \ |
| 253 | | ATMEL_LCDC_CLKMOD_ALWAYSACTIVE) |
| 254 | |
| 255 | static void at91_lcdc_power_control(int on) |
| 256 | { |
| 257 | at91_set_gpio_value(AT91_PIN_PA30, on); |
| 258 | } |
| 259 | |
| 260 | /* Driver datas */ |
| 261 | static struct atmel_lcdfb_info __initdata neocore926_lcdc_data = { |
| 262 | .lcdcon_is_backlight = true, |
| 263 | .default_bpp = 16, |
| 264 | .default_dmacon = ATMEL_LCDC_DMAEN, |
| 265 | .default_lcdcon2 = AT91SAM9263_DEFAULT_LCDCON2, |
| 266 | .default_monspecs = &at91fb_default_monspecs, |
| 267 | .atmel_lcdfb_power_control = at91_lcdc_power_control, |
| 268 | .guard_time = 1, |
| 269 | .lcd_wiring_mode = ATMEL_LCDC_WIRING_RGB555, |
| 270 | }; |
| 271 | |
| 272 | #else |
| 273 | static struct atmel_lcdfb_info __initdata neocore926_lcdc_data; |
| 274 | #endif |
| 275 | |
| 276 | |
| 277 | /* |
| 278 | * GPIO Buttons |
| 279 | */ |
| 280 | #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE) |
| 281 | static struct gpio_keys_button neocore926_buttons[] = { |
| 282 | { /* BP1, "leftclic" */ |
| 283 | .code = BTN_LEFT, |
| 284 | .gpio = AT91_PIN_PC5, |
| 285 | .active_low = 1, |
| 286 | .desc = "left_click", |
| 287 | .wakeup = 1, |
| 288 | }, |
| 289 | { /* BP2, "rightclic" */ |
| 290 | .code = BTN_RIGHT, |
| 291 | .gpio = AT91_PIN_PC4, |
| 292 | .active_low = 1, |
| 293 | .desc = "right_click", |
| 294 | .wakeup = 1, |
| 295 | }, |
| 296 | }; |
| 297 | |
| 298 | static struct gpio_keys_platform_data neocore926_button_data = { |
| 299 | .buttons = neocore926_buttons, |
| 300 | .nbuttons = ARRAY_SIZE(neocore926_buttons), |
| 301 | }; |
| 302 | |
| 303 | static struct platform_device neocore926_button_device = { |
| 304 | .name = "gpio-keys", |
| 305 | .id = -1, |
| 306 | .num_resources = 0, |
| 307 | .dev = { |
| 308 | .platform_data = &neocore926_button_data, |
| 309 | } |
| 310 | }; |
| 311 | |
| 312 | static void __init neocore926_add_device_buttons(void) |
| 313 | { |
| 314 | at91_set_GPIO_periph(AT91_PIN_PC5, 0); /* left button */ |
| 315 | at91_set_deglitch(AT91_PIN_PC5, 1); |
| 316 | at91_set_GPIO_periph(AT91_PIN_PC4, 0); /* right button */ |
| 317 | at91_set_deglitch(AT91_PIN_PC4, 1); |
| 318 | |
| 319 | platform_device_register(&neocore926_button_device); |
| 320 | } |
| 321 | #else |
| 322 | static void __init neocore926_add_device_buttons(void) {} |
| 323 | #endif |
| 324 | |
| 325 | |
| 326 | /* |
| 327 | * AC97 |
| 328 | */ |
Andrew Victor | 9173a8e | 2009-09-22 10:47:50 +0100 | [diff] [blame] | 329 | static struct ac97c_platform_data neocore926_ac97_data = { |
Andrew Victor | ffc63b7 | 2008-10-06 20:13:53 +0100 | [diff] [blame] | 330 | .reset_pin = AT91_PIN_PA13, |
| 331 | }; |
| 332 | |
| 333 | |
| 334 | static void __init neocore926_board_init(void) |
| 335 | { |
| 336 | /* Serial */ |
Jean-Christophe PLAGNIOL-VILLARD | 71b149b | 2012-04-05 14:14:28 +0800 | [diff] [blame] | 337 | /* DBGU on ttyS0. (Rx & Tx only) */ |
| 338 | at91_register_uart(0, 0, 0); |
| 339 | |
| 340 | /* USART0 on ttyS1. (Rx, Tx, RTS, CTS) */ |
| 341 | at91_register_uart(AT91SAM9263_ID_US0, 1, ATMEL_UART_CTS | ATMEL_UART_RTS); |
Andrew Victor | ffc63b7 | 2008-10-06 20:13:53 +0100 | [diff] [blame] | 342 | at91_add_device_serial(); |
| 343 | |
| 344 | /* USB Host */ |
| 345 | at91_add_device_usbh(&neocore926_usbh_data); |
| 346 | |
| 347 | /* USB Device */ |
| 348 | at91_add_device_udc(&neocore926_udc_data); |
| 349 | |
| 350 | /* SPI */ |
| 351 | at91_set_gpio_output(AT91_PIN_PE20, 1); /* select spi0 clock */ |
| 352 | at91_add_device_spi(neocore926_spi_devices, ARRAY_SIZE(neocore926_spi_devices)); |
| 353 | |
| 354 | /* Touchscreen */ |
| 355 | neocore926_add_device_ts(); |
| 356 | |
| 357 | /* MMC */ |
Ludovic Desroches | 4cf3326 | 2012-05-21 12:23:27 +0200 | [diff] [blame] | 358 | at91_add_device_mci(0, &neocore926_mci0_data); |
Andrew Victor | ffc63b7 | 2008-10-06 20:13:53 +0100 | [diff] [blame] | 359 | |
| 360 | /* Ethernet */ |
| 361 | at91_add_device_eth(&neocore926_macb_data); |
| 362 | |
| 363 | /* NAND */ |
| 364 | neocore926_add_device_nand(); |
| 365 | |
| 366 | /* I2C */ |
| 367 | at91_add_device_i2c(NULL, 0); |
| 368 | |
| 369 | /* LCD Controller */ |
| 370 | at91_add_device_lcdc(&neocore926_lcdc_data); |
| 371 | |
| 372 | /* Push Buttons */ |
| 373 | neocore926_add_device_buttons(); |
| 374 | |
| 375 | /* AC97 */ |
| 376 | at91_add_device_ac97(&neocore926_ac97_data); |
| 377 | } |
| 378 | |
| 379 | MACHINE_START(NEOCORE926, "ADENEO NEOCORE 926") |
| 380 | /* Maintainer: ADENEO */ |
Andrew Victor | ffc63b7 | 2008-10-06 20:13:53 +0100 | [diff] [blame] | 381 | .timer = &at91sam926x_timer, |
Jean-Christophe PLAGNIOL-VILLARD | 21d08b9 | 2011-04-23 15:28:34 +0800 | [diff] [blame] | 382 | .map_io = at91_map_io, |
Ludovic Desroches | 3e13546 | 2012-06-11 15:38:03 +0200 | [diff] [blame] | 383 | .handle_irq = at91_aic_handle_irq, |
Jean-Christophe PLAGNIOL-VILLARD | 1b021a3 | 2011-04-28 20:19:32 +0800 | [diff] [blame] | 384 | .init_early = neocore926_init_early, |
Jean-Christophe PLAGNIOL-VILLARD | 92100c1 | 2011-04-23 15:28:34 +0800 | [diff] [blame] | 385 | .init_irq = at91_init_irq_default, |
Andrew Victor | ffc63b7 | 2008-10-06 20:13:53 +0100 | [diff] [blame] | 386 | .init_machine = neocore926_board_init, |
| 387 | MACHINE_END |