at91: remove MTD_NAND_ATMEL_BUSWIDTH_16 option
[pandora-kernel.git] / arch / arm / mach-at91 / board-at572d940hf_ek.c
1 /*
2  * linux/arch/arm/mach-at91/board-at572d940hf_ek.c
3  *
4  * Copyright (C) 2008 Atmel Antonio R. Costa <costa.antonior@gmail.com>
5  * Copyright (C) 2005 SAN People
6  *
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.
11  *
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.
16  *
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
20  */
21
22 #include <linux/types.h>
23 #include <linux/init.h>
24 #include <linux/mm.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>
31
32 #include <mach/hardware.h>
33 #include <asm/setup.h>
34 #include <asm/mach-types.h>
35 #include <asm/irq.h>
36
37 #include <asm/mach/arch.h>
38 #include <asm/mach/map.h>
39 #include <asm/mach/irq.h>
40
41 #include <mach/board.h>
42 #include <mach/gpio.h>
43 #include <mach/at91sam9_smc.h>
44 #include <mach/system_rev.h>
45
46 #include "sam9_smc.h"
47 #include "generic.h"
48
49
50 static void __init eb_map_io(void)
51 {
52         /* Initialize processor: 12.500 MHz crystal */
53         at572d940hf_initialize(12000000);
54
55         /* DBGU on ttyS0. (Rx & Tx only) */
56         at91_register_uart(0, 0, 0);
57
58         /* USART0 on ttyS1. (Rx & Tx only) */
59         at91_register_uart(AT572D940HF_ID_US0, 1, 0);
60
61         /* USART1 on ttyS2. (Rx & Tx only) */
62         at91_register_uart(AT572D940HF_ID_US1, 2, 0);
63
64         /* USART2 on ttyS3. (Tx & Rx only */
65         at91_register_uart(AT572D940HF_ID_US2, 3, 0);
66
67         /* set serial console to ttyS0 (ie, DBGU) */
68         at91_set_serial_console(0);
69 }
70
71 static void __init eb_init_irq(void)
72 {
73         at572d940hf_init_interrupts(NULL);
74 }
75
76
77 /*
78  * USB Host Port
79  */
80 static struct at91_usbh_data __initdata eb_usbh_data = {
81         .ports          = 2,
82 };
83
84
85 /*
86  * USB Device Port
87  */
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 */
91 };
92
93
94 /*
95  * MCI (SD/MMC)
96  */
97 static struct at91_mmc_data __initdata eb_mmc_data = {
98         .wire4          = 1,
99 /*      .det_pin        = ... not connected */
100 /*      .wp_pin         = ... not connected */
101 /*      .vcc_pin        = ... not connected */
102 };
103
104
105 /*
106  * MACB Ethernet device
107  */
108 static struct at91_eth_data __initdata eb_eth_data = {
109         .phy_irq_pin    = AT91_PIN_PB25,
110         .is_rmii        = 1,
111 };
112
113 /*
114  * NOR flash
115  */
116
117 static struct mtd_partition eb_nor_partitions[] = {
118         {
119                 .name           = "Raw Environment",
120                 .offset         = 0,
121                 .size           = SZ_4M,
122                 .mask_flags     = 0,
123         },
124         {
125                 .name           = "OS FS",
126                 .offset         = MTDPART_OFS_APPEND,
127                 .size           = 3 * SZ_1M,
128                 .mask_flags     = 0,
129         },
130         {
131                 .name           = "APP FS",
132                 .offset         = MTDPART_OFS_APPEND,
133                 .size           = MTDPART_SIZ_FULL,
134                 .mask_flags     = 0,
135         },
136 };
137
138 static void nor_flash_set_vpp(struct map_info* mi, int i) {
139 };
140
141 static struct physmap_flash_data nor_flash_data = {
142         .width          = 4,
143         .parts          = eb_nor_partitions,
144         .nr_parts       = ARRAY_SIZE(eb_nor_partitions),
145         .set_vpp        = nor_flash_set_vpp,
146 };
147
148 static struct resource nor_flash_resources[] = {
149         {
150                 .start  = AT91_CHIPSELECT_0,
151                 .end    = AT91_CHIPSELECT_0 + SZ_16M - 1,
152                 .flags  = IORESOURCE_MEM,
153         },
154 };
155
156 static struct platform_device nor_flash = {
157         .name           = "physmap-flash",
158         .id             = 0,
159         .dev            = {
160                                 .platform_data = &nor_flash_data,
161                         },
162         .resource       = nor_flash_resources,
163         .num_resources  = ARRAY_SIZE(nor_flash_resources),
164 };
165
166 static struct sam9_smc_config __initdata eb_nor_smc_config = {
167         .ncs_read_setup         = 1,
168         .nrd_setup              = 1,
169         .ncs_write_setup        = 1,
170         .nwe_setup              = 1,
171
172         .ncs_read_pulse         = 7,
173         .nrd_pulse              = 7,
174         .ncs_write_pulse        = 7,
175         .nwe_pulse              = 7,
176
177         .read_cycle             = 9,
178         .write_cycle            = 9,
179
180         .mode                   = AT91_SMC_READMODE | AT91_SMC_WRITEMODE | AT91_SMC_EXNWMODE_DISABLE | AT91_SMC_BAT_WRITE | AT91_SMC_DBW_32,
181         .tdf_cycles             = 1,
182 };
183
184 static void __init eb_add_device_nor(void)
185 {
186         /* configure chip-select 0 (NOR) */
187         sam9_smc_configure(0, &eb_nor_smc_config);
188         platform_device_register(&nor_flash);
189 }
190
191 /*
192  * NAND flash
193  */
194 static struct mtd_partition __initdata eb_nand_partition[] = {
195         {
196                 .name   = "Partition 1",
197                 .offset = 0,
198                 .size   = SZ_16M,
199         },
200         {
201                 .name   = "Partition 2",
202                 .offset = MTDPART_OFS_NXTBLK,
203                 .size   = MTDPART_SIZ_FULL,
204         }
205 };
206
207 static struct mtd_partition * __init nand_partitions(int size, int *num_partitions)
208 {
209         *num_partitions = ARRAY_SIZE(eb_nand_partition);
210         return eb_nand_partition;
211 }
212
213 static struct atmel_nand_data __initdata eb_nand_data = {
214         .ale            = 22,
215         .cle            = 21,
216 /*      .det_pin        = ... not connected */
217 /*      .rdy_pin        = AT91_PIN_PC16, */
218         .enable_pin     = AT91_PIN_PA15,
219         .partition_info = nand_partitions,
220 };
221
222 static struct sam9_smc_config __initdata eb_nand_smc_config = {
223         .ncs_read_setup         = 0,
224         .nrd_setup              = 0,
225         .ncs_write_setup        = 1,
226         .nwe_setup              = 1,
227
228         .ncs_read_pulse         = 3,
229         .nrd_pulse              = 3,
230         .ncs_write_pulse        = 3,
231         .nwe_pulse              = 3,
232
233         .read_cycle             = 5,
234         .write_cycle            = 5,
235
236         .mode                   = AT91_SMC_READMODE | AT91_SMC_WRITEMODE | AT91_SMC_EXNWMODE_DISABLE,
237         .tdf_cycles             = 12,
238 };
239
240 static void __init eb_add_device_nand(void)
241 {
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;
246         else
247                 eb_nand_smc_config.mode |= AT91_SMC_DBW_8;
248
249         /* configure chip-select 3 (NAND) */
250         sam9_smc_configure(3, &eb_nand_smc_config);
251
252         at91_add_device_nand(&eb_nand_data);
253 }
254
255
256 /*
257  * SPI devices
258  */
259 static struct resource rtc_resources[] = {
260         [0] = {
261                 .start  = AT572D940HF_ID_IRQ1,
262                 .end    = AT572D940HF_ID_IRQ1,
263                 .flags  = IORESOURCE_IRQ,
264         },
265 };
266
267 static struct ds1305_platform_data ds1306_data = {
268         .is_ds1306      = true,
269         .en_1hz         = false,
270 };
271
272 static struct spi_board_info eb_spi_devices[] = {
273         {       /* RTC Dallas DS1306 */
274                 .modalias       = "rtc-ds1305",
275                 .chip_select    = 3,
276                 .mode           = SPI_CS_HIGH | SPI_CPOL | SPI_CPHA,
277                 .max_speed_hz   = 500000,
278                 .bus_num        = 0,
279                 .irq            = AT572D940HF_ID_IRQ1,
280                 .platform_data  = (void *) &ds1306_data,
281         },
282 #if defined(CONFIG_MTD_AT91_DATAFLASH_CARD)
283         {       /* Dataflash card */
284                 .modalias       = "mtd_dataflash",
285                 .chip_select    = 0,
286                 .max_speed_hz   = 15 * 1000 * 1000,
287                 .bus_num        = 0,
288         },
289 #endif
290 };
291
292 static void __init eb_board_init(void)
293 {
294         /* Serial */
295         at91_add_device_serial();
296         /* USB Host */
297         at91_add_device_usbh(&eb_usbh_data);
298         /* USB Device */
299         at91_add_device_udc(&eb_udc_data);
300         /* I2C */
301         at91_add_device_i2c(NULL, 0);
302         /* NOR */
303         eb_add_device_nor();
304         /* NAND */
305         eb_add_device_nand();
306         /* SPI */
307         at91_add_device_spi(eb_spi_devices, ARRAY_SIZE(eb_spi_devices));
308         /* MMC */
309         at91_add_device_mmc(0, &eb_mmc_data);
310         /* Ethernet */
311         at91_add_device_eth(&eb_eth_data);
312         /* mAgic */
313         at91_add_device_mAgic();
314 }
315
316 MACHINE_START(AT572D940HFEB, "Atmel AT91D940HF-EB")
317         /* Maintainer: Atmel <costa.antonior@gmail.com> */
318         .boot_params    = AT91_SDRAM_BASE + 0x100,
319         .timer          = &at91sam926x_timer,
320         .map_io         = eb_map_io,
321         .init_irq       = eb_init_irq,
322         .init_machine   = eb_board_init,
323 MACHINE_END