Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost
[cris-mirror.git] / arch / blackfin / mach-bf561 / boards / ezkit.c
blobacc5363f60c62ba9371503d3a948c85788830bd3
1 /*
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.
7 */
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>
19 #include <linux/gpio/machine.h>
20 #include <asm/dma.h>
21 #include <asm/bfin5xx_spi.h>
22 #include <asm/portmux.h>
23 #include <asm/dpmc.h>
26 * Name the Board for the /proc/cpuinfo
28 const char bfin_board_name[] = "ADI BF561-EZKIT";
30 #if IS_ENABLED(CONFIG_USB_ISP1760_HCD)
31 #include <linux/usb/isp1760.h>
32 static struct resource bfin_isp1760_resources[] = {
33 [0] = {
34 .start = 0x2C0F0000,
35 .end = 0x203C0000 + 0xfffff,
36 .flags = IORESOURCE_MEM,
38 [1] = {
39 .start = IRQ_PF10,
40 .end = IRQ_PF10,
41 .flags = IORESOURCE_IRQ,
45 static struct isp1760_platform_data isp1760_priv = {
46 .is_isp1761 = 0,
47 .bus_width_16 = 1,
48 .port1_otg = 0,
49 .analog_oc = 0,
50 .dack_polarity_high = 0,
51 .dreq_polarity_high = 0,
54 static struct platform_device bfin_isp1760_device = {
55 .name = "isp1760",
56 .id = 0,
57 .dev = {
58 .platform_data = &isp1760_priv,
60 .num_resources = ARRAY_SIZE(bfin_isp1760_resources),
61 .resource = bfin_isp1760_resources,
63 #endif
65 #if IS_ENABLED(CONFIG_USB_ISP1362_HCD)
66 #include <linux/usb/isp1362.h>
68 static struct resource isp1362_hcd_resources[] = {
70 .start = 0x2c060000,
71 .end = 0x2c060000,
72 .flags = IORESOURCE_MEM,
73 }, {
74 .start = 0x2c060004,
75 .end = 0x2c060004,
76 .flags = IORESOURCE_MEM,
77 }, {
78 .start = IRQ_PF8,
79 .end = IRQ_PF8,
80 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWEDGE,
84 static struct isp1362_platform_data isp1362_priv = {
85 .sel15Kres = 1,
86 .clknotstop = 0,
87 .oc_enable = 0,
88 .int_act_high = 0,
89 .int_edge_triggered = 0,
90 .remote_wakeup_connected = 0,
91 .no_power_switching = 1,
92 .power_switching_mode = 0,
95 static struct platform_device isp1362_hcd_device = {
96 .name = "isp1362-hcd",
97 .id = 0,
98 .dev = {
99 .platform_data = &isp1362_priv,
101 .num_resources = ARRAY_SIZE(isp1362_hcd_resources),
102 .resource = isp1362_hcd_resources,
104 #endif
106 #if IS_ENABLED(CONFIG_USB_NET2272)
107 static struct resource net2272_bfin_resources[] = {
109 .start = 0x2C000000,
110 .end = 0x2C000000 + 0x7F,
111 .flags = IORESOURCE_MEM,
112 }, {
113 .start = 1,
114 .flags = IORESOURCE_BUS,
115 }, {
116 .start = IRQ_PF10,
117 .end = IRQ_PF10,
118 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
122 static struct platform_device net2272_bfin_device = {
123 .name = "net2272",
124 .id = -1,
125 .num_resources = ARRAY_SIZE(net2272_bfin_resources),
126 .resource = net2272_bfin_resources,
128 #endif
131 * USB-LAN EzExtender board
132 * Driver needs to know address, irq and flag pin.
134 #if IS_ENABLED(CONFIG_SMC91X)
135 #include <linux/smc91x.h>
137 static struct smc91x_platdata smc91x_info = {
138 .flags = SMC91X_USE_8BIT | SMC91X_USE_16BIT | SMC91X_USE_32BIT |
139 SMC91X_NOWAIT,
140 .leda = RPC_LED_100_10,
141 .ledb = RPC_LED_TX_RX,
144 static struct resource smc91x_resources[] = {
146 .name = "smc91x-regs",
147 .start = 0x2C010300,
148 .end = 0x2C010300 + 16,
149 .flags = IORESOURCE_MEM,
150 }, {
152 .start = IRQ_PF9,
153 .end = IRQ_PF9,
154 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
158 static struct platform_device smc91x_device = {
159 .name = "smc91x",
160 .id = 0,
161 .num_resources = ARRAY_SIZE(smc91x_resources),
162 .resource = smc91x_resources,
163 .dev = {
164 .platform_data = &smc91x_info,
167 #endif
169 #if IS_ENABLED(CONFIG_SERIAL_BFIN)
170 #ifdef CONFIG_SERIAL_BFIN_UART0
171 static struct resource bfin_uart0_resources[] = {
173 .start = BFIN_UART_THR,
174 .end = BFIN_UART_GCTL+2,
175 .flags = IORESOURCE_MEM,
178 .start = IRQ_UART_TX,
179 .end = IRQ_UART_TX,
180 .flags = IORESOURCE_IRQ,
183 .start = IRQ_UART_RX,
184 .end = IRQ_UART_RX,
185 .flags = IORESOURCE_IRQ,
188 .start = IRQ_UART_ERROR,
189 .end = IRQ_UART_ERROR,
190 .flags = IORESOURCE_IRQ,
193 .start = CH_UART_TX,
194 .end = CH_UART_TX,
195 .flags = IORESOURCE_DMA,
198 .start = CH_UART_RX,
199 .end = CH_UART_RX,
200 .flags = IORESOURCE_DMA,
204 static unsigned short bfin_uart0_peripherals[] = {
205 P_UART0_TX, P_UART0_RX, 0
208 static struct platform_device bfin_uart0_device = {
209 .name = "bfin-uart",
210 .id = 0,
211 .num_resources = ARRAY_SIZE(bfin_uart0_resources),
212 .resource = bfin_uart0_resources,
213 .dev = {
214 .platform_data = &bfin_uart0_peripherals, /* Passed to driver */
217 #endif
218 #endif
220 #if IS_ENABLED(CONFIG_BFIN_SIR)
221 #ifdef CONFIG_BFIN_SIR0
222 static struct resource bfin_sir0_resources[] = {
224 .start = 0xFFC00400,
225 .end = 0xFFC004FF,
226 .flags = IORESOURCE_MEM,
229 .start = IRQ_UART0_RX,
230 .end = IRQ_UART0_RX+1,
231 .flags = IORESOURCE_IRQ,
234 .start = CH_UART0_RX,
235 .end = CH_UART0_RX+1,
236 .flags = IORESOURCE_DMA,
240 static struct platform_device bfin_sir0_device = {
241 .name = "bfin_sir",
242 .id = 0,
243 .num_resources = ARRAY_SIZE(bfin_sir0_resources),
244 .resource = bfin_sir0_resources,
246 #endif
247 #endif
249 #if IS_ENABLED(CONFIG_MTD_PHYSMAP)
250 static struct mtd_partition ezkit_partitions[] = {
252 .name = "bootloader(nor)",
253 .size = 0x40000,
254 .offset = 0,
255 }, {
256 .name = "linux kernel(nor)",
257 .size = 0x1C0000,
258 .offset = MTDPART_OFS_APPEND,
259 }, {
260 .name = "file system(nor)",
261 .size = 0x800000 - 0x40000 - 0x1C0000 - 0x2000 * 8,
262 .offset = MTDPART_OFS_APPEND,
263 }, {
264 .name = "config(nor)",
265 .size = 0x2000 * 7,
266 .offset = MTDPART_OFS_APPEND,
267 }, {
268 .name = "u-boot env(nor)",
269 .size = 0x2000,
270 .offset = MTDPART_OFS_APPEND,
274 static struct physmap_flash_data ezkit_flash_data = {
275 .width = 2,
276 .parts = ezkit_partitions,
277 .nr_parts = ARRAY_SIZE(ezkit_partitions),
280 static struct resource ezkit_flash_resource = {
281 .start = 0x20000000,
282 .end = 0x207fffff,
283 .flags = IORESOURCE_MEM,
286 static struct platform_device ezkit_flash_device = {
287 .name = "physmap-flash",
288 .id = 0,
289 .dev = {
290 .platform_data = &ezkit_flash_data,
292 .num_resources = 1,
293 .resource = &ezkit_flash_resource,
295 #endif
297 #if IS_ENABLED(CONFIG_SPI_BFIN5XX)
298 /* SPI (0) */
299 static struct resource bfin_spi0_resource[] = {
300 [0] = {
301 .start = SPI0_REGBASE,
302 .end = SPI0_REGBASE + 0xFF,
303 .flags = IORESOURCE_MEM,
305 [1] = {
306 .start = CH_SPI,
307 .end = CH_SPI,
308 .flags = IORESOURCE_DMA,
310 [2] = {
311 .start = IRQ_SPI,
312 .end = IRQ_SPI,
313 .flags = IORESOURCE_IRQ,
317 /* SPI controller data */
318 static struct bfin5xx_spi_master bfin_spi0_info = {
319 .num_chipselect = 8,
320 .enable_dma = 1, /* master has the ability to do dma transfer */
321 .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
324 static struct platform_device bfin_spi0_device = {
325 .name = "bfin-spi",
326 .id = 0, /* Bus number */
327 .num_resources = ARRAY_SIZE(bfin_spi0_resource),
328 .resource = bfin_spi0_resource,
329 .dev = {
330 .platform_data = &bfin_spi0_info, /* Passed to driver */
333 #endif
335 static struct spi_board_info bfin_spi_board_info[] __initdata = {
336 #if IS_ENABLED(CONFIG_SND_BF5XX_SOC_AD183X)
338 .modalias = "ad183x",
339 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
340 .bus_num = 0,
341 .chip_select = 4,
342 .platform_data = "ad1836", /* only includes chip name for the moment */
343 .mode = SPI_MODE_3,
345 #endif
346 #if IS_ENABLED(CONFIG_SPI_SPIDEV)
348 .modalias = "spidev",
349 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
350 .bus_num = 0,
351 .chip_select = 1,
353 #endif
356 #if IS_ENABLED(CONFIG_KEYBOARD_GPIO)
357 #include <linux/input.h>
358 #include <linux/gpio_keys.h>
360 static struct gpio_keys_button bfin_gpio_keys_table[] = {
361 {BTN_0, GPIO_PF5, 1, "gpio-keys: BTN0"},
362 {BTN_1, GPIO_PF6, 1, "gpio-keys: BTN1"},
363 {BTN_2, GPIO_PF7, 1, "gpio-keys: BTN2"},
364 {BTN_3, GPIO_PF8, 1, "gpio-keys: BTN3"},
367 static struct gpio_keys_platform_data bfin_gpio_keys_data = {
368 .buttons = bfin_gpio_keys_table,
369 .nbuttons = ARRAY_SIZE(bfin_gpio_keys_table),
372 static struct platform_device bfin_device_gpiokeys = {
373 .name = "gpio-keys",
374 .dev = {
375 .platform_data = &bfin_gpio_keys_data,
378 #endif
380 #if IS_ENABLED(CONFIG_I2C_GPIO)
381 #include <linux/i2c-gpio.h>
383 static struct gpiod_lookup_table bfin_i2c_gpiod_table = {
384 .dev_id = "i2c-gpio",
385 .table = {
386 GPIO_LOOKUP_IDX("BFIN-GPIO", GPIO_PF1, NULL, 0,
387 GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN),
388 GPIO_LOOKUP_IDX("BFIN-GPIO", GPIO_PF0, NULL, 1,
389 GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN),
393 static struct i2c_gpio_platform_data i2c_gpio_data = {
394 .udelay = 10,
397 static struct platform_device i2c_gpio_device = {
398 .name = "i2c-gpio",
399 .id = 0,
400 .dev = {
401 .platform_data = &i2c_gpio_data,
404 #endif
406 static const unsigned int cclk_vlev_datasheet[] =
408 VRPAIR(VLEV_085, 250000000),
409 VRPAIR(VLEV_090, 300000000),
410 VRPAIR(VLEV_095, 313000000),
411 VRPAIR(VLEV_100, 350000000),
412 VRPAIR(VLEV_105, 400000000),
413 VRPAIR(VLEV_110, 444000000),
414 VRPAIR(VLEV_115, 450000000),
415 VRPAIR(VLEV_120, 475000000),
416 VRPAIR(VLEV_125, 500000000),
417 VRPAIR(VLEV_130, 600000000),
420 static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
421 .tuple_tab = cclk_vlev_datasheet,
422 .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
423 .vr_settling_time = 25 /* us */,
426 static struct platform_device bfin_dpmc = {
427 .name = "bfin dpmc",
428 .dev = {
429 .platform_data = &bfin_dmpc_vreg_data,
433 #if IS_ENABLED(CONFIG_VIDEO_BLACKFIN_CAPTURE)
434 #include <linux/videodev2.h>
435 #include <media/blackfin/bfin_capture.h>
436 #include <media/blackfin/ppi.h>
438 static const unsigned short ppi_req[] = {
439 P_PPI0_D0, P_PPI0_D1, P_PPI0_D2, P_PPI0_D3,
440 P_PPI0_D4, P_PPI0_D5, P_PPI0_D6, P_PPI0_D7,
441 P_PPI0_CLK, P_PPI0_FS1, P_PPI0_FS2,
445 static const struct ppi_info ppi_info = {
446 .type = PPI_TYPE_PPI,
447 .dma_ch = CH_PPI0,
448 .irq_err = IRQ_PPI1_ERROR,
449 .base = (void __iomem *)PPI0_CONTROL,
450 .pin_req = ppi_req,
453 #if IS_ENABLED(CONFIG_VIDEO_ADV7183)
454 #include <media/i2c/adv7183.h>
455 static struct v4l2_input adv7183_inputs[] = {
457 .index = 0,
458 .name = "Composite",
459 .type = V4L2_INPUT_TYPE_CAMERA,
460 .std = V4L2_STD_ALL,
461 .capabilities = V4L2_IN_CAP_STD,
464 .index = 1,
465 .name = "S-Video",
466 .type = V4L2_INPUT_TYPE_CAMERA,
467 .std = V4L2_STD_ALL,
468 .capabilities = V4L2_IN_CAP_STD,
471 .index = 2,
472 .name = "Component",
473 .type = V4L2_INPUT_TYPE_CAMERA,
474 .std = V4L2_STD_ALL,
475 .capabilities = V4L2_IN_CAP_STD,
479 static struct bcap_route adv7183_routes[] = {
481 .input = ADV7183_COMPOSITE4,
482 .output = ADV7183_8BIT_OUT,
485 .input = ADV7183_SVIDEO0,
486 .output = ADV7183_8BIT_OUT,
489 .input = ADV7183_COMPONENT0,
490 .output = ADV7183_8BIT_OUT,
495 static const unsigned adv7183_gpio[] = {
496 GPIO_PF13, /* reset pin */
497 GPIO_PF2, /* output enable pin */
500 static struct bfin_capture_config bfin_capture_data = {
501 .card_name = "BF561",
502 .inputs = adv7183_inputs,
503 .num_inputs = ARRAY_SIZE(adv7183_inputs),
504 .routes = adv7183_routes,
505 .i2c_adapter_id = 0,
506 .board_info = {
507 .type = "adv7183",
508 .addr = 0x20,
509 .platform_data = (void *)adv7183_gpio,
511 .ppi_info = &ppi_info,
512 .ppi_control = (PACK_EN | DLEN_8 | DMA32 | FLD_SEL),
514 #endif
516 static struct platform_device bfin_capture_device = {
517 .name = "bfin_capture",
518 .dev = {
519 .platform_data = &bfin_capture_data,
522 #endif
524 #if IS_ENABLED(CONFIG_SND_BF5XX_I2S)
525 static struct platform_device bfin_i2s = {
526 .name = "bfin-i2s",
527 .id = CONFIG_SND_BF5XX_SPORT_NUM,
528 /* TODO: add platform data here */
530 #endif
532 #if IS_ENABLED(CONFIG_SND_BF5XX_AC97)
533 static struct platform_device bfin_ac97 = {
534 .name = "bfin-ac97",
535 .id = CONFIG_SND_BF5XX_SPORT_NUM,
536 /* TODO: add platform data here */
538 #endif
540 #if IS_ENABLED(CONFIG_SND_BF5XX_SOC_AD1836)
541 static const char * const ad1836_link[] = {
542 "bfin-i2s.0",
543 "spi0.4",
545 static struct platform_device bfin_ad1836_machine = {
546 .name = "bfin-snd-ad1836",
547 .id = -1,
548 .dev = {
549 .platform_data = (void *)ad1836_link,
552 #endif
554 static struct platform_device *ezkit_devices[] __initdata = {
556 &bfin_dpmc,
558 #if IS_ENABLED(CONFIG_SMC91X)
559 &smc91x_device,
560 #endif
562 #if IS_ENABLED(CONFIG_USB_NET2272)
563 &net2272_bfin_device,
564 #endif
566 #if IS_ENABLED(CONFIG_USB_ISP1760_HCD)
567 &bfin_isp1760_device,
568 #endif
570 #if IS_ENABLED(CONFIG_SPI_BFIN5XX)
571 &bfin_spi0_device,
572 #endif
574 #if IS_ENABLED(CONFIG_SERIAL_BFIN)
575 #ifdef CONFIG_SERIAL_BFIN_UART0
576 &bfin_uart0_device,
577 #endif
578 #endif
580 #if IS_ENABLED(CONFIG_BFIN_SIR)
581 #ifdef CONFIG_BFIN_SIR0
582 &bfin_sir0_device,
583 #endif
584 #endif
586 #if IS_ENABLED(CONFIG_KEYBOARD_GPIO)
587 &bfin_device_gpiokeys,
588 #endif
590 #if IS_ENABLED(CONFIG_I2C_GPIO)
591 &i2c_gpio_device,
592 #endif
594 #if IS_ENABLED(CONFIG_USB_ISP1362_HCD)
595 &isp1362_hcd_device,
596 #endif
598 #if IS_ENABLED(CONFIG_MTD_PHYSMAP)
599 &ezkit_flash_device,
600 #endif
602 #if IS_ENABLED(CONFIG_VIDEO_BLACKFIN_CAPTURE)
603 &bfin_capture_device,
604 #endif
606 #if IS_ENABLED(CONFIG_SND_BF5XX_I2S)
607 &bfin_i2s,
608 #endif
610 #if IS_ENABLED(CONFIG_SND_BF5XX_AC97)
611 &bfin_ac97,
612 #endif
614 #if IS_ENABLED(CONFIG_SND_BF5XX_SOC_AD1836)
615 &bfin_ad1836_machine,
616 #endif
619 static int __init net2272_init(void)
621 #if IS_ENABLED(CONFIG_USB_NET2272)
622 int ret;
624 ret = gpio_request(GPIO_PF11, "net2272");
625 if (ret)
626 return ret;
628 /* Reset the USB chip */
629 gpio_direction_output(GPIO_PF11, 0);
630 mdelay(2);
631 gpio_set_value(GPIO_PF11, 1);
632 #endif
634 return 0;
637 static int __init ezkit_init(void)
639 int ret;
641 printk(KERN_INFO "%s(): registering device resources\n", __func__);
643 #if IS_ENABLED(CONFIG_I2C_GPIO)
644 gpiod_add_lookup_table(&bfin_i2c_gpiod_table);
645 #endif
646 ret = platform_add_devices(ezkit_devices, ARRAY_SIZE(ezkit_devices));
647 if (ret < 0)
648 return ret;
650 #if IS_ENABLED(CONFIG_SMC91X)
651 bfin_write_FIO0_DIR(bfin_read_FIO0_DIR() | (1 << 12));
652 SSYNC();
653 #endif
655 #if IS_ENABLED(CONFIG_SND_BF5XX_SOC_AD183X)
656 bfin_write_FIO0_DIR(bfin_read_FIO0_DIR() | (1 << 15));
657 bfin_write_FIO0_FLAG_S(1 << 15);
658 SSYNC();
660 * This initialization lasts for approximately 4500 MCLKs.
661 * MCLK = 12.288MHz
663 udelay(400);
664 #endif
666 if (net2272_init())
667 pr_warning("unable to configure net2272; it probably won't work\n");
669 spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
670 return 0;
673 arch_initcall(ezkit_init);
675 static struct platform_device *ezkit_early_devices[] __initdata = {
676 #if defined(CONFIG_SERIAL_BFIN_CONSOLE) || defined(CONFIG_EARLY_PRINTK)
677 #ifdef CONFIG_SERIAL_BFIN_UART0
678 &bfin_uart0_device,
679 #endif
680 #endif
683 void __init native_machine_early_platform_add_devices(void)
685 printk(KERN_INFO "register early platform devices\n");
686 early_platform_add_devices(ezkit_early_devices,
687 ARRAY_SIZE(ezkit_early_devices));