2 * Copyright 2004-2009 Analog Devices Inc.
3 * 2005 National ICT Australia (NICTA)
4 * Aidan Williams <aidan@nicta.com.au>
6 * Licensed under the GPL-2 or later.
9 #include <linux/device.h>
10 #include <linux/platform_device.h>
11 #include <linux/mtd/mtd.h>
12 #include <linux/mtd/partitions.h>
13 #include <linux/mtd/physmap.h>
14 #include <linux/spi/spi.h>
15 #include <linux/irq.h>
16 #include <linux/interrupt.h>
17 #include <linux/delay.h>
19 #include <asm/bfin5xx_spi.h>
20 #include <asm/portmux.h>
24 * Name the Board for the /proc/cpuinfo
26 const char bfin_board_name[] = "ADI BF561-EZKIT";
28 #if IS_ENABLED(CONFIG_USB_ISP1760_HCD)
29 #include <linux/usb/isp1760.h>
30 static struct resource bfin_isp1760_resources[] = {
33 .end = 0x203C0000 + 0xfffff,
34 .flags = IORESOURCE_MEM,
39 .flags = IORESOURCE_IRQ,
43 static struct isp1760_platform_data isp1760_priv = {
48 .dack_polarity_high = 0,
49 .dreq_polarity_high = 0,
52 static struct platform_device bfin_isp1760_device = {
56 .platform_data = &isp1760_priv,
58 .num_resources = ARRAY_SIZE(bfin_isp1760_resources),
59 .resource = bfin_isp1760_resources,
63 #if IS_ENABLED(CONFIG_USB_ISP1362_HCD)
64 #include <linux/usb/isp1362.h>
66 static struct resource isp1362_hcd_resources[] = {
70 .flags = IORESOURCE_MEM,
74 .flags = IORESOURCE_MEM,
78 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWEDGE,
82 static struct isp1362_platform_data isp1362_priv = {
87 .int_edge_triggered = 0,
88 .remote_wakeup_connected = 0,
89 .no_power_switching = 1,
90 .power_switching_mode = 0,
93 static struct platform_device isp1362_hcd_device = {
94 .name = "isp1362-hcd",
97 .platform_data = &isp1362_priv,
99 .num_resources = ARRAY_SIZE(isp1362_hcd_resources),
100 .resource = isp1362_hcd_resources,
104 #if IS_ENABLED(CONFIG_USB_NET2272)
105 static struct resource net2272_bfin_resources[] = {
108 .end = 0x2C000000 + 0x7F,
109 .flags = IORESOURCE_MEM,
112 .flags = IORESOURCE_BUS,
116 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
120 static struct platform_device net2272_bfin_device = {
123 .num_resources = ARRAY_SIZE(net2272_bfin_resources),
124 .resource = net2272_bfin_resources,
129 * USB-LAN EzExtender board
130 * Driver needs to know address, irq and flag pin.
132 #if IS_ENABLED(CONFIG_SMC91X)
133 #include <linux/smc91x.h>
135 static struct smc91x_platdata smc91x_info = {
136 .flags = SMC91X_USE_32BIT | SMC91X_NOWAIT,
137 .leda = RPC_LED_100_10,
138 .ledb = RPC_LED_TX_RX,
141 static struct resource smc91x_resources[] = {
143 .name = "smc91x-regs",
145 .end = 0x2C010300 + 16,
146 .flags = IORESOURCE_MEM,
151 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
155 static struct platform_device smc91x_device = {
158 .num_resources = ARRAY_SIZE(smc91x_resources),
159 .resource = smc91x_resources,
161 .platform_data = &smc91x_info,
166 #if IS_ENABLED(CONFIG_SERIAL_BFIN)
167 #ifdef CONFIG_SERIAL_BFIN_UART0
168 static struct resource bfin_uart0_resources[] = {
170 .start = BFIN_UART_THR,
171 .end = BFIN_UART_GCTL+2,
172 .flags = IORESOURCE_MEM,
175 .start = IRQ_UART_TX,
177 .flags = IORESOURCE_IRQ,
180 .start = IRQ_UART_RX,
182 .flags = IORESOURCE_IRQ,
185 .start = IRQ_UART_ERROR,
186 .end = IRQ_UART_ERROR,
187 .flags = IORESOURCE_IRQ,
192 .flags = IORESOURCE_DMA,
197 .flags = IORESOURCE_DMA,
201 static unsigned short bfin_uart0_peripherals[] = {
202 P_UART0_TX, P_UART0_RX, 0
205 static struct platform_device bfin_uart0_device = {
208 .num_resources = ARRAY_SIZE(bfin_uart0_resources),
209 .resource = bfin_uart0_resources,
211 .platform_data = &bfin_uart0_peripherals, /* Passed to driver */
217 #if IS_ENABLED(CONFIG_BFIN_SIR)
218 #ifdef CONFIG_BFIN_SIR0
219 static struct resource bfin_sir0_resources[] = {
223 .flags = IORESOURCE_MEM,
226 .start = IRQ_UART0_RX,
227 .end = IRQ_UART0_RX+1,
228 .flags = IORESOURCE_IRQ,
231 .start = CH_UART0_RX,
232 .end = CH_UART0_RX+1,
233 .flags = IORESOURCE_DMA,
237 static struct platform_device bfin_sir0_device = {
240 .num_resources = ARRAY_SIZE(bfin_sir0_resources),
241 .resource = bfin_sir0_resources,
246 #if IS_ENABLED(CONFIG_MTD_PHYSMAP)
247 static struct mtd_partition ezkit_partitions[] = {
249 .name = "bootloader(nor)",
253 .name = "linux kernel(nor)",
255 .offset = MTDPART_OFS_APPEND,
257 .name = "file system(nor)",
258 .size = 0x800000 - 0x40000 - 0x1C0000 - 0x2000 * 8,
259 .offset = MTDPART_OFS_APPEND,
261 .name = "config(nor)",
263 .offset = MTDPART_OFS_APPEND,
265 .name = "u-boot env(nor)",
267 .offset = MTDPART_OFS_APPEND,
271 static struct physmap_flash_data ezkit_flash_data = {
273 .parts = ezkit_partitions,
274 .nr_parts = ARRAY_SIZE(ezkit_partitions),
277 static struct resource ezkit_flash_resource = {
280 .flags = IORESOURCE_MEM,
283 static struct platform_device ezkit_flash_device = {
284 .name = "physmap-flash",
287 .platform_data = &ezkit_flash_data,
290 .resource = &ezkit_flash_resource,
294 #if IS_ENABLED(CONFIG_SPI_BFIN5XX)
296 static struct resource bfin_spi0_resource[] = {
298 .start = SPI0_REGBASE,
299 .end = SPI0_REGBASE + 0xFF,
300 .flags = IORESOURCE_MEM,
305 .flags = IORESOURCE_DMA,
310 .flags = IORESOURCE_IRQ,
314 /* SPI controller data */
315 static struct bfin5xx_spi_master bfin_spi0_info = {
317 .enable_dma = 1, /* master has the ability to do dma transfer */
318 .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
321 static struct platform_device bfin_spi0_device = {
323 .id = 0, /* Bus number */
324 .num_resources = ARRAY_SIZE(bfin_spi0_resource),
325 .resource = bfin_spi0_resource,
327 .platform_data = &bfin_spi0_info, /* Passed to driver */
332 static struct spi_board_info bfin_spi_board_info[] __initdata = {
333 #if IS_ENABLED(CONFIG_SND_BF5XX_SOC_AD183X)
335 .modalias = "ad183x",
336 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
339 .platform_data = "ad1836", /* only includes chip name for the moment */
343 #if IS_ENABLED(CONFIG_SPI_SPIDEV)
345 .modalias = "spidev",
346 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
353 #if IS_ENABLED(CONFIG_KEYBOARD_GPIO)
354 #include <linux/input.h>
355 #include <linux/gpio_keys.h>
357 static struct gpio_keys_button bfin_gpio_keys_table[] = {
358 {BTN_0, GPIO_PF5, 1, "gpio-keys: BTN0"},
359 {BTN_1, GPIO_PF6, 1, "gpio-keys: BTN1"},
360 {BTN_2, GPIO_PF7, 1, "gpio-keys: BTN2"},
361 {BTN_3, GPIO_PF8, 1, "gpio-keys: BTN3"},
364 static struct gpio_keys_platform_data bfin_gpio_keys_data = {
365 .buttons = bfin_gpio_keys_table,
366 .nbuttons = ARRAY_SIZE(bfin_gpio_keys_table),
369 static struct platform_device bfin_device_gpiokeys = {
372 .platform_data = &bfin_gpio_keys_data,
377 #if IS_ENABLED(CONFIG_I2C_GPIO)
378 #include <linux/i2c-gpio.h>
380 static struct i2c_gpio_platform_data i2c_gpio_data = {
383 .sda_is_open_drain = 0,
384 .scl_is_open_drain = 0,
388 static struct platform_device i2c_gpio_device = {
392 .platform_data = &i2c_gpio_data,
397 static const unsigned int cclk_vlev_datasheet[] =
399 VRPAIR(VLEV_085, 250000000),
400 VRPAIR(VLEV_090, 300000000),
401 VRPAIR(VLEV_095, 313000000),
402 VRPAIR(VLEV_100, 350000000),
403 VRPAIR(VLEV_105, 400000000),
404 VRPAIR(VLEV_110, 444000000),
405 VRPAIR(VLEV_115, 450000000),
406 VRPAIR(VLEV_120, 475000000),
407 VRPAIR(VLEV_125, 500000000),
408 VRPAIR(VLEV_130, 600000000),
411 static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
412 .tuple_tab = cclk_vlev_datasheet,
413 .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
414 .vr_settling_time = 25 /* us */,
417 static struct platform_device bfin_dpmc = {
420 .platform_data = &bfin_dmpc_vreg_data,
424 #if IS_ENABLED(CONFIG_VIDEO_BLACKFIN_CAPTURE)
425 #include <linux/videodev2.h>
426 #include <media/blackfin/bfin_capture.h>
427 #include <media/blackfin/ppi.h>
429 static const unsigned short ppi_req[] = {
430 P_PPI0_D0, P_PPI0_D1, P_PPI0_D2, P_PPI0_D3,
431 P_PPI0_D4, P_PPI0_D5, P_PPI0_D6, P_PPI0_D7,
432 P_PPI0_CLK, P_PPI0_FS1, P_PPI0_FS2,
436 static const struct ppi_info ppi_info = {
437 .type = PPI_TYPE_PPI,
439 .irq_err = IRQ_PPI1_ERROR,
440 .base = (void __iomem *)PPI0_CONTROL,
444 #if IS_ENABLED(CONFIG_VIDEO_ADV7183)
445 #include <media/adv7183.h>
446 static struct v4l2_input adv7183_inputs[] = {
450 .type = V4L2_INPUT_TYPE_CAMERA,
452 .capabilities = V4L2_IN_CAP_STD,
457 .type = V4L2_INPUT_TYPE_CAMERA,
459 .capabilities = V4L2_IN_CAP_STD,
464 .type = V4L2_INPUT_TYPE_CAMERA,
466 .capabilities = V4L2_IN_CAP_STD,
470 static struct bcap_route adv7183_routes[] = {
472 .input = ADV7183_COMPOSITE4,
473 .output = ADV7183_8BIT_OUT,
476 .input = ADV7183_SVIDEO0,
477 .output = ADV7183_8BIT_OUT,
480 .input = ADV7183_COMPONENT0,
481 .output = ADV7183_8BIT_OUT,
486 static const unsigned adv7183_gpio[] = {
487 GPIO_PF13, /* reset pin */
488 GPIO_PF2, /* output enable pin */
491 static struct bfin_capture_config bfin_capture_data = {
492 .card_name = "BF561",
493 .inputs = adv7183_inputs,
494 .num_inputs = ARRAY_SIZE(adv7183_inputs),
495 .routes = adv7183_routes,
500 .platform_data = (void *)adv7183_gpio,
502 .ppi_info = &ppi_info,
503 .ppi_control = (PACK_EN | DLEN_8 | DMA32 | FLD_SEL),
507 static struct platform_device bfin_capture_device = {
508 .name = "bfin_capture",
510 .platform_data = &bfin_capture_data,
515 #if IS_ENABLED(CONFIG_SND_BF5XX_I2S)
516 static struct platform_device bfin_i2s = {
518 .id = CONFIG_SND_BF5XX_SPORT_NUM,
519 /* TODO: add platform data here */
523 #if IS_ENABLED(CONFIG_SND_BF5XX_AC97)
524 static struct platform_device bfin_ac97 = {
526 .id = CONFIG_SND_BF5XX_SPORT_NUM,
527 /* TODO: add platform data here */
531 #if IS_ENABLED(CONFIG_SND_BF5XX_SOC_AD1836)
532 static const char * const ad1836_link[] = {
536 static struct platform_device bfin_ad1836_machine = {
537 .name = "bfin-snd-ad1836",
540 .platform_data = (void *)ad1836_link,
545 static struct platform_device *ezkit_devices[] __initdata = {
549 #if IS_ENABLED(CONFIG_SMC91X)
553 #if IS_ENABLED(CONFIG_USB_NET2272)
554 &net2272_bfin_device,
557 #if IS_ENABLED(CONFIG_USB_ISP1760_HCD)
558 &bfin_isp1760_device,
561 #if IS_ENABLED(CONFIG_SPI_BFIN5XX)
565 #if IS_ENABLED(CONFIG_SERIAL_BFIN)
566 #ifdef CONFIG_SERIAL_BFIN_UART0
571 #if IS_ENABLED(CONFIG_BFIN_SIR)
572 #ifdef CONFIG_BFIN_SIR0
577 #if IS_ENABLED(CONFIG_KEYBOARD_GPIO)
578 &bfin_device_gpiokeys,
581 #if IS_ENABLED(CONFIG_I2C_GPIO)
585 #if IS_ENABLED(CONFIG_USB_ISP1362_HCD)
589 #if IS_ENABLED(CONFIG_MTD_PHYSMAP)
593 #if IS_ENABLED(CONFIG_VIDEO_BLACKFIN_CAPTURE)
594 &bfin_capture_device,
597 #if IS_ENABLED(CONFIG_SND_BF5XX_I2S)
601 #if IS_ENABLED(CONFIG_SND_BF5XX_AC97)
605 #if IS_ENABLED(CONFIG_SND_BF5XX_SOC_AD1836)
606 &bfin_ad1836_machine,
610 static int __init net2272_init(void)
612 #if IS_ENABLED(CONFIG_USB_NET2272)
615 ret = gpio_request(GPIO_PF11, "net2272");
619 /* Reset the USB chip */
620 gpio_direction_output(GPIO_PF11, 0);
622 gpio_set_value(GPIO_PF11, 1);
628 static int __init ezkit_init(void)
632 printk(KERN_INFO "%s(): registering device resources\n", __func__);
634 ret = platform_add_devices(ezkit_devices, ARRAY_SIZE(ezkit_devices));
638 #if IS_ENABLED(CONFIG_SMC91X)
639 bfin_write_FIO0_DIR(bfin_read_FIO0_DIR() | (1 << 12));
643 #if IS_ENABLED(CONFIG_SND_BF5XX_SOC_AD183X)
644 bfin_write_FIO0_DIR(bfin_read_FIO0_DIR() | (1 << 15));
645 bfin_write_FIO0_FLAG_S(1 << 15);
648 * This initialization lasts for approximately 4500 MCLKs.
655 pr_warning("unable to configure net2272; it probably won't work\n");
657 spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
661 arch_initcall(ezkit_init);
663 static struct platform_device *ezkit_early_devices[] __initdata = {
664 #if defined(CONFIG_SERIAL_BFIN_CONSOLE) || defined(CONFIG_EARLY_PRINTK)
665 #ifdef CONFIG_SERIAL_BFIN_UART0
671 void __init native_machine_early_platform_add_devices(void)
673 printk(KERN_INFO "register early platform devices\n");
674 early_platform_add_devices(ezkit_early_devices,
675 ARRAY_SIZE(ezkit_early_devices));