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/mtd/physmap.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[] = "ADDS-BF537-STAMP";
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_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
108 #include <linux/input.h>
109 #include <linux/gpio_keys.h>
111 static struct gpio_keys_button bfin_gpio_keys_table[] = {
112 {BTN_0, GPIO_PF2, 1, "gpio-keys: BTN0"},
113 {BTN_1, GPIO_PF3, 1, "gpio-keys: BTN1"},
114 {BTN_2, GPIO_PF4, 1, "gpio-keys: BTN2"},
115 {BTN_3, GPIO_PF5, 1, "gpio-keys: BTN3"},
118 static struct gpio_keys_platform_data bfin_gpio_keys_data = {
119 .buttons = bfin_gpio_keys_table,
120 .nbuttons = ARRAY_SIZE(bfin_gpio_keys_table),
123 static struct platform_device bfin_device_gpiokeys = {
126 .platform_data = &bfin_gpio_keys_data,
131 static struct resource bfin_gpios_resources = {
133 .end = MAX_BLACKFIN_GPIOS - 1,
134 .flags = IORESOURCE_IRQ,
137 static struct platform_device bfin_gpios_device = {
138 .name = "simple-gpio",
141 .resource = &bfin_gpios_resources,
144 #if defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE)
145 static struct resource bfin_pcmcia_cf_resources[] = {
147 .start = 0x20310000, /* IO PORT */
149 .flags = IORESOURCE_MEM,
151 .start = 0x20311000, /* Attribute Memory */
153 .flags = IORESOURCE_MEM,
157 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
159 .start = 6, /* Card Detect PF6 */
161 .flags = IORESOURCE_IRQ,
165 static struct platform_device bfin_pcmcia_cf_device = {
166 .name = "bfin_cf_pcmcia",
168 .num_resources = ARRAY_SIZE(bfin_pcmcia_cf_resources),
169 .resource = bfin_pcmcia_cf_resources,
173 #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
174 static struct platform_device rtc_device = {
180 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
181 static struct resource smc91x_resources[] = {
183 .name = "smc91x-regs",
185 .end = 0x20300300 + 16,
186 .flags = IORESOURCE_MEM,
191 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
194 static struct platform_device smc91x_device = {
197 .num_resources = ARRAY_SIZE(smc91x_resources),
198 .resource = smc91x_resources,
202 #if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
203 static struct resource dm9000_resources[] = {
206 .end = 0x203FB800 + 8,
207 .flags = IORESOURCE_MEM,
212 .flags = (IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE),
216 static struct platform_device dm9000_device = {
219 .num_resources = ARRAY_SIZE(dm9000_resources),
220 .resource = dm9000_resources,
224 #if defined(CONFIG_AX88180) || defined(CONFIG_AX88180_MODULE)
225 static struct resource ax88180_resources[] = {
228 .end = 0x20300000 + 0x8000,
229 .flags = IORESOURCE_MEM,
234 .flags = (IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL),
238 static struct platform_device ax88180_device = {
241 .num_resources = ARRAY_SIZE(ax88180_resources),
242 .resource = ax88180_resources,
246 #if defined(CONFIG_USB_SL811_HCD) || defined(CONFIG_USB_SL811_HCD_MODULE)
247 static struct resource sl811_hcd_resources[] = {
251 .flags = IORESOURCE_MEM,
255 .flags = IORESOURCE_MEM,
257 .start = CONFIG_USB_SL811_BFIN_IRQ,
258 .end = CONFIG_USB_SL811_BFIN_IRQ,
259 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
263 #if defined(CONFIG_USB_SL811_BFIN_USE_VBUS)
264 void sl811_port_power(struct device *dev, int is_on)
266 gpio_request(CONFIG_USB_SL811_BFIN_GPIO_VBUS, "usb:SL811_VBUS");
267 gpio_direction_output(CONFIG_USB_SL811_BFIN_GPIO_VBUS, is_on);
271 static struct sl811_platform_data sl811_priv = {
273 .power = 250, /* == 500mA */
274 #if defined(CONFIG_USB_SL811_BFIN_USE_VBUS)
275 .port_power = &sl811_port_power,
279 static struct platform_device sl811_hcd_device = {
283 .platform_data = &sl811_priv,
285 .num_resources = ARRAY_SIZE(sl811_hcd_resources),
286 .resource = sl811_hcd_resources,
290 #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
291 static struct resource isp1362_hcd_resources[] = {
295 .flags = IORESOURCE_MEM,
299 .flags = IORESOURCE_MEM,
301 .start = CONFIG_USB_ISP1362_BFIN_GPIO_IRQ,
302 .end = CONFIG_USB_ISP1362_BFIN_GPIO_IRQ,
303 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
307 static struct isp1362_platform_data isp1362_priv = {
312 .int_edge_triggered = 0,
313 .remote_wakeup_connected = 0,
314 .no_power_switching = 1,
315 .power_switching_mode = 0,
318 static struct platform_device isp1362_hcd_device = {
319 .name = "isp1362-hcd",
322 .platform_data = &isp1362_priv,
324 .num_resources = ARRAY_SIZE(isp1362_hcd_resources),
325 .resource = isp1362_hcd_resources,
329 #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
330 static struct platform_device bfin_mac_device = {
335 #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
336 static struct resource net2272_bfin_resources[] = {
339 .end = 0x20300000 + 0x100,
340 .flags = IORESOURCE_MEM,
344 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
348 static struct platform_device net2272_bfin_device = {
351 .num_resources = ARRAY_SIZE(net2272_bfin_resources),
352 .resource = net2272_bfin_resources,
356 static struct mtd_partition stamp_partitions[] = {
358 .name = "Bootloader",
364 .offset = MTDPART_OFS_APPEND,
367 .size = 0x400000 - 0x40000 - 0xE0000 - 0x10000,
368 .offset = MTDPART_OFS_APPEND,
370 .name = "MAC Address",
371 .size = MTDPART_SIZ_FULL,
373 .mask_flags = MTD_WRITEABLE,
377 static struct physmap_flash_data stamp_flash_data = {
379 .parts = stamp_partitions,
380 .nr_parts = ARRAY_SIZE(stamp_partitions),
383 static struct resource stamp_flash_resource = {
386 .flags = IORESOURCE_MEM,
389 static struct platform_device stamp_flash_device = {
390 .name = "physmap-flash",
393 .platform_data = &stamp_flash_data,
396 .resource = &stamp_flash_resource,
399 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
400 /* all SPI peripherals info goes here */
402 #if defined(CONFIG_MTD_M25P80) \
403 || defined(CONFIG_MTD_M25P80_MODULE)
404 static struct mtd_partition bfin_spi_flash_partitions[] = {
406 .name = "bootloader",
409 .mask_flags = MTD_CAP_ROM
413 .offset = MTDPART_OFS_APPEND,
415 .name = "file system",
416 .size = MTDPART_SIZ_FULL,
417 .offset = MTDPART_OFS_APPEND,
421 static struct flash_platform_data bfin_spi_flash_data = {
423 .parts = bfin_spi_flash_partitions,
424 .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
428 /* SPI flash chip (m25p64) */
429 static struct bfin5xx_spi_chip spi_flash_chip_info = {
430 .enable_dma = 0, /* use dma transfer with this chip*/
435 #if defined(CONFIG_SPI_ADC_BF533) \
436 || defined(CONFIG_SPI_ADC_BF533_MODULE)
438 static struct bfin5xx_spi_chip spi_adc_chip_info = {
439 .enable_dma = 1, /* use dma transfer with this chip*/
444 #if defined(CONFIG_SND_BLACKFIN_AD1836) \
445 || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
446 static struct bfin5xx_spi_chip ad1836_spi_chip_info = {
452 #if defined(CONFIG_AD9960) || defined(CONFIG_AD9960_MODULE)
453 static struct bfin5xx_spi_chip ad9960_spi_chip_info = {
459 #if defined(CONFIG_SPI_MMC) || defined(CONFIG_SPI_MMC_MODULE)
460 static struct bfin5xx_spi_chip spi_mmc_chip_info = {
466 #if defined(CONFIG_PBX)
467 static struct bfin5xx_spi_chip spi_si3xxx_chip_info = {
468 .ctl_reg = 0x4, /* send zero */
471 .cs_change_per_word = 1,
475 #if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
476 static struct bfin5xx_spi_chip spi_ad7877_chip_info = {
481 static const struct ad7877_platform_data bfin_ad7877_ts_info = {
483 .vref_delay_usecs = 50, /* internal, no capacitor */
486 .pressure_max = 1000,
488 .stopacq_polarity = 1,
489 .first_conversion_delay = 3,
490 .acquisition_time = 1,
492 .pen_down_acc_interval = 1,
496 #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
497 static struct bfin5xx_spi_chip spidev_chip_info = {
503 static struct spi_board_info bfin_spi_board_info[] __initdata = {
504 #if defined(CONFIG_MTD_M25P80) \
505 || defined(CONFIG_MTD_M25P80_MODULE)
507 /* the modalias must be the same as spi device driver name */
508 .modalias = "m25p80", /* Name of spi_driver for this device */
509 .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
510 .bus_num = 0, /* Framework bus number */
511 .chip_select = 1, /* Framework chip select. On STAMP537 it is SPISSEL1*/
512 .platform_data = &bfin_spi_flash_data,
513 .controller_data = &spi_flash_chip_info,
518 #if defined(CONFIG_SPI_ADC_BF533) \
519 || defined(CONFIG_SPI_ADC_BF533_MODULE)
521 .modalias = "bfin_spi_adc", /* Name of spi_driver for this device */
522 .max_speed_hz = 6250000, /* max spi clock (SCK) speed in HZ */
523 .bus_num = 0, /* Framework bus number */
524 .chip_select = 1, /* Framework chip select. */
525 .platform_data = NULL, /* No spi_driver specific config */
526 .controller_data = &spi_adc_chip_info,
530 #if defined(CONFIG_SND_BLACKFIN_AD1836) \
531 || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
533 .modalias = "ad1836-spi",
534 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
536 .chip_select = CONFIG_SND_BLACKFIN_SPI_PFBIT,
537 .controller_data = &ad1836_spi_chip_info,
540 #if defined(CONFIG_AD9960) || defined(CONFIG_AD9960_MODULE)
542 .modalias = "ad9960-spi",
543 .max_speed_hz = 10000000, /* max spi clock (SCK) speed in HZ */
546 .controller_data = &ad9960_spi_chip_info,
549 #if defined(CONFIG_SPI_MMC) || defined(CONFIG_SPI_MMC_MODULE)
551 .modalias = "spi_mmc_dummy",
552 .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */
555 .platform_data = NULL,
556 .controller_data = &spi_mmc_chip_info,
560 .modalias = "spi_mmc",
561 .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */
563 .chip_select = CONFIG_SPI_MMC_CS_CHAN,
564 .platform_data = NULL,
565 .controller_data = &spi_mmc_chip_info,
569 #if defined(CONFIG_PBX)
571 .modalias = "fxs-spi",
572 .max_speed_hz = 12500000, /* max spi clock (SCK) speed in HZ */
574 .chip_select = 8 - CONFIG_J11_JUMPER,
575 .controller_data = &spi_si3xxx_chip_info,
579 .modalias = "fxo-spi",
580 .max_speed_hz = 12500000, /* max spi clock (SCK) speed in HZ */
582 .chip_select = 8 - CONFIG_J19_JUMPER,
583 .controller_data = &spi_si3xxx_chip_info,
587 #if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
589 .modalias = "ad7877",
590 .platform_data = &bfin_ad7877_ts_info,
592 .max_speed_hz = 12500000, /* max spi clock (SCK) speed in HZ */
595 .controller_data = &spi_ad7877_chip_info,
598 #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
600 .modalias = "spidev",
601 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
604 .controller_data = &spidev_chip_info,
609 /* SPI controller data */
610 static struct bfin5xx_spi_master bfin_spi0_info = {
612 .enable_dma = 1, /* master has the ability to do dma transfer */
613 .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
617 static struct resource bfin_spi0_resource[] = {
619 .start = SPI0_REGBASE,
620 .end = SPI0_REGBASE + 0xFF,
621 .flags = IORESOURCE_MEM,
626 .flags = IORESOURCE_IRQ,
630 static struct platform_device bfin_spi0_device = {
632 .id = 0, /* Bus number */
633 .num_resources = ARRAY_SIZE(bfin_spi0_resource),
634 .resource = bfin_spi0_resource,
636 .platform_data = &bfin_spi0_info, /* Passed to driver */
639 #endif /* spi master and devices */
641 #if defined(CONFIG_FB_BF537_LQ035) || defined(CONFIG_FB_BF537_LQ035_MODULE)
642 static struct platform_device bfin_fb_device = {
643 .name = "bf537-lq035",
647 #if defined(CONFIG_FB_BFIN_7393) || defined(CONFIG_FB_BFIN_7393_MODULE)
648 static struct platform_device bfin_fb_adv7393_device = {
649 .name = "bfin-adv7393",
653 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
654 static struct resource bfin_uart_resources[] = {
655 #ifdef CONFIG_SERIAL_BFIN_UART0
659 .flags = IORESOURCE_MEM,
662 #ifdef CONFIG_SERIAL_BFIN_UART1
666 .flags = IORESOURCE_MEM,
671 static struct platform_device bfin_uart_device = {
674 .num_resources = ARRAY_SIZE(bfin_uart_resources),
675 .resource = bfin_uart_resources,
679 #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
680 static struct resource bfin_twi0_resource[] = {
682 .start = TWI0_REGBASE,
684 .flags = IORESOURCE_MEM,
689 .flags = IORESOURCE_IRQ,
693 static struct platform_device i2c_bfin_twi_device = {
694 .name = "i2c-bfin-twi",
696 .num_resources = ARRAY_SIZE(bfin_twi0_resource),
697 .resource = bfin_twi0_resource,
701 #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
702 static struct platform_device bfin_sport0_uart_device = {
703 .name = "bfin-sport-uart",
707 static struct platform_device bfin_sport1_uart_device = {
708 .name = "bfin-sport-uart",
713 #if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
716 static struct pata_platform_info bfin_pata_platform_data = {
718 .irq_flags = IRQF_TRIGGER_HIGH | IRQF_DISABLED,
721 static struct resource bfin_pata_resources[] = {
725 .flags = IORESOURCE_MEM,
730 .flags = IORESOURCE_MEM,
735 .flags = IORESOURCE_IRQ,
739 static struct platform_device bfin_pata_device = {
740 .name = "pata_platform",
742 .num_resources = ARRAY_SIZE(bfin_pata_resources),
743 .resource = bfin_pata_resources,
745 .platform_data = &bfin_pata_platform_data,
750 static struct platform_device *stamp_devices[] __initdata = {
751 #if defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE)
752 &bfin_pcmcia_cf_device,
755 #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
759 #if defined(CONFIG_USB_SL811_HCD) || defined(CONFIG_USB_SL811_HCD_MODULE)
763 #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
767 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
771 #if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
775 #if defined(CONFIG_AX88180) || defined(CONFIG_AX88180_MODULE)
779 #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
783 #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
784 &net2272_bfin_device,
787 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
791 #if defined(CONFIG_FB_BF537_LQ035) || defined(CONFIG_FB_BF537_LQ035_MODULE)
795 #if defined(CONFIG_FB_BFIN_7393) || defined(CONFIG_FB_BFIN_7393_MODULE)
796 &bfin_fb_adv7393_device,
799 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
803 #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
804 &i2c_bfin_twi_device,
807 #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
808 &bfin_sport0_uart_device,
809 &bfin_sport1_uart_device,
812 #if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
816 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
817 &bfin_device_gpiokeys,
824 static int __init stamp_init(void)
826 printk(KERN_INFO "%s(): registering device resources\n", __FUNCTION__);
827 platform_add_devices(stamp_devices, ARRAY_SIZE(stamp_devices));
828 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
829 spi_register_board_info(bfin_spi_board_info,
830 ARRAY_SIZE(bfin_spi_board_info));
833 #if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
834 irq_desc[PATA_INT].status |= IRQ_NOAUTOEN;
839 arch_initcall(stamp_init);
841 void native_machine_restart(char *cmd)
843 /* workaround reboot hang when booting from SPI */
844 if ((bfin_read_SYSCR() & 0x7) == 0x3)
845 bfin_gpio_reset_spi0_ssel1();
849 * Currently the MAC address is saved in Flash by U-Boot
851 #define FLASH_MAC 0x203f0000
852 void bfin_get_ether_addr(char *addr)
854 *(u32 *)(&(addr[0])) = bfin_read32(FLASH_MAC);
855 *(u16 *)(&(addr[4])) = bfin_read16(FLASH_MAC + 4);
857 EXPORT_SYMBOL(bfin_get_ether_addr);