2 * linux/arch/arm/mach-at91/board-at572d940hf_ek.c
4 * Copyright (C) 2008 Atmel Antonio R. Costa <costa.antonior@gmail.com>
5 * Copyright (C) 2005 SAN People
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include <linux/types.h>
23 #include <linux/init.h>
25 #include <linux/module.h>
26 #include <linux/platform_device.h>
27 #include <linux/spi/spi.h>
28 #include <linux/spi/ds1305.h>
29 #include <linux/irq.h>
30 #include <linux/mtd/physmap.h>
32 #include <mach/hardware.h>
33 #include <asm/setup.h>
34 #include <asm/mach-types.h>
37 #include <asm/mach/arch.h>
38 #include <asm/mach/map.h>
39 #include <asm/mach/irq.h>
41 #include <mach/board.h>
42 #include <mach/gpio.h>
43 #include <mach/at91sam9_smc.h>
44 #include <mach/system_rev.h>
50 static void __init eb_init_early(void)
52 /* Initialize processor: 12.500 MHz crystal */
53 at572d940hf_initialize(12000000);
55 /* DBGU on ttyS0. (Rx & Tx only) */
56 at91_register_uart(0, 0, 0);
58 /* USART0 on ttyS1. (Rx & Tx only) */
59 at91_register_uart(AT572D940HF_ID_US0, 1, 0);
61 /* USART1 on ttyS2. (Rx & Tx only) */
62 at91_register_uart(AT572D940HF_ID_US1, 2, 0);
64 /* USART2 on ttyS3. (Tx & Rx only */
65 at91_register_uart(AT572D940HF_ID_US2, 3, 0);
67 /* set serial console to ttyS0 (ie, DBGU) */
68 at91_set_serial_console(0);
71 static void __init eb_init_irq(void)
73 at572d940hf_init_interrupts(NULL);
80 static struct at91_usbh_data __initdata eb_usbh_data = {
88 static struct at91_udc_data __initdata eb_udc_data = {
89 .vbus_pin = 0, /* no VBUS detection,UDC always on */
90 .pullup_pin = 0, /* pull-up driven by UDC */
97 static struct at91_mmc_data __initdata eb_mmc_data = {
99 /* .det_pin = ... not connected */
100 /* .wp_pin = ... not connected */
101 /* .vcc_pin = ... not connected */
106 * MACB Ethernet device
108 static struct at91_eth_data __initdata eb_eth_data = {
109 .phy_irq_pin = AT91_PIN_PB25,
117 static struct mtd_partition eb_nor_partitions[] = {
119 .name = "Raw Environment",
126 .offset = MTDPART_OFS_APPEND,
132 .offset = MTDPART_OFS_APPEND,
133 .size = MTDPART_SIZ_FULL,
138 static void nor_flash_set_vpp(struct map_info* mi, int i) {
141 static struct physmap_flash_data nor_flash_data = {
143 .parts = eb_nor_partitions,
144 .nr_parts = ARRAY_SIZE(eb_nor_partitions),
145 .set_vpp = nor_flash_set_vpp,
148 static struct resource nor_flash_resources[] = {
150 .start = AT91_CHIPSELECT_0,
151 .end = AT91_CHIPSELECT_0 + SZ_16M - 1,
152 .flags = IORESOURCE_MEM,
156 static struct platform_device nor_flash = {
157 .name = "physmap-flash",
160 .platform_data = &nor_flash_data,
162 .resource = nor_flash_resources,
163 .num_resources = ARRAY_SIZE(nor_flash_resources),
166 static struct sam9_smc_config __initdata eb_nor_smc_config = {
169 .ncs_write_setup = 1,
174 .ncs_write_pulse = 7,
180 .mode = AT91_SMC_READMODE | AT91_SMC_WRITEMODE | AT91_SMC_EXNWMODE_DISABLE | AT91_SMC_BAT_WRITE | AT91_SMC_DBW_32,
184 static void __init eb_add_device_nor(void)
186 /* configure chip-select 0 (NOR) */
187 sam9_smc_configure(0, &eb_nor_smc_config);
188 platform_device_register(&nor_flash);
194 static struct mtd_partition __initdata eb_nand_partition[] = {
196 .name = "Partition 1",
201 .name = "Partition 2",
202 .offset = MTDPART_OFS_NXTBLK,
203 .size = MTDPART_SIZ_FULL,
207 static struct mtd_partition * __init nand_partitions(int size, int *num_partitions)
209 *num_partitions = ARRAY_SIZE(eb_nand_partition);
210 return eb_nand_partition;
213 static struct atmel_nand_data __initdata eb_nand_data = {
216 /* .det_pin = ... not connected */
217 /* .rdy_pin = AT91_PIN_PC16, */
218 .enable_pin = AT91_PIN_PA15,
219 .partition_info = nand_partitions,
222 static struct sam9_smc_config __initdata eb_nand_smc_config = {
225 .ncs_write_setup = 1,
230 .ncs_write_pulse = 3,
236 .mode = AT91_SMC_READMODE | AT91_SMC_WRITEMODE | AT91_SMC_EXNWMODE_DISABLE,
240 static void __init eb_add_device_nand(void)
242 ek_nand_data.bus_width_16 = !board_have_nand_8bit();
243 /* setup bus-width (8 or 16) */
244 if (eb_nand_data.bus_width_16)
245 eb_nand_smc_config.mode |= AT91_SMC_DBW_16;
247 eb_nand_smc_config.mode |= AT91_SMC_DBW_8;
249 /* configure chip-select 3 (NAND) */
250 sam9_smc_configure(3, &eb_nand_smc_config);
252 at91_add_device_nand(&eb_nand_data);
259 static struct resource rtc_resources[] = {
261 .start = AT572D940HF_ID_IRQ1,
262 .end = AT572D940HF_ID_IRQ1,
263 .flags = IORESOURCE_IRQ,
267 static struct ds1305_platform_data ds1306_data = {
272 static struct spi_board_info eb_spi_devices[] = {
273 { /* RTC Dallas DS1306 */
274 .modalias = "rtc-ds1305",
276 .mode = SPI_CS_HIGH | SPI_CPOL | SPI_CPHA,
277 .max_speed_hz = 500000,
279 .irq = AT572D940HF_ID_IRQ1,
280 .platform_data = (void *) &ds1306_data,
282 #if defined(CONFIG_MTD_AT91_DATAFLASH_CARD)
283 { /* Dataflash card */
284 .modalias = "mtd_dataflash",
286 .max_speed_hz = 15 * 1000 * 1000,
292 static void __init eb_board_init(void)
295 at91_add_device_serial();
297 at91_add_device_usbh(&eb_usbh_data);
299 at91_add_device_udc(&eb_udc_data);
301 at91_add_device_i2c(NULL, 0);
305 eb_add_device_nand();
307 at91_add_device_spi(eb_spi_devices, ARRAY_SIZE(eb_spi_devices));
309 at91_add_device_mmc(0, &eb_mmc_data);
311 at91_add_device_eth(&eb_eth_data);
313 at91_add_device_mAgic();
316 MACHINE_START(AT572D940HFEB, "Atmel AT91D940HF-EB")
317 /* Maintainer: Atmel <costa.antonior@gmail.com> */
318 .timer = &at91sam926x_timer,
319 .map_io = at572d940hf_map_io,
320 .init_early = eb_init_early,
321 .init_irq = eb_init_irq,
322 .init_machine = eb_board_init,