2 * File: arch/blackfin/mach-bf537/boards/generic_board.c
3 * Based on: arch/blackfin/mach-bf533/boards/ezkit.c
4 * Author: Aidan Williams <aidan@nicta.com.au>
10 * Copyright 2005 National ICT Australia (NICTA)
11 * Copyright 2004-2008 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/spi/spi.h>
37 #include <linux/spi/flash.h>
38 #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
39 #include <linux/usb/isp1362.h>
41 #include <linux/ata_platform.h>
42 #include <linux/irq.h>
43 #include <linux/interrupt.h>
44 #include <linux/usb/sl811.h>
46 #include <asm/bfin5xx_spi.h>
47 #include <asm/reboot.h>
48 #include <asm/portmux.h>
49 #include <linux/spi/ad7877.h>
52 * Name the Board for the /proc/cpuinfo
54 const char bfin_board_name[] = "GENERIC Board";
57 * Driver needs to know address, irq and flag pin.
60 #define ISP1761_BASE 0x203C0000
61 #define ISP1761_IRQ IRQ_PF7
63 #if defined(CONFIG_USB_ISP1760_HCD) || defined(CONFIG_USB_ISP1760_HCD_MODULE)
64 static struct resource bfin_isp1761_resources[] = {
66 .name = "isp1761-regs",
67 .start = ISP1761_BASE + 0x00000000,
68 .end = ISP1761_BASE + 0x000fffff,
69 .flags = IORESOURCE_MEM,
74 .flags = IORESOURCE_IRQ,
78 static struct platform_device bfin_isp1761_device = {
81 .num_resources = ARRAY_SIZE(bfin_isp1761_resources),
82 .resource = bfin_isp1761_resources,
85 static struct platform_device *bfin_isp1761_devices[] = {
89 int __init bfin_isp1761_init(void)
91 unsigned int num_devices = ARRAY_SIZE(bfin_isp1761_devices);
93 printk(KERN_INFO "%s(): registering device resources\n", __FUNCTION__);
94 set_irq_type(ISP1761_IRQ, IRQF_TRIGGER_FALLING);
96 return platform_add_devices(bfin_isp1761_devices, num_devices);
99 void __exit bfin_isp1761_exit(void)
101 platform_device_unregister(&bfin_isp1761_device);
104 arch_initcall(bfin_isp1761_init);
107 #if defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE)
108 static struct resource bfin_pcmcia_cf_resources[] = {
110 .start = 0x20310000, /* IO PORT */
112 .flags = IORESOURCE_MEM,
114 .start = 0x20311000, /* Attribute Memory */
116 .flags = IORESOURCE_MEM,
120 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
122 .start = 6, /* Card Detect PF6 */
124 .flags = IORESOURCE_IRQ,
128 static struct platform_device bfin_pcmcia_cf_device = {
129 .name = "bfin_cf_pcmcia",
131 .num_resources = ARRAY_SIZE(bfin_pcmcia_cf_resources),
132 .resource = bfin_pcmcia_cf_resources,
136 #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
137 static struct platform_device rtc_device = {
143 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
144 static struct resource smc91x_resources[] = {
146 .name = "smc91x-regs",
148 .end = 0x20300300 + 16,
149 .flags = IORESOURCE_MEM,
154 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
157 static struct platform_device smc91x_device = {
160 .num_resources = ARRAY_SIZE(smc91x_resources),
161 .resource = smc91x_resources,
165 #if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
166 static struct resource dm9000_resources[] = {
169 .end = 0x203FB800 + 8,
170 .flags = IORESOURCE_MEM,
175 .flags = (IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE),
179 static struct platform_device dm9000_device = {
182 .num_resources = ARRAY_SIZE(dm9000_resources),
183 .resource = dm9000_resources,
187 #if defined(CONFIG_USB_SL811_HCD) || defined(CONFIG_USB_SL811_HCD_MODULE)
188 static struct resource sl811_hcd_resources[] = {
192 .flags = IORESOURCE_MEM,
196 .flags = IORESOURCE_MEM,
198 .start = CONFIG_USB_SL811_BFIN_IRQ,
199 .end = CONFIG_USB_SL811_BFIN_IRQ,
200 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
204 #if defined(CONFIG_USB_SL811_BFIN_USE_VBUS)
205 void sl811_port_power(struct device *dev, int is_on)
207 gpio_request(CONFIG_USB_SL811_BFIN_GPIO_VBUS, "usb:SL811_VBUS");
208 gpio_direction_output(CONFIG_USB_SL811_BFIN_GPIO_VBUS, is_on);
213 static struct sl811_platform_data sl811_priv = {
215 .power = 250, /* == 500mA */
216 #if defined(CONFIG_USB_SL811_BFIN_USE_VBUS)
217 .port_power = &sl811_port_power,
221 static struct platform_device sl811_hcd_device = {
225 .platform_data = &sl811_priv,
227 .num_resources = ARRAY_SIZE(sl811_hcd_resources),
228 .resource = sl811_hcd_resources,
232 #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
233 static struct resource isp1362_hcd_resources[] = {
237 .flags = IORESOURCE_MEM,
241 .flags = IORESOURCE_MEM,
243 .start = CONFIG_USB_ISP1362_BFIN_GPIO_IRQ,
244 .end = CONFIG_USB_ISP1362_BFIN_GPIO_IRQ,
245 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
249 static struct isp1362_platform_data isp1362_priv = {
254 .int_edge_triggered = 0,
255 .remote_wakeup_connected = 0,
256 .no_power_switching = 1,
257 .power_switching_mode = 0,
260 static struct platform_device isp1362_hcd_device = {
261 .name = "isp1362-hcd",
264 .platform_data = &isp1362_priv,
266 .num_resources = ARRAY_SIZE(isp1362_hcd_resources),
267 .resource = isp1362_hcd_resources,
271 #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
272 static struct platform_device bfin_mac_device = {
277 #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
278 static struct resource net2272_bfin_resources[] = {
281 .end = 0x20300000 + 0x100,
282 .flags = IORESOURCE_MEM,
286 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
290 static struct platform_device net2272_bfin_device = {
293 .num_resources = ARRAY_SIZE(net2272_bfin_resources),
294 .resource = net2272_bfin_resources,
298 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
299 /* all SPI peripherals info goes here */
301 #if defined(CONFIG_MTD_M25P80) \
302 || defined(CONFIG_MTD_M25P80_MODULE)
303 static struct mtd_partition bfin_spi_flash_partitions[] = {
305 .name = "bootloader",
308 .mask_flags = MTD_CAP_ROM
314 .name = "file system",
316 .offset = 0x00100000,
320 static struct flash_platform_data bfin_spi_flash_data = {
322 .parts = bfin_spi_flash_partitions,
323 .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
327 /* SPI flash chip (m25p64) */
328 static struct bfin5xx_spi_chip spi_flash_chip_info = {
329 .enable_dma = 0, /* use dma transfer with this chip*/
334 #if defined(CONFIG_SPI_ADC_BF533) \
335 || defined(CONFIG_SPI_ADC_BF533_MODULE)
337 static struct bfin5xx_spi_chip spi_adc_chip_info = {
338 .enable_dma = 1, /* use dma transfer with this chip*/
343 #if defined(CONFIG_SND_BLACKFIN_AD1836) \
344 || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
345 static struct bfin5xx_spi_chip ad1836_spi_chip_info = {
351 #if defined(CONFIG_AD9960) || defined(CONFIG_AD9960_MODULE)
352 static struct bfin5xx_spi_chip ad9960_spi_chip_info = {
358 #if defined(CONFIG_SPI_MMC) || defined(CONFIG_SPI_MMC_MODULE)
359 static struct bfin5xx_spi_chip spi_mmc_chip_info = {
365 #if defined(CONFIG_PBX)
366 static struct bfin5xx_spi_chip spi_si3xxx_chip_info = {
367 .ctl_reg = 0x4, /* send zero */
370 .cs_change_per_word = 1,
374 #if defined(CONFIG_AD5304) || defined(CONFIG_AD5304_MODULE)
375 static struct bfin5xx_spi_chip ad5304_chip_info = {
381 #if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
382 static struct bfin5xx_spi_chip spi_ad7877_chip_info = {
387 static const struct ad7877_platform_data bfin_ad7877_ts_info = {
389 .vref_delay_usecs = 50, /* internal, no capacitor */
392 .pressure_max = 1000,
394 .stopacq_polarity = 1,
395 .first_conversion_delay = 3,
396 .acquisition_time = 1,
398 .pen_down_acc_interval = 1,
402 static struct spi_board_info bfin_spi_board_info[] __initdata = {
403 #if defined(CONFIG_MTD_M25P80) \
404 || defined(CONFIG_MTD_M25P80_MODULE)
406 /* the modalias must be the same as spi device driver name */
407 .modalias = "m25p80", /* Name of spi_driver for this device */
408 .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
409 .bus_num = 0, /* Framework bus number */
410 .chip_select = 1, /* Framework chip select. On STAMP537 it is SPISSEL1*/
411 .platform_data = &bfin_spi_flash_data,
412 .controller_data = &spi_flash_chip_info,
417 #if defined(CONFIG_SPI_ADC_BF533) \
418 || defined(CONFIG_SPI_ADC_BF533_MODULE)
420 .modalias = "bfin_spi_adc", /* Name of spi_driver for this device */
421 .max_speed_hz = 6250000, /* max spi clock (SCK) speed in HZ */
422 .bus_num = 0, /* Framework bus number */
423 .chip_select = 1, /* Framework chip select. */
424 .platform_data = NULL, /* No spi_driver specific config */
425 .controller_data = &spi_adc_chip_info,
429 #if defined(CONFIG_SND_BLACKFIN_AD1836) \
430 || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
432 .modalias = "ad1836-spi",
433 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
435 .chip_select = CONFIG_SND_BLACKFIN_SPI_PFBIT,
436 .controller_data = &ad1836_spi_chip_info,
439 #if defined(CONFIG_AD9960) || defined(CONFIG_AD9960_MODULE)
441 .modalias = "ad9960-spi",
442 .max_speed_hz = 10000000, /* max spi clock (SCK) speed in HZ */
445 .controller_data = &ad9960_spi_chip_info,
448 #if defined(CONFIG_SPI_MMC) || defined(CONFIG_SPI_MMC_MODULE)
450 .modalias = "spi_mmc_dummy",
451 .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
454 .platform_data = NULL,
455 .controller_data = &spi_mmc_chip_info,
459 .modalias = "spi_mmc",
460 .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
462 .chip_select = CONFIG_SPI_MMC_CS_CHAN,
463 .platform_data = NULL,
464 .controller_data = &spi_mmc_chip_info,
468 #if defined(CONFIG_PBX)
470 .modalias = "fxs-spi",
471 .max_speed_hz = 12500000, /* max spi clock (SCK) speed in HZ */
473 .chip_select = 8 - CONFIG_J11_JUMPER,
474 .controller_data = &spi_si3xxx_chip_info,
478 .modalias = "fxo-spi",
479 .max_speed_hz = 12500000, /* max spi clock (SCK) speed in HZ */
481 .chip_select = 8 - CONFIG_J19_JUMPER,
482 .controller_data = &spi_si3xxx_chip_info,
486 #if defined(CONFIG_AD5304) || defined(CONFIG_AD5304_MODULE)
488 .modalias = "ad5304_spi",
489 .max_speed_hz = 1250000, /* max spi clock (SCK) speed in HZ */
492 .platform_data = NULL,
493 .controller_data = &ad5304_chip_info,
497 #if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
499 .modalias = "ad7877",
500 .platform_data = &bfin_ad7877_ts_info,
502 .max_speed_hz = 12500000, /* max spi clock (SCK) speed in HZ */
505 .controller_data = &spi_ad7877_chip_info,
510 /* SPI controller data */
511 static struct bfin5xx_spi_master bfin_spi0_info = {
513 .enable_dma = 1, /* master has the ability to do dma transfer */
514 .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
518 static struct resource bfin_spi0_resource[] = {
520 .start = SPI0_REGBASE,
521 .end = SPI0_REGBASE + 0xFF,
522 .flags = IORESOURCE_MEM,
527 .flags = IORESOURCE_IRQ,
531 static struct platform_device bfin_spi0_device = {
533 .id = 0, /* Bus number */
534 .num_resources = ARRAY_SIZE(bfin_spi0_resource),
535 .resource = bfin_spi0_resource,
537 .platform_data = &bfin_spi0_info, /* Passed to driver */
540 #endif /* spi master and devices */
542 #if defined(CONFIG_FB_BF537_LQ035) || defined(CONFIG_FB_BF537_LQ035_MODULE)
543 static struct platform_device bfin_fb_device = {
544 .name = "bf537-lq035",
548 #if defined(CONFIG_FB_BFIN_7393) || defined(CONFIG_FB_BFIN_7393_MODULE)
549 static struct platform_device bfin_fb_adv7393_device = {
550 .name = "bfin-adv7393",
554 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
555 static struct resource bfin_uart_resources[] = {
559 .flags = IORESOURCE_MEM,
563 .flags = IORESOURCE_MEM,
567 static struct platform_device bfin_uart_device = {
570 .num_resources = ARRAY_SIZE(bfin_uart_resources),
571 .resource = bfin_uart_resources,
575 #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
576 static struct resource bfin_twi0_resource[] = {
578 .start = TWI0_REGBASE,
579 .end = TWI0_REGBASE + 0xFF,
580 .flags = IORESOURCE_MEM,
585 .flags = IORESOURCE_IRQ,
589 static struct platform_device i2c_bfin_twi_device = {
590 .name = "i2c-bfin-twi",
592 .num_resources = ARRAY_SIZE(bfin_twi0_resource),
593 .resource = bfin_twi0_resource,
597 #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
598 static struct platform_device bfin_sport0_uart_device = {
599 .name = "bfin-sport-uart",
603 static struct platform_device bfin_sport1_uart_device = {
604 .name = "bfin-sport-uart",
609 #if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
612 static struct pata_platform_info bfin_pata_platform_data = {
614 .irq_type = IRQF_TRIGGER_HIGH | IRQF_DISABLED,
617 static struct resource bfin_pata_resources[] = {
621 .flags = IORESOURCE_MEM,
626 .flags = IORESOURCE_MEM,
631 .flags = IORESOURCE_IRQ,
635 static struct platform_device bfin_pata_device = {
636 .name = "pata_platform",
638 .num_resources = ARRAY_SIZE(bfin_pata_resources),
639 .resource = bfin_pata_resources,
641 .platform_data = &bfin_pata_platform_data,
646 static struct platform_device *stamp_devices[] __initdata = {
647 #if defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE)
648 &bfin_pcmcia_cf_device,
651 #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
655 #if defined(CONFIG_USB_SL811_HCD) || defined(CONFIG_USB_SL811_HCD_MODULE)
659 #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
663 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
667 #if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
671 #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
675 #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
676 &net2272_bfin_device,
679 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
683 #if defined(CONFIG_FB_BF537_LQ035) || defined(CONFIG_FB_BF537_LQ035_MODULE)
687 #if defined(CONFIG_FB_BFIN_7393) || defined(CONFIG_FB_BFIN_7393_MODULE)
688 &bfin_fb_adv7393_device,
691 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
695 #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
696 &i2c_bfin_twi_device,
699 #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
700 &bfin_sport0_uart_device,
701 &bfin_sport1_uart_device,
704 #if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
709 static int __init stamp_init(void)
711 printk(KERN_INFO "%s(): registering device resources\n", __FUNCTION__);
712 platform_add_devices(stamp_devices, ARRAY_SIZE(stamp_devices));
713 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
714 spi_register_board_info(bfin_spi_board_info,
715 ARRAY_SIZE(bfin_spi_board_info));
718 #if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
719 irq_desc[PATA_INT].status |= IRQ_NOAUTOEN;
724 arch_initcall(stamp_init);
726 void native_machine_restart(char *cmd)
728 /* workaround reboot hang when booting from SPI */
729 if ((bfin_read_SYSCR() & 0x7) == 0x3)
730 bfin_gpio_reset_spi0_ssel1();
733 #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
734 void bfin_get_ether_addr(char *addr)
736 random_ether_addr(addr);
737 printk(KERN_WARNING "%s:%s: Setting Ethernet MAC to a random one\n", __FILE__, __func__);
739 EXPORT_SYMBOL(bfin_get_ether_addr);