2 * File: arch/blackfin/mach-bf527/boards/ezbrd.c
3 * Based on: arch/blackfin/mach-bf537/boards/stamp.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>
39 #include <linux/i2c.h>
40 #include <linux/irq.h>
41 #include <linux/interrupt.h>
42 #include <linux/usb/musb.h>
44 #include <asm/bfin5xx_spi.h>
45 #include <asm/reboot.h>
47 #include <asm/portmux.h>
49 #include <linux/spi/ad7877.h>
52 * Name the Board for the /proc/cpuinfo
54 const char bfin_board_name
[] = "ADI BF526-EZBRD";
57 * Driver needs to know address, irq and flag pin.
60 #if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE)
61 static struct resource musb_resources
[] = {
65 .flags
= IORESOURCE_MEM
,
67 [1] = { /* general IRQ */
68 .start
= IRQ_USB_INT0
,
70 .flags
= IORESOURCE_IRQ
| IORESOURCE_IRQ_HIGHLEVEL
,
75 .flags
= IORESOURCE_IRQ
| IORESOURCE_IRQ_HIGHLEVEL
,
79 static struct musb_hdrc_config musb_config
= {
86 .gpio_vrsel
= GPIO_PG13
,
89 static struct musb_hdrc_platform_data musb_plat
= {
90 #if defined(CONFIG_USB_MUSB_OTG)
92 #elif defined(CONFIG_USB_MUSB_HDRC_HCD)
94 #elif defined(CONFIG_USB_GADGET_MUSB_HDRC)
95 .mode
= MUSB_PERIPHERAL
,
97 .config
= &musb_config
,
100 static u64 musb_dmamask
= ~(u32
)0;
102 static struct platform_device musb_device
= {
106 .dma_mask
= &musb_dmamask
,
107 .coherent_dma_mask
= 0xffffffff,
108 .platform_data
= &musb_plat
,
110 .num_resources
= ARRAY_SIZE(musb_resources
),
111 .resource
= musb_resources
,
115 #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
116 static struct mtd_partition ezbrd_partitions
[] = {
118 .name
= "bootloader(nor)",
122 .name
= "linux kernel(nor)",
124 .offset
= MTDPART_OFS_APPEND
,
126 .name
= "file system(nor)",
127 .size
= MTDPART_SIZ_FULL
,
128 .offset
= MTDPART_OFS_APPEND
,
132 static struct physmap_flash_data ezbrd_flash_data
= {
134 .parts
= ezbrd_partitions
,
135 .nr_parts
= ARRAY_SIZE(ezbrd_partitions
),
138 static struct resource ezbrd_flash_resource
= {
141 .flags
= IORESOURCE_MEM
,
144 static struct platform_device ezbrd_flash_device
= {
145 .name
= "physmap-flash",
148 .platform_data
= &ezbrd_flash_data
,
151 .resource
= &ezbrd_flash_resource
,
155 #if defined(CONFIG_MTD_NAND_BF5XX) || defined(CONFIG_MTD_NAND_BF5XX_MODULE)
156 static struct mtd_partition partition_info
[] = {
158 .name
= "linux kernel(nand)",
160 .size
= 4 * 1024 * 1024,
163 .name
= "file system(nand)",
164 .offset
= MTDPART_OFS_APPEND
,
165 .size
= MTDPART_SIZ_FULL
,
169 static struct bf5xx_nand_platform bf5xx_nand_platform
= {
170 .page_size
= NFC_PG_SIZE_256
,
171 .data_width
= NFC_NWIDTH_8
,
172 .partitions
= partition_info
,
173 .nr_partitions
= ARRAY_SIZE(partition_info
),
178 static struct resource bf5xx_nand_resources
[] = {
181 .end
= NFC_DATA_RD
+ 2,
182 .flags
= IORESOURCE_MEM
,
187 .flags
= IORESOURCE_IRQ
,
191 static struct platform_device bf5xx_nand_device
= {
192 .name
= "bf5xx-nand",
194 .num_resources
= ARRAY_SIZE(bf5xx_nand_resources
),
195 .resource
= bf5xx_nand_resources
,
197 .platform_data
= &bf5xx_nand_platform
,
202 #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
203 static struct platform_device rtc_device
= {
210 #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
211 static struct platform_device bfin_mii_bus
= {
212 .name
= "bfin_mii_bus",
215 static struct platform_device bfin_mac_device
= {
217 .dev
.platform_data
= &bfin_mii_bus
,
221 #if defined(CONFIG_MTD_M25P80) \
222 || defined(CONFIG_MTD_M25P80_MODULE)
223 static struct mtd_partition bfin_spi_flash_partitions
[] = {
225 .name
= "bootloader(spi)",
228 .mask_flags
= MTD_CAP_ROM
230 .name
= "linux kernel(spi)",
231 .size
= MTDPART_SIZ_FULL
,
232 .offset
= MTDPART_OFS_APPEND
,
236 static struct flash_platform_data bfin_spi_flash_data
= {
238 .parts
= bfin_spi_flash_partitions
,
239 .nr_parts
= ARRAY_SIZE(bfin_spi_flash_partitions
),
240 .type
= "sst25wf040",
243 /* SPI flash chip (sst25wf040) */
244 static struct bfin5xx_spi_chip spi_flash_chip_info
= {
245 .enable_dma
= 0, /* use dma transfer with this chip*/
250 #if defined(CONFIG_BFIN_SPI_ADC) \
251 || defined(CONFIG_BFIN_SPI_ADC_MODULE)
253 static struct bfin5xx_spi_chip spi_adc_chip_info
= {
254 .enable_dma
= 1, /* use dma transfer with this chip*/
259 #if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
260 static struct bfin5xx_spi_chip mmc_spi_chip_info
= {
266 #if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
267 static struct bfin5xx_spi_chip spi_ad7877_chip_info
= {
272 static const struct ad7877_platform_data bfin_ad7877_ts_info
= {
274 .vref_delay_usecs
= 50, /* internal, no capacitor */
277 .pressure_max
= 1000,
279 .stopacq_polarity
= 1,
280 .first_conversion_delay
= 3,
281 .acquisition_time
= 1,
283 .pen_down_acc_interval
= 1,
287 #if defined(CONFIG_TOUCHSCREEN_AD7879) || defined(CONFIG_TOUCHSCREEN_AD7879_MODULE)
288 #include <linux/spi/ad7879.h>
289 static const struct ad7879_platform_data bfin_ad7879_ts_info
= {
290 .model
= 7879, /* Model = AD7879 */
291 .x_plate_ohms
= 620, /* 620 Ohm from the touch datasheet */
292 .pressure_max
= 10000,
294 .first_conversion_delay
= 3, /* wait 512us before do a first conversion */
295 .acquisition_time
= 1, /* 4us acquisition time per sample */
296 .median
= 2, /* do 8 measurements */
297 .averaging
= 1, /* take the average of 4 middle samples */
298 .pen_down_acc_interval
= 255, /* 9.4 ms */
299 .gpio_output
= 1, /* configure AUX/VBAT/GPIO as GPIO output */
300 .gpio_default
= 1, /* During initialization set GPIO = HIGH */
304 #if defined(CONFIG_TOUCHSCREEN_AD7879_SPI) || defined(CONFIG_TOUCHSCREEN_AD7879_SPI_MODULE)
305 static struct bfin5xx_spi_chip spi_ad7879_chip_info
= {
311 #if defined(CONFIG_SND_SOC_WM8731) || defined(CONFIG_SND_SOC_WM8731_MODULE) \
312 && defined(CONFIG_SND_SOC_WM8731_SPI)
313 static struct bfin5xx_spi_chip spi_wm8731_chip_info
= {
319 #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
320 static struct bfin5xx_spi_chip spidev_chip_info
= {
326 #if defined(CONFIG_FB_BFIN_LQ035Q1) || defined(CONFIG_FB_BFIN_LQ035Q1_MODULE)
327 static struct bfin5xx_spi_chip lq035q1_spi_chip_info
= {
333 static struct spi_board_info bfin_spi_board_info
[] __initdata
= {
334 #if defined(CONFIG_MTD_M25P80) \
335 || defined(CONFIG_MTD_M25P80_MODULE)
337 /* the modalias must be the same as spi device driver name */
338 .modalias
= "m25p80", /* Name of spi_driver for this device */
339 .max_speed_hz
= 25000000, /* max spi clock (SCK) speed in HZ */
340 .bus_num
= 0, /* Framework bus number */
341 .chip_select
= 1, /* Framework chip select. On STAMP537 it is SPISSEL1*/
342 .platform_data
= &bfin_spi_flash_data
,
343 .controller_data
= &spi_flash_chip_info
,
348 #if defined(CONFIG_BFIN_SPI_ADC) \
349 || defined(CONFIG_BFIN_SPI_ADC_MODULE)
351 .modalias
= "bfin_spi_adc", /* Name of spi_driver for this device */
352 .max_speed_hz
= 6250000, /* max spi clock (SCK) speed in HZ */
353 .bus_num
= 0, /* Framework bus number */
354 .chip_select
= 1, /* Framework chip select. */
355 .platform_data
= NULL
, /* No spi_driver specific config */
356 .controller_data
= &spi_adc_chip_info
,
360 #if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
362 .modalias
= "mmc_spi",
363 .max_speed_hz
= 25000000, /* max spi clock (SCK) speed in HZ */
366 .controller_data
= &mmc_spi_chip_info
,
370 #if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
372 .modalias
= "ad7877",
373 .platform_data
= &bfin_ad7877_ts_info
,
375 .max_speed_hz
= 12500000, /* max spi clock (SCK) speed in HZ */
378 .controller_data
= &spi_ad7877_chip_info
,
381 #if defined(CONFIG_TOUCHSCREEN_AD7879_SPI) || defined(CONFIG_TOUCHSCREEN_AD7879_SPI_MODULE)
383 .modalias
= "ad7879",
384 .platform_data
= &bfin_ad7879_ts_info
,
386 .max_speed_hz
= 5000000, /* max spi clock (SCK) speed in HZ */
389 .controller_data
= &spi_ad7879_chip_info
,
390 .mode
= SPI_CPHA
| SPI_CPOL
,
393 #if defined(CONFIG_SND_SOC_WM8731) || defined(CONFIG_SND_SOC_WM8731_MODULE) \
394 && defined(CONFIG_SND_SOC_WM8731_SPI)
396 .modalias
= "wm8731",
397 .max_speed_hz
= 3125000, /* max spi clock (SCK) speed in HZ */
400 .controller_data
= &spi_wm8731_chip_info
,
404 #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
406 .modalias
= "spidev",
407 .max_speed_hz
= 3125000, /* max spi clock (SCK) speed in HZ */
410 .controller_data
= &spidev_chip_info
,
413 #if defined(CONFIG_FB_BFIN_LQ035Q1) || defined(CONFIG_FB_BFIN_LQ035Q1_MODULE)
415 .modalias
= "bfin-lq035q1-spi",
416 .max_speed_hz
= 20000000, /* max spi clock (SCK) speed in HZ */
419 .controller_data
= &lq035q1_spi_chip_info
,
420 .mode
= SPI_CPHA
| SPI_CPOL
,
425 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
426 /* SPI controller data */
427 static struct bfin5xx_spi_master bfin_spi0_info
= {
429 .enable_dma
= 1, /* master has the ability to do dma transfer */
430 .pin_req
= {P_SPI0_SCK
, P_SPI0_MISO
, P_SPI0_MOSI
, 0},
434 static struct resource bfin_spi0_resource
[] = {
436 .start
= SPI0_REGBASE
,
437 .end
= SPI0_REGBASE
+ 0xFF,
438 .flags
= IORESOURCE_MEM
,
443 .flags
= IORESOURCE_DMA
,
448 .flags
= IORESOURCE_IRQ
,
452 static struct platform_device bfin_spi0_device
= {
454 .id
= 0, /* Bus number */
455 .num_resources
= ARRAY_SIZE(bfin_spi0_resource
),
456 .resource
= bfin_spi0_resource
,
458 .platform_data
= &bfin_spi0_info
, /* Passed to driver */
461 #endif /* spi master and devices */
463 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
464 static struct resource bfin_uart_resources
[] = {
465 #ifdef CONFIG_SERIAL_BFIN_UART0
469 .flags
= IORESOURCE_MEM
,
472 #ifdef CONFIG_SERIAL_BFIN_UART1
476 .flags
= IORESOURCE_MEM
,
481 static struct platform_device bfin_uart_device
= {
484 .num_resources
= ARRAY_SIZE(bfin_uart_resources
),
485 .resource
= bfin_uart_resources
,
489 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
490 #ifdef CONFIG_BFIN_SIR0
491 static struct resource bfin_sir0_resources
[] = {
495 .flags
= IORESOURCE_MEM
,
498 .start
= IRQ_UART0_RX
,
499 .end
= IRQ_UART0_RX
+1,
500 .flags
= IORESOURCE_IRQ
,
503 .start
= CH_UART0_RX
,
504 .end
= CH_UART0_RX
+1,
505 .flags
= IORESOURCE_DMA
,
509 static struct platform_device bfin_sir0_device
= {
512 .num_resources
= ARRAY_SIZE(bfin_sir0_resources
),
513 .resource
= bfin_sir0_resources
,
516 #ifdef CONFIG_BFIN_SIR1
517 static struct resource bfin_sir1_resources
[] = {
521 .flags
= IORESOURCE_MEM
,
524 .start
= IRQ_UART1_RX
,
525 .end
= IRQ_UART1_RX
+1,
526 .flags
= IORESOURCE_IRQ
,
529 .start
= CH_UART1_RX
,
530 .end
= CH_UART1_RX
+1,
531 .flags
= IORESOURCE_DMA
,
535 static struct platform_device bfin_sir1_device
= {
538 .num_resources
= ARRAY_SIZE(bfin_sir1_resources
),
539 .resource
= bfin_sir1_resources
,
544 #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
545 static struct resource bfin_twi0_resource
[] = {
547 .start
= TWI0_REGBASE
,
549 .flags
= IORESOURCE_MEM
,
554 .flags
= IORESOURCE_IRQ
,
558 static struct platform_device i2c_bfin_twi_device
= {
559 .name
= "i2c-bfin-twi",
561 .num_resources
= ARRAY_SIZE(bfin_twi0_resource
),
562 .resource
= bfin_twi0_resource
,
566 static struct i2c_board_info __initdata bfin_i2c_board_info
[] = {
567 #if defined(CONFIG_BFIN_TWI_LCD) || defined(CONFIG_BFIN_TWI_LCD_MODULE)
569 I2C_BOARD_INFO("pcf8574_lcd", 0x22),
572 #if defined(CONFIG_INPUT_PCF8574) || defined(CONFIG_INPUT_PCF8574_MODULE)
574 I2C_BOARD_INFO("pcf8574_keypad", 0x27),
580 #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
581 static struct platform_device bfin_sport0_uart_device
= {
582 .name
= "bfin-sport-uart",
586 static struct platform_device bfin_sport1_uart_device
= {
587 .name
= "bfin-sport-uart",
592 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
593 #include <linux/input.h>
594 #include <linux/gpio_keys.h>
596 static struct gpio_keys_button bfin_gpio_keys_table
[] = {
597 {BTN_0
, GPIO_PG0
, 1, "gpio-keys: BTN0"},
598 {BTN_1
, GPIO_PG13
, 1, "gpio-keys: BTN1"},
601 static struct gpio_keys_platform_data bfin_gpio_keys_data
= {
602 .buttons
= bfin_gpio_keys_table
,
603 .nbuttons
= ARRAY_SIZE(bfin_gpio_keys_table
),
606 static struct platform_device bfin_device_gpiokeys
= {
609 .platform_data
= &bfin_gpio_keys_data
,
614 static struct resource bfin_gpios_resources
= {
616 .end
= MAX_BLACKFIN_GPIOS
- 1,
617 .flags
= IORESOURCE_IRQ
,
620 static struct platform_device bfin_gpios_device
= {
621 .name
= "simple-gpio",
624 .resource
= &bfin_gpios_resources
,
627 static const unsigned int cclk_vlev_datasheet
[] =
629 VRPAIR(VLEV_100
, 400000000),
630 VRPAIR(VLEV_105
, 426000000),
631 VRPAIR(VLEV_110
, 500000000),
632 VRPAIR(VLEV_115
, 533000000),
633 VRPAIR(VLEV_120
, 600000000),
636 static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data
= {
637 .tuple_tab
= cclk_vlev_datasheet
,
638 .tabsize
= ARRAY_SIZE(cclk_vlev_datasheet
),
639 .vr_settling_time
= 25 /* us */,
642 static struct platform_device bfin_dpmc
= {
645 .platform_data
= &bfin_dmpc_vreg_data
,
649 #if defined(CONFIG_FB_BFIN_LQ035Q1) || defined(CONFIG_FB_BFIN_LQ035Q1_MODULE)
650 #include <asm/bfin-lq035q1.h>
652 static struct bfin_lq035q1fb_disp_info bfin_lq035q1_data
= {
653 .mode
= LQ035_NORM
| LQ035_RGB
| LQ035_RL
| LQ035_TB
,
655 .gpio_bl
= GPIO_PG12
,
658 static struct resource bfin_lq035q1_resources
[] = {
660 .start
= IRQ_PPI_ERROR
,
661 .end
= IRQ_PPI_ERROR
,
662 .flags
= IORESOURCE_IRQ
,
666 static struct platform_device bfin_lq035q1_device
= {
667 .name
= "bfin-lq035q1",
669 .num_resources
= ARRAY_SIZE(bfin_lq035q1_resources
),
670 .resource
= bfin_lq035q1_resources
,
672 .platform_data
= &bfin_lq035q1_data
,
677 static struct platform_device
*stamp_devices
[] __initdata
= {
681 #if defined(CONFIG_MTD_NAND_BF5XX) || defined(CONFIG_MTD_NAND_BF5XX_MODULE)
685 #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
689 #if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE)
693 #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
698 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
702 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
706 #if defined(CONFIG_FB_BFIN_LQ035Q1) || defined(CONFIG_FB_BFIN_LQ035Q1_MODULE)
707 &bfin_lq035q1_device
,
710 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
711 #ifdef CONFIG_BFIN_SIR0
714 #ifdef CONFIG_BFIN_SIR1
719 #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
720 &i2c_bfin_twi_device
,
723 #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
724 &bfin_sport0_uart_device
,
725 &bfin_sport1_uart_device
,
728 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
729 &bfin_device_gpiokeys
,
732 #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
739 static int __init
ezbrd_init(void)
741 printk(KERN_INFO
"%s(): registering device resources\n", __func__
);
742 i2c_register_board_info(0, bfin_i2c_board_info
,
743 ARRAY_SIZE(bfin_i2c_board_info
));
744 platform_add_devices(stamp_devices
, ARRAY_SIZE(stamp_devices
));
745 spi_register_board_info(bfin_spi_board_info
, ARRAY_SIZE(bfin_spi_board_info
));
749 arch_initcall(ezbrd_init
);
751 void native_machine_restart(char *cmd
)
753 /* workaround reboot hang when booting from SPI */
754 if ((bfin_read_SYSCR() & 0x7) == 0x3)
755 bfin_reset_boot_spi_cs(P_DEFAULT_BOOT_SPI_CS
);
758 void bfin_get_ether_addr(char *addr
)
760 /* the MAC is stored in OTP memory page 0xDF */
763 u32 (*otp_read
)(u32 page
, u32 flags
, u64
*page_content
) = (void *)0xEF00001A;
765 ret
= otp_read(0xDF, 0x00, &otp_mac
);
767 char *otp_mac_p
= (char *)&otp_mac
;
768 for (ret
= 0; ret
< 6; ++ret
)
769 addr
[ret
] = otp_mac_p
[5 - ret
];
772 EXPORT_SYMBOL(bfin_get_ether_addr
);