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