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_mac_device = {
270 #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
271 static struct resource net2272_bfin_resources[] = {
274 .end = 0x20300000 + 0x100,
275 .flags = IORESOURCE_MEM,
279 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
283 static struct platform_device net2272_bfin_device = {
286 .num_resources = ARRAY_SIZE(net2272_bfin_resources),
287 .resource = net2272_bfin_resources,
291 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
292 /* all SPI peripherals info goes here */
294 #if defined(CONFIG_MTD_M25P80) \
295 || defined(CONFIG_MTD_M25P80_MODULE)
296 static struct mtd_partition bfin_spi_flash_partitions[] = {
298 .name = "bootloader(spi)",
301 .mask_flags = MTD_CAP_ROM
303 .name = "linux kernel(spi)",
307 .name = "file system(spi)",
309 .offset = 0x00100000,
313 static struct flash_platform_data bfin_spi_flash_data = {
315 .parts = bfin_spi_flash_partitions,
316 .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
320 /* SPI flash chip (m25p64) */
321 static struct bfin5xx_spi_chip spi_flash_chip_info = {
322 .enable_dma = 0, /* use dma transfer with this chip*/
327 #if defined(CONFIG_SPI_ADC_BF533) \
328 || defined(CONFIG_SPI_ADC_BF533_MODULE)
330 static struct bfin5xx_spi_chip spi_adc_chip_info = {
331 .enable_dma = 1, /* use dma transfer with this chip*/
336 #if defined(CONFIG_SND_BLACKFIN_AD1836) \
337 || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
338 static struct bfin5xx_spi_chip ad1836_spi_chip_info = {
344 #if defined(CONFIG_AD9960) || defined(CONFIG_AD9960_MODULE)
345 static struct bfin5xx_spi_chip ad9960_spi_chip_info = {
351 #if defined(CONFIG_SPI_MMC) || defined(CONFIG_SPI_MMC_MODULE)
352 static struct bfin5xx_spi_chip spi_mmc_chip_info = {
358 #if defined(CONFIG_PBX)
359 static struct bfin5xx_spi_chip spi_si3xxx_chip_info = {
360 .ctl_reg = 0x4, /* send zero */
363 .cs_change_per_word = 1,
367 #if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
368 static struct bfin5xx_spi_chip spi_ad7877_chip_info = {
373 static const struct ad7877_platform_data bfin_ad7877_ts_info = {
375 .vref_delay_usecs = 50, /* internal, no capacitor */
378 .pressure_max = 1000,
380 .stopacq_polarity = 1,
381 .first_conversion_delay = 3,
382 .acquisition_time = 1,
384 .pen_down_acc_interval = 1,
388 static struct spi_board_info bfin_spi_board_info[] __initdata = {
389 #if defined(CONFIG_MTD_M25P80) \
390 || defined(CONFIG_MTD_M25P80_MODULE)
392 /* the modalias must be the same as spi device driver name */
393 .modalias = "m25p80", /* Name of spi_driver for this device */
394 .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
395 .bus_num = 0, /* Framework bus number */
396 .chip_select = 1, /* Framework chip select. On STAMP537 it is SPISSEL1*/
397 .platform_data = &bfin_spi_flash_data,
398 .controller_data = &spi_flash_chip_info,
403 #if defined(CONFIG_SPI_ADC_BF533) \
404 || defined(CONFIG_SPI_ADC_BF533_MODULE)
406 .modalias = "bfin_spi_adc", /* Name of spi_driver for this device */
407 .max_speed_hz = 6250000, /* max spi clock (SCK) speed in HZ */
408 .bus_num = 0, /* Framework bus number */
409 .chip_select = 1, /* Framework chip select. */
410 .platform_data = NULL, /* No spi_driver specific config */
411 .controller_data = &spi_adc_chip_info,
415 #if defined(CONFIG_SND_BLACKFIN_AD1836) \
416 || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
418 .modalias = "ad1836-spi",
419 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
421 .chip_select = CONFIG_SND_BLACKFIN_SPI_PFBIT,
422 .controller_data = &ad1836_spi_chip_info,
425 #if defined(CONFIG_AD9960) || defined(CONFIG_AD9960_MODULE)
427 .modalias = "ad9960-spi",
428 .max_speed_hz = 10000000, /* max spi clock (SCK) speed in HZ */
431 .controller_data = &ad9960_spi_chip_info,
434 #if defined(CONFIG_SPI_MMC) || defined(CONFIG_SPI_MMC_MODULE)
436 .modalias = "spi_mmc_dummy",
437 .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
440 .platform_data = NULL,
441 .controller_data = &spi_mmc_chip_info,
445 .modalias = "spi_mmc",
446 .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
448 .chip_select = CONFIG_SPI_MMC_CS_CHAN,
449 .platform_data = NULL,
450 .controller_data = &spi_mmc_chip_info,
454 #if defined(CONFIG_PBX)
456 .modalias = "fxs-spi",
457 .max_speed_hz = 12500000, /* max spi clock (SCK) speed in HZ */
459 .chip_select = 8 - CONFIG_J11_JUMPER,
460 .controller_data = &spi_si3xxx_chip_info,
464 .modalias = "fxo-spi",
465 .max_speed_hz = 12500000, /* max spi clock (SCK) speed in HZ */
467 .chip_select = 8 - CONFIG_J19_JUMPER,
468 .controller_data = &spi_si3xxx_chip_info,
472 #if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
474 .modalias = "ad7877",
475 .platform_data = &bfin_ad7877_ts_info,
477 .max_speed_hz = 12500000, /* max spi clock (SCK) speed in HZ */
480 .controller_data = &spi_ad7877_chip_info,
485 /* SPI controller data */
486 static struct bfin5xx_spi_master bfin_spi0_info = {
488 .enable_dma = 1, /* master has the ability to do dma transfer */
489 .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
493 static struct resource bfin_spi0_resource[] = {
495 .start = SPI0_REGBASE,
496 .end = SPI0_REGBASE + 0xFF,
497 .flags = IORESOURCE_MEM,
502 .flags = IORESOURCE_IRQ,
506 static struct platform_device bfin_spi0_device = {
508 .id = 0, /* Bus number */
509 .num_resources = ARRAY_SIZE(bfin_spi0_resource),
510 .resource = bfin_spi0_resource,
512 .platform_data = &bfin_spi0_info, /* Passed to driver */
515 #endif /* spi master and devices */
517 #if defined(CONFIG_FB_BF537_LQ035) || defined(CONFIG_FB_BF537_LQ035_MODULE)
518 static struct platform_device bfin_fb_device = {
519 .name = "bf537-lq035",
523 #if defined(CONFIG_FB_BFIN_7393) || defined(CONFIG_FB_BFIN_7393_MODULE)
524 static struct platform_device bfin_fb_adv7393_device = {
525 .name = "bfin-adv7393",
529 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
530 static struct resource bfin_uart_resources[] = {
534 .flags = IORESOURCE_MEM,
538 .flags = IORESOURCE_MEM,
542 static struct platform_device bfin_uart_device = {
545 .num_resources = ARRAY_SIZE(bfin_uart_resources),
546 .resource = bfin_uart_resources,
550 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
551 #ifdef CONFIG_BFIN_SIR0
552 static struct resource bfin_sir0_resources[] = {
556 .flags = IORESOURCE_MEM,
559 .start = IRQ_UART0_RX,
560 .end = IRQ_UART0_RX+1,
561 .flags = IORESOURCE_IRQ,
564 .start = CH_UART0_RX,
565 .end = CH_UART0_RX+1,
566 .flags = IORESOURCE_DMA,
570 static struct platform_device bfin_sir0_device = {
573 .num_resources = ARRAY_SIZE(bfin_sir0_resources),
574 .resource = bfin_sir0_resources,
577 #ifdef CONFIG_BFIN_SIR1
578 static struct resource bfin_sir1_resources[] = {
582 .flags = IORESOURCE_MEM,
585 .start = IRQ_UART1_RX,
586 .end = IRQ_UART1_RX+1,
587 .flags = IORESOURCE_IRQ,
590 .start = CH_UART1_RX,
591 .end = CH_UART1_RX+1,
592 .flags = IORESOURCE_DMA,
596 static struct platform_device bfin_sir1_device = {
599 .num_resources = ARRAY_SIZE(bfin_sir1_resources),
600 .resource = bfin_sir1_resources,
605 #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
606 static struct resource bfin_twi0_resource[] = {
608 .start = TWI0_REGBASE,
609 .end = TWI0_REGBASE + 0xFF,
610 .flags = IORESOURCE_MEM,
615 .flags = IORESOURCE_IRQ,
619 static struct platform_device i2c_bfin_twi_device = {
620 .name = "i2c-bfin-twi",
622 .num_resources = ARRAY_SIZE(bfin_twi0_resource),
623 .resource = bfin_twi0_resource,
627 #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
628 static struct platform_device bfin_sport0_uart_device = {
629 .name = "bfin-sport-uart",
633 static struct platform_device bfin_sport1_uart_device = {
634 .name = "bfin-sport-uart",
639 static struct platform_device *stamp_devices[] __initdata = {
640 #if defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE)
641 &bfin_pcmcia_cf_device,
644 #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
648 #if defined(CONFIG_USB_SL811_HCD) || defined(CONFIG_USB_SL811_HCD_MODULE)
652 #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
656 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
660 #if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
664 #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
668 #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
669 &net2272_bfin_device,
672 #if defined(CONFIG_USB_ISP1760_HCD) || defined(CONFIG_USB_ISP1760_HCD_MODULE)
673 &bfin_isp1760_device,
676 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
680 #if defined(CONFIG_FB_BF537_LQ035) || defined(CONFIG_FB_BF537_LQ035_MODULE)
684 #if defined(CONFIG_FB_BFIN_7393) || defined(CONFIG_FB_BFIN_7393_MODULE)
685 &bfin_fb_adv7393_device,
688 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
692 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
693 #ifdef CONFIG_BFIN_SIR0
696 #ifdef CONFIG_BFIN_SIR1
701 #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
702 &i2c_bfin_twi_device,
705 #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
706 &bfin_sport0_uart_device,
707 &bfin_sport1_uart_device,
711 static int __init stamp_init(void)
713 printk(KERN_INFO "%s(): registering device resources\n", __func__);
714 platform_add_devices(stamp_devices, ARRAY_SIZE(stamp_devices));
715 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
716 spi_register_board_info(bfin_spi_board_info,
717 ARRAY_SIZE(bfin_spi_board_info));
723 arch_initcall(stamp_init);
725 void native_machine_restart(char *cmd)
727 /* workaround reboot hang when booting from SPI */
728 if ((bfin_read_SYSCR() & 0x7) == 0x3)
729 bfin_gpio_reset_spi0_ssel1();
732 #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
733 void bfin_get_ether_addr(char *addr)
735 random_ether_addr(addr);
736 printk(KERN_WARNING "%s:%s: Setting Ethernet MAC to a random one\n", __FILE__, __func__);
738 EXPORT_SYMBOL(bfin_get_ether_addr);