• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/gpio.h>
18 #include <linux/delay.h>
19 #include <asm/dma.h>
20 #include <asm/bfin5xx_spi.h>
21 #include <asm/portmux.h>
22 #include <asm/dpmc.h>
23 
24 /*
25  * Name the Board for the /proc/cpuinfo
26  */
27 const char bfin_board_name[] = "ADI BF561-EZKIT";
28 
29 #if IS_ENABLED(CONFIG_USB_ISP1760_HCD)
30 #include <linux/usb/isp1760.h>
31 static struct resource bfin_isp1760_resources[] = {
32 	[0] = {
33 		.start  = 0x2C0F0000,
34 		.end    = 0x203C0000 + 0xfffff,
35 		.flags  = IORESOURCE_MEM,
36 	},
37 	[1] = {
38 		.start  = IRQ_PF10,
39 		.end    = IRQ_PF10,
40 		.flags  = IORESOURCE_IRQ,
41 	},
42 };
43 
44 static struct isp1760_platform_data isp1760_priv = {
45 	.is_isp1761 = 0,
46 	.bus_width_16 = 1,
47 	.port1_otg = 0,
48 	.analog_oc = 0,
49 	.dack_polarity_high = 0,
50 	.dreq_polarity_high = 0,
51 };
52 
53 static struct platform_device bfin_isp1760_device = {
54 	.name           = "isp1760",
55 	.id             = 0,
56 	.dev = {
57 		.platform_data = &isp1760_priv,
58 	},
59 	.num_resources  = ARRAY_SIZE(bfin_isp1760_resources),
60 	.resource       = bfin_isp1760_resources,
61 };
62 #endif
63 
64 #if IS_ENABLED(CONFIG_USB_ISP1362_HCD)
65 #include <linux/usb/isp1362.h>
66 
67 static struct resource isp1362_hcd_resources[] = {
68 	{
69 		.start = 0x2c060000,
70 		.end = 0x2c060000,
71 		.flags = IORESOURCE_MEM,
72 	}, {
73 		.start = 0x2c060004,
74 		.end = 0x2c060004,
75 		.flags = IORESOURCE_MEM,
76 	}, {
77 		.start = IRQ_PF8,
78 		.end = IRQ_PF8,
79 		.flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWEDGE,
80 	},
81 };
82 
83 static struct isp1362_platform_data isp1362_priv = {
84 	.sel15Kres = 1,
85 	.clknotstop = 0,
86 	.oc_enable = 0,
87 	.int_act_high = 0,
88 	.int_edge_triggered = 0,
89 	.remote_wakeup_connected = 0,
90 	.no_power_switching = 1,
91 	.power_switching_mode = 0,
92 };
93 
94 static struct platform_device isp1362_hcd_device = {
95 	.name = "isp1362-hcd",
96 	.id = 0,
97 	.dev = {
98 		.platform_data = &isp1362_priv,
99 	},
100 	.num_resources = ARRAY_SIZE(isp1362_hcd_resources),
101 	.resource = isp1362_hcd_resources,
102 };
103 #endif
104 
105 #if IS_ENABLED(CONFIG_USB_NET2272)
106 static struct resource net2272_bfin_resources[] = {
107 	{
108 		.start = 0x2C000000,
109 		.end = 0x2C000000 + 0x7F,
110 		.flags = IORESOURCE_MEM,
111 	}, {
112 		.start = 1,
113 		.flags = IORESOURCE_BUS,
114 	}, {
115 		.start = IRQ_PF10,
116 		.end = IRQ_PF10,
117 		.flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
118 	},
119 };
120 
121 static struct platform_device net2272_bfin_device = {
122 	.name = "net2272",
123 	.id = -1,
124 	.num_resources = ARRAY_SIZE(net2272_bfin_resources),
125 	.resource = net2272_bfin_resources,
126 };
127 #endif
128 
129 /*
130  *  USB-LAN EzExtender board
131  *  Driver needs to know address, irq and flag pin.
132  */
133 #if IS_ENABLED(CONFIG_SMC91X)
134 #include <linux/smc91x.h>
135 
136 static struct smc91x_platdata smc91x_info = {
137 	.flags = SMC91X_USE_8BIT | SMC91X_USE_16BIT | SMC91X_USE_32BIT |
138 		 SMC91X_NOWAIT,
139 	.leda = RPC_LED_100_10,
140 	.ledb = RPC_LED_TX_RX,
141 };
142 
143 static struct resource smc91x_resources[] = {
144 	{
145 		.name = "smc91x-regs",
146 		.start = 0x2C010300,
147 		.end = 0x2C010300 + 16,
148 		.flags = IORESOURCE_MEM,
149 	}, {
150 
151 		.start = IRQ_PF9,
152 		.end = IRQ_PF9,
153 		.flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
154 	},
155 };
156 
157 static struct platform_device smc91x_device = {
158 	.name = "smc91x",
159 	.id = 0,
160 	.num_resources = ARRAY_SIZE(smc91x_resources),
161 	.resource = smc91x_resources,
162 	.dev	= {
163 		.platform_data	= &smc91x_info,
164 	},
165 };
166 #endif
167 
168 #if IS_ENABLED(CONFIG_SERIAL_BFIN)
169 #ifdef CONFIG_SERIAL_BFIN_UART0
170 static struct resource bfin_uart0_resources[] = {
171 	{
172 		.start = BFIN_UART_THR,
173 		.end = BFIN_UART_GCTL+2,
174 		.flags = IORESOURCE_MEM,
175 	},
176 	{
177 		.start = IRQ_UART_TX,
178 		.end = IRQ_UART_TX,
179 		.flags = IORESOURCE_IRQ,
180 	},
181 	{
182 		.start = IRQ_UART_RX,
183 		.end = IRQ_UART_RX,
184 		.flags = IORESOURCE_IRQ,
185 	},
186 	{
187 		.start = IRQ_UART_ERROR,
188 		.end = IRQ_UART_ERROR,
189 		.flags = IORESOURCE_IRQ,
190 	},
191 	{
192 		.start = CH_UART_TX,
193 		.end = CH_UART_TX,
194 		.flags = IORESOURCE_DMA,
195 	},
196 	{
197 		.start = CH_UART_RX,
198 		.end = CH_UART_RX,
199 		.flags = IORESOURCE_DMA,
200 	},
201 };
202 
203 static unsigned short bfin_uart0_peripherals[] = {
204 	P_UART0_TX, P_UART0_RX, 0
205 };
206 
207 static struct platform_device bfin_uart0_device = {
208 	.name = "bfin-uart",
209 	.id = 0,
210 	.num_resources = ARRAY_SIZE(bfin_uart0_resources),
211 	.resource = bfin_uart0_resources,
212 	.dev = {
213 		.platform_data = &bfin_uart0_peripherals, /* Passed to driver */
214 	},
215 };
216 #endif
217 #endif
218 
219 #if IS_ENABLED(CONFIG_BFIN_SIR)
220 #ifdef CONFIG_BFIN_SIR0
221 static struct resource bfin_sir0_resources[] = {
222 	{
223 		.start = 0xFFC00400,
224 		.end = 0xFFC004FF,
225 		.flags = IORESOURCE_MEM,
226 	},
227 	{
228 		.start = IRQ_UART0_RX,
229 		.end = IRQ_UART0_RX+1,
230 		.flags = IORESOURCE_IRQ,
231 	},
232 	{
233 		.start = CH_UART0_RX,
234 		.end = CH_UART0_RX+1,
235 		.flags = IORESOURCE_DMA,
236 	},
237 };
238 
239 static struct platform_device bfin_sir0_device = {
240 	.name = "bfin_sir",
241 	.id = 0,
242 	.num_resources = ARRAY_SIZE(bfin_sir0_resources),
243 	.resource = bfin_sir0_resources,
244 };
245 #endif
246 #endif
247 
248 #if IS_ENABLED(CONFIG_MTD_PHYSMAP)
249 static struct mtd_partition ezkit_partitions[] = {
250 	{
251 		.name       = "bootloader(nor)",
252 		.size       = 0x40000,
253 		.offset     = 0,
254 	}, {
255 		.name       = "linux kernel(nor)",
256 		.size       = 0x1C0000,
257 		.offset     = MTDPART_OFS_APPEND,
258 	}, {
259 		.name       = "file system(nor)",
260 		.size       = 0x800000 - 0x40000 - 0x1C0000 - 0x2000 * 8,
261 		.offset     = MTDPART_OFS_APPEND,
262 	}, {
263 		.name       = "config(nor)",
264 		.size       = 0x2000 * 7,
265 		.offset     = MTDPART_OFS_APPEND,
266 	}, {
267 		.name       = "u-boot env(nor)",
268 		.size       = 0x2000,
269 		.offset     = MTDPART_OFS_APPEND,
270 	}
271 };
272 
273 static struct physmap_flash_data ezkit_flash_data = {
274 	.width      = 2,
275 	.parts      = ezkit_partitions,
276 	.nr_parts   = ARRAY_SIZE(ezkit_partitions),
277 };
278 
279 static struct resource ezkit_flash_resource = {
280 	.start = 0x20000000,
281 	.end   = 0x207fffff,
282 	.flags = IORESOURCE_MEM,
283 };
284 
285 static struct platform_device ezkit_flash_device = {
286 	.name          = "physmap-flash",
287 	.id            = 0,
288 	.dev = {
289 		.platform_data = &ezkit_flash_data,
290 	},
291 	.num_resources = 1,
292 	.resource      = &ezkit_flash_resource,
293 };
294 #endif
295 
296 #if IS_ENABLED(CONFIG_SPI_BFIN5XX)
297 /* SPI (0) */
298 static struct resource bfin_spi0_resource[] = {
299 	[0] = {
300 		.start = SPI0_REGBASE,
301 		.end   = SPI0_REGBASE + 0xFF,
302 		.flags = IORESOURCE_MEM,
303 	},
304 	[1] = {
305 		.start = CH_SPI,
306 		.end   = CH_SPI,
307 		.flags = IORESOURCE_DMA,
308 	},
309 	[2] = {
310 		.start = IRQ_SPI,
311 		.end   = IRQ_SPI,
312 		.flags = IORESOURCE_IRQ,
313 	}
314 };
315 
316 /* SPI controller data */
317 static struct bfin5xx_spi_master bfin_spi0_info = {
318 	.num_chipselect = 8,
319 	.enable_dma = 1,  /* master has the ability to do dma transfer */
320 	.pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
321 };
322 
323 static struct platform_device bfin_spi0_device = {
324 	.name = "bfin-spi",
325 	.id = 0, /* Bus number */
326 	.num_resources = ARRAY_SIZE(bfin_spi0_resource),
327 	.resource = bfin_spi0_resource,
328 	.dev = {
329 		.platform_data = &bfin_spi0_info, /* Passed to driver */
330 	},
331 };
332 #endif
333 
334 static struct spi_board_info bfin_spi_board_info[] __initdata = {
335 #if IS_ENABLED(CONFIG_SND_BF5XX_SOC_AD183X)
336 	{
337 		.modalias = "ad183x",
338 		.max_speed_hz = 3125000,     /* max spi clock (SCK) speed in HZ */
339 		.bus_num = 0,
340 		.chip_select = 4,
341 		.platform_data = "ad1836", /* only includes chip name for the moment */
342 		.mode = SPI_MODE_3,
343 	},
344 #endif
345 #if IS_ENABLED(CONFIG_SPI_SPIDEV)
346 	{
347 		.modalias = "spidev",
348 		.max_speed_hz = 3125000,     /* max spi clock (SCK) speed in HZ */
349 		.bus_num = 0,
350 		.chip_select = 1,
351 	},
352 #endif
353 };
354 
355 #if IS_ENABLED(CONFIG_KEYBOARD_GPIO)
356 #include <linux/input.h>
357 #include <linux/gpio_keys.h>
358 
359 static struct gpio_keys_button bfin_gpio_keys_table[] = {
360 	{BTN_0, GPIO_PF5, 1, "gpio-keys: BTN0"},
361 	{BTN_1, GPIO_PF6, 1, "gpio-keys: BTN1"},
362 	{BTN_2, GPIO_PF7, 1, "gpio-keys: BTN2"},
363 	{BTN_3, GPIO_PF8, 1, "gpio-keys: BTN3"},
364 };
365 
366 static struct gpio_keys_platform_data bfin_gpio_keys_data = {
367 	.buttons        = bfin_gpio_keys_table,
368 	.nbuttons       = ARRAY_SIZE(bfin_gpio_keys_table),
369 };
370 
371 static struct platform_device bfin_device_gpiokeys = {
372 	.name      = "gpio-keys",
373 	.dev = {
374 		.platform_data = &bfin_gpio_keys_data,
375 	},
376 };
377 #endif
378 
379 #if IS_ENABLED(CONFIG_I2C_GPIO)
380 #include <linux/i2c-gpio.h>
381 
382 static struct i2c_gpio_platform_data i2c_gpio_data = {
383 	.sda_pin		= GPIO_PF1,
384 	.scl_pin		= GPIO_PF0,
385 	.sda_is_open_drain	= 0,
386 	.scl_is_open_drain	= 0,
387 	.udelay			= 10,
388 };
389 
390 static struct platform_device i2c_gpio_device = {
391 	.name		= "i2c-gpio",
392 	.id		= 0,
393 	.dev		= {
394 		.platform_data	= &i2c_gpio_data,
395 	},
396 };
397 #endif
398 
399 static const unsigned int cclk_vlev_datasheet[] =
400 {
401 	VRPAIR(VLEV_085, 250000000),
402 	VRPAIR(VLEV_090, 300000000),
403 	VRPAIR(VLEV_095, 313000000),
404 	VRPAIR(VLEV_100, 350000000),
405 	VRPAIR(VLEV_105, 400000000),
406 	VRPAIR(VLEV_110, 444000000),
407 	VRPAIR(VLEV_115, 450000000),
408 	VRPAIR(VLEV_120, 475000000),
409 	VRPAIR(VLEV_125, 500000000),
410 	VRPAIR(VLEV_130, 600000000),
411 };
412 
413 static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
414 	.tuple_tab = cclk_vlev_datasheet,
415 	.tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
416 	.vr_settling_time = 25 /* us */,
417 };
418 
419 static struct platform_device bfin_dpmc = {
420 	.name = "bfin dpmc",
421 	.dev = {
422 		.platform_data = &bfin_dmpc_vreg_data,
423 	},
424 };
425 
426 #if IS_ENABLED(CONFIG_VIDEO_BLACKFIN_CAPTURE)
427 #include <linux/videodev2.h>
428 #include <media/blackfin/bfin_capture.h>
429 #include <media/blackfin/ppi.h>
430 
431 static const unsigned short ppi_req[] = {
432 	P_PPI0_D0, P_PPI0_D1, P_PPI0_D2, P_PPI0_D3,
433 	P_PPI0_D4, P_PPI0_D5, P_PPI0_D6, P_PPI0_D7,
434 	P_PPI0_CLK, P_PPI0_FS1, P_PPI0_FS2,
435 	0,
436 };
437 
438 static const struct ppi_info ppi_info = {
439 	.type = PPI_TYPE_PPI,
440 	.dma_ch = CH_PPI0,
441 	.irq_err = IRQ_PPI1_ERROR,
442 	.base = (void __iomem *)PPI0_CONTROL,
443 	.pin_req = ppi_req,
444 };
445 
446 #if IS_ENABLED(CONFIG_VIDEO_ADV7183)
447 #include <media/adv7183.h>
448 static struct v4l2_input adv7183_inputs[] = {
449 	{
450 		.index = 0,
451 		.name = "Composite",
452 		.type = V4L2_INPUT_TYPE_CAMERA,
453 		.std = V4L2_STD_ALL,
454 		.capabilities = V4L2_IN_CAP_STD,
455 	},
456 	{
457 		.index = 1,
458 		.name = "S-Video",
459 		.type = V4L2_INPUT_TYPE_CAMERA,
460 		.std = V4L2_STD_ALL,
461 		.capabilities = V4L2_IN_CAP_STD,
462 	},
463 	{
464 		.index = 2,
465 		.name = "Component",
466 		.type = V4L2_INPUT_TYPE_CAMERA,
467 		.std = V4L2_STD_ALL,
468 		.capabilities = V4L2_IN_CAP_STD,
469 	},
470 };
471 
472 static struct bcap_route adv7183_routes[] = {
473 	{
474 		.input = ADV7183_COMPOSITE4,
475 		.output = ADV7183_8BIT_OUT,
476 	},
477 	{
478 		.input = ADV7183_SVIDEO0,
479 		.output = ADV7183_8BIT_OUT,
480 	},
481 	{
482 		.input = ADV7183_COMPONENT0,
483 		.output = ADV7183_8BIT_OUT,
484 	},
485 };
486 
487 
488 static const unsigned adv7183_gpio[] = {
489 	GPIO_PF13, /* reset pin */
490 	GPIO_PF2,  /* output enable pin */
491 };
492 
493 static struct bfin_capture_config bfin_capture_data = {
494 	.card_name = "BF561",
495 	.inputs = adv7183_inputs,
496 	.num_inputs = ARRAY_SIZE(adv7183_inputs),
497 	.routes = adv7183_routes,
498 	.i2c_adapter_id = 0,
499 	.board_info = {
500 		.type = "adv7183",
501 		.addr = 0x20,
502 		.platform_data = (void *)adv7183_gpio,
503 	},
504 	.ppi_info = &ppi_info,
505 	.ppi_control = (PACK_EN | DLEN_8 | DMA32 | FLD_SEL),
506 };
507 #endif
508 
509 static struct platform_device bfin_capture_device = {
510 	.name = "bfin_capture",
511 	.dev = {
512 		.platform_data = &bfin_capture_data,
513 	},
514 };
515 #endif
516 
517 #if IS_ENABLED(CONFIG_SND_BF5XX_I2S)
518 static struct platform_device bfin_i2s = {
519 	.name = "bfin-i2s",
520 	.id = CONFIG_SND_BF5XX_SPORT_NUM,
521 	/* TODO: add platform data here */
522 };
523 #endif
524 
525 #if IS_ENABLED(CONFIG_SND_BF5XX_AC97)
526 static struct platform_device bfin_ac97 = {
527 	.name = "bfin-ac97",
528 	.id = CONFIG_SND_BF5XX_SPORT_NUM,
529 	/* TODO: add platform data here */
530 };
531 #endif
532 
533 #if IS_ENABLED(CONFIG_SND_BF5XX_SOC_AD1836)
534 static const char * const ad1836_link[] = {
535 	"bfin-i2s.0",
536 	"spi0.4",
537 };
538 static struct platform_device bfin_ad1836_machine = {
539 	.name = "bfin-snd-ad1836",
540 	.id = -1,
541 	.dev = {
542 		.platform_data = (void *)ad1836_link,
543 	},
544 };
545 #endif
546 
547 static struct platform_device *ezkit_devices[] __initdata = {
548 
549 	&bfin_dpmc,
550 
551 #if IS_ENABLED(CONFIG_SMC91X)
552 	&smc91x_device,
553 #endif
554 
555 #if IS_ENABLED(CONFIG_USB_NET2272)
556 	&net2272_bfin_device,
557 #endif
558 
559 #if IS_ENABLED(CONFIG_USB_ISP1760_HCD)
560 	&bfin_isp1760_device,
561 #endif
562 
563 #if IS_ENABLED(CONFIG_SPI_BFIN5XX)
564 	&bfin_spi0_device,
565 #endif
566 
567 #if IS_ENABLED(CONFIG_SERIAL_BFIN)
568 #ifdef CONFIG_SERIAL_BFIN_UART0
569 	&bfin_uart0_device,
570 #endif
571 #endif
572 
573 #if IS_ENABLED(CONFIG_BFIN_SIR)
574 #ifdef CONFIG_BFIN_SIR0
575 	&bfin_sir0_device,
576 #endif
577 #endif
578 
579 #if IS_ENABLED(CONFIG_KEYBOARD_GPIO)
580 	&bfin_device_gpiokeys,
581 #endif
582 
583 #if IS_ENABLED(CONFIG_I2C_GPIO)
584 	&i2c_gpio_device,
585 #endif
586 
587 #if IS_ENABLED(CONFIG_USB_ISP1362_HCD)
588 	&isp1362_hcd_device,
589 #endif
590 
591 #if IS_ENABLED(CONFIG_MTD_PHYSMAP)
592 	&ezkit_flash_device,
593 #endif
594 
595 #if IS_ENABLED(CONFIG_VIDEO_BLACKFIN_CAPTURE)
596 	&bfin_capture_device,
597 #endif
598 
599 #if IS_ENABLED(CONFIG_SND_BF5XX_I2S)
600 	&bfin_i2s,
601 #endif
602 
603 #if IS_ENABLED(CONFIG_SND_BF5XX_AC97)
604 	&bfin_ac97,
605 #endif
606 
607 #if IS_ENABLED(CONFIG_SND_BF5XX_SOC_AD1836)
608 	&bfin_ad1836_machine,
609 #endif
610 };
611 
net2272_init(void)612 static int __init net2272_init(void)
613 {
614 #if IS_ENABLED(CONFIG_USB_NET2272)
615 	int ret;
616 
617 	ret = gpio_request(GPIO_PF11, "net2272");
618 	if (ret)
619 		return ret;
620 
621 	/* Reset the USB chip */
622 	gpio_direction_output(GPIO_PF11, 0);
623 	mdelay(2);
624 	gpio_set_value(GPIO_PF11, 1);
625 #endif
626 
627 	return 0;
628 }
629 
ezkit_init(void)630 static int __init ezkit_init(void)
631 {
632 	int ret;
633 
634 	printk(KERN_INFO "%s(): registering device resources\n", __func__);
635 
636 	ret = platform_add_devices(ezkit_devices, ARRAY_SIZE(ezkit_devices));
637 	if (ret < 0)
638 		return ret;
639 
640 #if IS_ENABLED(CONFIG_SMC91X)
641 	bfin_write_FIO0_DIR(bfin_read_FIO0_DIR() | (1 << 12));
642 	SSYNC();
643 #endif
644 
645 #if IS_ENABLED(CONFIG_SND_BF5XX_SOC_AD183X)
646 	bfin_write_FIO0_DIR(bfin_read_FIO0_DIR() | (1 << 15));
647 	bfin_write_FIO0_FLAG_S(1 << 15);
648 	SSYNC();
649 	/*
650 	 * This initialization lasts for approximately 4500 MCLKs.
651 	 * MCLK = 12.288MHz
652 	 */
653 	udelay(400);
654 #endif
655 
656 	if (net2272_init())
657 		pr_warning("unable to configure net2272; it probably won't work\n");
658 
659 	spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
660 	return 0;
661 }
662 
663 arch_initcall(ezkit_init);
664 
665 static struct platform_device *ezkit_early_devices[] __initdata = {
666 #if defined(CONFIG_SERIAL_BFIN_CONSOLE) || defined(CONFIG_EARLY_PRINTK)
667 #ifdef CONFIG_SERIAL_BFIN_UART0
668 	&bfin_uart0_device,
669 #endif
670 #endif
671 };
672 
native_machine_early_platform_add_devices(void)673 void __init native_machine_early_platform_add_devices(void)
674 {
675 	printk(KERN_INFO "register early platform devices\n");
676 	early_platform_add_devices(ezkit_early_devices,
677 		ARRAY_SIZE(ezkit_early_devices));
678 }
679