2 * Copyright 2004-2009 Analog Devices Inc.
3 * 2005 National ICT Australia (NICTA)
4 * Aidan Williams <aidan@nicta.com.au>
6 * Licensed under the GPL-2 or later.
9 #include <linux/device.h>
10 #include <linux/etherdevice.h>
11 #include <linux/platform_device.h>
12 #include <linux/mtd/mtd.h>
13 #include <linux/mtd/partitions.h>
14 #include <linux/spi/spi.h>
15 #include <linux/spi/flash.h>
16 #include <linux/irq.h>
18 #include <asm/bfin5xx_spi.h>
19 #include <asm/portmux.h>
20 #include <linux/usb/sl811.h>
22 #include <linux/spi/ad7877.h>
25 * Name the Board for the /proc/cpuinfo
27 const char bfin_board_name[] = "ADI PNAV-1.0";
30 * Driver needs to know address, irq and flag pin.
33 #if defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE)
34 static struct resource bfin_pcmcia_cf_resources[] = {
36 .start = 0x20310000, /* IO PORT */
38 .flags = IORESOURCE_MEM,
40 .start = 0x20311000, /* Attribute Memory */
42 .flags = IORESOURCE_MEM,
46 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
48 .start = 6, /* Card Detect PF6 */
50 .flags = IORESOURCE_IRQ,
54 static struct platform_device bfin_pcmcia_cf_device = {
55 .name = "bfin_cf_pcmcia",
57 .num_resources = ARRAY_SIZE(bfin_pcmcia_cf_resources),
58 .resource = bfin_pcmcia_cf_resources,
62 #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
63 static struct platform_device rtc_device = {
69 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
70 #include <linux/smc91x.h>
72 static struct smc91x_platdata smc91x_info = {
73 .flags = SMC91X_USE_16BIT | SMC91X_NOWAIT,
74 .leda = RPC_LED_100_10,
75 .ledb = RPC_LED_TX_RX,
78 static struct resource smc91x_resources[] = {
80 .name = "smc91x-regs",
82 .end = 0x20300300 + 16,
83 .flags = IORESOURCE_MEM,
88 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
91 static struct platform_device smc91x_device = {
94 .num_resources = ARRAY_SIZE(smc91x_resources),
95 .resource = smc91x_resources,
97 .platform_data = &smc91x_info,
102 #if defined(CONFIG_USB_SL811_HCD) || defined(CONFIG_USB_SL811_HCD_MODULE)
103 static struct resource sl811_hcd_resources[] = {
107 .flags = IORESOURCE_MEM,
111 .flags = IORESOURCE_MEM,
113 .start = CONFIG_USB_SL811_BFIN_IRQ,
114 .end = CONFIG_USB_SL811_BFIN_IRQ,
115 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
119 #if defined(CONFIG_USB_SL811_BFIN_USE_VBUS)
120 void sl811_port_power(struct device *dev, int is_on)
122 gpio_request(CONFIG_USB_SL811_BFIN_GPIO_VBUS, "usb:SL811_VBUS");
123 gpio_direction_output(CONFIG_USB_SL811_BFIN_GPIO_VBUS, is_on);
128 static struct sl811_platform_data sl811_priv = {
130 .power = 250, /* == 500mA */
131 #if defined(CONFIG_USB_SL811_BFIN_USE_VBUS)
132 .port_power = &sl811_port_power,
136 static struct platform_device sl811_hcd_device = {
140 .platform_data = &sl811_priv,
142 .num_resources = ARRAY_SIZE(sl811_hcd_resources),
143 .resource = sl811_hcd_resources,
147 #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
148 static struct platform_device bfin_mii_bus = {
149 .name = "bfin_mii_bus",
152 static struct platform_device bfin_mac_device = {
154 .dev.platform_data = &bfin_mii_bus,
158 #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
159 static struct resource net2272_bfin_resources[] = {
162 .end = 0x20300000 + 0x100,
163 .flags = IORESOURCE_MEM,
167 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
171 static struct platform_device net2272_bfin_device = {
174 .num_resources = ARRAY_SIZE(net2272_bfin_resources),
175 .resource = net2272_bfin_resources,
179 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
180 /* all SPI peripherals info goes here */
182 #if defined(CONFIG_MTD_M25P80) \
183 || defined(CONFIG_MTD_M25P80_MODULE)
184 static struct mtd_partition bfin_spi_flash_partitions[] = {
186 .name = "bootloader(spi)",
189 .mask_flags = MTD_CAP_ROM
191 .name = "linux kernel(spi)",
195 .name = "file system(spi)",
197 .offset = 0x00100000,
201 static struct flash_platform_data bfin_spi_flash_data = {
203 .parts = bfin_spi_flash_partitions,
204 .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
208 /* SPI flash chip (m25p64) */
209 static struct bfin5xx_spi_chip spi_flash_chip_info = {
210 .enable_dma = 0, /* use dma transfer with this chip*/
215 #if defined(CONFIG_BFIN_SPI_ADC) \
216 || defined(CONFIG_BFIN_SPI_ADC_MODULE)
218 static struct bfin5xx_spi_chip spi_adc_chip_info = {
219 .enable_dma = 1, /* use dma transfer with this chip*/
224 #if defined(CONFIG_SND_BLACKFIN_AD1836) \
225 || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
226 static struct bfin5xx_spi_chip ad1836_spi_chip_info = {
232 #if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
233 static struct bfin5xx_spi_chip mmc_spi_chip_info = {
239 #if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
240 static struct bfin5xx_spi_chip spi_ad7877_chip_info = {
245 static const struct ad7877_platform_data bfin_ad7877_ts_info = {
247 .vref_delay_usecs = 50, /* internal, no capacitor */
250 .pressure_max = 1000,
252 .stopacq_polarity = 1,
253 .first_conversion_delay = 3,
254 .acquisition_time = 1,
256 .pen_down_acc_interval = 1,
260 static struct spi_board_info bfin_spi_board_info[] __initdata = {
261 #if defined(CONFIG_MTD_M25P80) \
262 || defined(CONFIG_MTD_M25P80_MODULE)
264 /* the modalias must be the same as spi device driver name */
265 .modalias = "m25p80", /* Name of spi_driver for this device */
266 .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
267 .bus_num = 0, /* Framework bus number */
268 .chip_select = 1, /* Framework chip select. On STAMP537 it is SPISSEL1*/
269 .platform_data = &bfin_spi_flash_data,
270 .controller_data = &spi_flash_chip_info,
275 #if defined(CONFIG_BFIN_SPI_ADC) \
276 || defined(CONFIG_BFIN_SPI_ADC_MODULE)
278 .modalias = "bfin_spi_adc", /* Name of spi_driver for this device */
279 .max_speed_hz = 6250000, /* max spi clock (SCK) speed in HZ */
280 .bus_num = 0, /* Framework bus number */
281 .chip_select = 1, /* Framework chip select. */
282 .platform_data = NULL, /* No spi_driver specific config */
283 .controller_data = &spi_adc_chip_info,
287 #if defined(CONFIG_SND_BLACKFIN_AD1836) \
288 || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
290 .modalias = "ad1836",
291 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
293 .chip_select = CONFIG_SND_BLACKFIN_SPI_PFBIT,
294 .controller_data = &ad1836_spi_chip_info,
297 #if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
299 .modalias = "mmc_spi",
300 .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
303 .controller_data = &mmc_spi_chip_info,
307 #if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
309 .modalias = "ad7877",
310 .platform_data = &bfin_ad7877_ts_info,
312 .max_speed_hz = 12500000, /* max spi clock (SCK) speed in HZ */
315 .controller_data = &spi_ad7877_chip_info,
322 static struct resource bfin_spi0_resource[] = {
324 .start = SPI0_REGBASE,
325 .end = SPI0_REGBASE + 0xFF,
326 .flags = IORESOURCE_MEM,
331 .flags = IORESOURCE_DMA,
336 .flags = IORESOURCE_IRQ,
340 /* SPI controller data */
341 static struct bfin5xx_spi_master bfin_spi0_info = {
343 .enable_dma = 1, /* master has the ability to do dma transfer */
344 .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
347 static struct platform_device bfin_spi0_device = {
349 .id = 0, /* Bus number */
350 .num_resources = ARRAY_SIZE(bfin_spi0_resource),
351 .resource = bfin_spi0_resource,
353 .platform_data = &bfin_spi0_info, /* Passed to driver */
356 #endif /* spi master and devices */
358 #if defined(CONFIG_FB_BF537_LQ035) || defined(CONFIG_FB_BF537_LQ035_MODULE)
359 static struct platform_device bfin_fb_device = {
360 .name = "bf537-lq035",
364 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
365 #ifdef CONFIG_SERIAL_BFIN_UART0
366 static struct resource bfin_uart0_resources[] = {
370 .flags = IORESOURCE_MEM,
373 .start = IRQ_UART0_RX,
374 .end = IRQ_UART0_RX+1,
375 .flags = IORESOURCE_IRQ,
378 .start = IRQ_UART0_ERROR,
379 .end = IRQ_UART0_ERROR,
380 .flags = IORESOURCE_IRQ,
383 .start = CH_UART0_TX,
385 .flags = IORESOURCE_DMA,
388 .start = CH_UART0_RX,
390 .flags = IORESOURCE_DMA,
394 unsigned short bfin_uart0_peripherals[] = {
395 P_UART0_TX, P_UART0_RX, 0
398 static struct platform_device bfin_uart0_device = {
401 .num_resources = ARRAY_SIZE(bfin_uart0_resources),
402 .resource = bfin_uart0_resources,
404 .platform_data = &bfin_uart0_peripherals, /* Passed to driver */
408 #ifdef CONFIG_SERIAL_BFIN_UART1
409 static struct resource bfin_uart1_resources[] = {
413 .flags = IORESOURCE_MEM,
416 .start = IRQ_UART1_RX,
417 .end = IRQ_UART1_RX+1,
418 .flags = IORESOURCE_IRQ,
421 .start = IRQ_UART1_ERROR,
422 .end = IRQ_UART1_ERROR,
423 .flags = IORESOURCE_IRQ,
426 .start = CH_UART1_TX,
428 .flags = IORESOURCE_DMA,
431 .start = CH_UART1_RX,
433 .flags = IORESOURCE_DMA,
437 unsigned short bfin_uart1_peripherals[] = {
438 P_UART1_TX, P_UART1_RX, 0
441 static struct platform_device bfin_uart1_device = {
444 .num_resources = ARRAY_SIZE(bfin_uart1_resources),
445 .resource = bfin_uart1_resources,
447 .platform_data = &bfin_uart1_peripherals, /* Passed to driver */
453 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
454 #ifdef CONFIG_BFIN_SIR0
455 static struct resource bfin_sir0_resources[] = {
459 .flags = IORESOURCE_MEM,
462 .start = IRQ_UART0_RX,
463 .end = IRQ_UART0_RX+1,
464 .flags = IORESOURCE_IRQ,
467 .start = CH_UART0_RX,
468 .end = CH_UART0_RX+1,
469 .flags = IORESOURCE_DMA,
473 static struct platform_device bfin_sir0_device = {
476 .num_resources = ARRAY_SIZE(bfin_sir0_resources),
477 .resource = bfin_sir0_resources,
480 #ifdef CONFIG_BFIN_SIR1
481 static struct resource bfin_sir1_resources[] = {
485 .flags = IORESOURCE_MEM,
488 .start = IRQ_UART1_RX,
489 .end = IRQ_UART1_RX+1,
490 .flags = IORESOURCE_IRQ,
493 .start = CH_UART1_RX,
494 .end = CH_UART1_RX+1,
495 .flags = IORESOURCE_DMA,
499 static struct platform_device bfin_sir1_device = {
502 .num_resources = ARRAY_SIZE(bfin_sir1_resources),
503 .resource = bfin_sir1_resources,
508 static struct platform_device *stamp_devices[] __initdata = {
509 #if defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE)
510 &bfin_pcmcia_cf_device,
513 #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
517 #if defined(CONFIG_USB_SL811_HCD) || defined(CONFIG_USB_SL811_HCD_MODULE)
521 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
525 #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
530 #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
531 &net2272_bfin_device,
534 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
538 #if defined(CONFIG_FB_BF537_LQ035) || defined(CONFIG_FB_BF537_LQ035_MODULE)
542 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
543 #ifdef CONFIG_SERIAL_BFIN_UART0
546 #ifdef CONFIG_SERIAL_BFIN_UART1
551 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
552 #ifdef CONFIG_BFIN_SIR0
555 #ifdef CONFIG_BFIN_SIR1
561 static int __init pnav_init(void)
563 printk(KERN_INFO "%s(): registering device resources\n", __func__);
564 platform_add_devices(stamp_devices, ARRAY_SIZE(stamp_devices));
565 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
566 spi_register_board_info(bfin_spi_board_info,
567 ARRAY_SIZE(bfin_spi_board_info));
572 arch_initcall(pnav_init);
574 void bfin_get_ether_addr(char *addr)
576 random_ether_addr(addr);
577 printk(KERN_WARNING "%s:%s: Setting Ethernet MAC to a random one\n", __FILE__, __func__);
579 EXPORT_SYMBOL(bfin_get_ether_addr);