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/irq.h>
42 #include <linux/interrupt.h>
43 #include <linux/usb/sl811.h>
45 #include <asm/bfin5xx_spi.h>
46 #include <asm/reboot.h>
47 #include <asm/portmux.h>
48 #include <linux/spi/ad7877.h>
51 * Name the Board for the /proc/cpuinfo
53 const char bfin_board_name[] = "UNKNOWN BOARD";
56 * Driver needs to know address, irq and flag pin.
59 #if defined(CONFIG_USB_ISP1760_HCD) || defined(CONFIG_USB_ISP1760_HCD_MODULE)
60 #include <linux/usb/isp1760.h>
61 static struct resource bfin_isp1760_resources[] = {
64 .end = 0x203C0000 + 0x000fffff,
65 .flags = IORESOURCE_MEM,
70 .flags = IORESOURCE_IRQ,
74 static struct isp1760_platform_data isp1760_priv = {
80 .dack_polarity_high = 0,
81 .dreq_polarity_high = 0,
84 static struct platform_device bfin_isp1760_device = {
85 .name = "isp1760-hcd",
88 .platform_data = &isp1760_priv,
90 .num_resources = ARRAY_SIZE(bfin_isp1760_resources),
91 .resource = bfin_isp1760_resources,
95 #if defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE)
96 static struct resource bfin_pcmcia_cf_resources[] = {
98 .start = 0x20310000, /* IO PORT */
100 .flags = IORESOURCE_MEM,
102 .start = 0x20311000, /* Attribute Memory */
104 .flags = IORESOURCE_MEM,
108 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
110 .start = 6, /* Card Detect PF6 */
112 .flags = IORESOURCE_IRQ,
116 static struct platform_device bfin_pcmcia_cf_device = {
117 .name = "bfin_cf_pcmcia",
119 .num_resources = ARRAY_SIZE(bfin_pcmcia_cf_resources),
120 .resource = bfin_pcmcia_cf_resources,
124 #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
125 static struct platform_device rtc_device = {
131 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
132 static struct resource smc91x_resources[] = {
134 .name = "smc91x-regs",
136 .end = 0x20300300 + 16,
137 .flags = IORESOURCE_MEM,
142 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
145 static struct platform_device smc91x_device = {
148 .num_resources = ARRAY_SIZE(smc91x_resources),
149 .resource = smc91x_resources,
153 #if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
154 static struct resource dm9000_resources[] = {
157 .end = 0x203FB800 + 1,
158 .flags = IORESOURCE_MEM,
161 .start = 0x203FB800 + 4,
162 .end = 0x203FB800 + 5,
163 .flags = IORESOURCE_MEM,
168 .flags = (IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE),
172 static struct platform_device dm9000_device = {
175 .num_resources = ARRAY_SIZE(dm9000_resources),
176 .resource = dm9000_resources,
180 #if defined(CONFIG_USB_SL811_HCD) || defined(CONFIG_USB_SL811_HCD_MODULE)
181 static struct resource sl811_hcd_resources[] = {
185 .flags = IORESOURCE_MEM,
189 .flags = IORESOURCE_MEM,
191 .start = CONFIG_USB_SL811_BFIN_IRQ,
192 .end = CONFIG_USB_SL811_BFIN_IRQ,
193 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
197 #if defined(CONFIG_USB_SL811_BFIN_USE_VBUS)
198 void sl811_port_power(struct device *dev, int is_on)
200 gpio_request(CONFIG_USB_SL811_BFIN_GPIO_VBUS, "usb:SL811_VBUS");
201 gpio_direction_output(CONFIG_USB_SL811_BFIN_GPIO_VBUS, is_on);
206 static struct sl811_platform_data sl811_priv = {
208 .power = 250, /* == 500mA */
209 #if defined(CONFIG_USB_SL811_BFIN_USE_VBUS)
210 .port_power = &sl811_port_power,
214 static struct platform_device sl811_hcd_device = {
218 .platform_data = &sl811_priv,
220 .num_resources = ARRAY_SIZE(sl811_hcd_resources),
221 .resource = sl811_hcd_resources,
225 #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
226 static struct resource isp1362_hcd_resources[] = {
230 .flags = IORESOURCE_MEM,
234 .flags = IORESOURCE_MEM,
236 .start = CONFIG_USB_ISP1362_BFIN_GPIO_IRQ,
237 .end = CONFIG_USB_ISP1362_BFIN_GPIO_IRQ,
238 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
242 static struct isp1362_platform_data isp1362_priv = {
247 .int_edge_triggered = 0,
248 .remote_wakeup_connected = 0,
249 .no_power_switching = 1,
250 .power_switching_mode = 0,
253 static struct platform_device isp1362_hcd_device = {
254 .name = "isp1362-hcd",
257 .platform_data = &isp1362_priv,
259 .num_resources = ARRAY_SIZE(isp1362_hcd_resources),
260 .resource = isp1362_hcd_resources,
264 #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
265 static struct platform_device bfin_mii_bus = {
266 .name = "bfin_mii_bus",
269 static struct platform_device bfin_mac_device = {
271 .dev.platform_data = &bfin_mii_bus,
275 #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
276 static struct resource net2272_bfin_resources[] = {
279 .end = 0x20300000 + 0x100,
280 .flags = IORESOURCE_MEM,
284 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
288 static struct platform_device net2272_bfin_device = {
291 .num_resources = ARRAY_SIZE(net2272_bfin_resources),
292 .resource = net2272_bfin_resources,
296 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
297 /* all SPI peripherals info goes here */
299 #if defined(CONFIG_MTD_M25P80) \
300 || defined(CONFIG_MTD_M25P80_MODULE)
301 static struct mtd_partition bfin_spi_flash_partitions[] = {
303 .name = "bootloader(spi)",
306 .mask_flags = MTD_CAP_ROM
308 .name = "linux kernel(spi)",
312 .name = "file system(spi)",
314 .offset = 0x00100000,
318 static struct flash_platform_data bfin_spi_flash_data = {
320 .parts = bfin_spi_flash_partitions,
321 .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
325 /* SPI flash chip (m25p64) */
326 static struct bfin5xx_spi_chip spi_flash_chip_info = {
327 .enable_dma = 0, /* use dma transfer with this chip*/
332 #if defined(CONFIG_SPI_ADC_BF533) \
333 || defined(CONFIG_SPI_ADC_BF533_MODULE)
335 static struct bfin5xx_spi_chip spi_adc_chip_info = {
336 .enable_dma = 1, /* use dma transfer with this chip*/
341 #if defined(CONFIG_SND_BLACKFIN_AD1836) \
342 || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
343 static struct bfin5xx_spi_chip ad1836_spi_chip_info = {
349 #if defined(CONFIG_AD9960) || defined(CONFIG_AD9960_MODULE)
350 static struct bfin5xx_spi_chip ad9960_spi_chip_info = {
356 #if defined(CONFIG_SPI_MMC) || defined(CONFIG_SPI_MMC_MODULE)
357 static struct bfin5xx_spi_chip spi_mmc_chip_info = {
363 #if defined(CONFIG_PBX)
364 static struct bfin5xx_spi_chip spi_si3xxx_chip_info = {
365 .ctl_reg = 0x4, /* send zero */
368 .cs_change_per_word = 1,
372 #if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
373 static struct bfin5xx_spi_chip spi_ad7877_chip_info = {
378 static const struct ad7877_platform_data bfin_ad7877_ts_info = {
380 .vref_delay_usecs = 50, /* internal, no capacitor */
383 .pressure_max = 1000,
385 .stopacq_polarity = 1,
386 .first_conversion_delay = 3,
387 .acquisition_time = 1,
389 .pen_down_acc_interval = 1,
393 static struct spi_board_info bfin_spi_board_info[] __initdata = {
394 #if defined(CONFIG_MTD_M25P80) \
395 || defined(CONFIG_MTD_M25P80_MODULE)
397 /* the modalias must be the same as spi device driver name */
398 .modalias = "m25p80", /* Name of spi_driver for this device */
399 .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
400 .bus_num = 0, /* Framework bus number */
401 .chip_select = 1, /* Framework chip select. On STAMP537 it is SPISSEL1*/
402 .platform_data = &bfin_spi_flash_data,
403 .controller_data = &spi_flash_chip_info,
408 #if defined(CONFIG_SPI_ADC_BF533) \
409 || defined(CONFIG_SPI_ADC_BF533_MODULE)
411 .modalias = "bfin_spi_adc", /* Name of spi_driver for this device */
412 .max_speed_hz = 6250000, /* max spi clock (SCK) speed in HZ */
413 .bus_num = 0, /* Framework bus number */
414 .chip_select = 1, /* Framework chip select. */
415 .platform_data = NULL, /* No spi_driver specific config */
416 .controller_data = &spi_adc_chip_info,
420 #if defined(CONFIG_SND_BLACKFIN_AD1836) \
421 || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
423 .modalias = "ad1836-spi",
424 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
426 .chip_select = CONFIG_SND_BLACKFIN_SPI_PFBIT,
427 .controller_data = &ad1836_spi_chip_info,
430 #if defined(CONFIG_AD9960) || defined(CONFIG_AD9960_MODULE)
432 .modalias = "ad9960-spi",
433 .max_speed_hz = 10000000, /* max spi clock (SCK) speed in HZ */
436 .controller_data = &ad9960_spi_chip_info,
439 #if defined(CONFIG_SPI_MMC) || defined(CONFIG_SPI_MMC_MODULE)
441 .modalias = "spi_mmc_dummy",
442 .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
445 .platform_data = NULL,
446 .controller_data = &spi_mmc_chip_info,
450 .modalias = "spi_mmc",
451 .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
453 .chip_select = CONFIG_SPI_MMC_CS_CHAN,
454 .platform_data = NULL,
455 .controller_data = &spi_mmc_chip_info,
459 #if defined(CONFIG_PBX)
461 .modalias = "fxs-spi",
462 .max_speed_hz = 12500000, /* max spi clock (SCK) speed in HZ */
464 .chip_select = 8 - CONFIG_J11_JUMPER,
465 .controller_data = &spi_si3xxx_chip_info,
469 .modalias = "fxo-spi",
470 .max_speed_hz = 12500000, /* max spi clock (SCK) speed in HZ */
472 .chip_select = 8 - CONFIG_J19_JUMPER,
473 .controller_data = &spi_si3xxx_chip_info,
477 #if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
479 .modalias = "ad7877",
480 .platform_data = &bfin_ad7877_ts_info,
482 .max_speed_hz = 12500000, /* max spi clock (SCK) speed in HZ */
485 .controller_data = &spi_ad7877_chip_info,
490 /* SPI controller data */
491 static struct bfin5xx_spi_master bfin_spi0_info = {
493 .enable_dma = 1, /* master has the ability to do dma transfer */
494 .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
498 static struct resource bfin_spi0_resource[] = {
500 .start = SPI0_REGBASE,
501 .end = SPI0_REGBASE + 0xFF,
502 .flags = IORESOURCE_MEM,
507 .flags = IORESOURCE_IRQ,
511 static struct platform_device bfin_spi0_device = {
513 .id = 0, /* Bus number */
514 .num_resources = ARRAY_SIZE(bfin_spi0_resource),
515 .resource = bfin_spi0_resource,
517 .platform_data = &bfin_spi0_info, /* Passed to driver */
520 #endif /* spi master and devices */
522 #if defined(CONFIG_FB_BF537_LQ035) || defined(CONFIG_FB_BF537_LQ035_MODULE)
523 static struct platform_device bfin_fb_device = {
524 .name = "bf537-lq035",
528 #if defined(CONFIG_FB_BFIN_7393) || defined(CONFIG_FB_BFIN_7393_MODULE)
529 static struct platform_device bfin_fb_adv7393_device = {
530 .name = "bfin-adv7393",
534 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
535 static struct resource bfin_uart_resources[] = {
539 .flags = IORESOURCE_MEM,
543 .flags = IORESOURCE_MEM,
547 static struct platform_device bfin_uart_device = {
550 .num_resources = ARRAY_SIZE(bfin_uart_resources),
551 .resource = bfin_uart_resources,
555 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
556 #ifdef CONFIG_BFIN_SIR0
557 static struct resource bfin_sir0_resources[] = {
561 .flags = IORESOURCE_MEM,
564 .start = IRQ_UART0_RX,
565 .end = IRQ_UART0_RX+1,
566 .flags = IORESOURCE_IRQ,
569 .start = CH_UART0_RX,
570 .end = CH_UART0_RX+1,
571 .flags = IORESOURCE_DMA,
575 static struct platform_device bfin_sir0_device = {
578 .num_resources = ARRAY_SIZE(bfin_sir0_resources),
579 .resource = bfin_sir0_resources,
582 #ifdef CONFIG_BFIN_SIR1
583 static struct resource bfin_sir1_resources[] = {
587 .flags = IORESOURCE_MEM,
590 .start = IRQ_UART1_RX,
591 .end = IRQ_UART1_RX+1,
592 .flags = IORESOURCE_IRQ,
595 .start = CH_UART1_RX,
596 .end = CH_UART1_RX+1,
597 .flags = IORESOURCE_DMA,
601 static struct platform_device bfin_sir1_device = {
604 .num_resources = ARRAY_SIZE(bfin_sir1_resources),
605 .resource = bfin_sir1_resources,
610 #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
611 static struct resource bfin_twi0_resource[] = {
613 .start = TWI0_REGBASE,
614 .end = TWI0_REGBASE + 0xFF,
615 .flags = IORESOURCE_MEM,
620 .flags = IORESOURCE_IRQ,
624 static struct platform_device i2c_bfin_twi_device = {
625 .name = "i2c-bfin-twi",
627 .num_resources = ARRAY_SIZE(bfin_twi0_resource),
628 .resource = bfin_twi0_resource,
632 #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
633 static struct platform_device bfin_sport0_uart_device = {
634 .name = "bfin-sport-uart",
638 static struct platform_device bfin_sport1_uart_device = {
639 .name = "bfin-sport-uart",
644 static struct platform_device *stamp_devices[] __initdata = {
645 #if defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE)
646 &bfin_pcmcia_cf_device,
649 #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
653 #if defined(CONFIG_USB_SL811_HCD) || defined(CONFIG_USB_SL811_HCD_MODULE)
657 #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
661 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
665 #if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
669 #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
674 #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
675 &net2272_bfin_device,
678 #if defined(CONFIG_USB_ISP1760_HCD) || defined(CONFIG_USB_ISP1760_HCD_MODULE)
679 &bfin_isp1760_device,
682 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
686 #if defined(CONFIG_FB_BF537_LQ035) || defined(CONFIG_FB_BF537_LQ035_MODULE)
690 #if defined(CONFIG_FB_BFIN_7393) || defined(CONFIG_FB_BFIN_7393_MODULE)
691 &bfin_fb_adv7393_device,
694 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
698 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
699 #ifdef CONFIG_BFIN_SIR0
702 #ifdef CONFIG_BFIN_SIR1
707 #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
708 &i2c_bfin_twi_device,
711 #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
712 &bfin_sport0_uart_device,
713 &bfin_sport1_uart_device,
717 static int __init generic_init(void)
719 printk(KERN_INFO "%s(): registering device resources\n", __func__);
720 platform_add_devices(stamp_devices, ARRAY_SIZE(stamp_devices));
721 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
722 spi_register_board_info(bfin_spi_board_info,
723 ARRAY_SIZE(bfin_spi_board_info));
729 arch_initcall(generic_init);
731 void native_machine_restart(char *cmd)
733 /* workaround reboot hang when booting from SPI */
734 if ((bfin_read_SYSCR() & 0x7) == 0x3)
735 bfin_reset_boot_spi_cs(P_DEFAULT_BOOT_SPI_CS);
738 #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
739 void bfin_get_ether_addr(char *addr)
741 random_ether_addr(addr);
742 printk(KERN_WARNING "%s:%s: Setting Ethernet MAC to a random one\n", __FILE__, __func__);
744 EXPORT_SYMBOL(bfin_get_ether_addr);