blob: 337abd2f0c1a0334672ae79b6f42ac16453b3c58 [file] [log] [blame]
Nicolas Ferre789b23b2009-06-26 15:36:58 +01001/*
2 * Board-specific setup code for the AT91SAM9M10G45 Evaluation Kit family
3 *
4 * Covers: * AT91SAM9G45-EKES board
5 * * AT91SAM9M10G45-EK board
6 *
7 * Copyright (C) 2009 Atmel Corporation.
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 */
15
16#include <linux/types.h>
Russell King2f8163b2011-07-26 10:53:52 +010017#include <linux/gpio.h>
Nicolas Ferre789b23b2009-06-26 15:36:58 +010018#include <linux/init.h>
19#include <linux/mm.h>
20#include <linux/module.h>
21#include <linux/platform_device.h>
22#include <linux/spi/spi.h>
23#include <linux/fb.h>
24#include <linux/gpio_keys.h>
25#include <linux/input.h>
26#include <linux/leds.h>
Nicolas Ferre75305d72010-10-22 18:27:48 +020027#include <linux/atmel-mci.h>
Josh Wu343754f2011-10-22 15:17:40 +080028#include <linux/delay.h>
Nicolas Ferre789b23b2009-06-26 15:36:58 +010029
Maxime Ripard4a5920e2012-05-11 15:35:35 +020030#include <linux/platform_data/at91_adc.h>
31
Nicolas Ferre75305d72010-10-22 18:27:48 +020032#include <mach/hardware.h>
Nicolas Ferre789b23b2009-06-26 15:36:58 +010033#include <video/atmel_lcdc.h>
Josh Wu343754f2011-10-22 15:17:40 +080034#include <media/soc_camera.h>
35#include <media/atmel-isi.h>
Nicolas Ferre789b23b2009-06-26 15:36:58 +010036
37#include <asm/setup.h>
38#include <asm/mach-types.h>
39#include <asm/irq.h>
40
41#include <asm/mach/arch.h>
42#include <asm/mach/map.h>
43#include <asm/mach/irq.h>
44
Nicolas Ferre789b23b2009-06-26 15:36:58 +010045#include <mach/board.h>
Nicolas Ferre789b23b2009-06-26 15:36:58 +010046#include <mach/at91sam9_smc.h>
47#include <mach/at91_shdwc.h>
Jean-Christophe PLAGNIOL-VILLARD76b2ab72011-04-14 00:34:03 +080048#include <mach/system_rev.h>
Nicolas Ferre789b23b2009-06-26 15:36:58 +010049
50#include "sam9_smc.h"
51#include "generic.h"
52
53
Jean-Christophe PLAGNIOL-VILLARD1b021a32011-04-28 20:19:32 +080054static void __init ek_init_early(void)
Nicolas Ferre789b23b2009-06-26 15:36:58 +010055{
56 /* Initialize processor: 12.000 MHz crystal */
Jean-Christophe PLAGNIOL-VILLARD21d08b92011-04-23 15:28:34 +080057 at91_initialize(12000000);
Nicolas Ferre789b23b2009-06-26 15:36:58 +010058
59 /* DGBU on ttyS0. (Rx & Tx only) */
60 at91_register_uart(0, 0, 0);
61
62 /* USART0 not connected on the -EK board */
63 /* USART1 on ttyS2. (Rx, Tx, RTS, CTS) */
64 at91_register_uart(AT91SAM9G45_ID_US1, 2, ATMEL_UART_CTS | ATMEL_UART_RTS);
65
66 /* set serial console to ttyS0 (ie, DBGU) */
67 at91_set_serial_console(0);
68}
69
Nicolas Ferre789b23b2009-06-26 15:36:58 +010070/*
71 * USB HS Host port (common to OHCI & EHCI)
72 */
73static struct at91_usbh_data __initdata ek_usbh_hs_data = {
74 .ports = 2,
75 .vbus_pin = {AT91_PIN_PD1, AT91_PIN_PD3},
Nicolas Ferrecca03552012-03-28 11:56:28 +020076 .vbus_pin_active_low = {1, 1},
Jean-Christophe PLAGNIOL-VILLARD63b4c292011-11-25 01:51:06 +080077 .overcurrent_pin= {-EINVAL, -EINVAL},
Nicolas Ferre789b23b2009-06-26 15:36:58 +010078};
79
80
81/*
82 * USB HS Device port
83 */
84static struct usba_platform_data __initdata ek_usba_udc_data = {
85 .vbus_pin = AT91_PIN_PB19,
86};
87
88
89/*
90 * SPI devices.
91 */
92static struct spi_board_info ek_spi_devices[] = {
93 { /* DataFlash chip */
94 .modalias = "mtd_dataflash",
95 .chip_select = 0,
96 .max_speed_hz = 15 * 1000 * 1000,
97 .bus_num = 0,
98 },
99};
100
101
102/*
Nicolas Ferre75305d72010-10-22 18:27:48 +0200103 * MCI (SD/MMC)
104 */
105static struct mci_platform_data __initdata mci0_data = {
106 .slot[0] = {
107 .bus_width = 4,
108 .detect_pin = AT91_PIN_PD10,
Jean-Christophe PLAGNIOL-VILLARD63b4c292011-11-25 01:51:06 +0800109 .wp_pin = -EINVAL,
Nicolas Ferre75305d72010-10-22 18:27:48 +0200110 },
111};
112
113static struct mci_platform_data __initdata mci1_data = {
114 .slot[0] = {
115 .bus_width = 4,
116 .detect_pin = AT91_PIN_PD11,
117 .wp_pin = AT91_PIN_PD29,
118 },
119};
120
121
122/*
Nicolas Ferre789b23b2009-06-26 15:36:58 +0100123 * MACB Ethernet device
124 */
Jamie Iles84e0cdb2011-03-08 20:17:06 +0000125static struct macb_platform_data __initdata ek_macb_data = {
Nicolas Ferre789b23b2009-06-26 15:36:58 +0100126 .phy_irq_pin = AT91_PIN_PD5,
127 .is_rmii = 1,
128};
129
130
131/*
132 * NAND flash
133 */
134static struct mtd_partition __initdata ek_nand_partition[] = {
135 {
136 .name = "Partition 1",
137 .offset = 0,
138 .size = SZ_64M,
139 },
140 {
141 .name = "Partition 2",
142 .offset = MTDPART_OFS_NXTBLK,
143 .size = MTDPART_SIZ_FULL,
144 },
145};
146
Nicolas Ferre789b23b2009-06-26 15:36:58 +0100147/* det_pin is not connected */
148static struct atmel_nand_data __initdata ek_nand_data = {
149 .ale = 21,
150 .cle = 22,
151 .rdy_pin = AT91_PIN_PC8,
152 .enable_pin = AT91_PIN_PC14,
Jean-Christophe PLAGNIOL-VILLARD63b4c292011-11-25 01:51:06 +0800153 .det_pin = -EINVAL,
Jean-Christophe PLAGNIOL-VILLARDbf4289c2011-12-29 14:43:24 +0800154 .ecc_mode = NAND_ECC_SOFT,
Jean-Christophe PLAGNIOL-VILLARD98619dc2011-12-29 15:05:50 +0800155 .on_flash_bbt = 1,
Dmitry Eremin-Solenikov1754aab2011-05-29 17:49:22 +0400156 .parts = ek_nand_partition,
157 .num_parts = ARRAY_SIZE(ek_nand_partition),
Nicolas Ferre789b23b2009-06-26 15:36:58 +0100158};
159
160static struct sam9_smc_config __initdata ek_nand_smc_config = {
161 .ncs_read_setup = 0,
162 .nrd_setup = 2,
163 .ncs_write_setup = 0,
164 .nwe_setup = 2,
165
166 .ncs_read_pulse = 4,
167 .nrd_pulse = 4,
168 .ncs_write_pulse = 4,
169 .nwe_pulse = 4,
170
171 .read_cycle = 7,
172 .write_cycle = 7,
173
174 .mode = AT91_SMC_READMODE | AT91_SMC_WRITEMODE | AT91_SMC_EXNWMODE_DISABLE,
175 .tdf_cycles = 3,
176};
177
178static void __init ek_add_device_nand(void)
179{
Nicolas Ferre64393b32011-07-01 12:25:24 +0200180 ek_nand_data.bus_width_16 = board_have_nand_16bit();
Nicolas Ferre789b23b2009-06-26 15:36:58 +0100181 /* setup bus-width (8 or 16) */
182 if (ek_nand_data.bus_width_16)
183 ek_nand_smc_config.mode |= AT91_SMC_DBW_16;
184 else
185 ek_nand_smc_config.mode |= AT91_SMC_DBW_8;
186
187 /* configure chip-select 3 (NAND) */
Jean-Christophe PLAGNIOL-VILLARDfaee0cc2011-10-14 01:37:09 +0800188 sam9_smc_configure(0, 3, &ek_nand_smc_config);
Nicolas Ferre789b23b2009-06-26 15:36:58 +0100189
190 at91_add_device_nand(&ek_nand_data);
191}
192
193
194/*
Josh Wu343754f2011-10-22 15:17:40 +0800195 * ISI
196 */
197static struct isi_platform_data __initdata isi_data = {
198 .frate = ISI_CFG1_FRATE_CAPTURE_ALL,
199 /* to use codec and preview path simultaneously */
200 .full_mode = 1,
201 .data_width_flags = ISI_DATAWIDTH_8 | ISI_DATAWIDTH_10,
202 /* ISI_MCK is provided by programmable clock or external clock */
203 .mck_hz = 25000000,
204};
205
206
207/*
208 * soc-camera OV2640
209 */
210#if defined(CONFIG_SOC_CAMERA_OV2640) || \
211 defined(CONFIG_SOC_CAMERA_OV2640_MODULE)
212static unsigned long isi_camera_query_bus_param(struct soc_camera_link *link)
213{
214 /* ISI board for ek using default 8-bits connection */
215 return SOCAM_DATAWIDTH_8;
216}
217
218static int i2c_camera_power(struct device *dev, int on)
219{
220 /* enable or disable the camera */
221 pr_debug("%s: %s the camera\n", __func__, on ? "ENABLE" : "DISABLE");
222 at91_set_gpio_output(AT91_PIN_PD13, !on);
223
224 if (!on)
225 goto out;
226
227 /* If enabled, give a reset impulse */
228 at91_set_gpio_output(AT91_PIN_PD12, 0);
229 msleep(20);
230 at91_set_gpio_output(AT91_PIN_PD12, 1);
231 msleep(100);
232
233out:
234 return 0;
235}
236
237static struct i2c_board_info i2c_camera = {
238 I2C_BOARD_INFO("ov2640", 0x30),
239};
240
241static struct soc_camera_link iclink_ov2640 = {
242 .bus_id = 0,
243 .board_info = &i2c_camera,
244 .i2c_adapter_id = 0,
245 .power = i2c_camera_power,
246 .query_bus_param = isi_camera_query_bus_param,
247};
248
249static struct platform_device isi_ov2640 = {
250 .name = "soc-camera-pdrv",
251 .id = 0,
252 .dev = {
253 .platform_data = &iclink_ov2640,
254 },
255};
256#endif
257
258
259/*
Nicolas Ferre789b23b2009-06-26 15:36:58 +0100260 * LCD Controller
261 */
262#if defined(CONFIG_FB_ATMEL) || defined(CONFIG_FB_ATMEL_MODULE)
263static struct fb_videomode at91_tft_vga_modes[] = {
264 {
265 .name = "LG",
266 .refresh = 60,
267 .xres = 480, .yres = 272,
268 .pixclock = KHZ2PICOS(9000),
269
270 .left_margin = 1, .right_margin = 1,
271 .upper_margin = 40, .lower_margin = 1,
272 .hsync_len = 45, .vsync_len = 1,
273
274 .sync = 0,
275 .vmode = FB_VMODE_NONINTERLACED,
276 },
277};
278
279static struct fb_monspecs at91fb_default_monspecs = {
280 .manufacturer = "LG",
281 .monitor = "LB043WQ1",
282
283 .modedb = at91_tft_vga_modes,
284 .modedb_len = ARRAY_SIZE(at91_tft_vga_modes),
285 .hfmin = 15000,
286 .hfmax = 17640,
287 .vfmin = 57,
288 .vfmax = 67,
289};
290
291#define AT91SAM9G45_DEFAULT_LCDCON2 (ATMEL_LCDC_MEMOR_LITTLE \
292 | ATMEL_LCDC_DISTYPE_TFT \
293 | ATMEL_LCDC_CLKMOD_ALWAYSACTIVE)
294
295/* Driver datas */
296static struct atmel_lcdfb_info __initdata ek_lcdc_data = {
297 .lcdcon_is_backlight = true,
298 .default_bpp = 32,
299 .default_dmacon = ATMEL_LCDC_DMAEN,
300 .default_lcdcon2 = AT91SAM9G45_DEFAULT_LCDCON2,
301 .default_monspecs = &at91fb_default_monspecs,
302 .guard_time = 9,
303 .lcd_wiring_mode = ATMEL_LCDC_WIRING_RGB,
304};
305
306#else
307static struct atmel_lcdfb_info __initdata ek_lcdc_data;
308#endif
309
310
311/*
Nicolas Ferre985f37f2009-11-19 09:32:52 -0800312 * Touchscreen
313 */
314static struct at91_tsadcc_data ek_tsadcc_data = {
315 .adc_clock = 300000,
316 .pendet_debounce = 0x0d,
317 .ts_sample_hold_time = 0x0a,
318};
319
Maxime Ripard4a5920e2012-05-11 15:35:35 +0200320/*
321 * ADCs
322 */
323static struct at91_adc_data ek_adc_data = {
324 .channels_used = BIT(0) | BIT(1) | BIT(2) | BIT(3) | BIT(4) | BIT(5) | BIT(6) | BIT(7),
325 .use_external_triggers = true,
326 .vref = 3300,
327};
Nicolas Ferre985f37f2009-11-19 09:32:52 -0800328
329/*
Nicolas Ferre789b23b2009-06-26 15:36:58 +0100330 * GPIO Buttons
331 */
332#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
333static struct gpio_keys_button ek_buttons[] = {
334 { /* BP1, "leftclic" */
335 .code = BTN_LEFT,
336 .gpio = AT91_PIN_PB6,
337 .active_low = 1,
338 .desc = "left_click",
339 .wakeup = 1,
340 },
341 { /* BP2, "rightclic" */
342 .code = BTN_RIGHT,
343 .gpio = AT91_PIN_PB7,
344 .active_low = 1,
345 .desc = "right_click",
346 .wakeup = 1,
347 },
348 /* BP3, "joystick" */
349 {
350 .code = KEY_LEFT,
351 .gpio = AT91_PIN_PB14,
352 .active_low = 1,
353 .desc = "Joystick Left",
354 },
355 {
356 .code = KEY_RIGHT,
357 .gpio = AT91_PIN_PB15,
358 .active_low = 1,
359 .desc = "Joystick Right",
360 },
361 {
362 .code = KEY_UP,
363 .gpio = AT91_PIN_PB16,
364 .active_low = 1,
365 .desc = "Joystick Up",
366 },
367 {
368 .code = KEY_DOWN,
369 .gpio = AT91_PIN_PB17,
370 .active_low = 1,
371 .desc = "Joystick Down",
372 },
373 {
374 .code = KEY_ENTER,
375 .gpio = AT91_PIN_PB18,
376 .active_low = 1,
377 .desc = "Joystick Press",
378 },
379};
380
381static struct gpio_keys_platform_data ek_button_data = {
382 .buttons = ek_buttons,
383 .nbuttons = ARRAY_SIZE(ek_buttons),
384};
385
386static struct platform_device ek_button_device = {
387 .name = "gpio-keys",
388 .id = -1,
389 .num_resources = 0,
390 .dev = {
391 .platform_data = &ek_button_data,
392 }
393};
394
395static void __init ek_add_device_buttons(void)
396{
397 int i;
398
399 for (i = 0; i < ARRAY_SIZE(ek_buttons); i++) {
400 at91_set_GPIO_periph(ek_buttons[i].gpio, 1);
401 at91_set_deglitch(ek_buttons[i].gpio, 1);
402 }
403
404 platform_device_register(&ek_button_device);
405}
406#else
407static void __init ek_add_device_buttons(void) {}
408#endif
409
410
411/*
Nicolas Ferre378ac652009-09-18 16:14:22 +0100412 * AC97
413 * reset_pin is not connected: NRST
414 */
415static struct ac97c_platform_data ek_ac97_data = {
Jean-Christophe PLAGNIOL-VILLARD63b4c292011-11-25 01:51:06 +0800416 .reset_pin = -EINVAL,
Nicolas Ferre378ac652009-09-18 16:14:22 +0100417};
418
419
420/*
Nicolas Ferre789b23b2009-06-26 15:36:58 +0100421 * LEDs ... these could all be PWM-driven, for variable brightness
422 */
423static struct gpio_led ek_leds[] = {
424 { /* "top" led, red, powerled */
425 .name = "d8",
426 .gpio = AT91_PIN_PD30,
427 .default_trigger = "heartbeat",
428 },
429 { /* "left" led, green, userled2, pwm3 */
430 .name = "d6",
431 .gpio = AT91_PIN_PD0,
432 .active_low = 1,
433 .default_trigger = "nand-disk",
434 },
435#if !(defined(CONFIG_LEDS_ATMEL_PWM) || defined(CONFIG_LEDS_ATMEL_PWM_MODULE))
436 { /* "right" led, green, userled1, pwm1 */
437 .name = "d7",
438 .gpio = AT91_PIN_PD31,
439 .active_low = 1,
440 .default_trigger = "mmc0",
441 },
442#endif
443};
444
445
446/*
447 * PWM Leds
448 */
449static struct gpio_led ek_pwm_led[] = {
450#if defined(CONFIG_LEDS_ATMEL_PWM) || defined(CONFIG_LEDS_ATMEL_PWM_MODULE)
451 { /* "right" led, green, userled1, pwm1 */
452 .name = "d7",
453 .gpio = 1, /* is PWM channel number */
454 .active_low = 1,
455 .default_trigger = "none",
456 },
457#endif
458};
459
Josh Wu343754f2011-10-22 15:17:40 +0800460static struct platform_device *devices[] __initdata = {
461#if defined(CONFIG_SOC_CAMERA_OV2640) || \
462 defined(CONFIG_SOC_CAMERA_OV2640_MODULE)
463 &isi_ov2640,
464#endif
465};
Nicolas Ferre789b23b2009-06-26 15:36:58 +0100466
467static void __init ek_board_init(void)
468{
469 /* Serial */
470 at91_add_device_serial();
471 /* USB HS Host */
472 at91_add_device_usbh_ohci(&ek_usbh_hs_data);
Nicolas Ferref51f78c2009-09-25 12:11:32 +0100473 at91_add_device_usbh_ehci(&ek_usbh_hs_data);
Nicolas Ferre789b23b2009-06-26 15:36:58 +0100474 /* USB HS Device */
475 at91_add_device_usba(&ek_usba_udc_data);
476 /* SPI */
477 at91_add_device_spi(ek_spi_devices, ARRAY_SIZE(ek_spi_devices));
Nicolas Ferre75305d72010-10-22 18:27:48 +0200478 /* MMC */
479 at91_add_device_mci(0, &mci0_data);
480 at91_add_device_mci(1, &mci1_data);
Nicolas Ferre789b23b2009-06-26 15:36:58 +0100481 /* Ethernet */
482 at91_add_device_eth(&ek_macb_data);
483 /* NAND */
484 ek_add_device_nand();
485 /* I2C */
486 at91_add_device_i2c(0, NULL, 0);
Josh Wu343754f2011-10-22 15:17:40 +0800487 /* ISI, using programmable clock as ISI_MCK */
488 at91_add_device_isi(&isi_data, true);
Nicolas Ferre789b23b2009-06-26 15:36:58 +0100489 /* LCD Controller */
490 at91_add_device_lcdc(&ek_lcdc_data);
Nicolas Ferre985f37f2009-11-19 09:32:52 -0800491 /* Touch Screen */
492 at91_add_device_tsadcc(&ek_tsadcc_data);
Maxime Ripard4a5920e2012-05-11 15:35:35 +0200493 /* ADC */
494 at91_add_device_adc(&ek_adc_data);
Nicolas Ferre789b23b2009-06-26 15:36:58 +0100495 /* Push Buttons */
496 ek_add_device_buttons();
Nicolas Ferre378ac652009-09-18 16:14:22 +0100497 /* AC97 */
498 at91_add_device_ac97(&ek_ac97_data);
Nicolas Ferre789b23b2009-06-26 15:36:58 +0100499 /* LEDs */
500 at91_gpio_leds(ek_leds, ARRAY_SIZE(ek_leds));
501 at91_pwm_leds(ek_pwm_led, ARRAY_SIZE(ek_pwm_led));
Josh Wu343754f2011-10-22 15:17:40 +0800502 /* Other platform devices */
503 platform_add_devices(devices, ARRAY_SIZE(devices));
Nicolas Ferre789b23b2009-06-26 15:36:58 +0100504}
505
Jean-Christophe PLAGNIOL-VILLARD67dd8992010-09-22 07:55:59 +0200506MACHINE_START(AT91SAM9M10G45EK, "Atmel AT91SAM9M10G45-EK")
Nicolas Ferre789b23b2009-06-26 15:36:58 +0100507 /* Maintainer: Atmel */
Nicolas Ferre789b23b2009-06-26 15:36:58 +0100508 .timer = &at91sam926x_timer,
Jean-Christophe PLAGNIOL-VILLARD21d08b92011-04-23 15:28:34 +0800509 .map_io = at91_map_io,
Jean-Christophe PLAGNIOL-VILLARD1b021a32011-04-28 20:19:32 +0800510 .init_early = ek_init_early,
Jean-Christophe PLAGNIOL-VILLARD92100c12011-04-23 15:28:34 +0800511 .init_irq = at91_init_irq_default,
Nicolas Ferre789b23b2009-06-26 15:36:58 +0100512 .init_machine = ek_board_init,
513MACHINE_END