Blackfin: convert boards to use platform data with smc91x
[linux-2.6/linux-2.6-openrd.git] / arch / blackfin / mach-bf537 / boards / tcm_bf537.c
blob97a86b4ce96d991a60953be9d735cff12bac6c07
1 /*
2 * File: arch/blackfin/mach-bf537/boards/tcm_bf537.c
3 * Based on: arch/blackfin/mach-bf533/boards/cm_bf537.c
4 * Author: Aidan Williams <aidan@nicta.com.au>
6 * Created: 2005
7 * Description: Board description file
9 * Modified:
10 * Copyright 2005 National ICT Australia (NICTA)
11 * Copyright 2004-2006 Analog Devices Inc.
13 * Bugs: Enter bugs at http://blackfin.uclinux.org/
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.
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.
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
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/mtd/physmap.h>
37 #include <linux/spi/spi.h>
38 #include <linux/spi/flash.h>
39 #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
40 #include <linux/usb/isp1362.h>
41 #endif
42 #include <linux/ata_platform.h>
43 #include <linux/irq.h>
44 #include <asm/dma.h>
45 #include <asm/bfin5xx_spi.h>
46 #include <asm/portmux.h>
47 #include <asm/dpmc.h>
50 * Name the Board for the /proc/cpuinfo
52 const char bfin_board_name[] = "Bluetechnix TCM BF537";
54 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
55 /* all SPI peripherals info goes here */
57 #if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE)
58 static struct mtd_partition bfin_spi_flash_partitions[] = {
60 .name = "bootloader(spi)",
61 .size = 0x00020000,
62 .offset = 0,
63 .mask_flags = MTD_CAP_ROM
64 }, {
65 .name = "linux kernel(spi)",
66 .size = 0xe0000,
67 .offset = 0x20000
68 }, {
69 .name = "file system(spi)",
70 .size = 0x700000,
71 .offset = 0x00100000,
75 static struct flash_platform_data bfin_spi_flash_data = {
76 .name = "m25p80",
77 .parts = bfin_spi_flash_partitions,
78 .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
79 .type = "m25p64",
82 /* SPI flash chip (m25p64) */
83 static struct bfin5xx_spi_chip spi_flash_chip_info = {
84 .enable_dma = 0, /* use dma transfer with this chip*/
85 .bits_per_word = 8,
87 #endif
89 #if defined(CONFIG_BFIN_SPI_ADC) || defined(CONFIG_BFIN_SPI_ADC_MODULE)
90 /* SPI ADC chip */
91 static struct bfin5xx_spi_chip spi_adc_chip_info = {
92 .enable_dma = 1, /* use dma transfer with this chip*/
93 .bits_per_word = 16,
95 #endif
97 #if defined(CONFIG_SND_BLACKFIN_AD1836) || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
98 static struct bfin5xx_spi_chip ad1836_spi_chip_info = {
99 .enable_dma = 0,
100 .bits_per_word = 16,
102 #endif
104 #if defined(CONFIG_AD9960) || defined(CONFIG_AD9960_MODULE)
105 static struct bfin5xx_spi_chip ad9960_spi_chip_info = {
106 .enable_dma = 0,
107 .bits_per_word = 16,
109 #endif
111 #if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
112 static struct bfin5xx_spi_chip mmc_spi_chip_info = {
113 .enable_dma = 0,
114 .bits_per_word = 8,
116 #endif
118 static struct spi_board_info bfin_spi_board_info[] __initdata = {
119 #if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE)
121 /* the modalias must be the same as spi device driver name */
122 .modalias = "m25p80", /* Name of spi_driver for this device */
123 .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
124 .bus_num = 0, /* Framework bus number */
125 .chip_select = 1, /* Framework chip select. On STAMP537 it is SPISSEL1*/
126 .platform_data = &bfin_spi_flash_data,
127 .controller_data = &spi_flash_chip_info,
128 .mode = SPI_MODE_3,
130 #endif
132 #if defined(CONFIG_BFIN_SPI_ADC) || defined(CONFIG_BFIN_SPI_ADC_MODULE)
134 .modalias = "bfin_spi_adc", /* Name of spi_driver for this device */
135 .max_speed_hz = 6250000, /* max spi clock (SCK) speed in HZ */
136 .bus_num = 0, /* Framework bus number */
137 .chip_select = 1, /* Framework chip select. */
138 .platform_data = NULL, /* No spi_driver specific config */
139 .controller_data = &spi_adc_chip_info,
141 #endif
143 #if defined(CONFIG_SND_BLACKFIN_AD1836) || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
145 .modalias = "ad1836-spi",
146 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
147 .bus_num = 0,
148 .chip_select = CONFIG_SND_BLACKFIN_SPI_PFBIT,
149 .controller_data = &ad1836_spi_chip_info,
151 #endif
153 #if defined(CONFIG_AD9960) || defined(CONFIG_AD9960_MODULE)
155 .modalias = "ad9960-spi",
156 .max_speed_hz = 10000000, /* max spi clock (SCK) speed in HZ */
157 .bus_num = 0,
158 .chip_select = 1,
159 .controller_data = &ad9960_spi_chip_info,
161 #endif
163 #if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
165 .modalias = "mmc_spi",
166 .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
167 .bus_num = 0,
168 .chip_select = 5,
169 .controller_data = &mmc_spi_chip_info,
170 .mode = SPI_MODE_3,
172 #endif
175 /* SPI (0) */
176 static struct resource bfin_spi0_resource[] = {
177 [0] = {
178 .start = SPI0_REGBASE,
179 .end = SPI0_REGBASE + 0xFF,
180 .flags = IORESOURCE_MEM,
182 [1] = {
183 .start = CH_SPI,
184 .end = CH_SPI,
185 .flags = IORESOURCE_DMA,
187 [2] = {
188 .start = IRQ_SPI,
189 .end = IRQ_SPI,
190 .flags = IORESOURCE_IRQ,
194 /* SPI controller data */
195 static struct bfin5xx_spi_master bfin_spi0_info = {
196 .num_chipselect = 8,
197 .enable_dma = 1, /* master has the ability to do dma transfer */
198 .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
201 static struct platform_device bfin_spi0_device = {
202 .name = "bfin-spi",
203 .id = 0, /* Bus number */
204 .num_resources = ARRAY_SIZE(bfin_spi0_resource),
205 .resource = bfin_spi0_resource,
206 .dev = {
207 .platform_data = &bfin_spi0_info, /* Passed to driver */
210 #endif /* spi master and devices */
212 #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
213 static struct platform_device rtc_device = {
214 .name = "rtc-bfin",
215 .id = -1,
217 #endif
219 #if defined(CONFIG_FB_HITACHI_TX09) || defined(CONFIG_FB_HITACHI_TX09_MODULE)
220 static struct platform_device hitachi_fb_device = {
221 .name = "hitachi-tx09",
223 #endif
225 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
226 #include <linux/smc91x.h>
228 static struct smc91x_platdata smc91x_info = {
229 .flags = SMC91X_USE_16BIT | SMC91X_NOWAIT,
230 .leda = RPC_LED_100_10,
231 .ledb = RPC_LED_TX_RX,
234 static struct resource smc91x_resources[] = {
236 .start = 0x20200300,
237 .end = 0x20200300 + 16,
238 .flags = IORESOURCE_MEM,
239 }, {
240 .start = IRQ_PF14,
241 .end = IRQ_PF14,
242 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
246 static struct platform_device smc91x_device = {
247 .name = "smc91x",
248 .id = 0,
249 .num_resources = ARRAY_SIZE(smc91x_resources),
250 .resource = smc91x_resources,
251 .dev = {
252 .platform_data = &smc91x_info,
255 #endif
257 #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
258 static struct resource isp1362_hcd_resources[] = {
260 .start = 0x20308000,
261 .end = 0x20308000,
262 .flags = IORESOURCE_MEM,
263 }, {
264 .start = 0x20308004,
265 .end = 0x20308004,
266 .flags = IORESOURCE_MEM,
267 }, {
268 .start = IRQ_PG15,
269 .end = IRQ_PG15,
270 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
274 static struct isp1362_platform_data isp1362_priv = {
275 .sel15Kres = 1,
276 .clknotstop = 0,
277 .oc_enable = 0,
278 .int_act_high = 0,
279 .int_edge_triggered = 0,
280 .remote_wakeup_connected = 0,
281 .no_power_switching = 1,
282 .power_switching_mode = 0,
285 static struct platform_device isp1362_hcd_device = {
286 .name = "isp1362-hcd",
287 .id = 0,
288 .dev = {
289 .platform_data = &isp1362_priv,
291 .num_resources = ARRAY_SIZE(isp1362_hcd_resources),
292 .resource = isp1362_hcd_resources,
294 #endif
296 #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
297 static struct resource net2272_bfin_resources[] = {
299 .start = 0x20200000,
300 .end = 0x20200000 + 0x100,
301 .flags = IORESOURCE_MEM,
302 }, {
303 .start = IRQ_PH14,
304 .end = IRQ_PH14,
305 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
309 static struct platform_device net2272_bfin_device = {
310 .name = "net2272",
311 .id = -1,
312 .num_resources = ARRAY_SIZE(net2272_bfin_resources),
313 .resource = net2272_bfin_resources,
315 #endif
317 static struct resource bfin_gpios_resources = {
318 .start = 0,
319 .end = MAX_BLACKFIN_GPIOS - 1,
320 .flags = IORESOURCE_IRQ,
323 static struct platform_device bfin_gpios_device = {
324 .name = "simple-gpio",
325 .id = -1,
326 .num_resources = 1,
327 .resource = &bfin_gpios_resources,
330 #if defined(CONFIG_MTD_GPIO_ADDR) || defined(CONFIG_MTD_GPIO_ADDR_MODULE)
331 static struct mtd_partition cm_partitions[] = {
333 .name = "bootloader(nor)",
334 .size = 0x40000,
335 .offset = 0,
336 }, {
337 .name = "linux kernel(nor)",
338 .size = 0xE0000,
339 .offset = MTDPART_OFS_APPEND,
340 }, {
341 .name = "file system(nor)",
342 .size = MTDPART_SIZ_FULL,
343 .offset = MTDPART_OFS_APPEND,
347 static struct physmap_flash_data cm_flash_data = {
348 .width = 2,
349 .parts = cm_partitions,
350 .nr_parts = ARRAY_SIZE(cm_partitions),
353 static unsigned cm_flash_gpios[] = { GPIO_PF4, GPIO_PF5 };
355 static struct resource cm_flash_resource[] = {
357 .name = "cfi_probe",
358 .start = 0x20000000,
359 .end = 0x201fffff,
360 .flags = IORESOURCE_MEM,
361 }, {
362 .start = (unsigned long)cm_flash_gpios,
363 .end = ARRAY_SIZE(cm_flash_gpios),
364 .flags = IORESOURCE_IRQ,
368 static struct platform_device cm_flash_device = {
369 .name = "gpio-addr-flash",
370 .id = 0,
371 .dev = {
372 .platform_data = &cm_flash_data,
374 .num_resources = ARRAY_SIZE(cm_flash_resource),
375 .resource = cm_flash_resource,
377 #endif
379 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
380 static struct resource bfin_uart_resources[] = {
382 .start = 0xFFC00400,
383 .end = 0xFFC004FF,
384 .flags = IORESOURCE_MEM,
385 }, {
386 .start = 0xFFC02000,
387 .end = 0xFFC020FF,
388 .flags = IORESOURCE_MEM,
392 static struct platform_device bfin_uart_device = {
393 .name = "bfin-uart",
394 .id = 1,
395 .num_resources = ARRAY_SIZE(bfin_uart_resources),
396 .resource = bfin_uart_resources,
398 #endif
400 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
401 #ifdef CONFIG_BFIN_SIR0
402 static struct resource bfin_sir0_resources[] = {
404 .start = 0xFFC00400,
405 .end = 0xFFC004FF,
406 .flags = IORESOURCE_MEM,
409 .start = IRQ_UART0_RX,
410 .end = IRQ_UART0_RX+1,
411 .flags = IORESOURCE_IRQ,
414 .start = CH_UART0_RX,
415 .end = CH_UART0_RX+1,
416 .flags = IORESOURCE_DMA,
420 static struct platform_device bfin_sir0_device = {
421 .name = "bfin_sir",
422 .id = 0,
423 .num_resources = ARRAY_SIZE(bfin_sir0_resources),
424 .resource = bfin_sir0_resources,
426 #endif
427 #ifdef CONFIG_BFIN_SIR1
428 static struct resource bfin_sir1_resources[] = {
430 .start = 0xFFC02000,
431 .end = 0xFFC020FF,
432 .flags = IORESOURCE_MEM,
435 .start = IRQ_UART1_RX,
436 .end = IRQ_UART1_RX+1,
437 .flags = IORESOURCE_IRQ,
440 .start = CH_UART1_RX,
441 .end = CH_UART1_RX+1,
442 .flags = IORESOURCE_DMA,
446 static struct platform_device bfin_sir1_device = {
447 .name = "bfin_sir",
448 .id = 1,
449 .num_resources = ARRAY_SIZE(bfin_sir1_resources),
450 .resource = bfin_sir1_resources,
452 #endif
453 #endif
455 #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
456 static struct resource bfin_twi0_resource[] = {
457 [0] = {
458 .start = TWI0_REGBASE,
459 .end = TWI0_REGBASE,
460 .flags = IORESOURCE_MEM,
462 [1] = {
463 .start = IRQ_TWI,
464 .end = IRQ_TWI,
465 .flags = IORESOURCE_IRQ,
469 static struct platform_device i2c_bfin_twi_device = {
470 .name = "i2c-bfin-twi",
471 .id = 0,
472 .num_resources = ARRAY_SIZE(bfin_twi0_resource),
473 .resource = bfin_twi0_resource,
475 #endif
477 #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
478 static struct platform_device bfin_sport0_uart_device = {
479 .name = "bfin-sport-uart",
480 .id = 0,
483 static struct platform_device bfin_sport1_uart_device = {
484 .name = "bfin-sport-uart",
485 .id = 1,
487 #endif
489 #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
490 static struct platform_device bfin_mii_bus = {
491 .name = "bfin_mii_bus",
494 static struct platform_device bfin_mac_device = {
495 .name = "bfin_mac",
496 .dev.platform_data = &bfin_mii_bus,
498 #endif
500 #if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
501 #define PATA_INT IRQ_PF14
503 static struct pata_platform_info bfin_pata_platform_data = {
504 .ioport_shift = 2,
505 .irq_type = IRQF_TRIGGER_HIGH | IRQF_DISABLED,
508 static struct resource bfin_pata_resources[] = {
510 .start = 0x2030C000,
511 .end = 0x2030C01F,
512 .flags = IORESOURCE_MEM,
515 .start = 0x2030D018,
516 .end = 0x2030D01B,
517 .flags = IORESOURCE_MEM,
520 .start = PATA_INT,
521 .end = PATA_INT,
522 .flags = IORESOURCE_IRQ,
526 static struct platform_device bfin_pata_device = {
527 .name = "pata_platform",
528 .id = -1,
529 .num_resources = ARRAY_SIZE(bfin_pata_resources),
530 .resource = bfin_pata_resources,
531 .dev = {
532 .platform_data = &bfin_pata_platform_data,
535 #endif
537 static const unsigned int cclk_vlev_datasheet[] =
539 VRPAIR(VLEV_085, 250000000),
540 VRPAIR(VLEV_090, 376000000),
541 VRPAIR(VLEV_095, 426000000),
542 VRPAIR(VLEV_100, 426000000),
543 VRPAIR(VLEV_105, 476000000),
544 VRPAIR(VLEV_110, 476000000),
545 VRPAIR(VLEV_115, 476000000),
546 VRPAIR(VLEV_120, 500000000),
547 VRPAIR(VLEV_125, 533000000),
548 VRPAIR(VLEV_130, 600000000),
551 static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
552 .tuple_tab = cclk_vlev_datasheet,
553 .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
554 .vr_settling_time = 25 /* us */,
557 static struct platform_device bfin_dpmc = {
558 .name = "bfin dpmc",
559 .dev = {
560 .platform_data = &bfin_dmpc_vreg_data,
564 static struct platform_device *cm_bf537_devices[] __initdata = {
566 &bfin_dpmc,
568 #if defined(CONFIG_FB_HITACHI_TX09) || defined(CONFIG_FB_HITACHI_TX09_MODULE)
569 &hitachi_fb_device,
570 #endif
572 #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
573 &rtc_device,
574 #endif
576 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
577 &bfin_uart_device,
578 #endif
580 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
581 #ifdef CONFIG_BFIN_SIR0
582 &bfin_sir0_device,
583 #endif
584 #ifdef CONFIG_BFIN_SIR1
585 &bfin_sir1_device,
586 #endif
587 #endif
589 #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
590 &i2c_bfin_twi_device,
591 #endif
593 #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
594 &bfin_sport0_uart_device,
595 &bfin_sport1_uart_device,
596 #endif
598 #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
599 &isp1362_hcd_device,
600 #endif
602 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
603 &smc91x_device,
604 #endif
606 #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
607 &bfin_mii_bus,
608 &bfin_mac_device,
609 #endif
611 #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
612 &net2272_bfin_device,
613 #endif
615 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
616 &bfin_spi0_device,
617 #endif
619 #if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
620 &bfin_pata_device,
621 #endif
623 #if defined(CONFIG_MTD_GPIO_ADDR) || defined(CONFIG_MTD_GPIO_ADDR_MODULE)
624 &cm_flash_device,
625 #endif
627 &bfin_gpios_device,
630 static int __init tcm_bf537_init(void)
632 printk(KERN_INFO "%s(): registering device resources\n", __func__);
633 platform_add_devices(cm_bf537_devices, ARRAY_SIZE(cm_bf537_devices));
634 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
635 spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
636 #endif
638 #if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
639 irq_desc[PATA_INT].status |= IRQ_NOAUTOEN;
640 #endif
641 return 0;
644 arch_initcall(tcm_bf537_init);
646 void bfin_get_ether_addr(char *addr)
648 random_ether_addr(addr);
649 printk(KERN_WARNING "%s:%s: Setting Ethernet MAC to a random one\n", __FILE__, __func__);
651 EXPORT_SYMBOL(bfin_get_ether_addr);