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 #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
17 #include <linux/usb/isp1362.h>
19 #include <linux/irq.h>
21 #include <asm/bfin5xx_spi.h>
22 #include <asm/portmux.h>
23 #include <linux/usb/sl811.h>
25 #include <linux/spi/ad7877.h>
28 * Name the Board for the /proc/cpuinfo
30 const char bfin_board_name[] = "ADI PNAV-1.0";
33 * Driver needs to know address, irq and flag pin.
36 #if defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE)
37 static struct resource bfin_pcmcia_cf_resources[] = {
39 .start = 0x20310000, /* IO PORT */
41 .flags = IORESOURCE_MEM,
43 .start = 0x20311000, /* Attribute Memory */
45 .flags = IORESOURCE_MEM,
49 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
51 .start = 6, /* Card Detect PF6 */
53 .flags = IORESOURCE_IRQ,
57 static struct platform_device bfin_pcmcia_cf_device = {
58 .name = "bfin_cf_pcmcia",
60 .num_resources = ARRAY_SIZE(bfin_pcmcia_cf_resources),
61 .resource = bfin_pcmcia_cf_resources,
65 #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
66 static struct platform_device rtc_device = {
72 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
73 #include <linux/smc91x.h>
75 static struct smc91x_platdata smc91x_info = {
76 .flags = SMC91X_USE_16BIT | SMC91X_NOWAIT,
77 .leda = RPC_LED_100_10,
78 .ledb = RPC_LED_TX_RX,
81 static struct resource smc91x_resources[] = {
83 .name = "smc91x-regs",
85 .end = 0x20300300 + 16,
86 .flags = IORESOURCE_MEM,
91 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
94 static struct platform_device smc91x_device = {
97 .num_resources = ARRAY_SIZE(smc91x_resources),
98 .resource = smc91x_resources,
100 .platform_data = &smc91x_info,
105 #if defined(CONFIG_USB_SL811_HCD) || defined(CONFIG_USB_SL811_HCD_MODULE)
106 static struct resource sl811_hcd_resources[] = {
110 .flags = IORESOURCE_MEM,
114 .flags = IORESOURCE_MEM,
116 .start = CONFIG_USB_SL811_BFIN_IRQ,
117 .end = CONFIG_USB_SL811_BFIN_IRQ,
118 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
122 #if defined(CONFIG_USB_SL811_BFIN_USE_VBUS)
123 void sl811_port_power(struct device *dev, int is_on)
125 gpio_request(CONFIG_USB_SL811_BFIN_GPIO_VBUS, "usb:SL811_VBUS");
126 gpio_direction_output(CONFIG_USB_SL811_BFIN_GPIO_VBUS, is_on);
131 static struct sl811_platform_data sl811_priv = {
133 .power = 250, /* == 500mA */
134 #if defined(CONFIG_USB_SL811_BFIN_USE_VBUS)
135 .port_power = &sl811_port_power,
139 static struct platform_device sl811_hcd_device = {
143 .platform_data = &sl811_priv,
145 .num_resources = ARRAY_SIZE(sl811_hcd_resources),
146 .resource = sl811_hcd_resources,
150 #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
151 static struct resource isp1362_hcd_resources[] = {
155 .flags = IORESOURCE_MEM,
159 .flags = IORESOURCE_MEM,
161 .start = CONFIG_USB_ISP1362_BFIN_GPIO_IRQ,
162 .end = CONFIG_USB_ISP1362_BFIN_GPIO_IRQ,
163 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
167 static struct isp1362_platform_data isp1362_priv = {
172 .int_edge_triggered = 0,
173 .remote_wakeup_connected = 0,
174 .no_power_switching = 1,
175 .power_switching_mode = 0,
178 static struct platform_device isp1362_hcd_device = {
179 .name = "isp1362-hcd",
182 .platform_data = &isp1362_priv,
184 .num_resources = ARRAY_SIZE(isp1362_hcd_resources),
185 .resource = isp1362_hcd_resources,
189 #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
190 static struct platform_device bfin_mii_bus = {
191 .name = "bfin_mii_bus",
194 static struct platform_device bfin_mac_device = {
196 .dev.platform_data = &bfin_mii_bus,
200 #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
201 static struct resource net2272_bfin_resources[] = {
204 .end = 0x20300000 + 0x100,
205 .flags = IORESOURCE_MEM,
209 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
213 static struct platform_device net2272_bfin_device = {
216 .num_resources = ARRAY_SIZE(net2272_bfin_resources),
217 .resource = net2272_bfin_resources,
221 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
222 /* all SPI peripherals info goes here */
224 #if defined(CONFIG_MTD_M25P80) \
225 || defined(CONFIG_MTD_M25P80_MODULE)
226 static struct mtd_partition bfin_spi_flash_partitions[] = {
228 .name = "bootloader(spi)",
231 .mask_flags = MTD_CAP_ROM
233 .name = "linux kernel(spi)",
237 .name = "file system(spi)",
239 .offset = 0x00100000,
243 static struct flash_platform_data bfin_spi_flash_data = {
245 .parts = bfin_spi_flash_partitions,
246 .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
250 /* SPI flash chip (m25p64) */
251 static struct bfin5xx_spi_chip spi_flash_chip_info = {
252 .enable_dma = 0, /* use dma transfer with this chip*/
257 #if defined(CONFIG_BFIN_SPI_ADC) \
258 || defined(CONFIG_BFIN_SPI_ADC_MODULE)
260 static struct bfin5xx_spi_chip spi_adc_chip_info = {
261 .enable_dma = 1, /* use dma transfer with this chip*/
266 #if defined(CONFIG_SND_BLACKFIN_AD1836) \
267 || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
268 static struct bfin5xx_spi_chip ad1836_spi_chip_info = {
274 #if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
275 static struct bfin5xx_spi_chip mmc_spi_chip_info = {
281 #if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
282 static struct bfin5xx_spi_chip spi_ad7877_chip_info = {
287 static const struct ad7877_platform_data bfin_ad7877_ts_info = {
289 .vref_delay_usecs = 50, /* internal, no capacitor */
292 .pressure_max = 1000,
294 .stopacq_polarity = 1,
295 .first_conversion_delay = 3,
296 .acquisition_time = 1,
298 .pen_down_acc_interval = 1,
302 static struct spi_board_info bfin_spi_board_info[] __initdata = {
303 #if defined(CONFIG_MTD_M25P80) \
304 || defined(CONFIG_MTD_M25P80_MODULE)
306 /* the modalias must be the same as spi device driver name */
307 .modalias = "m25p80", /* Name of spi_driver for this device */
308 .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
309 .bus_num = 0, /* Framework bus number */
310 .chip_select = 1, /* Framework chip select. On STAMP537 it is SPISSEL1*/
311 .platform_data = &bfin_spi_flash_data,
312 .controller_data = &spi_flash_chip_info,
317 #if defined(CONFIG_BFIN_SPI_ADC) \
318 || defined(CONFIG_BFIN_SPI_ADC_MODULE)
320 .modalias = "bfin_spi_adc", /* Name of spi_driver for this device */
321 .max_speed_hz = 6250000, /* max spi clock (SCK) speed in HZ */
322 .bus_num = 0, /* Framework bus number */
323 .chip_select = 1, /* Framework chip select. */
324 .platform_data = NULL, /* No spi_driver specific config */
325 .controller_data = &spi_adc_chip_info,
329 #if defined(CONFIG_SND_BLACKFIN_AD1836) \
330 || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
332 .modalias = "ad1836",
333 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
335 .chip_select = CONFIG_SND_BLACKFIN_SPI_PFBIT,
336 .controller_data = &ad1836_spi_chip_info,
339 #if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
341 .modalias = "mmc_spi",
342 .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
345 .controller_data = &mmc_spi_chip_info,
349 #if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
351 .modalias = "ad7877",
352 .platform_data = &bfin_ad7877_ts_info,
354 .max_speed_hz = 12500000, /* max spi clock (SCK) speed in HZ */
357 .controller_data = &spi_ad7877_chip_info,
364 static struct resource bfin_spi0_resource[] = {
366 .start = SPI0_REGBASE,
367 .end = SPI0_REGBASE + 0xFF,
368 .flags = IORESOURCE_MEM,
373 .flags = IORESOURCE_DMA,
378 .flags = IORESOURCE_IRQ,
382 /* SPI controller data */
383 static struct bfin5xx_spi_master bfin_spi0_info = {
385 .enable_dma = 1, /* master has the ability to do dma transfer */
386 .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
389 static struct platform_device bfin_spi0_device = {
391 .id = 0, /* Bus number */
392 .num_resources = ARRAY_SIZE(bfin_spi0_resource),
393 .resource = bfin_spi0_resource,
395 .platform_data = &bfin_spi0_info, /* Passed to driver */
398 #endif /* spi master and devices */
400 #if defined(CONFIG_FB_BF537_LQ035) || defined(CONFIG_FB_BF537_LQ035_MODULE)
401 static struct platform_device bfin_fb_device = {
402 .name = "bf537-lq035",
406 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
407 static struct resource bfin_uart_resources[] = {
411 .flags = IORESOURCE_MEM,
415 .flags = IORESOURCE_MEM,
419 static struct platform_device bfin_uart_device = {
422 .num_resources = ARRAY_SIZE(bfin_uart_resources),
423 .resource = bfin_uart_resources,
427 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
428 #ifdef CONFIG_BFIN_SIR0
429 static struct resource bfin_sir0_resources[] = {
433 .flags = IORESOURCE_MEM,
436 .start = IRQ_UART0_RX,
437 .end = IRQ_UART0_RX+1,
438 .flags = IORESOURCE_IRQ,
441 .start = CH_UART0_RX,
442 .end = CH_UART0_RX+1,
443 .flags = IORESOURCE_DMA,
447 static struct platform_device bfin_sir0_device = {
450 .num_resources = ARRAY_SIZE(bfin_sir0_resources),
451 .resource = bfin_sir0_resources,
454 #ifdef CONFIG_BFIN_SIR1
455 static struct resource bfin_sir1_resources[] = {
459 .flags = IORESOURCE_MEM,
462 .start = IRQ_UART1_RX,
463 .end = IRQ_UART1_RX+1,
464 .flags = IORESOURCE_IRQ,
467 .start = CH_UART1_RX,
468 .end = CH_UART1_RX+1,
469 .flags = IORESOURCE_DMA,
473 static struct platform_device bfin_sir1_device = {
476 .num_resources = ARRAY_SIZE(bfin_sir1_resources),
477 .resource = bfin_sir1_resources,
482 static struct platform_device *stamp_devices[] __initdata = {
483 #if defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE)
484 &bfin_pcmcia_cf_device,
487 #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
491 #if defined(CONFIG_USB_SL811_HCD) || defined(CONFIG_USB_SL811_HCD_MODULE)
495 #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
499 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
503 #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
508 #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
509 &net2272_bfin_device,
512 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
516 #if defined(CONFIG_FB_BF537_LQ035) || defined(CONFIG_FB_BF537_LQ035_MODULE)
520 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
524 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
525 #ifdef CONFIG_BFIN_SIR0
528 #ifdef CONFIG_BFIN_SIR1
534 static int __init pnav_init(void)
536 printk(KERN_INFO "%s(): registering device resources\n", __func__);
537 platform_add_devices(stamp_devices, ARRAY_SIZE(stamp_devices));
538 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
539 spi_register_board_info(bfin_spi_board_info,
540 ARRAY_SIZE(bfin_spi_board_info));
545 arch_initcall(pnav_init);
547 void bfin_get_ether_addr(char *addr)
549 random_ether_addr(addr);
550 printk(KERN_WARNING "%s:%s: Setting Ethernet MAC to a random one\n", __FILE__, __func__);
552 EXPORT_SYMBOL(bfin_get_ether_addr);