2 * File: arch/blackfin/mach-bf548/boards/cm_bf548.c
3 * Based on: arch/blackfin/mach-bf537/boards/ezkit.c
4 * Author: Aidan Williams <aidan@nicta.com.au>
10 * Copyright 2005 National ICT Australia (NICTA)
11 * Copyright 2004-2008 Analog Devices Inc.
13 * Bugs: Enter bugs at http://blackfin.uclinux.org/
15 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 2 of the License, or
18 * (at your option) any later version.
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, see the file COPYING, or write
27 * to the Free Software Foundation, Inc.,
28 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
31 #include <linux/device.h>
32 #include <linux/platform_device.h>
33 #include <linux/mtd/mtd.h>
34 #include <linux/mtd/partitions.h>
35 #include <linux/mtd/physmap.h>
36 #include <linux/spi/spi.h>
37 #include <linux/spi/flash.h>
38 #include <linux/irq.h>
39 #include <linux/interrupt.h>
40 #include <linux/usb/musb.h>
41 #include <asm/bfin5xx_spi.h>
45 #include <asm/portmux.h>
46 #include <asm/bfin_sdh.h>
47 #include <mach/bf54x_keys.h>
49 #include <linux/input.h>
50 #include <linux/spi/ad7877.h>
53 * Name the Board for the /proc/cpuinfo
55 const char bfin_board_name
[] = "Bluetechnix CM-BF548";
58 * Driver needs to know address, irq and flag pin.
61 #if defined(CONFIG_FB_BF54X_LQ043) || defined(CONFIG_FB_BF54X_LQ043_MODULE)
63 #include <mach/bf54x-lq043.h>
65 static struct bfin_bf54xfb_mach_info bf54x_lq043_data
= {
68 .xres
= {480, 480, 480},
69 .yres
= {272, 272, 272},
74 static struct resource bf54x_lq043_resources
[] = {
76 .start
= IRQ_EPPI0_ERR
,
78 .flags
= IORESOURCE_IRQ
,
82 static struct platform_device bf54x_lq043_device
= {
83 .name
= "bf54x-lq043",
85 .num_resources
= ARRAY_SIZE(bf54x_lq043_resources
),
86 .resource
= bf54x_lq043_resources
,
88 .platform_data
= &bf54x_lq043_data
,
93 #if defined(CONFIG_KEYBOARD_BFIN) || defined(CONFIG_KEYBOARD_BFIN_MODULE)
94 static unsigned int bf548_keymap
[] = {
95 KEYVAL(0, 0, KEY_ENTER
),
96 KEYVAL(0, 1, KEY_HELP
),
98 KEYVAL(0, 3, KEY_BACKSPACE
),
99 KEYVAL(1, 0, KEY_TAB
),
103 KEYVAL(2, 0, KEY_DOWN
),
107 KEYVAL(3, 0, KEY_UP
),
113 static struct bfin_kpad_platform_data bf54x_kpad_data
= {
116 .keymap
= bf548_keymap
,
117 .keymapsize
= ARRAY_SIZE(bf548_keymap
),
119 .debounce_time
= 5000, /* ns (5ms) */
120 .coldrive_time
= 1000, /* ns (1ms) */
121 .keyup_test_interval
= 50, /* ms (50ms) */
124 static struct resource bf54x_kpad_resources
[] = {
128 .flags
= IORESOURCE_IRQ
,
132 static struct platform_device bf54x_kpad_device
= {
133 .name
= "bf54x-keys",
135 .num_resources
= ARRAY_SIZE(bf54x_kpad_resources
),
136 .resource
= bf54x_kpad_resources
,
138 .platform_data
= &bf54x_kpad_data
,
143 #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
144 static struct platform_device rtc_device
= {
150 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
151 static struct resource bfin_uart_resources
[] = {
152 #ifdef CONFIG_SERIAL_BFIN_UART0
156 .flags
= IORESOURCE_MEM
,
159 #ifdef CONFIG_SERIAL_BFIN_UART1
163 .flags
= IORESOURCE_MEM
,
166 #ifdef CONFIG_SERIAL_BFIN_UART2
170 .flags
= IORESOURCE_MEM
,
173 #ifdef CONFIG_SERIAL_BFIN_UART3
177 .flags
= IORESOURCE_MEM
,
182 static struct platform_device bfin_uart_device
= {
185 .num_resources
= ARRAY_SIZE(bfin_uart_resources
),
186 .resource
= bfin_uart_resources
,
190 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
191 #ifdef CONFIG_BFIN_SIR0
192 static struct resource bfin_sir0_resources
[] = {
196 .flags
= IORESOURCE_MEM
,
199 .start
= IRQ_UART0_RX
,
200 .end
= IRQ_UART0_RX
+1,
201 .flags
= IORESOURCE_IRQ
,
204 .start
= CH_UART0_RX
,
205 .end
= CH_UART0_RX
+1,
206 .flags
= IORESOURCE_DMA
,
209 static struct platform_device bfin_sir0_device
= {
212 .num_resources
= ARRAY_SIZE(bfin_sir0_resources
),
213 .resource
= bfin_sir0_resources
,
216 #ifdef CONFIG_BFIN_SIR1
217 static struct resource bfin_sir1_resources
[] = {
221 .flags
= IORESOURCE_MEM
,
224 .start
= IRQ_UART1_RX
,
225 .end
= IRQ_UART1_RX
+1,
226 .flags
= IORESOURCE_IRQ
,
229 .start
= CH_UART1_RX
,
230 .end
= CH_UART1_RX
+1,
231 .flags
= IORESOURCE_DMA
,
234 static struct platform_device bfin_sir1_device
= {
237 .num_resources
= ARRAY_SIZE(bfin_sir1_resources
),
238 .resource
= bfin_sir1_resources
,
241 #ifdef CONFIG_BFIN_SIR2
242 static struct resource bfin_sir2_resources
[] = {
246 .flags
= IORESOURCE_MEM
,
249 .start
= IRQ_UART2_RX
,
250 .end
= IRQ_UART2_RX
+1,
251 .flags
= IORESOURCE_IRQ
,
254 .start
= CH_UART2_RX
,
255 .end
= CH_UART2_RX
+1,
256 .flags
= IORESOURCE_DMA
,
259 static struct platform_device bfin_sir2_device
= {
262 .num_resources
= ARRAY_SIZE(bfin_sir2_resources
),
263 .resource
= bfin_sir2_resources
,
266 #ifdef CONFIG_BFIN_SIR3
267 static struct resource bfin_sir3_resources
[] = {
271 .flags
= IORESOURCE_MEM
,
274 .start
= IRQ_UART3_RX
,
275 .end
= IRQ_UART3_RX
+1,
276 .flags
= IORESOURCE_IRQ
,
279 .start
= CH_UART3_RX
,
280 .end
= CH_UART3_RX
+1,
281 .flags
= IORESOURCE_DMA
,
284 static struct platform_device bfin_sir3_device
= {
287 .num_resources
= ARRAY_SIZE(bfin_sir3_resources
),
288 .resource
= bfin_sir3_resources
,
293 #if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE)
294 static struct resource smsc911x_resources
[] = {
296 .name
= "smsc911x-memory",
298 .end
= 0x24000000 + 0xFF,
299 .flags
= IORESOURCE_MEM
,
304 .flags
= IORESOURCE_IRQ
| IORESOURCE_IRQ_LOWLEVEL
,
307 static struct platform_device smsc911x_device
= {
310 .num_resources
= ARRAY_SIZE(smsc911x_resources
),
311 .resource
= smsc911x_resources
,
315 #if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE)
316 static struct resource musb_resources
[] = {
320 .flags
= IORESOURCE_MEM
,
322 [1] = { /* general IRQ */
323 .start
= IRQ_USB_INT0
,
325 .flags
= IORESOURCE_IRQ
| IORESOURCE_IRQ_HIGHLEVEL
,
327 [2] = { /* DMA IRQ */
328 .start
= IRQ_USB_DMA
,
330 .flags
= IORESOURCE_IRQ
| IORESOURCE_IRQ_HIGHLEVEL
,
334 static struct musb_hdrc_config musb_config
= {
341 .gpio_vrsel
= GPIO_PH6
,
344 static struct musb_hdrc_platform_data musb_plat
= {
345 #if defined(CONFIG_USB_MUSB_OTG)
347 #elif defined(CONFIG_USB_MUSB_HDRC_HCD)
349 #elif defined(CONFIG_USB_GADGET_MUSB_HDRC)
350 .mode
= MUSB_PERIPHERAL
,
352 .config
= &musb_config
,
355 static u64 musb_dmamask
= ~(u32
)0;
357 static struct platform_device musb_device
= {
361 .dma_mask
= &musb_dmamask
,
362 .coherent_dma_mask
= 0xffffffff,
363 .platform_data
= &musb_plat
,
365 .num_resources
= ARRAY_SIZE(musb_resources
),
366 .resource
= musb_resources
,
370 static struct resource bfin_gpios_resources
= {
372 .end
= MAX_BLACKFIN_GPIOS
- 1,
373 .flags
= IORESOURCE_IRQ
,
376 static struct platform_device bfin_gpios_device
= {
377 .name
= "simple-gpio",
380 .resource
= &bfin_gpios_resources
,
383 #if defined(CONFIG_PATA_BF54X) || defined(CONFIG_PATA_BF54X_MODULE)
384 static struct resource bfin_atapi_resources
[] = {
388 .flags
= IORESOURCE_MEM
,
391 .start
= IRQ_ATAPI_ERR
,
392 .end
= IRQ_ATAPI_ERR
,
393 .flags
= IORESOURCE_IRQ
,
397 static struct platform_device bfin_atapi_device
= {
398 .name
= "pata-bf54x",
400 .num_resources
= ARRAY_SIZE(bfin_atapi_resources
),
401 .resource
= bfin_atapi_resources
,
405 #if defined(CONFIG_MTD_NAND_BF5XX) || defined(CONFIG_MTD_NAND_BF5XX_MODULE)
406 static struct mtd_partition partition_info
[] = {
408 .name
= "linux kernel(nand)",
410 .size
= 4 * 1024 * 1024,
413 .name
= "file system(nand)",
414 .offset
= 4 * 1024 * 1024,
415 .size
= (256 - 4) * 1024 * 1024,
419 static struct bf5xx_nand_platform bf5xx_nand_platform
= {
420 .page_size
= NFC_PG_SIZE_256
,
421 .data_width
= NFC_NWIDTH_8
,
422 .partitions
= partition_info
,
423 .nr_partitions
= ARRAY_SIZE(partition_info
),
428 static struct resource bf5xx_nand_resources
[] = {
432 .flags
= IORESOURCE_MEM
,
437 .flags
= IORESOURCE_IRQ
,
441 static struct platform_device bf5xx_nand_device
= {
442 .name
= "bf5xx-nand",
444 .num_resources
= ARRAY_SIZE(bf5xx_nand_resources
),
445 .resource
= bf5xx_nand_resources
,
447 .platform_data
= &bf5xx_nand_platform
,
452 #if defined(CONFIG_SDH_BFIN) || defined(CONFIG_SDH_BFIN_MODULE)
453 static struct bfin_sd_host bfin_sdh_data
= {
455 .irq_int0
= IRQ_SDH_MASK0
,
456 .pin_req
= {P_SD_D0
, P_SD_D1
, P_SD_D2
, P_SD_D3
, P_SD_CLK
, P_SD_CMD
, 0},
459 static struct platform_device bf54x_sdh_device
= {
463 .platform_data
= &bfin_sdh_data
,
468 #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
469 static struct mtd_partition para_partitions
[] = {
471 .name
= "bootloader(nor)",
475 .name
= "linux kernel(nor)",
477 .offset
= MTDPART_OFS_APPEND
,
479 .name
= "file system(nor)",
480 .size
= MTDPART_SIZ_FULL
,
481 .offset
= MTDPART_OFS_APPEND
,
485 static struct physmap_flash_data para_flash_data
= {
487 .parts
= para_partitions
,
488 .nr_parts
= ARRAY_SIZE(para_partitions
),
491 static struct resource para_flash_resource
= {
494 .flags
= IORESOURCE_MEM
,
497 static struct platform_device para_flash_device
= {
498 .name
= "physmap-flash",
501 .platform_data
= ¶_flash_data
,
504 .resource
= ¶_flash_resource
,
508 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
509 /* all SPI peripherals info goes here */
510 #if defined(CONFIG_MTD_M25P80) \
511 || defined(CONFIG_MTD_M25P80_MODULE)
512 /* SPI flash chip (m25p16) */
513 static struct mtd_partition bfin_spi_flash_partitions
[] = {
515 .name
= "bootloader(spi)",
518 .mask_flags
= MTD_CAP_ROM
520 .name
= "linux kernel(spi)",
526 static struct flash_platform_data bfin_spi_flash_data
= {
528 .parts
= bfin_spi_flash_partitions
,
529 .nr_parts
= ARRAY_SIZE(bfin_spi_flash_partitions
),
533 static struct bfin5xx_spi_chip spi_flash_chip_info
= {
534 .enable_dma
= 0, /* use dma transfer with this chip*/
536 .cs_change_per_word
= 0,
540 #if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
541 static struct bfin5xx_spi_chip spi_ad7877_chip_info
= {
542 .cs_change_per_word
= 0,
547 static const struct ad7877_platform_data bfin_ad7877_ts_info
= {
549 .vref_delay_usecs
= 50, /* internal, no capacitor */
552 .pressure_max
= 1000,
554 .stopacq_polarity
= 1,
555 .first_conversion_delay
= 3,
556 .acquisition_time
= 1,
558 .pen_down_acc_interval
= 1,
562 #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
563 static struct bfin5xx_spi_chip spidev_chip_info
= {
569 static struct spi_board_info bf54x_spi_board_info
[] __initdata
= {
570 #if defined(CONFIG_MTD_M25P80) \
571 || defined(CONFIG_MTD_M25P80_MODULE)
573 /* the modalias must be the same as spi device driver name */
574 .modalias
= "m25p80", /* Name of spi_driver for this device */
575 .max_speed_hz
= 25000000, /* max spi clock (SCK) speed in HZ */
576 .bus_num
= 0, /* Framework bus number */
577 .chip_select
= 1, /* SPI_SSEL1*/
578 .platform_data
= &bfin_spi_flash_data
,
579 .controller_data
= &spi_flash_chip_info
,
583 #if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
585 .modalias
= "ad7877",
586 .platform_data
= &bfin_ad7877_ts_info
,
588 .max_speed_hz
= 12500000, /* max spi clock (SCK) speed in HZ */
591 .controller_data
= &spi_ad7877_chip_info
,
594 #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
596 .modalias
= "spidev",
597 .max_speed_hz
= 3125000, /* max spi clock (SCK) speed in HZ */
600 .controller_data
= &spidev_chip_info
,
606 static struct resource bfin_spi0_resource
[] = {
608 .start
= SPI0_REGBASE
,
609 .end
= SPI0_REGBASE
+ 0xFF,
610 .flags
= IORESOURCE_MEM
,
615 .flags
= IORESOURCE_DMA
,
620 .flags
= IORESOURCE_IRQ
,
625 static struct resource bfin_spi1_resource
[] = {
627 .start
= SPI1_REGBASE
,
628 .end
= SPI1_REGBASE
+ 0xFF,
629 .flags
= IORESOURCE_MEM
,
634 .flags
= IORESOURCE_DMA
,
639 .flags
= IORESOURCE_IRQ
,
643 /* SPI controller data */
644 static struct bfin5xx_spi_master bf54x_spi_master_info0
= {
646 .enable_dma
= 1, /* master has the ability to do dma transfer */
647 .pin_req
= {P_SPI0_SCK
, P_SPI0_MISO
, P_SPI0_MOSI
, 0},
650 static struct platform_device bf54x_spi_master0
= {
652 .id
= 0, /* Bus number */
653 .num_resources
= ARRAY_SIZE(bfin_spi0_resource
),
654 .resource
= bfin_spi0_resource
,
656 .platform_data
= &bf54x_spi_master_info0
, /* Passed to driver */
660 static struct bfin5xx_spi_master bf54x_spi_master_info1
= {
662 .enable_dma
= 1, /* master has the ability to do dma transfer */
663 .pin_req
= {P_SPI1_SCK
, P_SPI1_MISO
, P_SPI1_MOSI
, 0},
666 static struct platform_device bf54x_spi_master1
= {
668 .id
= 1, /* Bus number */
669 .num_resources
= ARRAY_SIZE(bfin_spi1_resource
),
670 .resource
= bfin_spi1_resource
,
672 .platform_data
= &bf54x_spi_master_info1
, /* Passed to driver */
675 #endif /* spi master and devices */
677 #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
678 static struct resource bfin_twi0_resource
[] = {
680 .start
= TWI0_REGBASE
,
681 .end
= TWI0_REGBASE
+ 0xFF,
682 .flags
= IORESOURCE_MEM
,
687 .flags
= IORESOURCE_IRQ
,
691 static struct platform_device i2c_bfin_twi0_device
= {
692 .name
= "i2c-bfin-twi",
694 .num_resources
= ARRAY_SIZE(bfin_twi0_resource
),
695 .resource
= bfin_twi0_resource
,
698 #if !defined(CONFIG_BF542) /* The BF542 only has 1 TWI */
699 static struct resource bfin_twi1_resource
[] = {
701 .start
= TWI1_REGBASE
,
702 .end
= TWI1_REGBASE
+ 0xFF,
703 .flags
= IORESOURCE_MEM
,
708 .flags
= IORESOURCE_IRQ
,
712 static struct platform_device i2c_bfin_twi1_device
= {
713 .name
= "i2c-bfin-twi",
715 .num_resources
= ARRAY_SIZE(bfin_twi1_resource
),
716 .resource
= bfin_twi1_resource
,
721 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
722 #include <linux/gpio_keys.h>
724 static struct gpio_keys_button bfin_gpio_keys_table
[] = {
725 {BTN_0
, GPIO_PH7
, 1, "gpio-keys: BTN0"},
728 static struct gpio_keys_platform_data bfin_gpio_keys_data
= {
729 .buttons
= bfin_gpio_keys_table
,
730 .nbuttons
= ARRAY_SIZE(bfin_gpio_keys_table
),
733 static struct platform_device bfin_device_gpiokeys
= {
736 .platform_data
= &bfin_gpio_keys_data
,
741 static const unsigned int cclk_vlev_datasheet
[] =
744 * Internal VLEV BF54XSBBC1533
745 ****temporarily using these values until data sheet is updated
747 VRPAIR(VLEV_085
, 150000000),
748 VRPAIR(VLEV_090
, 250000000),
749 VRPAIR(VLEV_110
, 276000000),
750 VRPAIR(VLEV_115
, 301000000),
751 VRPAIR(VLEV_120
, 525000000),
752 VRPAIR(VLEV_125
, 550000000),
753 VRPAIR(VLEV_130
, 600000000),
756 static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data
= {
757 .tuple_tab
= cclk_vlev_datasheet
,
758 .tabsize
= ARRAY_SIZE(cclk_vlev_datasheet
),
759 .vr_settling_time
= 25 /* us */,
762 static struct platform_device bfin_dpmc
= {
765 .platform_data
= &bfin_dmpc_vreg_data
,
769 static struct platform_device
*cm_bf548_devices
[] __initdata
= {
773 #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
777 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
781 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
782 #ifdef CONFIG_BFIN_SIR0
785 #ifdef CONFIG_BFIN_SIR1
788 #ifdef CONFIG_BFIN_SIR2
791 #ifdef CONFIG_BFIN_SIR3
796 #if defined(CONFIG_FB_BF54X_LQ043) || defined(CONFIG_FB_BF54X_LQ043_MODULE)
800 #if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE)
804 #if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE)
808 #if defined(CONFIG_PATA_BF54X) || defined(CONFIG_PATA_BF54X_MODULE)
812 #if defined(CONFIG_MTD_NAND_BF5XX) || defined(CONFIG_MTD_NAND_BF5XX_MODULE)
816 #if defined(CONFIG_SDH_BFIN) || defined(CONFIG_SDH_BFIN_MODULE)
820 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
825 #if defined(CONFIG_KEYBOARD_BFIN) || defined(CONFIG_KEYBOARD_BFIN_MODULE)
829 #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
830 &i2c_bfin_twi0_device
,
831 #if !defined(CONFIG_BF542)
832 &i2c_bfin_twi1_device
,
836 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
837 &bfin_device_gpiokeys
,
840 #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
847 static int __init
cm_bf548_init(void)
849 printk(KERN_INFO
"%s(): registering device resources\n", __func__
);
850 platform_add_devices(cm_bf548_devices
, ARRAY_SIZE(cm_bf548_devices
));
852 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
853 spi_register_board_info(bf54x_spi_board_info
,
854 ARRAY_SIZE(bf54x_spi_board_info
));
860 arch_initcall(cm_bf548_init
);