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>
21 #include <linux/spi/ad7877.h>
24 * Name the Board for the /proc/cpuinfo
26 const char bfin_board_name[] = "ADI PNAV-1.0";
29 * Driver needs to know address, irq and flag pin.
32 #if defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE)
33 static struct resource bfin_pcmcia_cf_resources[] = {
35 .start = 0x20310000, /* IO PORT */
37 .flags = IORESOURCE_MEM,
39 .start = 0x20311000, /* Attribute Memory */
41 .flags = IORESOURCE_MEM,
45 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
47 .start = 6, /* Card Detect PF6 */
49 .flags = IORESOURCE_IRQ,
53 static struct platform_device bfin_pcmcia_cf_device = {
54 .name = "bfin_cf_pcmcia",
56 .num_resources = ARRAY_SIZE(bfin_pcmcia_cf_resources),
57 .resource = bfin_pcmcia_cf_resources,
61 #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
62 static struct platform_device rtc_device = {
68 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
69 #include <linux/smc91x.h>
71 static struct smc91x_platdata smc91x_info = {
72 .flags = SMC91X_USE_16BIT | SMC91X_NOWAIT,
73 .leda = RPC_LED_100_10,
74 .ledb = RPC_LED_TX_RX,
77 static struct resource smc91x_resources[] = {
79 .name = "smc91x-regs",
81 .end = 0x20300300 + 16,
82 .flags = IORESOURCE_MEM,
87 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
90 static struct platform_device smc91x_device = {
93 .num_resources = ARRAY_SIZE(smc91x_resources),
94 .resource = smc91x_resources,
96 .platform_data = &smc91x_info,
101 #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
102 static struct platform_device bfin_mii_bus = {
103 .name = "bfin_mii_bus",
106 static struct platform_device bfin_mac_device = {
108 .dev.platform_data = &bfin_mii_bus,
112 #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
113 static struct resource net2272_bfin_resources[] = {
116 .end = 0x20300000 + 0x100,
117 .flags = IORESOURCE_MEM,
121 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
125 static struct platform_device net2272_bfin_device = {
128 .num_resources = ARRAY_SIZE(net2272_bfin_resources),
129 .resource = net2272_bfin_resources,
133 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
134 /* all SPI peripherals info goes here */
136 #if defined(CONFIG_MTD_M25P80) \
137 || defined(CONFIG_MTD_M25P80_MODULE)
138 static struct mtd_partition bfin_spi_flash_partitions[] = {
140 .name = "bootloader(spi)",
143 .mask_flags = MTD_CAP_ROM
145 .name = "linux kernel(spi)",
149 .name = "file system(spi)",
151 .offset = 0x00100000,
155 static struct flash_platform_data bfin_spi_flash_data = {
157 .parts = bfin_spi_flash_partitions,
158 .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
162 /* SPI flash chip (m25p64) */
163 static struct bfin5xx_spi_chip spi_flash_chip_info = {
164 .enable_dma = 0, /* use dma transfer with this chip*/
169 #if defined(CONFIG_BFIN_SPI_ADC) \
170 || defined(CONFIG_BFIN_SPI_ADC_MODULE)
172 static struct bfin5xx_spi_chip spi_adc_chip_info = {
173 .enable_dma = 1, /* use dma transfer with this chip*/
178 #if defined(CONFIG_SND_BF5XX_SOC_AD183X) \
179 || defined(CONFIG_SND_BF5XX_SOC_AD183X_MODULE)
180 static struct bfin5xx_spi_chip ad1836_spi_chip_info = {
186 #if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
187 static struct bfin5xx_spi_chip mmc_spi_chip_info = {
193 #if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
194 static struct bfin5xx_spi_chip spi_ad7877_chip_info = {
199 static const struct ad7877_platform_data bfin_ad7877_ts_info = {
201 .vref_delay_usecs = 50, /* internal, no capacitor */
204 .pressure_max = 1000,
206 .stopacq_polarity = 1,
207 .first_conversion_delay = 3,
208 .acquisition_time = 1,
210 .pen_down_acc_interval = 1,
214 static struct spi_board_info bfin_spi_board_info[] __initdata = {
215 #if defined(CONFIG_MTD_M25P80) \
216 || defined(CONFIG_MTD_M25P80_MODULE)
218 /* the modalias must be the same as spi device driver name */
219 .modalias = "m25p80", /* Name of spi_driver for this device */
220 .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
221 .bus_num = 0, /* Framework bus number */
222 .chip_select = 1, /* Framework chip select. On STAMP537 it is SPISSEL1*/
223 .platform_data = &bfin_spi_flash_data,
224 .controller_data = &spi_flash_chip_info,
229 #if defined(CONFIG_BFIN_SPI_ADC) \
230 || defined(CONFIG_BFIN_SPI_ADC_MODULE)
232 .modalias = "bfin_spi_adc", /* Name of spi_driver for this device */
233 .max_speed_hz = 6250000, /* max spi clock (SCK) speed in HZ */
234 .bus_num = 0, /* Framework bus number */
235 .chip_select = 1, /* Framework chip select. */
236 .platform_data = NULL, /* No spi_driver specific config */
237 .controller_data = &spi_adc_chip_info,
241 #if defined(CONFIG_SND_BF5XX_SOC_AD183X) \
242 || defined(CONFIG_SND_BF5XX_SOC_AD183X_MODULE)
244 .modalias = "ad183x",
245 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
248 .controller_data = &ad1836_spi_chip_info,
251 #if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
253 .modalias = "mmc_spi",
254 .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
257 .controller_data = &mmc_spi_chip_info,
261 #if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
263 .modalias = "ad7877",
264 .platform_data = &bfin_ad7877_ts_info,
266 .max_speed_hz = 12500000, /* max spi clock (SCK) speed in HZ */
269 .controller_data = &spi_ad7877_chip_info,
276 static struct resource bfin_spi0_resource[] = {
278 .start = SPI0_REGBASE,
279 .end = SPI0_REGBASE + 0xFF,
280 .flags = IORESOURCE_MEM,
285 .flags = IORESOURCE_DMA,
290 .flags = IORESOURCE_IRQ,
294 /* SPI controller data */
295 static struct bfin5xx_spi_master bfin_spi0_info = {
297 .enable_dma = 1, /* master has the ability to do dma transfer */
298 .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
301 static struct platform_device bfin_spi0_device = {
303 .id = 0, /* Bus number */
304 .num_resources = ARRAY_SIZE(bfin_spi0_resource),
305 .resource = bfin_spi0_resource,
307 .platform_data = &bfin_spi0_info, /* Passed to driver */
310 #endif /* spi master and devices */
312 #if defined(CONFIG_FB_BF537_LQ035) || defined(CONFIG_FB_BF537_LQ035_MODULE)
313 static struct platform_device bfin_fb_device = {
314 .name = "bf537-lq035",
318 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
319 #ifdef CONFIG_SERIAL_BFIN_UART0
320 static struct resource bfin_uart0_resources[] = {
324 .flags = IORESOURCE_MEM,
327 .start = IRQ_UART0_RX,
328 .end = IRQ_UART0_RX+1,
329 .flags = IORESOURCE_IRQ,
332 .start = IRQ_UART0_ERROR,
333 .end = IRQ_UART0_ERROR,
334 .flags = IORESOURCE_IRQ,
337 .start = CH_UART0_TX,
339 .flags = IORESOURCE_DMA,
342 .start = CH_UART0_RX,
344 .flags = IORESOURCE_DMA,
348 unsigned short bfin_uart0_peripherals[] = {
349 P_UART0_TX, P_UART0_RX, 0
352 static struct platform_device bfin_uart0_device = {
355 .num_resources = ARRAY_SIZE(bfin_uart0_resources),
356 .resource = bfin_uart0_resources,
358 .platform_data = &bfin_uart0_peripherals, /* Passed to driver */
362 #ifdef CONFIG_SERIAL_BFIN_UART1
363 static struct resource bfin_uart1_resources[] = {
367 .flags = IORESOURCE_MEM,
370 .start = IRQ_UART1_RX,
371 .end = IRQ_UART1_RX+1,
372 .flags = IORESOURCE_IRQ,
375 .start = IRQ_UART1_ERROR,
376 .end = IRQ_UART1_ERROR,
377 .flags = IORESOURCE_IRQ,
380 .start = CH_UART1_TX,
382 .flags = IORESOURCE_DMA,
385 .start = CH_UART1_RX,
387 .flags = IORESOURCE_DMA,
391 unsigned short bfin_uart1_peripherals[] = {
392 P_UART1_TX, P_UART1_RX, 0
395 static struct platform_device bfin_uart1_device = {
398 .num_resources = ARRAY_SIZE(bfin_uart1_resources),
399 .resource = bfin_uart1_resources,
401 .platform_data = &bfin_uart1_peripherals, /* Passed to driver */
407 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
408 #ifdef CONFIG_BFIN_SIR0
409 static struct resource bfin_sir0_resources[] = {
413 .flags = IORESOURCE_MEM,
416 .start = IRQ_UART0_RX,
417 .end = IRQ_UART0_RX+1,
418 .flags = IORESOURCE_IRQ,
421 .start = CH_UART0_RX,
422 .end = CH_UART0_RX+1,
423 .flags = IORESOURCE_DMA,
427 static struct platform_device bfin_sir0_device = {
430 .num_resources = ARRAY_SIZE(bfin_sir0_resources),
431 .resource = bfin_sir0_resources,
434 #ifdef CONFIG_BFIN_SIR1
435 static struct resource bfin_sir1_resources[] = {
439 .flags = IORESOURCE_MEM,
442 .start = IRQ_UART1_RX,
443 .end = IRQ_UART1_RX+1,
444 .flags = IORESOURCE_IRQ,
447 .start = CH_UART1_RX,
448 .end = CH_UART1_RX+1,
449 .flags = IORESOURCE_DMA,
453 static struct platform_device bfin_sir1_device = {
456 .num_resources = ARRAY_SIZE(bfin_sir1_resources),
457 .resource = bfin_sir1_resources,
462 static struct platform_device *stamp_devices[] __initdata = {
463 #if defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE)
464 &bfin_pcmcia_cf_device,
467 #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
471 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
475 #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
480 #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
481 &net2272_bfin_device,
484 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
488 #if defined(CONFIG_FB_BF537_LQ035) || defined(CONFIG_FB_BF537_LQ035_MODULE)
492 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
493 #ifdef CONFIG_SERIAL_BFIN_UART0
496 #ifdef CONFIG_SERIAL_BFIN_UART1
501 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
502 #ifdef CONFIG_BFIN_SIR0
505 #ifdef CONFIG_BFIN_SIR1
511 static int __init pnav_init(void)
513 printk(KERN_INFO "%s(): registering device resources\n", __func__);
514 platform_add_devices(stamp_devices, ARRAY_SIZE(stamp_devices));
515 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
516 spi_register_board_info(bfin_spi_board_info,
517 ARRAY_SIZE(bfin_spi_board_info));
522 arch_initcall(pnav_init);
524 static struct platform_device *stamp_early_devices[] __initdata = {
525 #if defined(CONFIG_SERIAL_BFIN_CONSOLE) || defined(CONFIG_EARLY_PRINTK)
526 #ifdef CONFIG_SERIAL_BFIN_UART0
529 #ifdef CONFIG_SERIAL_BFIN_UART1
535 void __init native_machine_early_platform_add_devices(void)
537 printk(KERN_INFO "register early platform devices\n");
538 early_platform_add_devices(stamp_early_devices,
539 ARRAY_SIZE(stamp_early_devices));
542 void bfin_get_ether_addr(char *addr)
544 random_ether_addr(addr);
545 printk(KERN_WARNING "%s:%s: Setting Ethernet MAC to a random one\n", __FILE__, __func__);
547 EXPORT_SYMBOL(bfin_get_ether_addr);