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 <mach/bf54x_keys.h>
48 #include <linux/input.h>
49 #include <linux/spi/ad7877.h>
52 * Name the Board for the /proc/cpuinfo
54 const char bfin_board_name
[] = "Bluetechnix CM-BF548";
57 * Driver needs to know address, irq and flag pin.
60 #if defined(CONFIG_FB_BF54X_LQ043) || defined(CONFIG_FB_BF54X_LQ043_MODULE)
62 #include <mach/bf54x-lq043.h>
64 static struct bfin_bf54xfb_mach_info bf54x_lq043_data
= {
67 .xres
= {480, 480, 480},
68 .yres
= {272, 272, 272},
73 static struct resource bf54x_lq043_resources
[] = {
75 .start
= IRQ_EPPI0_ERR
,
77 .flags
= IORESOURCE_IRQ
,
81 static struct platform_device bf54x_lq043_device
= {
82 .name
= "bf54x-lq043",
84 .num_resources
= ARRAY_SIZE(bf54x_lq043_resources
),
85 .resource
= bf54x_lq043_resources
,
87 .platform_data
= &bf54x_lq043_data
,
92 #if defined(CONFIG_KEYBOARD_BFIN) || defined(CONFIG_KEYBOARD_BFIN_MODULE)
93 static unsigned int bf548_keymap
[] = {
94 KEYVAL(0, 0, KEY_ENTER
),
95 KEYVAL(0, 1, KEY_HELP
),
97 KEYVAL(0, 3, KEY_BACKSPACE
),
98 KEYVAL(1, 0, KEY_TAB
),
102 KEYVAL(2, 0, KEY_DOWN
),
106 KEYVAL(3, 0, KEY_UP
),
112 static struct bfin_kpad_platform_data bf54x_kpad_data
= {
115 .keymap
= bf548_keymap
,
116 .keymapsize
= ARRAY_SIZE(bf548_keymap
),
118 .debounce_time
= 5000, /* ns (5ms) */
119 .coldrive_time
= 1000, /* ns (1ms) */
120 .keyup_test_interval
= 50, /* ms (50ms) */
123 static struct resource bf54x_kpad_resources
[] = {
127 .flags
= IORESOURCE_IRQ
,
131 static struct platform_device bf54x_kpad_device
= {
132 .name
= "bf54x-keys",
134 .num_resources
= ARRAY_SIZE(bf54x_kpad_resources
),
135 .resource
= bf54x_kpad_resources
,
137 .platform_data
= &bf54x_kpad_data
,
142 #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
143 static struct platform_device rtc_device
= {
149 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
150 static struct resource bfin_uart_resources
[] = {
151 #ifdef CONFIG_SERIAL_BFIN_UART0
155 .flags
= IORESOURCE_MEM
,
158 #ifdef CONFIG_SERIAL_BFIN_UART1
162 .flags
= IORESOURCE_MEM
,
165 #ifdef CONFIG_SERIAL_BFIN_UART2
169 .flags
= IORESOURCE_MEM
,
172 #ifdef CONFIG_SERIAL_BFIN_UART3
176 .flags
= IORESOURCE_MEM
,
181 static struct platform_device bfin_uart_device
= {
184 .num_resources
= ARRAY_SIZE(bfin_uart_resources
),
185 .resource
= bfin_uart_resources
,
189 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
190 #ifdef CONFIG_BFIN_SIR0
191 static struct resource bfin_sir0_resources
[] = {
195 .flags
= IORESOURCE_MEM
,
198 .start
= IRQ_UART0_RX
,
199 .end
= IRQ_UART0_RX
+1,
200 .flags
= IORESOURCE_IRQ
,
203 .start
= CH_UART0_RX
,
204 .end
= CH_UART0_RX
+1,
205 .flags
= IORESOURCE_DMA
,
208 static struct platform_device bfin_sir0_device
= {
211 .num_resources
= ARRAY_SIZE(bfin_sir0_resources
),
212 .resource
= bfin_sir0_resources
,
215 #ifdef CONFIG_BFIN_SIR1
216 static struct resource bfin_sir1_resources
[] = {
220 .flags
= IORESOURCE_MEM
,
223 .start
= IRQ_UART1_RX
,
224 .end
= IRQ_UART1_RX
+1,
225 .flags
= IORESOURCE_IRQ
,
228 .start
= CH_UART1_RX
,
229 .end
= CH_UART1_RX
+1,
230 .flags
= IORESOURCE_DMA
,
233 static struct platform_device bfin_sir1_device
= {
236 .num_resources
= ARRAY_SIZE(bfin_sir1_resources
),
237 .resource
= bfin_sir1_resources
,
240 #ifdef CONFIG_BFIN_SIR2
241 static struct resource bfin_sir2_resources
[] = {
245 .flags
= IORESOURCE_MEM
,
248 .start
= IRQ_UART2_RX
,
249 .end
= IRQ_UART2_RX
+1,
250 .flags
= IORESOURCE_IRQ
,
253 .start
= CH_UART2_RX
,
254 .end
= CH_UART2_RX
+1,
255 .flags
= IORESOURCE_DMA
,
258 static struct platform_device bfin_sir2_device
= {
261 .num_resources
= ARRAY_SIZE(bfin_sir2_resources
),
262 .resource
= bfin_sir2_resources
,
265 #ifdef CONFIG_BFIN_SIR3
266 static struct resource bfin_sir3_resources
[] = {
270 .flags
= IORESOURCE_MEM
,
273 .start
= IRQ_UART3_RX
,
274 .end
= IRQ_UART3_RX
+1,
275 .flags
= IORESOURCE_IRQ
,
278 .start
= CH_UART3_RX
,
279 .end
= CH_UART3_RX
+1,
280 .flags
= IORESOURCE_DMA
,
283 static struct platform_device bfin_sir3_device
= {
286 .num_resources
= ARRAY_SIZE(bfin_sir3_resources
),
287 .resource
= bfin_sir3_resources
,
292 #if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE)
293 static struct resource smsc911x_resources
[] = {
295 .name
= "smsc911x-memory",
297 .end
= 0x24000000 + 0xFF,
298 .flags
= IORESOURCE_MEM
,
303 .flags
= IORESOURCE_IRQ
| IORESOURCE_IRQ_LOWLEVEL
,
306 static struct platform_device smsc911x_device
= {
309 .num_resources
= ARRAY_SIZE(smsc911x_resources
),
310 .resource
= smsc911x_resources
,
314 #if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE)
315 static struct resource musb_resources
[] = {
319 .flags
= IORESOURCE_MEM
,
321 [1] = { /* general IRQ */
322 .start
= IRQ_USB_INT0
,
324 .flags
= IORESOURCE_IRQ
| IORESOURCE_IRQ_HIGHLEVEL
,
326 [2] = { /* DMA IRQ */
327 .start
= IRQ_USB_DMA
,
329 .flags
= IORESOURCE_IRQ
| IORESOURCE_IRQ_HIGHLEVEL
,
333 static struct musb_hdrc_config musb_config
= {
340 .gpio_vrsel
= GPIO_PH6
,
343 static struct musb_hdrc_platform_data musb_plat
= {
344 #if defined(CONFIG_USB_MUSB_OTG)
346 #elif defined(CONFIG_USB_MUSB_HDRC_HCD)
348 #elif defined(CONFIG_USB_GADGET_MUSB_HDRC)
349 .mode
= MUSB_PERIPHERAL
,
351 .config
= &musb_config
,
354 static u64 musb_dmamask
= ~(u32
)0;
356 static struct platform_device musb_device
= {
360 .dma_mask
= &musb_dmamask
,
361 .coherent_dma_mask
= 0xffffffff,
362 .platform_data
= &musb_plat
,
364 .num_resources
= ARRAY_SIZE(musb_resources
),
365 .resource
= musb_resources
,
369 static struct resource bfin_gpios_resources
= {
371 .end
= MAX_BLACKFIN_GPIOS
- 1,
372 .flags
= IORESOURCE_IRQ
,
375 static struct platform_device bfin_gpios_device
= {
376 .name
= "simple-gpio",
379 .resource
= &bfin_gpios_resources
,
382 #if defined(CONFIG_PATA_BF54X) || defined(CONFIG_PATA_BF54X_MODULE)
383 static struct resource bfin_atapi_resources
[] = {
387 .flags
= IORESOURCE_MEM
,
390 .start
= IRQ_ATAPI_ERR
,
391 .end
= IRQ_ATAPI_ERR
,
392 .flags
= IORESOURCE_IRQ
,
396 static struct platform_device bfin_atapi_device
= {
397 .name
= "pata-bf54x",
399 .num_resources
= ARRAY_SIZE(bfin_atapi_resources
),
400 .resource
= bfin_atapi_resources
,
404 #if defined(CONFIG_MTD_NAND_BF5XX) || defined(CONFIG_MTD_NAND_BF5XX_MODULE)
405 static struct mtd_partition partition_info
[] = {
407 .name
= "linux kernel(nand)",
409 .size
= 4 * 1024 * 1024,
412 .name
= "file system(nand)",
413 .offset
= 4 * 1024 * 1024,
414 .size
= (256 - 4) * 1024 * 1024,
418 static struct bf5xx_nand_platform bf5xx_nand_platform
= {
419 .page_size
= NFC_PG_SIZE_256
,
420 .data_width
= NFC_NWIDTH_8
,
421 .partitions
= partition_info
,
422 .nr_partitions
= ARRAY_SIZE(partition_info
),
427 static struct resource bf5xx_nand_resources
[] = {
431 .flags
= IORESOURCE_MEM
,
436 .flags
= IORESOURCE_IRQ
,
440 static struct platform_device bf5xx_nand_device
= {
441 .name
= "bf5xx-nand",
443 .num_resources
= ARRAY_SIZE(bf5xx_nand_resources
),
444 .resource
= bf5xx_nand_resources
,
446 .platform_data
= &bf5xx_nand_platform
,
451 #if defined(CONFIG_SDH_BFIN) || defined(CONFIG_SDH_BFIN_MODULE)
452 static struct platform_device bf54x_sdh_device
= {
458 #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
459 static struct mtd_partition para_partitions
[] = {
461 .name
= "bootloader(nor)",
465 .name
= "linux kernel(nor)",
467 .offset
= MTDPART_OFS_APPEND
,
469 .name
= "file system(nor)",
470 .size
= MTDPART_SIZ_FULL
,
471 .offset
= MTDPART_OFS_APPEND
,
475 static struct physmap_flash_data para_flash_data
= {
477 .parts
= para_partitions
,
478 .nr_parts
= ARRAY_SIZE(para_partitions
),
481 static struct resource para_flash_resource
= {
484 .flags
= IORESOURCE_MEM
,
487 static struct platform_device para_flash_device
= {
488 .name
= "physmap-flash",
491 .platform_data
= ¶_flash_data
,
494 .resource
= ¶_flash_resource
,
498 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
499 /* all SPI peripherals info goes here */
500 #if defined(CONFIG_MTD_M25P80) \
501 || defined(CONFIG_MTD_M25P80_MODULE)
502 /* SPI flash chip (m25p16) */
503 static struct mtd_partition bfin_spi_flash_partitions
[] = {
505 .name
= "bootloader(spi)",
508 .mask_flags
= MTD_CAP_ROM
510 .name
= "linux kernel(spi)",
516 static struct flash_platform_data bfin_spi_flash_data
= {
518 .parts
= bfin_spi_flash_partitions
,
519 .nr_parts
= ARRAY_SIZE(bfin_spi_flash_partitions
),
523 static struct bfin5xx_spi_chip spi_flash_chip_info
= {
524 .enable_dma
= 0, /* use dma transfer with this chip*/
526 .cs_change_per_word
= 0,
530 #if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
531 static struct bfin5xx_spi_chip spi_ad7877_chip_info
= {
532 .cs_change_per_word
= 0,
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_IRQ
,
610 static struct resource bfin_spi1_resource
[] = {
612 .start
= SPI1_REGBASE
,
613 .end
= SPI1_REGBASE
+ 0xFF,
614 .flags
= IORESOURCE_MEM
,
619 .flags
= IORESOURCE_IRQ
,
623 /* SPI controller data */
624 static struct bfin5xx_spi_master bf54x_spi_master_info0
= {
626 .enable_dma
= 1, /* master has the ability to do dma transfer */
627 .pin_req
= {P_SPI0_SCK
, P_SPI0_MISO
, P_SPI0_MOSI
, 0},
630 static struct platform_device bf54x_spi_master0
= {
632 .id
= 0, /* Bus number */
633 .num_resources
= ARRAY_SIZE(bfin_spi0_resource
),
634 .resource
= bfin_spi0_resource
,
636 .platform_data
= &bf54x_spi_master_info0
, /* Passed to driver */
640 static struct bfin5xx_spi_master bf54x_spi_master_info1
= {
642 .enable_dma
= 1, /* master has the ability to do dma transfer */
643 .pin_req
= {P_SPI1_SCK
, P_SPI1_MISO
, P_SPI1_MOSI
, 0},
646 static struct platform_device bf54x_spi_master1
= {
648 .id
= 1, /* Bus number */
649 .num_resources
= ARRAY_SIZE(bfin_spi1_resource
),
650 .resource
= bfin_spi1_resource
,
652 .platform_data
= &bf54x_spi_master_info1
, /* Passed to driver */
655 #endif /* spi master and devices */
657 #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
658 static struct resource bfin_twi0_resource
[] = {
660 .start
= TWI0_REGBASE
,
661 .end
= TWI0_REGBASE
+ 0xFF,
662 .flags
= IORESOURCE_MEM
,
667 .flags
= IORESOURCE_IRQ
,
671 static struct platform_device i2c_bfin_twi0_device
= {
672 .name
= "i2c-bfin-twi",
674 .num_resources
= ARRAY_SIZE(bfin_twi0_resource
),
675 .resource
= bfin_twi0_resource
,
678 #if !defined(CONFIG_BF542) /* The BF542 only has 1 TWI */
679 static struct resource bfin_twi1_resource
[] = {
681 .start
= TWI1_REGBASE
,
682 .end
= TWI1_REGBASE
+ 0xFF,
683 .flags
= IORESOURCE_MEM
,
688 .flags
= IORESOURCE_IRQ
,
692 static struct platform_device i2c_bfin_twi1_device
= {
693 .name
= "i2c-bfin-twi",
695 .num_resources
= ARRAY_SIZE(bfin_twi1_resource
),
696 .resource
= bfin_twi1_resource
,
701 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
702 #include <linux/gpio_keys.h>
704 static struct gpio_keys_button bfin_gpio_keys_table
[] = {
705 {BTN_0
, GPIO_PH7
, 1, "gpio-keys: BTN0"},
708 static struct gpio_keys_platform_data bfin_gpio_keys_data
= {
709 .buttons
= bfin_gpio_keys_table
,
710 .nbuttons
= ARRAY_SIZE(bfin_gpio_keys_table
),
713 static struct platform_device bfin_device_gpiokeys
= {
716 .platform_data
= &bfin_gpio_keys_data
,
721 static const unsigned int cclk_vlev_datasheet
[] =
724 * Internal VLEV BF54XSBBC1533
725 ****temporarily using these values until data sheet is updated
727 VRPAIR(VLEV_085
, 150000000),
728 VRPAIR(VLEV_090
, 250000000),
729 VRPAIR(VLEV_110
, 276000000),
730 VRPAIR(VLEV_115
, 301000000),
731 VRPAIR(VLEV_120
, 525000000),
732 VRPAIR(VLEV_125
, 550000000),
733 VRPAIR(VLEV_130
, 600000000),
736 static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data
= {
737 .tuple_tab
= cclk_vlev_datasheet
,
738 .tabsize
= ARRAY_SIZE(cclk_vlev_datasheet
),
739 .vr_settling_time
= 25 /* us */,
742 static struct platform_device bfin_dpmc
= {
745 .platform_data
= &bfin_dmpc_vreg_data
,
749 static struct platform_device
*cm_bf548_devices
[] __initdata
= {
753 #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
757 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
761 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
762 #ifdef CONFIG_BFIN_SIR0
765 #ifdef CONFIG_BFIN_SIR1
768 #ifdef CONFIG_BFIN_SIR2
771 #ifdef CONFIG_BFIN_SIR3
776 #if defined(CONFIG_FB_BF54X_LQ043) || defined(CONFIG_FB_BF54X_LQ043_MODULE)
780 #if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE)
784 #if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE)
788 #if defined(CONFIG_PATA_BF54X) || defined(CONFIG_PATA_BF54X_MODULE)
792 #if defined(CONFIG_MTD_NAND_BF5XX) || defined(CONFIG_MTD_NAND_BF5XX_MODULE)
796 #if defined(CONFIG_SDH_BFIN) || defined(CONFIG_SDH_BFIN_MODULE)
800 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
805 #if defined(CONFIG_KEYBOARD_BFIN) || defined(CONFIG_KEYBOARD_BFIN_MODULE)
809 #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
810 &i2c_bfin_twi0_device
,
811 #if !defined(CONFIG_BF542)
812 &i2c_bfin_twi1_device
,
816 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
817 &bfin_device_gpiokeys
,
820 #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
827 static int __init
cm_bf548_init(void)
829 printk(KERN_INFO
"%s(): registering device resources\n", __func__
);
830 platform_add_devices(cm_bf548_devices
, ARRAY_SIZE(cm_bf548_devices
));
832 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
833 spi_register_board_info(bf54x_spi_board_info
,
834 ARRAY_SIZE(bf54x_spi_board_info
));
840 arch_initcall(cm_bf548_init
);