blob: 39a28effc3df9d2443211e769c7d7de72508957d [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>
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
Jean-Christophe PLAGNIOL-VILLARD1b021a32011-04-28 20:19:32 +080041static void __init ek_init_early(void)
Andrew Victorc42dcb32007-05-11 19:24:18 +010042{
43 /* Initialize processor: 12.000 MHz crystal */
Jean-Christophe PLAGNIOL-VILLARD21d08b92011-04-23 15:28:34 +080044 at91_initialize(12000000);
Andrew Victorc42dcb32007-05-11 19:24:18 +010045
Samuel R. C. Vale4f379402009-07-10 12:07:15 -030046 /* DBGU on ttyS0. (Rx & Tx only) */
Andrew Victora3da1222008-04-02 21:47:29 +010047 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
Andrew Victorc42dcb32007-05-11 19:24:18 +010056/*
Nicolas Ferreba45ca42008-04-08 13:59:18 +010057 * USB HS Device port
58 */
59static struct usba_platform_data __initdata ek_usba_udc_data = {
60 .vbus_pin = AT91_PIN_PA8,
61};
62
63
64/*
Andrew Victorc42dcb32007-05-11 19:24:18 +010065 * MCI (SD/MMC)
66 */
67static struct at91_mmc_data __initdata ek_mmc_data = {
68 .wire4 = 1,
69 .det_pin = AT91_PIN_PA15,
70// .wp_pin = ... not connected
71// .vcc_pin = ... not connected
72};
73
74
75/*
76 * NAND flash
77 */
78static struct mtd_partition __initdata ek_nand_partition[] = {
79 {
80 .name = "Partition 1",
81 .offset = 0,
Andrew Victore5052402008-09-21 21:30:02 +010082 .size = SZ_256K,
Andrew Victorc42dcb32007-05-11 19:24:18 +010083 },
84 {
85 .name = "Partition 2",
Andrew Victore5052402008-09-21 21:30:02 +010086 .offset = MTDPART_OFS_NXTBLK,
Andrew Victorc42dcb32007-05-11 19:24:18 +010087 .size = MTDPART_SIZ_FULL,
88 },
89};
90
Russell Kingcdea4602007-05-30 17:48:45 +010091static struct mtd_partition * __init nand_partitions(int size, int *num_partitions)
Andrew Victorc42dcb32007-05-11 19:24:18 +010092{
93 *num_partitions = ARRAY_SIZE(ek_nand_partition);
94 return ek_nand_partition;
95}
96
HÃ¥vard Skinnemoen3c3796c2008-06-06 18:04:53 +020097static struct atmel_nand_data __initdata ek_nand_data = {
Andrew Victorc42dcb32007-05-11 19:24:18 +010098 .ale = 21,
99 .cle = 22,
100// .det_pin = ... not connected
101 .rdy_pin = AT91_PIN_PD17,
102 .enable_pin = AT91_PIN_PB6,
103 .partition_info = nand_partitions,
Andrew Victorc42dcb32007-05-11 19:24:18 +0100104};
105
Andrew Victor8cdae512008-10-06 20:05:35 +0100106static struct sam9_smc_config __initdata ek_nand_smc_config = {
107 .ncs_read_setup = 0,
108 .nrd_setup = 1,
109 .ncs_write_setup = 0,
110 .nwe_setup = 1,
111
112 .ncs_read_pulse = 3,
113 .nrd_pulse = 3,
114 .ncs_write_pulse = 3,
115 .nwe_pulse = 3,
116
117 .read_cycle = 5,
118 .write_cycle = 5,
119
120 .mode = AT91_SMC_READMODE | AT91_SMC_WRITEMODE | AT91_SMC_EXNWMODE_DISABLE | AT91_SMC_DBW_8,
121 .tdf_cycles = 2,
122};
123
124static void __init ek_add_device_nand(void)
125{
126 /* configure chip-select 3 (NAND) */
127 sam9_smc_configure(3, &ek_nand_smc_config);
128
129 at91_add_device_nand(&ek_nand_data);
130}
131
Andrew Victorc42dcb32007-05-11 19:24:18 +0100132
133/*
134 * SPI devices
135 */
136static struct spi_board_info ek_spi_devices[] = {
137 { /* DataFlash chip */
138 .modalias = "mtd_dataflash",
139 .chip_select = 0,
140 .max_speed_hz = 15 * 1000 * 1000,
141 .bus_num = 0,
142 },
143};
144
145
146/*
147 * LCD Controller
148 */
149#if defined(CONFIG_FB_ATMEL) || defined(CONFIG_FB_ATMEL_MODULE)
150static struct fb_videomode at91_tft_vga_modes[] = {
151 {
152 .name = "TX09D50VM1CCA @ 60",
153 .refresh = 60,
154 .xres = 240, .yres = 320,
155 .pixclock = KHZ2PICOS(4965),
156
157 .left_margin = 1, .right_margin = 33,
158 .upper_margin = 1, .lower_margin = 0,
159 .hsync_len = 5, .vsync_len = 1,
160
161 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
162 .vmode = FB_VMODE_NONINTERLACED,
163 },
164};
165
166static struct fb_monspecs at91fb_default_monspecs = {
167 .manufacturer = "HIT",
168 .monitor = "TX09D50VM1CCA",
169
170 .modedb = at91_tft_vga_modes,
171 .modedb_len = ARRAY_SIZE(at91_tft_vga_modes),
172 .hfmin = 15000,
173 .hfmax = 64000,
174 .vfmin = 50,
175 .vfmax = 150,
176};
177
178#define AT91SAM9RL_DEFAULT_LCDCON2 (ATMEL_LCDC_MEMOR_LITTLE \
179 | ATMEL_LCDC_DISTYPE_TFT \
180 | ATMEL_LCDC_CLKMOD_ALWAYSACTIVE)
181
182static void at91_lcdc_power_control(int on)
183{
184 if (on)
Nicolas Ferre9a24ee02009-06-24 17:13:48 +0100185 at91_set_gpio_value(AT91_PIN_PC1, 0); /* power up */
Andrew Victorc42dcb32007-05-11 19:24:18 +0100186 else
Nicolas Ferre9a24ee02009-06-24 17:13:48 +0100187 at91_set_gpio_value(AT91_PIN_PC1, 1); /* power down */
Andrew Victorc42dcb32007-05-11 19:24:18 +0100188}
189
190/* Driver datas */
191static struct atmel_lcdfb_info __initdata ek_lcdc_data = {
Nicolas Ferre9a24ee02009-06-24 17:13:48 +0100192 .lcdcon_is_backlight = true,
Andrew Victorc42dcb32007-05-11 19:24:18 +0100193 .default_bpp = 16,
194 .default_dmacon = ATMEL_LCDC_DMAEN,
195 .default_lcdcon2 = AT91SAM9RL_DEFAULT_LCDCON2,
196 .default_monspecs = &at91fb_default_monspecs,
197 .atmel_lcdfb_power_control = at91_lcdc_power_control,
198 .guard_time = 1,
Nicolas Ferre9a24ee02009-06-24 17:13:48 +0100199 .lcd_wiring_mode = ATMEL_LCDC_WIRING_RGB,
Andrew Victorc42dcb32007-05-11 19:24:18 +0100200};
201
202#else
203static struct atmel_lcdfb_info __initdata ek_lcdc_data;
204#endif
205
206
Nicolas Ferre226ddb92009-06-24 17:13:47 +0100207/*
Nicolas Ferre439a3302009-09-18 16:14:21 +0100208 * AC97
209 * reset_pin is not connected: NRST
210 */
211static struct ac97c_platform_data ek_ac97_data = {
212};
213
214
215/*
Nicolas Ferre226ddb92009-06-24 17:13:47 +0100216 * LEDs
217 */
218static struct gpio_led ek_leds[] = {
219 { /* "bottom" led, green, userled1 to be defined */
220 .name = "ds1",
221 .gpio = AT91_PIN_PD15,
222 .active_low = 1,
223 .default_trigger = "none",
224 },
225 { /* "bottom" led, green, userled2 to be defined */
226 .name = "ds2",
227 .gpio = AT91_PIN_PD16,
228 .active_low = 1,
229 .default_trigger = "none",
230 },
231 { /* "power" led, yellow */
232 .name = "ds3",
233 .gpio = AT91_PIN_PD14,
234 .default_trigger = "heartbeat",
235 }
236};
237
238
239/*
Nicolas Ferre423c9b02009-11-19 09:31:20 -0800240 * Touchscreen
241 */
242static struct at91_tsadcc_data ek_tsadcc_data = {
243 .adc_clock = 1000000,
244 .pendet_debounce = 0x0f,
245 .ts_sample_hold_time = 0x03,
246};
247
248
249/*
Nicolas Ferre226ddb92009-06-24 17:13:47 +0100250 * GPIO Buttons
251 */
252#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
253static struct gpio_keys_button ek_buttons[] = {
254 {
255 .gpio = AT91_PIN_PB0,
256 .code = BTN_2,
257 .desc = "Right Click",
258 .active_low = 1,
259 .wakeup = 1,
260 },
261 {
262 .gpio = AT91_PIN_PB1,
263 .code = BTN_1,
264 .desc = "Left Click",
265 .active_low = 1,
266 .wakeup = 1,
267 }
268};
269
270static struct gpio_keys_platform_data ek_button_data = {
271 .buttons = ek_buttons,
272 .nbuttons = ARRAY_SIZE(ek_buttons),
273};
274
275static struct platform_device ek_button_device = {
276 .name = "gpio-keys",
277 .id = -1,
278 .num_resources = 0,
279 .dev = {
280 .platform_data = &ek_button_data,
281 }
282};
283
284static void __init ek_add_device_buttons(void)
285{
286 at91_set_gpio_input(AT91_PIN_PB1, 1); /* btn1 */
287 at91_set_deglitch(AT91_PIN_PB1, 1);
288 at91_set_gpio_input(AT91_PIN_PB0, 1); /* btn2 */
289 at91_set_deglitch(AT91_PIN_PB0, 1);
290
291 platform_device_register(&ek_button_device);
292}
293#else
294static void __init ek_add_device_buttons(void) {}
295#endif
296
297
Andrew Victorc42dcb32007-05-11 19:24:18 +0100298static void __init ek_board_init(void)
299{
300 /* Serial */
301 at91_add_device_serial();
Nicolas Ferreba45ca42008-04-08 13:59:18 +0100302 /* USB HS */
303 at91_add_device_usba(&ek_usba_udc_data);
Andrew Victorc42dcb32007-05-11 19:24:18 +0100304 /* I2C */
Andrew Victorf230d3f2007-11-19 13:47:20 +0100305 at91_add_device_i2c(NULL, 0);
Andrew Victorc42dcb32007-05-11 19:24:18 +0100306 /* NAND */
Andrew Victor8cdae512008-10-06 20:05:35 +0100307 ek_add_device_nand();
Andrew Victorc42dcb32007-05-11 19:24:18 +0100308 /* SPI */
309 at91_add_device_spi(ek_spi_devices, ARRAY_SIZE(ek_spi_devices));
310 /* MMC */
311 at91_add_device_mmc(0, &ek_mmc_data);
312 /* LCD Controller */
313 at91_add_device_lcdc(&ek_lcdc_data);
Nicolas Ferre439a3302009-09-18 16:14:21 +0100314 /* AC97 */
315 at91_add_device_ac97(&ek_ac97_data);
Andrew Victorf7647e62008-09-18 19:45:35 +0100316 /* Touch Screen Controller */
Nicolas Ferre423c9b02009-11-19 09:31:20 -0800317 at91_add_device_tsadcc(&ek_tsadcc_data);
Nicolas Ferre226ddb92009-06-24 17:13:47 +0100318 /* LEDs */
319 at91_gpio_leds(ek_leds, ARRAY_SIZE(ek_leds));
320 /* Push Buttons */
321 ek_add_device_buttons();
Andrew Victorc42dcb32007-05-11 19:24:18 +0100322}
323
324MACHINE_START(AT91SAM9RLEK, "Atmel AT91SAM9RL-EK")
325 /* Maintainer: Atmel */
Andrew Victorc42dcb32007-05-11 19:24:18 +0100326 .timer = &at91sam926x_timer,
Jean-Christophe PLAGNIOL-VILLARD21d08b92011-04-23 15:28:34 +0800327 .map_io = at91_map_io,
Jean-Christophe PLAGNIOL-VILLARD1b021a32011-04-28 20:19:32 +0800328 .init_early = ek_init_early,
Jean-Christophe PLAGNIOL-VILLARD92100c12011-04-23 15:28:34 +0800329 .init_irq = at91_init_irq_default,
Andrew Victorc42dcb32007-05-11 19:24:18 +0100330 .init_machine = ek_board_init,
331MACHINE_END