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 #if defined(CONFIG_PATA_BF54X) || defined(CONFIG_PATA_BF54X_MODULE)
363 static struct resource bfin_atapi_resources
[] = {
367 .flags
= IORESOURCE_MEM
,
370 .start
= IRQ_ATAPI_ERR
,
371 .end
= IRQ_ATAPI_ERR
,
372 .flags
= IORESOURCE_IRQ
,
376 static struct platform_device bfin_atapi_device
= {
377 .name
= "pata-bf54x",
379 .num_resources
= ARRAY_SIZE(bfin_atapi_resources
),
380 .resource
= bfin_atapi_resources
,
384 #if defined(CONFIG_MTD_NAND_BF5XX) || defined(CONFIG_MTD_NAND_BF5XX_MODULE)
385 static struct mtd_partition partition_info
[] = {
387 .name
= "linux kernel(nand)",
389 .size
= 4 * 1024 * 1024,
392 .name
= "file system(nand)",
393 .offset
= 4 * 1024 * 1024,
394 .size
= (256 - 4) * 1024 * 1024,
398 static struct bf5xx_nand_platform bf5xx_nand_platform
= {
399 .page_size
= NFC_PG_SIZE_256
,
400 .data_width
= NFC_NWIDTH_8
,
401 .partitions
= partition_info
,
402 .nr_partitions
= ARRAY_SIZE(partition_info
),
407 static struct resource bf5xx_nand_resources
[] = {
411 .flags
= IORESOURCE_MEM
,
416 .flags
= IORESOURCE_IRQ
,
420 static struct platform_device bf5xx_nand_device
= {
421 .name
= "bf5xx-nand",
423 .num_resources
= ARRAY_SIZE(bf5xx_nand_resources
),
424 .resource
= bf5xx_nand_resources
,
426 .platform_data
= &bf5xx_nand_platform
,
431 #if defined(CONFIG_SDH_BFIN) || defined(CONFIG_SDH_BFIN_MODULE)
432 static struct bfin_sd_host bfin_sdh_data
= {
434 .irq_int0
= IRQ_SDH_MASK0
,
435 .pin_req
= {P_SD_D0
, P_SD_D1
, P_SD_D2
, P_SD_D3
, P_SD_CLK
, P_SD_CMD
, 0},
438 static struct platform_device bf54x_sdh_device
= {
442 .platform_data
= &bfin_sdh_data
,
447 #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
448 static struct mtd_partition para_partitions
[] = {
450 .name
= "bootloader(nor)",
454 .name
= "linux kernel(nor)",
456 .offset
= MTDPART_OFS_APPEND
,
458 .name
= "file system(nor)",
459 .size
= MTDPART_SIZ_FULL
,
460 .offset
= MTDPART_OFS_APPEND
,
464 static struct physmap_flash_data para_flash_data
= {
466 .parts
= para_partitions
,
467 .nr_parts
= ARRAY_SIZE(para_partitions
),
470 static struct resource para_flash_resource
= {
473 .flags
= IORESOURCE_MEM
,
476 static struct platform_device para_flash_device
= {
477 .name
= "physmap-flash",
480 .platform_data
= ¶_flash_data
,
483 .resource
= ¶_flash_resource
,
487 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
488 /* all SPI peripherals info goes here */
489 #if defined(CONFIG_MTD_M25P80) \
490 || defined(CONFIG_MTD_M25P80_MODULE)
491 /* SPI flash chip (m25p16) */
492 static struct mtd_partition bfin_spi_flash_partitions
[] = {
494 .name
= "bootloader(spi)",
497 .mask_flags
= MTD_CAP_ROM
499 .name
= "linux kernel(spi)",
505 static struct flash_platform_data bfin_spi_flash_data
= {
507 .parts
= bfin_spi_flash_partitions
,
508 .nr_parts
= ARRAY_SIZE(bfin_spi_flash_partitions
),
512 static struct bfin5xx_spi_chip spi_flash_chip_info
= {
513 .enable_dma
= 0, /* use dma transfer with this chip*/
518 #if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
519 static struct bfin5xx_spi_chip spi_ad7877_chip_info
= {
524 static const struct ad7877_platform_data bfin_ad7877_ts_info
= {
526 .vref_delay_usecs
= 50, /* internal, no capacitor */
529 .pressure_max
= 1000,
531 .stopacq_polarity
= 1,
532 .first_conversion_delay
= 3,
533 .acquisition_time
= 1,
535 .pen_down_acc_interval
= 1,
539 #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
540 static struct bfin5xx_spi_chip spidev_chip_info
= {
546 static struct spi_board_info bf54x_spi_board_info
[] __initdata
= {
547 #if defined(CONFIG_MTD_M25P80) \
548 || defined(CONFIG_MTD_M25P80_MODULE)
550 /* the modalias must be the same as spi device driver name */
551 .modalias
= "m25p80", /* Name of spi_driver for this device */
552 .max_speed_hz
= 25000000, /* max spi clock (SCK) speed in HZ */
553 .bus_num
= 0, /* Framework bus number */
554 .chip_select
= 1, /* SPI_SSEL1*/
555 .platform_data
= &bfin_spi_flash_data
,
556 .controller_data
= &spi_flash_chip_info
,
560 #if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
562 .modalias
= "ad7877",
563 .platform_data
= &bfin_ad7877_ts_info
,
565 .max_speed_hz
= 12500000, /* max spi clock (SCK) speed in HZ */
568 .controller_data
= &spi_ad7877_chip_info
,
571 #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
573 .modalias
= "spidev",
574 .max_speed_hz
= 3125000, /* max spi clock (SCK) speed in HZ */
577 .controller_data
= &spidev_chip_info
,
583 static struct resource bfin_spi0_resource
[] = {
585 .start
= SPI0_REGBASE
,
586 .end
= SPI0_REGBASE
+ 0xFF,
587 .flags
= IORESOURCE_MEM
,
592 .flags
= IORESOURCE_DMA
,
597 .flags
= IORESOURCE_IRQ
,
602 static struct resource bfin_spi1_resource
[] = {
604 .start
= SPI1_REGBASE
,
605 .end
= SPI1_REGBASE
+ 0xFF,
606 .flags
= IORESOURCE_MEM
,
611 .flags
= IORESOURCE_DMA
,
616 .flags
= IORESOURCE_IRQ
,
620 /* SPI controller data */
621 static struct bfin5xx_spi_master bf54x_spi_master_info0
= {
623 .enable_dma
= 1, /* master has the ability to do dma transfer */
624 .pin_req
= {P_SPI0_SCK
, P_SPI0_MISO
, P_SPI0_MOSI
, 0},
627 static struct platform_device bf54x_spi_master0
= {
629 .id
= 0, /* Bus number */
630 .num_resources
= ARRAY_SIZE(bfin_spi0_resource
),
631 .resource
= bfin_spi0_resource
,
633 .platform_data
= &bf54x_spi_master_info0
, /* Passed to driver */
637 static struct bfin5xx_spi_master bf54x_spi_master_info1
= {
639 .enable_dma
= 1, /* master has the ability to do dma transfer */
640 .pin_req
= {P_SPI1_SCK
, P_SPI1_MISO
, P_SPI1_MOSI
, 0},
643 static struct platform_device bf54x_spi_master1
= {
645 .id
= 1, /* Bus number */
646 .num_resources
= ARRAY_SIZE(bfin_spi1_resource
),
647 .resource
= bfin_spi1_resource
,
649 .platform_data
= &bf54x_spi_master_info1
, /* Passed to driver */
652 #endif /* spi master and devices */
654 #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
655 static struct resource bfin_twi0_resource
[] = {
657 .start
= TWI0_REGBASE
,
658 .end
= TWI0_REGBASE
+ 0xFF,
659 .flags
= IORESOURCE_MEM
,
664 .flags
= IORESOURCE_IRQ
,
668 static struct platform_device i2c_bfin_twi0_device
= {
669 .name
= "i2c-bfin-twi",
671 .num_resources
= ARRAY_SIZE(bfin_twi0_resource
),
672 .resource
= bfin_twi0_resource
,
675 #if !defined(CONFIG_BF542) /* The BF542 only has 1 TWI */
676 static struct resource bfin_twi1_resource
[] = {
678 .start
= TWI1_REGBASE
,
679 .end
= TWI1_REGBASE
+ 0xFF,
680 .flags
= IORESOURCE_MEM
,
685 .flags
= IORESOURCE_IRQ
,
689 static struct platform_device i2c_bfin_twi1_device
= {
690 .name
= "i2c-bfin-twi",
692 .num_resources
= ARRAY_SIZE(bfin_twi1_resource
),
693 .resource
= bfin_twi1_resource
,
698 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
699 #include <linux/gpio_keys.h>
701 static struct gpio_keys_button bfin_gpio_keys_table
[] = {
702 {BTN_0
, GPIO_PH7
, 1, "gpio-keys: BTN0"},
705 static struct gpio_keys_platform_data bfin_gpio_keys_data
= {
706 .buttons
= bfin_gpio_keys_table
,
707 .nbuttons
= ARRAY_SIZE(bfin_gpio_keys_table
),
710 static struct platform_device bfin_device_gpiokeys
= {
713 .platform_data
= &bfin_gpio_keys_data
,
718 static const unsigned int cclk_vlev_datasheet
[] =
721 * Internal VLEV BF54XSBBC1533
722 ****temporarily using these values until data sheet is updated
724 VRPAIR(VLEV_085
, 150000000),
725 VRPAIR(VLEV_090
, 250000000),
726 VRPAIR(VLEV_110
, 276000000),
727 VRPAIR(VLEV_115
, 301000000),
728 VRPAIR(VLEV_120
, 525000000),
729 VRPAIR(VLEV_125
, 550000000),
730 VRPAIR(VLEV_130
, 600000000),
733 static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data
= {
734 .tuple_tab
= cclk_vlev_datasheet
,
735 .tabsize
= ARRAY_SIZE(cclk_vlev_datasheet
),
736 .vr_settling_time
= 25 /* us */,
739 static struct platform_device bfin_dpmc
= {
742 .platform_data
= &bfin_dmpc_vreg_data
,
746 static struct platform_device
*cm_bf548_devices
[] __initdata
= {
750 #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
754 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
758 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
759 #ifdef CONFIG_BFIN_SIR0
762 #ifdef CONFIG_BFIN_SIR1
765 #ifdef CONFIG_BFIN_SIR2
768 #ifdef CONFIG_BFIN_SIR3
773 #if defined(CONFIG_FB_BF54X_LQ043) || defined(CONFIG_FB_BF54X_LQ043_MODULE)
777 #if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE)
781 #if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE)
785 #if defined(CONFIG_PATA_BF54X) || defined(CONFIG_PATA_BF54X_MODULE)
789 #if defined(CONFIG_MTD_NAND_BF5XX) || defined(CONFIG_MTD_NAND_BF5XX_MODULE)
793 #if defined(CONFIG_SDH_BFIN) || defined(CONFIG_SDH_BFIN_MODULE)
797 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
802 #if defined(CONFIG_KEYBOARD_BFIN) || defined(CONFIG_KEYBOARD_BFIN_MODULE)
806 #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
807 &i2c_bfin_twi0_device
,
808 #if !defined(CONFIG_BF542)
809 &i2c_bfin_twi1_device
,
813 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
814 &bfin_device_gpiokeys
,
817 #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
822 static int __init
cm_bf548_init(void)
824 printk(KERN_INFO
"%s(): registering device resources\n", __func__
);
825 platform_add_devices(cm_bf548_devices
, ARRAY_SIZE(cm_bf548_devices
));
827 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
828 spi_register_board_info(bf54x_spi_board_info
,
829 ARRAY_SIZE(bf54x_spi_board_info
));
835 arch_initcall(cm_bf548_init
);