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>
22 #include <linux/gpio/machine.h>
24 #include <asm/bfin5xx_spi.h>
25 #include <asm/portmux.h>
29 * Name the Board for the /proc/cpuinfo
31 const char bfin_board_name
[] = "ADI BF533-EZKIT";
33 #if IS_ENABLED(CONFIG_RTC_DRV_BFIN)
34 static struct platform_device rtc_device
= {
41 * USB-LAN EzExtender board
42 * Driver needs to know address, irq and flag pin.
44 #if IS_ENABLED(CONFIG_SMC91X)
45 #include <linux/smc91x.h>
47 static struct smc91x_platdata smc91x_info
= {
48 .flags
= SMC91X_USE_16BIT
| SMC91X_NOWAIT
,
49 .leda
= RPC_LED_100_10
,
50 .ledb
= RPC_LED_TX_RX
,
53 static struct resource smc91x_resources
[] = {
55 .name
= "smc91x-regs",
57 .end
= 0x20310300 + 16,
58 .flags
= IORESOURCE_MEM
,
62 .flags
= IORESOURCE_IRQ
| IORESOURCE_IRQ_HIGHLEVEL
,
65 static struct platform_device smc91x_device
= {
68 .num_resources
= ARRAY_SIZE(smc91x_resources
),
69 .resource
= smc91x_resources
,
71 .platform_data
= &smc91x_info
,
76 #if IS_ENABLED(CONFIG_MTD_PHYSMAP)
77 static struct mtd_partition ezkit_partitions_a
[] = {
79 .name
= "bootloader(nor a)",
83 .name
= "linux kernel(nor a)",
84 .size
= MTDPART_SIZ_FULL
,
85 .offset
= MTDPART_OFS_APPEND
,
89 static struct physmap_flash_data ezkit_flash_data_a
= {
91 .parts
= ezkit_partitions_a
,
92 .nr_parts
= ARRAY_SIZE(ezkit_partitions_a
),
95 static struct resource ezkit_flash_resource_a
= {
98 .flags
= IORESOURCE_MEM
,
101 static struct platform_device ezkit_flash_device_a
= {
102 .name
= "physmap-flash",
105 .platform_data
= &ezkit_flash_data_a
,
108 .resource
= &ezkit_flash_resource_a
,
111 static struct mtd_partition ezkit_partitions_b
[] = {
113 .name
= "file system(nor b)",
114 .size
= MTDPART_SIZ_FULL
,
115 .offset
= MTDPART_OFS_APPEND
,
119 static struct physmap_flash_data ezkit_flash_data_b
= {
121 .parts
= ezkit_partitions_b
,
122 .nr_parts
= ARRAY_SIZE(ezkit_partitions_b
),
125 static struct resource ezkit_flash_resource_b
= {
128 .flags
= IORESOURCE_MEM
,
131 static struct platform_device ezkit_flash_device_b
= {
132 .name
= "physmap-flash",
135 .platform_data
= &ezkit_flash_data_b
,
138 .resource
= &ezkit_flash_resource_b
,
142 #if IS_ENABLED(CONFIG_MTD_PLATRAM)
143 static struct platdata_mtd_ram sram_data_a
= {
144 .mapname
= "Flash A SRAM",
148 static struct resource sram_resource_a
= {
151 .flags
= IORESOURCE_MEM
,
154 static struct platform_device sram_device_a
= {
158 .platform_data
= &sram_data_a
,
161 .resource
= &sram_resource_a
,
164 static struct platdata_mtd_ram sram_data_b
= {
165 .mapname
= "Flash B SRAM",
169 static struct resource sram_resource_b
= {
172 .flags
= IORESOURCE_MEM
,
175 static struct platform_device sram_device_b
= {
179 .platform_data
= &sram_data_b
,
182 .resource
= &sram_resource_b
,
186 #if IS_ENABLED(CONFIG_MTD_M25P80)
187 static struct mtd_partition bfin_spi_flash_partitions
[] = {
189 .name
= "bootloader(spi)",
192 .mask_flags
= MTD_CAP_ROM
194 .name
= "linux kernel(spi)",
196 .offset
= MTDPART_OFS_APPEND
,
198 .name
= "file system(spi)",
199 .size
= MTDPART_SIZ_FULL
,
200 .offset
= MTDPART_OFS_APPEND
,
204 static struct flash_platform_data bfin_spi_flash_data
= {
206 .parts
= bfin_spi_flash_partitions
,
207 .nr_parts
= ARRAY_SIZE(bfin_spi_flash_partitions
),
211 /* SPI flash chip (m25p64) */
212 static struct bfin5xx_spi_chip spi_flash_chip_info
= {
213 .enable_dma
= 0, /* use dma transfer with this chip*/
217 static struct spi_board_info bfin_spi_board_info
[] __initdata
= {
218 #if IS_ENABLED(CONFIG_MTD_M25P80)
220 /* the modalias must be the same as spi device driver name */
221 .modalias
= "m25p80", /* Name of spi_driver for this device */
222 .max_speed_hz
= 25000000, /* max spi clock (SCK) speed in HZ */
223 .bus_num
= 0, /* Framework bus number */
224 .chip_select
= 2, /* Framework chip select. On STAMP537 it is SPISSEL2*/
225 .platform_data
= &bfin_spi_flash_data
,
226 .controller_data
= &spi_flash_chip_info
,
231 #if IS_ENABLED(CONFIG_SND_BF5XX_SOC_AD183X)
233 .modalias
= "ad183x",
234 .max_speed_hz
= 3125000, /* max spi clock (SCK) speed in HZ */
239 #if IS_ENABLED(CONFIG_SPI_SPIDEV)
241 .modalias
= "spidev",
242 .max_speed_hz
= 3125000, /* max spi clock (SCK) speed in HZ */
249 #if IS_ENABLED(CONFIG_SPI_BFIN5XX)
251 static struct resource bfin_spi0_resource
[] = {
253 .start
= SPI0_REGBASE
,
254 .end
= SPI0_REGBASE
+ 0xFF,
255 .flags
= IORESOURCE_MEM
,
260 .flags
= IORESOURCE_DMA
,
265 .flags
= IORESOURCE_IRQ
,
269 /* SPI controller data */
270 static struct bfin5xx_spi_master bfin_spi0_info
= {
272 .enable_dma
= 1, /* master has the ability to do dma transfer */
273 .pin_req
= {P_SPI0_SCK
, P_SPI0_MISO
, P_SPI0_MOSI
, 0},
276 static struct platform_device bfin_spi0_device
= {
278 .id
= 0, /* Bus number */
279 .num_resources
= ARRAY_SIZE(bfin_spi0_resource
),
280 .resource
= bfin_spi0_resource
,
282 .platform_data
= &bfin_spi0_info
, /* Passed to driver */
285 #endif /* spi master and devices */
287 #if IS_ENABLED(CONFIG_SERIAL_BFIN)
288 #ifdef CONFIG_SERIAL_BFIN_UART0
289 static struct resource bfin_uart0_resources
[] = {
291 .start
= BFIN_UART_THR
,
292 .end
= BFIN_UART_GCTL
+2,
293 .flags
= IORESOURCE_MEM
,
296 .start
= IRQ_UART0_TX
,
298 .flags
= IORESOURCE_IRQ
,
301 .start
= IRQ_UART0_RX
,
303 .flags
= IORESOURCE_IRQ
,
306 .start
= IRQ_UART0_ERROR
,
307 .end
= IRQ_UART0_ERROR
,
308 .flags
= IORESOURCE_IRQ
,
311 .start
= CH_UART0_TX
,
313 .flags
= IORESOURCE_DMA
,
316 .start
= CH_UART0_RX
,
318 .flags
= IORESOURCE_DMA
,
322 static unsigned short bfin_uart0_peripherals
[] = {
323 P_UART0_TX
, P_UART0_RX
, 0
326 static struct platform_device bfin_uart0_device
= {
329 .num_resources
= ARRAY_SIZE(bfin_uart0_resources
),
330 .resource
= bfin_uart0_resources
,
332 .platform_data
= &bfin_uart0_peripherals
, /* Passed to driver */
338 #if IS_ENABLED(CONFIG_BFIN_SIR)
339 #ifdef CONFIG_BFIN_SIR0
340 static struct resource bfin_sir0_resources
[] = {
344 .flags
= IORESOURCE_MEM
,
347 .start
= IRQ_UART0_RX
,
348 .end
= IRQ_UART0_RX
+1,
349 .flags
= IORESOURCE_IRQ
,
352 .start
= CH_UART0_RX
,
353 .end
= CH_UART0_RX
+1,
354 .flags
= IORESOURCE_DMA
,
358 static struct platform_device bfin_sir0_device
= {
361 .num_resources
= ARRAY_SIZE(bfin_sir0_resources
),
362 .resource
= bfin_sir0_resources
,
367 #if IS_ENABLED(CONFIG_KEYBOARD_GPIO)
368 #include <linux/input.h>
369 #include <linux/gpio_keys.h>
371 static struct gpio_keys_button bfin_gpio_keys_table
[] = {
372 {BTN_0
, GPIO_PF7
, 1, "gpio-keys: BTN0"},
373 {BTN_1
, GPIO_PF8
, 1, "gpio-keys: BTN1"},
374 {BTN_2
, GPIO_PF9
, 1, "gpio-keys: BTN2"},
375 {BTN_3
, GPIO_PF10
, 1, "gpio-keys: BTN3"},
378 static struct gpio_keys_platform_data bfin_gpio_keys_data
= {
379 .buttons
= bfin_gpio_keys_table
,
380 .nbuttons
= ARRAY_SIZE(bfin_gpio_keys_table
),
383 static struct platform_device bfin_device_gpiokeys
= {
386 .platform_data
= &bfin_gpio_keys_data
,
391 #if IS_ENABLED(CONFIG_I2C_GPIO)
392 #include <linux/i2c-gpio.h>
394 static struct gpiod_lookup_table bfin_i2c_gpiod_table
= {
395 .dev_id
= "i2c-gpio",
397 GPIO_LOOKUP_IDX("BFIN-GPIO", GPIO_PF1
, NULL
, 0,
398 GPIO_ACTIVE_HIGH
| GPIO_OPEN_DRAIN
),
399 GPIO_LOOKUP_IDX("BFIN-GPIO", GPIO_PF0
, NULL
, 1,
400 GPIO_ACTIVE_HIGH
| GPIO_OPEN_DRAIN
),
404 static struct i2c_gpio_platform_data i2c_gpio_data
= {
408 static struct platform_device i2c_gpio_device
= {
412 .platform_data
= &i2c_gpio_data
,
417 static const unsigned int cclk_vlev_datasheet
[] =
419 VRPAIR(VLEV_085
, 250000000),
420 VRPAIR(VLEV_090
, 376000000),
421 VRPAIR(VLEV_095
, 426000000),
422 VRPAIR(VLEV_100
, 426000000),
423 VRPAIR(VLEV_105
, 476000000),
424 VRPAIR(VLEV_110
, 476000000),
425 VRPAIR(VLEV_115
, 476000000),
426 VRPAIR(VLEV_120
, 600000000),
427 VRPAIR(VLEV_125
, 600000000),
428 VRPAIR(VLEV_130
, 600000000),
431 static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data
= {
432 .tuple_tab
= cclk_vlev_datasheet
,
433 .tabsize
= ARRAY_SIZE(cclk_vlev_datasheet
),
434 .vr_settling_time
= 25 /* us */,
437 static struct platform_device bfin_dpmc
= {
440 .platform_data
= &bfin_dmpc_vreg_data
,
444 static struct i2c_board_info __initdata bfin_i2c_board_info
[] = {
445 #if IS_ENABLED(CONFIG_FB_BFIN_7393)
447 I2C_BOARD_INFO("bfin-adv7393", 0x2B),
452 #if IS_ENABLED(CONFIG_SND_BF5XX_I2S)
453 static struct platform_device bfin_i2s
= {
455 .id
= CONFIG_SND_BF5XX_SPORT_NUM
,
456 /* TODO: add platform data here */
460 #if IS_ENABLED(CONFIG_SND_BF5XX_AC97)
461 static struct platform_device bfin_ac97
= {
463 .id
= CONFIG_SND_BF5XX_SPORT_NUM
,
464 /* TODO: add platform data here */
468 static struct platform_device
*ezkit_devices
[] __initdata
= {
472 #if IS_ENABLED(CONFIG_MTD_PHYSMAP)
473 &ezkit_flash_device_a
,
474 &ezkit_flash_device_b
,
477 #if IS_ENABLED(CONFIG_MTD_PLATRAM)
482 #if IS_ENABLED(CONFIG_SMC91X)
486 #if IS_ENABLED(CONFIG_SPI_BFIN5XX)
490 #if IS_ENABLED(CONFIG_RTC_DRV_BFIN)
494 #if IS_ENABLED(CONFIG_SERIAL_BFIN)
495 #ifdef CONFIG_SERIAL_BFIN_UART0
500 #if IS_ENABLED(CONFIG_BFIN_SIR)
501 #ifdef CONFIG_BFIN_SIR0
506 #if IS_ENABLED(CONFIG_KEYBOARD_GPIO)
507 &bfin_device_gpiokeys
,
510 #if IS_ENABLED(CONFIG_I2C_GPIO)
514 #if IS_ENABLED(CONFIG_SND_BF5XX_I2S)
518 #if IS_ENABLED(CONFIG_SND_BF5XX_AC97)
523 static int __init
ezkit_init(void)
525 printk(KERN_INFO
"%s(): registering device resources\n", __func__
);
526 #if IS_ENABLED(CONFIG_I2C_GPIO)
527 gpiod_add_lookup_table(&bfin_i2c_gpiod_table
);
529 platform_add_devices(ezkit_devices
, ARRAY_SIZE(ezkit_devices
));
530 spi_register_board_info(bfin_spi_board_info
, ARRAY_SIZE(bfin_spi_board_info
));
531 i2c_register_board_info(0, bfin_i2c_board_info
,
532 ARRAY_SIZE(bfin_i2c_board_info
));
536 arch_initcall(ezkit_init
);
538 static struct platform_device
*ezkit_early_devices
[] __initdata
= {
539 #if defined(CONFIG_SERIAL_BFIN_CONSOLE) || defined(CONFIG_EARLY_PRINTK)
540 #ifdef CONFIG_SERIAL_BFIN_UART0
546 void __init
native_machine_early_platform_add_devices(void)
548 printk(KERN_INFO
"register early platform devices\n");
549 early_platform_add_devices(ezkit_early_devices
,
550 ARRAY_SIZE(ezkit_early_devices
));