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/delay.h>
19 #include <asm/bfin5xx_spi.h>
20 #include <asm/portmux.h>
24 * Name the Board for the /proc/cpuinfo
26 const char bfin_board_name[] = "ADI BF561-EZKIT";
28 #if defined(CONFIG_USB_ISP1760_HCD) || defined(CONFIG_USB_ISP1760_HCD_MODULE)
29 #include <linux/usb/isp1760.h>
30 static struct resource bfin_isp1760_resources[] = {
33 .end = 0x203C0000 + 0xfffff,
34 .flags = IORESOURCE_MEM,
39 .flags = IORESOURCE_IRQ,
43 static struct isp1760_platform_data isp1760_priv = {
48 .dack_polarity_high = 0,
49 .dreq_polarity_high = 0,
52 static struct platform_device bfin_isp1760_device = {
56 .platform_data = &isp1760_priv,
58 .num_resources = ARRAY_SIZE(bfin_isp1760_resources),
59 .resource = bfin_isp1760_resources,
63 #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
64 #include <linux/usb/isp1362.h>
66 static struct resource isp1362_hcd_resources[] = {
70 .flags = IORESOURCE_MEM,
74 .flags = IORESOURCE_MEM,
78 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWEDGE,
82 static struct isp1362_platform_data isp1362_priv = {
87 .int_edge_triggered = 0,
88 .remote_wakeup_connected = 0,
89 .no_power_switching = 1,
90 .power_switching_mode = 0,
93 static struct platform_device isp1362_hcd_device = {
94 .name = "isp1362-hcd",
97 .platform_data = &isp1362_priv,
99 .num_resources = ARRAY_SIZE(isp1362_hcd_resources),
100 .resource = isp1362_hcd_resources,
104 #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
105 static struct resource net2272_bfin_resources[] = {
108 .end = 0x2C000000 + 0x7F,
109 .flags = IORESOURCE_MEM,
113 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
117 static struct platform_device net2272_bfin_device = {
120 .num_resources = ARRAY_SIZE(net2272_bfin_resources),
121 .resource = net2272_bfin_resources,
126 * USB-LAN EzExtender board
127 * Driver needs to know address, irq and flag pin.
129 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
130 #include <linux/smc91x.h>
132 static struct smc91x_platdata smc91x_info = {
133 .flags = SMC91X_USE_32BIT | SMC91X_NOWAIT,
134 .leda = RPC_LED_100_10,
135 .ledb = RPC_LED_TX_RX,
138 static struct resource smc91x_resources[] = {
140 .name = "smc91x-regs",
142 .end = 0x2C010300 + 16,
143 .flags = IORESOURCE_MEM,
148 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
152 static struct platform_device smc91x_device = {
155 .num_resources = ARRAY_SIZE(smc91x_resources),
156 .resource = smc91x_resources,
158 .platform_data = &smc91x_info,
163 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
164 #ifdef CONFIG_SERIAL_BFIN_UART0
165 static struct resource bfin_uart0_resources[] = {
167 .start = BFIN_UART_THR,
168 .end = BFIN_UART_GCTL+2,
169 .flags = IORESOURCE_MEM,
172 .start = IRQ_UART_RX,
173 .end = IRQ_UART_RX+1,
174 .flags = IORESOURCE_IRQ,
177 .start = IRQ_UART_ERROR,
178 .end = IRQ_UART_ERROR,
179 .flags = IORESOURCE_IRQ,
184 .flags = IORESOURCE_DMA,
189 .flags = IORESOURCE_DMA,
193 unsigned short bfin_uart0_peripherals[] = {
194 P_UART0_TX, P_UART0_RX, 0
197 static struct platform_device bfin_uart0_device = {
200 .num_resources = ARRAY_SIZE(bfin_uart0_resources),
201 .resource = bfin_uart0_resources,
203 .platform_data = &bfin_uart0_peripherals, /* Passed to driver */
209 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
210 #ifdef CONFIG_BFIN_SIR0
211 static struct resource bfin_sir0_resources[] = {
215 .flags = IORESOURCE_MEM,
218 .start = IRQ_UART0_RX,
219 .end = IRQ_UART0_RX+1,
220 .flags = IORESOURCE_IRQ,
223 .start = CH_UART0_RX,
224 .end = CH_UART0_RX+1,
225 .flags = IORESOURCE_DMA,
229 static struct platform_device bfin_sir0_device = {
232 .num_resources = ARRAY_SIZE(bfin_sir0_resources),
233 .resource = bfin_sir0_resources,
238 #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
239 static struct mtd_partition ezkit_partitions[] = {
241 .name = "bootloader(nor)",
245 .name = "linux kernel(nor)",
247 .offset = MTDPART_OFS_APPEND,
249 .name = "file system(nor)",
250 .size = MTDPART_SIZ_FULL,
251 .offset = MTDPART_OFS_APPEND,
255 static struct physmap_flash_data ezkit_flash_data = {
257 .parts = ezkit_partitions,
258 .nr_parts = ARRAY_SIZE(ezkit_partitions),
261 static struct resource ezkit_flash_resource = {
264 .flags = IORESOURCE_MEM,
267 static struct platform_device ezkit_flash_device = {
268 .name = "physmap-flash",
271 .platform_data = &ezkit_flash_data,
274 .resource = &ezkit_flash_resource,
278 #if defined(CONFIG_SND_BF5XX_SOC_AD183X) \
279 || defined(CONFIG_SND_BF5XX_SOC_AD183X_MODULE)
280 static struct bfin5xx_spi_chip ad1836_spi_chip_info = {
286 #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
287 static struct bfin5xx_spi_chip spidev_chip_info = {
293 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
295 static struct resource bfin_spi0_resource[] = {
297 .start = SPI0_REGBASE,
298 .end = SPI0_REGBASE + 0xFF,
299 .flags = IORESOURCE_MEM,
304 .flags = IORESOURCE_DMA,
309 .flags = IORESOURCE_IRQ,
313 /* SPI controller data */
314 static struct bfin5xx_spi_master bfin_spi0_info = {
316 .enable_dma = 1, /* master has the ability to do dma transfer */
317 .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
320 static struct platform_device bfin_spi0_device = {
322 .id = 0, /* Bus number */
323 .num_resources = ARRAY_SIZE(bfin_spi0_resource),
324 .resource = bfin_spi0_resource,
326 .platform_data = &bfin_spi0_info, /* Passed to driver */
331 static struct spi_board_info bfin_spi_board_info[] __initdata = {
332 #if defined(CONFIG_SND_BF5XX_SOC_AD183X) \
333 || defined(CONFIG_SND_BF5XX_SOC_AD183X_MODULE)
335 .modalias = "ad183x",
336 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
339 .platform_data = "ad1836", /* only includes chip name for the moment */
340 .controller_data = &ad1836_spi_chip_info,
344 #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
346 .modalias = "spidev",
347 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
350 .controller_data = &spidev_chip_info,
355 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
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 defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
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 defined(CONFIG_SND_BF5XX_I2S) || defined(CONFIG_SND_BF5XX_I2S_MODULE)
427 static struct platform_device bfin_i2s = {
429 .id = CONFIG_SND_BF5XX_SPORT_NUM,
430 /* TODO: add platform data here */
434 #if defined(CONFIG_SND_BF5XX_TDM) || defined(CONFIG_SND_BF5XX_TDM_MODULE)
435 static struct platform_device bfin_tdm = {
437 .id = CONFIG_SND_BF5XX_SPORT_NUM,
438 /* TODO: add platform data here */
442 #if defined(CONFIG_SND_BF5XX_AC97) || defined(CONFIG_SND_BF5XX_AC97_MODULE)
443 static struct platform_device bfin_ac97 = {
445 .id = CONFIG_SND_BF5XX_SPORT_NUM,
446 /* TODO: add platform data here */
450 static struct platform_device *ezkit_devices[] __initdata = {
454 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
458 #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
459 &net2272_bfin_device,
462 #if defined(CONFIG_USB_ISP1760_HCD) || defined(CONFIG_USB_ISP1760_HCD_MODULE)
463 &bfin_isp1760_device,
466 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
470 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
471 #ifdef CONFIG_SERIAL_BFIN_UART0
476 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
477 #ifdef CONFIG_BFIN_SIR0
482 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
483 &bfin_device_gpiokeys,
486 #if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
490 #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
494 #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
498 #if defined(CONFIG_SND_BF5XX_I2S) || defined(CONFIG_SND_BF5XX_I2S_MODULE)
502 #if defined(CONFIG_SND_BF5XX_TDM) || defined(CONFIG_SND_BF5XX_TDM_MODULE)
506 #if defined(CONFIG_SND_BF5XX_AC97) || defined(CONFIG_SND_BF5XX_AC97_MODULE)
511 static int __init ezkit_init(void)
515 printk(KERN_INFO "%s(): registering device resources\n", __func__);
517 ret = platform_add_devices(ezkit_devices, ARRAY_SIZE(ezkit_devices));
521 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
522 bfin_write_FIO0_DIR(bfin_read_FIO0_DIR() | (1 << 12));
526 #if defined(CONFIG_SND_BF5XX_SOC_AD183X) || defined(CONFIG_SND_BF5XX_SOC_AD183X_MODULE)
527 bfin_write_FIO0_DIR(bfin_read_FIO0_DIR() | (1 << 15));
528 bfin_write_FIO0_FLAG_S(1 << 15);
531 * This initialization lasts for approximately 4500 MCLKs.
537 spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
541 arch_initcall(ezkit_init);
543 static struct platform_device *ezkit_early_devices[] __initdata = {
544 #if defined(CONFIG_SERIAL_BFIN_CONSOLE) || defined(CONFIG_EARLY_PRINTK)
545 #ifdef CONFIG_SERIAL_BFIN_UART0
551 void __init native_machine_early_platform_add_devices(void)
553 printk(KERN_INFO "register early platform devices\n");
554 early_platform_add_devices(ezkit_early_devices,
555 ARRAY_SIZE(ezkit_early_devices));