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/plat-ram.h>
14 #include <linux/mtd/physmap.h>
15 #include <linux/spi/spi.h>
16 #include <linux/spi/flash.h>
17 #if IS_ENABLED(CONFIG_USB_ISP1362_HCD)
18 #include <linux/usb/isp1362.h>
20 #include <linux/irq.h>
21 #include <linux/i2c.h>
23 #include <asm/bfin5xx_spi.h>
24 #include <asm/portmux.h>
28 * Name the Board for the /proc/cpuinfo
30 const char bfin_board_name[] = "ADI BF533-EZKIT";
32 #if IS_ENABLED(CONFIG_RTC_DRV_BFIN)
33 static struct platform_device rtc_device = {
40 * USB-LAN EzExtender board
41 * Driver needs to know address, irq and flag pin.
43 #if IS_ENABLED(CONFIG_SMC91X)
44 #include <linux/smc91x.h>
46 static struct smc91x_platdata smc91x_info = {
47 .flags = SMC91X_USE_16BIT | SMC91X_NOWAIT,
48 .leda = RPC_LED_100_10,
49 .ledb = RPC_LED_TX_RX,
52 static struct resource smc91x_resources[] = {
54 .name = "smc91x-regs",
56 .end = 0x20310300 + 16,
57 .flags = IORESOURCE_MEM,
61 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
64 static struct platform_device smc91x_device = {
67 .num_resources = ARRAY_SIZE(smc91x_resources),
68 .resource = smc91x_resources,
70 .platform_data = &smc91x_info,
75 #if IS_ENABLED(CONFIG_MTD_PHYSMAP)
76 static struct mtd_partition ezkit_partitions_a[] = {
78 .name = "bootloader(nor a)",
82 .name = "linux kernel(nor a)",
83 .size = MTDPART_SIZ_FULL,
84 .offset = MTDPART_OFS_APPEND,
88 static struct physmap_flash_data ezkit_flash_data_a = {
90 .parts = ezkit_partitions_a,
91 .nr_parts = ARRAY_SIZE(ezkit_partitions_a),
94 static struct resource ezkit_flash_resource_a = {
97 .flags = IORESOURCE_MEM,
100 static struct platform_device ezkit_flash_device_a = {
101 .name = "physmap-flash",
104 .platform_data = &ezkit_flash_data_a,
107 .resource = &ezkit_flash_resource_a,
110 static struct mtd_partition ezkit_partitions_b[] = {
112 .name = "file system(nor b)",
113 .size = MTDPART_SIZ_FULL,
114 .offset = MTDPART_OFS_APPEND,
118 static struct physmap_flash_data ezkit_flash_data_b = {
120 .parts = ezkit_partitions_b,
121 .nr_parts = ARRAY_SIZE(ezkit_partitions_b),
124 static struct resource ezkit_flash_resource_b = {
127 .flags = IORESOURCE_MEM,
130 static struct platform_device ezkit_flash_device_b = {
131 .name = "physmap-flash",
134 .platform_data = &ezkit_flash_data_b,
137 .resource = &ezkit_flash_resource_b,
141 #if IS_ENABLED(CONFIG_MTD_PLATRAM)
142 static struct platdata_mtd_ram sram_data_a = {
143 .mapname = "Flash A SRAM",
147 static struct resource sram_resource_a = {
150 .flags = IORESOURCE_MEM,
153 static struct platform_device sram_device_a = {
157 .platform_data = &sram_data_a,
160 .resource = &sram_resource_a,
163 static struct platdata_mtd_ram sram_data_b = {
164 .mapname = "Flash B SRAM",
168 static struct resource sram_resource_b = {
171 .flags = IORESOURCE_MEM,
174 static struct platform_device sram_device_b = {
178 .platform_data = &sram_data_b,
181 .resource = &sram_resource_b,
185 #if IS_ENABLED(CONFIG_MTD_M25P80)
186 static struct mtd_partition bfin_spi_flash_partitions[] = {
188 .name = "bootloader(spi)",
191 .mask_flags = MTD_CAP_ROM
193 .name = "linux kernel(spi)",
195 .offset = MTDPART_OFS_APPEND,
197 .name = "file system(spi)",
198 .size = MTDPART_SIZ_FULL,
199 .offset = MTDPART_OFS_APPEND,
203 static struct flash_platform_data bfin_spi_flash_data = {
205 .parts = bfin_spi_flash_partitions,
206 .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
210 /* SPI flash chip (m25p64) */
211 static struct bfin5xx_spi_chip spi_flash_chip_info = {
212 .enable_dma = 0, /* use dma transfer with this chip*/
216 static struct spi_board_info bfin_spi_board_info[] __initdata = {
217 #if IS_ENABLED(CONFIG_MTD_M25P80)
219 /* the modalias must be the same as spi device driver name */
220 .modalias = "m25p80", /* Name of spi_driver for this device */
221 .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
222 .bus_num = 0, /* Framework bus number */
223 .chip_select = 2, /* Framework chip select. On STAMP537 it is SPISSEL2*/
224 .platform_data = &bfin_spi_flash_data,
225 .controller_data = &spi_flash_chip_info,
230 #if IS_ENABLED(CONFIG_SND_BF5XX_SOC_AD183X)
232 .modalias = "ad183x",
233 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
238 #if IS_ENABLED(CONFIG_SPI_SPIDEV)
240 .modalias = "spidev",
241 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
248 #if IS_ENABLED(CONFIG_SPI_BFIN5XX)
250 static struct resource bfin_spi0_resource[] = {
252 .start = SPI0_REGBASE,
253 .end = SPI0_REGBASE + 0xFF,
254 .flags = IORESOURCE_MEM,
259 .flags = IORESOURCE_DMA,
264 .flags = IORESOURCE_IRQ,
268 /* SPI controller data */
269 static struct bfin5xx_spi_master bfin_spi0_info = {
271 .enable_dma = 1, /* master has the ability to do dma transfer */
272 .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
275 static struct platform_device bfin_spi0_device = {
277 .id = 0, /* Bus number */
278 .num_resources = ARRAY_SIZE(bfin_spi0_resource),
279 .resource = bfin_spi0_resource,
281 .platform_data = &bfin_spi0_info, /* Passed to driver */
284 #endif /* spi master and devices */
286 #if IS_ENABLED(CONFIG_SERIAL_BFIN)
287 #ifdef CONFIG_SERIAL_BFIN_UART0
288 static struct resource bfin_uart0_resources[] = {
290 .start = BFIN_UART_THR,
291 .end = BFIN_UART_GCTL+2,
292 .flags = IORESOURCE_MEM,
295 .start = IRQ_UART0_TX,
297 .flags = IORESOURCE_IRQ,
300 .start = IRQ_UART0_RX,
302 .flags = IORESOURCE_IRQ,
305 .start = IRQ_UART0_ERROR,
306 .end = IRQ_UART0_ERROR,
307 .flags = IORESOURCE_IRQ,
310 .start = CH_UART0_TX,
312 .flags = IORESOURCE_DMA,
315 .start = CH_UART0_RX,
317 .flags = IORESOURCE_DMA,
321 static unsigned short bfin_uart0_peripherals[] = {
322 P_UART0_TX, P_UART0_RX, 0
325 static struct platform_device bfin_uart0_device = {
328 .num_resources = ARRAY_SIZE(bfin_uart0_resources),
329 .resource = bfin_uart0_resources,
331 .platform_data = &bfin_uart0_peripherals, /* Passed to driver */
337 #if IS_ENABLED(CONFIG_BFIN_SIR)
338 #ifdef CONFIG_BFIN_SIR0
339 static struct resource bfin_sir0_resources[] = {
343 .flags = IORESOURCE_MEM,
346 .start = IRQ_UART0_RX,
347 .end = IRQ_UART0_RX+1,
348 .flags = IORESOURCE_IRQ,
351 .start = CH_UART0_RX,
352 .end = CH_UART0_RX+1,
353 .flags = IORESOURCE_DMA,
357 static struct platform_device bfin_sir0_device = {
360 .num_resources = ARRAY_SIZE(bfin_sir0_resources),
361 .resource = bfin_sir0_resources,
366 #if IS_ENABLED(CONFIG_KEYBOARD_GPIO)
367 #include <linux/input.h>
368 #include <linux/gpio_keys.h>
370 static struct gpio_keys_button bfin_gpio_keys_table[] = {
371 {BTN_0, GPIO_PF7, 1, "gpio-keys: BTN0"},
372 {BTN_1, GPIO_PF8, 1, "gpio-keys: BTN1"},
373 {BTN_2, GPIO_PF9, 1, "gpio-keys: BTN2"},
374 {BTN_3, GPIO_PF10, 1, "gpio-keys: BTN3"},
377 static struct gpio_keys_platform_data bfin_gpio_keys_data = {
378 .buttons = bfin_gpio_keys_table,
379 .nbuttons = ARRAY_SIZE(bfin_gpio_keys_table),
382 static struct platform_device bfin_device_gpiokeys = {
385 .platform_data = &bfin_gpio_keys_data,
390 #if IS_ENABLED(CONFIG_I2C_GPIO)
391 #include <linux/i2c-gpio.h>
393 static struct i2c_gpio_platform_data i2c_gpio_data = {
396 .sda_is_open_drain = 0,
397 .scl_is_open_drain = 0,
401 static struct platform_device i2c_gpio_device = {
405 .platform_data = &i2c_gpio_data,
410 static const unsigned int cclk_vlev_datasheet[] =
412 VRPAIR(VLEV_085, 250000000),
413 VRPAIR(VLEV_090, 376000000),
414 VRPAIR(VLEV_095, 426000000),
415 VRPAIR(VLEV_100, 426000000),
416 VRPAIR(VLEV_105, 476000000),
417 VRPAIR(VLEV_110, 476000000),
418 VRPAIR(VLEV_115, 476000000),
419 VRPAIR(VLEV_120, 600000000),
420 VRPAIR(VLEV_125, 600000000),
421 VRPAIR(VLEV_130, 600000000),
424 static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
425 .tuple_tab = cclk_vlev_datasheet,
426 .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
427 .vr_settling_time = 25 /* us */,
430 static struct platform_device bfin_dpmc = {
433 .platform_data = &bfin_dmpc_vreg_data,
437 static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
438 #if IS_ENABLED(CONFIG_FB_BFIN_7393)
440 I2C_BOARD_INFO("bfin-adv7393", 0x2B),
445 #if IS_ENABLED(CONFIG_SND_BF5XX_I2S)
446 static struct platform_device bfin_i2s = {
448 .id = CONFIG_SND_BF5XX_SPORT_NUM,
449 /* TODO: add platform data here */
453 #if IS_ENABLED(CONFIG_SND_BF5XX_AC97)
454 static struct platform_device bfin_ac97 = {
456 .id = CONFIG_SND_BF5XX_SPORT_NUM,
457 /* TODO: add platform data here */
461 static struct platform_device *ezkit_devices[] __initdata = {
465 #if IS_ENABLED(CONFIG_MTD_PHYSMAP)
466 &ezkit_flash_device_a,
467 &ezkit_flash_device_b,
470 #if IS_ENABLED(CONFIG_MTD_PLATRAM)
475 #if IS_ENABLED(CONFIG_SMC91X)
479 #if IS_ENABLED(CONFIG_SPI_BFIN5XX)
483 #if IS_ENABLED(CONFIG_RTC_DRV_BFIN)
487 #if IS_ENABLED(CONFIG_SERIAL_BFIN)
488 #ifdef CONFIG_SERIAL_BFIN_UART0
493 #if IS_ENABLED(CONFIG_BFIN_SIR)
494 #ifdef CONFIG_BFIN_SIR0
499 #if IS_ENABLED(CONFIG_KEYBOARD_GPIO)
500 &bfin_device_gpiokeys,
503 #if IS_ENABLED(CONFIG_I2C_GPIO)
507 #if IS_ENABLED(CONFIG_SND_BF5XX_I2S)
511 #if IS_ENABLED(CONFIG_SND_BF5XX_AC97)
516 static int __init ezkit_init(void)
518 printk(KERN_INFO "%s(): registering device resources\n", __func__);
519 platform_add_devices(ezkit_devices, ARRAY_SIZE(ezkit_devices));
520 spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
521 i2c_register_board_info(0, bfin_i2c_board_info,
522 ARRAY_SIZE(bfin_i2c_board_info));
526 arch_initcall(ezkit_init);
528 static struct platform_device *ezkit_early_devices[] __initdata = {
529 #if defined(CONFIG_SERIAL_BFIN_CONSOLE) || defined(CONFIG_EARLY_PRINTK)
530 #ifdef CONFIG_SERIAL_BFIN_UART0
536 void __init native_machine_early_platform_add_devices(void)
538 printk(KERN_INFO "register early platform devices\n");
539 early_platform_add_devices(ezkit_early_devices,
540 ARRAY_SIZE(ezkit_early_devices));