2 * File: arch/blackfin/mach-bf518/boards/ezbrd.c
3 * Based on: arch/blackfin/mach-bf527/boards/ezbrd.c
4 * Author: Bryan Wu <cooloney@kernel.org>
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>
43 #include <asm/bfin5xx_spi.h>
44 #include <asm/reboot.h>
45 #include <asm/portmux.h>
47 #include <asm/bfin_sdh.h>
48 #include <linux/spi/ad7877.h>
52 * Name the Board for the /proc/cpuinfo
54 const char bfin_board_name[] = "ADI BF518F-EZBRD";
57 * Driver needs to know address, irq and flag pin.
60 #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
61 static struct mtd_partition ezbrd_partitions[] = {
63 .name = "bootloader(nor)",
67 .name = "linux kernel(nor)",
69 .offset = MTDPART_OFS_APPEND,
71 .name = "file system(nor)",
72 .size = MTDPART_SIZ_FULL,
73 .offset = MTDPART_OFS_APPEND,
77 static struct physmap_flash_data ezbrd_flash_data = {
79 .parts = ezbrd_partitions,
80 .nr_parts = ARRAY_SIZE(ezbrd_partitions),
83 static struct resource ezbrd_flash_resource = {
86 .flags = IORESOURCE_MEM,
89 static struct platform_device ezbrd_flash_device = {
90 .name = "physmap-flash",
93 .platform_data = &ezbrd_flash_data,
96 .resource = &ezbrd_flash_resource,
100 #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
101 static struct platform_device rtc_device = {
107 #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
108 static struct platform_device bfin_mii_bus = {
109 .name = "bfin_mii_bus",
112 static struct platform_device bfin_mac_device = {
114 .dev.platform_data = &bfin_mii_bus,
117 #if defined(CONFIG_NET_DSA_KSZ8893M) || defined(CONFIG_NET_DSA_KSZ8893M_MODULE)
118 static struct dsa_platform_data ksz8893m_switch_data = {
119 .mii_bus = &bfin_mii_bus.dev,
120 .netdev = &bfin_mac_device.dev,
121 .port_names[0] = NULL,
122 .port_names[1] = "eth%d",
123 .port_names[2] = "eth%d",
124 .port_names[3] = "cpu",
127 static struct platform_device ksz8893m_switch_device = {
131 .dev.platform_data = &ksz8893m_switch_data,
136 #if defined(CONFIG_MTD_M25P80) \
137 || defined(CONFIG_MTD_M25P80_MODULE)
138 static struct mtd_partition bfin_spi_flash_partitions[] = {
140 .name = "bootloader(spi)",
143 .mask_flags = MTD_CAP_ROM
145 .name = "linux kernel(spi)",
146 .size = MTDPART_SIZ_FULL,
147 .offset = MTDPART_OFS_APPEND,
151 static struct flash_platform_data bfin_spi_flash_data = {
153 .parts = bfin_spi_flash_partitions,
154 .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
158 /* SPI flash chip (m25p64) */
159 static struct bfin5xx_spi_chip spi_flash_chip_info = {
160 .enable_dma = 0, /* use dma transfer with this chip*/
165 #if defined(CONFIG_SPI_ADC_BF533) \
166 || defined(CONFIG_SPI_ADC_BF533_MODULE)
168 static struct bfin5xx_spi_chip spi_adc_chip_info = {
169 .enable_dma = 1, /* use dma transfer with this chip*/
174 #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
175 #if defined(CONFIG_NET_DSA_KSZ8893M) \
176 || defined(CONFIG_NET_DSA_KSZ8893M_MODULE)
177 /* SPI SWITCH CHIP */
178 static struct bfin5xx_spi_chip spi_switch_info = {
185 #if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
186 static struct bfin5xx_spi_chip mmc_spi_chip_info = {
192 #if defined(CONFIG_PBX)
193 static struct bfin5xx_spi_chip spi_si3xxx_chip_info = {
194 .ctl_reg = 0x4, /* send zero */
197 .cs_change_per_word = 1,
201 #if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
202 static struct bfin5xx_spi_chip spi_ad7877_chip_info = {
207 static const struct ad7877_platform_data bfin_ad7877_ts_info = {
209 .vref_delay_usecs = 50, /* internal, no capacitor */
212 .pressure_max = 1000,
214 .stopacq_polarity = 1,
215 .first_conversion_delay = 3,
216 .acquisition_time = 1,
218 .pen_down_acc_interval = 1,
222 #if defined(CONFIG_SND_SOC_WM8731) || defined(CONFIG_SND_SOC_WM8731_MODULE) \
223 && defined(CONFIG_SND_SOC_WM8731_SPI)
224 static struct bfin5xx_spi_chip spi_wm8731_chip_info = {
230 #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
231 static struct bfin5xx_spi_chip spidev_chip_info = {
237 static struct spi_board_info bfin_spi_board_info[] __initdata = {
238 #if defined(CONFIG_MTD_M25P80) \
239 || defined(CONFIG_MTD_M25P80_MODULE)
241 /* the modalias must be the same as spi device driver name */
242 .modalias = "m25p80", /* Name of spi_driver for this device */
243 .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
244 .bus_num = 0, /* Framework bus number */
245 .chip_select = 1, /* Framework chip select. On STAMP537 it is SPISSEL1*/
246 .platform_data = &bfin_spi_flash_data,
247 .controller_data = &spi_flash_chip_info,
252 #if defined(CONFIG_SPI_ADC_BF533) \
253 || defined(CONFIG_SPI_ADC_BF533_MODULE)
255 .modalias = "bfin_spi_adc", /* Name of spi_driver for this device */
256 .max_speed_hz = 6250000, /* max spi clock (SCK) speed in HZ */
257 .bus_num = 0, /* Framework bus number */
258 .chip_select = 1, /* Framework chip select. */
259 .platform_data = NULL, /* No spi_driver specific config */
260 .controller_data = &spi_adc_chip_info,
264 #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
265 #if defined(CONFIG_NET_DSA_KSZ8893M) \
266 || defined(CONFIG_NET_DSA_KSZ8893M_MODULE)
268 .modalias = "ksz8893m",
269 .max_speed_hz = 5000000,
272 .platform_data = NULL,
273 .controller_data = &spi_switch_info,
279 #if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
281 .modalias = "mmc_spi",
282 .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
285 .controller_data = &mmc_spi_chip_info,
289 #if defined(CONFIG_PBX)
291 .modalias = "fxs-spi",
292 .max_speed_hz = 12500000, /* max spi clock (SCK) speed in HZ */
294 .chip_select = 8 - CONFIG_J11_JUMPER,
295 .controller_data = &spi_si3xxx_chip_info,
299 .modalias = "fxo-spi",
300 .max_speed_hz = 12500000, /* max spi clock (SCK) speed in HZ */
302 .chip_select = 8 - CONFIG_J19_JUMPER,
303 .controller_data = &spi_si3xxx_chip_info,
307 #if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
309 .modalias = "ad7877",
310 .platform_data = &bfin_ad7877_ts_info,
312 .max_speed_hz = 12500000, /* max spi clock (SCK) speed in HZ */
315 .controller_data = &spi_ad7877_chip_info,
318 #if defined(CONFIG_SND_SOC_WM8731) || defined(CONFIG_SND_SOC_WM8731_MODULE) \
319 && defined(CONFIG_SND_SOC_WM8731_SPI)
321 .modalias = "wm8731",
322 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
325 .controller_data = &spi_wm8731_chip_info,
329 #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
331 .modalias = "spidev",
332 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
335 .controller_data = &spidev_chip_info,
338 #if defined(CONFIG_FB_BFIN_LQ035Q1) || defined(CONFIG_FB_BFIN_LQ035Q1_MODULE)
340 .modalias = "bfin-lq035q1-spi",
341 .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */
344 .controller_data = &lq035q1_spi_chip_info,
345 .mode = SPI_CPHA | SPI_CPOL,
350 /* SPI controller data */
351 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
353 static struct bfin5xx_spi_master bfin_spi0_info = {
355 .enable_dma = 1, /* master has the ability to do dma transfer */
356 .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
359 static struct resource bfin_spi0_resource[] = {
361 .start = SPI0_REGBASE,
362 .end = SPI0_REGBASE + 0xFF,
363 .flags = IORESOURCE_MEM,
368 .flags = IORESOURCE_IRQ,
372 static struct platform_device bfin_spi0_device = {
374 .id = 0, /* Bus number */
375 .num_resources = ARRAY_SIZE(bfin_spi0_resource),
376 .resource = bfin_spi0_resource,
378 .platform_data = &bfin_spi0_info, /* Passed to driver */
383 static struct bfin5xx_spi_master bfin_spi1_info = {
385 .enable_dma = 1, /* master has the ability to do dma transfer */
386 .pin_req = {P_SPI1_SCK, P_SPI1_MISO, P_SPI1_MOSI, 0},
389 static struct resource bfin_spi1_resource[] = {
391 .start = SPI1_REGBASE,
392 .end = SPI1_REGBASE + 0xFF,
393 .flags = IORESOURCE_MEM,
398 .flags = IORESOURCE_IRQ,
402 static struct platform_device bfin_spi1_device = {
404 .id = 1, /* Bus number */
405 .num_resources = ARRAY_SIZE(bfin_spi1_resource),
406 .resource = bfin_spi1_resource,
408 .platform_data = &bfin_spi1_info, /* Passed to driver */
411 #endif /* spi master and devices */
413 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
414 static struct resource bfin_uart_resources[] = {
415 #ifdef CONFIG_SERIAL_BFIN_UART0
419 .flags = IORESOURCE_MEM,
422 #ifdef CONFIG_SERIAL_BFIN_UART1
426 .flags = IORESOURCE_MEM,
431 static struct platform_device bfin_uart_device = {
434 .num_resources = ARRAY_SIZE(bfin_uart_resources),
435 .resource = bfin_uart_resources,
439 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
440 #ifdef CONFIG_BFIN_SIR0
441 static struct resource bfin_sir0_resources[] = {
445 .flags = IORESOURCE_MEM,
448 .start = IRQ_UART0_RX,
449 .end = IRQ_UART0_RX+1,
450 .flags = IORESOURCE_IRQ,
453 .start = CH_UART0_RX,
454 .end = CH_UART0_RX+1,
455 .flags = IORESOURCE_DMA,
459 static struct platform_device bfin_sir0_device = {
462 .num_resources = ARRAY_SIZE(bfin_sir0_resources),
463 .resource = bfin_sir0_resources,
466 #ifdef CONFIG_BFIN_SIR1
467 static struct resource bfin_sir1_resources[] = {
471 .flags = IORESOURCE_MEM,
474 .start = IRQ_UART1_RX,
475 .end = IRQ_UART1_RX+1,
476 .flags = IORESOURCE_IRQ,
479 .start = CH_UART1_RX,
480 .end = CH_UART1_RX+1,
481 .flags = IORESOURCE_DMA,
485 static struct platform_device bfin_sir1_device = {
488 .num_resources = ARRAY_SIZE(bfin_sir1_resources),
489 .resource = bfin_sir1_resources,
494 #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
495 static struct resource bfin_twi0_resource[] = {
497 .start = TWI0_REGBASE,
499 .flags = IORESOURCE_MEM,
504 .flags = IORESOURCE_IRQ,
508 static struct platform_device i2c_bfin_twi_device = {
509 .name = "i2c-bfin-twi",
511 .num_resources = ARRAY_SIZE(bfin_twi0_resource),
512 .resource = bfin_twi0_resource,
516 static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
517 #if defined(CONFIG_TWI_LCD) || defined(CONFIG_TWI_LCD_MODULE)
519 I2C_BOARD_INFO("pcf8574_lcd", 0x22),
522 #if defined(CONFIG_TWI_KEYPAD) || defined(CONFIG_TWI_KEYPAD_MODULE)
524 I2C_BOARD_INFO("pcf8574_keypad", 0x27),
530 #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
531 static struct platform_device bfin_sport0_uart_device = {
532 .name = "bfin-sport-uart",
536 static struct platform_device bfin_sport1_uart_device = {
537 .name = "bfin-sport-uart",
542 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
543 #include <linux/input.h>
544 #include <linux/gpio_keys.h>
546 static struct gpio_keys_button bfin_gpio_keys_table[] = {
547 {BTN_0, GPIO_PG0, 1, "gpio-keys: BTN0"},
548 {BTN_1, GPIO_PG13, 1, "gpio-keys: BTN1"},
551 static struct gpio_keys_platform_data bfin_gpio_keys_data = {
552 .buttons = bfin_gpio_keys_table,
553 .nbuttons = ARRAY_SIZE(bfin_gpio_keys_table),
556 static struct platform_device bfin_device_gpiokeys = {
559 .platform_data = &bfin_gpio_keys_data,
564 #if defined(CONFIG_SDH_BFIN) || defined(CONFIG_SDH_BFIN_MODULE)
566 static struct bfin_sd_host bfin_sdh_data = {
568 .irq_int0 = IRQ_RSI_INT0,
569 .pin_req = {P_RSI_DATA0, P_RSI_DATA1, P_RSI_DATA2, P_RSI_DATA3, P_RSI_CMD, P_RSI_CLK, 0},
572 static struct platform_device bf51x_sdh_device = {
576 .platform_data = &bfin_sdh_data,
581 static struct resource bfin_gpios_resources = {
583 .end = MAX_BLACKFIN_GPIOS - 1,
584 .flags = IORESOURCE_IRQ,
587 static struct platform_device bfin_gpios_device = {
588 .name = "simple-gpio",
591 .resource = &bfin_gpios_resources,
594 static const unsigned int cclk_vlev_datasheet[] =
596 VRPAIR(VLEV_100, 400000000),
597 VRPAIR(VLEV_105, 426000000),
598 VRPAIR(VLEV_110, 500000000),
599 VRPAIR(VLEV_115, 533000000),
600 VRPAIR(VLEV_120, 600000000),
603 static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
604 .tuple_tab = cclk_vlev_datasheet,
605 .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
606 .vr_settling_time = 25 /* us */,
609 static struct platform_device bfin_dpmc = {
612 .platform_data = &bfin_dmpc_vreg_data,
616 static struct platform_device *stamp_devices[] __initdata = {
620 #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
624 #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
627 #if defined(CONFIG_NET_DSA_KSZ8893M) || defined(CONFIG_NET_DSA_KSZ8893M_MODULE)
628 &ksz8893m_switch_device,
632 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
637 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
641 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
642 #ifdef CONFIG_BFIN_SIR0
645 #ifdef CONFIG_BFIN_SIR1
650 #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
651 &i2c_bfin_twi_device,
654 #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
655 &bfin_sport0_uart_device,
656 &bfin_sport1_uart_device,
659 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
660 &bfin_device_gpiokeys,
663 #if defined(CONFIG_SDH_BFIN) || defined(CONFIG_SDH_BFIN_MODULE)
667 #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
674 static int __init ezbrd_init(void)
676 printk(KERN_INFO "%s(): registering device resources\n", __func__);
677 i2c_register_board_info(0, bfin_i2c_board_info,
678 ARRAY_SIZE(bfin_i2c_board_info));
679 platform_add_devices(stamp_devices, ARRAY_SIZE(stamp_devices));
680 spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
684 arch_initcall(ezbrd_init);
686 void native_machine_restart(char *cmd)
688 /* workaround reboot hang when booting from SPI */
689 if ((bfin_read_SYSCR() & 0x7) == 0x3)
690 bfin_reset_boot_spi_cs(P_DEFAULT_BOOT_SPI_CS);
693 void bfin_get_ether_addr(char *addr)
695 /* the MAC is stored in OTP memory page 0xDF */
698 u32 (*otp_read)(u32 page, u32 flags, u64 *page_content) = (void *)0xEF00001A;
700 ret = otp_read(0xDF, 0x00, &otp_mac);
702 char *otp_mac_p = (char *)&otp_mac;
703 for (ret = 0; ret < 6; ++ret)
704 addr[ret] = otp_mac_p[5 - ret];
707 EXPORT_SYMBOL(bfin_get_ether_addr);