blob: fb89ea92e3f24bc0f52934c18aec7528b43c643d [file] [log] [blame]
Andrew Victorc42dcb32007-05-11 19:24:18 +01001/*
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 King2f8163b2011-07-26 10:53:52 +010011#include <linux/gpio.h>
Andrew Victorc42dcb32007-05-11 19:24:18 +010012#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 Ferre226ddb92009-06-24 17:13:47 +010019#include <linux/input.h>
20#include <linux/gpio_keys.h>
Andrew Victorc42dcb32007-05-11 19:24:18 +010021
22#include <video/atmel_lcdc.h>
23
Andrew Victorc42dcb32007-05-11 19:24:18 +010024#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 Victore5052402008-09-21 21:30:02 +010032#include <mach/hardware.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010033#include <mach/board.h>
Ludovic Desroches3e135462012-06-11 15:38:03 +020034#include <mach/at91_aic.h>
Russell King80b02c12009-01-08 10:01:47 +000035#include <mach/at91sam9_smc.h>
Andrew Victor8cdae512008-10-06 20:05:35 +010036#include <mach/at91_shdwc.h>
Andrew Victorc42dcb32007-05-11 19:24:18 +010037
Andrew Victor8cdae512008-10-06 20:05:35 +010038#include "sam9_smc.h"
Andrew Victorc42dcb32007-05-11 19:24:18 +010039#include "generic.h"
40
41
Jean-Christophe PLAGNIOL-VILLARD1b021a32011-04-28 20:19:32 +080042static void __init ek_init_early(void)
Andrew Victorc42dcb32007-05-11 19:24:18 +010043{
44 /* Initialize processor: 12.000 MHz crystal */
Jean-Christophe PLAGNIOL-VILLARD21d08b92011-04-23 15:28:34 +080045 at91_initialize(12000000);
Andrew Victorc42dcb32007-05-11 19:24:18 +010046}
47
Andrew Victorc42dcb32007-05-11 19:24:18 +010048/*
Nicolas Ferreba45ca42008-04-08 13:59:18 +010049 * USB HS Device port
50 */
51static struct usba_platform_data __initdata ek_usba_udc_data = {
52 .vbus_pin = AT91_PIN_PA8,
53};
54
55
56/*
Andrew Victorc42dcb32007-05-11 19:24:18 +010057 * MCI (SD/MMC)
58 */
Ludovic Desroches4cf33262012-05-21 12:23:27 +020059static struct mci_platform_data __initdata mci0_data = {
60 .slot[0] = {
61 .bus_width = 4,
62 .detect_pin = AT91_PIN_PA15,
63 .wp_pin = -EINVAL,
64 },
Andrew Victorc42dcb32007-05-11 19:24:18 +010065};
66
67
68/*
69 * NAND flash
70 */
71static struct mtd_partition __initdata ek_nand_partition[] = {
72 {
73 .name = "Partition 1",
74 .offset = 0,
Andrew Victore5052402008-09-21 21:30:02 +010075 .size = SZ_256K,
Andrew Victorc42dcb32007-05-11 19:24:18 +010076 },
77 {
78 .name = "Partition 2",
Andrew Victore5052402008-09-21 21:30:02 +010079 .offset = MTDPART_OFS_NXTBLK,
Andrew Victorc42dcb32007-05-11 19:24:18 +010080 .size = MTDPART_SIZ_FULL,
81 },
82};
83
HÃ¥vard Skinnemoen3c3796c2008-06-06 18:04:53 +020084static struct atmel_nand_data __initdata ek_nand_data = {
Andrew Victorc42dcb32007-05-11 19:24:18 +010085 .ale = 21,
86 .cle = 22,
Jean-Christophe PLAGNIOL-VILLARD63b4c292011-11-25 01:51:06 +080087 .det_pin = -EINVAL,
Andrew Victorc42dcb32007-05-11 19:24:18 +010088 .rdy_pin = AT91_PIN_PD17,
89 .enable_pin = AT91_PIN_PB6,
Jean-Christophe PLAGNIOL-VILLARDbf4289c2011-12-29 14:43:24 +080090 .ecc_mode = NAND_ECC_SOFT,
Jean-Christophe PLAGNIOL-VILLARD98619dc2011-12-29 15:05:50 +080091 .on_flash_bbt = 1,
Dmitry Eremin-Solenikov1754aab2011-05-29 17:49:22 +040092 .parts = ek_nand_partition,
93 .num_parts = ARRAY_SIZE(ek_nand_partition),
Andrew Victorc42dcb32007-05-11 19:24:18 +010094};
95
Andrew Victor8cdae512008-10-06 20:05:35 +010096static struct sam9_smc_config __initdata ek_nand_smc_config = {
97 .ncs_read_setup = 0,
98 .nrd_setup = 1,
99 .ncs_write_setup = 0,
100 .nwe_setup = 1,
101
102 .ncs_read_pulse = 3,
103 .nrd_pulse = 3,
104 .ncs_write_pulse = 3,
105 .nwe_pulse = 3,
106
107 .read_cycle = 5,
108 .write_cycle = 5,
109
110 .mode = AT91_SMC_READMODE | AT91_SMC_WRITEMODE | AT91_SMC_EXNWMODE_DISABLE | AT91_SMC_DBW_8,
111 .tdf_cycles = 2,
112};
113
114static void __init ek_add_device_nand(void)
115{
116 /* configure chip-select 3 (NAND) */
Jean-Christophe PLAGNIOL-VILLARDfaee0cc2011-10-14 01:37:09 +0800117 sam9_smc_configure(0, 3, &ek_nand_smc_config);
Andrew Victor8cdae512008-10-06 20:05:35 +0100118
119 at91_add_device_nand(&ek_nand_data);
120}
121
Andrew Victorc42dcb32007-05-11 19:24:18 +0100122
123/*
124 * SPI devices
125 */
126static struct spi_board_info ek_spi_devices[] = {
127 { /* DataFlash chip */
128 .modalias = "mtd_dataflash",
129 .chip_select = 0,
130 .max_speed_hz = 15 * 1000 * 1000,
131 .bus_num = 0,
132 },
133};
134
135
136/*
137 * LCD Controller
138 */
139#if defined(CONFIG_FB_ATMEL) || defined(CONFIG_FB_ATMEL_MODULE)
140static struct fb_videomode at91_tft_vga_modes[] = {
141 {
142 .name = "TX09D50VM1CCA @ 60",
143 .refresh = 60,
144 .xres = 240, .yres = 320,
145 .pixclock = KHZ2PICOS(4965),
146
147 .left_margin = 1, .right_margin = 33,
148 .upper_margin = 1, .lower_margin = 0,
149 .hsync_len = 5, .vsync_len = 1,
150
151 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
152 .vmode = FB_VMODE_NONINTERLACED,
153 },
154};
155
156static struct fb_monspecs at91fb_default_monspecs = {
157 .manufacturer = "HIT",
158 .monitor = "TX09D50VM1CCA",
159
160 .modedb = at91_tft_vga_modes,
161 .modedb_len = ARRAY_SIZE(at91_tft_vga_modes),
162 .hfmin = 15000,
163 .hfmax = 64000,
164 .vfmin = 50,
165 .vfmax = 150,
166};
167
168#define AT91SAM9RL_DEFAULT_LCDCON2 (ATMEL_LCDC_MEMOR_LITTLE \
169 | ATMEL_LCDC_DISTYPE_TFT \
170 | ATMEL_LCDC_CLKMOD_ALWAYSACTIVE)
171
172static void at91_lcdc_power_control(int on)
173{
174 if (on)
Nicolas Ferre9a24ee02009-06-24 17:13:48 +0100175 at91_set_gpio_value(AT91_PIN_PC1, 0); /* power up */
Andrew Victorc42dcb32007-05-11 19:24:18 +0100176 else
Nicolas Ferre9a24ee02009-06-24 17:13:48 +0100177 at91_set_gpio_value(AT91_PIN_PC1, 1); /* power down */
Andrew Victorc42dcb32007-05-11 19:24:18 +0100178}
179
180/* Driver datas */
181static struct atmel_lcdfb_info __initdata ek_lcdc_data = {
Nicolas Ferre9a24ee02009-06-24 17:13:48 +0100182 .lcdcon_is_backlight = true,
Andrew Victorc42dcb32007-05-11 19:24:18 +0100183 .default_bpp = 16,
184 .default_dmacon = ATMEL_LCDC_DMAEN,
185 .default_lcdcon2 = AT91SAM9RL_DEFAULT_LCDCON2,
186 .default_monspecs = &at91fb_default_monspecs,
187 .atmel_lcdfb_power_control = at91_lcdc_power_control,
188 .guard_time = 1,
Nicolas Ferre9a24ee02009-06-24 17:13:48 +0100189 .lcd_wiring_mode = ATMEL_LCDC_WIRING_RGB,
Andrew Victorc42dcb32007-05-11 19:24:18 +0100190};
191
192#else
193static struct atmel_lcdfb_info __initdata ek_lcdc_data;
194#endif
195
196
Nicolas Ferre226ddb92009-06-24 17:13:47 +0100197/*
Nicolas Ferre439a3302009-09-18 16:14:21 +0100198 * AC97
199 * reset_pin is not connected: NRST
200 */
201static struct ac97c_platform_data ek_ac97_data = {
Jean-Christophe PLAGNIOL-VILLARD63b4c292011-11-25 01:51:06 +0800202 .reset_pin = -EINVAL,
Nicolas Ferre439a3302009-09-18 16:14:21 +0100203};
204
205
206/*
Nicolas Ferre226ddb92009-06-24 17:13:47 +0100207 * LEDs
208 */
209static struct gpio_led ek_leds[] = {
210 { /* "bottom" led, green, userled1 to be defined */
211 .name = "ds1",
212 .gpio = AT91_PIN_PD15,
213 .active_low = 1,
214 .default_trigger = "none",
215 },
216 { /* "bottom" led, green, userled2 to be defined */
217 .name = "ds2",
218 .gpio = AT91_PIN_PD16,
219 .active_low = 1,
220 .default_trigger = "none",
221 },
222 { /* "power" led, yellow */
223 .name = "ds3",
224 .gpio = AT91_PIN_PD14,
225 .default_trigger = "heartbeat",
226 }
227};
228
229
230/*
Nicolas Ferre423c9b02009-11-19 09:31:20 -0800231 * Touchscreen
232 */
233static struct at91_tsadcc_data ek_tsadcc_data = {
234 .adc_clock = 1000000,
235 .pendet_debounce = 0x0f,
236 .ts_sample_hold_time = 0x03,
237};
238
239
240/*
Nicolas Ferre226ddb92009-06-24 17:13:47 +0100241 * GPIO Buttons
242 */
243#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
244static struct gpio_keys_button ek_buttons[] = {
245 {
246 .gpio = AT91_PIN_PB0,
247 .code = BTN_2,
248 .desc = "Right Click",
249 .active_low = 1,
250 .wakeup = 1,
251 },
252 {
253 .gpio = AT91_PIN_PB1,
254 .code = BTN_1,
255 .desc = "Left Click",
256 .active_low = 1,
257 .wakeup = 1,
258 }
259};
260
261static struct gpio_keys_platform_data ek_button_data = {
262 .buttons = ek_buttons,
263 .nbuttons = ARRAY_SIZE(ek_buttons),
264};
265
266static struct platform_device ek_button_device = {
267 .name = "gpio-keys",
268 .id = -1,
269 .num_resources = 0,
270 .dev = {
271 .platform_data = &ek_button_data,
272 }
273};
274
275static void __init ek_add_device_buttons(void)
276{
277 at91_set_gpio_input(AT91_PIN_PB1, 1); /* btn1 */
278 at91_set_deglitch(AT91_PIN_PB1, 1);
279 at91_set_gpio_input(AT91_PIN_PB0, 1); /* btn2 */
280 at91_set_deglitch(AT91_PIN_PB0, 1);
281
282 platform_device_register(&ek_button_device);
283}
284#else
285static void __init ek_add_device_buttons(void) {}
286#endif
287
288
Andrew Victorc42dcb32007-05-11 19:24:18 +0100289static void __init ek_board_init(void)
290{
291 /* Serial */
Jean-Christophe PLAGNIOL-VILLARD71b149b2012-04-05 14:14:28 +0800292 /* DBGU on ttyS0. (Rx & Tx only) */
293 at91_register_uart(0, 0, 0);
294
295 /* USART0 on ttyS1. (Rx, Tx, CTS, RTS) */
296 at91_register_uart(AT91SAM9RL_ID_US0, 1, ATMEL_UART_CTS | ATMEL_UART_RTS);
Andrew Victorc42dcb32007-05-11 19:24:18 +0100297 at91_add_device_serial();
Nicolas Ferreba45ca42008-04-08 13:59:18 +0100298 /* USB HS */
299 at91_add_device_usba(&ek_usba_udc_data);
Andrew Victorc42dcb32007-05-11 19:24:18 +0100300 /* I2C */
Andrew Victorf230d3f2007-11-19 13:47:20 +0100301 at91_add_device_i2c(NULL, 0);
Andrew Victorc42dcb32007-05-11 19:24:18 +0100302 /* NAND */
Andrew Victor8cdae512008-10-06 20:05:35 +0100303 ek_add_device_nand();
Andrew Victorc42dcb32007-05-11 19:24:18 +0100304 /* SPI */
305 at91_add_device_spi(ek_spi_devices, ARRAY_SIZE(ek_spi_devices));
306 /* MMC */
Ludovic Desroches4cf33262012-05-21 12:23:27 +0200307 at91_add_device_mci(0, &mci0_data);
Andrew Victorc42dcb32007-05-11 19:24:18 +0100308 /* LCD Controller */
309 at91_add_device_lcdc(&ek_lcdc_data);
Nicolas Ferre439a3302009-09-18 16:14:21 +0100310 /* AC97 */
311 at91_add_device_ac97(&ek_ac97_data);
Andrew Victorf7647e62008-09-18 19:45:35 +0100312 /* Touch Screen Controller */
Nicolas Ferre423c9b02009-11-19 09:31:20 -0800313 at91_add_device_tsadcc(&ek_tsadcc_data);
Nicolas Ferre226ddb92009-06-24 17:13:47 +0100314 /* LEDs */
315 at91_gpio_leds(ek_leds, ARRAY_SIZE(ek_leds));
316 /* Push Buttons */
317 ek_add_device_buttons();
Andrew Victorc42dcb32007-05-11 19:24:18 +0100318}
319
320MACHINE_START(AT91SAM9RLEK, "Atmel AT91SAM9RL-EK")
321 /* Maintainer: Atmel */
Andrew Victorc42dcb32007-05-11 19:24:18 +0100322 .timer = &at91sam926x_timer,
Jean-Christophe PLAGNIOL-VILLARD21d08b92011-04-23 15:28:34 +0800323 .map_io = at91_map_io,
Ludovic Desroches3e135462012-06-11 15:38:03 +0200324 .handle_irq = at91_aic_handle_irq,
Jean-Christophe PLAGNIOL-VILLARD1b021a32011-04-28 20:19:32 +0800325 .init_early = ek_init_early,
Jean-Christophe PLAGNIOL-VILLARD92100c12011-04-23 15:28:34 +0800326 .init_irq = at91_init_irq_default,
Andrew Victorc42dcb32007-05-11 19:24:18 +0100327 .init_machine = ek_board_init,
328MACHINE_END