include: replace linux/module.h with "struct module" wherever possible
[linux-2.6/next.git] / arch / blackfin / mach-bf561 / boards / ezkit.c
blob9490dc800ca589f6ef3f4337174bf257221f180a
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/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>
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[] = {
31 [0] = {
32 .start = 0x2C0F0000,
33 .end = 0x203C0000 + 0xfffff,
34 .flags = IORESOURCE_MEM,
36 [1] = {
37 .start = IRQ_PF10,
38 .end = IRQ_PF10,
39 .flags = IORESOURCE_IRQ,
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,
52 static struct platform_device bfin_isp1760_device = {
53 .name = "isp1760",
54 .id = 0,
55 .dev = {
56 .platform_data = &isp1760_priv,
58 .num_resources = ARRAY_SIZE(bfin_isp1760_resources),
59 .resource = bfin_isp1760_resources,
61 #endif
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[] = {
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,
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,
93 static struct platform_device isp1362_hcd_device = {
94 .name = "isp1362-hcd",
95 .id = 0,
96 .dev = {
97 .platform_data = &isp1362_priv,
99 .num_resources = ARRAY_SIZE(isp1362_hcd_resources),
100 .resource = isp1362_hcd_resources,
102 #endif
104 #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
105 static struct resource net2272_bfin_resources[] = {
107 .start = 0x2C000000,
108 .end = 0x2C000000 + 0x7F,
109 .flags = IORESOURCE_MEM,
110 }, {
111 .start = 1,
112 .flags = IORESOURCE_BUS,
113 }, {
114 .start = IRQ_PF10,
115 .end = IRQ_PF10,
116 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
120 static struct platform_device net2272_bfin_device = {
121 .name = "net2272",
122 .id = -1,
123 .num_resources = ARRAY_SIZE(net2272_bfin_resources),
124 .resource = net2272_bfin_resources,
126 #endif
129 * USB-LAN EzExtender board
130 * Driver needs to know address, irq and flag pin.
132 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
133 #include <linux/smc91x.h>
135 static struct smc91x_platdata smc91x_info = {
136 .flags = SMC91X_USE_32BIT | SMC91X_NOWAIT,
137 .leda = RPC_LED_100_10,
138 .ledb = RPC_LED_TX_RX,
141 static struct resource smc91x_resources[] = {
143 .name = "smc91x-regs",
144 .start = 0x2C010300,
145 .end = 0x2C010300 + 16,
146 .flags = IORESOURCE_MEM,
147 }, {
149 .start = IRQ_PF9,
150 .end = IRQ_PF9,
151 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
155 static struct platform_device smc91x_device = {
156 .name = "smc91x",
157 .id = 0,
158 .num_resources = ARRAY_SIZE(smc91x_resources),
159 .resource = smc91x_resources,
160 .dev = {
161 .platform_data = &smc91x_info,
164 #endif
166 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
167 #ifdef CONFIG_SERIAL_BFIN_UART0
168 static struct resource bfin_uart0_resources[] = {
170 .start = BFIN_UART_THR,
171 .end = BFIN_UART_GCTL+2,
172 .flags = IORESOURCE_MEM,
175 .start = IRQ_UART_RX,
176 .end = IRQ_UART_RX+1,
177 .flags = IORESOURCE_IRQ,
180 .start = IRQ_UART_ERROR,
181 .end = IRQ_UART_ERROR,
182 .flags = IORESOURCE_IRQ,
185 .start = CH_UART_TX,
186 .end = CH_UART_TX,
187 .flags = IORESOURCE_DMA,
190 .start = CH_UART_RX,
191 .end = CH_UART_RX,
192 .flags = IORESOURCE_DMA,
196 static unsigned short bfin_uart0_peripherals[] = {
197 P_UART0_TX, P_UART0_RX, 0
200 static struct platform_device bfin_uart0_device = {
201 .name = "bfin-uart",
202 .id = 0,
203 .num_resources = ARRAY_SIZE(bfin_uart0_resources),
204 .resource = bfin_uart0_resources,
205 .dev = {
206 .platform_data = &bfin_uart0_peripherals, /* Passed to driver */
209 #endif
210 #endif
212 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
213 #ifdef CONFIG_BFIN_SIR0
214 static struct resource bfin_sir0_resources[] = {
216 .start = 0xFFC00400,
217 .end = 0xFFC004FF,
218 .flags = IORESOURCE_MEM,
221 .start = IRQ_UART0_RX,
222 .end = IRQ_UART0_RX+1,
223 .flags = IORESOURCE_IRQ,
226 .start = CH_UART0_RX,
227 .end = CH_UART0_RX+1,
228 .flags = IORESOURCE_DMA,
232 static struct platform_device bfin_sir0_device = {
233 .name = "bfin_sir",
234 .id = 0,
235 .num_resources = ARRAY_SIZE(bfin_sir0_resources),
236 .resource = bfin_sir0_resources,
238 #endif
239 #endif
241 #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
242 static struct mtd_partition ezkit_partitions[] = {
244 .name = "bootloader(nor)",
245 .size = 0x40000,
246 .offset = 0,
247 }, {
248 .name = "linux kernel(nor)",
249 .size = 0x1C0000,
250 .offset = MTDPART_OFS_APPEND,
251 }, {
252 .name = "file system(nor)",
253 .size = 0x800000 - 0x40000 - 0x1C0000 - 0x2000 * 8,
254 .offset = MTDPART_OFS_APPEND,
255 }, {
256 .name = "config(nor)",
257 .size = 0x2000 * 7,
258 .offset = MTDPART_OFS_APPEND,
259 }, {
260 .name = "u-boot env(nor)",
261 .size = 0x2000,
262 .offset = MTDPART_OFS_APPEND,
266 static struct physmap_flash_data ezkit_flash_data = {
267 .width = 2,
268 .parts = ezkit_partitions,
269 .nr_parts = ARRAY_SIZE(ezkit_partitions),
272 static struct resource ezkit_flash_resource = {
273 .start = 0x20000000,
274 .end = 0x207fffff,
275 .flags = IORESOURCE_MEM,
278 static struct platform_device ezkit_flash_device = {
279 .name = "physmap-flash",
280 .id = 0,
281 .dev = {
282 .platform_data = &ezkit_flash_data,
284 .num_resources = 1,
285 .resource = &ezkit_flash_resource,
287 #endif
289 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
290 /* SPI (0) */
291 static struct resource bfin_spi0_resource[] = {
292 [0] = {
293 .start = SPI0_REGBASE,
294 .end = SPI0_REGBASE + 0xFF,
295 .flags = IORESOURCE_MEM,
297 [1] = {
298 .start = CH_SPI,
299 .end = CH_SPI,
300 .flags = IORESOURCE_DMA,
302 [2] = {
303 .start = IRQ_SPI,
304 .end = IRQ_SPI,
305 .flags = IORESOURCE_IRQ,
309 /* SPI controller data */
310 static struct bfin5xx_spi_master bfin_spi0_info = {
311 .num_chipselect = 8,
312 .enable_dma = 1, /* master has the ability to do dma transfer */
313 .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
316 static struct platform_device bfin_spi0_device = {
317 .name = "bfin-spi",
318 .id = 0, /* Bus number */
319 .num_resources = ARRAY_SIZE(bfin_spi0_resource),
320 .resource = bfin_spi0_resource,
321 .dev = {
322 .platform_data = &bfin_spi0_info, /* Passed to driver */
325 #endif
327 static struct spi_board_info bfin_spi_board_info[] __initdata = {
328 #if defined(CONFIG_SND_BF5XX_SOC_AD183X) \
329 || defined(CONFIG_SND_BF5XX_SOC_AD183X_MODULE)
331 .modalias = "ad183x",
332 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
333 .bus_num = 0,
334 .chip_select = 4,
335 .platform_data = "ad1836", /* only includes chip name for the moment */
336 .mode = SPI_MODE_3,
338 #endif
339 #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
341 .modalias = "spidev",
342 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
343 .bus_num = 0,
344 .chip_select = 1,
346 #endif
349 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
350 #include <linux/input.h>
351 #include <linux/gpio_keys.h>
353 static struct gpio_keys_button bfin_gpio_keys_table[] = {
354 {BTN_0, GPIO_PF5, 1, "gpio-keys: BTN0"},
355 {BTN_1, GPIO_PF6, 1, "gpio-keys: BTN1"},
356 {BTN_2, GPIO_PF7, 1, "gpio-keys: BTN2"},
357 {BTN_3, GPIO_PF8, 1, "gpio-keys: BTN3"},
360 static struct gpio_keys_platform_data bfin_gpio_keys_data = {
361 .buttons = bfin_gpio_keys_table,
362 .nbuttons = ARRAY_SIZE(bfin_gpio_keys_table),
365 static struct platform_device bfin_device_gpiokeys = {
366 .name = "gpio-keys",
367 .dev = {
368 .platform_data = &bfin_gpio_keys_data,
371 #endif
373 #if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
374 #include <linux/i2c-gpio.h>
376 static struct i2c_gpio_platform_data i2c_gpio_data = {
377 .sda_pin = GPIO_PF1,
378 .scl_pin = GPIO_PF0,
379 .sda_is_open_drain = 0,
380 .scl_is_open_drain = 0,
381 .udelay = 40,
384 static struct platform_device i2c_gpio_device = {
385 .name = "i2c-gpio",
386 .id = 0,
387 .dev = {
388 .platform_data = &i2c_gpio_data,
391 #endif
393 static const unsigned int cclk_vlev_datasheet[] =
395 VRPAIR(VLEV_085, 250000000),
396 VRPAIR(VLEV_090, 300000000),
397 VRPAIR(VLEV_095, 313000000),
398 VRPAIR(VLEV_100, 350000000),
399 VRPAIR(VLEV_105, 400000000),
400 VRPAIR(VLEV_110, 444000000),
401 VRPAIR(VLEV_115, 450000000),
402 VRPAIR(VLEV_120, 475000000),
403 VRPAIR(VLEV_125, 500000000),
404 VRPAIR(VLEV_130, 600000000),
407 static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
408 .tuple_tab = cclk_vlev_datasheet,
409 .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
410 .vr_settling_time = 25 /* us */,
413 static struct platform_device bfin_dpmc = {
414 .name = "bfin dpmc",
415 .dev = {
416 .platform_data = &bfin_dmpc_vreg_data,
420 #if defined(CONFIG_SND_BF5XX_I2S) || defined(CONFIG_SND_BF5XX_I2S_MODULE)
421 static struct platform_device bfin_i2s = {
422 .name = "bfin-i2s",
423 .id = CONFIG_SND_BF5XX_SPORT_NUM,
424 /* TODO: add platform data here */
426 #endif
428 #if defined(CONFIG_SND_BF5XX_TDM) || defined(CONFIG_SND_BF5XX_TDM_MODULE)
429 static struct platform_device bfin_tdm = {
430 .name = "bfin-tdm",
431 .id = CONFIG_SND_BF5XX_SPORT_NUM,
432 /* TODO: add platform data here */
434 #endif
436 #if defined(CONFIG_SND_BF5XX_AC97) || defined(CONFIG_SND_BF5XX_AC97_MODULE)
437 static struct platform_device bfin_ac97 = {
438 .name = "bfin-ac97",
439 .id = CONFIG_SND_BF5XX_SPORT_NUM,
440 /* TODO: add platform data here */
442 #endif
444 static struct platform_device *ezkit_devices[] __initdata = {
446 &bfin_dpmc,
448 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
449 &smc91x_device,
450 #endif
452 #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
453 &net2272_bfin_device,
454 #endif
456 #if defined(CONFIG_USB_ISP1760_HCD) || defined(CONFIG_USB_ISP1760_HCD_MODULE)
457 &bfin_isp1760_device,
458 #endif
460 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
461 &bfin_spi0_device,
462 #endif
464 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
465 #ifdef CONFIG_SERIAL_BFIN_UART0
466 &bfin_uart0_device,
467 #endif
468 #endif
470 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
471 #ifdef CONFIG_BFIN_SIR0
472 &bfin_sir0_device,
473 #endif
474 #endif
476 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
477 &bfin_device_gpiokeys,
478 #endif
480 #if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
481 &i2c_gpio_device,
482 #endif
484 #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
485 &isp1362_hcd_device,
486 #endif
488 #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
489 &ezkit_flash_device,
490 #endif
492 #if defined(CONFIG_SND_BF5XX_I2S) || defined(CONFIG_SND_BF5XX_I2S_MODULE)
493 &bfin_i2s,
494 #endif
496 #if defined(CONFIG_SND_BF5XX_TDM) || defined(CONFIG_SND_BF5XX_TDM_MODULE)
497 &bfin_tdm,
498 #endif
500 #if defined(CONFIG_SND_BF5XX_AC97) || defined(CONFIG_SND_BF5XX_AC97_MODULE)
501 &bfin_ac97,
502 #endif
505 static int __init net2272_init(void)
507 #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
508 int ret;
510 ret = gpio_request(GPIO_PF11, "net2272");
511 if (ret)
512 return ret;
514 /* Reset the USB chip */
515 gpio_direction_output(GPIO_PF11, 0);
516 mdelay(2);
517 gpio_set_value(GPIO_PF11, 1);
518 #endif
520 return 0;
523 static int __init ezkit_init(void)
525 int ret;
527 printk(KERN_INFO "%s(): registering device resources\n", __func__);
529 ret = platform_add_devices(ezkit_devices, ARRAY_SIZE(ezkit_devices));
530 if (ret < 0)
531 return ret;
533 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
534 bfin_write_FIO0_DIR(bfin_read_FIO0_DIR() | (1 << 12));
535 SSYNC();
536 #endif
538 #if defined(CONFIG_SND_BF5XX_SOC_AD183X) || defined(CONFIG_SND_BF5XX_SOC_AD183X_MODULE)
539 bfin_write_FIO0_DIR(bfin_read_FIO0_DIR() | (1 << 15));
540 bfin_write_FIO0_FLAG_S(1 << 15);
541 SSYNC();
543 * This initialization lasts for approximately 4500 MCLKs.
544 * MCLK = 12.288MHz
546 udelay(400);
547 #endif
549 if (net2272_init())
550 pr_warning("unable to configure net2272; it probably won't work\n");
552 spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
553 return 0;
556 arch_initcall(ezkit_init);
558 static struct platform_device *ezkit_early_devices[] __initdata = {
559 #if defined(CONFIG_SERIAL_BFIN_CONSOLE) || defined(CONFIG_EARLY_PRINTK)
560 #ifdef CONFIG_SERIAL_BFIN_UART0
561 &bfin_uart0_device,
562 #endif
563 #endif
566 void __init native_machine_early_platform_add_devices(void)
568 printk(KERN_INFO "register early platform devices\n");
569 early_platform_add_devices(ezkit_early_devices,
570 ARRAY_SIZE(ezkit_early_devices));