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_mac_device = {
216 #if defined(CONFIG_MTD_M25P80) \
217 || defined(CONFIG_MTD_M25P80_MODULE)
218 static struct mtd_partition bfin_spi_flash_partitions[] = {
220 .name = "bootloader(spi)",
223 .mask_flags = MTD_CAP_ROM
225 .name = "linux kernel(spi)",
226 .size = MTDPART_SIZ_FULL,
227 .offset = MTDPART_OFS_APPEND,
231 static struct flash_platform_data bfin_spi_flash_data = {
233 .parts = bfin_spi_flash_partitions,
234 .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
238 /* SPI flash chip (m25p64) */
239 static struct bfin5xx_spi_chip spi_flash_chip_info = {
240 .enable_dma = 0, /* use dma transfer with this chip*/
245 #if defined(CONFIG_SPI_ADC_BF533) \
246 || defined(CONFIG_SPI_ADC_BF533_MODULE)
248 static struct bfin5xx_spi_chip spi_adc_chip_info = {
249 .enable_dma = 1, /* use dma transfer with this chip*/
254 #if defined(CONFIG_SPI_MMC) || defined(CONFIG_SPI_MMC_MODULE)
255 static struct bfin5xx_spi_chip spi_mmc_chip_info = {
261 #if defined(CONFIG_PBX)
262 static struct bfin5xx_spi_chip spi_si3xxx_chip_info = {
263 .ctl_reg = 0x4, /* send zero */
266 .cs_change_per_word = 1,
270 #if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
271 static struct bfin5xx_spi_chip spi_ad7877_chip_info = {
276 static const struct ad7877_platform_data bfin_ad7877_ts_info = {
278 .vref_delay_usecs = 50, /* internal, no capacitor */
281 .pressure_max = 1000,
283 .stopacq_polarity = 1,
284 .first_conversion_delay = 3,
285 .acquisition_time = 1,
287 .pen_down_acc_interval = 1,
291 #if defined(CONFIG_SND_SOC_WM8731) || defined(CONFIG_SND_SOC_WM8731_MODULE) \
292 && defined(CONFIG_SND_SOC_WM8731_SPI)
293 static struct bfin5xx_spi_chip spi_wm8731_chip_info = {
299 #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
300 static struct bfin5xx_spi_chip spidev_chip_info = {
306 #if defined(CONFIG_FB_BFIN_LQ035Q1) || defined(CONFIG_FB_BFIN_LQ035Q1_MODULE)
307 static struct bfin5xx_spi_chip lq035q1_spi_chip_info = {
313 static struct spi_board_info bfin_spi_board_info[] __initdata = {
314 #if defined(CONFIG_MTD_M25P80) \
315 || defined(CONFIG_MTD_M25P80_MODULE)
317 /* the modalias must be the same as spi device driver name */
318 .modalias = "m25p80", /* Name of spi_driver for this device */
319 .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
320 .bus_num = 0, /* Framework bus number */
321 .chip_select = 1, /* Framework chip select. On STAMP537 it is SPISSEL1*/
322 .platform_data = &bfin_spi_flash_data,
323 .controller_data = &spi_flash_chip_info,
328 #if defined(CONFIG_SPI_ADC_BF533) \
329 || defined(CONFIG_SPI_ADC_BF533_MODULE)
331 .modalias = "bfin_spi_adc", /* Name of spi_driver for this device */
332 .max_speed_hz = 6250000, /* max spi clock (SCK) speed in HZ */
333 .bus_num = 0, /* Framework bus number */
334 .chip_select = 1, /* Framework chip select. */
335 .platform_data = NULL, /* No spi_driver specific config */
336 .controller_data = &spi_adc_chip_info,
340 #if defined(CONFIG_SPI_MMC) || defined(CONFIG_SPI_MMC_MODULE)
342 .modalias = "spi_mmc_dummy",
343 .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
346 .platform_data = NULL,
347 .controller_data = &spi_mmc_chip_info,
351 .modalias = "spi_mmc",
352 .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
354 .chip_select = CONFIG_SPI_MMC_CS_CHAN,
355 .platform_data = NULL,
356 .controller_data = &spi_mmc_chip_info,
360 #if defined(CONFIG_PBX)
362 .modalias = "fxs-spi",
363 .max_speed_hz = 12500000, /* max spi clock (SCK) speed in HZ */
365 .chip_select = 8 - CONFIG_J11_JUMPER,
366 .controller_data = &spi_si3xxx_chip_info,
370 .modalias = "fxo-spi",
371 .max_speed_hz = 12500000, /* max spi clock (SCK) speed in HZ */
373 .chip_select = 8 - CONFIG_J19_JUMPER,
374 .controller_data = &spi_si3xxx_chip_info,
378 #if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
380 .modalias = "ad7877",
381 .platform_data = &bfin_ad7877_ts_info,
383 .max_speed_hz = 12500000, /* max spi clock (SCK) speed in HZ */
386 .controller_data = &spi_ad7877_chip_info,
389 #if defined(CONFIG_SND_SOC_WM8731) || defined(CONFIG_SND_SOC_WM8731_MODULE) \
390 && defined(CONFIG_SND_SOC_WM8731_SPI)
392 .modalias = "wm8731",
393 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
396 .controller_data = &spi_wm8731_chip_info,
400 #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
402 .modalias = "spidev",
403 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
406 .controller_data = &spidev_chip_info,
409 #if defined(CONFIG_FB_BFIN_LQ035Q1) || defined(CONFIG_FB_BFIN_LQ035Q1_MODULE)
411 .modalias = "bfin-lq035q1-spi",
412 .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */
415 .controller_data = &lq035q1_spi_chip_info,
416 .mode = SPI_CPHA | SPI_CPOL,
421 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
422 /* SPI controller data */
423 static struct bfin5xx_spi_master bfin_spi0_info = {
425 .enable_dma = 1, /* master has the ability to do dma transfer */
426 .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
430 static struct resource bfin_spi0_resource[] = {
432 .start = SPI0_REGBASE,
433 .end = SPI0_REGBASE + 0xFF,
434 .flags = IORESOURCE_MEM,
439 .flags = IORESOURCE_IRQ,
443 static struct platform_device bfin_spi0_device = {
445 .id = 0, /* Bus number */
446 .num_resources = ARRAY_SIZE(bfin_spi0_resource),
447 .resource = bfin_spi0_resource,
449 .platform_data = &bfin_spi0_info, /* Passed to driver */
452 #endif /* spi master and devices */
454 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
455 static struct resource bfin_uart_resources[] = {
456 #ifdef CONFIG_SERIAL_BFIN_UART0
460 .flags = IORESOURCE_MEM,
463 #ifdef CONFIG_SERIAL_BFIN_UART1
467 .flags = IORESOURCE_MEM,
472 static struct platform_device bfin_uart_device = {
475 .num_resources = ARRAY_SIZE(bfin_uart_resources),
476 .resource = bfin_uart_resources,
480 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
481 #ifdef CONFIG_BFIN_SIR0
482 static struct resource bfin_sir0_resources[] = {
486 .flags = IORESOURCE_MEM,
489 .start = IRQ_UART0_RX,
490 .end = IRQ_UART0_RX+1,
491 .flags = IORESOURCE_IRQ,
494 .start = CH_UART0_RX,
495 .end = CH_UART0_RX+1,
496 .flags = IORESOURCE_DMA,
500 static struct platform_device bfin_sir0_device = {
503 .num_resources = ARRAY_SIZE(bfin_sir0_resources),
504 .resource = bfin_sir0_resources,
507 #ifdef CONFIG_BFIN_SIR1
508 static struct resource bfin_sir1_resources[] = {
512 .flags = IORESOURCE_MEM,
515 .start = IRQ_UART1_RX,
516 .end = IRQ_UART1_RX+1,
517 .flags = IORESOURCE_IRQ,
520 .start = CH_UART1_RX,
521 .end = CH_UART1_RX+1,
522 .flags = IORESOURCE_DMA,
526 static struct platform_device bfin_sir1_device = {
529 .num_resources = ARRAY_SIZE(bfin_sir1_resources),
530 .resource = bfin_sir1_resources,
535 #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
536 static struct resource bfin_twi0_resource[] = {
538 .start = TWI0_REGBASE,
540 .flags = IORESOURCE_MEM,
545 .flags = IORESOURCE_IRQ,
549 static struct platform_device i2c_bfin_twi_device = {
550 .name = "i2c-bfin-twi",
552 .num_resources = ARRAY_SIZE(bfin_twi0_resource),
553 .resource = bfin_twi0_resource,
557 #ifdef CONFIG_I2C_BOARDINFO
558 static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
559 #if defined(CONFIG_TWI_LCD) || defined(CONFIG_TWI_LCD_MODULE)
561 I2C_BOARD_INFO("pcf8574_lcd", 0x22),
564 #if defined(CONFIG_TWI_KEYPAD) || defined(CONFIG_TWI_KEYPAD_MODULE)
566 I2C_BOARD_INFO("pcf8574_keypad", 0x27),
573 #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
574 static struct platform_device bfin_sport0_uart_device = {
575 .name = "bfin-sport-uart",
579 static struct platform_device bfin_sport1_uart_device = {
580 .name = "bfin-sport-uart",
585 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
586 #include <linux/input.h>
587 #include <linux/gpio_keys.h>
589 static struct gpio_keys_button bfin_gpio_keys_table[] = {
590 {BTN_0, GPIO_PG0, 1, "gpio-keys: BTN0"},
591 {BTN_1, GPIO_PG13, 1, "gpio-keys: BTN1"},
594 static struct gpio_keys_platform_data bfin_gpio_keys_data = {
595 .buttons = bfin_gpio_keys_table,
596 .nbuttons = ARRAY_SIZE(bfin_gpio_keys_table),
599 static struct platform_device bfin_device_gpiokeys = {
602 .platform_data = &bfin_gpio_keys_data,
607 static struct resource bfin_gpios_resources = {
609 .end = MAX_BLACKFIN_GPIOS - 1,
610 .flags = IORESOURCE_IRQ,
613 static struct platform_device bfin_gpios_device = {
614 .name = "simple-gpio",
617 .resource = &bfin_gpios_resources,
620 static const unsigned int cclk_vlev_datasheet[] =
622 VRPAIR(VLEV_100, 400000000),
623 VRPAIR(VLEV_105, 426000000),
624 VRPAIR(VLEV_110, 500000000),
625 VRPAIR(VLEV_115, 533000000),
626 VRPAIR(VLEV_120, 600000000),
629 static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
630 .tuple_tab = cclk_vlev_datasheet,
631 .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
632 .vr_settling_time = 25 /* us */,
635 static struct platform_device bfin_dpmc = {
638 .platform_data = &bfin_dmpc_vreg_data,
642 #if defined(CONFIG_FB_BFIN_LQ035Q1) || defined(CONFIG_FB_BFIN_LQ035Q1_MODULE)
643 #include <asm/bfin-lq035q1.h>
645 static struct bfin_lq035q1fb_disp_info bfin_lq035q1_data = {
646 .mode = LQ035_NORM | LQ035_RGB | LQ035_RL | LQ035_TB,
648 .gpio_bl = GPIO_PG12,
651 static struct resource bfin_lq035q1_resources[] = {
653 .start = IRQ_PPI_ERROR,
654 .end = IRQ_PPI_ERROR,
655 .flags = IORESOURCE_IRQ,
659 static struct platform_device bfin_lq035q1_device = {
660 .name = "bfin-lq035q1",
662 .num_resources = ARRAY_SIZE(bfin_lq035q1_resources),
663 .resource = bfin_lq035q1_resources,
665 .platform_data = &bfin_lq035q1_data,
670 static struct platform_device *stamp_devices[] __initdata = {
674 #if defined(CONFIG_MTD_NAND_BF5XX) || defined(CONFIG_MTD_NAND_BF5XX_MODULE)
678 #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
682 #if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE)
686 #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
690 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
694 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
698 #if defined(CONFIG_FB_BFIN_LQ035Q1) || defined(CONFIG_FB_BFIN_LQ035Q1_MODULE)
699 &bfin_lq035q1_device,
702 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
703 #ifdef CONFIG_BFIN_SIR0
706 #ifdef CONFIG_BFIN_SIR1
711 #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
712 &i2c_bfin_twi_device,
715 #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
716 &bfin_sport0_uart_device,
717 &bfin_sport1_uart_device,
720 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
721 &bfin_device_gpiokeys,
724 #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
731 static int __init stamp_init(void)
733 printk(KERN_INFO "%s(): registering device resources\n", __func__);
735 #ifdef CONFIG_I2C_BOARDINFO
736 i2c_register_board_info(0, bfin_i2c_board_info,
737 ARRAY_SIZE(bfin_i2c_board_info));
740 platform_add_devices(stamp_devices, ARRAY_SIZE(stamp_devices));
741 spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
745 arch_initcall(stamp_init);
747 void native_machine_restart(char *cmd)
749 /* workaround reboot hang when booting from SPI */
750 if ((bfin_read_SYSCR() & 0x7) == 0x3)
751 bfin_gpio_reset_spi0_ssel1();
754 void bfin_get_ether_addr(char *addr)
756 /* the MAC is stored in OTP memory page 0xDF */
759 u32 (*otp_read)(u32 page, u32 flags, u64 *page_content) = (void *)0xEF00001A;
761 ret = otp_read(0xDF, 0x00, &otp_mac);
763 char *otp_mac_p = (char *)&otp_mac;
764 for (ret = 0; ret < 6; ++ret)
765 addr[ret] = otp_mac_p[5 - ret];
768 EXPORT_SYMBOL(bfin_get_ether_addr);