2 * Copyright 2004-2009 Analog Devices Inc.
3 * 2008-2009 Bluetechnix
4 * 2005 National ICT Australia (NICTA)
5 * Aidan Williams <aidan@nicta.com.au>
7 * Licensed under the GPL-2 or later.
10 #include <linux/device.h>
11 #include <linux/platform_device.h>
12 #include <linux/mtd/mtd.h>
13 #include <linux/mtd/partitions.h>
14 #include <linux/mtd/physmap.h>
15 #include <linux/spi/spi.h>
16 #include <linux/spi/flash.h>
17 #include <linux/irq.h>
18 #include <linux/interrupt.h>
19 #include <linux/usb/musb.h>
20 #include <asm/bfin5xx_spi.h>
24 #include <asm/portmux.h>
25 #include <asm/bfin_sdh.h>
26 #include <mach/bf54x_keys.h>
28 #include <linux/input.h>
29 #include <linux/spi/ad7877.h>
32 * Name the Board for the /proc/cpuinfo
34 const char bfin_board_name[] = "Bluetechnix CM-BF548";
37 * Driver needs to know address, irq and flag pin.
40 #if defined(CONFIG_FB_BF54X_LQ043) || defined(CONFIG_FB_BF54X_LQ043_MODULE)
42 #include <mach/bf54x-lq043.h>
44 static struct bfin_bf54xfb_mach_info bf54x_lq043_data = {
47 .xres = {480, 480, 480},
48 .yres = {272, 272, 272},
53 static struct resource bf54x_lq043_resources[] = {
55 .start = IRQ_EPPI0_ERR,
57 .flags = IORESOURCE_IRQ,
61 static struct platform_device bf54x_lq043_device = {
62 .name = "bf54x-lq043",
64 .num_resources = ARRAY_SIZE(bf54x_lq043_resources),
65 .resource = bf54x_lq043_resources,
67 .platform_data = &bf54x_lq043_data,
72 #if defined(CONFIG_KEYBOARD_BFIN) || defined(CONFIG_KEYBOARD_BFIN_MODULE)
73 static unsigned int bf548_keymap[] = {
74 KEYVAL(0, 0, KEY_ENTER),
75 KEYVAL(0, 1, KEY_HELP),
77 KEYVAL(0, 3, KEY_BACKSPACE),
78 KEYVAL(1, 0, KEY_TAB),
82 KEYVAL(2, 0, KEY_DOWN),
92 static struct bfin_kpad_platform_data bf54x_kpad_data = {
95 .keymap = bf548_keymap,
96 .keymapsize = ARRAY_SIZE(bf548_keymap),
98 .debounce_time = 5000, /* ns (5ms) */
99 .coldrive_time = 1000, /* ns (1ms) */
100 .keyup_test_interval = 50, /* ms (50ms) */
103 static struct resource bf54x_kpad_resources[] = {
107 .flags = IORESOURCE_IRQ,
111 static struct platform_device bf54x_kpad_device = {
112 .name = "bf54x-keys",
114 .num_resources = ARRAY_SIZE(bf54x_kpad_resources),
115 .resource = bf54x_kpad_resources,
117 .platform_data = &bf54x_kpad_data,
122 #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
123 static struct platform_device rtc_device = {
129 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
130 static struct resource bfin_uart_resources[] = {
131 #ifdef CONFIG_SERIAL_BFIN_UART0
135 .flags = IORESOURCE_MEM,
138 #ifdef CONFIG_SERIAL_BFIN_UART1
142 .flags = IORESOURCE_MEM,
145 #ifdef CONFIG_SERIAL_BFIN_UART2
149 .flags = IORESOURCE_MEM,
152 #ifdef CONFIG_SERIAL_BFIN_UART3
156 .flags = IORESOURCE_MEM,
161 static struct platform_device bfin_uart_device = {
164 .num_resources = ARRAY_SIZE(bfin_uart_resources),
165 .resource = bfin_uart_resources,
169 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
170 #ifdef CONFIG_BFIN_SIR0
171 static struct resource bfin_sir0_resources[] = {
175 .flags = IORESOURCE_MEM,
178 .start = IRQ_UART0_RX,
179 .end = IRQ_UART0_RX+1,
180 .flags = IORESOURCE_IRQ,
183 .start = CH_UART0_RX,
184 .end = CH_UART0_RX+1,
185 .flags = IORESOURCE_DMA,
188 static struct platform_device bfin_sir0_device = {
191 .num_resources = ARRAY_SIZE(bfin_sir0_resources),
192 .resource = bfin_sir0_resources,
195 #ifdef CONFIG_BFIN_SIR1
196 static struct resource bfin_sir1_resources[] = {
200 .flags = IORESOURCE_MEM,
203 .start = IRQ_UART1_RX,
204 .end = IRQ_UART1_RX+1,
205 .flags = IORESOURCE_IRQ,
208 .start = CH_UART1_RX,
209 .end = CH_UART1_RX+1,
210 .flags = IORESOURCE_DMA,
213 static struct platform_device bfin_sir1_device = {
216 .num_resources = ARRAY_SIZE(bfin_sir1_resources),
217 .resource = bfin_sir1_resources,
220 #ifdef CONFIG_BFIN_SIR2
221 static struct resource bfin_sir2_resources[] = {
225 .flags = IORESOURCE_MEM,
228 .start = IRQ_UART2_RX,
229 .end = IRQ_UART2_RX+1,
230 .flags = IORESOURCE_IRQ,
233 .start = CH_UART2_RX,
234 .end = CH_UART2_RX+1,
235 .flags = IORESOURCE_DMA,
238 static struct platform_device bfin_sir2_device = {
241 .num_resources = ARRAY_SIZE(bfin_sir2_resources),
242 .resource = bfin_sir2_resources,
245 #ifdef CONFIG_BFIN_SIR3
246 static struct resource bfin_sir3_resources[] = {
250 .flags = IORESOURCE_MEM,
253 .start = IRQ_UART3_RX,
254 .end = IRQ_UART3_RX+1,
255 .flags = IORESOURCE_IRQ,
258 .start = CH_UART3_RX,
259 .end = CH_UART3_RX+1,
260 .flags = IORESOURCE_DMA,
263 static struct platform_device bfin_sir3_device = {
266 .num_resources = ARRAY_SIZE(bfin_sir3_resources),
267 .resource = bfin_sir3_resources,
272 #if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE)
273 #include <linux/smsc911x.h>
275 static struct resource smsc911x_resources[] = {
277 .name = "smsc911x-memory",
279 .end = 0x24000000 + 0xFF,
280 .flags = IORESOURCE_MEM,
285 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
289 static struct smsc911x_platform_config smsc911x_config = {
290 .flags = SMSC911X_USE_16BIT,
291 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
292 .irq_type = SMSC911X_IRQ_TYPE_OPEN_DRAIN,
293 .phy_interface = PHY_INTERFACE_MODE_MII,
296 static struct platform_device smsc911x_device = {
299 .num_resources = ARRAY_SIZE(smsc911x_resources),
300 .resource = smsc911x_resources,
302 .platform_data = &smsc911x_config,
307 #if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE)
308 static struct resource musb_resources[] = {
312 .flags = IORESOURCE_MEM,
314 [1] = { /* general IRQ */
315 .start = IRQ_USB_INT0,
317 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
319 [2] = { /* DMA IRQ */
320 .start = IRQ_USB_DMA,
322 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
326 static struct musb_hdrc_config musb_config = {
333 .gpio_vrsel = GPIO_PH6,
336 static struct musb_hdrc_platform_data musb_plat = {
337 #if defined(CONFIG_USB_MUSB_OTG)
339 #elif defined(CONFIG_USB_MUSB_HDRC_HCD)
341 #elif defined(CONFIG_USB_GADGET_MUSB_HDRC)
342 .mode = MUSB_PERIPHERAL,
344 .config = &musb_config,
347 static u64 musb_dmamask = ~(u32)0;
349 static struct platform_device musb_device = {
353 .dma_mask = &musb_dmamask,
354 .coherent_dma_mask = 0xffffffff,
355 .platform_data = &musb_plat,
357 .num_resources = ARRAY_SIZE(musb_resources),
358 .resource = musb_resources,
362 static struct resource bfin_gpios_resources = {
364 .end = MAX_BLACKFIN_GPIOS - 1,
365 .flags = IORESOURCE_IRQ,
368 static struct platform_device bfin_gpios_device = {
369 .name = "simple-gpio",
372 .resource = &bfin_gpios_resources,
375 #if defined(CONFIG_PATA_BF54X) || defined(CONFIG_PATA_BF54X_MODULE)
376 static struct resource bfin_atapi_resources[] = {
380 .flags = IORESOURCE_MEM,
383 .start = IRQ_ATAPI_ERR,
384 .end = IRQ_ATAPI_ERR,
385 .flags = IORESOURCE_IRQ,
389 static struct platform_device bfin_atapi_device = {
390 .name = "pata-bf54x",
392 .num_resources = ARRAY_SIZE(bfin_atapi_resources),
393 .resource = bfin_atapi_resources,
397 #if defined(CONFIG_MTD_NAND_BF5XX) || defined(CONFIG_MTD_NAND_BF5XX_MODULE)
398 static struct mtd_partition partition_info[] = {
400 .name = "linux kernel(nand)",
402 .size = 4 * 1024 * 1024,
405 .name = "file system(nand)",
406 .offset = 4 * 1024 * 1024,
407 .size = (256 - 4) * 1024 * 1024,
411 static struct bf5xx_nand_platform bf5xx_nand_platform = {
412 .page_size = NFC_PG_SIZE_256,
413 .data_width = NFC_NWIDTH_8,
414 .partitions = partition_info,
415 .nr_partitions = ARRAY_SIZE(partition_info),
420 static struct resource bf5xx_nand_resources[] = {
424 .flags = IORESOURCE_MEM,
429 .flags = IORESOURCE_IRQ,
433 static struct platform_device bf5xx_nand_device = {
434 .name = "bf5xx-nand",
436 .num_resources = ARRAY_SIZE(bf5xx_nand_resources),
437 .resource = bf5xx_nand_resources,
439 .platform_data = &bf5xx_nand_platform,
444 #if defined(CONFIG_SDH_BFIN) || defined(CONFIG_SDH_BFIN_MODULE)
445 static struct bfin_sd_host bfin_sdh_data = {
447 .irq_int0 = IRQ_SDH_MASK0,
448 .pin_req = {P_SD_D0, P_SD_D1, P_SD_D2, P_SD_D3, P_SD_CLK, P_SD_CMD, 0},
451 static struct platform_device bf54x_sdh_device = {
455 .platform_data = &bfin_sdh_data,
460 #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
461 static struct mtd_partition para_partitions[] = {
463 .name = "bootloader(nor)",
467 .name = "linux kernel(nor)",
469 .offset = MTDPART_OFS_APPEND,
471 .name = "file system(nor)",
472 .size = MTDPART_SIZ_FULL,
473 .offset = MTDPART_OFS_APPEND,
477 static struct physmap_flash_data para_flash_data = {
479 .parts = para_partitions,
480 .nr_parts = ARRAY_SIZE(para_partitions),
483 static struct resource para_flash_resource = {
486 .flags = IORESOURCE_MEM,
489 static struct platform_device para_flash_device = {
490 .name = "physmap-flash",
493 .platform_data = ¶_flash_data,
496 .resource = ¶_flash_resource,
500 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
501 /* all SPI peripherals info goes here */
502 #if defined(CONFIG_MTD_M25P80) \
503 || defined(CONFIG_MTD_M25P80_MODULE)
504 /* SPI flash chip (m25p16) */
505 static struct mtd_partition bfin_spi_flash_partitions[] = {
507 .name = "bootloader(spi)",
510 .mask_flags = MTD_CAP_ROM
512 .name = "linux kernel(spi)",
518 static struct flash_platform_data bfin_spi_flash_data = {
520 .parts = bfin_spi_flash_partitions,
521 .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
525 static struct bfin5xx_spi_chip spi_flash_chip_info = {
526 .enable_dma = 0, /* use dma transfer with this chip*/
531 #if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
532 static struct bfin5xx_spi_chip spi_ad7877_chip_info = {
537 static const struct ad7877_platform_data bfin_ad7877_ts_info = {
539 .vref_delay_usecs = 50, /* internal, no capacitor */
542 .pressure_max = 1000,
544 .stopacq_polarity = 1,
545 .first_conversion_delay = 3,
546 .acquisition_time = 1,
548 .pen_down_acc_interval = 1,
552 #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
553 static struct bfin5xx_spi_chip spidev_chip_info = {
559 static struct spi_board_info bf54x_spi_board_info[] __initdata = {
560 #if defined(CONFIG_MTD_M25P80) \
561 || defined(CONFIG_MTD_M25P80_MODULE)
563 /* the modalias must be the same as spi device driver name */
564 .modalias = "m25p80", /* Name of spi_driver for this device */
565 .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
566 .bus_num = 0, /* Framework bus number */
567 .chip_select = 1, /* SPI_SSEL1*/
568 .platform_data = &bfin_spi_flash_data,
569 .controller_data = &spi_flash_chip_info,
573 #if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
575 .modalias = "ad7877",
576 .platform_data = &bfin_ad7877_ts_info,
578 .max_speed_hz = 12500000, /* max spi clock (SCK) speed in HZ */
581 .controller_data = &spi_ad7877_chip_info,
584 #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
586 .modalias = "spidev",
587 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
590 .controller_data = &spidev_chip_info,
596 static struct resource bfin_spi0_resource[] = {
598 .start = SPI0_REGBASE,
599 .end = SPI0_REGBASE + 0xFF,
600 .flags = IORESOURCE_MEM,
605 .flags = IORESOURCE_DMA,
610 .flags = IORESOURCE_IRQ,
615 static struct resource bfin_spi1_resource[] = {
617 .start = SPI1_REGBASE,
618 .end = SPI1_REGBASE + 0xFF,
619 .flags = IORESOURCE_MEM,
624 .flags = IORESOURCE_DMA,
629 .flags = IORESOURCE_IRQ,
633 /* SPI controller data */
634 static struct bfin5xx_spi_master bf54x_spi_master_info0 = {
636 .enable_dma = 1, /* master has the ability to do dma transfer */
637 .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
640 static struct platform_device bf54x_spi_master0 = {
642 .id = 0, /* Bus number */
643 .num_resources = ARRAY_SIZE(bfin_spi0_resource),
644 .resource = bfin_spi0_resource,
646 .platform_data = &bf54x_spi_master_info0, /* Passed to driver */
650 static struct bfin5xx_spi_master bf54x_spi_master_info1 = {
652 .enable_dma = 1, /* master has the ability to do dma transfer */
653 .pin_req = {P_SPI1_SCK, P_SPI1_MISO, P_SPI1_MOSI, 0},
656 static struct platform_device bf54x_spi_master1 = {
658 .id = 1, /* Bus number */
659 .num_resources = ARRAY_SIZE(bfin_spi1_resource),
660 .resource = bfin_spi1_resource,
662 .platform_data = &bf54x_spi_master_info1, /* Passed to driver */
665 #endif /* spi master and devices */
667 #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
668 static struct resource bfin_twi0_resource[] = {
670 .start = TWI0_REGBASE,
671 .end = TWI0_REGBASE + 0xFF,
672 .flags = IORESOURCE_MEM,
677 .flags = IORESOURCE_IRQ,
681 static struct platform_device i2c_bfin_twi0_device = {
682 .name = "i2c-bfin-twi",
684 .num_resources = ARRAY_SIZE(bfin_twi0_resource),
685 .resource = bfin_twi0_resource,
688 #if !defined(CONFIG_BF542) /* The BF542 only has 1 TWI */
689 static struct resource bfin_twi1_resource[] = {
691 .start = TWI1_REGBASE,
692 .end = TWI1_REGBASE + 0xFF,
693 .flags = IORESOURCE_MEM,
698 .flags = IORESOURCE_IRQ,
702 static struct platform_device i2c_bfin_twi1_device = {
703 .name = "i2c-bfin-twi",
705 .num_resources = ARRAY_SIZE(bfin_twi1_resource),
706 .resource = bfin_twi1_resource,
711 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
712 #include <linux/gpio_keys.h>
714 static struct gpio_keys_button bfin_gpio_keys_table[] = {
715 {BTN_0, GPIO_PH7, 1, "gpio-keys: BTN0"},
718 static struct gpio_keys_platform_data bfin_gpio_keys_data = {
719 .buttons = bfin_gpio_keys_table,
720 .nbuttons = ARRAY_SIZE(bfin_gpio_keys_table),
723 static struct platform_device bfin_device_gpiokeys = {
726 .platform_data = &bfin_gpio_keys_data,
731 static const unsigned int cclk_vlev_datasheet[] =
734 * Internal VLEV BF54XSBBC1533
735 ****temporarily using these values until data sheet is updated
737 VRPAIR(VLEV_085, 150000000),
738 VRPAIR(VLEV_090, 250000000),
739 VRPAIR(VLEV_110, 276000000),
740 VRPAIR(VLEV_115, 301000000),
741 VRPAIR(VLEV_120, 525000000),
742 VRPAIR(VLEV_125, 550000000),
743 VRPAIR(VLEV_130, 600000000),
746 static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
747 .tuple_tab = cclk_vlev_datasheet,
748 .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
749 .vr_settling_time = 25 /* us */,
752 static struct platform_device bfin_dpmc = {
755 .platform_data = &bfin_dmpc_vreg_data,
759 static struct platform_device *cm_bf548_devices[] __initdata = {
763 #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
767 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
771 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
772 #ifdef CONFIG_BFIN_SIR0
775 #ifdef CONFIG_BFIN_SIR1
778 #ifdef CONFIG_BFIN_SIR2
781 #ifdef CONFIG_BFIN_SIR3
786 #if defined(CONFIG_FB_BF54X_LQ043) || defined(CONFIG_FB_BF54X_LQ043_MODULE)
790 #if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE)
794 #if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE)
798 #if defined(CONFIG_PATA_BF54X) || defined(CONFIG_PATA_BF54X_MODULE)
802 #if defined(CONFIG_MTD_NAND_BF5XX) || defined(CONFIG_MTD_NAND_BF5XX_MODULE)
806 #if defined(CONFIG_SDH_BFIN) || defined(CONFIG_SDH_BFIN_MODULE)
810 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
815 #if defined(CONFIG_KEYBOARD_BFIN) || defined(CONFIG_KEYBOARD_BFIN_MODULE)
819 #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
820 &i2c_bfin_twi0_device,
821 #if !defined(CONFIG_BF542)
822 &i2c_bfin_twi1_device,
826 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
827 &bfin_device_gpiokeys,
830 #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
837 static int __init cm_bf548_init(void)
839 printk(KERN_INFO "%s(): registering device resources\n", __func__);
840 platform_add_devices(cm_bf548_devices, ARRAY_SIZE(cm_bf548_devices));
842 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
843 spi_register_board_info(bf54x_spi_board_info,
844 ARRAY_SIZE(bf54x_spi_board_info));
850 arch_initcall(cm_bf548_init);