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