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/init.h>
13 #include <linux/module.h>
14 #include <linux/platform_device.h>
15 #include <linux/spi/spi.h>
17 #include <linux/clk.h>
18 #include <linux/input.h>
19 #include <linux/gpio_keys.h>
21 #include <video/atmel_lcdc.h>
23 #include <asm/setup.h>
24 #include <asm/mach-types.h>
27 #include <asm/mach/arch.h>
28 #include <asm/mach/map.h>
29 #include <asm/mach/irq.h>
31 #include <mach/hardware.h>
32 #include <mach/board.h>
33 #include <mach/gpio.h>
34 #include <mach/at91sam9_smc.h>
35 #include <mach/at91_shdwc.h>
41 static void __init
ek_map_io(void)
43 /* Initialize processor: 12.000 MHz crystal */
44 at91sam9rl_initialize(12000000);
46 /* DGBU on ttyS0. (Rx & Tx only) */
47 at91_register_uart(0, 0, 0);
49 /* USART0 on ttyS1. (Rx, Tx, CTS, RTS) */
50 at91_register_uart(AT91SAM9RL_ID_US0
, 1, ATMEL_UART_CTS
| ATMEL_UART_RTS
);
52 /* set serial console to ttyS0 (ie, DBGU) */
53 at91_set_serial_console(0);
56 static void __init
ek_init_irq(void)
58 at91sam9rl_init_interrupts(NULL
);
65 static struct usba_platform_data __initdata ek_usba_udc_data
= {
66 .vbus_pin
= AT91_PIN_PA8
,
73 static struct at91_mmc_data __initdata ek_mmc_data
= {
75 .det_pin
= AT91_PIN_PA15
,
76 // .wp_pin = ... not connected
77 // .vcc_pin = ... not connected
84 static struct mtd_partition __initdata ek_nand_partition
[] = {
86 .name
= "Partition 1",
91 .name
= "Partition 2",
92 .offset
= MTDPART_OFS_NXTBLK
,
93 .size
= MTDPART_SIZ_FULL
,
97 static struct mtd_partition
* __init
nand_partitions(int size
, int *num_partitions
)
99 *num_partitions
= ARRAY_SIZE(ek_nand_partition
);
100 return ek_nand_partition
;
103 static struct atmel_nand_data __initdata ek_nand_data
= {
106 // .det_pin = ... not connected
107 .rdy_pin
= AT91_PIN_PD17
,
108 .enable_pin
= AT91_PIN_PB6
,
109 .partition_info
= nand_partitions
,
112 static struct sam9_smc_config __initdata ek_nand_smc_config
= {
115 .ncs_write_setup
= 0,
120 .ncs_write_pulse
= 3,
126 .mode
= AT91_SMC_READMODE
| AT91_SMC_WRITEMODE
| AT91_SMC_EXNWMODE_DISABLE
| AT91_SMC_DBW_8
,
130 static void __init
ek_add_device_nand(void)
132 /* configure chip-select 3 (NAND) */
133 sam9_smc_configure(3, &ek_nand_smc_config
);
135 at91_add_device_nand(&ek_nand_data
);
142 static struct spi_board_info ek_spi_devices
[] = {
143 { /* DataFlash chip */
144 .modalias
= "mtd_dataflash",
146 .max_speed_hz
= 15 * 1000 * 1000,
155 #if defined(CONFIG_FB_ATMEL) || defined(CONFIG_FB_ATMEL_MODULE)
156 static struct fb_videomode at91_tft_vga_modes
[] = {
158 .name
= "TX09D50VM1CCA @ 60",
160 .xres
= 240, .yres
= 320,
161 .pixclock
= KHZ2PICOS(4965),
163 .left_margin
= 1, .right_margin
= 33,
164 .upper_margin
= 1, .lower_margin
= 0,
165 .hsync_len
= 5, .vsync_len
= 1,
167 .sync
= FB_SYNC_HOR_HIGH_ACT
| FB_SYNC_VERT_HIGH_ACT
,
168 .vmode
= FB_VMODE_NONINTERLACED
,
172 static struct fb_monspecs at91fb_default_monspecs
= {
173 .manufacturer
= "HIT",
174 .monitor
= "TX09D50VM1CCA",
176 .modedb
= at91_tft_vga_modes
,
177 .modedb_len
= ARRAY_SIZE(at91_tft_vga_modes
),
184 #define AT91SAM9RL_DEFAULT_LCDCON2 (ATMEL_LCDC_MEMOR_LITTLE \
185 | ATMEL_LCDC_DISTYPE_TFT \
186 | ATMEL_LCDC_CLKMOD_ALWAYSACTIVE)
188 static void at91_lcdc_power_control(int on
)
191 at91_set_gpio_value(AT91_PIN_PC1
, 0); /* power up */
193 at91_set_gpio_value(AT91_PIN_PC1
, 1); /* power down */
197 static struct atmel_lcdfb_info __initdata ek_lcdc_data
= {
198 .lcdcon_is_backlight
= true,
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
,
205 .lcd_wiring_mode
= ATMEL_LCDC_WIRING_RGB
,
209 static struct atmel_lcdfb_info __initdata ek_lcdc_data
;
216 static struct gpio_led ek_leds
[] = {
217 { /* "bottom" led, green, userled1 to be defined */
219 .gpio
= AT91_PIN_PD15
,
221 .default_trigger
= "none",
223 { /* "bottom" led, green, userled2 to be defined */
225 .gpio
= AT91_PIN_PD16
,
227 .default_trigger
= "none",
229 { /* "power" led, yellow */
231 .gpio
= AT91_PIN_PD14
,
232 .default_trigger
= "heartbeat",
240 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
241 static struct gpio_keys_button ek_buttons
[] = {
243 .gpio
= AT91_PIN_PB0
,
245 .desc
= "Right Click",
250 .gpio
= AT91_PIN_PB1
,
252 .desc
= "Left Click",
258 static struct gpio_keys_platform_data ek_button_data
= {
259 .buttons
= ek_buttons
,
260 .nbuttons
= ARRAY_SIZE(ek_buttons
),
263 static struct platform_device ek_button_device
= {
268 .platform_data
= &ek_button_data
,
272 static void __init
ek_add_device_buttons(void)
274 at91_set_gpio_input(AT91_PIN_PB1
, 1); /* btn1 */
275 at91_set_deglitch(AT91_PIN_PB1
, 1);
276 at91_set_gpio_input(AT91_PIN_PB0
, 1); /* btn2 */
277 at91_set_deglitch(AT91_PIN_PB0
, 1);
279 platform_device_register(&ek_button_device
);
282 static void __init
ek_add_device_buttons(void) {}
286 static void __init
ek_board_init(void)
289 at91_add_device_serial();
291 at91_add_device_usba(&ek_usba_udc_data
);
293 at91_add_device_i2c(NULL
, 0);
295 ek_add_device_nand();
297 at91_add_device_spi(ek_spi_devices
, ARRAY_SIZE(ek_spi_devices
));
299 at91_add_device_mmc(0, &ek_mmc_data
);
301 at91_add_device_lcdc(&ek_lcdc_data
);
302 /* Touch Screen Controller */
303 at91_add_device_tsadcc();
305 at91_gpio_leds(ek_leds
, ARRAY_SIZE(ek_leds
));
307 ek_add_device_buttons();
310 MACHINE_START(AT91SAM9RLEK
, "Atmel AT91SAM9RL-EK")
311 /* Maintainer: Atmel */
312 .phys_io
= AT91_BASE_SYS
,
313 .io_pg_offst
= (AT91_VA_BASE_SYS
>> 18) & 0xfffc,
314 .boot_params
= AT91_SDRAM_BASE
+ 0x100,
315 .timer
= &at91sam926x_timer
,
317 .init_irq
= ek_init_irq
,
318 .init_machine
= ek_board_init
,