2 * File: arch/blackfin/mach-bf548/boards/ezkit.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-2007 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/i2c.h>
40 #include <linux/interrupt.h>
41 #if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE)
42 #include <linux/usb/musb.h>
44 #include <asm/bfin5xx_spi.h>
50 #include <asm/portmux.h>
51 #include <asm/mach/bf54x_keys.h>
52 #include <linux/input.h>
53 #include <linux/spi/ad7877.h>
56 * Name the Board for the /proc/cpuinfo
58 const char bfin_board_name
[] = "ADSP-BF548-EZKIT";
61 * Driver needs to know address, irq and flag pin.
64 #if defined(CONFIG_FB_BF54X_LQ043) || defined(CONFIG_FB_BF54X_LQ043_MODULE)
66 #include <asm/mach/bf54x-lq043.h>
68 static struct bfin_bf54xfb_mach_info bf54x_lq043_data
= {
71 .xres
= {480, 480, 480},
72 .yres
= {272, 272, 272},
77 static struct resource bf54x_lq043_resources
[] = {
79 .start
= IRQ_EPPI0_ERR
,
81 .flags
= IORESOURCE_IRQ
,
85 static struct platform_device bf54x_lq043_device
= {
86 .name
= "bf54x-lq043",
88 .num_resources
= ARRAY_SIZE(bf54x_lq043_resources
),
89 .resource
= bf54x_lq043_resources
,
91 .platform_data
= &bf54x_lq043_data
,
96 #if defined(CONFIG_KEYBOARD_BFIN) || defined(CONFIG_KEYBOARD_BFIN_MODULE)
97 static const unsigned int bf548_keymap
[] = {
98 KEYVAL(0, 0, KEY_ENTER
),
99 KEYVAL(0, 1, KEY_HELP
),
101 KEYVAL(0, 3, KEY_BACKSPACE
),
102 KEYVAL(1, 0, KEY_TAB
),
106 KEYVAL(2, 0, KEY_DOWN
),
110 KEYVAL(3, 0, KEY_UP
),
116 static struct bfin_kpad_platform_data bf54x_kpad_data
= {
119 .keymap
= bf548_keymap
,
120 .keymapsize
= ARRAY_SIZE(bf548_keymap
),
122 .debounce_time
= 5000, /* ns (5ms) */
123 .coldrive_time
= 1000, /* ns (1ms) */
124 .keyup_test_interval
= 50, /* ms (50ms) */
127 static struct resource bf54x_kpad_resources
[] = {
131 .flags
= IORESOURCE_IRQ
,
135 static struct platform_device bf54x_kpad_device
= {
136 .name
= "bf54x-keys",
138 .num_resources
= ARRAY_SIZE(bf54x_kpad_resources
),
139 .resource
= bf54x_kpad_resources
,
141 .platform_data
= &bf54x_kpad_data
,
146 #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
147 static struct platform_device rtc_device
= {
153 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
154 static struct resource bfin_uart_resources
[] = {
155 #ifdef CONFIG_SERIAL_BFIN_UART0
159 .flags
= IORESOURCE_MEM
,
162 #ifdef CONFIG_SERIAL_BFIN_UART1
166 .flags
= IORESOURCE_MEM
,
169 #ifdef CONFIG_SERIAL_BFIN_UART2
173 .flags
= IORESOURCE_MEM
,
176 #ifdef CONFIG_SERIAL_BFIN_UART3
184 static struct platform_device bfin_uart_device
= {
187 .num_resources
= ARRAY_SIZE(bfin_uart_resources
),
188 .resource
= bfin_uart_resources
,
192 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
193 static struct resource bfin_sir_resources
[] = {
194 #ifdef CONFIG_BFIN_SIR0
198 .flags
= IORESOURCE_MEM
,
201 #ifdef CONFIG_BFIN_SIR1
205 .flags
= IORESOURCE_MEM
,
208 #ifdef CONFIG_BFIN_SIR2
212 .flags
= IORESOURCE_MEM
,
215 #ifdef CONFIG_BFIN_SIR3
219 .flags
= IORESOURCE_MEM
,
224 static struct platform_device bfin_sir_device
= {
227 .num_resources
= ARRAY_SIZE(bfin_sir_resources
),
228 .resource
= bfin_sir_resources
,
232 #if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE)
233 static struct resource smsc911x_resources
[] = {
235 .name
= "smsc911x-memory",
237 .end
= 0x24000000 + 0xFF,
238 .flags
= IORESOURCE_MEM
,
243 .flags
= IORESOURCE_IRQ
| IORESOURCE_IRQ_LOWLEVEL
,
246 static struct platform_device smsc911x_device
= {
249 .num_resources
= ARRAY_SIZE(smsc911x_resources
),
250 .resource
= smsc911x_resources
,
254 #if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE)
255 static struct resource musb_resources
[] = {
259 .flags
= IORESOURCE_MEM
,
261 [1] = { /* general IRQ */
262 .start
= IRQ_USB_INT0
,
264 .flags
= IORESOURCE_IRQ
| IORESOURCE_IRQ_HIGHLEVEL
,
266 [2] = { /* DMA IRQ */
267 .start
= IRQ_USB_DMA
,
269 .flags
= IORESOURCE_IRQ
| IORESOURCE_IRQ_HIGHLEVEL
,
273 static struct musb_hdrc_platform_data musb_plat
= {
274 #if defined(CONFIG_USB_MUSB_OTG)
276 #elif defined(CONFIG_USB_MUSB_HDRC_HCD)
278 #elif defined(CONFIG_USB_GADGET_MUSB_HDRC)
279 .mode
= MUSB_PERIPHERAL
,
284 static u64 musb_dmamask
= ~(u32
)0;
286 static struct platform_device musb_device
= {
290 .dma_mask
= &musb_dmamask
,
291 .coherent_dma_mask
= 0xffffffff,
292 .platform_data
= &musb_plat
,
294 .num_resources
= ARRAY_SIZE(musb_resources
),
295 .resource
= musb_resources
,
299 #if defined(CONFIG_PATA_BF54X) || defined(CONFIG_PATA_BF54X_MODULE)
300 static struct resource bfin_atapi_resources
[] = {
304 .flags
= IORESOURCE_MEM
,
307 .start
= IRQ_ATAPI_ERR
,
308 .end
= IRQ_ATAPI_ERR
,
309 .flags
= IORESOURCE_IRQ
,
313 static struct platform_device bfin_atapi_device
= {
314 .name
= "pata-bf54x",
316 .num_resources
= ARRAY_SIZE(bfin_atapi_resources
),
317 .resource
= bfin_atapi_resources
,
321 #if defined(CONFIG_MTD_NAND_BF5XX) || defined(CONFIG_MTD_NAND_BF5XX_MODULE)
322 static struct mtd_partition partition_info
[] = {
324 .name
= "Linux Kernel",
329 .name
= "File System",
330 .offset
= MTDPART_OFS_APPEND
,
331 .size
= MTDPART_SIZ_FULL
,
335 static struct bf5xx_nand_platform bf5xx_nand_platform
= {
336 .page_size
= NFC_PG_SIZE_256
,
337 .data_width
= NFC_NWIDTH_8
,
338 .partitions
= partition_info
,
339 .nr_partitions
= ARRAY_SIZE(partition_info
),
344 static struct resource bf5xx_nand_resources
[] = {
348 .flags
= IORESOURCE_MEM
,
353 .flags
= IORESOURCE_IRQ
,
357 static struct platform_device bf5xx_nand_device
= {
358 .name
= "bf5xx-nand",
360 .num_resources
= ARRAY_SIZE(bf5xx_nand_resources
),
361 .resource
= bf5xx_nand_resources
,
363 .platform_data
= &bf5xx_nand_platform
,
368 #if defined(CONFIG_SDH_BFIN) || defined(CONFIG_SDH_BFIN_MODULE)
369 static struct platform_device bf54x_sdh_device
= {
375 #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
376 static struct mtd_partition ezkit_partitions
[] = {
378 .name
= "Bootloader",
384 .offset
= MTDPART_OFS_APPEND
,
387 .size
= MTDPART_SIZ_FULL
,
388 .offset
= MTDPART_OFS_APPEND
,
392 static struct physmap_flash_data ezkit_flash_data
= {
394 .parts
= ezkit_partitions
,
395 .nr_parts
= ARRAY_SIZE(ezkit_partitions
),
398 static struct resource ezkit_flash_resource
= {
401 .flags
= IORESOURCE_MEM
,
404 static struct platform_device ezkit_flash_device
= {
405 .name
= "physmap-flash",
408 .platform_data
= &ezkit_flash_data
,
411 .resource
= &ezkit_flash_resource
,
415 #if defined(CONFIG_MTD_M25P80) \
416 || defined(CONFIG_MTD_M25P80_MODULE)
417 /* SPI flash chip (m25p16) */
418 static struct mtd_partition bfin_spi_flash_partitions
[] = {
420 .name
= "bootloader",
423 .mask_flags
= MTD_CAP_ROM
425 .name
= "linux kernel",
426 .size
= MTDPART_SIZ_FULL
,
427 .offset
= MTDPART_OFS_APPEND
,
431 static struct flash_platform_data bfin_spi_flash_data
= {
433 .parts
= bfin_spi_flash_partitions
,
434 .nr_parts
= ARRAY_SIZE(bfin_spi_flash_partitions
),
438 static struct bfin5xx_spi_chip spi_flash_chip_info
= {
439 .enable_dma
= 0, /* use dma transfer with this chip*/
441 .cs_change_per_word
= 0,
445 #if defined(CONFIG_SND_BLACKFIN_AD1836) \
446 || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
447 static struct bfin5xx_spi_chip ad1836_spi_chip_info
= {
453 #if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
454 static struct bfin5xx_spi_chip spi_ad7877_chip_info
= {
455 .cs_change_per_word
= 0,
460 static const struct ad7877_platform_data bfin_ad7877_ts_info
= {
462 .vref_delay_usecs
= 50, /* internal, no capacitor */
465 .pressure_max
= 1000,
467 .stopacq_polarity
= 1,
468 .first_conversion_delay
= 3,
469 .acquisition_time
= 1,
471 .pen_down_acc_interval
= 1,
475 #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
476 static struct bfin5xx_spi_chip spidev_chip_info
= {
482 static struct spi_board_info bfin_spi_board_info
[] __initdata
= {
483 #if defined(CONFIG_MTD_M25P80) \
484 || defined(CONFIG_MTD_M25P80_MODULE)
486 /* the modalias must be the same as spi device driver name */
487 .modalias
= "m25p80", /* Name of spi_driver for this device */
488 .max_speed_hz
= 25000000, /* max spi clock (SCK) speed in HZ */
489 .bus_num
= 0, /* Framework bus number */
490 .chip_select
= 1, /* SPI_SSEL1*/
491 .platform_data
= &bfin_spi_flash_data
,
492 .controller_data
= &spi_flash_chip_info
,
496 #if defined(CONFIG_SND_BLACKFIN_AD1836) \
497 || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
499 .modalias
= "ad1836-spi",
500 .max_speed_hz
= 3125000, /* max spi clock (SCK) speed in HZ */
502 .chip_select
= CONFIG_SND_BLACKFIN_SPI_PFBIT
,
503 .controller_data
= &ad1836_spi_chip_info
,
506 #if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
508 .modalias
= "ad7877",
509 .platform_data
= &bfin_ad7877_ts_info
,
511 .max_speed_hz
= 12500000, /* max spi clock (SCK) speed in HZ */
514 .controller_data
= &spi_ad7877_chip_info
,
517 #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
519 .modalias
= "spidev",
520 .max_speed_hz
= 3125000, /* max spi clock (SCK) speed in HZ */
523 .controller_data
= &spidev_chip_info
,
528 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
530 static struct resource bfin_spi0_resource
[] = {
532 .start
= SPI0_REGBASE
,
533 .end
= SPI0_REGBASE
+ 0xFF,
534 .flags
= IORESOURCE_MEM
,
539 .flags
= IORESOURCE_IRQ
,
544 static struct resource bfin_spi1_resource
[] = {
546 .start
= SPI1_REGBASE
,
547 .end
= SPI1_REGBASE
+ 0xFF,
548 .flags
= IORESOURCE_MEM
,
553 .flags
= IORESOURCE_IRQ
,
557 /* SPI controller data */
558 static struct bfin5xx_spi_master bf54x_spi_master_info0
= {
560 .enable_dma
= 1, /* master has the ability to do dma transfer */
561 .pin_req
= {P_SPI0_SCK
, P_SPI0_MISO
, P_SPI0_MOSI
, 0},
564 static struct platform_device bf54x_spi_master0
= {
566 .id
= 0, /* Bus number */
567 .num_resources
= ARRAY_SIZE(bfin_spi0_resource
),
568 .resource
= bfin_spi0_resource
,
570 .platform_data
= &bf54x_spi_master_info0
, /* Passed to driver */
574 static struct bfin5xx_spi_master bf54x_spi_master_info1
= {
576 .enable_dma
= 1, /* master has the ability to do dma transfer */
577 .pin_req
= {P_SPI1_SCK
, P_SPI1_MISO
, P_SPI1_MOSI
, 0},
580 static struct platform_device bf54x_spi_master1
= {
582 .id
= 1, /* Bus number */
583 .num_resources
= ARRAY_SIZE(bfin_spi1_resource
),
584 .resource
= bfin_spi1_resource
,
586 .platform_data
= &bf54x_spi_master_info1
, /* Passed to driver */
589 #endif /* spi master and devices */
591 #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
592 static struct resource bfin_twi0_resource
[] = {
594 .start
= TWI0_REGBASE
,
595 .end
= TWI0_REGBASE
+ 0xFF,
596 .flags
= IORESOURCE_MEM
,
601 .flags
= IORESOURCE_IRQ
,
605 static struct platform_device i2c_bfin_twi0_device
= {
606 .name
= "i2c-bfin-twi",
608 .num_resources
= ARRAY_SIZE(bfin_twi0_resource
),
609 .resource
= bfin_twi0_resource
,
612 #if !defined(CONFIG_BF542) /* The BF542 only has 1 TWI */
613 static struct resource bfin_twi1_resource
[] = {
615 .start
= TWI1_REGBASE
,
616 .end
= TWI1_REGBASE
+ 0xFF,
617 .flags
= IORESOURCE_MEM
,
622 .flags
= IORESOURCE_IRQ
,
626 static struct platform_device i2c_bfin_twi1_device
= {
627 .name
= "i2c-bfin-twi",
629 .num_resources
= ARRAY_SIZE(bfin_twi1_resource
),
630 .resource
= bfin_twi1_resource
,
635 #ifdef CONFIG_I2C_BOARDINFO
636 static struct i2c_board_info __initdata bfin_i2c_board_info0
[] = {
639 #if !defined(CONFIG_BF542) /* The BF542 only has 1 TWI */
640 static struct i2c_board_info __initdata bfin_i2c_board_info1
[] = {
641 #if defined(CONFIG_TWI_LCD) || defined(CONFIG_TWI_LCD_MODULE)
643 I2C_BOARD_INFO("pcf8574_lcd", 0x22),
646 #if defined(CONFIG_TWI_KEYPAD) || defined(CONFIG_TWI_KEYPAD_MODULE)
648 I2C_BOARD_INFO("pcf8574_keypad", 0x27),
656 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
657 #include <linux/gpio_keys.h>
659 static struct gpio_keys_button bfin_gpio_keys_table
[] = {
660 {BTN_0
, GPIO_PB8
, 1, "gpio-keys: BTN0"},
661 {BTN_1
, GPIO_PB9
, 1, "gpio-keys: BTN1"},
662 {BTN_2
, GPIO_PB10
, 1, "gpio-keys: BTN2"},
663 {BTN_3
, GPIO_PB11
, 1, "gpio-keys: BTN3"},
666 static struct gpio_keys_platform_data bfin_gpio_keys_data
= {
667 .buttons
= bfin_gpio_keys_table
,
668 .nbuttons
= ARRAY_SIZE(bfin_gpio_keys_table
),
671 static struct platform_device bfin_device_gpiokeys
= {
674 .platform_data
= &bfin_gpio_keys_data
,
679 static struct resource bfin_gpios_resources
= {
681 .end
= MAX_BLACKFIN_GPIOS
- 1,
682 .flags
= IORESOURCE_IRQ
,
685 static struct platform_device bfin_gpios_device
= {
686 .name
= "simple-gpio",
689 .resource
= &bfin_gpios_resources
,
692 static const unsigned int cclk_vlev_datasheet
[] =
695 * Internal VLEV BF54XSBBC1533
696 ****temporarily using these values until data sheet is updated
698 VRPAIR(VLEV_085
, 150000000),
699 VRPAIR(VLEV_090
, 250000000),
700 VRPAIR(VLEV_110
, 276000000),
701 VRPAIR(VLEV_115
, 301000000),
702 VRPAIR(VLEV_120
, 525000000),
703 VRPAIR(VLEV_125
, 550000000),
704 VRPAIR(VLEV_130
, 600000000),
707 static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data
= {
708 .tuple_tab
= cclk_vlev_datasheet
,
709 .tabsize
= ARRAY_SIZE(cclk_vlev_datasheet
),
710 .vr_settling_time
= 25 /* us */,
713 static struct platform_device bfin_dpmc
= {
716 .platform_data
= &bfin_dmpc_vreg_data
,
720 static struct platform_device
*ezkit_devices
[] __initdata
= {
724 #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
728 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
732 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
736 #if defined(CONFIG_FB_BF54X_LQ043) || defined(CONFIG_FB_BF54X_LQ043_MODULE)
740 #if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE)
744 #if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE)
748 #if defined(CONFIG_PATA_BF54X) || defined(CONFIG_PATA_BF54X_MODULE)
752 #if defined(CONFIG_MTD_NAND_BF5XX) || defined(CONFIG_MTD_NAND_BF5XX_MODULE)
756 #if defined(CONFIG_SDH_BFIN) || defined(CONFIG_SDH_BFIN_MODULE)
760 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
765 #if defined(CONFIG_KEYBOARD_BFIN) || defined(CONFIG_KEYBOARD_BFIN_MODULE)
769 #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
770 &i2c_bfin_twi0_device
,
771 #if !defined(CONFIG_BF542)
772 &i2c_bfin_twi1_device
,
776 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
777 &bfin_device_gpiokeys
,
782 #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
787 static int __init
ezkit_init(void)
789 printk(KERN_INFO
"%s(): registering device resources\n", __func__
);
791 #ifdef CONFIG_I2C_BOARDINFO
792 i2c_register_board_info(0, bfin_i2c_board_info0
,
793 ARRAY_SIZE(bfin_i2c_board_info0
));
794 #if !defined(CONFIG_BF542) /* The BF542 only has 1 TWI */
795 i2c_register_board_info(1, bfin_i2c_board_info1
,
796 ARRAY_SIZE(bfin_i2c_board_info1
));
800 platform_add_devices(ezkit_devices
, ARRAY_SIZE(ezkit_devices
));
802 spi_register_board_info(bfin_spi_board_info
, ARRAY_SIZE(bfin_spi_board_info
));
807 arch_initcall(ezkit_init
);