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_8BIT | SMC91X_USE_16BIT | SMC91X_USE_32BIT |
139 .leda = RPC_LED_100_10,
140 .ledb = RPC_LED_TX_RX,
143 static struct resource smc91x_resources[] = {
145 .name = "smc91x-regs",
147 .end = 0x2C010300 + 16,
148 .flags = IORESOURCE_MEM,
153 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
157 static struct platform_device smc91x_device = {
160 .num_resources = ARRAY_SIZE(smc91x_resources),
161 .resource = smc91x_resources,
163 .platform_data = &smc91x_info,
168 #if IS_ENABLED(CONFIG_SERIAL_BFIN)
169 #ifdef CONFIG_SERIAL_BFIN_UART0
170 static struct resource bfin_uart0_resources[] = {
172 .start = BFIN_UART_THR,
173 .end = BFIN_UART_GCTL+2,
174 .flags = IORESOURCE_MEM,
177 .start = IRQ_UART_TX,
179 .flags = IORESOURCE_IRQ,
182 .start = IRQ_UART_RX,
184 .flags = IORESOURCE_IRQ,
187 .start = IRQ_UART_ERROR,
188 .end = IRQ_UART_ERROR,
189 .flags = IORESOURCE_IRQ,
194 .flags = IORESOURCE_DMA,
199 .flags = IORESOURCE_DMA,
203 static unsigned short bfin_uart0_peripherals[] = {
204 P_UART0_TX, P_UART0_RX, 0
207 static struct platform_device bfin_uart0_device = {
210 .num_resources = ARRAY_SIZE(bfin_uart0_resources),
211 .resource = bfin_uart0_resources,
213 .platform_data = &bfin_uart0_peripherals, /* Passed to driver */
219 #if IS_ENABLED(CONFIG_BFIN_SIR)
220 #ifdef CONFIG_BFIN_SIR0
221 static struct resource bfin_sir0_resources[] = {
225 .flags = IORESOURCE_MEM,
228 .start = IRQ_UART0_RX,
229 .end = IRQ_UART0_RX+1,
230 .flags = IORESOURCE_IRQ,
233 .start = CH_UART0_RX,
234 .end = CH_UART0_RX+1,
235 .flags = IORESOURCE_DMA,
239 static struct platform_device bfin_sir0_device = {
242 .num_resources = ARRAY_SIZE(bfin_sir0_resources),
243 .resource = bfin_sir0_resources,
248 #if IS_ENABLED(CONFIG_MTD_PHYSMAP)
249 static struct mtd_partition ezkit_partitions[] = {
251 .name = "bootloader(nor)",
255 .name = "linux kernel(nor)",
257 .offset = MTDPART_OFS_APPEND,
259 .name = "file system(nor)",
260 .size = 0x800000 - 0x40000 - 0x1C0000 - 0x2000 * 8,
261 .offset = MTDPART_OFS_APPEND,
263 .name = "config(nor)",
265 .offset = MTDPART_OFS_APPEND,
267 .name = "u-boot env(nor)",
269 .offset = MTDPART_OFS_APPEND,
273 static struct physmap_flash_data ezkit_flash_data = {
275 .parts = ezkit_partitions,
276 .nr_parts = ARRAY_SIZE(ezkit_partitions),
279 static struct resource ezkit_flash_resource = {
282 .flags = IORESOURCE_MEM,
285 static struct platform_device ezkit_flash_device = {
286 .name = "physmap-flash",
289 .platform_data = &ezkit_flash_data,
292 .resource = &ezkit_flash_resource,
296 #if IS_ENABLED(CONFIG_SPI_BFIN5XX)
298 static struct resource bfin_spi0_resource[] = {
300 .start = SPI0_REGBASE,
301 .end = SPI0_REGBASE + 0xFF,
302 .flags = IORESOURCE_MEM,
307 .flags = IORESOURCE_DMA,
312 .flags = IORESOURCE_IRQ,
316 /* SPI controller data */
317 static struct bfin5xx_spi_master bfin_spi0_info = {
319 .enable_dma = 1, /* master has the ability to do dma transfer */
320 .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
323 static struct platform_device bfin_spi0_device = {
325 .id = 0, /* Bus number */
326 .num_resources = ARRAY_SIZE(bfin_spi0_resource),
327 .resource = bfin_spi0_resource,
329 .platform_data = &bfin_spi0_info, /* Passed to driver */
334 static struct spi_board_info bfin_spi_board_info[] __initdata = {
335 #if IS_ENABLED(CONFIG_SND_BF5XX_SOC_AD183X)
337 .modalias = "ad183x",
338 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
341 .platform_data = "ad1836", /* only includes chip name for the moment */
345 #if IS_ENABLED(CONFIG_SPI_SPIDEV)
347 .modalias = "spidev",
348 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
355 #if IS_ENABLED(CONFIG_KEYBOARD_GPIO)
356 #include <linux/input.h>
357 #include <linux/gpio_keys.h>
359 static struct gpio_keys_button bfin_gpio_keys_table[] = {
360 {BTN_0, GPIO_PF5, 1, "gpio-keys: BTN0"},
361 {BTN_1, GPIO_PF6, 1, "gpio-keys: BTN1"},
362 {BTN_2, GPIO_PF7, 1, "gpio-keys: BTN2"},
363 {BTN_3, GPIO_PF8, 1, "gpio-keys: BTN3"},
366 static struct gpio_keys_platform_data bfin_gpio_keys_data = {
367 .buttons = bfin_gpio_keys_table,
368 .nbuttons = ARRAY_SIZE(bfin_gpio_keys_table),
371 static struct platform_device bfin_device_gpiokeys = {
374 .platform_data = &bfin_gpio_keys_data,
379 #if IS_ENABLED(CONFIG_I2C_GPIO)
380 #include <linux/i2c-gpio.h>
382 static struct i2c_gpio_platform_data i2c_gpio_data = {
385 .sda_is_open_drain = 0,
386 .scl_is_open_drain = 0,
390 static struct platform_device i2c_gpio_device = {
394 .platform_data = &i2c_gpio_data,
399 static const unsigned int cclk_vlev_datasheet[] =
401 VRPAIR(VLEV_085, 250000000),
402 VRPAIR(VLEV_090, 300000000),
403 VRPAIR(VLEV_095, 313000000),
404 VRPAIR(VLEV_100, 350000000),
405 VRPAIR(VLEV_105, 400000000),
406 VRPAIR(VLEV_110, 444000000),
407 VRPAIR(VLEV_115, 450000000),
408 VRPAIR(VLEV_120, 475000000),
409 VRPAIR(VLEV_125, 500000000),
410 VRPAIR(VLEV_130, 600000000),
413 static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
414 .tuple_tab = cclk_vlev_datasheet,
415 .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
416 .vr_settling_time = 25 /* us */,
419 static struct platform_device bfin_dpmc = {
422 .platform_data = &bfin_dmpc_vreg_data,
426 #if IS_ENABLED(CONFIG_VIDEO_BLACKFIN_CAPTURE)
427 #include <linux/videodev2.h>
428 #include <media/blackfin/bfin_capture.h>
429 #include <media/blackfin/ppi.h>
431 static const unsigned short ppi_req[] = {
432 P_PPI0_D0, P_PPI0_D1, P_PPI0_D2, P_PPI0_D3,
433 P_PPI0_D4, P_PPI0_D5, P_PPI0_D6, P_PPI0_D7,
434 P_PPI0_CLK, P_PPI0_FS1, P_PPI0_FS2,
438 static const struct ppi_info ppi_info = {
439 .type = PPI_TYPE_PPI,
441 .irq_err = IRQ_PPI1_ERROR,
442 .base = (void __iomem *)PPI0_CONTROL,
446 #if IS_ENABLED(CONFIG_VIDEO_ADV7183)
447 #include <media/i2c/adv7183.h>
448 static struct v4l2_input adv7183_inputs[] = {
452 .type = V4L2_INPUT_TYPE_CAMERA,
454 .capabilities = V4L2_IN_CAP_STD,
459 .type = V4L2_INPUT_TYPE_CAMERA,
461 .capabilities = V4L2_IN_CAP_STD,
466 .type = V4L2_INPUT_TYPE_CAMERA,
468 .capabilities = V4L2_IN_CAP_STD,
472 static struct bcap_route adv7183_routes[] = {
474 .input = ADV7183_COMPOSITE4,
475 .output = ADV7183_8BIT_OUT,
478 .input = ADV7183_SVIDEO0,
479 .output = ADV7183_8BIT_OUT,
482 .input = ADV7183_COMPONENT0,
483 .output = ADV7183_8BIT_OUT,
488 static const unsigned adv7183_gpio[] = {
489 GPIO_PF13, /* reset pin */
490 GPIO_PF2, /* output enable pin */
493 static struct bfin_capture_config bfin_capture_data = {
494 .card_name = "BF561",
495 .inputs = adv7183_inputs,
496 .num_inputs = ARRAY_SIZE(adv7183_inputs),
497 .routes = adv7183_routes,
502 .platform_data = (void *)adv7183_gpio,
504 .ppi_info = &ppi_info,
505 .ppi_control = (PACK_EN | DLEN_8 | DMA32 | FLD_SEL),
509 static struct platform_device bfin_capture_device = {
510 .name = "bfin_capture",
512 .platform_data = &bfin_capture_data,
517 #if IS_ENABLED(CONFIG_SND_BF5XX_I2S)
518 static struct platform_device bfin_i2s = {
520 .id = CONFIG_SND_BF5XX_SPORT_NUM,
521 /* TODO: add platform data here */
525 #if IS_ENABLED(CONFIG_SND_BF5XX_AC97)
526 static struct platform_device bfin_ac97 = {
528 .id = CONFIG_SND_BF5XX_SPORT_NUM,
529 /* TODO: add platform data here */
533 #if IS_ENABLED(CONFIG_SND_BF5XX_SOC_AD1836)
534 static const char * const ad1836_link[] = {
538 static struct platform_device bfin_ad1836_machine = {
539 .name = "bfin-snd-ad1836",
542 .platform_data = (void *)ad1836_link,
547 static struct platform_device *ezkit_devices[] __initdata = {
551 #if IS_ENABLED(CONFIG_SMC91X)
555 #if IS_ENABLED(CONFIG_USB_NET2272)
556 &net2272_bfin_device,
559 #if IS_ENABLED(CONFIG_USB_ISP1760_HCD)
560 &bfin_isp1760_device,
563 #if IS_ENABLED(CONFIG_SPI_BFIN5XX)
567 #if IS_ENABLED(CONFIG_SERIAL_BFIN)
568 #ifdef CONFIG_SERIAL_BFIN_UART0
573 #if IS_ENABLED(CONFIG_BFIN_SIR)
574 #ifdef CONFIG_BFIN_SIR0
579 #if IS_ENABLED(CONFIG_KEYBOARD_GPIO)
580 &bfin_device_gpiokeys,
583 #if IS_ENABLED(CONFIG_I2C_GPIO)
587 #if IS_ENABLED(CONFIG_USB_ISP1362_HCD)
591 #if IS_ENABLED(CONFIG_MTD_PHYSMAP)
595 #if IS_ENABLED(CONFIG_VIDEO_BLACKFIN_CAPTURE)
596 &bfin_capture_device,
599 #if IS_ENABLED(CONFIG_SND_BF5XX_I2S)
603 #if IS_ENABLED(CONFIG_SND_BF5XX_AC97)
607 #if IS_ENABLED(CONFIG_SND_BF5XX_SOC_AD1836)
608 &bfin_ad1836_machine,
612 static int __init net2272_init(void)
614 #if IS_ENABLED(CONFIG_USB_NET2272)
617 ret = gpio_request(GPIO_PF11, "net2272");
621 /* Reset the USB chip */
622 gpio_direction_output(GPIO_PF11, 0);
624 gpio_set_value(GPIO_PF11, 1);
630 static int __init ezkit_init(void)
634 printk(KERN_INFO "%s(): registering device resources\n", __func__);
636 ret = platform_add_devices(ezkit_devices, ARRAY_SIZE(ezkit_devices));
640 #if IS_ENABLED(CONFIG_SMC91X)
641 bfin_write_FIO0_DIR(bfin_read_FIO0_DIR() | (1 << 12));
645 #if IS_ENABLED(CONFIG_SND_BF5XX_SOC_AD183X)
646 bfin_write_FIO0_DIR(bfin_read_FIO0_DIR() | (1 << 15));
647 bfin_write_FIO0_FLAG_S(1 << 15);
650 * This initialization lasts for approximately 4500 MCLKs.
657 pr_warning("unable to configure net2272; it probably won't work\n");
659 spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
663 arch_initcall(ezkit_init);
665 static struct platform_device *ezkit_early_devices[] __initdata = {
666 #if defined(CONFIG_SERIAL_BFIN_CONSOLE) || defined(CONFIG_EARLY_PRINTK)
667 #ifdef CONFIG_SERIAL_BFIN_UART0
673 void __init native_machine_early_platform_add_devices(void)
675 printk(KERN_INFO "register early platform devices\n");
676 early_platform_add_devices(ezkit_early_devices,
677 ARRAY_SIZE(ezkit_early_devices));