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[] = "GENERIC Board";
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", __func__);
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_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE)
107 static struct resource bfin_pcmcia_cf_resources[] = {
109 .start = 0x20310000, /* IO PORT */
111 .flags = IORESOURCE_MEM,
113 .start = 0x20311000, /* Attribute Memory */
115 .flags = IORESOURCE_MEM,
119 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
121 .start = 6, /* Card Detect PF6 */
123 .flags = IORESOURCE_IRQ,
127 static struct platform_device bfin_pcmcia_cf_device = {
128 .name = "bfin_cf_pcmcia",
130 .num_resources = ARRAY_SIZE(bfin_pcmcia_cf_resources),
131 .resource = bfin_pcmcia_cf_resources,
135 #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
136 static struct platform_device rtc_device = {
142 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
143 static struct resource smc91x_resources[] = {
145 .name = "smc91x-regs",
147 .end = 0x20300300 + 16,
148 .flags = IORESOURCE_MEM,
153 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
156 static struct platform_device smc91x_device = {
159 .num_resources = ARRAY_SIZE(smc91x_resources),
160 .resource = smc91x_resources,
164 #if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
165 static struct resource dm9000_resources[] = {
168 .end = 0x203FB800 + 1,
169 .flags = IORESOURCE_MEM,
172 .start = 0x203FB800 + 4,
173 .end = 0x203FB800 + 5,
174 .flags = IORESOURCE_MEM,
179 .flags = (IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE),
183 static struct platform_device dm9000_device = {
186 .num_resources = ARRAY_SIZE(dm9000_resources),
187 .resource = dm9000_resources,
191 #if defined(CONFIG_USB_SL811_HCD) || defined(CONFIG_USB_SL811_HCD_MODULE)
192 static struct resource sl811_hcd_resources[] = {
196 .flags = IORESOURCE_MEM,
200 .flags = IORESOURCE_MEM,
202 .start = CONFIG_USB_SL811_BFIN_IRQ,
203 .end = CONFIG_USB_SL811_BFIN_IRQ,
204 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
208 #if defined(CONFIG_USB_SL811_BFIN_USE_VBUS)
209 void sl811_port_power(struct device *dev, int is_on)
211 gpio_request(CONFIG_USB_SL811_BFIN_GPIO_VBUS, "usb:SL811_VBUS");
212 gpio_direction_output(CONFIG_USB_SL811_BFIN_GPIO_VBUS, is_on);
217 static struct sl811_platform_data sl811_priv = {
219 .power = 250, /* == 500mA */
220 #if defined(CONFIG_USB_SL811_BFIN_USE_VBUS)
221 .port_power = &sl811_port_power,
225 static struct platform_device sl811_hcd_device = {
229 .platform_data = &sl811_priv,
231 .num_resources = ARRAY_SIZE(sl811_hcd_resources),
232 .resource = sl811_hcd_resources,
236 #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
237 static struct resource isp1362_hcd_resources[] = {
241 .flags = IORESOURCE_MEM,
245 .flags = IORESOURCE_MEM,
247 .start = CONFIG_USB_ISP1362_BFIN_GPIO_IRQ,
248 .end = CONFIG_USB_ISP1362_BFIN_GPIO_IRQ,
249 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
253 static struct isp1362_platform_data isp1362_priv = {
258 .int_edge_triggered = 0,
259 .remote_wakeup_connected = 0,
260 .no_power_switching = 1,
261 .power_switching_mode = 0,
264 static struct platform_device isp1362_hcd_device = {
265 .name = "isp1362-hcd",
268 .platform_data = &isp1362_priv,
270 .num_resources = ARRAY_SIZE(isp1362_hcd_resources),
271 .resource = isp1362_hcd_resources,
275 #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
276 static struct platform_device bfin_mac_device = {
281 #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
282 static struct resource net2272_bfin_resources[] = {
285 .end = 0x20300000 + 0x100,
286 .flags = IORESOURCE_MEM,
290 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
294 static struct platform_device net2272_bfin_device = {
297 .num_resources = ARRAY_SIZE(net2272_bfin_resources),
298 .resource = net2272_bfin_resources,
302 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
303 /* all SPI peripherals info goes here */
305 #if defined(CONFIG_MTD_M25P80) \
306 || defined(CONFIG_MTD_M25P80_MODULE)
307 static struct mtd_partition bfin_spi_flash_partitions[] = {
309 .name = "bootloader(spi)",
312 .mask_flags = MTD_CAP_ROM
314 .name = "linux kernel(spi)",
318 .name = "file system(spi)",
320 .offset = 0x00100000,
324 static struct flash_platform_data bfin_spi_flash_data = {
326 .parts = bfin_spi_flash_partitions,
327 .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
331 /* SPI flash chip (m25p64) */
332 static struct bfin5xx_spi_chip spi_flash_chip_info = {
333 .enable_dma = 0, /* use dma transfer with this chip*/
338 #if defined(CONFIG_SPI_ADC_BF533) \
339 || defined(CONFIG_SPI_ADC_BF533_MODULE)
341 static struct bfin5xx_spi_chip spi_adc_chip_info = {
342 .enable_dma = 1, /* use dma transfer with this chip*/
347 #if defined(CONFIG_SND_BLACKFIN_AD1836) \
348 || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
349 static struct bfin5xx_spi_chip ad1836_spi_chip_info = {
355 #if defined(CONFIG_AD9960) || defined(CONFIG_AD9960_MODULE)
356 static struct bfin5xx_spi_chip ad9960_spi_chip_info = {
362 #if defined(CONFIG_SPI_MMC) || defined(CONFIG_SPI_MMC_MODULE)
363 static struct bfin5xx_spi_chip spi_mmc_chip_info = {
369 #if defined(CONFIG_PBX)
370 static struct bfin5xx_spi_chip spi_si3xxx_chip_info = {
371 .ctl_reg = 0x4, /* send zero */
374 .cs_change_per_word = 1,
378 #if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
379 static struct bfin5xx_spi_chip spi_ad7877_chip_info = {
384 static const struct ad7877_platform_data bfin_ad7877_ts_info = {
386 .vref_delay_usecs = 50, /* internal, no capacitor */
389 .pressure_max = 1000,
391 .stopacq_polarity = 1,
392 .first_conversion_delay = 3,
393 .acquisition_time = 1,
395 .pen_down_acc_interval = 1,
399 static struct spi_board_info bfin_spi_board_info[] __initdata = {
400 #if defined(CONFIG_MTD_M25P80) \
401 || defined(CONFIG_MTD_M25P80_MODULE)
403 /* the modalias must be the same as spi device driver name */
404 .modalias = "m25p80", /* Name of spi_driver for this device */
405 .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
406 .bus_num = 0, /* Framework bus number */
407 .chip_select = 1, /* Framework chip select. On STAMP537 it is SPISSEL1*/
408 .platform_data = &bfin_spi_flash_data,
409 .controller_data = &spi_flash_chip_info,
414 #if defined(CONFIG_SPI_ADC_BF533) \
415 || defined(CONFIG_SPI_ADC_BF533_MODULE)
417 .modalias = "bfin_spi_adc", /* Name of spi_driver for this device */
418 .max_speed_hz = 6250000, /* max spi clock (SCK) speed in HZ */
419 .bus_num = 0, /* Framework bus number */
420 .chip_select = 1, /* Framework chip select. */
421 .platform_data = NULL, /* No spi_driver specific config */
422 .controller_data = &spi_adc_chip_info,
426 #if defined(CONFIG_SND_BLACKFIN_AD1836) \
427 || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
429 .modalias = "ad1836-spi",
430 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
432 .chip_select = CONFIG_SND_BLACKFIN_SPI_PFBIT,
433 .controller_data = &ad1836_spi_chip_info,
436 #if defined(CONFIG_AD9960) || defined(CONFIG_AD9960_MODULE)
438 .modalias = "ad9960-spi",
439 .max_speed_hz = 10000000, /* max spi clock (SCK) speed in HZ */
442 .controller_data = &ad9960_spi_chip_info,
445 #if defined(CONFIG_SPI_MMC) || defined(CONFIG_SPI_MMC_MODULE)
447 .modalias = "spi_mmc_dummy",
448 .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
451 .platform_data = NULL,
452 .controller_data = &spi_mmc_chip_info,
456 .modalias = "spi_mmc",
457 .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
459 .chip_select = CONFIG_SPI_MMC_CS_CHAN,
460 .platform_data = NULL,
461 .controller_data = &spi_mmc_chip_info,
465 #if defined(CONFIG_PBX)
467 .modalias = "fxs-spi",
468 .max_speed_hz = 12500000, /* max spi clock (SCK) speed in HZ */
470 .chip_select = 8 - CONFIG_J11_JUMPER,
471 .controller_data = &spi_si3xxx_chip_info,
475 .modalias = "fxo-spi",
476 .max_speed_hz = 12500000, /* max spi clock (SCK) speed in HZ */
478 .chip_select = 8 - CONFIG_J19_JUMPER,
479 .controller_data = &spi_si3xxx_chip_info,
483 #if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
485 .modalias = "ad7877",
486 .platform_data = &bfin_ad7877_ts_info,
488 .max_speed_hz = 12500000, /* max spi clock (SCK) speed in HZ */
491 .controller_data = &spi_ad7877_chip_info,
496 /* SPI controller data */
497 static struct bfin5xx_spi_master bfin_spi0_info = {
499 .enable_dma = 1, /* master has the ability to do dma transfer */
500 .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
504 static struct resource bfin_spi0_resource[] = {
506 .start = SPI0_REGBASE,
507 .end = SPI0_REGBASE + 0xFF,
508 .flags = IORESOURCE_MEM,
513 .flags = IORESOURCE_IRQ,
517 static struct platform_device bfin_spi0_device = {
519 .id = 0, /* Bus number */
520 .num_resources = ARRAY_SIZE(bfin_spi0_resource),
521 .resource = bfin_spi0_resource,
523 .platform_data = &bfin_spi0_info, /* Passed to driver */
526 #endif /* spi master and devices */
528 #if defined(CONFIG_FB_BF537_LQ035) || defined(CONFIG_FB_BF537_LQ035_MODULE)
529 static struct platform_device bfin_fb_device = {
530 .name = "bf537-lq035",
534 #if defined(CONFIG_FB_BFIN_7393) || defined(CONFIG_FB_BFIN_7393_MODULE)
535 static struct platform_device bfin_fb_adv7393_device = {
536 .name = "bfin-adv7393",
540 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
541 static struct resource bfin_uart_resources[] = {
545 .flags = IORESOURCE_MEM,
549 .flags = IORESOURCE_MEM,
553 static struct platform_device bfin_uart_device = {
556 .num_resources = ARRAY_SIZE(bfin_uart_resources),
557 .resource = bfin_uart_resources,
561 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
562 static struct resource bfin_sir_resources[] = {
563 #ifdef CONFIG_BFIN_SIR0
567 .flags = IORESOURCE_MEM,
570 #ifdef CONFIG_BFIN_SIR1
574 .flags = IORESOURCE_MEM,
579 static struct platform_device bfin_sir_device = {
582 .num_resources = ARRAY_SIZE(bfin_sir_resources),
583 .resource = bfin_sir_resources,
587 #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
588 static struct resource bfin_twi0_resource[] = {
590 .start = TWI0_REGBASE,
591 .end = TWI0_REGBASE + 0xFF,
592 .flags = IORESOURCE_MEM,
597 .flags = IORESOURCE_IRQ,
601 static struct platform_device i2c_bfin_twi_device = {
602 .name = "i2c-bfin-twi",
604 .num_resources = ARRAY_SIZE(bfin_twi0_resource),
605 .resource = bfin_twi0_resource,
609 #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
610 static struct platform_device bfin_sport0_uart_device = {
611 .name = "bfin-sport-uart",
615 static struct platform_device bfin_sport1_uart_device = {
616 .name = "bfin-sport-uart",
621 static struct platform_device *stamp_devices[] __initdata = {
622 #if defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE)
623 &bfin_pcmcia_cf_device,
626 #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
630 #if defined(CONFIG_USB_SL811_HCD) || defined(CONFIG_USB_SL811_HCD_MODULE)
634 #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
638 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
642 #if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
646 #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
650 #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
651 &net2272_bfin_device,
654 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
658 #if defined(CONFIG_FB_BF537_LQ035) || defined(CONFIG_FB_BF537_LQ035_MODULE)
662 #if defined(CONFIG_FB_BFIN_7393) || defined(CONFIG_FB_BFIN_7393_MODULE)
663 &bfin_fb_adv7393_device,
666 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
670 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
674 #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
675 &i2c_bfin_twi_device,
678 #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
679 &bfin_sport0_uart_device,
680 &bfin_sport1_uart_device,
684 static int __init stamp_init(void)
686 printk(KERN_INFO "%s(): registering device resources\n", __func__);
687 platform_add_devices(stamp_devices, ARRAY_SIZE(stamp_devices));
688 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
689 spi_register_board_info(bfin_spi_board_info,
690 ARRAY_SIZE(bfin_spi_board_info));
696 arch_initcall(stamp_init);
698 void native_machine_restart(char *cmd)
700 /* workaround reboot hang when booting from SPI */
701 if ((bfin_read_SYSCR() & 0x7) == 0x3)
702 bfin_gpio_reset_spi0_ssel1();
705 #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
706 void bfin_get_ether_addr(char *addr)
708 random_ether_addr(addr);
709 printk(KERN_WARNING "%s:%s: Setting Ethernet MAC to a random one\n", __FILE__, __func__);
711 EXPORT_SYMBOL(bfin_get_ether_addr);