Merge git://git.kernel.org/pub/scm/linux/kernel/git/wim/linux-2.6-watchdog
[sfrench/cifs-2.6.git] / arch / blackfin / mach-bf533 / boards / cm_bf533.c
1 /*
2  * File:         arch/blackfin/mach-bf533/boards/cm_bf533.c
3  * Based on:     arch/blackfin/mach-bf533/boards/ezkit.c
4  * Author:       Aidan Williams <aidan@nicta.com.au> Copyright 2005
5  *
6  * Created:      2005
7  * Description:  Board description file
8  *
9  * Modified:
10  *               Copyright 2004-2006 Analog Devices Inc.
11  *
12  * Bugs:         Enter bugs at http://blackfin.uclinux.org/
13  *
14  * This program is free software; you can redistribute it and/or modify
15  * it under the terms of the GNU General Public License as published by
16  * the Free Software Foundation; either version 2 of the License, or
17  * (at your option) any later version.
18  *
19  * This program is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22  * GNU General Public License for more details.
23  *
24  * You should have received a copy of the GNU General Public License
25  * along with this program; if not, see the file COPYING, or write
26  * to the Free Software Foundation, Inc.,
27  * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
28  */
29
30 #include <linux/device.h>
31 #include <linux/platform_device.h>
32 #include <linux/mtd/mtd.h>
33 #include <linux/mtd/partitions.h>
34 #include <linux/spi/spi.h>
35 #include <linux/spi/flash.h>
36 #include <linux/usb_isp1362.h>
37 #include <linux/pata_platform.h>
38 #include <linux/irq.h>
39 #include <asm/dma.h>
40 #include <asm/bfin5xx_spi.h>
41
42 /*
43  * Name the Board for the /proc/cpuinfo
44  */
45 const char bfin_board_name[] = "Bluetechnix CM BF533";
46
47 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
48 /* all SPI peripherals info goes here */
49 #if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE)
50 static struct mtd_partition bfin_spi_flash_partitions[] = {
51         {
52                 .name = "bootloader",
53                 .size = 0x00020000,
54                 .offset = 0,
55                 .mask_flags = MTD_CAP_ROM
56         }, {
57                 .name = "kernel",
58                 .size = 0xe0000,
59                 .offset = 0x20000
60         }, {
61                 .name = "file system",
62                 .size = 0x700000,
63                 .offset = 0x00100000,
64         }
65 };
66
67 static struct flash_platform_data bfin_spi_flash_data = {
68         .name = "m25p80",
69         .parts = bfin_spi_flash_partitions,
70         .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
71         .type = "m25p64",
72 };
73
74 /* SPI flash chip (m25p64) */
75 static struct bfin5xx_spi_chip spi_flash_chip_info = {
76         .enable_dma = 0,         /* use dma transfer with this chip*/
77         .bits_per_word = 8,
78 };
79 #endif
80
81 /* SPI ADC chip */
82 #if defined(CONFIG_SPI_ADC_BF533) || defined(CONFIG_SPI_ADC_BF533_MODULE)
83 static struct bfin5xx_spi_chip spi_adc_chip_info = {
84         .enable_dma = 1,         /* use dma transfer with this chip*/
85         .bits_per_word = 16,
86 };
87 #endif
88
89 #if defined(CONFIG_SND_BLACKFIN_AD1836) || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
90 static struct bfin5xx_spi_chip ad1836_spi_chip_info = {
91         .enable_dma = 0,
92         .bits_per_word = 16,
93 };
94 #endif
95
96 #if defined(CONFIG_SPI_MMC) || defined(CONFIG_SPI_MMC_MODULE)
97 static struct bfin5xx_spi_chip spi_mmc_chip_info = {
98         .enable_dma = 1,
99         .bits_per_word = 8,
100 };
101 #endif
102
103 static struct spi_board_info bfin_spi_board_info[] __initdata = {
104 #if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE)
105         {
106                 /* the modalias must be the same as spi device driver name */
107                 .modalias = "m25p80",       /* Name of spi_driver for this device */
108                 .max_speed_hz = 25000000,     /* max spi clock (SCK) speed in HZ */
109                 .bus_num = 0,               /* Framework bus number */
110                 .chip_select = 1,           /* Framework chip select. On STAMP537 it is SPISSEL1*/
111                 .platform_data = &bfin_spi_flash_data,
112                 .controller_data = &spi_flash_chip_info,
113                 .mode = SPI_MODE_3,
114         },
115 #endif
116
117 #if defined(CONFIG_SPI_ADC_BF533) || defined(CONFIG_SPI_ADC_BF533_MODULE)
118         {
119                 .modalias = "bfin_spi_adc", /* Name of spi_driver for this device */
120                 .max_speed_hz = 6250000,     /* max spi clock (SCK) speed in HZ */
121                 .bus_num = 0,               /* Framework bus number */
122                 .chip_select = 2,           /* Framework chip select. */
123                 .platform_data = NULL,      /* No spi_driver specific config */
124                 .controller_data = &spi_adc_chip_info,
125         },
126 #endif
127
128 #if defined(CONFIG_SND_BLACKFIN_AD1836) || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
129         {
130                 .modalias = "ad1836-spi",
131                 .max_speed_hz = 3125000,     /* max spi clock (SCK) speed in HZ */
132                 .bus_num = 0,
133                 .chip_select = CONFIG_SND_BLACKFIN_SPI_PFBIT,
134                 .controller_data = &ad1836_spi_chip_info,
135         },
136 #endif
137
138 #if defined(CONFIG_SPI_MMC) || defined(CONFIG_SPI_MMC_MODULE)
139         {
140                 .modalias = "spi_mmc_dummy",
141                 .max_speed_hz = 25000000,     /* max spi clock (SCK) speed in HZ */
142                 .bus_num = 0,
143                 .chip_select = 0,
144                 .platform_data = NULL,
145                 .controller_data = &spi_mmc_chip_info,
146                 .mode = SPI_MODE_3,
147         },
148         {
149                 .modalias = "spi_mmc",
150                 .max_speed_hz = 25000000,     /* max spi clock (SCK) speed in HZ */
151                 .bus_num = 0,
152                 .chip_select = CONFIG_SPI_MMC_CS_CHAN,
153                 .platform_data = NULL,
154                 .controller_data = &spi_mmc_chip_info,
155                 .mode = SPI_MODE_3,
156         },
157 #endif
158 };
159
160 /* SPI (0) */
161 static struct resource bfin_spi0_resource[] = {
162         [0] = {
163                 .start = SPI0_REGBASE,
164                 .end   = SPI0_REGBASE + 0xFF,
165                 .flags = IORESOURCE_MEM,
166         },
167         [1] = {
168                 .start = CH_SPI,
169                 .end   = CH_SPI,
170                 .flags = IORESOURCE_IRQ,
171         }
172 };
173
174 /* SPI controller data */
175 static struct bfin5xx_spi_master bfin_spi0_info = {
176         .num_chipselect = 8,
177         .enable_dma = 1,  /* master has the ability to do dma transfer */
178 };
179
180 static struct platform_device bfin_spi0_device = {
181         .name = "bfin-spi",
182         .id = 0, /* Bus number */
183         .num_resources = ARRAY_SIZE(bfin_spi0_resource),
184         .resource = bfin_spi0_resource,
185         .dev = {
186                 .platform_data = &bfin_spi0_info, /* Passed to driver */
187         },
188 };
189 #endif  /* spi master and devices */
190
191 #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
192 static struct platform_device rtc_device = {
193         .name = "rtc-bfin",
194         .id   = -1,
195 };
196 #endif
197
198 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
199 static struct resource smc91x_resources[] = {
200         {
201                 .start = 0x20200300,
202                 .end = 0x20200300 + 16,
203                 .flags = IORESOURCE_MEM,
204         }, {
205                 .start = IRQ_PF0,
206                 .end = IRQ_PF0,
207                 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
208         },
209 };
210 static struct platform_device smc91x_device = {
211         .name = "smc91x",
212         .id = 0,
213         .num_resources = ARRAY_SIZE(smc91x_resources),
214         .resource = smc91x_resources,
215 };
216 #endif
217
218 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
219 static struct resource bfin_uart_resources[] = {
220         {
221                 .start = 0xFFC00400,
222                 .end = 0xFFC004FF,
223                 .flags = IORESOURCE_MEM,
224         },
225 };
226
227 static struct platform_device bfin_uart_device = {
228         .name = "bfin-uart",
229         .id = 1,
230         .num_resources = ARRAY_SIZE(bfin_uart_resources),
231         .resource = bfin_uart_resources,
232 };
233 #endif
234
235 #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
236 static struct platform_device bfin_sport0_uart_device = {
237         .name = "bfin-sport-uart",
238         .id = 0,
239 };
240
241 static struct platform_device bfin_sport1_uart_device = {
242         .name = "bfin-sport-uart",
243         .id = 1,
244 };
245 #endif
246
247 #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
248 static struct resource isp1362_hcd_resources[] = {
249         {
250                 .start = 0x20308000,
251                 .end = 0x20308000,
252                 .flags = IORESOURCE_MEM,
253         }, {
254                 .start = 0x20308004,
255                 .end = 0x20308004,
256                 .flags = IORESOURCE_MEM,
257         }, {
258                 .start = IRQ_PF4,
259                 .end = IRQ_PF4,
260                 .flags = IORESOURCE_IRQ,
261         },
262 };
263
264 static struct isp1362_platform_data isp1362_priv = {
265         .sel15Kres = 1,
266         .clknotstop = 0,
267         .oc_enable = 0,
268         .int_act_high = 0,
269         .int_edge_triggered = 0,
270         .remote_wakeup_connected = 0,
271         .no_power_switching = 1,
272         .power_switching_mode = 0,
273 };
274
275 static struct platform_device isp1362_hcd_device = {
276         .name = "isp1362-hcd",
277         .id = 0,
278         .dev = {
279                 .platform_data = &isp1362_priv,
280         },
281         .num_resources = ARRAY_SIZE(isp1362_hcd_resources),
282         .resource = isp1362_hcd_resources,
283 };
284 #endif
285
286 #if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
287 #define PATA_INT        38
288
289 static struct pata_platform_info bfin_pata_platform_data = {
290         .ioport_shift = 2,
291         .irq_type = IRQF_TRIGGER_HIGH | IRQF_DISABLED,
292 };
293
294 static struct resource bfin_pata_resources[] = {
295         {
296                 .start = 0x2030C000,
297                 .end = 0x2030C01F,
298                 .flags = IORESOURCE_MEM,
299         },
300         {
301                 .start = 0x2030D018,
302                 .end = 0x2030D01B,
303                 .flags = IORESOURCE_MEM,
304         },
305         {
306                 .start = PATA_INT,
307                 .end = PATA_INT,
308                 .flags = IORESOURCE_IRQ,
309         },
310 };
311
312 static struct platform_device bfin_pata_device = {
313         .name = "pata_platform",
314         .id = -1,
315         .num_resources = ARRAY_SIZE(bfin_pata_resources),
316         .resource = bfin_pata_resources,
317         .dev = {
318                 .platform_data = &bfin_pata_platform_data,
319         }
320 };
321 #endif
322
323 static struct platform_device *cm_bf533_devices[] __initdata = {
324 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
325         &bfin_uart_device,
326 #endif
327
328 #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
329         &bfin_sport0_uart_device,
330         &bfin_sport1_uart_device,
331 #endif
332
333 #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
334         &rtc_device,
335 #endif
336
337 #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
338         &isp1362_hcd_device,
339 #endif
340
341 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
342         &smc91x_device,
343 #endif
344
345 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
346         &bfin_spi0_device,
347 #endif
348
349 #if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
350         &bfin_pata_device,
351 #endif
352 };
353
354 static int __init cm_bf533_init(void)
355 {
356         printk(KERN_INFO "%s(): registering device resources\n", __FUNCTION__);
357         platform_add_devices(cm_bf533_devices, ARRAY_SIZE(cm_bf533_devices));
358 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
359         spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
360 #endif
361
362 #if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
363         irq_desc[PATA_INT].status |= IRQ_NOAUTOEN;
364 #endif
365         return 0;
366 }
367
368 arch_initcall(cm_bf533_init);