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>
18 #include <asm/bfin5xx_spi.h>
19 #include <asm/portmux.h>
23 * Name the Board for the /proc/cpuinfo
25 const char bfin_board_name[] = "ADI BF561-EZKIT";
27 #if defined(CONFIG_USB_ISP1760_HCD) || defined(CONFIG_USB_ISP1760_HCD_MODULE)
28 #include <linux/usb/isp1760.h>
29 static struct resource bfin_isp1760_resources[] = {
32 .end = 0x203C0000 + 0xfffff,
33 .flags = IORESOURCE_MEM,
38 .flags = IORESOURCE_IRQ,
42 static struct isp1760_platform_data isp1760_priv = {
47 .dack_polarity_high = 0,
48 .dreq_polarity_high = 0,
51 static struct platform_device bfin_isp1760_device = {
55 .platform_data = &isp1760_priv,
57 .num_resources = ARRAY_SIZE(bfin_isp1760_resources),
58 .resource = bfin_isp1760_resources,
62 #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
63 #include <linux/usb/isp1362.h>
65 static struct resource isp1362_hcd_resources[] = {
69 .flags = IORESOURCE_MEM,
73 .flags = IORESOURCE_MEM,
77 .flags = IORESOURCE_IRQ,
81 static struct isp1362_platform_data isp1362_priv = {
86 .int_edge_triggered = 0,
87 .remote_wakeup_connected = 0,
88 .no_power_switching = 1,
89 .power_switching_mode = 0,
92 static struct platform_device isp1362_hcd_device = {
93 .name = "isp1362-hcd",
96 .platform_data = &isp1362_priv,
98 .num_resources = ARRAY_SIZE(isp1362_hcd_resources),
99 .resource = isp1362_hcd_resources,
103 #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
104 static struct resource net2272_bfin_resources[] = {
107 .end = 0x2C000000 + 0x7F,
108 .flags = IORESOURCE_MEM,
112 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
116 static struct platform_device net2272_bfin_device = {
119 .num_resources = ARRAY_SIZE(net2272_bfin_resources),
120 .resource = net2272_bfin_resources,
125 * USB-LAN EzExtender board
126 * Driver needs to know address, irq and flag pin.
128 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
129 #include <linux/smc91x.h>
131 static struct smc91x_platdata smc91x_info = {
132 .flags = SMC91X_USE_32BIT | SMC91X_NOWAIT,
133 .leda = RPC_LED_100_10,
134 .ledb = RPC_LED_TX_RX,
137 static struct resource smc91x_resources[] = {
139 .name = "smc91x-regs",
141 .end = 0x2C010300 + 16,
142 .flags = IORESOURCE_MEM,
147 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
151 static struct platform_device smc91x_device = {
154 .num_resources = ARRAY_SIZE(smc91x_resources),
155 .resource = smc91x_resources,
157 .platform_data = &smc91x_info,
162 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
163 #ifdef CONFIG_SERIAL_BFIN_UART0
164 static struct resource bfin_uart0_resources[] = {
166 .start = BFIN_UART_THR,
167 .end = BFIN_UART_GCTL+2,
168 .flags = IORESOURCE_MEM,
171 .start = IRQ_UART_RX,
172 .end = IRQ_UART_RX+1,
173 .flags = IORESOURCE_IRQ,
176 .start = IRQ_UART_ERROR,
177 .end = IRQ_UART_ERROR,
178 .flags = IORESOURCE_IRQ,
183 .flags = IORESOURCE_DMA,
188 .flags = IORESOURCE_DMA,
192 unsigned short bfin_uart0_peripherals[] = {
193 P_UART0_TX, P_UART0_RX, 0
196 static struct platform_device bfin_uart0_device = {
199 .num_resources = ARRAY_SIZE(bfin_uart0_resources),
200 .resource = bfin_uart0_resources,
202 .platform_data = &bfin_uart0_peripherals, /* Passed to driver */
208 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
209 #ifdef CONFIG_BFIN_SIR0
210 static struct resource bfin_sir0_resources[] = {
214 .flags = IORESOURCE_MEM,
217 .start = IRQ_UART0_RX,
218 .end = IRQ_UART0_RX+1,
219 .flags = IORESOURCE_IRQ,
222 .start = CH_UART0_RX,
223 .end = CH_UART0_RX+1,
224 .flags = IORESOURCE_DMA,
228 static struct platform_device bfin_sir0_device = {
231 .num_resources = ARRAY_SIZE(bfin_sir0_resources),
232 .resource = bfin_sir0_resources,
237 #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
238 static struct mtd_partition ezkit_partitions[] = {
240 .name = "bootloader(nor)",
244 .name = "linux kernel(nor)",
246 .offset = MTDPART_OFS_APPEND,
248 .name = "file system(nor)",
249 .size = MTDPART_SIZ_FULL,
250 .offset = MTDPART_OFS_APPEND,
254 static struct physmap_flash_data ezkit_flash_data = {
256 .parts = ezkit_partitions,
257 .nr_parts = ARRAY_SIZE(ezkit_partitions),
260 static struct resource ezkit_flash_resource = {
263 .flags = IORESOURCE_MEM,
266 static struct platform_device ezkit_flash_device = {
267 .name = "physmap-flash",
270 .platform_data = &ezkit_flash_data,
273 .resource = &ezkit_flash_resource,
277 #if defined(CONFIG_SND_BLACKFIN_AD183X) \
278 || defined(CONFIG_SND_BLACKFIN_AD183X_MODULE)
279 static struct bfin5xx_spi_chip ad1836_spi_chip_info = {
285 #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
286 static struct bfin5xx_spi_chip spidev_chip_info = {
292 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
294 static struct resource bfin_spi0_resource[] = {
296 .start = SPI0_REGBASE,
297 .end = SPI0_REGBASE + 0xFF,
298 .flags = IORESOURCE_MEM,
303 .flags = IORESOURCE_DMA,
308 .flags = IORESOURCE_IRQ,
312 /* SPI controller data */
313 static struct bfin5xx_spi_master bfin_spi0_info = {
315 .enable_dma = 1, /* master has the ability to do dma transfer */
316 .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
319 static struct platform_device bfin_spi0_device = {
321 .id = 0, /* Bus number */
322 .num_resources = ARRAY_SIZE(bfin_spi0_resource),
323 .resource = bfin_spi0_resource,
325 .platform_data = &bfin_spi0_info, /* Passed to driver */
330 static struct spi_board_info bfin_spi_board_info[] __initdata = {
331 #if defined(CONFIG_SND_BLACKFIN_AD183X) \
332 || defined(CONFIG_SND_BLACKFIN_AD183X_MODULE)
334 .modalias = "ad1836",
335 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
337 .chip_select = CONFIG_SND_BLACKFIN_SPI_PFBIT,
338 .controller_data = &ad1836_spi_chip_info,
341 #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
343 .modalias = "spidev",
344 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
347 .controller_data = &spidev_chip_info,
352 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
353 #include <linux/input.h>
354 #include <linux/gpio_keys.h>
356 static struct gpio_keys_button bfin_gpio_keys_table[] = {
357 {BTN_0, GPIO_PF5, 1, "gpio-keys: BTN0"},
358 {BTN_1, GPIO_PF6, 1, "gpio-keys: BTN1"},
359 {BTN_2, GPIO_PF7, 1, "gpio-keys: BTN2"},
360 {BTN_3, GPIO_PF8, 1, "gpio-keys: BTN3"},
363 static struct gpio_keys_platform_data bfin_gpio_keys_data = {
364 .buttons = bfin_gpio_keys_table,
365 .nbuttons = ARRAY_SIZE(bfin_gpio_keys_table),
368 static struct platform_device bfin_device_gpiokeys = {
371 .platform_data = &bfin_gpio_keys_data,
376 #if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
377 #include <linux/i2c-gpio.h>
379 static struct i2c_gpio_platform_data i2c_gpio_data = {
382 .sda_is_open_drain = 0,
383 .scl_is_open_drain = 0,
387 static struct platform_device i2c_gpio_device = {
391 .platform_data = &i2c_gpio_data,
396 static const unsigned int cclk_vlev_datasheet[] =
398 VRPAIR(VLEV_085, 250000000),
399 VRPAIR(VLEV_090, 300000000),
400 VRPAIR(VLEV_095, 313000000),
401 VRPAIR(VLEV_100, 350000000),
402 VRPAIR(VLEV_105, 400000000),
403 VRPAIR(VLEV_110, 444000000),
404 VRPAIR(VLEV_115, 450000000),
405 VRPAIR(VLEV_120, 475000000),
406 VRPAIR(VLEV_125, 500000000),
407 VRPAIR(VLEV_130, 600000000),
410 static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
411 .tuple_tab = cclk_vlev_datasheet,
412 .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
413 .vr_settling_time = 25 /* us */,
416 static struct platform_device bfin_dpmc = {
419 .platform_data = &bfin_dmpc_vreg_data,
423 static struct platform_device *ezkit_devices[] __initdata = {
427 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
431 #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
432 &net2272_bfin_device,
435 #if defined(CONFIG_USB_ISP1760_HCD) || defined(CONFIG_USB_ISP1760_HCD_MODULE)
436 &bfin_isp1760_device,
439 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
443 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
444 #ifdef CONFIG_SERIAL_BFIN_UART0
449 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
450 #ifdef CONFIG_BFIN_SIR0
455 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
456 &bfin_device_gpiokeys,
459 #if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
463 #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
467 #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
472 static int __init ezkit_init(void)
476 printk(KERN_INFO "%s(): registering device resources\n", __func__);
478 ret = platform_add_devices(ezkit_devices, ARRAY_SIZE(ezkit_devices));
482 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
483 bfin_write_FIO0_DIR(bfin_read_FIO0_DIR() | (1 << 12));
487 spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
491 arch_initcall(ezkit_init);
493 static struct platform_device *ezkit_early_devices[] __initdata = {
494 #if defined(CONFIG_SERIAL_BFIN_CONSOLE) || defined(CONFIG_EARLY_PRINTK)
495 #ifdef CONFIG_SERIAL_BFIN_UART0
501 void __init native_machine_early_platform_add_devices(void)
503 printk(KERN_INFO "register early platform devices\n");
504 early_platform_add_devices(ezkit_early_devices,
505 ARRAY_SIZE(ezkit_early_devices));