Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6
[sfrench/cifs-2.6.git] / arch / blackfin / mach-bf537 / boards / cm_bf537.c
1 /*
2  * File:         arch/blackfin/mach-bf537/boards/cm_bf537.c
3  * Based on:     arch/blackfin/mach-bf533/boards/ezkit.c
4  * Author:       Aidan Williams <aidan@nicta.com.au>
5  *
6  * Created:      2005
7  * Description:  Board description file
8  *
9  * Modified:
10  *               Copyright 2005 National ICT Australia (NICTA)
11  *               Copyright 2004-2006 Analog Devices Inc.
12  *
13  * Bugs:         Enter bugs at http://blackfin.uclinux.org/
14  *
15  * This program is free software; you can redistribute it and/or modify
16  * it under the terms of the GNU General Public License as published by
17  * the Free Software Foundation; either version 2 of the License, or
18  * (at your option) any later version.
19  *
20  * This program is distributed in the hope that it will be useful,
21  * but WITHOUT ANY WARRANTY; without even the implied warranty of
22  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23  * GNU General Public License for more details.
24  *
25  * You should have received a copy of the GNU General Public License
26  * along with this program; if not, see the file COPYING, or write
27  * to the Free Software Foundation, Inc.,
28  * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
29  */
30
31 #include <linux/device.h>
32 #include <linux/etherdevice.h>
33 #include <linux/platform_device.h>
34 #include <linux/mtd/mtd.h>
35 #include <linux/mtd/partitions.h>
36 #include <linux/spi/spi.h>
37 #include <linux/spi/flash.h>
38 #include <linux/usb/isp1362.h>
39 #include <linux/ata_platform.h>
40 #include <linux/irq.h>
41 #include <asm/dma.h>
42 #include <asm/bfin5xx_spi.h>
43 #include <asm/portmux.h>
44
45 /*
46  * Name the Board for the /proc/cpuinfo
47  */
48 const char bfin_board_name[] = "Bluetechnix CM BF537";
49
50 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
51 /* all SPI peripherals info goes here */
52
53 #if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE)
54 static struct mtd_partition bfin_spi_flash_partitions[] = {
55         {
56                 .name = "bootloader",
57                 .size = 0x00020000,
58                 .offset = 0,
59                 .mask_flags = MTD_CAP_ROM
60         }, {
61                 .name = "kernel",
62                 .size = 0xe0000,
63                 .offset = 0x20000
64         }, {
65                 .name = "file system",
66                 .size = 0x700000,
67                 .offset = 0x00100000,
68         }
69 };
70
71 static struct flash_platform_data bfin_spi_flash_data = {
72         .name = "m25p80",
73         .parts = bfin_spi_flash_partitions,
74         .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
75         .type = "m25p64",
76 };
77
78 /* SPI flash chip (m25p64) */
79 static struct bfin5xx_spi_chip spi_flash_chip_info = {
80         .enable_dma = 0,         /* use dma transfer with this chip*/
81         .bits_per_word = 8,
82 };
83 #endif
84
85 #if defined(CONFIG_SPI_ADC_BF533) || defined(CONFIG_SPI_ADC_BF533_MODULE)
86 /* SPI ADC chip */
87 static struct bfin5xx_spi_chip spi_adc_chip_info = {
88         .enable_dma = 1,         /* use dma transfer with this chip*/
89         .bits_per_word = 16,
90 };
91 #endif
92
93 #if defined(CONFIG_SND_BLACKFIN_AD1836) || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
94 static struct bfin5xx_spi_chip ad1836_spi_chip_info = {
95         .enable_dma = 0,
96         .bits_per_word = 16,
97 };
98 #endif
99
100 #if defined(CONFIG_AD9960) || defined(CONFIG_AD9960_MODULE)
101 static struct bfin5xx_spi_chip ad9960_spi_chip_info = {
102         .enable_dma = 0,
103         .bits_per_word = 16,
104 };
105 #endif
106
107 #if defined(CONFIG_SPI_MMC) || defined(CONFIG_SPI_MMC_MODULE)
108 static struct bfin5xx_spi_chip spi_mmc_chip_info = {
109         .enable_dma = 1,
110         .bits_per_word = 8,
111 };
112 #endif
113
114 static struct spi_board_info bfin_spi_board_info[] __initdata = {
115 #if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE)
116         {
117                 /* the modalias must be the same as spi device driver name */
118                 .modalias = "m25p80", /* Name of spi_driver for this device */
119                 .max_speed_hz = 25000000,     /* max spi clock (SCK) speed in HZ */
120                 .bus_num = 0, /* Framework bus number */
121                 .chip_select = 1, /* Framework chip select. On STAMP537 it is SPISSEL1*/
122                 .platform_data = &bfin_spi_flash_data,
123                 .controller_data = &spi_flash_chip_info,
124                 .mode = SPI_MODE_3,
125         },
126 #endif
127
128 #if defined(CONFIG_SPI_ADC_BF533) || defined(CONFIG_SPI_ADC_BF533_MODULE)
129         {
130                 .modalias = "bfin_spi_adc", /* Name of spi_driver for this device */
131                 .max_speed_hz = 6250000,     /* max spi clock (SCK) speed in HZ */
132                 .bus_num = 0, /* Framework bus number */
133                 .chip_select = 1, /* Framework chip select. */
134                 .platform_data = NULL, /* No spi_driver specific config */
135                 .controller_data = &spi_adc_chip_info,
136         },
137 #endif
138
139 #if defined(CONFIG_SND_BLACKFIN_AD1836) || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
140         {
141                 .modalias = "ad1836-spi",
142                 .max_speed_hz = 3125000,     /* max spi clock (SCK) speed in HZ */
143                 .bus_num = 0,
144                 .chip_select = CONFIG_SND_BLACKFIN_SPI_PFBIT,
145                 .controller_data = &ad1836_spi_chip_info,
146         },
147 #endif
148
149 #if defined(CONFIG_AD9960) || defined(CONFIG_AD9960_MODULE)
150         {
151                 .modalias = "ad9960-spi",
152                 .max_speed_hz = 10000000,     /* max spi clock (SCK) speed in HZ */
153                 .bus_num = 0,
154                 .chip_select = 1,
155                 .controller_data = &ad9960_spi_chip_info,
156         },
157 #endif
158
159 #if defined(CONFIG_SPI_MMC) || defined(CONFIG_SPI_MMC_MODULE)
160         {
161                 .modalias = "spi_mmc_dummy",
162                 .max_speed_hz = 25000000,     /* max spi clock (SCK) speed in HZ */
163                 .bus_num = 0,
164                 .chip_select = 7,
165                 .platform_data = NULL,
166                 .controller_data = &spi_mmc_chip_info,
167                 .mode = SPI_MODE_3,
168         },
169         {
170                 .modalias = "spi_mmc",
171                 .max_speed_hz = 25000000,     /* max spi clock (SCK) speed in HZ */
172                 .bus_num = 0,
173                 .chip_select = CONFIG_SPI_MMC_CS_CHAN,
174                 .platform_data = NULL,
175                 .controller_data = &spi_mmc_chip_info,
176                 .mode = SPI_MODE_3,
177         },
178 #endif
179 };
180
181 /* SPI (0) */
182 static struct resource bfin_spi0_resource[] = {
183         [0] = {
184                 .start = SPI0_REGBASE,
185                 .end   = SPI0_REGBASE + 0xFF,
186                 .flags = IORESOURCE_MEM,
187                 },
188         [1] = {
189                 .start = CH_SPI,
190                 .end   = CH_SPI,
191                 .flags = IORESOURCE_IRQ,
192         }
193 };
194
195 /* SPI controller data */
196 static struct bfin5xx_spi_master bfin_spi0_info = {
197         .num_chipselect = 8,
198         .enable_dma = 1,  /* master has the ability to do dma transfer */
199         .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
200 };
201
202 static struct platform_device bfin_spi0_device = {
203         .name = "bfin-spi",
204         .id = 0, /* Bus number */
205         .num_resources = ARRAY_SIZE(bfin_spi0_resource),
206         .resource = bfin_spi0_resource,
207         .dev = {
208                 .platform_data = &bfin_spi0_info, /* Passed to driver */
209         },
210 };
211 #endif  /* spi master and devices */
212
213 #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
214 static struct platform_device rtc_device = {
215         .name = "rtc-bfin",
216         .id   = -1,
217 };
218 #endif
219
220 #if defined(CONFIG_FB_HITACHI_TX09) || defined(CONFIG_FB_HITACHI_TX09_MODULE)
221 static struct platform_device hitachi_fb_device = {
222         .name = "hitachi-tx09",
223 };
224 #endif
225
226 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
227 static struct resource smc91x_resources[] = {
228         {
229                 .start = 0x20200300,
230                 .end = 0x20200300 + 16,
231                 .flags = IORESOURCE_MEM,
232         }, {
233                 .start = IRQ_PF14,
234                 .end = IRQ_PF14,
235                 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
236                 },
237 };
238
239 static struct platform_device smc91x_device = {
240         .name = "smc91x",
241         .id = 0,
242         .num_resources = ARRAY_SIZE(smc91x_resources),
243         .resource = smc91x_resources,
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_PG15,
259                 .end = IRQ_PG15,
260                 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
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_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
287 static struct resource net2272_bfin_resources[] = {
288         {
289                 .start = 0x20200000,
290                 .end = 0x20200000 + 0x100,
291                 .flags = IORESOURCE_MEM,
292         }, {
293                 .start = IRQ_PH14,
294                 .end = IRQ_PH14,
295                 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
296         },
297 };
298
299 static struct platform_device net2272_bfin_device = {
300         .name = "net2272",
301         .id = -1,
302         .num_resources = ARRAY_SIZE(net2272_bfin_resources),
303         .resource = net2272_bfin_resources,
304 };
305 #endif
306
307 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
308 static struct resource bfin_uart_resources[] = {
309         {
310                 .start = 0xFFC00400,
311                 .end = 0xFFC004FF,
312                 .flags = IORESOURCE_MEM,
313         }, {
314                 .start = 0xFFC02000,
315                 .end = 0xFFC020FF,
316                 .flags = IORESOURCE_MEM,
317         },
318 };
319
320 static struct platform_device bfin_uart_device = {
321         .name = "bfin-uart",
322         .id = 1,
323         .num_resources = ARRAY_SIZE(bfin_uart_resources),
324         .resource = bfin_uart_resources,
325 };
326 #endif
327
328 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
329 static struct resource bfin_sir_resources[] = {
330 #ifdef CONFIG_BFIN_SIR0
331         {
332                 .start = 0xFFC00400,
333                 .end = 0xFFC004FF,
334                 .flags = IORESOURCE_MEM,
335         },
336 #endif
337 #ifdef CONFIG_BFIN_SIR1
338         {
339                 .start = 0xFFC02000,
340                 .end = 0xFFC020FF,
341                 .flags = IORESOURCE_MEM,
342         },
343 #endif
344 };
345
346 static struct platform_device bfin_sir_device = {
347         .name = "bfin_sir",
348         .id = 0,
349         .num_resources = ARRAY_SIZE(bfin_sir_resources),
350         .resource = bfin_sir_resources,
351 };
352 #endif
353
354 #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
355 static struct resource bfin_twi0_resource[] = {
356         [0] = {
357                 .start = TWI0_REGBASE,
358                 .end   = TWI0_REGBASE,
359                 .flags = IORESOURCE_MEM,
360         },
361         [1] = {
362                 .start = IRQ_TWI,
363                 .end   = IRQ_TWI,
364                 .flags = IORESOURCE_IRQ,
365         },
366 };
367
368 static struct platform_device i2c_bfin_twi_device = {
369         .name = "i2c-bfin-twi",
370         .id = 0,
371         .num_resources = ARRAY_SIZE(bfin_twi0_resource),
372         .resource = bfin_twi0_resource,
373 };
374 #endif
375
376 #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
377 static struct platform_device bfin_sport0_uart_device = {
378         .name = "bfin-sport-uart",
379         .id = 0,
380 };
381
382 static struct platform_device bfin_sport1_uart_device = {
383         .name = "bfin-sport-uart",
384         .id = 1,
385 };
386 #endif
387
388 #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
389 static struct platform_device bfin_mac_device = {
390         .name = "bfin_mac",
391 };
392 #endif
393
394 #if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
395 #define PATA_INT        64
396
397 static struct pata_platform_info bfin_pata_platform_data = {
398         .ioport_shift = 2,
399         .irq_type = IRQF_TRIGGER_HIGH | IRQF_DISABLED,
400 };
401
402 static struct resource bfin_pata_resources[] = {
403         {
404                 .start = 0x2030C000,
405                 .end = 0x2030C01F,
406                 .flags = IORESOURCE_MEM,
407         },
408         {
409                 .start = 0x2030D018,
410                 .end = 0x2030D01B,
411                 .flags = IORESOURCE_MEM,
412         },
413         {
414                 .start = PATA_INT,
415                 .end = PATA_INT,
416                 .flags = IORESOURCE_IRQ,
417         },
418 };
419
420 static struct platform_device bfin_pata_device = {
421         .name = "pata_platform",
422         .id = -1,
423         .num_resources = ARRAY_SIZE(bfin_pata_resources),
424         .resource = bfin_pata_resources,
425         .dev = {
426                 .platform_data = &bfin_pata_platform_data,
427         }
428 };
429 #endif
430
431 static struct platform_device *cm_bf537_devices[] __initdata = {
432 #if defined(CONFIG_FB_HITACHI_TX09) || defined(CONFIG_FB_HITACHI_TX09_MODULE)
433         &hitachi_fb_device,
434 #endif
435
436 #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
437         &rtc_device,
438 #endif
439
440 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
441         &bfin_uart_device,
442 #endif
443
444 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
445         &bfin_sir_device,
446 #endif
447
448 #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
449         &i2c_bfin_twi_device,
450 #endif
451
452 #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
453         &bfin_sport0_uart_device,
454         &bfin_sport1_uart_device,
455 #endif
456
457 #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
458         &isp1362_hcd_device,
459 #endif
460
461 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
462         &smc91x_device,
463 #endif
464
465 #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
466         &bfin_mac_device,
467 #endif
468
469 #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
470         &net2272_bfin_device,
471 #endif
472
473 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
474         &bfin_spi0_device,
475 #endif
476
477 #if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
478         &bfin_pata_device,
479 #endif
480 };
481
482 static int __init cm_bf537_init(void)
483 {
484         printk(KERN_INFO "%s(): registering device resources\n", __func__);
485         platform_add_devices(cm_bf537_devices, ARRAY_SIZE(cm_bf537_devices));
486 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
487         spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
488 #endif
489
490 #if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
491         irq_desc[PATA_INT].status |= IRQ_NOAUTOEN;
492 #endif
493         return 0;
494 }
495
496 arch_initcall(cm_bf537_init);
497
498 void bfin_get_ether_addr(char *addr)
499 {
500         random_ether_addr(addr);
501         printk(KERN_WARNING "%s:%s: Setting Ethernet MAC to a random one\n", __FILE__, __func__);
502 }
503 EXPORT_SYMBOL(bfin_get_ether_addr);