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