blob: 9120d5d3a6fc31348628d28c2ad1f8a5c6268136 [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>
11#include <linux/init.h>
12#include <linux/mm.h>
13#include <linux/module.h>
14#include <linux/platform_device.h>
15#include <linux/spi/spi.h>
16#include <linux/fb.h>
17#include <linux/clk.h>
Nicolas Ferre226ddb92009-06-24 17:13:47 +010018#include <linux/input.h>
19#include <linux/gpio_keys.h>
Andrew Victorc42dcb32007-05-11 19:24:18 +010020
21#include <video/atmel_lcdc.h>
22
Andrew Victorc42dcb32007-05-11 19:24:18 +010023#include <asm/setup.h>
24#include <asm/mach-types.h>
25#include <asm/irq.h>
26
27#include <asm/mach/arch.h>
28#include <asm/mach/map.h>
29#include <asm/mach/irq.h>
30
Andrew Victore5052402008-09-21 21:30:02 +010031#include <mach/hardware.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010032#include <mach/board.h>
33#include <mach/gpio.h>
Russell King80b02c12009-01-08 10:01:47 +000034#include <mach/at91sam9_smc.h>
Andrew Victor8cdae512008-10-06 20:05:35 +010035#include <mach/at91_shdwc.h>
Andrew Victorc42dcb32007-05-11 19:24:18 +010036
Andrew Victor8cdae512008-10-06 20:05:35 +010037#include "sam9_smc.h"
Andrew Victorc42dcb32007-05-11 19:24:18 +010038#include "generic.h"
39
40
Andrew Victorc42dcb32007-05-11 19:24:18 +010041static void __init ek_map_io(void)
42{
43 /* Initialize processor: 12.000 MHz crystal */
44 at91sam9rl_initialize(12000000);
45
Andrew Victora3da1222008-04-02 21:47:29 +010046 /* DGBU on ttyS0. (Rx & Tx only) */
47 at91_register_uart(0, 0, 0);
48
49 /* USART0 on ttyS1. (Rx, Tx, CTS, RTS) */
50 at91_register_uart(AT91SAM9RL_ID_US0, 1, ATMEL_UART_CTS | ATMEL_UART_RTS);
51
52 /* set serial console to ttyS0 (ie, DBGU) */
53 at91_set_serial_console(0);
Andrew Victorc42dcb32007-05-11 19:24:18 +010054}
55
56static void __init ek_init_irq(void)
57{
58 at91sam9rl_init_interrupts(NULL);
59}
60
61
62/*
Nicolas Ferreba45ca42008-04-08 13:59:18 +010063 * USB HS Device port
64 */
65static struct usba_platform_data __initdata ek_usba_udc_data = {
66 .vbus_pin = AT91_PIN_PA8,
67};
68
69
70/*
Andrew Victorc42dcb32007-05-11 19:24:18 +010071 * MCI (SD/MMC)
72 */
73static struct at91_mmc_data __initdata ek_mmc_data = {
74 .wire4 = 1,
75 .det_pin = AT91_PIN_PA15,
76// .wp_pin = ... not connected
77// .vcc_pin = ... not connected
78};
79
80
81/*
82 * NAND flash
83 */
84static struct mtd_partition __initdata ek_nand_partition[] = {
85 {
86 .name = "Partition 1",
87 .offset = 0,
Andrew Victore5052402008-09-21 21:30:02 +010088 .size = SZ_256K,
Andrew Victorc42dcb32007-05-11 19:24:18 +010089 },
90 {
91 .name = "Partition 2",
Andrew Victore5052402008-09-21 21:30:02 +010092 .offset = MTDPART_OFS_NXTBLK,
Andrew Victorc42dcb32007-05-11 19:24:18 +010093 .size = MTDPART_SIZ_FULL,
94 },
95};
96
Russell Kingcdea4602007-05-30 17:48:45 +010097static struct mtd_partition * __init nand_partitions(int size, int *num_partitions)
Andrew Victorc42dcb32007-05-11 19:24:18 +010098{
99 *num_partitions = ARRAY_SIZE(ek_nand_partition);
100 return ek_nand_partition;
101}
102
HÃ¥vard Skinnemoen3c3796c2008-06-06 18:04:53 +0200103static struct atmel_nand_data __initdata ek_nand_data = {
Andrew Victorc42dcb32007-05-11 19:24:18 +0100104 .ale = 21,
105 .cle = 22,
106// .det_pin = ... not connected
107 .rdy_pin = AT91_PIN_PD17,
108 .enable_pin = AT91_PIN_PB6,
109 .partition_info = nand_partitions,
Andrew Victorc42dcb32007-05-11 19:24:18 +0100110};
111
Andrew Victor8cdae512008-10-06 20:05:35 +0100112static struct sam9_smc_config __initdata ek_nand_smc_config = {
113 .ncs_read_setup = 0,
114 .nrd_setup = 1,
115 .ncs_write_setup = 0,
116 .nwe_setup = 1,
117
118 .ncs_read_pulse = 3,
119 .nrd_pulse = 3,
120 .ncs_write_pulse = 3,
121 .nwe_pulse = 3,
122
123 .read_cycle = 5,
124 .write_cycle = 5,
125
126 .mode = AT91_SMC_READMODE | AT91_SMC_WRITEMODE | AT91_SMC_EXNWMODE_DISABLE | AT91_SMC_DBW_8,
127 .tdf_cycles = 2,
128};
129
130static void __init ek_add_device_nand(void)
131{
132 /* configure chip-select 3 (NAND) */
133 sam9_smc_configure(3, &ek_nand_smc_config);
134
135 at91_add_device_nand(&ek_nand_data);
136}
137
Andrew Victorc42dcb32007-05-11 19:24:18 +0100138
139/*
140 * SPI devices
141 */
142static struct spi_board_info ek_spi_devices[] = {
143 { /* DataFlash chip */
144 .modalias = "mtd_dataflash",
145 .chip_select = 0,
146 .max_speed_hz = 15 * 1000 * 1000,
147 .bus_num = 0,
148 },
149};
150
151
152/*
153 * LCD Controller
154 */
155#if defined(CONFIG_FB_ATMEL) || defined(CONFIG_FB_ATMEL_MODULE)
156static struct fb_videomode at91_tft_vga_modes[] = {
157 {
158 .name = "TX09D50VM1CCA @ 60",
159 .refresh = 60,
160 .xres = 240, .yres = 320,
161 .pixclock = KHZ2PICOS(4965),
162
163 .left_margin = 1, .right_margin = 33,
164 .upper_margin = 1, .lower_margin = 0,
165 .hsync_len = 5, .vsync_len = 1,
166
167 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
168 .vmode = FB_VMODE_NONINTERLACED,
169 },
170};
171
172static struct fb_monspecs at91fb_default_monspecs = {
173 .manufacturer = "HIT",
174 .monitor = "TX09D50VM1CCA",
175
176 .modedb = at91_tft_vga_modes,
177 .modedb_len = ARRAY_SIZE(at91_tft_vga_modes),
178 .hfmin = 15000,
179 .hfmax = 64000,
180 .vfmin = 50,
181 .vfmax = 150,
182};
183
184#define AT91SAM9RL_DEFAULT_LCDCON2 (ATMEL_LCDC_MEMOR_LITTLE \
185 | ATMEL_LCDC_DISTYPE_TFT \
186 | ATMEL_LCDC_CLKMOD_ALWAYSACTIVE)
187
188static void at91_lcdc_power_control(int on)
189{
190 if (on)
191 at91_set_gpio_value(AT91_PIN_PA30, 0); /* power up */
192 else
193 at91_set_gpio_value(AT91_PIN_PA30, 1); /* power down */
194}
195
196/* Driver datas */
197static struct atmel_lcdfb_info __initdata ek_lcdc_data = {
198 .default_bpp = 16,
199 .default_dmacon = ATMEL_LCDC_DMAEN,
200 .default_lcdcon2 = AT91SAM9RL_DEFAULT_LCDCON2,
201 .default_monspecs = &at91fb_default_monspecs,
202 .atmel_lcdfb_power_control = at91_lcdc_power_control,
203 .guard_time = 1,
204};
205
206#else
207static struct atmel_lcdfb_info __initdata ek_lcdc_data;
208#endif
209
210
Nicolas Ferre226ddb92009-06-24 17:13:47 +0100211/*
212 * LEDs
213 */
214static struct gpio_led ek_leds[] = {
215 { /* "bottom" led, green, userled1 to be defined */
216 .name = "ds1",
217 .gpio = AT91_PIN_PD15,
218 .active_low = 1,
219 .default_trigger = "none",
220 },
221 { /* "bottom" led, green, userled2 to be defined */
222 .name = "ds2",
223 .gpio = AT91_PIN_PD16,
224 .active_low = 1,
225 .default_trigger = "none",
226 },
227 { /* "power" led, yellow */
228 .name = "ds3",
229 .gpio = AT91_PIN_PD14,
230 .default_trigger = "heartbeat",
231 }
232};
233
234
235/*
236 * GPIO Buttons
237 */
238#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
239static struct gpio_keys_button ek_buttons[] = {
240 {
241 .gpio = AT91_PIN_PB0,
242 .code = BTN_2,
243 .desc = "Right Click",
244 .active_low = 1,
245 .wakeup = 1,
246 },
247 {
248 .gpio = AT91_PIN_PB1,
249 .code = BTN_1,
250 .desc = "Left Click",
251 .active_low = 1,
252 .wakeup = 1,
253 }
254};
255
256static struct gpio_keys_platform_data ek_button_data = {
257 .buttons = ek_buttons,
258 .nbuttons = ARRAY_SIZE(ek_buttons),
259};
260
261static struct platform_device ek_button_device = {
262 .name = "gpio-keys",
263 .id = -1,
264 .num_resources = 0,
265 .dev = {
266 .platform_data = &ek_button_data,
267 }
268};
269
270static void __init ek_add_device_buttons(void)
271{
272 at91_set_gpio_input(AT91_PIN_PB1, 1); /* btn1 */
273 at91_set_deglitch(AT91_PIN_PB1, 1);
274 at91_set_gpio_input(AT91_PIN_PB0, 1); /* btn2 */
275 at91_set_deglitch(AT91_PIN_PB0, 1);
276
277 platform_device_register(&ek_button_device);
278}
279#else
280static void __init ek_add_device_buttons(void) {}
281#endif
282
283
Andrew Victorc42dcb32007-05-11 19:24:18 +0100284static void __init ek_board_init(void)
285{
286 /* Serial */
287 at91_add_device_serial();
Nicolas Ferreba45ca42008-04-08 13:59:18 +0100288 /* USB HS */
289 at91_add_device_usba(&ek_usba_udc_data);
Andrew Victorc42dcb32007-05-11 19:24:18 +0100290 /* I2C */
Andrew Victorf230d3f2007-11-19 13:47:20 +0100291 at91_add_device_i2c(NULL, 0);
Andrew Victorc42dcb32007-05-11 19:24:18 +0100292 /* NAND */
Andrew Victor8cdae512008-10-06 20:05:35 +0100293 ek_add_device_nand();
Andrew Victorc42dcb32007-05-11 19:24:18 +0100294 /* SPI */
295 at91_add_device_spi(ek_spi_devices, ARRAY_SIZE(ek_spi_devices));
296 /* MMC */
297 at91_add_device_mmc(0, &ek_mmc_data);
298 /* LCD Controller */
299 at91_add_device_lcdc(&ek_lcdc_data);
Andrew Victorf7647e62008-09-18 19:45:35 +0100300 /* Touch Screen Controller */
301 at91_add_device_tsadcc();
Nicolas Ferre226ddb92009-06-24 17:13:47 +0100302 /* LEDs */
303 at91_gpio_leds(ek_leds, ARRAY_SIZE(ek_leds));
304 /* Push Buttons */
305 ek_add_device_buttons();
Andrew Victorc42dcb32007-05-11 19:24:18 +0100306}
307
308MACHINE_START(AT91SAM9RLEK, "Atmel AT91SAM9RL-EK")
309 /* Maintainer: Atmel */
310 .phys_io = AT91_BASE_SYS,
311 .io_pg_offst = (AT91_VA_BASE_SYS >> 18) & 0xfffc,
312 .boot_params = AT91_SDRAM_BASE + 0x100,
313 .timer = &at91sam926x_timer,
314 .map_io = ek_map_io,
315 .init_irq = ek_init_irq,
316 .init_machine = ek_board_init,
317MACHINE_END