aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-at91/board-cap9adk.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/mach-at91/board-cap9adk.c')
-rw-r--r--arch/arm/mach-at91/board-cap9adk.c359
1 files changed, 359 insertions, 0 deletions
diff --git a/arch/arm/mach-at91/board-cap9adk.c b/arch/arm/mach-at91/board-cap9adk.c
new file mode 100644
index 000000000000..185437131541
--- /dev/null
+++ b/arch/arm/mach-at91/board-cap9adk.c
@@ -0,0 +1,359 @@
1/*
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>
25#include <linux/init.h>
26#include <linux/mm.h>
27#include <linux/module.h>
28#include <linux/platform_device.h>
29#include <linux/spi/spi.h>
30#include <linux/spi/ads7846.h>
31#include <linux/fb.h>
32#include <linux/mtd/physmap.h>
33
34#include <video/atmel_lcdc.h>
35
36#include <asm/hardware.h>
37#include <asm/setup.h>
38#include <asm/mach-types.h>
39#include <asm/irq.h>
40
41#include <asm/mach/arch.h>
42#include <asm/mach/map.h>
43#include <asm/mach/irq.h>
44
45#include <asm/arch/board.h>
46#include <asm/arch/gpio.h>
47#include <asm/arch/at91cap9_matrix.h>
48#include <asm/arch/at91sam926x_mc.h>
49
50#include "generic.h"
51
52
53static void __init cap9adk_map_io(void)
54{
55 /* Initialize processor: 12 MHz crystal */
56 at91cap9_initialize(12000000);
57
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
68static void __init cap9adk_init_irq(void)
69{
70 at91cap9_init_interrupts(NULL);
71}
72
73
74/*
75 * USB Host port
76 */
77static struct at91_usbh_data __initdata cap9adk_usbh_data = {
78 .ports = 2,
79};
80
81
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
172static struct mtd_partition * __init nand_partitions(int size, int *num_partitions)
173{
174 *num_partitions = ARRAY_SIZE(cap9adk_nand_partitions);
175 return cap9adk_nand_partitions;
176}
177
178static struct at91_nand_data __initdata cap9adk_nand_data = {
179 .ale = 21,
180 .cle = 22,
181// .det_pin = ... not connected
182// .rdy_pin = ... not connected
183 .enable_pin = AT91_PIN_PD15,
184 .partition_info = nand_partitions,
185#if defined(CONFIG_MTD_NAND_AT91_BUSWIDTH_16)
186 .bus_width_16 = 1,
187#else
188 .bus_width_16 = 0,
189#endif
190};
191
192
193/*
194 * NOR flash
195 */
196static struct mtd_partition cap9adk_nor_partitions[] = {
197 {
198 .name = "NOR partition",
199 .offset = 0,
200 .size = MTDPART_SIZ_FULL,
201 },
202};
203
204static struct physmap_flash_data cap9adk_nor_data = {
205 .width = 2,
206 .parts = cap9adk_nor_partitions,
207 .nr_parts = ARRAY_SIZE(cap9adk_nor_partitions),
208};
209
210#define NOR_BASE AT91_CHIPSELECT_0
211#define NOR_SIZE 0x800000
212
213static struct resource nor_flash_resources[] = {
214 {
215 .start = NOR_BASE,
216 .end = NOR_BASE + NOR_SIZE - 1,
217 .flags = IORESOURCE_MEM,
218 }
219};
220
221static struct platform_device cap9adk_nor_flash = {
222 .name = "physmap-flash",
223 .id = 0,
224 .dev = {
225 .platform_data = &cap9adk_nor_data,
226 },
227 .resource = nor_flash_resources,
228 .num_resources = ARRAY_SIZE(nor_flash_resources),
229};
230
231static __init void cap9adk_add_device_nor(void)
232{
233 unsigned long csa;
234
235 csa = at91_sys_read(AT91_MATRIX_EBICSA);
236 at91_sys_write(AT91_MATRIX_EBICSA, csa | AT91_MATRIX_EBI_VDDIOMSEL_3_3V);
237
238 /* set the bus interface characteristics */
239 at91_sys_write(AT91_SMC_SETUP(0), AT91_SMC_NWESETUP_(4) | AT91_SMC_NCS_WRSETUP_(2)
240 | AT91_SMC_NRDSETUP_(4) | AT91_SMC_NCS_RDSETUP_(2));
241
242 at91_sys_write(AT91_SMC_PULSE(0), AT91_SMC_NWEPULSE_(8) | AT91_SMC_NCS_WRPULSE_(10)
243 | AT91_SMC_NRDPULSE_(8) | AT91_SMC_NCS_RDPULSE_(10));
244
245 at91_sys_write(AT91_SMC_CYCLE(0), AT91_SMC_NWECYCLE_(16) | AT91_SMC_NRDCYCLE_(16));
246
247 at91_sys_write(AT91_SMC_MODE(0), AT91_SMC_READMODE | AT91_SMC_WRITEMODE
248 | AT91_SMC_EXNWMODE_DISABLE | AT91_SMC_BAT_WRITE
249 | AT91_SMC_DBW_16 | AT91_SMC_TDF_(1));
250
251 platform_device_register(&cap9adk_nor_flash);
252}
253
254
255/*
256 * LCD Controller
257 */
258#if defined(CONFIG_FB_ATMEL) || defined(CONFIG_FB_ATMEL_MODULE)
259static struct fb_videomode at91_tft_vga_modes[] = {
260 {
261 .name = "TX09D50VM1CCA @ 60",
262 .refresh = 60,
263 .xres = 240, .yres = 320,
264 .pixclock = KHZ2PICOS(4965),
265
266 .left_margin = 1, .right_margin = 33,
267 .upper_margin = 1, .lower_margin = 0,
268 .hsync_len = 5, .vsync_len = 1,
269
270 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
271 .vmode = FB_VMODE_NONINTERLACED,
272 },
273};
274
275static struct fb_monspecs at91fb_default_monspecs = {
276 .manufacturer = "HIT",
277 .monitor = "TX09D70VM1CCA",
278
279 .modedb = at91_tft_vga_modes,
280 .modedb_len = ARRAY_SIZE(at91_tft_vga_modes),
281 .hfmin = 15000,
282 .hfmax = 64000,
283 .vfmin = 50,
284 .vfmax = 150,
285};
286
287#define AT91CAP9_DEFAULT_LCDCON2 (ATMEL_LCDC_MEMOR_LITTLE \
288 | ATMEL_LCDC_DISTYPE_TFT \
289 | ATMEL_LCDC_CLKMOD_ALWAYSACTIVE)
290
291static void at91_lcdc_power_control(int on)
292{
293 if (on)
294 at91_set_gpio_value(AT91_PIN_PC0, 0); /* power up */
295 else
296 at91_set_gpio_value(AT91_PIN_PC0, 1); /* power down */
297}
298
299/* Driver datas */
300static struct atmel_lcdfb_info __initdata cap9adk_lcdc_data = {
301 .default_bpp = 16,
302 .default_dmacon = ATMEL_LCDC_DMAEN,
303 .default_lcdcon2 = AT91CAP9_DEFAULT_LCDCON2,
304 .default_monspecs = &at91fb_default_monspecs,
305 .atmel_lcdfb_power_control = at91_lcdc_power_control,
306 .guard_time = 1,
307};
308
309#else
310static struct atmel_lcdfb_info __initdata cap9adk_lcdc_data;
311#endif
312
313
314/*
315 * AC97
316 */
317static struct atmel_ac97_data cap9adk_ac97_data = {
318// .reset_pin = ... not connected
319};
320
321
322static void __init cap9adk_board_init(void)
323{
324 /* Serial */
325 at91_add_device_serial();
326 /* USB Host */
327 set_irq_type(AT91CAP9_ID_UHP, IRQT_HIGH);
328 at91_add_device_usbh(&cap9adk_usbh_data);
329 /* SPI */
330 at91_add_device_spi(cap9adk_spi_devices, ARRAY_SIZE(cap9adk_spi_devices));
331 /* Touchscreen */
332 cap9adk_add_device_ts();
333 /* MMC */
334 at91_add_device_mmc(1, &cap9adk_mmc_data);
335 /* Ethernet */
336 at91_add_device_eth(&cap9adk_macb_data);
337 /* NAND */
338 at91_add_device_nand(&cap9adk_nand_data);
339 /* NOR Flash */
340 cap9adk_add_device_nor();
341 /* I2C */
342 at91_add_device_i2c(NULL, 0);
343 /* LCD Controller */
344 set_irq_type(AT91CAP9_ID_LCDC, IRQT_HIGH);
345 at91_add_device_lcdc(&cap9adk_lcdc_data);
346 /* AC97 */
347 at91_add_device_ac97(&cap9adk_ac97_data);
348}
349
350MACHINE_START(AT91CAP9ADK, "Atmel AT91CAP9A-DK")
351 /* Maintainer: Stelian Pop <stelian.pop@leadtechdesign.com> */
352 .phys_io = AT91_BASE_SYS,
353 .io_pg_offst = (AT91_VA_BASE_SYS >> 18) & 0xfffc,
354 .boot_params = AT91_SDRAM_BASE + 0x100,
355 .timer = &at91sam926x_timer,
356 .map_io = cap9adk_map_io,
357 .init_irq = cap9adk_init_irq,
358 .init_machine = cap9adk_board_init,
359MACHINE_END