• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /asuswrt-rt-n18u-9.0.0.4.380.2695/release/src-rt-6.x.4708/linux/linux-2.6/arch/blackfin/mach-bf533/boards/
1/*
2 * Board Info File for the BlackStamp
3 *
4 * Copyright 2004-2008 Analog Devices Inc.
5 *                2008 Benjamin Matthews <bmat@lle.rochester.edu>
6 *                2005 National ICT Australia (NICTA)
7 *                      Aidan Williams <aidan@nicta.com.au>
8 *
9 * More info about the BlackStamp at:
10 * 	http://blackfin.uclinux.org/gf/project/blackstamp/
11 *
12 * Licensed under the GPL-2 or later.
13 */
14
15#include <linux/device.h>
16#include <linux/platform_device.h>
17#include <linux/mtd/mtd.h>
18#include <linux/mtd/partitions.h>
19#include <linux/mtd/physmap.h>
20#include <linux/spi/spi.h>
21#include <linux/spi/flash.h>
22#include <linux/irq.h>
23#include <linux/i2c.h>
24#include <asm/dma.h>
25#include <asm/bfin5xx_spi.h>
26#include <asm/portmux.h>
27#include <asm/dpmc.h>
28
29/*
30 * Name the Board for the /proc/cpuinfo
31 */
32const char bfin_board_name[] = "BlackStamp";
33
34#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
35static struct platform_device rtc_device = {
36	.name = "rtc-bfin",
37	.id   = -1,
38};
39#endif
40
41/*
42 *  Driver needs to know address, irq and flag pin.
43 */
44#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
45#include <linux/smc91x.h>
46
47static struct smc91x_platdata smc91x_info = {
48	.flags = SMC91X_USE_16BIT | SMC91X_NOWAIT,
49	.leda = RPC_LED_100_10,
50	.ledb = RPC_LED_TX_RX,
51};
52
53static struct resource smc91x_resources[] = {
54	{
55		.name = "smc91x-regs",
56		.start = 0x20300300,
57		.end = 0x20300300 + 16,
58		.flags = IORESOURCE_MEM,
59	}, {
60		.start = IRQ_PF3,
61		.end = IRQ_PF3,
62		.flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
63	},
64};
65
66static struct platform_device smc91x_device = {
67	.name = "smc91x",
68	.id = 0,
69	.num_resources = ARRAY_SIZE(smc91x_resources),
70	.resource = smc91x_resources,
71	.dev	= {
72		.platform_data	= &smc91x_info,
73	},
74};
75#endif
76
77#if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE)
78static struct mtd_partition bfin_spi_flash_partitions[] = {
79	{
80		.name = "bootloader(spi)",
81		.size = 0x00040000,
82		.offset = 0,
83		.mask_flags = MTD_CAP_ROM
84	}, {
85		.name = "linux kernel(spi)",
86		.size = 0x180000,
87		.offset = MTDPART_OFS_APPEND,
88	}, {
89		.name = "file system(spi)",
90		.size = MTDPART_SIZ_FULL,
91		.offset = MTDPART_OFS_APPEND,
92	}
93};
94
95static struct flash_platform_data bfin_spi_flash_data = {
96	.name = "m25p80",
97	.parts = bfin_spi_flash_partitions,
98	.nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
99	.type = "m25p64",
100};
101
102/* SPI flash chip (m25p64) */
103static struct bfin5xx_spi_chip spi_flash_chip_info = {
104	.enable_dma = 0,         /* use dma transfer with this chip*/
105	.bits_per_word = 8,
106};
107#endif
108
109#if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
110static struct bfin5xx_spi_chip mmc_spi_chip_info = {
111	.enable_dma = 0,
112	.bits_per_word = 8,
113};
114#endif
115
116#if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
117static struct bfin5xx_spi_chip spidev_chip_info = {
118	.enable_dma = 0,
119	.bits_per_word = 8,
120};
121#endif
122
123static struct spi_board_info bfin_spi_board_info[] __initdata = {
124#if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE)
125	{
126		/* the modalias must be the same as spi device driver name */
127		.modalias = "m25p80", /* Name of spi_driver for this device */
128		.max_speed_hz = 20000000,     /* max spi clock (SCK) speed in HZ */
129		.bus_num = 0, /* Framework bus number */
130		.chip_select = 2, /* Framework chip select. */
131		.platform_data = &bfin_spi_flash_data,
132		.controller_data = &spi_flash_chip_info,
133		.mode = SPI_MODE_3,
134	},
135#endif
136
137#if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
138	{
139		.modalias = "mmc_spi",
140		.max_speed_hz = 20000000,     /* max spi clock (SCK) speed in HZ */
141		.bus_num = 0,
142		.chip_select = 5,
143		.controller_data = &mmc_spi_chip_info,
144		.mode = SPI_MODE_3,
145	},
146#endif
147
148#if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
149	{
150		.modalias = "spidev",
151		.max_speed_hz = 3125000,     /* max spi clock (SCK) speed in HZ */
152		.bus_num = 0,
153		.chip_select = 7,
154		.controller_data = &spidev_chip_info,
155	},
156#endif
157};
158
159#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
160/* SPI (0) */
161static struct resource bfin_spi0_resource[] = {
162	[0] = {
163		.start = SPI0_REGBASE,
164		.end   = SPI0_REGBASE + 0xFF,
165		.flags = IORESOURCE_MEM,
166	},
167	[1] = {
168		.start = CH_SPI,
169		.end   = CH_SPI,
170		.flags = IORESOURCE_DMA,
171	},
172	[2] = {
173		.start = IRQ_SPI,
174		.end   = IRQ_SPI,
175		.flags = IORESOURCE_IRQ,
176	}
177};
178
179/* SPI controller data */
180static struct bfin5xx_spi_master bfin_spi0_info = {
181	.num_chipselect = 8,
182	.enable_dma = 1,  /* master has the ability to do dma transfer */
183	.pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
184};
185
186static struct platform_device bfin_spi0_device = {
187	.name = "bfin-spi",
188	.id = 0, /* Bus number */
189	.num_resources = ARRAY_SIZE(bfin_spi0_resource),
190	.resource = bfin_spi0_resource,
191	.dev = {
192		.platform_data = &bfin_spi0_info, /* Passed to driver */
193	},
194};
195#endif  /* spi master and devices */
196
197#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
198#ifdef CONFIG_SERIAL_BFIN_UART0
199static struct resource bfin_uart0_resources[] = {
200	{
201		.start = BFIN_UART_THR,
202		.end = BFIN_UART_GCTL+2,
203		.flags = IORESOURCE_MEM,
204	},
205	{
206		.start = IRQ_UART0_RX,
207		.end = IRQ_UART0_RX + 1,
208		.flags = IORESOURCE_IRQ,
209	},
210	{
211		.start = IRQ_UART0_ERROR,
212		.end = IRQ_UART0_ERROR,
213		.flags = IORESOURCE_IRQ,
214	},
215	{
216		.start = CH_UART0_TX,
217		.end = CH_UART0_TX,
218		.flags = IORESOURCE_DMA,
219	},
220	{
221		.start = CH_UART0_RX,
222		.end = CH_UART0_RX,
223		.flags = IORESOURCE_DMA,
224	},
225};
226
227unsigned short bfin_uart0_peripherals[] = {
228	P_UART0_TX, P_UART0_RX, 0
229};
230
231static struct platform_device bfin_uart0_device = {
232	.name = "bfin-uart",
233	.id = 0,
234	.num_resources = ARRAY_SIZE(bfin_uart0_resources),
235	.resource = bfin_uart0_resources,
236	.dev = {
237		.platform_data = &bfin_uart0_peripherals, /* Passed to driver */
238	},
239};
240#endif
241#endif
242
243#if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
244#ifdef CONFIG_BFIN_SIR0
245static struct resource bfin_sir0_resources[] = {
246	{
247		.start = 0xFFC00400,
248		.end = 0xFFC004FF,
249		.flags = IORESOURCE_MEM,
250	},
251	{
252		.start = IRQ_UART0_RX,
253		.end = IRQ_UART0_RX+1,
254		.flags = IORESOURCE_IRQ,
255	},
256	{
257		.start = CH_UART0_RX,
258		.end = CH_UART0_RX+1,
259		.flags = IORESOURCE_DMA,
260	},
261};
262
263static struct platform_device bfin_sir0_device = {
264	.name = "bfin_sir",
265	.id = 0,
266	.num_resources = ARRAY_SIZE(bfin_sir0_resources),
267	.resource = bfin_sir0_resources,
268};
269#endif
270#endif
271
272#if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
273#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
274static struct resource bfin_sport0_uart_resources[] = {
275	{
276		.start = SPORT0_TCR1,
277		.end = SPORT0_MRCS3+4,
278		.flags = IORESOURCE_MEM,
279	},
280	{
281		.start = IRQ_SPORT0_RX,
282		.end = IRQ_SPORT0_RX+1,
283		.flags = IORESOURCE_IRQ,
284	},
285	{
286		.start = IRQ_SPORT0_ERROR,
287		.end = IRQ_SPORT0_ERROR,
288		.flags = IORESOURCE_IRQ,
289	},
290};
291
292unsigned short bfin_sport0_peripherals[] = {
293	P_SPORT0_TFS, P_SPORT0_DTPRI, P_SPORT0_TSCLK, P_SPORT0_RFS,
294	P_SPORT0_DRPRI, P_SPORT0_RSCLK, P_SPORT0_DRSEC, P_SPORT0_DTSEC, 0
295};
296
297static struct platform_device bfin_sport0_uart_device = {
298	.name = "bfin-sport-uart",
299	.id = 0,
300	.num_resources = ARRAY_SIZE(bfin_sport0_uart_resources),
301	.resource = bfin_sport0_uart_resources,
302	.dev = {
303		.platform_data = &bfin_sport0_peripherals, /* Passed to driver */
304	},
305};
306#endif
307#ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
308static struct resource bfin_sport1_uart_resources[] = {
309	{
310		.start = SPORT1_TCR1,
311		.end = SPORT1_MRCS3+4,
312		.flags = IORESOURCE_MEM,
313	},
314	{
315		.start = IRQ_SPORT1_RX,
316		.end = IRQ_SPORT1_RX+1,
317		.flags = IORESOURCE_IRQ,
318	},
319	{
320		.start = IRQ_SPORT1_ERROR,
321		.end = IRQ_SPORT1_ERROR,
322		.flags = IORESOURCE_IRQ,
323	},
324};
325
326unsigned short bfin_sport1_peripherals[] = {
327	P_SPORT1_TFS, P_SPORT1_DTPRI, P_SPORT1_TSCLK, P_SPORT1_RFS,
328	P_SPORT1_DRPRI, P_SPORT1_RSCLK, P_SPORT1_DRSEC, P_SPORT1_DTSEC, 0
329};
330
331static struct platform_device bfin_sport1_uart_device = {
332	.name = "bfin-sport-uart",
333	.id = 1,
334	.num_resources = ARRAY_SIZE(bfin_sport1_uart_resources),
335	.resource = bfin_sport1_uart_resources,
336	.dev = {
337		.platform_data = &bfin_sport1_peripherals, /* Passed to driver */
338	},
339};
340#endif
341#endif
342
343#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
344#include <linux/input.h>
345#include <linux/gpio_keys.h>
346
347static struct gpio_keys_button bfin_gpio_keys_table[] = {
348	{BTN_0, GPIO_PF4, 0, "gpio-keys: BTN0"},
349	{BTN_1, GPIO_PF5, 0, "gpio-keys: BTN1"},
350	{BTN_2, GPIO_PF6, 0, "gpio-keys: BTN2"},
351}; /* Mapped to the first three PF Test Points */
352
353static struct gpio_keys_platform_data bfin_gpio_keys_data = {
354	.buttons        = bfin_gpio_keys_table,
355	.nbuttons       = ARRAY_SIZE(bfin_gpio_keys_table),
356};
357
358static struct platform_device bfin_device_gpiokeys = {
359	.name      = "gpio-keys",
360	.dev = {
361		.platform_data = &bfin_gpio_keys_data,
362	},
363};
364#endif
365
366#if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
367#include <linux/i2c-gpio.h>
368
369static struct i2c_gpio_platform_data i2c_gpio_data = {
370	.sda_pin		= 8,
371	.scl_pin		= 9,
372	.sda_is_open_drain	= 0,
373	.scl_is_open_drain	= 0,
374	.udelay			= 40,
375}; /* This hasn't actually been used these pins
376    * are (currently) free pins on the expansion connector */
377
378static struct platform_device i2c_gpio_device = {
379	.name		= "i2c-gpio",
380	.id		= 0,
381	.dev		= {
382		.platform_data	= &i2c_gpio_data,
383	},
384};
385#endif
386
387static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
388};
389
390static const unsigned int cclk_vlev_datasheet[] =
391{
392	VRPAIR(VLEV_085, 250000000),
393	VRPAIR(VLEV_090, 376000000),
394	VRPAIR(VLEV_095, 426000000),
395	VRPAIR(VLEV_100, 426000000),
396	VRPAIR(VLEV_105, 476000000),
397	VRPAIR(VLEV_110, 476000000),
398	VRPAIR(VLEV_115, 476000000),
399	VRPAIR(VLEV_120, 600000000),
400	VRPAIR(VLEV_125, 600000000),
401	VRPAIR(VLEV_130, 600000000),
402};
403
404static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
405	.tuple_tab = cclk_vlev_datasheet,
406	.tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
407	.vr_settling_time = 25 /* us */,
408};
409
410static struct platform_device bfin_dpmc = {
411	.name = "bfin dpmc",
412	.dev = {
413		.platform_data = &bfin_dmpc_vreg_data,
414	},
415};
416
417static struct platform_device *stamp_devices[] __initdata = {
418
419	&bfin_dpmc,
420
421#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
422	&rtc_device,
423#endif
424
425#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
426	&smc91x_device,
427#endif
428
429
430#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
431	&bfin_spi0_device,
432#endif
433
434#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
435#ifdef CONFIG_SERIAL_BFIN_UART0
436	&bfin_uart0_device,
437#endif
438#endif
439
440#if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
441#ifdef CONFIG_BFIN_SIR0
442	&bfin_sir0_device,
443#endif
444#endif
445
446#if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
447#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
448	&bfin_sport0_uart_device,
449#endif
450#ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
451	&bfin_sport1_uart_device,
452#endif
453#endif
454
455#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
456	&bfin_device_gpiokeys,
457#endif
458
459#if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
460	&i2c_gpio_device,
461#endif
462};
463
464static int __init blackstamp_init(void)
465{
466	int ret;
467
468	printk(KERN_INFO "%s(): registering device resources\n", __func__);
469
470	i2c_register_board_info(0, bfin_i2c_board_info,
471				ARRAY_SIZE(bfin_i2c_board_info));
472
473	ret = platform_add_devices(stamp_devices, ARRAY_SIZE(stamp_devices));
474	if (ret < 0)
475		return ret;
476
477#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
478	/* setup BF533_STAMP CPLD to route AMS3 to Ethernet MAC */
479	bfin_write_FIO_DIR(bfin_read_FIO_DIR() | PF0);
480	bfin_write_FIO_FLAG_S(PF0);
481	SSYNC();
482#endif
483
484	spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
485	return 0;
486}
487
488arch_initcall(blackstamp_init);
489
490static struct platform_device *stamp_early_devices[] __initdata = {
491#if defined(CONFIG_SERIAL_BFIN_CONSOLE) || defined(CONFIG_EARLY_PRINTK)
492#ifdef CONFIG_SERIAL_BFIN_UART0
493	&bfin_uart0_device,
494#endif
495#endif
496
497#if defined(CONFIG_SERIAL_BFIN_SPORT_CONSOLE)
498#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
499	&bfin_sport0_uart_device,
500#endif
501#ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
502	&bfin_sport1_uart_device,
503#endif
504#endif
505};
506
507void __init native_machine_early_platform_add_devices(void)
508{
509	printk(KERN_INFO "register early platform devices\n");
510	early_platform_add_devices(stamp_early_devices,
511		ARRAY_SIZE(stamp_early_devices));
512}
513