blob: 9bc6ab32e0acd2bb9b7d3f60ebd8c0a77d8980b3 [file] [log] [blame]
Andrew Victorffc63b72008-10-06 20:13:53 +01001/*
2 * linux/arch/arm/mach-at91/board-neocore926.c
3 *
4 * Copyright (C) 2005 SAN People
5 * Copyright (C) 2007 Atmel Corporation
6 * Copyright (C) 2008 ADENEO.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */
22
23#include <linux/types.h>
24#include <linux/init.h>
25#include <linux/mm.h>
26#include <linux/module.h>
27#include <linux/platform_device.h>
28#include <linux/spi/spi.h>
29#include <linux/spi/ads7846.h>
30#include <linux/fb.h>
31#include <linux/gpio_keys.h>
32#include <linux/input.h>
33
34#include <video/atmel_lcdc.h>
35
36#include <asm/setup.h>
37#include <asm/mach-types.h>
38#include <asm/irq.h>
39#include <asm/sizes.h>
40
41#include <asm/mach/arch.h>
42#include <asm/mach/map.h>
43#include <asm/mach/irq.h>
44
45#include <mach/hardware.h>
46#include <mach/board.h>
47#include <mach/gpio.h>
48#include <mach/at91sam9_smc.h>
49
50#include "sam9_smc.h"
51#include "generic.h"
52
53
Jean-Christophe PLAGNIOL-VILLARD1b021a32011-04-28 20:19:32 +080054static void __init neocore926_init_early(void)
Andrew Victorffc63b72008-10-06 20:13:53 +010055{
56 /* Initialize processor: 20 MHz crystal */
Jean-Christophe PLAGNIOL-VILLARD21d08b92011-04-23 15:28:34 +080057 at91_initialize(20000000);
Andrew Victorffc63b72008-10-06 20:13:53 +010058
Samuel R. C. Vale4f379402009-07-10 12:07:15 -030059 /* DBGU on ttyS0. (Rx & Tx only) */
Andrew Victorffc63b72008-10-06 20:13:53 +010060 at91_register_uart(0, 0, 0);
61
62 /* USART0 on ttyS1. (Rx, Tx, RTS, CTS) */
63 at91_register_uart(AT91SAM9263_ID_US0, 1, ATMEL_UART_CTS | ATMEL_UART_RTS);
64
65 /* set serial console to ttyS0 (ie, DBGU) */
66 at91_set_serial_console(0);
67}
68
Andrew Victorffc63b72008-10-06 20:13:53 +010069/*
70 * USB Host port
71 */
72static struct at91_usbh_data __initdata neocore926_usbh_data = {
73 .ports = 2,
74 .vbus_pin = { AT91_PIN_PA24, AT91_PIN_PA21 },
75};
76
77/*
78 * USB Device port
79 */
80static struct at91_udc_data __initdata neocore926_udc_data = {
81 .vbus_pin = AT91_PIN_PA25,
82 .pullup_pin = 0, /* pull-up driven by UDC */
83};
84
85
86/*
87 * ADS7846 Touchscreen
88 */
89#if defined(CONFIG_TOUCHSCREEN_ADS7846) || defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE)
90static int ads7843_pendown_state(void)
91{
92 return !at91_get_gpio_value(AT91_PIN_PA15); /* Touchscreen PENIRQ */
93}
94
95static struct ads7846_platform_data ads_info = {
96 .model = 7843,
97 .x_min = 150,
98 .x_max = 3830,
99 .y_min = 190,
100 .y_max = 3830,
101 .vref_delay_usecs = 100,
102 .x_plate_ohms = 450,
103 .y_plate_ohms = 250,
104 .pressure_max = 15000,
105 .debounce_max = 1,
106 .debounce_rep = 0,
107 .debounce_tol = (~0),
108 .get_pendown_state = ads7843_pendown_state,
109};
110
111static void __init neocore926_add_device_ts(void)
112{
113 at91_set_B_periph(AT91_PIN_PA15, 1); /* External IRQ1, with pullup */
114 at91_set_gpio_input(AT91_PIN_PC13, 1); /* Touchscreen BUSY signal */
115}
116#else
117static void __init neocore926_add_device_ts(void) {}
118#endif
119
120/*
121 * SPI devices.
122 */
123static struct spi_board_info neocore926_spi_devices[] = {
124#if defined(CONFIG_MTD_AT91_DATAFLASH_CARD)
125 { /* DataFlash card */
126 .modalias = "mtd_dataflash",
127 .chip_select = 0,
128 .max_speed_hz = 15 * 1000 * 1000,
129 .bus_num = 0,
130 },
131#endif
132#if defined(CONFIG_TOUCHSCREEN_ADS7846) || defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE)
133 {
134 .modalias = "ads7846",
135 .chip_select = 1,
136 .max_speed_hz = 125000 * 16,
137 .bus_num = 0,
138 .platform_data = &ads_info,
139 .irq = AT91SAM9263_ID_IRQ1,
140 },
141#endif
142};
143
144
145/*
146 * MCI (SD/MMC)
147 */
148static struct at91_mmc_data __initdata neocore926_mmc_data = {
149 .wire4 = 1,
150 .det_pin = AT91_PIN_PE18,
151 .wp_pin = AT91_PIN_PE19,
152};
153
154
155/*
156 * MACB Ethernet device
157 */
158static struct at91_eth_data __initdata neocore926_macb_data = {
159 .phy_irq_pin = AT91_PIN_PE31,
160 .is_rmii = 1,
161};
162
163
164/*
165 * NAND flash
166 */
167static struct mtd_partition __initdata neocore926_nand_partition[] = {
168 {
169 .name = "Linux Kernel", /* "Partition 1", */
170 .offset = 0,
171 .size = SZ_8M,
172 },
173 {
174 .name = "Filesystem", /* "Partition 2", */
175 .offset = MTDPART_OFS_NXTBLK,
176 .size = SZ_32M,
177 },
178 {
179 .name = "Free", /* "Partition 3", */
180 .offset = MTDPART_OFS_NXTBLK,
181 .size = MTDPART_SIZ_FULL,
182 },
183};
184
185static struct mtd_partition * __init nand_partitions(int size, int *num_partitions)
186{
187 *num_partitions = ARRAY_SIZE(neocore926_nand_partition);
188 return neocore926_nand_partition;
189}
190
191static struct atmel_nand_data __initdata neocore926_nand_data = {
192 .ale = 21,
193 .cle = 22,
194 .rdy_pin = AT91_PIN_PB19,
195 .rdy_pin_active_low = 1,
196 .enable_pin = AT91_PIN_PD15,
197 .partition_info = nand_partitions,
198};
199
200static struct sam9_smc_config __initdata neocore926_nand_smc_config = {
201 .ncs_read_setup = 0,
202 .nrd_setup = 1,
203 .ncs_write_setup = 0,
204 .nwe_setup = 1,
205
206 .ncs_read_pulse = 4,
207 .nrd_pulse = 4,
208 .ncs_write_pulse = 4,
209 .nwe_pulse = 4,
210
211 .read_cycle = 6,
212 .write_cycle = 6,
213
214 .mode = AT91_SMC_READMODE | AT91_SMC_WRITEMODE | AT91_SMC_EXNWMODE_DISABLE | AT91_SMC_DBW_8,
215 .tdf_cycles = 2,
216};
217
218static void __init neocore926_add_device_nand(void)
219{
220 /* configure chip-select 3 (NAND) */
221 sam9_smc_configure(3, &neocore926_nand_smc_config);
222
223 at91_add_device_nand(&neocore926_nand_data);
224}
225
226
227/*
228 * LCD Controller
229 */
230#if defined(CONFIG_FB_ATMEL) || defined(CONFIG_FB_ATMEL_MODULE)
231static struct fb_videomode at91_tft_vga_modes[] = {
232 {
233 .name = "TX09D50VM1CCA @ 60",
234 .refresh = 60,
235 .xres = 240, .yres = 320,
236 .pixclock = KHZ2PICOS(5000),
237
238 .left_margin = 1, .right_margin = 33,
239 .upper_margin = 1, .lower_margin = 0,
240 .hsync_len = 5, .vsync_len = 1,
241
242 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
243 .vmode = FB_VMODE_NONINTERLACED,
244 },
245};
246
247static struct fb_monspecs at91fb_default_monspecs = {
248 .manufacturer = "HIT",
249 .monitor = "TX09D70VM1CCA",
250
251 .modedb = at91_tft_vga_modes,
252 .modedb_len = ARRAY_SIZE(at91_tft_vga_modes),
253 .hfmin = 15000,
254 .hfmax = 64000,
255 .vfmin = 50,
256 .vfmax = 150,
257};
258
259#define AT91SAM9263_DEFAULT_LCDCON2 (ATMEL_LCDC_MEMOR_LITTLE \
260 | ATMEL_LCDC_DISTYPE_TFT \
261 | ATMEL_LCDC_CLKMOD_ALWAYSACTIVE)
262
263static void at91_lcdc_power_control(int on)
264{
265 at91_set_gpio_value(AT91_PIN_PA30, on);
266}
267
268/* Driver datas */
269static struct atmel_lcdfb_info __initdata neocore926_lcdc_data = {
270 .lcdcon_is_backlight = true,
271 .default_bpp = 16,
272 .default_dmacon = ATMEL_LCDC_DMAEN,
273 .default_lcdcon2 = AT91SAM9263_DEFAULT_LCDCON2,
274 .default_monspecs = &at91fb_default_monspecs,
275 .atmel_lcdfb_power_control = at91_lcdc_power_control,
276 .guard_time = 1,
277 .lcd_wiring_mode = ATMEL_LCDC_WIRING_RGB555,
278};
279
280#else
281static struct atmel_lcdfb_info __initdata neocore926_lcdc_data;
282#endif
283
284
285/*
286 * GPIO Buttons
287 */
288#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
289static struct gpio_keys_button neocore926_buttons[] = {
290 { /* BP1, "leftclic" */
291 .code = BTN_LEFT,
292 .gpio = AT91_PIN_PC5,
293 .active_low = 1,
294 .desc = "left_click",
295 .wakeup = 1,
296 },
297 { /* BP2, "rightclic" */
298 .code = BTN_RIGHT,
299 .gpio = AT91_PIN_PC4,
300 .active_low = 1,
301 .desc = "right_click",
302 .wakeup = 1,
303 },
304};
305
306static struct gpio_keys_platform_data neocore926_button_data = {
307 .buttons = neocore926_buttons,
308 .nbuttons = ARRAY_SIZE(neocore926_buttons),
309};
310
311static struct platform_device neocore926_button_device = {
312 .name = "gpio-keys",
313 .id = -1,
314 .num_resources = 0,
315 .dev = {
316 .platform_data = &neocore926_button_data,
317 }
318};
319
320static void __init neocore926_add_device_buttons(void)
321{
322 at91_set_GPIO_periph(AT91_PIN_PC5, 0); /* left button */
323 at91_set_deglitch(AT91_PIN_PC5, 1);
324 at91_set_GPIO_periph(AT91_PIN_PC4, 0); /* right button */
325 at91_set_deglitch(AT91_PIN_PC4, 1);
326
327 platform_device_register(&neocore926_button_device);
328}
329#else
330static void __init neocore926_add_device_buttons(void) {}
331#endif
332
333
334/*
335 * AC97
336 */
Andrew Victor9173a8e2009-09-22 10:47:50 +0100337static struct ac97c_platform_data neocore926_ac97_data = {
Andrew Victorffc63b72008-10-06 20:13:53 +0100338 .reset_pin = AT91_PIN_PA13,
339};
340
341
342static void __init neocore926_board_init(void)
343{
344 /* Serial */
345 at91_add_device_serial();
346
347 /* USB Host */
348 at91_add_device_usbh(&neocore926_usbh_data);
349
350 /* USB Device */
351 at91_add_device_udc(&neocore926_udc_data);
352
353 /* SPI */
354 at91_set_gpio_output(AT91_PIN_PE20, 1); /* select spi0 clock */
355 at91_add_device_spi(neocore926_spi_devices, ARRAY_SIZE(neocore926_spi_devices));
356
357 /* Touchscreen */
358 neocore926_add_device_ts();
359
360 /* MMC */
361 at91_add_device_mmc(1, &neocore926_mmc_data);
362
363 /* Ethernet */
364 at91_add_device_eth(&neocore926_macb_data);
365
366 /* NAND */
367 neocore926_add_device_nand();
368
369 /* I2C */
370 at91_add_device_i2c(NULL, 0);
371
372 /* LCD Controller */
373 at91_add_device_lcdc(&neocore926_lcdc_data);
374
375 /* Push Buttons */
376 neocore926_add_device_buttons();
377
378 /* AC97 */
379 at91_add_device_ac97(&neocore926_ac97_data);
380}
381
382MACHINE_START(NEOCORE926, "ADENEO NEOCORE 926")
383 /* Maintainer: ADENEO */
Andrew Victorffc63b72008-10-06 20:13:53 +0100384 .timer = &at91sam926x_timer,
Jean-Christophe PLAGNIOL-VILLARD21d08b92011-04-23 15:28:34 +0800385 .map_io = at91_map_io,
Jean-Christophe PLAGNIOL-VILLARD1b021a32011-04-28 20:19:32 +0800386 .init_early = neocore926_init_early,
Jean-Christophe PLAGNIOL-VILLARD92100c12011-04-23 15:28:34 +0800387 .init_irq = at91_init_irq_default,
Andrew Victorffc63b72008-10-06 20:13:53 +0100388 .init_machine = neocore926_board_init,
389MACHINE_END