Merge branch 'locking-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
[cris-mirror.git] / arch / blackfin / mach-bf533 / boards / ezkit.c
blobd64d270e9e62ad2d71e2e4697f71fb7d30ef012e
1 /*
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.
7 */
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>
19 #endif
20 #include <linux/irq.h>
21 #include <linux/i2c.h>
22 #include <linux/gpio/machine.h>
23 #include <asm/dma.h>
24 #include <asm/bfin5xx_spi.h>
25 #include <asm/portmux.h>
26 #include <asm/dpmc.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 = {
35 .name = "rtc-bfin",
36 .id = -1,
38 #endif
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",
56 .start = 0x20310300,
57 .end = 0x20310300 + 16,
58 .flags = IORESOURCE_MEM,
59 }, {
60 .start = IRQ_PF9,
61 .end = IRQ_PF9,
62 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
65 static struct platform_device smc91x_device = {
66 .name = "smc91x",
67 .id = 0,
68 .num_resources = ARRAY_SIZE(smc91x_resources),
69 .resource = smc91x_resources,
70 .dev = {
71 .platform_data = &smc91x_info,
74 #endif
76 #if IS_ENABLED(CONFIG_MTD_PHYSMAP)
77 static struct mtd_partition ezkit_partitions_a[] = {
79 .name = "bootloader(nor a)",
80 .size = 0x40000,
81 .offset = 0,
82 }, {
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 = {
90 .width = 2,
91 .parts = ezkit_partitions_a,
92 .nr_parts = ARRAY_SIZE(ezkit_partitions_a),
95 static struct resource ezkit_flash_resource_a = {
96 .start = 0x20000000,
97 .end = 0x200fffff,
98 .flags = IORESOURCE_MEM,
101 static struct platform_device ezkit_flash_device_a = {
102 .name = "physmap-flash",
103 .id = 0,
104 .dev = {
105 .platform_data = &ezkit_flash_data_a,
107 .num_resources = 1,
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 = {
120 .width = 2,
121 .parts = ezkit_partitions_b,
122 .nr_parts = ARRAY_SIZE(ezkit_partitions_b),
125 static struct resource ezkit_flash_resource_b = {
126 .start = 0x20100000,
127 .end = 0x201fffff,
128 .flags = IORESOURCE_MEM,
131 static struct platform_device ezkit_flash_device_b = {
132 .name = "physmap-flash",
133 .id = 4,
134 .dev = {
135 .platform_data = &ezkit_flash_data_b,
137 .num_resources = 1,
138 .resource = &ezkit_flash_resource_b,
140 #endif
142 #if IS_ENABLED(CONFIG_MTD_PLATRAM)
143 static struct platdata_mtd_ram sram_data_a = {
144 .mapname = "Flash A SRAM",
145 .bankwidth = 2,
148 static struct resource sram_resource_a = {
149 .start = 0x20240000,
150 .end = 0x2024ffff,
151 .flags = IORESOURCE_MEM,
154 static struct platform_device sram_device_a = {
155 .name = "mtd-ram",
156 .id = 8,
157 .dev = {
158 .platform_data = &sram_data_a,
160 .num_resources = 1,
161 .resource = &sram_resource_a,
164 static struct platdata_mtd_ram sram_data_b = {
165 .mapname = "Flash B SRAM",
166 .bankwidth = 2,
169 static struct resource sram_resource_b = {
170 .start = 0x202c0000,
171 .end = 0x202cffff,
172 .flags = IORESOURCE_MEM,
175 static struct platform_device sram_device_b = {
176 .name = "mtd-ram",
177 .id = 9,
178 .dev = {
179 .platform_data = &sram_data_b,
181 .num_resources = 1,
182 .resource = &sram_resource_b,
184 #endif
186 #if IS_ENABLED(CONFIG_MTD_M25P80)
187 static struct mtd_partition bfin_spi_flash_partitions[] = {
189 .name = "bootloader(spi)",
190 .size = 0x00020000,
191 .offset = 0,
192 .mask_flags = MTD_CAP_ROM
193 }, {
194 .name = "linux kernel(spi)",
195 .size = 0xe0000,
196 .offset = MTDPART_OFS_APPEND,
197 }, {
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 = {
205 .name = "m25p80",
206 .parts = bfin_spi_flash_partitions,
207 .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
208 .type = "m25p64",
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*/
215 #endif
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,
227 .mode = SPI_MODE_3,
229 #endif
231 #if IS_ENABLED(CONFIG_SND_BF5XX_SOC_AD183X)
233 .modalias = "ad183x",
234 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
235 .bus_num = 0,
236 .chip_select = 4,
238 #endif
239 #if IS_ENABLED(CONFIG_SPI_SPIDEV)
241 .modalias = "spidev",
242 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
243 .bus_num = 0,
244 .chip_select = 1,
246 #endif
249 #if IS_ENABLED(CONFIG_SPI_BFIN5XX)
250 /* SPI (0) */
251 static struct resource bfin_spi0_resource[] = {
252 [0] = {
253 .start = SPI0_REGBASE,
254 .end = SPI0_REGBASE + 0xFF,
255 .flags = IORESOURCE_MEM,
257 [1] = {
258 .start = CH_SPI,
259 .end = CH_SPI,
260 .flags = IORESOURCE_DMA,
262 [2] = {
263 .start = IRQ_SPI,
264 .end = IRQ_SPI,
265 .flags = IORESOURCE_IRQ,
269 /* SPI controller data */
270 static struct bfin5xx_spi_master bfin_spi0_info = {
271 .num_chipselect = 8,
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 = {
277 .name = "bfin-spi",
278 .id = 0, /* Bus number */
279 .num_resources = ARRAY_SIZE(bfin_spi0_resource),
280 .resource = bfin_spi0_resource,
281 .dev = {
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,
297 .end = IRQ_UART0_TX,
298 .flags = IORESOURCE_IRQ,
301 .start = IRQ_UART0_RX,
302 .end = 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,
312 .end = CH_UART0_TX,
313 .flags = IORESOURCE_DMA,
316 .start = CH_UART0_RX,
317 .end = 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 = {
327 .name = "bfin-uart",
328 .id = 0,
329 .num_resources = ARRAY_SIZE(bfin_uart0_resources),
330 .resource = bfin_uart0_resources,
331 .dev = {
332 .platform_data = &bfin_uart0_peripherals, /* Passed to driver */
335 #endif
336 #endif
338 #if IS_ENABLED(CONFIG_BFIN_SIR)
339 #ifdef CONFIG_BFIN_SIR0
340 static struct resource bfin_sir0_resources[] = {
342 .start = 0xFFC00400,
343 .end = 0xFFC004FF,
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 = {
359 .name = "bfin_sir",
360 .id = 0,
361 .num_resources = ARRAY_SIZE(bfin_sir0_resources),
362 .resource = bfin_sir0_resources,
364 #endif
365 #endif
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 = {
384 .name = "gpio-keys",
385 .dev = {
386 .platform_data = &bfin_gpio_keys_data,
389 #endif
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",
396 .table = {
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 = {
405 .udelay = 40,
408 static struct platform_device i2c_gpio_device = {
409 .name = "i2c-gpio",
410 .id = 0,
411 .dev = {
412 .platform_data = &i2c_gpio_data,
415 #endif
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 = {
438 .name = "bfin dpmc",
439 .dev = {
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),
449 #endif
452 #if IS_ENABLED(CONFIG_SND_BF5XX_I2S)
453 static struct platform_device bfin_i2s = {
454 .name = "bfin-i2s",
455 .id = CONFIG_SND_BF5XX_SPORT_NUM,
456 /* TODO: add platform data here */
458 #endif
460 #if IS_ENABLED(CONFIG_SND_BF5XX_AC97)
461 static struct platform_device bfin_ac97 = {
462 .name = "bfin-ac97",
463 .id = CONFIG_SND_BF5XX_SPORT_NUM,
464 /* TODO: add platform data here */
466 #endif
468 static struct platform_device *ezkit_devices[] __initdata = {
470 &bfin_dpmc,
472 #if IS_ENABLED(CONFIG_MTD_PHYSMAP)
473 &ezkit_flash_device_a,
474 &ezkit_flash_device_b,
475 #endif
477 #if IS_ENABLED(CONFIG_MTD_PLATRAM)
478 &sram_device_a,
479 &sram_device_b,
480 #endif
482 #if IS_ENABLED(CONFIG_SMC91X)
483 &smc91x_device,
484 #endif
486 #if IS_ENABLED(CONFIG_SPI_BFIN5XX)
487 &bfin_spi0_device,
488 #endif
490 #if IS_ENABLED(CONFIG_RTC_DRV_BFIN)
491 &rtc_device,
492 #endif
494 #if IS_ENABLED(CONFIG_SERIAL_BFIN)
495 #ifdef CONFIG_SERIAL_BFIN_UART0
496 &bfin_uart0_device,
497 #endif
498 #endif
500 #if IS_ENABLED(CONFIG_BFIN_SIR)
501 #ifdef CONFIG_BFIN_SIR0
502 &bfin_sir0_device,
503 #endif
504 #endif
506 #if IS_ENABLED(CONFIG_KEYBOARD_GPIO)
507 &bfin_device_gpiokeys,
508 #endif
510 #if IS_ENABLED(CONFIG_I2C_GPIO)
511 &i2c_gpio_device,
512 #endif
514 #if IS_ENABLED(CONFIG_SND_BF5XX_I2S)
515 &bfin_i2s,
516 #endif
518 #if IS_ENABLED(CONFIG_SND_BF5XX_AC97)
519 &bfin_ac97,
520 #endif
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);
528 #endif
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));
533 return 0;
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
541 &bfin_uart0_device,
542 #endif
543 #endif
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));