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