blob: 5dffd3be62d25878b52cdbb46150a7d71ad965ac [file] [log] [blame]
Andrew Victor86640ca2008-01-24 15:16:41 +01001/*
2 * linux/arch/arm/mach-at91/board-cap9adk.c
3 *
4 * Copyright (C) 2007 Stelian Pop <stelian.pop@leadtechdesign.com>
5 * Copyright (C) 2007 Lead Tech Design <www.leadtechdesign.com>
6 * Copyright (C) 2005 SAN People
7 * Copyright (C) 2007 Atmel Corporation.
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 */
23
24#include <linux/types.h>
Russell King2f8163b2011-07-26 10:53:52 +010025#include <linux/gpio.h>
Andrew Victor86640ca2008-01-24 15:16:41 +010026#include <linux/init.h>
27#include <linux/mm.h>
28#include <linux/module.h>
29#include <linux/platform_device.h>
30#include <linux/spi/spi.h>
31#include <linux/spi/ads7846.h>
32#include <linux/fb.h>
33#include <linux/mtd/physmap.h>
34
35#include <video/atmel_lcdc.h>
36
Russell Kinga09e64f2008-08-05 16:14:15 +010037#include <mach/hardware.h>
Andrew Victor86640ca2008-01-24 15:16:41 +010038#include <asm/setup.h>
39#include <asm/mach-types.h>
Andrew Victor86640ca2008-01-24 15:16:41 +010040
41#include <asm/mach/arch.h>
42#include <asm/mach/map.h>
Andrew Victor86640ca2008-01-24 15:16:41 +010043
Russell Kinga09e64f2008-08-05 16:14:15 +010044#include <mach/board.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010045#include <mach/at91cap9_matrix.h>
46#include <mach/at91sam9_smc.h>
Jean-Christophe PLAGNIOL-VILLARD76b2ab72011-04-14 00:34:03 +080047#include <mach/system_rev.h>
Andrew Victor86640ca2008-01-24 15:16:41 +010048
Andrew Victor8cdae512008-10-06 20:05:35 +010049#include "sam9_smc.h"
Andrew Victor86640ca2008-01-24 15:16:41 +010050#include "generic.h"
51
52
Jean-Christophe PLAGNIOL-VILLARD1b021a32011-04-28 20:19:32 +080053static void __init cap9adk_init_early(void)
Andrew Victor86640ca2008-01-24 15:16:41 +010054{
55 /* Initialize processor: 12 MHz crystal */
Jean-Christophe PLAGNIOL-VILLARD21d08b92011-04-23 15:28:34 +080056 at91_initialize(12000000);
Andrew Victor86640ca2008-01-24 15:16:41 +010057
58 /* Setup the LEDs: USER1 and USER2 LED for cpu/timer... */
59 at91_init_leds(AT91_PIN_PA10, AT91_PIN_PA11);
60 /* ... POWER LED always on */
61 at91_set_gpio_output(AT91_PIN_PC29, 1);
62
63 /* Setup the serial ports and console */
64 at91_register_uart(0, 0, 0); /* DBGU = ttyS0 */
65 at91_set_serial_console(0);
66}
67
Andrew Victor86640ca2008-01-24 15:16:41 +010068/*
69 * USB Host port
70 */
71static struct at91_usbh_data __initdata cap9adk_usbh_data = {
72 .ports = 2,
73};
74
Stelian Pop7c8cf662008-04-05 21:15:25 +010075/*
76 * USB HS Device port
77 */
78static struct usba_platform_data __initdata cap9adk_usba_udc_data = {
79 .vbus_pin = AT91_PIN_PB31,
80};
Andrew Victor86640ca2008-01-24 15:16:41 +010081
82/*
83 * ADS7846 Touchscreen
84 */
85#if defined(CONFIG_TOUCHSCREEN_ADS7846) || defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE)
86static int ads7843_pendown_state(void)
87{
88 return !at91_get_gpio_value(AT91_PIN_PC4); /* Touchscreen PENIRQ */
89}
90
91static struct ads7846_platform_data ads_info = {
92 .model = 7843,
93 .x_min = 150,
94 .x_max = 3830,
95 .y_min = 190,
96 .y_max = 3830,
97 .vref_delay_usecs = 100,
98 .x_plate_ohms = 450,
99 .y_plate_ohms = 250,
100 .pressure_max = 15000,
101 .debounce_max = 1,
102 .debounce_rep = 0,
103 .debounce_tol = (~0),
104 .get_pendown_state = ads7843_pendown_state,
105};
106
107static void __init cap9adk_add_device_ts(void)
108{
109 at91_set_gpio_input(AT91_PIN_PC4, 1); /* Touchscreen PENIRQ */
110 at91_set_gpio_input(AT91_PIN_PC5, 1); /* Touchscreen BUSY */
111}
112#else
113static void __init cap9adk_add_device_ts(void) {}
114#endif
115
116
117/*
118 * SPI devices.
119 */
120static struct spi_board_info cap9adk_spi_devices[] = {
121#if defined(CONFIG_MTD_AT91_DATAFLASH_CARD)
122 { /* DataFlash card */
123 .modalias = "mtd_dataflash",
124 .chip_select = 0,
125 .max_speed_hz = 15 * 1000 * 1000,
126 .bus_num = 0,
127 },
128#endif
129#if defined(CONFIG_TOUCHSCREEN_ADS7846) || defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE)
130 {
131 .modalias = "ads7846",
132 .chip_select = 3, /* can be 2 or 3, depending on J2 jumper */
133 .max_speed_hz = 125000 * 26, /* (max sample rate @ 3V) * (cmd + data + overhead) */
134 .bus_num = 0,
135 .platform_data = &ads_info,
136 .irq = AT91_PIN_PC4,
137 },
138#endif
139};
140
141
142/*
143 * MCI (SD/MMC)
144 */
145static struct at91_mmc_data __initdata cap9adk_mmc_data = {
146 .wire4 = 1,
147// .det_pin = ... not connected
148// .wp_pin = ... not connected
149// .vcc_pin = ... not connected
150};
151
152
153/*
154 * MACB Ethernet device
155 */
156static struct at91_eth_data __initdata cap9adk_macb_data = {
157 .is_rmii = 1,
158};
159
160
161/*
162 * NAND flash
163 */
164static struct mtd_partition __initdata cap9adk_nand_partitions[] = {
165 {
166 .name = "NAND partition",
167 .offset = 0,
168 .size = MTDPART_SIZ_FULL,
169 },
170};
171
HÃ¥vard Skinnemoen3c3796c2008-06-06 18:04:53 +0200172static struct atmel_nand_data __initdata cap9adk_nand_data = {
Andrew Victor86640ca2008-01-24 15:16:41 +0100173 .ale = 21,
174 .cle = 22,
175// .det_pin = ... not connected
176// .rdy_pin = ... not connected
177 .enable_pin = AT91_PIN_PD15,
Dmitry Eremin-Solenikov1754aab2011-05-29 17:49:22 +0400178 .parts = cap9adk_nand_partitions,
179 .num_parts = ARRAY_SIZE(cap9adk_nand_partitions),
Andrew Victor86640ca2008-01-24 15:16:41 +0100180};
181
Andrew Victor8cdae512008-10-06 20:05:35 +0100182static struct sam9_smc_config __initdata cap9adk_nand_smc_config = {
183 .ncs_read_setup = 1,
184 .nrd_setup = 2,
185 .ncs_write_setup = 1,
186 .nwe_setup = 2,
187
188 .ncs_read_pulse = 6,
189 .nrd_pulse = 4,
190 .ncs_write_pulse = 6,
191 .nwe_pulse = 4,
192
193 .read_cycle = 8,
194 .write_cycle = 8,
195
196 .mode = AT91_SMC_READMODE | AT91_SMC_WRITEMODE | AT91_SMC_EXNWMODE_DISABLE,
197 .tdf_cycles = 1,
198};
199
200static void __init cap9adk_add_device_nand(void)
201{
202 unsigned long csa;
203
204 csa = at91_sys_read(AT91_MATRIX_EBICSA);
205 at91_sys_write(AT91_MATRIX_EBICSA, csa | AT91_MATRIX_EBI_VDDIOMSEL_3_3V);
206
Nicolas Ferre64393b32011-07-01 12:25:24 +0200207 cap9adk_nand_data.bus_width_16 = board_have_nand_16bit();
Andrew Victor8cdae512008-10-06 20:05:35 +0100208 /* setup bus-width (8 or 16) */
209 if (cap9adk_nand_data.bus_width_16)
210 cap9adk_nand_smc_config.mode |= AT91_SMC_DBW_16;
211 else
212 cap9adk_nand_smc_config.mode |= AT91_SMC_DBW_8;
213
214 /* configure chip-select 3 (NAND) */
215 sam9_smc_configure(3, &cap9adk_nand_smc_config);
216
217 at91_add_device_nand(&cap9adk_nand_data);
218}
219
Andrew Victor86640ca2008-01-24 15:16:41 +0100220
221/*
222 * NOR flash
223 */
224static struct mtd_partition cap9adk_nor_partitions[] = {
225 {
226 .name = "NOR partition",
227 .offset = 0,
228 .size = MTDPART_SIZ_FULL,
229 },
230};
231
232static struct physmap_flash_data cap9adk_nor_data = {
233 .width = 2,
234 .parts = cap9adk_nor_partitions,
235 .nr_parts = ARRAY_SIZE(cap9adk_nor_partitions),
236};
237
238#define NOR_BASE AT91_CHIPSELECT_0
Andrew Victore5052402008-09-21 21:30:02 +0100239#define NOR_SIZE SZ_8M
Andrew Victor86640ca2008-01-24 15:16:41 +0100240
241static struct resource nor_flash_resources[] = {
242 {
243 .start = NOR_BASE,
244 .end = NOR_BASE + NOR_SIZE - 1,
245 .flags = IORESOURCE_MEM,
246 }
247};
248
249static struct platform_device cap9adk_nor_flash = {
250 .name = "physmap-flash",
251 .id = 0,
252 .dev = {
253 .platform_data = &cap9adk_nor_data,
254 },
255 .resource = nor_flash_resources,
256 .num_resources = ARRAY_SIZE(nor_flash_resources),
257};
258
Andrew Victor8cdae512008-10-06 20:05:35 +0100259static struct sam9_smc_config __initdata cap9adk_nor_smc_config = {
260 .ncs_read_setup = 2,
261 .nrd_setup = 4,
262 .ncs_write_setup = 2,
263 .nwe_setup = 4,
264
265 .ncs_read_pulse = 10,
266 .nrd_pulse = 8,
267 .ncs_write_pulse = 10,
268 .nwe_pulse = 8,
269
270 .read_cycle = 16,
271 .write_cycle = 16,
272
273 .mode = AT91_SMC_READMODE | AT91_SMC_WRITEMODE | AT91_SMC_EXNWMODE_DISABLE | AT91_SMC_BAT_WRITE | AT91_SMC_DBW_16,
274 .tdf_cycles = 1,
275};
276
Andrew Victor86640ca2008-01-24 15:16:41 +0100277static __init void cap9adk_add_device_nor(void)
278{
279 unsigned long csa;
280
281 csa = at91_sys_read(AT91_MATRIX_EBICSA);
282 at91_sys_write(AT91_MATRIX_EBICSA, csa | AT91_MATRIX_EBI_VDDIOMSEL_3_3V);
283
Andrew Victor8cdae512008-10-06 20:05:35 +0100284 /* configure chip-select 0 (NOR) */
285 sam9_smc_configure(0, &cap9adk_nor_smc_config);
Andrew Victor86640ca2008-01-24 15:16:41 +0100286
287 platform_device_register(&cap9adk_nor_flash);
288}
289
290
291/*
292 * LCD Controller
293 */
294#if defined(CONFIG_FB_ATMEL) || defined(CONFIG_FB_ATMEL_MODULE)
295static struct fb_videomode at91_tft_vga_modes[] = {
296 {
297 .name = "TX09D50VM1CCA @ 60",
298 .refresh = 60,
299 .xres = 240, .yres = 320,
300 .pixclock = KHZ2PICOS(4965),
301
302 .left_margin = 1, .right_margin = 33,
303 .upper_margin = 1, .lower_margin = 0,
304 .hsync_len = 5, .vsync_len = 1,
305
306 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
307 .vmode = FB_VMODE_NONINTERLACED,
308 },
309};
310
311static struct fb_monspecs at91fb_default_monspecs = {
312 .manufacturer = "HIT",
313 .monitor = "TX09D70VM1CCA",
314
315 .modedb = at91_tft_vga_modes,
316 .modedb_len = ARRAY_SIZE(at91_tft_vga_modes),
317 .hfmin = 15000,
318 .hfmax = 64000,
319 .vfmin = 50,
320 .vfmax = 150,
321};
322
323#define AT91CAP9_DEFAULT_LCDCON2 (ATMEL_LCDC_MEMOR_LITTLE \
324 | ATMEL_LCDC_DISTYPE_TFT \
325 | ATMEL_LCDC_CLKMOD_ALWAYSACTIVE)
326
327static void at91_lcdc_power_control(int on)
328{
329 if (on)
330 at91_set_gpio_value(AT91_PIN_PC0, 0); /* power up */
331 else
332 at91_set_gpio_value(AT91_PIN_PC0, 1); /* power down */
333}
334
335/* Driver datas */
336static struct atmel_lcdfb_info __initdata cap9adk_lcdc_data = {
337 .default_bpp = 16,
338 .default_dmacon = ATMEL_LCDC_DMAEN,
339 .default_lcdcon2 = AT91CAP9_DEFAULT_LCDCON2,
340 .default_monspecs = &at91fb_default_monspecs,
341 .atmel_lcdfb_power_control = at91_lcdc_power_control,
342 .guard_time = 1,
343};
344
345#else
346static struct atmel_lcdfb_info __initdata cap9adk_lcdc_data;
347#endif
348
349
350/*
351 * AC97
352 */
Andrew Victor9173a8e2009-09-22 10:47:50 +0100353static struct ac97c_platform_data cap9adk_ac97_data = {
Andrew Victor86640ca2008-01-24 15:16:41 +0100354// .reset_pin = ... not connected
355};
356
357
358static void __init cap9adk_board_init(void)
359{
360 /* Serial */
361 at91_add_device_serial();
362 /* USB Host */
Andrew Victor86640ca2008-01-24 15:16:41 +0100363 at91_add_device_usbh(&cap9adk_usbh_data);
Stelian Pop7c8cf662008-04-05 21:15:25 +0100364 /* USB HS */
Stelian Pop7c8cf662008-04-05 21:15:25 +0100365 at91_add_device_usba(&cap9adk_usba_udc_data);
Andrew Victor86640ca2008-01-24 15:16:41 +0100366 /* SPI */
367 at91_add_device_spi(cap9adk_spi_devices, ARRAY_SIZE(cap9adk_spi_devices));
368 /* Touchscreen */
369 cap9adk_add_device_ts();
370 /* MMC */
371 at91_add_device_mmc(1, &cap9adk_mmc_data);
372 /* Ethernet */
373 at91_add_device_eth(&cap9adk_macb_data);
374 /* NAND */
Andrew Victor8cdae512008-10-06 20:05:35 +0100375 cap9adk_add_device_nand();
Andrew Victor86640ca2008-01-24 15:16:41 +0100376 /* NOR Flash */
377 cap9adk_add_device_nor();
378 /* I2C */
379 at91_add_device_i2c(NULL, 0);
380 /* LCD Controller */
Andrew Victor86640ca2008-01-24 15:16:41 +0100381 at91_add_device_lcdc(&cap9adk_lcdc_data);
382 /* AC97 */
383 at91_add_device_ac97(&cap9adk_ac97_data);
384}
385
386MACHINE_START(AT91CAP9ADK, "Atmel AT91CAP9A-DK")
387 /* Maintainer: Stelian Pop <stelian.pop@leadtechdesign.com> */
Andrew Victor86640ca2008-01-24 15:16:41 +0100388 .timer = &at91sam926x_timer,
Jean-Christophe PLAGNIOL-VILLARD21d08b92011-04-23 15:28:34 +0800389 .map_io = at91_map_io,
Jean-Christophe PLAGNIOL-VILLARD1b021a32011-04-28 20:19:32 +0800390 .init_early = cap9adk_init_early,
Jean-Christophe PLAGNIOL-VILLARD92100c12011-04-23 15:28:34 +0800391 .init_irq = at91_init_irq_default,
Andrew Victor86640ca2008-01-24 15:16:41 +0100392 .init_machine = cap9adk_board_init,
393MACHINE_END