2 * linux/arch/arm/mach-at91/board-cap9adk.c
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.
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.
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.
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
24 #include <linux/types.h>
25 #include <linux/init.h>
27 #include <linux/module.h>
28 #include <linux/platform_device.h>
29 #include <linux/spi/spi.h>
30 #include <linux/spi/ads7846.h>
32 #include <linux/mtd/physmap.h>
34 #include <video/atmel_lcdc.h>
36 #include <mach/hardware.h>
37 #include <asm/setup.h>
38 #include <asm/mach-types.h>
40 #include <asm/mach/arch.h>
41 #include <asm/mach/map.h>
43 #include <mach/board.h>
44 #include <mach/gpio.h>
45 #include <mach/at91cap9_matrix.h>
46 #include <mach/at91sam9_smc.h>
47 #include <mach/system_rev.h>
53 static void __init
cap9adk_init_early(void)
55 /* Initialize processor: 12 MHz crystal */
56 at91cap9_initialize(12000000);
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);
63 /* Setup the serial ports and console */
64 at91_register_uart(0, 0, 0); /* DBGU = ttyS0 */
65 at91_set_serial_console(0);
68 static void __init
cap9adk_init_irq(void)
70 at91cap9_init_interrupts(NULL
);
77 static struct at91_usbh_data __initdata cap9adk_usbh_data
= {
84 static struct usba_platform_data __initdata cap9adk_usba_udc_data
= {
85 .vbus_pin
= AT91_PIN_PB31
,
91 #if defined(CONFIG_TOUCHSCREEN_ADS7846) || defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE)
92 static int ads7843_pendown_state(void)
94 return !at91_get_gpio_value(AT91_PIN_PC4
); /* Touchscreen PENIRQ */
97 static struct ads7846_platform_data ads_info
= {
103 .vref_delay_usecs
= 100,
106 .pressure_max
= 15000,
109 .debounce_tol
= (~0),
110 .get_pendown_state
= ads7843_pendown_state
,
113 static void __init
cap9adk_add_device_ts(void)
115 at91_set_gpio_input(AT91_PIN_PC4
, 1); /* Touchscreen PENIRQ */
116 at91_set_gpio_input(AT91_PIN_PC5
, 1); /* Touchscreen BUSY */
119 static void __init
cap9adk_add_device_ts(void) {}
126 static struct spi_board_info cap9adk_spi_devices
[] = {
127 #if defined(CONFIG_MTD_AT91_DATAFLASH_CARD)
128 { /* DataFlash card */
129 .modalias
= "mtd_dataflash",
131 .max_speed_hz
= 15 * 1000 * 1000,
135 #if defined(CONFIG_TOUCHSCREEN_ADS7846) || defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE)
137 .modalias
= "ads7846",
138 .chip_select
= 3, /* can be 2 or 3, depending on J2 jumper */
139 .max_speed_hz
= 125000 * 26, /* (max sample rate @ 3V) * (cmd + data + overhead) */
141 .platform_data
= &ads_info
,
151 static struct at91_mmc_data __initdata cap9adk_mmc_data
= {
153 // .det_pin = ... not connected
154 // .wp_pin = ... not connected
155 // .vcc_pin = ... not connected
160 * MACB Ethernet device
162 static struct at91_eth_data __initdata cap9adk_macb_data
= {
170 static struct mtd_partition __initdata cap9adk_nand_partitions
[] = {
172 .name
= "NAND partition",
174 .size
= MTDPART_SIZ_FULL
,
178 static struct mtd_partition
* __init
nand_partitions(int size
, int *num_partitions
)
180 *num_partitions
= ARRAY_SIZE(cap9adk_nand_partitions
);
181 return cap9adk_nand_partitions
;
184 static struct atmel_nand_data __initdata cap9adk_nand_data
= {
187 // .det_pin = ... not connected
188 // .rdy_pin = ... not connected
189 .enable_pin
= AT91_PIN_PD15
,
190 .partition_info
= nand_partitions
,
193 static struct sam9_smc_config __initdata cap9adk_nand_smc_config
= {
196 .ncs_write_setup
= 1,
201 .ncs_write_pulse
= 6,
207 .mode
= AT91_SMC_READMODE
| AT91_SMC_WRITEMODE
| AT91_SMC_EXNWMODE_DISABLE
,
211 static void __init
cap9adk_add_device_nand(void)
215 csa
= at91_sys_read(AT91_MATRIX_EBICSA
);
216 at91_sys_write(AT91_MATRIX_EBICSA
, csa
| AT91_MATRIX_EBI_VDDIOMSEL_3_3V
);
218 cap9adk_nand_data
.bus_width_16
= board_have_nand_16bit();
219 /* setup bus-width (8 or 16) */
220 if (cap9adk_nand_data
.bus_width_16
)
221 cap9adk_nand_smc_config
.mode
|= AT91_SMC_DBW_16
;
223 cap9adk_nand_smc_config
.mode
|= AT91_SMC_DBW_8
;
225 /* configure chip-select 3 (NAND) */
226 sam9_smc_configure(3, &cap9adk_nand_smc_config
);
228 at91_add_device_nand(&cap9adk_nand_data
);
235 static struct mtd_partition cap9adk_nor_partitions
[] = {
237 .name
= "NOR partition",
239 .size
= MTDPART_SIZ_FULL
,
243 static struct physmap_flash_data cap9adk_nor_data
= {
245 .parts
= cap9adk_nor_partitions
,
246 .nr_parts
= ARRAY_SIZE(cap9adk_nor_partitions
),
249 #define NOR_BASE AT91_CHIPSELECT_0
250 #define NOR_SIZE SZ_8M
252 static struct resource nor_flash_resources
[] = {
255 .end
= NOR_BASE
+ NOR_SIZE
- 1,
256 .flags
= IORESOURCE_MEM
,
260 static struct platform_device cap9adk_nor_flash
= {
261 .name
= "physmap-flash",
264 .platform_data
= &cap9adk_nor_data
,
266 .resource
= nor_flash_resources
,
267 .num_resources
= ARRAY_SIZE(nor_flash_resources
),
270 static struct sam9_smc_config __initdata cap9adk_nor_smc_config
= {
273 .ncs_write_setup
= 2,
276 .ncs_read_pulse
= 10,
278 .ncs_write_pulse
= 10,
284 .mode
= AT91_SMC_READMODE
| AT91_SMC_WRITEMODE
| AT91_SMC_EXNWMODE_DISABLE
| AT91_SMC_BAT_WRITE
| AT91_SMC_DBW_16
,
288 static __init
void cap9adk_add_device_nor(void)
292 csa
= at91_sys_read(AT91_MATRIX_EBICSA
);
293 at91_sys_write(AT91_MATRIX_EBICSA
, csa
| AT91_MATRIX_EBI_VDDIOMSEL_3_3V
);
295 /* configure chip-select 0 (NOR) */
296 sam9_smc_configure(0, &cap9adk_nor_smc_config
);
298 platform_device_register(&cap9adk_nor_flash
);
305 #if defined(CONFIG_FB_ATMEL) || defined(CONFIG_FB_ATMEL_MODULE)
306 static struct fb_videomode at91_tft_vga_modes
[] = {
308 .name
= "TX09D50VM1CCA @ 60",
310 .xres
= 240, .yres
= 320,
311 .pixclock
= KHZ2PICOS(4965),
313 .left_margin
= 1, .right_margin
= 33,
314 .upper_margin
= 1, .lower_margin
= 0,
315 .hsync_len
= 5, .vsync_len
= 1,
317 .sync
= FB_SYNC_HOR_HIGH_ACT
| FB_SYNC_VERT_HIGH_ACT
,
318 .vmode
= FB_VMODE_NONINTERLACED
,
322 static struct fb_monspecs at91fb_default_monspecs
= {
323 .manufacturer
= "HIT",
324 .monitor
= "TX09D70VM1CCA",
326 .modedb
= at91_tft_vga_modes
,
327 .modedb_len
= ARRAY_SIZE(at91_tft_vga_modes
),
334 #define AT91CAP9_DEFAULT_LCDCON2 (ATMEL_LCDC_MEMOR_LITTLE \
335 | ATMEL_LCDC_DISTYPE_TFT \
336 | ATMEL_LCDC_CLKMOD_ALWAYSACTIVE)
338 static void at91_lcdc_power_control(int on
)
341 at91_set_gpio_value(AT91_PIN_PC0
, 0); /* power up */
343 at91_set_gpio_value(AT91_PIN_PC0
, 1); /* power down */
347 static struct atmel_lcdfb_info __initdata cap9adk_lcdc_data
= {
349 .default_dmacon
= ATMEL_LCDC_DMAEN
,
350 .default_lcdcon2
= AT91CAP9_DEFAULT_LCDCON2
,
351 .default_monspecs
= &at91fb_default_monspecs
,
352 .atmel_lcdfb_power_control
= at91_lcdc_power_control
,
357 static struct atmel_lcdfb_info __initdata cap9adk_lcdc_data
;
364 static struct ac97c_platform_data cap9adk_ac97_data
= {
365 // .reset_pin = ... not connected
369 static void __init
cap9adk_board_init(void)
372 at91_add_device_serial();
374 at91_add_device_usbh(&cap9adk_usbh_data
);
376 at91_add_device_usba(&cap9adk_usba_udc_data
);
378 at91_add_device_spi(cap9adk_spi_devices
, ARRAY_SIZE(cap9adk_spi_devices
));
380 cap9adk_add_device_ts();
382 at91_add_device_mmc(1, &cap9adk_mmc_data
);
384 at91_add_device_eth(&cap9adk_macb_data
);
386 cap9adk_add_device_nand();
388 cap9adk_add_device_nor();
390 at91_add_device_i2c(NULL
, 0);
392 at91_add_device_lcdc(&cap9adk_lcdc_data
);
394 at91_add_device_ac97(&cap9adk_ac97_data
);
397 MACHINE_START(AT91CAP9ADK
, "Atmel AT91CAP9A-DK")
398 /* Maintainer: Stelian Pop <stelian.pop@leadtechdesign.com> */
399 .timer
= &at91sam926x_timer
,
400 .map_io
= at91cap9_map_io
,
401 .init_early
= cap9adk_init_early
,
402 .init_irq
= cap9adk_init_irq
,
403 .init_machine
= cap9adk_board_init
,