5067984a62e78f669d4fbe99cc5eb0d62f251b4a
[deliverable/linux.git] / arch / blackfin / mach-bf561 / boards / ezkit.c
1 /*
2 * Copyright 2004-2009 Analog Devices Inc.
3 * 2005 National ICT Australia (NICTA)
4 * Aidan Williams <aidan@nicta.com.au>
5 *
6 * Licensed under the GPL-2 or later.
7 */
8
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>
18 #include <asm/dma.h>
19 #include <asm/bfin5xx_spi.h>
20 #include <asm/portmux.h>
21 #include <asm/dpmc.h>
22
23 /*
24 * Name the Board for the /proc/cpuinfo
25 */
26 const char bfin_board_name[] = "ADI BF561-EZKIT";
27
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[] = {
31 [0] = {
32 .start = 0x2C0F0000,
33 .end = 0x203C0000 + 0xfffff,
34 .flags = IORESOURCE_MEM,
35 },
36 [1] = {
37 .start = IRQ_PF10,
38 .end = IRQ_PF10,
39 .flags = IORESOURCE_IRQ,
40 },
41 };
42
43 static struct isp1760_platform_data isp1760_priv = {
44 .is_isp1761 = 0,
45 .bus_width_16 = 1,
46 .port1_otg = 0,
47 .analog_oc = 0,
48 .dack_polarity_high = 0,
49 .dreq_polarity_high = 0,
50 };
51
52 static struct platform_device bfin_isp1760_device = {
53 .name = "isp1760",
54 .id = 0,
55 .dev = {
56 .platform_data = &isp1760_priv,
57 },
58 .num_resources = ARRAY_SIZE(bfin_isp1760_resources),
59 .resource = bfin_isp1760_resources,
60 };
61 #endif
62
63 #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
64 #include <linux/usb/isp1362.h>
65
66 static struct resource isp1362_hcd_resources[] = {
67 {
68 .start = 0x2c060000,
69 .end = 0x2c060000,
70 .flags = IORESOURCE_MEM,
71 }, {
72 .start = 0x2c060004,
73 .end = 0x2c060004,
74 .flags = IORESOURCE_MEM,
75 }, {
76 .start = IRQ_PF8,
77 .end = IRQ_PF8,
78 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWEDGE,
79 },
80 };
81
82 static struct isp1362_platform_data isp1362_priv = {
83 .sel15Kres = 1,
84 .clknotstop = 0,
85 .oc_enable = 0,
86 .int_act_high = 0,
87 .int_edge_triggered = 0,
88 .remote_wakeup_connected = 0,
89 .no_power_switching = 1,
90 .power_switching_mode = 0,
91 };
92
93 static struct platform_device isp1362_hcd_device = {
94 .name = "isp1362-hcd",
95 .id = 0,
96 .dev = {
97 .platform_data = &isp1362_priv,
98 },
99 .num_resources = ARRAY_SIZE(isp1362_hcd_resources),
100 .resource = isp1362_hcd_resources,
101 };
102 #endif
103
104 #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
105 static struct resource net2272_bfin_resources[] = {
106 {
107 .start = 0x2C000000,
108 .end = 0x2C000000 + 0x7F,
109 .flags = IORESOURCE_MEM,
110 }, {
111 .start = IRQ_PF10,
112 .end = IRQ_PF10,
113 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
114 },
115 };
116
117 static struct platform_device net2272_bfin_device = {
118 .name = "net2272",
119 .id = -1,
120 .num_resources = ARRAY_SIZE(net2272_bfin_resources),
121 .resource = net2272_bfin_resources,
122 };
123 #endif
124
125 /*
126 * USB-LAN EzExtender board
127 * Driver needs to know address, irq and flag pin.
128 */
129 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
130 #include <linux/smc91x.h>
131
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,
136 };
137
138 static struct resource smc91x_resources[] = {
139 {
140 .name = "smc91x-regs",
141 .start = 0x2C010300,
142 .end = 0x2C010300 + 16,
143 .flags = IORESOURCE_MEM,
144 }, {
145
146 .start = IRQ_PF9,
147 .end = IRQ_PF9,
148 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
149 },
150 };
151
152 static struct platform_device smc91x_device = {
153 .name = "smc91x",
154 .id = 0,
155 .num_resources = ARRAY_SIZE(smc91x_resources),
156 .resource = smc91x_resources,
157 .dev = {
158 .platform_data = &smc91x_info,
159 },
160 };
161 #endif
162
163 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
164 #ifdef CONFIG_SERIAL_BFIN_UART0
165 static struct resource bfin_uart0_resources[] = {
166 {
167 .start = BFIN_UART_THR,
168 .end = BFIN_UART_GCTL+2,
169 .flags = IORESOURCE_MEM,
170 },
171 {
172 .start = IRQ_UART_RX,
173 .end = IRQ_UART_RX+1,
174 .flags = IORESOURCE_IRQ,
175 },
176 {
177 .start = IRQ_UART_ERROR,
178 .end = IRQ_UART_ERROR,
179 .flags = IORESOURCE_IRQ,
180 },
181 {
182 .start = CH_UART_TX,
183 .end = CH_UART_TX,
184 .flags = IORESOURCE_DMA,
185 },
186 {
187 .start = CH_UART_RX,
188 .end = CH_UART_RX,
189 .flags = IORESOURCE_DMA,
190 },
191 };
192
193 static unsigned short bfin_uart0_peripherals[] = {
194 P_UART0_TX, P_UART0_RX, 0
195 };
196
197 static struct platform_device bfin_uart0_device = {
198 .name = "bfin-uart",
199 .id = 0,
200 .num_resources = ARRAY_SIZE(bfin_uart0_resources),
201 .resource = bfin_uart0_resources,
202 .dev = {
203 .platform_data = &bfin_uart0_peripherals, /* Passed to driver */
204 },
205 };
206 #endif
207 #endif
208
209 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
210 #ifdef CONFIG_BFIN_SIR0
211 static struct resource bfin_sir0_resources[] = {
212 {
213 .start = 0xFFC00400,
214 .end = 0xFFC004FF,
215 .flags = IORESOURCE_MEM,
216 },
217 {
218 .start = IRQ_UART0_RX,
219 .end = IRQ_UART0_RX+1,
220 .flags = IORESOURCE_IRQ,
221 },
222 {
223 .start = CH_UART0_RX,
224 .end = CH_UART0_RX+1,
225 .flags = IORESOURCE_DMA,
226 },
227 };
228
229 static struct platform_device bfin_sir0_device = {
230 .name = "bfin_sir",
231 .id = 0,
232 .num_resources = ARRAY_SIZE(bfin_sir0_resources),
233 .resource = bfin_sir0_resources,
234 };
235 #endif
236 #endif
237
238 #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
239 static struct mtd_partition ezkit_partitions[] = {
240 {
241 .name = "bootloader(nor)",
242 .size = 0x40000,
243 .offset = 0,
244 }, {
245 .name = "linux kernel(nor)",
246 .size = 0x1C0000,
247 .offset = MTDPART_OFS_APPEND,
248 }, {
249 .name = "file system(nor)",
250 .size = 0x800000 - 0x40000 - 0x1C0000 - 0x2000 * 8,
251 .offset = MTDPART_OFS_APPEND,
252 }, {
253 .name = "config(nor)",
254 .size = 0x2000 * 7,
255 .offset = MTDPART_OFS_APPEND,
256 }, {
257 .name = "u-boot env(nor)",
258 .size = 0x2000,
259 .offset = MTDPART_OFS_APPEND,
260 }
261 };
262
263 static struct physmap_flash_data ezkit_flash_data = {
264 .width = 2,
265 .parts = ezkit_partitions,
266 .nr_parts = ARRAY_SIZE(ezkit_partitions),
267 };
268
269 static struct resource ezkit_flash_resource = {
270 .start = 0x20000000,
271 .end = 0x207fffff,
272 .flags = IORESOURCE_MEM,
273 };
274
275 static struct platform_device ezkit_flash_device = {
276 .name = "physmap-flash",
277 .id = 0,
278 .dev = {
279 .platform_data = &ezkit_flash_data,
280 },
281 .num_resources = 1,
282 .resource = &ezkit_flash_resource,
283 };
284 #endif
285
286 #if defined(CONFIG_SND_BF5XX_SOC_AD183X) \
287 || defined(CONFIG_SND_BF5XX_SOC_AD183X_MODULE)
288 static struct bfin5xx_spi_chip ad1836_spi_chip_info = {
289 .enable_dma = 0,
290 .bits_per_word = 16,
291 };
292 #endif
293
294 #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
295 static struct bfin5xx_spi_chip spidev_chip_info = {
296 .enable_dma = 0,
297 .bits_per_word = 8,
298 };
299 #endif
300
301 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
302 /* SPI (0) */
303 static struct resource bfin_spi0_resource[] = {
304 [0] = {
305 .start = SPI0_REGBASE,
306 .end = SPI0_REGBASE + 0xFF,
307 .flags = IORESOURCE_MEM,
308 },
309 [1] = {
310 .start = CH_SPI,
311 .end = CH_SPI,
312 .flags = IORESOURCE_DMA,
313 },
314 [2] = {
315 .start = IRQ_SPI,
316 .end = IRQ_SPI,
317 .flags = IORESOURCE_IRQ,
318 }
319 };
320
321 /* SPI controller data */
322 static struct bfin5xx_spi_master bfin_spi0_info = {
323 .num_chipselect = 8,
324 .enable_dma = 1, /* master has the ability to do dma transfer */
325 .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
326 };
327
328 static struct platform_device bfin_spi0_device = {
329 .name = "bfin-spi",
330 .id = 0, /* Bus number */
331 .num_resources = ARRAY_SIZE(bfin_spi0_resource),
332 .resource = bfin_spi0_resource,
333 .dev = {
334 .platform_data = &bfin_spi0_info, /* Passed to driver */
335 },
336 };
337 #endif
338
339 static struct spi_board_info bfin_spi_board_info[] __initdata = {
340 #if defined(CONFIG_SND_BF5XX_SOC_AD183X) \
341 || defined(CONFIG_SND_BF5XX_SOC_AD183X_MODULE)
342 {
343 .modalias = "ad183x",
344 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
345 .bus_num = 0,
346 .chip_select = 4,
347 .platform_data = "ad1836", /* only includes chip name for the moment */
348 .controller_data = &ad1836_spi_chip_info,
349 .mode = SPI_MODE_3,
350 },
351 #endif
352 #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
353 {
354 .modalias = "spidev",
355 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
356 .bus_num = 0,
357 .chip_select = 1,
358 .controller_data = &spidev_chip_info,
359 },
360 #endif
361 };
362
363 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
364 #include <linux/input.h>
365 #include <linux/gpio_keys.h>
366
367 static struct gpio_keys_button bfin_gpio_keys_table[] = {
368 {BTN_0, GPIO_PF5, 1, "gpio-keys: BTN0"},
369 {BTN_1, GPIO_PF6, 1, "gpio-keys: BTN1"},
370 {BTN_2, GPIO_PF7, 1, "gpio-keys: BTN2"},
371 {BTN_3, GPIO_PF8, 1, "gpio-keys: BTN3"},
372 };
373
374 static struct gpio_keys_platform_data bfin_gpio_keys_data = {
375 .buttons = bfin_gpio_keys_table,
376 .nbuttons = ARRAY_SIZE(bfin_gpio_keys_table),
377 };
378
379 static struct platform_device bfin_device_gpiokeys = {
380 .name = "gpio-keys",
381 .dev = {
382 .platform_data = &bfin_gpio_keys_data,
383 },
384 };
385 #endif
386
387 #if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
388 #include <linux/i2c-gpio.h>
389
390 static struct i2c_gpio_platform_data i2c_gpio_data = {
391 .sda_pin = GPIO_PF1,
392 .scl_pin = GPIO_PF0,
393 .sda_is_open_drain = 0,
394 .scl_is_open_drain = 0,
395 .udelay = 40,
396 };
397
398 static struct platform_device i2c_gpio_device = {
399 .name = "i2c-gpio",
400 .id = 0,
401 .dev = {
402 .platform_data = &i2c_gpio_data,
403 },
404 };
405 #endif
406
407 static const unsigned int cclk_vlev_datasheet[] =
408 {
409 VRPAIR(VLEV_085, 250000000),
410 VRPAIR(VLEV_090, 300000000),
411 VRPAIR(VLEV_095, 313000000),
412 VRPAIR(VLEV_100, 350000000),
413 VRPAIR(VLEV_105, 400000000),
414 VRPAIR(VLEV_110, 444000000),
415 VRPAIR(VLEV_115, 450000000),
416 VRPAIR(VLEV_120, 475000000),
417 VRPAIR(VLEV_125, 500000000),
418 VRPAIR(VLEV_130, 600000000),
419 };
420
421 static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
422 .tuple_tab = cclk_vlev_datasheet,
423 .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
424 .vr_settling_time = 25 /* us */,
425 };
426
427 static struct platform_device bfin_dpmc = {
428 .name = "bfin dpmc",
429 .dev = {
430 .platform_data = &bfin_dmpc_vreg_data,
431 },
432 };
433
434 #if defined(CONFIG_SND_BF5XX_I2S) || defined(CONFIG_SND_BF5XX_I2S_MODULE)
435 static struct platform_device bfin_i2s = {
436 .name = "bfin-i2s",
437 .id = CONFIG_SND_BF5XX_SPORT_NUM,
438 /* TODO: add platform data here */
439 };
440 #endif
441
442 #if defined(CONFIG_SND_BF5XX_TDM) || defined(CONFIG_SND_BF5XX_TDM_MODULE)
443 static struct platform_device bfin_tdm = {
444 .name = "bfin-tdm",
445 .id = CONFIG_SND_BF5XX_SPORT_NUM,
446 /* TODO: add platform data here */
447 };
448 #endif
449
450 #if defined(CONFIG_SND_BF5XX_AC97) || defined(CONFIG_SND_BF5XX_AC97_MODULE)
451 static struct platform_device bfin_ac97 = {
452 .name = "bfin-ac97",
453 .id = CONFIG_SND_BF5XX_SPORT_NUM,
454 /* TODO: add platform data here */
455 };
456 #endif
457
458 static struct platform_device *ezkit_devices[] __initdata = {
459
460 &bfin_dpmc,
461
462 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
463 &smc91x_device,
464 #endif
465
466 #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
467 &net2272_bfin_device,
468 #endif
469
470 #if defined(CONFIG_USB_ISP1760_HCD) || defined(CONFIG_USB_ISP1760_HCD_MODULE)
471 &bfin_isp1760_device,
472 #endif
473
474 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
475 &bfin_spi0_device,
476 #endif
477
478 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
479 #ifdef CONFIG_SERIAL_BFIN_UART0
480 &bfin_uart0_device,
481 #endif
482 #endif
483
484 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
485 #ifdef CONFIG_BFIN_SIR0
486 &bfin_sir0_device,
487 #endif
488 #endif
489
490 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
491 &bfin_device_gpiokeys,
492 #endif
493
494 #if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
495 &i2c_gpio_device,
496 #endif
497
498 #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
499 &isp1362_hcd_device,
500 #endif
501
502 #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
503 &ezkit_flash_device,
504 #endif
505
506 #if defined(CONFIG_SND_BF5XX_I2S) || defined(CONFIG_SND_BF5XX_I2S_MODULE)
507 &bfin_i2s,
508 #endif
509
510 #if defined(CONFIG_SND_BF5XX_TDM) || defined(CONFIG_SND_BF5XX_TDM_MODULE)
511 &bfin_tdm,
512 #endif
513
514 #if defined(CONFIG_SND_BF5XX_AC97) || defined(CONFIG_SND_BF5XX_AC97_MODULE)
515 &bfin_ac97,
516 #endif
517 };
518
519 static int __init ezkit_init(void)
520 {
521 int ret;
522
523 printk(KERN_INFO "%s(): registering device resources\n", __func__);
524
525 ret = platform_add_devices(ezkit_devices, ARRAY_SIZE(ezkit_devices));
526 if (ret < 0)
527 return ret;
528
529 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
530 bfin_write_FIO0_DIR(bfin_read_FIO0_DIR() | (1 << 12));
531 SSYNC();
532 #endif
533
534 #if defined(CONFIG_SND_BF5XX_SOC_AD183X) || defined(CONFIG_SND_BF5XX_SOC_AD183X_MODULE)
535 bfin_write_FIO0_DIR(bfin_read_FIO0_DIR() | (1 << 15));
536 bfin_write_FIO0_FLAG_S(1 << 15);
537 SSYNC();
538 /*
539 * This initialization lasts for approximately 4500 MCLKs.
540 * MCLK = 12.288MHz
541 */
542 udelay(400);
543 #endif
544
545 spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
546 return 0;
547 }
548
549 arch_initcall(ezkit_init);
550
551 static struct platform_device *ezkit_early_devices[] __initdata = {
552 #if defined(CONFIG_SERIAL_BFIN_CONSOLE) || defined(CONFIG_EARLY_PRINTK)
553 #ifdef CONFIG_SERIAL_BFIN_UART0
554 &bfin_uart0_device,
555 #endif
556 #endif
557 };
558
559 void __init native_machine_early_platform_add_devices(void)
560 {
561 printk(KERN_INFO "register early platform devices\n");
562 early_platform_add_devices(ezkit_early_devices,
563 ARRAY_SIZE(ezkit_early_devices));
564 }
This page took 0.110617 seconds and 4 git commands to generate.