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/gpio.h>
18 #include <linux/delay.h>
20 #include <asm/bfin5xx_spi.h>
21 #include <asm/portmux.h>
25 * Name the Board for the /proc/cpuinfo
27 const char bfin_board_name[] = "ADI BF561-EZKIT";
29 #if IS_ENABLED(CONFIG_USB_ISP1760_HCD)
30 #include <linux/usb/isp1760.h>
31 static struct resource bfin_isp1760_resources[] = {
34 .end = 0x203C0000 + 0xfffff,
35 .flags = IORESOURCE_MEM,
40 .flags = IORESOURCE_IRQ,
44 static struct isp1760_platform_data isp1760_priv = {
49 .dack_polarity_high = 0,
50 .dreq_polarity_high = 0,
53 static struct platform_device bfin_isp1760_device = {
57 .platform_data = &isp1760_priv,
59 .num_resources = ARRAY_SIZE(bfin_isp1760_resources),
60 .resource = bfin_isp1760_resources,
64 #if IS_ENABLED(CONFIG_USB_ISP1362_HCD)
65 #include <linux/usb/isp1362.h>
67 static struct resource isp1362_hcd_resources[] = {
71 .flags = IORESOURCE_MEM,
75 .flags = IORESOURCE_MEM,
79 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWEDGE,
83 static struct isp1362_platform_data isp1362_priv = {
88 .int_edge_triggered = 0,
89 .remote_wakeup_connected = 0,
90 .no_power_switching = 1,
91 .power_switching_mode = 0,
94 static struct platform_device isp1362_hcd_device = {
95 .name = "isp1362-hcd",
98 .platform_data = &isp1362_priv,
100 .num_resources = ARRAY_SIZE(isp1362_hcd_resources),
101 .resource = isp1362_hcd_resources,
105 #if IS_ENABLED(CONFIG_USB_NET2272)
106 static struct resource net2272_bfin_resources[] = {
109 .end = 0x2C000000 + 0x7F,
110 .flags = IORESOURCE_MEM,
113 .flags = IORESOURCE_BUS,
117 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
121 static struct platform_device net2272_bfin_device = {
124 .num_resources = ARRAY_SIZE(net2272_bfin_resources),
125 .resource = net2272_bfin_resources,
130 * USB-LAN EzExtender board
131 * Driver needs to know address, irq and flag pin.
133 #if IS_ENABLED(CONFIG_SMC91X)
134 #include <linux/smc91x.h>
136 static struct smc91x_platdata smc91x_info = {
137 .flags = SMC91X_USE_32BIT | SMC91X_NOWAIT,
138 .leda = RPC_LED_100_10,
139 .ledb = RPC_LED_TX_RX,
142 static struct resource smc91x_resources[] = {
144 .name = "smc91x-regs",
146 .end = 0x2C010300 + 16,
147 .flags = IORESOURCE_MEM,
152 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
156 static struct platform_device smc91x_device = {
159 .num_resources = ARRAY_SIZE(smc91x_resources),
160 .resource = smc91x_resources,
162 .platform_data = &smc91x_info,
167 #if IS_ENABLED(CONFIG_SERIAL_BFIN)
168 #ifdef CONFIG_SERIAL_BFIN_UART0
169 static struct resource bfin_uart0_resources[] = {
171 .start = BFIN_UART_THR,
172 .end = BFIN_UART_GCTL+2,
173 .flags = IORESOURCE_MEM,
176 .start = IRQ_UART_TX,
178 .flags = IORESOURCE_IRQ,
181 .start = IRQ_UART_RX,
183 .flags = IORESOURCE_IRQ,
186 .start = IRQ_UART_ERROR,
187 .end = IRQ_UART_ERROR,
188 .flags = IORESOURCE_IRQ,
193 .flags = IORESOURCE_DMA,
198 .flags = IORESOURCE_DMA,
202 static unsigned short bfin_uart0_peripherals[] = {
203 P_UART0_TX, P_UART0_RX, 0
206 static struct platform_device bfin_uart0_device = {
209 .num_resources = ARRAY_SIZE(bfin_uart0_resources),
210 .resource = bfin_uart0_resources,
212 .platform_data = &bfin_uart0_peripherals, /* Passed to driver */
218 #if IS_ENABLED(CONFIG_BFIN_SIR)
219 #ifdef CONFIG_BFIN_SIR0
220 static struct resource bfin_sir0_resources[] = {
224 .flags = IORESOURCE_MEM,
227 .start = IRQ_UART0_RX,
228 .end = IRQ_UART0_RX+1,
229 .flags = IORESOURCE_IRQ,
232 .start = CH_UART0_RX,
233 .end = CH_UART0_RX+1,
234 .flags = IORESOURCE_DMA,
238 static struct platform_device bfin_sir0_device = {
241 .num_resources = ARRAY_SIZE(bfin_sir0_resources),
242 .resource = bfin_sir0_resources,
247 #if IS_ENABLED(CONFIG_MTD_PHYSMAP)
248 static struct mtd_partition ezkit_partitions[] = {
250 .name = "bootloader(nor)",
254 .name = "linux kernel(nor)",
256 .offset = MTDPART_OFS_APPEND,
258 .name = "file system(nor)",
259 .size = 0x800000 - 0x40000 - 0x1C0000 - 0x2000 * 8,
260 .offset = MTDPART_OFS_APPEND,
262 .name = "config(nor)",
264 .offset = MTDPART_OFS_APPEND,
266 .name = "u-boot env(nor)",
268 .offset = MTDPART_OFS_APPEND,
272 static struct physmap_flash_data ezkit_flash_data = {
274 .parts = ezkit_partitions,
275 .nr_parts = ARRAY_SIZE(ezkit_partitions),
278 static struct resource ezkit_flash_resource = {
281 .flags = IORESOURCE_MEM,
284 static struct platform_device ezkit_flash_device = {
285 .name = "physmap-flash",
288 .platform_data = &ezkit_flash_data,
291 .resource = &ezkit_flash_resource,
295 #if IS_ENABLED(CONFIG_SPI_BFIN5XX)
297 static struct resource bfin_spi0_resource[] = {
299 .start = SPI0_REGBASE,
300 .end = SPI0_REGBASE + 0xFF,
301 .flags = IORESOURCE_MEM,
306 .flags = IORESOURCE_DMA,
311 .flags = IORESOURCE_IRQ,
315 /* SPI controller data */
316 static struct bfin5xx_spi_master bfin_spi0_info = {
318 .enable_dma = 1, /* master has the ability to do dma transfer */
319 .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
322 static struct platform_device bfin_spi0_device = {
324 .id = 0, /* Bus number */
325 .num_resources = ARRAY_SIZE(bfin_spi0_resource),
326 .resource = bfin_spi0_resource,
328 .platform_data = &bfin_spi0_info, /* Passed to driver */
333 static struct spi_board_info bfin_spi_board_info[] __initdata = {
334 #if IS_ENABLED(CONFIG_SND_BF5XX_SOC_AD183X)
336 .modalias = "ad183x",
337 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
340 .platform_data = "ad1836", /* only includes chip name for the moment */
344 #if IS_ENABLED(CONFIG_SPI_SPIDEV)
346 .modalias = "spidev",
347 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
354 #if IS_ENABLED(CONFIG_KEYBOARD_GPIO)
355 #include <linux/input.h>
356 #include <linux/gpio_keys.h>
358 static struct gpio_keys_button bfin_gpio_keys_table[] = {
359 {BTN_0, GPIO_PF5, 1, "gpio-keys: BTN0"},
360 {BTN_1, GPIO_PF6, 1, "gpio-keys: BTN1"},
361 {BTN_2, GPIO_PF7, 1, "gpio-keys: BTN2"},
362 {BTN_3, GPIO_PF8, 1, "gpio-keys: BTN3"},
365 static struct gpio_keys_platform_data bfin_gpio_keys_data = {
366 .buttons = bfin_gpio_keys_table,
367 .nbuttons = ARRAY_SIZE(bfin_gpio_keys_table),
370 static struct platform_device bfin_device_gpiokeys = {
373 .platform_data = &bfin_gpio_keys_data,
378 #if IS_ENABLED(CONFIG_I2C_GPIO)
379 #include <linux/i2c-gpio.h>
381 static struct i2c_gpio_platform_data i2c_gpio_data = {
384 .sda_is_open_drain = 0,
385 .scl_is_open_drain = 0,
389 static struct platform_device i2c_gpio_device = {
393 .platform_data = &i2c_gpio_data,
398 static const unsigned int cclk_vlev_datasheet[] =
400 VRPAIR(VLEV_085, 250000000),
401 VRPAIR(VLEV_090, 300000000),
402 VRPAIR(VLEV_095, 313000000),
403 VRPAIR(VLEV_100, 350000000),
404 VRPAIR(VLEV_105, 400000000),
405 VRPAIR(VLEV_110, 444000000),
406 VRPAIR(VLEV_115, 450000000),
407 VRPAIR(VLEV_120, 475000000),
408 VRPAIR(VLEV_125, 500000000),
409 VRPAIR(VLEV_130, 600000000),
412 static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
413 .tuple_tab = cclk_vlev_datasheet,
414 .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
415 .vr_settling_time = 25 /* us */,
418 static struct platform_device bfin_dpmc = {
421 .platform_data = &bfin_dmpc_vreg_data,
425 #if IS_ENABLED(CONFIG_VIDEO_BLACKFIN_CAPTURE)
426 #include <linux/videodev2.h>
427 #include <media/blackfin/bfin_capture.h>
428 #include <media/blackfin/ppi.h>
430 static const unsigned short ppi_req[] = {
431 P_PPI0_D0, P_PPI0_D1, P_PPI0_D2, P_PPI0_D3,
432 P_PPI0_D4, P_PPI0_D5, P_PPI0_D6, P_PPI0_D7,
433 P_PPI0_CLK, P_PPI0_FS1, P_PPI0_FS2,
437 static const struct ppi_info ppi_info = {
438 .type = PPI_TYPE_PPI,
440 .irq_err = IRQ_PPI1_ERROR,
441 .base = (void __iomem *)PPI0_CONTROL,
445 #if IS_ENABLED(CONFIG_VIDEO_ADV7183)
446 #include <media/i2c/adv7183.h>
447 static struct v4l2_input adv7183_inputs[] = {
451 .type = V4L2_INPUT_TYPE_CAMERA,
453 .capabilities = V4L2_IN_CAP_STD,
458 .type = V4L2_INPUT_TYPE_CAMERA,
460 .capabilities = V4L2_IN_CAP_STD,
465 .type = V4L2_INPUT_TYPE_CAMERA,
467 .capabilities = V4L2_IN_CAP_STD,
471 static struct bcap_route adv7183_routes[] = {
473 .input = ADV7183_COMPOSITE4,
474 .output = ADV7183_8BIT_OUT,
477 .input = ADV7183_SVIDEO0,
478 .output = ADV7183_8BIT_OUT,
481 .input = ADV7183_COMPONENT0,
482 .output = ADV7183_8BIT_OUT,
487 static const unsigned adv7183_gpio[] = {
488 GPIO_PF13, /* reset pin */
489 GPIO_PF2, /* output enable pin */
492 static struct bfin_capture_config bfin_capture_data = {
493 .card_name = "BF561",
494 .inputs = adv7183_inputs,
495 .num_inputs = ARRAY_SIZE(adv7183_inputs),
496 .routes = adv7183_routes,
501 .platform_data = (void *)adv7183_gpio,
503 .ppi_info = &ppi_info,
504 .ppi_control = (PACK_EN | DLEN_8 | DMA32 | FLD_SEL),
508 static struct platform_device bfin_capture_device = {
509 .name = "bfin_capture",
511 .platform_data = &bfin_capture_data,
516 #if IS_ENABLED(CONFIG_SND_BF5XX_I2S)
517 static struct platform_device bfin_i2s = {
519 .id = CONFIG_SND_BF5XX_SPORT_NUM,
520 /* TODO: add platform data here */
524 #if IS_ENABLED(CONFIG_SND_BF5XX_AC97)
525 static struct platform_device bfin_ac97 = {
527 .id = CONFIG_SND_BF5XX_SPORT_NUM,
528 /* TODO: add platform data here */
532 #if IS_ENABLED(CONFIG_SND_BF5XX_SOC_AD1836)
533 static const char * const ad1836_link[] = {
537 static struct platform_device bfin_ad1836_machine = {
538 .name = "bfin-snd-ad1836",
541 .platform_data = (void *)ad1836_link,
546 static struct platform_device *ezkit_devices[] __initdata = {
550 #if IS_ENABLED(CONFIG_SMC91X)
554 #if IS_ENABLED(CONFIG_USB_NET2272)
555 &net2272_bfin_device,
558 #if IS_ENABLED(CONFIG_USB_ISP1760_HCD)
559 &bfin_isp1760_device,
562 #if IS_ENABLED(CONFIG_SPI_BFIN5XX)
566 #if IS_ENABLED(CONFIG_SERIAL_BFIN)
567 #ifdef CONFIG_SERIAL_BFIN_UART0
572 #if IS_ENABLED(CONFIG_BFIN_SIR)
573 #ifdef CONFIG_BFIN_SIR0
578 #if IS_ENABLED(CONFIG_KEYBOARD_GPIO)
579 &bfin_device_gpiokeys,
582 #if IS_ENABLED(CONFIG_I2C_GPIO)
586 #if IS_ENABLED(CONFIG_USB_ISP1362_HCD)
590 #if IS_ENABLED(CONFIG_MTD_PHYSMAP)
594 #if IS_ENABLED(CONFIG_VIDEO_BLACKFIN_CAPTURE)
595 &bfin_capture_device,
598 #if IS_ENABLED(CONFIG_SND_BF5XX_I2S)
602 #if IS_ENABLED(CONFIG_SND_BF5XX_AC97)
606 #if IS_ENABLED(CONFIG_SND_BF5XX_SOC_AD1836)
607 &bfin_ad1836_machine,
611 static int __init net2272_init(void)
613 #if IS_ENABLED(CONFIG_USB_NET2272)
616 ret = gpio_request(GPIO_PF11, "net2272");
620 /* Reset the USB chip */
621 gpio_direction_output(GPIO_PF11, 0);
623 gpio_set_value(GPIO_PF11, 1);
629 static int __init ezkit_init(void)
633 printk(KERN_INFO "%s(): registering device resources\n", __func__);
635 ret = platform_add_devices(ezkit_devices, ARRAY_SIZE(ezkit_devices));
639 #if IS_ENABLED(CONFIG_SMC91X)
640 bfin_write_FIO0_DIR(bfin_read_FIO0_DIR() | (1 << 12));
644 #if IS_ENABLED(CONFIG_SND_BF5XX_SOC_AD183X)
645 bfin_write_FIO0_DIR(bfin_read_FIO0_DIR() | (1 << 15));
646 bfin_write_FIO0_FLAG_S(1 << 15);
649 * This initialization lasts for approximately 4500 MCLKs.
656 pr_warning("unable to configure net2272; it probably won't work\n");
658 spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
662 arch_initcall(ezkit_init);
664 static struct platform_device *ezkit_early_devices[] __initdata = {
665 #if defined(CONFIG_SERIAL_BFIN_CONSOLE) || defined(CONFIG_EARLY_PRINTK)
666 #ifdef CONFIG_SERIAL_BFIN_UART0
672 void __init native_machine_early_platform_add_devices(void)
674 printk(KERN_INFO "register early platform devices\n");
675 early_platform_add_devices(ezkit_early_devices,
676 ARRAY_SIZE(ezkit_early_devices));