2 * Copyright (C) 2005 SAN People
3 * Copyright (C) 2007 Atmel Corporation
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
10 #include <linux/types.h>
11 #include <linux/gpio.h>
12 #include <linux/init.h>
14 #include <linux/module.h>
15 #include <linux/platform_device.h>
16 #include <linux/spi/spi.h>
18 #include <linux/clk.h>
19 #include <linux/input.h>
20 #include <linux/gpio_keys.h>
22 #include <video/atmel_lcdc.h>
24 #include <asm/setup.h>
25 #include <asm/mach-types.h>
28 #include <asm/mach/arch.h>
29 #include <asm/mach/map.h>
30 #include <asm/mach/irq.h>
32 #include <mach/hardware.h>
33 #include <mach/board.h>
34 #include <mach/at91_aic.h>
35 #include <mach/at91sam9_smc.h>
36 #include <mach/at91_shdwc.h>
42 static void __init
ek_init_early(void)
44 /* Initialize processor: 12.000 MHz crystal */
45 at91_initialize(12000000);
51 static struct usba_platform_data __initdata ek_usba_udc_data
= {
52 .vbus_pin
= AT91_PIN_PA8
,
59 static struct at91_mmc_data __initdata ek_mmc_data
= {
61 .det_pin
= AT91_PIN_PA15
,
70 static struct mtd_partition __initdata ek_nand_partition
[] = {
72 .name
= "Partition 1",
77 .name
= "Partition 2",
78 .offset
= MTDPART_OFS_NXTBLK
,
79 .size
= MTDPART_SIZ_FULL
,
83 static struct atmel_nand_data __initdata ek_nand_data
= {
87 .rdy_pin
= AT91_PIN_PD17
,
88 .enable_pin
= AT91_PIN_PB6
,
89 .ecc_mode
= NAND_ECC_SOFT
,
91 .parts
= ek_nand_partition
,
92 .num_parts
= ARRAY_SIZE(ek_nand_partition
),
95 static struct sam9_smc_config __initdata ek_nand_smc_config
= {
103 .ncs_write_pulse
= 3,
109 .mode
= AT91_SMC_READMODE
| AT91_SMC_WRITEMODE
| AT91_SMC_EXNWMODE_DISABLE
| AT91_SMC_DBW_8
,
113 static void __init
ek_add_device_nand(void)
115 /* configure chip-select 3 (NAND) */
116 sam9_smc_configure(0, 3, &ek_nand_smc_config
);
118 at91_add_device_nand(&ek_nand_data
);
125 static struct spi_board_info ek_spi_devices
[] = {
126 { /* DataFlash chip */
127 .modalias
= "mtd_dataflash",
129 .max_speed_hz
= 15 * 1000 * 1000,
138 #if defined(CONFIG_FB_ATMEL) || defined(CONFIG_FB_ATMEL_MODULE)
139 static struct fb_videomode at91_tft_vga_modes
[] = {
141 .name
= "TX09D50VM1CCA @ 60",
143 .xres
= 240, .yres
= 320,
144 .pixclock
= KHZ2PICOS(4965),
146 .left_margin
= 1, .right_margin
= 33,
147 .upper_margin
= 1, .lower_margin
= 0,
148 .hsync_len
= 5, .vsync_len
= 1,
150 .sync
= FB_SYNC_HOR_HIGH_ACT
| FB_SYNC_VERT_HIGH_ACT
,
151 .vmode
= FB_VMODE_NONINTERLACED
,
155 static struct fb_monspecs at91fb_default_monspecs
= {
156 .manufacturer
= "HIT",
157 .monitor
= "TX09D50VM1CCA",
159 .modedb
= at91_tft_vga_modes
,
160 .modedb_len
= ARRAY_SIZE(at91_tft_vga_modes
),
167 #define AT91SAM9RL_DEFAULT_LCDCON2 (ATMEL_LCDC_MEMOR_LITTLE \
168 | ATMEL_LCDC_DISTYPE_TFT \
169 | ATMEL_LCDC_CLKMOD_ALWAYSACTIVE)
171 static void at91_lcdc_power_control(int on
)
174 at91_set_gpio_value(AT91_PIN_PC1
, 0); /* power up */
176 at91_set_gpio_value(AT91_PIN_PC1
, 1); /* power down */
180 static struct atmel_lcdfb_info __initdata ek_lcdc_data
= {
181 .lcdcon_is_backlight
= true,
183 .default_dmacon
= ATMEL_LCDC_DMAEN
,
184 .default_lcdcon2
= AT91SAM9RL_DEFAULT_LCDCON2
,
185 .default_monspecs
= &at91fb_default_monspecs
,
186 .atmel_lcdfb_power_control
= at91_lcdc_power_control
,
188 .lcd_wiring_mode
= ATMEL_LCDC_WIRING_RGB
,
192 static struct atmel_lcdfb_info __initdata ek_lcdc_data
;
198 * reset_pin is not connected: NRST
200 static struct ac97c_platform_data ek_ac97_data
= {
201 .reset_pin
= -EINVAL
,
208 static struct gpio_led ek_leds
[] = {
209 { /* "bottom" led, green, userled1 to be defined */
211 .gpio
= AT91_PIN_PD15
,
213 .default_trigger
= "none",
215 { /* "bottom" led, green, userled2 to be defined */
217 .gpio
= AT91_PIN_PD16
,
219 .default_trigger
= "none",
221 { /* "power" led, yellow */
223 .gpio
= AT91_PIN_PD14
,
224 .default_trigger
= "heartbeat",
232 static struct at91_tsadcc_data ek_tsadcc_data
= {
233 .adc_clock
= 1000000,
234 .pendet_debounce
= 0x0f,
235 .ts_sample_hold_time
= 0x03,
242 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
243 static struct gpio_keys_button ek_buttons
[] = {
245 .gpio
= AT91_PIN_PB0
,
247 .desc
= "Right Click",
252 .gpio
= AT91_PIN_PB1
,
254 .desc
= "Left Click",
260 static struct gpio_keys_platform_data ek_button_data
= {
261 .buttons
= ek_buttons
,
262 .nbuttons
= ARRAY_SIZE(ek_buttons
),
265 static struct platform_device ek_button_device
= {
270 .platform_data
= &ek_button_data
,
274 static void __init
ek_add_device_buttons(void)
276 at91_set_gpio_input(AT91_PIN_PB1
, 1); /* btn1 */
277 at91_set_deglitch(AT91_PIN_PB1
, 1);
278 at91_set_gpio_input(AT91_PIN_PB0
, 1); /* btn2 */
279 at91_set_deglitch(AT91_PIN_PB0
, 1);
281 platform_device_register(&ek_button_device
);
284 static void __init
ek_add_device_buttons(void) {}
288 static void __init
ek_board_init(void)
291 /* DBGU on ttyS0. (Rx & Tx only) */
292 at91_register_uart(0, 0, 0);
294 /* USART0 on ttyS1. (Rx, Tx, CTS, RTS) */
295 at91_register_uart(AT91SAM9RL_ID_US0
, 1, ATMEL_UART_CTS
| ATMEL_UART_RTS
);
296 at91_add_device_serial();
298 at91_add_device_usba(&ek_usba_udc_data
);
300 at91_add_device_i2c(NULL
, 0);
302 ek_add_device_nand();
304 at91_add_device_spi(ek_spi_devices
, ARRAY_SIZE(ek_spi_devices
));
306 at91_add_device_mmc(0, &ek_mmc_data
);
308 at91_add_device_lcdc(&ek_lcdc_data
);
310 at91_add_device_ac97(&ek_ac97_data
);
311 /* Touch Screen Controller */
312 at91_add_device_tsadcc(&ek_tsadcc_data
);
314 at91_gpio_leds(ek_leds
, ARRAY_SIZE(ek_leds
));
316 ek_add_device_buttons();
319 MACHINE_START(AT91SAM9RLEK
, "Atmel AT91SAM9RL-EK")
320 /* Maintainer: Atmel */
321 .timer
= &at91sam926x_timer
,
322 .map_io
= at91_map_io
,
323 .handle_irq
= at91_aic_handle_irq
,
324 .init_early
= ek_init_early
,
325 .init_irq
= at91_init_irq_default
,
326 .init_machine
= ek_board_init
,