2 * File: arch/blackfin/mach-bf537/boards/stamp.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-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/platform_device.h>
33 #include <linux/mtd/mtd.h>
34 #include <linux/mtd/partitions.h>
35 #include <linux/spi/spi.h>
36 #include <linux/spi/flash.h>
37 #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
38 #include <linux/usb/isp1362.h>
40 #include <linux/pata_platform.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[] = "ADDS-BF537-STAMP";
56 * Driver needs to know address, irq and flag pin.
59 #define ISP1761_BASE 0x203C0000
60 #define ISP1761_IRQ IRQ_PF7
62 #if defined(CONFIG_USB_ISP1760_HCD) || defined(CONFIG_USB_ISP1760_HCD_MODULE)
63 static struct resource bfin_isp1761_resources[] = {
65 .name = "isp1761-regs",
66 .start = ISP1761_BASE + 0x00000000,
67 .end = ISP1761_BASE + 0x000fffff,
68 .flags = IORESOURCE_MEM,
73 .flags = IORESOURCE_IRQ,
77 static struct platform_device bfin_isp1761_device = {
80 .num_resources = ARRAY_SIZE(bfin_isp1761_resources),
81 .resource = bfin_isp1761_resources,
84 static struct platform_device *bfin_isp1761_devices[] = {
88 int __init bfin_isp1761_init(void)
90 unsigned int num_devices = ARRAY_SIZE(bfin_isp1761_devices);
92 printk(KERN_INFO "%s(): registering device resources\n", __FUNCTION__);
93 set_irq_type(ISP1761_IRQ, IRQF_TRIGGER_FALLING);
95 return platform_add_devices(bfin_isp1761_devices, num_devices);
98 void __exit bfin_isp1761_exit(void)
100 platform_device_unregister(&bfin_isp1761_device);
103 arch_initcall(bfin_isp1761_init);
106 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
107 #include <linux/input.h>
108 #include <linux/gpio_keys.h>
110 static struct gpio_keys_button bfin_gpio_keys_table[] = {
111 {BTN_0, GPIO_PF2, 1, "gpio-keys: BTN0"},
112 {BTN_1, GPIO_PF3, 1, "gpio-keys: BTN1"},
113 {BTN_2, GPIO_PF4, 1, "gpio-keys: BTN2"},
114 {BTN_3, GPIO_PF5, 1, "gpio-keys: BTN3"},
117 static struct gpio_keys_platform_data bfin_gpio_keys_data = {
118 .buttons = bfin_gpio_keys_table,
119 .nbuttons = ARRAY_SIZE(bfin_gpio_keys_table),
122 static struct platform_device bfin_device_gpiokeys = {
125 .platform_data = &bfin_gpio_keys_data,
130 #if defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE)
131 static struct resource bfin_pcmcia_cf_resources[] = {
133 .start = 0x20310000, /* IO PORT */
135 .flags = IORESOURCE_MEM,
137 .start = 0x20311000, /* Attribute Memory */
139 .flags = IORESOURCE_MEM,
143 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
145 .start = 6, /* Card Detect PF6 */
147 .flags = IORESOURCE_IRQ,
151 static struct platform_device bfin_pcmcia_cf_device = {
152 .name = "bfin_cf_pcmcia",
154 .num_resources = ARRAY_SIZE(bfin_pcmcia_cf_resources),
155 .resource = bfin_pcmcia_cf_resources,
159 #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
160 static struct platform_device rtc_device = {
166 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
167 static struct resource smc91x_resources[] = {
169 .name = "smc91x-regs",
171 .end = 0x20300300 + 16,
172 .flags = IORESOURCE_MEM,
177 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
180 static struct platform_device smc91x_device = {
183 .num_resources = ARRAY_SIZE(smc91x_resources),
184 .resource = smc91x_resources,
188 #if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
189 static struct resource dm9000_resources[] = {
192 .end = 0x203FB800 + 8,
193 .flags = IORESOURCE_MEM,
198 .flags = (IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE),
202 static struct platform_device dm9000_device = {
205 .num_resources = ARRAY_SIZE(dm9000_resources),
206 .resource = dm9000_resources,
210 #if defined(CONFIG_AX88180) || defined(CONFIG_AX88180_MODULE)
211 static struct resource ax88180_resources[] = {
214 .end = 0x20300000 + 0x8000,
215 .flags = IORESOURCE_MEM,
220 .flags = (IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL),
224 static struct platform_device ax88180_device = {
227 .num_resources = ARRAY_SIZE(ax88180_resources),
228 .resource = ax88180_resources,
232 #if defined(CONFIG_USB_SL811_HCD) || defined(CONFIG_USB_SL811_HCD_MODULE)
233 static struct resource sl811_hcd_resources[] = {
237 .flags = IORESOURCE_MEM,
241 .flags = IORESOURCE_MEM,
243 .start = CONFIG_USB_SL811_BFIN_IRQ,
244 .end = CONFIG_USB_SL811_BFIN_IRQ,
245 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
249 #if defined(CONFIG_USB_SL811_BFIN_USE_VBUS)
250 void sl811_port_power(struct device *dev, int is_on)
252 gpio_request(CONFIG_USB_SL811_BFIN_GPIO_VBUS, "usb:SL811_VBUS");
253 gpio_direction_output(CONFIG_USB_SL811_BFIN_GPIO_VBUS);
256 gpio_set_value(CONFIG_USB_SL811_BFIN_GPIO_VBUS, 1);
258 gpio_set_value(CONFIG_USB_SL811_BFIN_GPIO_VBUS, 0);
262 static struct sl811_platform_data sl811_priv = {
264 .power = 250, /* == 500mA */
265 #if defined(CONFIG_USB_SL811_BFIN_USE_VBUS)
266 .port_power = &sl811_port_power,
270 static struct platform_device sl811_hcd_device = {
274 .platform_data = &sl811_priv,
276 .num_resources = ARRAY_SIZE(sl811_hcd_resources),
277 .resource = sl811_hcd_resources,
281 #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
282 static struct resource isp1362_hcd_resources[] = {
286 .flags = IORESOURCE_MEM,
290 .flags = IORESOURCE_MEM,
292 .start = CONFIG_USB_ISP1362_BFIN_GPIO_IRQ,
293 .end = CONFIG_USB_ISP1362_BFIN_GPIO_IRQ,
294 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
298 static struct isp1362_platform_data isp1362_priv = {
303 .int_edge_triggered = 0,
304 .remote_wakeup_connected = 0,
305 .no_power_switching = 1,
306 .power_switching_mode = 0,
309 static struct platform_device isp1362_hcd_device = {
310 .name = "isp1362-hcd",
313 .platform_data = &isp1362_priv,
315 .num_resources = ARRAY_SIZE(isp1362_hcd_resources),
316 .resource = isp1362_hcd_resources,
320 #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
321 static struct platform_device bfin_mac_device = {
326 #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
327 static struct resource net2272_bfin_resources[] = {
330 .end = 0x20300000 + 0x100,
331 .flags = IORESOURCE_MEM,
335 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
339 static struct platform_device net2272_bfin_device = {
342 .num_resources = ARRAY_SIZE(net2272_bfin_resources),
343 .resource = net2272_bfin_resources,
347 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
348 /* all SPI peripherals info goes here */
350 #if defined(CONFIG_MTD_M25P80) \
351 || defined(CONFIG_MTD_M25P80_MODULE)
352 static struct mtd_partition bfin_spi_flash_partitions[] = {
354 .name = "bootloader",
357 .mask_flags = MTD_CAP_ROM
363 .name = "file system",
365 .offset = 0x00100000,
369 static struct flash_platform_data bfin_spi_flash_data = {
371 .parts = bfin_spi_flash_partitions,
372 .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
376 /* SPI flash chip (m25p64) */
377 static struct bfin5xx_spi_chip spi_flash_chip_info = {
378 .enable_dma = 0, /* use dma transfer with this chip*/
383 #if defined(CONFIG_SPI_ADC_BF533) \
384 || defined(CONFIG_SPI_ADC_BF533_MODULE)
386 static struct bfin5xx_spi_chip spi_adc_chip_info = {
387 .enable_dma = 1, /* use dma transfer with this chip*/
392 #if defined(CONFIG_SND_BLACKFIN_AD1836) \
393 || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
394 static struct bfin5xx_spi_chip ad1836_spi_chip_info = {
400 #if defined(CONFIG_AD9960) || defined(CONFIG_AD9960_MODULE)
401 static struct bfin5xx_spi_chip ad9960_spi_chip_info = {
407 #if defined(CONFIG_SPI_MMC) || defined(CONFIG_SPI_MMC_MODULE)
408 static struct bfin5xx_spi_chip spi_mmc_chip_info = {
414 #if defined(CONFIG_PBX)
415 static struct bfin5xx_spi_chip spi_si3xxx_chip_info = {
416 .ctl_reg = 0x4, /* send zero */
419 .cs_change_per_word = 1,
423 #if defined(CONFIG_AD5304) || defined(CONFIG_AD5304_MODULE)
424 static struct bfin5xx_spi_chip ad5304_chip_info = {
430 #if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
431 static struct bfin5xx_spi_chip spi_ad7877_chip_info = {
436 static const struct ad7877_platform_data bfin_ad7877_ts_info = {
438 .vref_delay_usecs = 50, /* internal, no capacitor */
441 .pressure_max = 1000,
443 .stopacq_polarity = 1,
444 .first_conversion_delay = 3,
445 .acquisition_time = 1,
447 .pen_down_acc_interval = 1,
451 static struct spi_board_info bfin_spi_board_info[] __initdata = {
452 #if defined(CONFIG_MTD_M25P80) \
453 || defined(CONFIG_MTD_M25P80_MODULE)
455 /* the modalias must be the same as spi device driver name */
456 .modalias = "m25p80", /* Name of spi_driver for this device */
457 .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
458 .bus_num = 0, /* Framework bus number */
459 .chip_select = 1, /* Framework chip select. On STAMP537 it is SPISSEL1*/
460 .platform_data = &bfin_spi_flash_data,
461 .controller_data = &spi_flash_chip_info,
466 #if defined(CONFIG_SPI_ADC_BF533) \
467 || defined(CONFIG_SPI_ADC_BF533_MODULE)
469 .modalias = "bfin_spi_adc", /* Name of spi_driver for this device */
470 .max_speed_hz = 6250000, /* max spi clock (SCK) speed in HZ */
471 .bus_num = 0, /* Framework bus number */
472 .chip_select = 1, /* Framework chip select. */
473 .platform_data = NULL, /* No spi_driver specific config */
474 .controller_data = &spi_adc_chip_info,
478 #if defined(CONFIG_SND_BLACKFIN_AD1836) \
479 || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
481 .modalias = "ad1836-spi",
482 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
484 .chip_select = CONFIG_SND_BLACKFIN_SPI_PFBIT,
485 .controller_data = &ad1836_spi_chip_info,
488 #if defined(CONFIG_AD9960) || defined(CONFIG_AD9960_MODULE)
490 .modalias = "ad9960-spi",
491 .max_speed_hz = 10000000, /* max spi clock (SCK) speed in HZ */
494 .controller_data = &ad9960_spi_chip_info,
497 #if defined(CONFIG_SPI_MMC) || defined(CONFIG_SPI_MMC_MODULE)
499 .modalias = "spi_mmc_dummy",
500 .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */
503 .platform_data = NULL,
504 .controller_data = &spi_mmc_chip_info,
508 .modalias = "spi_mmc",
509 .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */
511 .chip_select = CONFIG_SPI_MMC_CS_CHAN,
512 .platform_data = NULL,
513 .controller_data = &spi_mmc_chip_info,
517 #if defined(CONFIG_PBX)
519 .modalias = "fxs-spi",
520 .max_speed_hz = 12500000, /* max spi clock (SCK) speed in HZ */
522 .chip_select = 8 - CONFIG_J11_JUMPER,
523 .controller_data = &spi_si3xxx_chip_info,
527 .modalias = "fxo-spi",
528 .max_speed_hz = 12500000, /* max spi clock (SCK) speed in HZ */
530 .chip_select = 8 - CONFIG_J19_JUMPER,
531 .controller_data = &spi_si3xxx_chip_info,
535 #if defined(CONFIG_AD5304) || defined(CONFIG_AD5304_MODULE)
537 .modalias = "ad5304_spi",
538 .max_speed_hz = 1250000, /* max spi clock (SCK) speed in HZ */
541 .platform_data = NULL,
542 .controller_data = &ad5304_chip_info,
546 #if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
548 .modalias = "ad7877",
549 .platform_data = &bfin_ad7877_ts_info,
551 .max_speed_hz = 12500000, /* max spi clock (SCK) speed in HZ */
554 .controller_data = &spi_ad7877_chip_info,
559 /* SPI controller data */
560 static struct bfin5xx_spi_master bfin_spi0_info = {
562 .enable_dma = 1, /* master has the ability to do dma transfer */
563 .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
567 static struct resource bfin_spi0_resource[] = {
569 .start = SPI0_REGBASE,
570 .end = SPI0_REGBASE + 0xFF,
571 .flags = IORESOURCE_MEM,
576 .flags = IORESOURCE_IRQ,
580 static struct platform_device bfin_spi0_device = {
582 .id = 0, /* Bus number */
583 .num_resources = ARRAY_SIZE(bfin_spi0_resource),
584 .resource = bfin_spi0_resource,
586 .platform_data = &bfin_spi0_info, /* Passed to driver */
589 #endif /* spi master and devices */
591 #if defined(CONFIG_FB_BF537_LQ035) || defined(CONFIG_FB_BF537_LQ035_MODULE)
592 static struct platform_device bfin_fb_device = {
593 .name = "bf537-lq035",
597 #if defined(CONFIG_FB_BFIN_7393) || defined(CONFIG_FB_BFIN_7393_MODULE)
598 static struct platform_device bfin_fb_adv7393_device = {
599 .name = "bfin-adv7393",
603 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
604 static struct resource bfin_uart_resources[] = {
605 #ifdef CONFIG_SERIAL_BFIN_UART0
609 .flags = IORESOURCE_MEM,
612 #ifdef CONFIG_SERIAL_BFIN_UART1
616 .flags = IORESOURCE_MEM,
621 static struct platform_device bfin_uart_device = {
624 .num_resources = ARRAY_SIZE(bfin_uart_resources),
625 .resource = bfin_uart_resources,
629 #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
630 static struct resource bfin_twi0_resource[] = {
632 .start = TWI0_REGBASE,
634 .flags = IORESOURCE_MEM,
639 .flags = IORESOURCE_IRQ,
643 static struct platform_device i2c_bfin_twi_device = {
644 .name = "i2c-bfin-twi",
646 .num_resources = ARRAY_SIZE(bfin_twi0_resource),
647 .resource = bfin_twi0_resource,
651 #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
652 static struct platform_device bfin_sport0_uart_device = {
653 .name = "bfin-sport-uart",
657 static struct platform_device bfin_sport1_uart_device = {
658 .name = "bfin-sport-uart",
663 #if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
666 static struct pata_platform_info bfin_pata_platform_data = {
668 .irq_flags = IRQF_TRIGGER_HIGH | IRQF_DISABLED,
671 static struct resource bfin_pata_resources[] = {
675 .flags = IORESOURCE_MEM,
680 .flags = IORESOURCE_MEM,
685 .flags = IORESOURCE_IRQ,
689 static struct platform_device bfin_pata_device = {
690 .name = "pata_platform",
692 .num_resources = ARRAY_SIZE(bfin_pata_resources),
693 .resource = bfin_pata_resources,
695 .platform_data = &bfin_pata_platform_data,
700 static struct platform_device *stamp_devices[] __initdata = {
701 #if defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE)
702 &bfin_pcmcia_cf_device,
705 #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
709 #if defined(CONFIG_USB_SL811_HCD) || defined(CONFIG_USB_SL811_HCD_MODULE)
713 #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
717 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
721 #if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
725 #if defined(CONFIG_AX88180) || defined(CONFIG_AX88180_MODULE)
729 #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
733 #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
734 &net2272_bfin_device,
737 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
741 #if defined(CONFIG_FB_BF537_LQ035) || defined(CONFIG_FB_BF537_LQ035_MODULE)
745 #if defined(CONFIG_FB_BFIN_7393) || defined(CONFIG_FB_BFIN_7393_MODULE)
746 &bfin_fb_adv7393_device,
749 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
753 #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
754 &i2c_bfin_twi_device,
757 #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
758 &bfin_sport0_uart_device,
759 &bfin_sport1_uart_device,
762 #if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
766 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
767 &bfin_device_gpiokeys,
771 static int __init stamp_init(void)
773 printk(KERN_INFO "%s(): registering device resources\n", __FUNCTION__);
774 platform_add_devices(stamp_devices, ARRAY_SIZE(stamp_devices));
775 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
776 spi_register_board_info(bfin_spi_board_info,
777 ARRAY_SIZE(bfin_spi_board_info));
780 #if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
781 irq_desc[PATA_INT].status |= IRQ_NOAUTOEN;
786 arch_initcall(stamp_init);
788 void native_machine_restart(char *cmd)
790 /* workaround reboot hang when booting from SPI */
791 if ((bfin_read_SYSCR() & 0x7) == 0x3)
792 bfin_gpio_reset_spi0_ssel1();
796 * Currently the MAC address is saved in Flash by U-Boot
798 #define FLASH_MAC 0x203f0000
799 void bfin_get_ether_addr(char *addr)
801 *(u32 *)(&(addr[0])) = bfin_read32(FLASH_MAC);
802 *(u16 *)(&(addr[4])) = bfin_read16(FLASH_MAC + 4);
804 EXPORT_SYMBOL(bfin_get_ether_addr);