Andrew Victor | c42dcb3 | 2007-05-11 19:24:18 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2005 SAN People |
| 3 | * Copyright (C) 2007 Atmel Corporation |
| 4 | * |
| 5 | * This file is subject to the terms and conditions of the GNU General Public |
| 6 | * License. See the file COPYING in the main directory of this archive for |
| 7 | * more details. |
| 8 | */ |
| 9 | |
| 10 | #include <linux/types.h> |
Russell King | 2f8163b | 2011-07-26 10:53:52 +0100 | [diff] [blame] | 11 | #include <linux/gpio.h> |
Andrew Victor | c42dcb3 | 2007-05-11 19:24:18 +0100 | [diff] [blame] | 12 | #include <linux/init.h> |
| 13 | #include <linux/mm.h> |
| 14 | #include <linux/module.h> |
| 15 | #include <linux/platform_device.h> |
| 16 | #include <linux/spi/spi.h> |
| 17 | #include <linux/fb.h> |
| 18 | #include <linux/clk.h> |
Nicolas Ferre | 226ddb9 | 2009-06-24 17:13:47 +0100 | [diff] [blame] | 19 | #include <linux/input.h> |
| 20 | #include <linux/gpio_keys.h> |
Andrew Victor | c42dcb3 | 2007-05-11 19:24:18 +0100 | [diff] [blame] | 21 | |
| 22 | #include <video/atmel_lcdc.h> |
| 23 | |
Andrew Victor | c42dcb3 | 2007-05-11 19:24:18 +0100 | [diff] [blame] | 24 | #include <asm/setup.h> |
| 25 | #include <asm/mach-types.h> |
| 26 | #include <asm/irq.h> |
| 27 | |
| 28 | #include <asm/mach/arch.h> |
| 29 | #include <asm/mach/map.h> |
| 30 | #include <asm/mach/irq.h> |
| 31 | |
Andrew Victor | e505240 | 2008-09-21 21:30:02 +0100 | [diff] [blame] | 32 | #include <mach/hardware.h> |
Russell King | 80b02c1 | 2009-01-08 10:01:47 +0000 | [diff] [blame] | 33 | #include <mach/at91sam9_smc.h> |
Andrew Victor | c42dcb3 | 2007-05-11 19:24:18 +0100 | [diff] [blame] | 34 | |
Jean-Christophe PLAGNIOL-VILLARD | a510b9b | 2012-10-30 06:41:28 +0800 | [diff] [blame] | 35 | |
| 36 | #include "at91_aic.h" |
Jean-Christophe PLAGNIOL-VILLARD | 176bdd2 | 2012-10-30 08:07:11 +0800 | [diff] [blame] | 37 | #include "at91_shdwc.h" |
Jean-Christophe PLAGNIOL-VILLARD | 43d2f53 | 2012-10-30 05:14:17 +0800 | [diff] [blame] | 38 | #include "board.h" |
Andrew Victor | 8cdae51 | 2008-10-06 20:05:35 +0100 | [diff] [blame] | 39 | #include "sam9_smc.h" |
Andrew Victor | c42dcb3 | 2007-05-11 19:24:18 +0100 | [diff] [blame] | 40 | #include "generic.h" |
| 41 | |
| 42 | |
Jean-Christophe PLAGNIOL-VILLARD | 1b021a3 | 2011-04-28 20:19:32 +0800 | [diff] [blame] | 43 | static void __init ek_init_early(void) |
Andrew Victor | c42dcb3 | 2007-05-11 19:24:18 +0100 | [diff] [blame] | 44 | { |
| 45 | /* Initialize processor: 12.000 MHz crystal */ |
Jean-Christophe PLAGNIOL-VILLARD | 21d08b9 | 2011-04-23 15:28:34 +0800 | [diff] [blame] | 46 | at91_initialize(12000000); |
Andrew Victor | c42dcb3 | 2007-05-11 19:24:18 +0100 | [diff] [blame] | 47 | } |
| 48 | |
Andrew Victor | c42dcb3 | 2007-05-11 19:24:18 +0100 | [diff] [blame] | 49 | /* |
Nicolas Ferre | ba45ca4 | 2008-04-08 13:59:18 +0100 | [diff] [blame] | 50 | * USB HS Device port |
| 51 | */ |
| 52 | static struct usba_platform_data __initdata ek_usba_udc_data = { |
| 53 | .vbus_pin = AT91_PIN_PA8, |
| 54 | }; |
| 55 | |
| 56 | |
| 57 | /* |
Andrew Victor | c42dcb3 | 2007-05-11 19:24:18 +0100 | [diff] [blame] | 58 | * MCI (SD/MMC) |
| 59 | */ |
Ludovic Desroches | 4cf3326 | 2012-05-21 12:23:27 +0200 | [diff] [blame] | 60 | static struct mci_platform_data __initdata mci0_data = { |
| 61 | .slot[0] = { |
| 62 | .bus_width = 4, |
| 63 | .detect_pin = AT91_PIN_PA15, |
| 64 | .wp_pin = -EINVAL, |
| 65 | }, |
Andrew Victor | c42dcb3 | 2007-05-11 19:24:18 +0100 | [diff] [blame] | 66 | }; |
| 67 | |
| 68 | |
| 69 | /* |
| 70 | * NAND flash |
| 71 | */ |
| 72 | static struct mtd_partition __initdata ek_nand_partition[] = { |
| 73 | { |
| 74 | .name = "Partition 1", |
| 75 | .offset = 0, |
Andrew Victor | e505240 | 2008-09-21 21:30:02 +0100 | [diff] [blame] | 76 | .size = SZ_256K, |
Andrew Victor | c42dcb3 | 2007-05-11 19:24:18 +0100 | [diff] [blame] | 77 | }, |
| 78 | { |
| 79 | .name = "Partition 2", |
Andrew Victor | e505240 | 2008-09-21 21:30:02 +0100 | [diff] [blame] | 80 | .offset = MTDPART_OFS_NXTBLK, |
Andrew Victor | c42dcb3 | 2007-05-11 19:24:18 +0100 | [diff] [blame] | 81 | .size = MTDPART_SIZ_FULL, |
| 82 | }, |
| 83 | }; |
| 84 | |
HÃ¥vard Skinnemoen | 3c3796c | 2008-06-06 18:04:53 +0200 | [diff] [blame] | 85 | static struct atmel_nand_data __initdata ek_nand_data = { |
Andrew Victor | c42dcb3 | 2007-05-11 19:24:18 +0100 | [diff] [blame] | 86 | .ale = 21, |
| 87 | .cle = 22, |
Jean-Christophe PLAGNIOL-VILLARD | 63b4c29 | 2011-11-25 01:51:06 +0800 | [diff] [blame] | 88 | .det_pin = -EINVAL, |
Andrew Victor | c42dcb3 | 2007-05-11 19:24:18 +0100 | [diff] [blame] | 89 | .rdy_pin = AT91_PIN_PD17, |
| 90 | .enable_pin = AT91_PIN_PB6, |
Jean-Christophe PLAGNIOL-VILLARD | bf4289c | 2011-12-29 14:43:24 +0800 | [diff] [blame] | 91 | .ecc_mode = NAND_ECC_SOFT, |
Jean-Christophe PLAGNIOL-VILLARD | 98619dc | 2011-12-29 15:05:50 +0800 | [diff] [blame] | 92 | .on_flash_bbt = 1, |
Dmitry Eremin-Solenikov | 1754aab | 2011-05-29 17:49:22 +0400 | [diff] [blame] | 93 | .parts = ek_nand_partition, |
| 94 | .num_parts = ARRAY_SIZE(ek_nand_partition), |
Andrew Victor | c42dcb3 | 2007-05-11 19:24:18 +0100 | [diff] [blame] | 95 | }; |
| 96 | |
Andrew Victor | 8cdae51 | 2008-10-06 20:05:35 +0100 | [diff] [blame] | 97 | static struct sam9_smc_config __initdata ek_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 | AT91_SMC_EXNWMODE_DISABLE | AT91_SMC_DBW_8, |
| 112 | .tdf_cycles = 2, |
| 113 | }; |
| 114 | |
| 115 | static void __init ek_add_device_nand(void) |
| 116 | { |
| 117 | /* configure chip-select 3 (NAND) */ |
Jean-Christophe PLAGNIOL-VILLARD | faee0cc | 2011-10-14 01:37:09 +0800 | [diff] [blame] | 118 | sam9_smc_configure(0, 3, &ek_nand_smc_config); |
Andrew Victor | 8cdae51 | 2008-10-06 20:05:35 +0100 | [diff] [blame] | 119 | |
| 120 | at91_add_device_nand(&ek_nand_data); |
| 121 | } |
| 122 | |
Andrew Victor | c42dcb3 | 2007-05-11 19:24:18 +0100 | [diff] [blame] | 123 | |
| 124 | /* |
| 125 | * SPI devices |
| 126 | */ |
| 127 | static struct spi_board_info ek_spi_devices[] = { |
| 128 | { /* DataFlash chip */ |
| 129 | .modalias = "mtd_dataflash", |
| 130 | .chip_select = 0, |
| 131 | .max_speed_hz = 15 * 1000 * 1000, |
| 132 | .bus_num = 0, |
| 133 | }, |
| 134 | }; |
| 135 | |
| 136 | |
| 137 | /* |
| 138 | * LCD Controller |
| 139 | */ |
| 140 | #if defined(CONFIG_FB_ATMEL) || defined(CONFIG_FB_ATMEL_MODULE) |
| 141 | static struct fb_videomode at91_tft_vga_modes[] = { |
| 142 | { |
| 143 | .name = "TX09D50VM1CCA @ 60", |
| 144 | .refresh = 60, |
| 145 | .xres = 240, .yres = 320, |
| 146 | .pixclock = KHZ2PICOS(4965), |
| 147 | |
| 148 | .left_margin = 1, .right_margin = 33, |
| 149 | .upper_margin = 1, .lower_margin = 0, |
| 150 | .hsync_len = 5, .vsync_len = 1, |
| 151 | |
| 152 | .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, |
| 153 | .vmode = FB_VMODE_NONINTERLACED, |
| 154 | }, |
| 155 | }; |
| 156 | |
| 157 | static struct fb_monspecs at91fb_default_monspecs = { |
| 158 | .manufacturer = "HIT", |
| 159 | .monitor = "TX09D50VM1CCA", |
| 160 | |
| 161 | .modedb = at91_tft_vga_modes, |
| 162 | .modedb_len = ARRAY_SIZE(at91_tft_vga_modes), |
| 163 | .hfmin = 15000, |
| 164 | .hfmax = 64000, |
| 165 | .vfmin = 50, |
| 166 | .vfmax = 150, |
| 167 | }; |
| 168 | |
| 169 | #define AT91SAM9RL_DEFAULT_LCDCON2 (ATMEL_LCDC_MEMOR_LITTLE \ |
| 170 | | ATMEL_LCDC_DISTYPE_TFT \ |
| 171 | | ATMEL_LCDC_CLKMOD_ALWAYSACTIVE) |
| 172 | |
| 173 | static void at91_lcdc_power_control(int on) |
| 174 | { |
| 175 | if (on) |
Nicolas Ferre | 9a24ee0 | 2009-06-24 17:13:48 +0100 | [diff] [blame] | 176 | at91_set_gpio_value(AT91_PIN_PC1, 0); /* power up */ |
Andrew Victor | c42dcb3 | 2007-05-11 19:24:18 +0100 | [diff] [blame] | 177 | else |
Nicolas Ferre | 9a24ee0 | 2009-06-24 17:13:48 +0100 | [diff] [blame] | 178 | at91_set_gpio_value(AT91_PIN_PC1, 1); /* power down */ |
Andrew Victor | c42dcb3 | 2007-05-11 19:24:18 +0100 | [diff] [blame] | 179 | } |
| 180 | |
| 181 | /* Driver datas */ |
| 182 | static struct atmel_lcdfb_info __initdata ek_lcdc_data = { |
Nicolas Ferre | 9a24ee0 | 2009-06-24 17:13:48 +0100 | [diff] [blame] | 183 | .lcdcon_is_backlight = true, |
Andrew Victor | c42dcb3 | 2007-05-11 19:24:18 +0100 | [diff] [blame] | 184 | .default_bpp = 16, |
| 185 | .default_dmacon = ATMEL_LCDC_DMAEN, |
| 186 | .default_lcdcon2 = AT91SAM9RL_DEFAULT_LCDCON2, |
| 187 | .default_monspecs = &at91fb_default_monspecs, |
| 188 | .atmel_lcdfb_power_control = at91_lcdc_power_control, |
| 189 | .guard_time = 1, |
Nicolas Ferre | 9a24ee0 | 2009-06-24 17:13:48 +0100 | [diff] [blame] | 190 | .lcd_wiring_mode = ATMEL_LCDC_WIRING_RGB, |
Andrew Victor | c42dcb3 | 2007-05-11 19:24:18 +0100 | [diff] [blame] | 191 | }; |
| 192 | |
| 193 | #else |
| 194 | static struct atmel_lcdfb_info __initdata ek_lcdc_data; |
| 195 | #endif |
| 196 | |
| 197 | |
Nicolas Ferre | 226ddb9 | 2009-06-24 17:13:47 +0100 | [diff] [blame] | 198 | /* |
Nicolas Ferre | 439a330 | 2009-09-18 16:14:21 +0100 | [diff] [blame] | 199 | * AC97 |
| 200 | * reset_pin is not connected: NRST |
| 201 | */ |
| 202 | static struct ac97c_platform_data ek_ac97_data = { |
Jean-Christophe PLAGNIOL-VILLARD | 63b4c29 | 2011-11-25 01:51:06 +0800 | [diff] [blame] | 203 | .reset_pin = -EINVAL, |
Nicolas Ferre | 439a330 | 2009-09-18 16:14:21 +0100 | [diff] [blame] | 204 | }; |
| 205 | |
| 206 | |
| 207 | /* |
Nicolas Ferre | 226ddb9 | 2009-06-24 17:13:47 +0100 | [diff] [blame] | 208 | * LEDs |
| 209 | */ |
| 210 | static struct gpio_led ek_leds[] = { |
| 211 | { /* "bottom" led, green, userled1 to be defined */ |
| 212 | .name = "ds1", |
| 213 | .gpio = AT91_PIN_PD15, |
| 214 | .active_low = 1, |
| 215 | .default_trigger = "none", |
| 216 | }, |
| 217 | { /* "bottom" led, green, userled2 to be defined */ |
| 218 | .name = "ds2", |
| 219 | .gpio = AT91_PIN_PD16, |
| 220 | .active_low = 1, |
| 221 | .default_trigger = "none", |
| 222 | }, |
| 223 | { /* "power" led, yellow */ |
| 224 | .name = "ds3", |
| 225 | .gpio = AT91_PIN_PD14, |
| 226 | .default_trigger = "heartbeat", |
| 227 | } |
| 228 | }; |
| 229 | |
| 230 | |
| 231 | /* |
Nicolas Ferre | 423c9b0 | 2009-11-19 09:31:20 -0800 | [diff] [blame] | 232 | * Touchscreen |
| 233 | */ |
| 234 | static struct at91_tsadcc_data ek_tsadcc_data = { |
| 235 | .adc_clock = 1000000, |
| 236 | .pendet_debounce = 0x0f, |
| 237 | .ts_sample_hold_time = 0x03, |
| 238 | }; |
| 239 | |
| 240 | |
| 241 | /* |
Nicolas Ferre | 226ddb9 | 2009-06-24 17:13:47 +0100 | [diff] [blame] | 242 | * GPIO Buttons |
| 243 | */ |
| 244 | #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE) |
| 245 | static struct gpio_keys_button ek_buttons[] = { |
| 246 | { |
| 247 | .gpio = AT91_PIN_PB0, |
| 248 | .code = BTN_2, |
| 249 | .desc = "Right Click", |
| 250 | .active_low = 1, |
| 251 | .wakeup = 1, |
| 252 | }, |
| 253 | { |
| 254 | .gpio = AT91_PIN_PB1, |
| 255 | .code = BTN_1, |
| 256 | .desc = "Left Click", |
| 257 | .active_low = 1, |
| 258 | .wakeup = 1, |
| 259 | } |
| 260 | }; |
| 261 | |
| 262 | static struct gpio_keys_platform_data ek_button_data = { |
| 263 | .buttons = ek_buttons, |
| 264 | .nbuttons = ARRAY_SIZE(ek_buttons), |
| 265 | }; |
| 266 | |
| 267 | static struct platform_device ek_button_device = { |
| 268 | .name = "gpio-keys", |
| 269 | .id = -1, |
| 270 | .num_resources = 0, |
| 271 | .dev = { |
| 272 | .platform_data = &ek_button_data, |
| 273 | } |
| 274 | }; |
| 275 | |
| 276 | static void __init ek_add_device_buttons(void) |
| 277 | { |
| 278 | at91_set_gpio_input(AT91_PIN_PB1, 1); /* btn1 */ |
| 279 | at91_set_deglitch(AT91_PIN_PB1, 1); |
| 280 | at91_set_gpio_input(AT91_PIN_PB0, 1); /* btn2 */ |
| 281 | at91_set_deglitch(AT91_PIN_PB0, 1); |
| 282 | |
| 283 | platform_device_register(&ek_button_device); |
| 284 | } |
| 285 | #else |
| 286 | static void __init ek_add_device_buttons(void) {} |
| 287 | #endif |
| 288 | |
| 289 | |
Andrew Victor | c42dcb3 | 2007-05-11 19:24:18 +0100 | [diff] [blame] | 290 | static void __init ek_board_init(void) |
| 291 | { |
| 292 | /* Serial */ |
Jean-Christophe PLAGNIOL-VILLARD | 71b149b | 2012-04-05 14:14:28 +0800 | [diff] [blame] | 293 | /* DBGU on ttyS0. (Rx & Tx only) */ |
| 294 | at91_register_uart(0, 0, 0); |
| 295 | |
| 296 | /* USART0 on ttyS1. (Rx, Tx, CTS, RTS) */ |
| 297 | at91_register_uart(AT91SAM9RL_ID_US0, 1, ATMEL_UART_CTS | ATMEL_UART_RTS); |
Andrew Victor | c42dcb3 | 2007-05-11 19:24:18 +0100 | [diff] [blame] | 298 | at91_add_device_serial(); |
Nicolas Ferre | ba45ca4 | 2008-04-08 13:59:18 +0100 | [diff] [blame] | 299 | /* USB HS */ |
| 300 | at91_add_device_usba(&ek_usba_udc_data); |
Andrew Victor | c42dcb3 | 2007-05-11 19:24:18 +0100 | [diff] [blame] | 301 | /* I2C */ |
Andrew Victor | f230d3f | 2007-11-19 13:47:20 +0100 | [diff] [blame] | 302 | at91_add_device_i2c(NULL, 0); |
Andrew Victor | c42dcb3 | 2007-05-11 19:24:18 +0100 | [diff] [blame] | 303 | /* NAND */ |
Andrew Victor | 8cdae51 | 2008-10-06 20:05:35 +0100 | [diff] [blame] | 304 | ek_add_device_nand(); |
Andrew Victor | c42dcb3 | 2007-05-11 19:24:18 +0100 | [diff] [blame] | 305 | /* SPI */ |
| 306 | at91_add_device_spi(ek_spi_devices, ARRAY_SIZE(ek_spi_devices)); |
| 307 | /* MMC */ |
Ludovic Desroches | 4cf3326 | 2012-05-21 12:23:27 +0200 | [diff] [blame] | 308 | at91_add_device_mci(0, &mci0_data); |
Andrew Victor | c42dcb3 | 2007-05-11 19:24:18 +0100 | [diff] [blame] | 309 | /* LCD Controller */ |
| 310 | at91_add_device_lcdc(&ek_lcdc_data); |
Nicolas Ferre | 439a330 | 2009-09-18 16:14:21 +0100 | [diff] [blame] | 311 | /* AC97 */ |
| 312 | at91_add_device_ac97(&ek_ac97_data); |
Andrew Victor | f7647e6 | 2008-09-18 19:45:35 +0100 | [diff] [blame] | 313 | /* Touch Screen Controller */ |
Nicolas Ferre | 423c9b0 | 2009-11-19 09:31:20 -0800 | [diff] [blame] | 314 | at91_add_device_tsadcc(&ek_tsadcc_data); |
Nicolas Ferre | 226ddb9 | 2009-06-24 17:13:47 +0100 | [diff] [blame] | 315 | /* LEDs */ |
| 316 | at91_gpio_leds(ek_leds, ARRAY_SIZE(ek_leds)); |
| 317 | /* Push Buttons */ |
| 318 | ek_add_device_buttons(); |
Andrew Victor | c42dcb3 | 2007-05-11 19:24:18 +0100 | [diff] [blame] | 319 | } |
| 320 | |
| 321 | MACHINE_START(AT91SAM9RLEK, "Atmel AT91SAM9RL-EK") |
| 322 | /* Maintainer: Atmel */ |
Andrew Victor | c42dcb3 | 2007-05-11 19:24:18 +0100 | [diff] [blame] | 323 | .timer = &at91sam926x_timer, |
Jean-Christophe PLAGNIOL-VILLARD | 21d08b9 | 2011-04-23 15:28:34 +0800 | [diff] [blame] | 324 | .map_io = at91_map_io, |
Ludovic Desroches | 3e13546 | 2012-06-11 15:38:03 +0200 | [diff] [blame] | 325 | .handle_irq = at91_aic_handle_irq, |
Jean-Christophe PLAGNIOL-VILLARD | 1b021a3 | 2011-04-28 20:19:32 +0800 | [diff] [blame] | 326 | .init_early = ek_init_early, |
Jean-Christophe PLAGNIOL-VILLARD | 92100c1 | 2011-04-23 15:28:34 +0800 | [diff] [blame] | 327 | .init_irq = at91_init_irq_default, |
Andrew Victor | c42dcb3 | 2007-05-11 19:24:18 +0100 | [diff] [blame] | 328 | .init_machine = ek_board_init, |
| 329 | MACHINE_END |