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>
19 #include <linux/gpio/machine.h>
21 #include <asm/bfin5xx_spi.h>
22 #include <asm/portmux.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
[] = {
35 .end
= 0x203C0000 + 0xfffff,
36 .flags
= IORESOURCE_MEM
,
41 .flags
= IORESOURCE_IRQ
,
45 static struct isp1760_platform_data isp1760_priv
= {
50 .dack_polarity_high
= 0,
51 .dreq_polarity_high
= 0,
54 static struct platform_device bfin_isp1760_device
= {
58 .platform_data
= &isp1760_priv
,
60 .num_resources
= ARRAY_SIZE(bfin_isp1760_resources
),
61 .resource
= bfin_isp1760_resources
,
65 #if IS_ENABLED(CONFIG_USB_ISP1362_HCD)
66 #include <linux/usb/isp1362.h>
68 static struct resource isp1362_hcd_resources
[] = {
72 .flags
= IORESOURCE_MEM
,
76 .flags
= IORESOURCE_MEM
,
80 .flags
= IORESOURCE_IRQ
| IORESOURCE_IRQ_LOWEDGE
,
84 static struct isp1362_platform_data isp1362_priv
= {
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",
99 .platform_data
= &isp1362_priv
,
101 .num_resources
= ARRAY_SIZE(isp1362_hcd_resources
),
102 .resource
= isp1362_hcd_resources
,
106 #if IS_ENABLED(CONFIG_USB_NET2272)
107 static struct resource net2272_bfin_resources
[] = {
110 .end
= 0x2C000000 + 0x7F,
111 .flags
= IORESOURCE_MEM
,
114 .flags
= IORESOURCE_BUS
,
118 .flags
= IORESOURCE_IRQ
| IORESOURCE_IRQ_LOWLEVEL
,
122 static struct platform_device net2272_bfin_device
= {
125 .num_resources
= ARRAY_SIZE(net2272_bfin_resources
),
126 .resource
= net2272_bfin_resources
,
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
|
140 .leda
= RPC_LED_100_10
,
141 .ledb
= RPC_LED_TX_RX
,
144 static struct resource smc91x_resources
[] = {
146 .name
= "smc91x-regs",
148 .end
= 0x2C010300 + 16,
149 .flags
= IORESOURCE_MEM
,
154 .flags
= IORESOURCE_IRQ
| IORESOURCE_IRQ_HIGHLEVEL
,
158 static struct platform_device smc91x_device
= {
161 .num_resources
= ARRAY_SIZE(smc91x_resources
),
162 .resource
= smc91x_resources
,
164 .platform_data
= &smc91x_info
,
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
,
180 .flags
= IORESOURCE_IRQ
,
183 .start
= IRQ_UART_RX
,
185 .flags
= IORESOURCE_IRQ
,
188 .start
= IRQ_UART_ERROR
,
189 .end
= IRQ_UART_ERROR
,
190 .flags
= IORESOURCE_IRQ
,
195 .flags
= IORESOURCE_DMA
,
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
= {
211 .num_resources
= ARRAY_SIZE(bfin_uart0_resources
),
212 .resource
= bfin_uart0_resources
,
214 .platform_data
= &bfin_uart0_peripherals
, /* Passed to driver */
220 #if IS_ENABLED(CONFIG_BFIN_SIR)
221 #ifdef CONFIG_BFIN_SIR0
222 static struct resource bfin_sir0_resources
[] = {
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
= {
243 .num_resources
= ARRAY_SIZE(bfin_sir0_resources
),
244 .resource
= bfin_sir0_resources
,
249 #if IS_ENABLED(CONFIG_MTD_PHYSMAP)
250 static struct mtd_partition ezkit_partitions
[] = {
252 .name
= "bootloader(nor)",
256 .name
= "linux kernel(nor)",
258 .offset
= MTDPART_OFS_APPEND
,
260 .name
= "file system(nor)",
261 .size
= 0x800000 - 0x40000 - 0x1C0000 - 0x2000 * 8,
262 .offset
= MTDPART_OFS_APPEND
,
264 .name
= "config(nor)",
266 .offset
= MTDPART_OFS_APPEND
,
268 .name
= "u-boot env(nor)",
270 .offset
= MTDPART_OFS_APPEND
,
274 static struct physmap_flash_data ezkit_flash_data
= {
276 .parts
= ezkit_partitions
,
277 .nr_parts
= ARRAY_SIZE(ezkit_partitions
),
280 static struct resource ezkit_flash_resource
= {
283 .flags
= IORESOURCE_MEM
,
286 static struct platform_device ezkit_flash_device
= {
287 .name
= "physmap-flash",
290 .platform_data
= &ezkit_flash_data
,
293 .resource
= &ezkit_flash_resource
,
297 #if IS_ENABLED(CONFIG_SPI_BFIN5XX)
299 static struct resource bfin_spi0_resource
[] = {
301 .start
= SPI0_REGBASE
,
302 .end
= SPI0_REGBASE
+ 0xFF,
303 .flags
= IORESOURCE_MEM
,
308 .flags
= IORESOURCE_DMA
,
313 .flags
= IORESOURCE_IRQ
,
317 /* SPI controller data */
318 static struct bfin5xx_spi_master bfin_spi0_info
= {
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
= {
326 .id
= 0, /* Bus number */
327 .num_resources
= ARRAY_SIZE(bfin_spi0_resource
),
328 .resource
= bfin_spi0_resource
,
330 .platform_data
= &bfin_spi0_info
, /* Passed to driver */
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 */
342 .platform_data
= "ad1836", /* only includes chip name for the moment */
346 #if IS_ENABLED(CONFIG_SPI_SPIDEV)
348 .modalias
= "spidev",
349 .max_speed_hz
= 3125000, /* max spi clock (SCK) speed in HZ */
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
= {
375 .platform_data
= &bfin_gpio_keys_data
,
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",
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
= {
397 static struct platform_device i2c_gpio_device
= {
401 .platform_data
= &i2c_gpio_data
,
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
= {
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
,
448 .irq_err
= IRQ_PPI1_ERROR
,
449 .base
= (void __iomem
*)PPI0_CONTROL
,
453 #if IS_ENABLED(CONFIG_VIDEO_ADV7183)
454 #include <media/i2c/adv7183.h>
455 static struct v4l2_input adv7183_inputs
[] = {
459 .type
= V4L2_INPUT_TYPE_CAMERA
,
461 .capabilities
= V4L2_IN_CAP_STD
,
466 .type
= V4L2_INPUT_TYPE_CAMERA
,
468 .capabilities
= V4L2_IN_CAP_STD
,
473 .type
= V4L2_INPUT_TYPE_CAMERA
,
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
,
509 .platform_data
= (void *)adv7183_gpio
,
511 .ppi_info
= &ppi_info
,
512 .ppi_control
= (PACK_EN
| DLEN_8
| DMA32
| FLD_SEL
),
516 static struct platform_device bfin_capture_device
= {
517 .name
= "bfin_capture",
519 .platform_data
= &bfin_capture_data
,
524 #if IS_ENABLED(CONFIG_SND_BF5XX_I2S)
525 static struct platform_device bfin_i2s
= {
527 .id
= CONFIG_SND_BF5XX_SPORT_NUM
,
528 /* TODO: add platform data here */
532 #if IS_ENABLED(CONFIG_SND_BF5XX_AC97)
533 static struct platform_device bfin_ac97
= {
535 .id
= CONFIG_SND_BF5XX_SPORT_NUM
,
536 /* TODO: add platform data here */
540 #if IS_ENABLED(CONFIG_SND_BF5XX_SOC_AD1836)
541 static const char * const ad1836_link
[] = {
545 static struct platform_device bfin_ad1836_machine
= {
546 .name
= "bfin-snd-ad1836",
549 .platform_data
= (void *)ad1836_link
,
554 static struct platform_device
*ezkit_devices
[] __initdata
= {
558 #if IS_ENABLED(CONFIG_SMC91X)
562 #if IS_ENABLED(CONFIG_USB_NET2272)
563 &net2272_bfin_device
,
566 #if IS_ENABLED(CONFIG_USB_ISP1760_HCD)
567 &bfin_isp1760_device
,
570 #if IS_ENABLED(CONFIG_SPI_BFIN5XX)
574 #if IS_ENABLED(CONFIG_SERIAL_BFIN)
575 #ifdef CONFIG_SERIAL_BFIN_UART0
580 #if IS_ENABLED(CONFIG_BFIN_SIR)
581 #ifdef CONFIG_BFIN_SIR0
586 #if IS_ENABLED(CONFIG_KEYBOARD_GPIO)
587 &bfin_device_gpiokeys
,
590 #if IS_ENABLED(CONFIG_I2C_GPIO)
594 #if IS_ENABLED(CONFIG_USB_ISP1362_HCD)
598 #if IS_ENABLED(CONFIG_MTD_PHYSMAP)
602 #if IS_ENABLED(CONFIG_VIDEO_BLACKFIN_CAPTURE)
603 &bfin_capture_device
,
606 #if IS_ENABLED(CONFIG_SND_BF5XX_I2S)
610 #if IS_ENABLED(CONFIG_SND_BF5XX_AC97)
614 #if IS_ENABLED(CONFIG_SND_BF5XX_SOC_AD1836)
615 &bfin_ad1836_machine
,
619 static int __init
net2272_init(void)
621 #if IS_ENABLED(CONFIG_USB_NET2272)
624 ret
= gpio_request(GPIO_PF11
, "net2272");
628 /* Reset the USB chip */
629 gpio_direction_output(GPIO_PF11
, 0);
631 gpio_set_value(GPIO_PF11
, 1);
637 static int __init
ezkit_init(void)
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
);
646 ret
= platform_add_devices(ezkit_devices
, ARRAY_SIZE(ezkit_devices
));
650 #if IS_ENABLED(CONFIG_SMC91X)
651 bfin_write_FIO0_DIR(bfin_read_FIO0_DIR() | (1 << 12));
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);
660 * This initialization lasts for approximately 4500 MCLKs.
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
));
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
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
));