blob: 6cb7b3ed9b3de48d276324ee81d9277d7102a72e [file] [log] [blame]
Javier Herreroab472a02007-10-29 16:14:44 +08001/*
Robin Getz96f10502009-09-24 14:11:24 +00002 * Copyright 2004-2009 Analog Devices Inc.
3 * 2007-2008 HV Sistemas S.L.
4 * Javier Herrero <jherrero@hvsistemas.es>
5 * 2005 National ICT Australia (NICTA)
6 * Aidan Williams <aidan@nicta.com.au>
Javier Herreroab472a02007-10-29 16:14:44 +08007 *
Robin Getz96f10502009-09-24 14:11:24 +00008 * Licensed under the GPL-2 or later.
Javier Herreroab472a02007-10-29 16:14:44 +08009 */
10
11#include <linux/device.h>
12#include <linux/platform_device.h>
13#include <linux/mtd/mtd.h>
14#include <linux/mtd/partitions.h>
15#include <linux/spi/spi.h>
16#include <linux/spi/flash.h>
17#if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
Mike Frysingerf02bcec2007-11-15 21:29:15 +080018#include <linux/usb/isp1362.h>
Javier Herreroab472a02007-10-29 16:14:44 +080019#endif
Javier Herreroab472a02007-10-29 16:14:44 +080020#include <linux/irq.h>
Javier Herrerofb96c562007-12-21 18:26:44 +080021
Javier Herreroab472a02007-10-29 16:14:44 +080022#include <asm/dma.h>
23#include <asm/bfin5xx_spi.h>
24#include <asm/reboot.h>
Bryan Wu5d448dd2007-11-12 23:24:42 +080025#include <asm/portmux.h>
Javier Herreroab472a02007-10-29 16:14:44 +080026
27/*
28 * Name the Board for the /proc/cpuinfo
29 */
30const char bfin_board_name[] = "HV Sistemas H8606";
31
Robert P. J. Day09db9482007-11-17 22:57:03 +080032#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
Javier Herreroab472a02007-10-29 16:14:44 +080033static struct platform_device rtc_device = {
34 .name = "rtc-bfin",
35 .id = -1,
36};
37#endif
38
39/*
40* Driver needs to know address, irq and flag pin.
41 */
42 #if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
43static struct resource dm9000_resources[] = {
44 [0] = {
45 .start = 0x20300000,
Javier Herrero45138432008-10-09 18:06:47 +080046 .end = 0x20300002,
Javier Herreroab472a02007-10-29 16:14:44 +080047 .flags = IORESOURCE_MEM,
48 },
49 [1] = {
Javier Herrero45138432008-10-09 18:06:47 +080050 .start = 0x20300004,
51 .end = 0x20300006,
Laurent Pinchartda3854f2008-06-24 22:15:58 +010052 .flags = IORESOURCE_MEM,
53 },
54 [2] = {
Javier Herreroab472a02007-10-29 16:14:44 +080055 .start = IRQ_PF10,
56 .end = IRQ_PF10,
Thomas Gleixner74b65412011-07-23 15:51:38 +000057 .flags = (IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE |
58 IORESOURCE_IRQ_SHAREABLE),
Javier Herreroab472a02007-10-29 16:14:44 +080059 },
60};
61
62static struct platform_device dm9000_device = {
63 .id = 0,
64 .name = "dm9000",
65 .resource = dm9000_resources,
66 .num_resources = ARRAY_SIZE(dm9000_resources),
67};
68#endif
69
70#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
Michael Hennerich61f09b52009-07-24 08:48:31 +000071#include <linux/smc91x.h>
72
73static struct smc91x_platdata smc91x_info = {
74 .flags = SMC91X_USE_16BIT | SMC91X_NOWAIT,
75 .leda = RPC_LED_100_10,
76 .ledb = RPC_LED_TX_RX,
77};
78
Javier Herreroab472a02007-10-29 16:14:44 +080079static struct resource smc91x_resources[] = {
80 {
81 .name = "smc91x-regs",
82 .start = 0x20300300,
83 .end = 0x20300300 + 16,
84 .flags = IORESOURCE_MEM,
85 }, {
86 .start = IRQ_PROG_INTB,
87 .end = IRQ_PROG_INTB,
88 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
89 }, {
Javier Herreroab472a02007-10-29 16:14:44 +080090 .start = IRQ_PF7,
91 .end = IRQ_PF7,
92 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
93 },
94};
95
96static struct platform_device smc91x_device = {
97 .name = "smc91x",
98 .id = 0,
99 .num_resources = ARRAY_SIZE(smc91x_resources),
100 .resource = smc91x_resources,
Michael Hennerich61f09b52009-07-24 08:48:31 +0000101 .dev = {
102 .platform_data = &smc91x_info,
103 },
Javier Herreroab472a02007-10-29 16:14:44 +0800104};
105#endif
106
107#if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
108static struct resource net2272_bfin_resources[] = {
109 {
110 .start = 0x20300000,
111 .end = 0x20300000 + 0x100,
112 .flags = IORESOURCE_MEM,
113 }, {
114 .start = IRQ_PF10,
115 .end = IRQ_PF10,
116 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
117 },
118};
119
120static 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,
125};
126#endif
127
Sonic Zhang7d157fb2011-11-07 18:40:10 +0800128#if defined(CONFIG_SPI_BFIN5XX) || defined(CONFIG_SPI_BFIN5XX_MODULE)
Javier Herreroab472a02007-10-29 16:14:44 +0800129/* all SPI peripherals info goes here */
130
131#if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE)
132static struct mtd_partition bfin_spi_flash_partitions[] = {
133 {
Javier Herrero45138432008-10-09 18:06:47 +0800134 .name = "bootloader (spi)",
135 .size = 0x40000,
Javier Herreroab472a02007-10-29 16:14:44 +0800136 .offset = 0,
137 .mask_flags = MTD_CAP_ROM
138 }, {
Javier Herrero45138432008-10-09 18:06:47 +0800139 .name = "fpga (spi)",
140 .size = 0x30000,
141 .offset = 0x40000
Javier Herreroab472a02007-10-29 16:14:44 +0800142 }, {
Javier Herrero45138432008-10-09 18:06:47 +0800143 .name = "linux kernel (spi)",
144 .size = 0x150000,
145 .offset = 0x70000
146 }, {
147 .name = "jffs2 root file system (spi)",
148 .size = 0x640000,
149 .offset = 0x1c0000,
Javier Herreroab472a02007-10-29 16:14:44 +0800150 }
151};
152
153static struct flash_platform_data bfin_spi_flash_data = {
154 .name = "m25p80",
155 .parts = bfin_spi_flash_partitions,
156 .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
157 .type = "m25p64",
158};
159
160/* SPI flash chip (m25p64) */
161static struct bfin5xx_spi_chip spi_flash_chip_info = {
162 .enable_dma = 0, /* use dma transfer with this chip*/
Javier Herreroab472a02007-10-29 16:14:44 +0800163};
164#endif
165
Javier Herreroab472a02007-10-29 16:14:44 +0800166/* Notice: for blackfin, the speed_hz is the value of register
167 * SPI_BAUD, not the real baudrate */
168static struct spi_board_info bfin_spi_board_info[] __initdata = {
169#if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE)
170 {
171 /* the modalias must be the same as spi device driver name */
172 .modalias = "m25p80", /* Name of spi_driver for this device */
173 /* this value is the baudrate divisor */
174 .max_speed_hz = 50000000, /* actual baudrate is SCLK/(2xspeed_hz) */
175 .bus_num = 0, /* Framework bus number */
176 .chip_select = 2, /* Framework chip select. On STAMP537 it is SPISSEL2*/
177 .platform_data = &bfin_spi_flash_data,
178 .controller_data = &spi_flash_chip_info,
179 .mode = SPI_MODE_3,
180 },
181#endif
182
Barry Song7ba80062010-01-28 09:37:21 +0000183#if defined(CONFIG_SND_BF5XX_SOC_AD183X) || defined(CONFIG_SND_BF5XX_SOC_AD183X_MODULE)
Javier Herreroab472a02007-10-29 16:14:44 +0800184 {
Barry Song7ba80062010-01-28 09:37:21 +0000185 .modalias = "ad183x",
Javier Herreroab472a02007-10-29 16:14:44 +0800186 .max_speed_hz = 16,
187 .bus_num = 1,
Barry Song7ba80062010-01-28 09:37:21 +0000188 .chip_select = 4,
Javier Herreroab472a02007-10-29 16:14:44 +0800189 },
190#endif
191
Javier Herreroab472a02007-10-29 16:14:44 +0800192};
193
194/* SPI (0) */
195static struct resource bfin_spi0_resource[] = {
196 [0] = {
197 .start = SPI0_REGBASE,
198 .end = SPI0_REGBASE + 0xFF,
199 .flags = IORESOURCE_MEM,
200 },
201 [1] = {
202 .start = CH_SPI,
203 .end = CH_SPI,
Yi Li53122692009-06-05 12:11:11 +0000204 .flags = IORESOURCE_DMA,
205 },
206 [2] = {
207 .start = IRQ_SPI,
208 .end = IRQ_SPI,
Javier Herreroab472a02007-10-29 16:14:44 +0800209 .flags = IORESOURCE_IRQ,
210 }
211};
212
213
214/* SPI controller data */
215static struct bfin5xx_spi_master bfin_spi0_info = {
216 .num_chipselect = 8,
217 .enable_dma = 1, /* master has the ability to do dma transfer */
Bryan Wu5d448dd2007-11-12 23:24:42 +0800218 .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
Javier Herreroab472a02007-10-29 16:14:44 +0800219};
220
221static struct platform_device bfin_spi0_device = {
222 .name = "bfin-spi",
223 .id = 0, /* Bus number */
224 .num_resources = ARRAY_SIZE(bfin_spi0_resource),
225 .resource = bfin_spi0_resource,
226 .dev = {
227 .platform_data = &bfin_spi0_info, /* Passed to driver */
228 },
229};
230#endif /* spi master and devices */
231
Javier Herreroab472a02007-10-29 16:14:44 +0800232#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
Sonic Zhang6bd1fbe2009-09-09 10:46:19 +0000233#ifdef CONFIG_SERIAL_BFIN_UART0
234static struct resource bfin_uart0_resources[] = {
Javier Herreroab472a02007-10-29 16:14:44 +0800235 {
Sonic Zhang6bd1fbe2009-09-09 10:46:19 +0000236 .start = BFIN_UART_THR,
237 .end = BFIN_UART_GCTL+2,
Javier Herreroab472a02007-10-29 16:14:44 +0800238 .flags = IORESOURCE_MEM,
239 },
Sonic Zhang6bd1fbe2009-09-09 10:46:19 +0000240 {
Sonic Zhangedb0a642011-08-01 17:53:21 +0800241 .start = IRQ_UART0_TX,
242 .end = IRQ_UART0_TX,
243 .flags = IORESOURCE_IRQ,
244 },
245 {
Sonic Zhang6bd1fbe2009-09-09 10:46:19 +0000246 .start = IRQ_UART0_RX,
Sonic Zhangedb0a642011-08-01 17:53:21 +0800247 .end = IRQ_UART0_RX,
Sonic Zhang6bd1fbe2009-09-09 10:46:19 +0000248 .flags = IORESOURCE_IRQ,
249 },
250 {
251 .start = IRQ_UART0_ERROR,
252 .end = IRQ_UART0_ERROR,
253 .flags = IORESOURCE_IRQ,
254 },
255 {
256 .start = CH_UART0_TX,
257 .end = CH_UART0_TX,
258 .flags = IORESOURCE_DMA,
259 },
260 {
261 .start = CH_UART0_RX,
262 .end = CH_UART0_RX,
263 .flags = IORESOURCE_DMA,
264 },
Javier Herreroab472a02007-10-29 16:14:44 +0800265};
266
Mike Frysingera8b19882010-11-24 09:23:04 +0000267static unsigned short bfin_uart0_peripherals[] = {
Sonic Zhang6bd1fbe2009-09-09 10:46:19 +0000268 P_UART0_TX, P_UART0_RX, 0
Javier Herreroab472a02007-10-29 16:14:44 +0800269};
Sonic Zhang6bd1fbe2009-09-09 10:46:19 +0000270
271static struct platform_device bfin_uart0_device = {
272 .name = "bfin-uart",
273 .id = 0,
274 .num_resources = ARRAY_SIZE(bfin_uart0_resources),
275 .resource = bfin_uart0_resources,
276 .dev = {
277 .platform_data = &bfin_uart0_peripherals, /* Passed to driver */
278 },
279};
280#endif
Javier Herreroab472a02007-10-29 16:14:44 +0800281#endif
282
Graf Yang5be36d22008-04-25 03:09:15 +0800283#if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
Graf Yang5be36d22008-04-25 03:09:15 +0800284#ifdef CONFIG_BFIN_SIR0
Graf Yang42bd8bc2009-01-07 23:14:39 +0800285static struct resource bfin_sir0_resources[] = {
Graf Yang5be36d22008-04-25 03:09:15 +0800286 {
287 .start = 0xFFC00400,
288 .end = 0xFFC004FF,
289 .flags = IORESOURCE_MEM,
290 },
Graf Yang42bd8bc2009-01-07 23:14:39 +0800291 {
292 .start = IRQ_UART0_RX,
293 .end = IRQ_UART0_RX+1,
294 .flags = IORESOURCE_IRQ,
295 },
296 {
297 .start = CH_UART0_RX,
298 .end = CH_UART0_RX+1,
299 .flags = IORESOURCE_DMA,
300 },
Graf Yang5be36d22008-04-25 03:09:15 +0800301};
302
Graf Yang42bd8bc2009-01-07 23:14:39 +0800303static struct platform_device bfin_sir0_device = {
Graf Yang5be36d22008-04-25 03:09:15 +0800304 .name = "bfin_sir",
305 .id = 0,
Graf Yang42bd8bc2009-01-07 23:14:39 +0800306 .num_resources = ARRAY_SIZE(bfin_sir0_resources),
307 .resource = bfin_sir0_resources,
Graf Yang5be36d22008-04-25 03:09:15 +0800308};
309#endif
Graf Yang42bd8bc2009-01-07 23:14:39 +0800310#endif
Graf Yang5be36d22008-04-25 03:09:15 +0800311
Javier Herrerofb96c562007-12-21 18:26:44 +0800312#if defined(CONFIG_SERIAL_8250) || defined(CONFIG_SERIAL_8250_MODULE)
313
314#include <linux/serial_8250.h>
315#include <linux/serial.h>
316
317/*
318 * Configuration for two 16550 UARTS in FPGA at addresses 0x20200000 and 0x202000010.
319 * running at half system clock, both with interrupt output or-ed to PF8. Change to
320 * suit different FPGA configuration, or to suit real 16550 UARTS connected to the bus
321 */
322
323static struct plat_serial8250_port serial8250_platform_data [] = {
324 {
Javier Herrero45138432008-10-09 18:06:47 +0800325 .membase = (void *)0x20200000,
Javier Herrerofb96c562007-12-21 18:26:44 +0800326 .mapbase = 0x20200000,
327 .irq = IRQ_PF8,
Mike Frysinger49e00ed2010-10-17 04:59:16 -0400328 .irqflags = IRQF_TRIGGER_HIGH,
Javier Herrerofb96c562007-12-21 18:26:44 +0800329 .flags = UPF_BOOT_AUTOCONF | UART_CONFIG_TYPE,
330 .iotype = UPIO_MEM,
331 .regshift = 1,
332 .uartclk = 66666667,
333 }, {
Javier Herrero45138432008-10-09 18:06:47 +0800334 .membase = (void *)0x20200010,
Javier Herrerofb96c562007-12-21 18:26:44 +0800335 .mapbase = 0x20200010,
336 .irq = IRQ_PF8,
Mike Frysinger49e00ed2010-10-17 04:59:16 -0400337 .irqflags = IRQF_TRIGGER_HIGH,
Javier Herrerofb96c562007-12-21 18:26:44 +0800338 .flags = UPF_BOOT_AUTOCONF | UART_CONFIG_TYPE,
339 .iotype = UPIO_MEM,
340 .regshift = 1,
341 .uartclk = 66666667,
342 }, {
343 }
344};
345
346static struct platform_device serial8250_device = {
347 .id = PLAT8250_DEV_PLATFORM,
348 .name = "serial8250",
349 .dev = {
350 .platform_data = serial8250_platform_data,
351 },
352};
353
354#endif
355
Javier Herrero7a5f8192008-01-27 19:53:08 +0800356#if defined(CONFIG_KEYBOARD_OPENCORES) || defined(CONFIG_KEYBOARD_OPENCORES_MODULE)
357
358/*
359 * Configuration for one OpenCores keyboard controller in FPGA at address 0x20200030,
360 * interrupt output wired to PF9. Change to suit different FPGA configuration
361 */
362
363static struct resource opencores_kbd_resources[] = {
364 [0] = {
365 .start = 0x20200030,
366 .end = 0x20300030 + 2,
367 .flags = IORESOURCE_MEM,
368 },
369 [1] = {
370 .start = IRQ_PF9,
371 .end = IRQ_PF9,
372 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
373 },
374};
375
376static struct platform_device opencores_kbd_device = {
377 .id = -1,
378 .name = "opencores-kbd",
379 .resource = opencores_kbd_resources,
380 .num_resources = ARRAY_SIZE(opencores_kbd_resources),
381};
382#endif
383
Javier Herrerofb96c562007-12-21 18:26:44 +0800384static struct platform_device *h8606_devices[] __initdata = {
Javier Herreroab472a02007-10-29 16:14:44 +0800385#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
386 &rtc_device,
387#endif
388
389#if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
390 &dm9000_device,
391#endif
392
393#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
394 &smc91x_device,
395#endif
396
397#if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
398 &net2272_bfin_device,
399#endif
400
Sonic Zhang7d157fb2011-11-07 18:40:10 +0800401#if defined(CONFIG_SPI_BFIN5XX) || defined(CONFIG_SPI_BFIN5XX_MODULE)
Javier Herreroab472a02007-10-29 16:14:44 +0800402 &bfin_spi0_device,
403#endif
404
405#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
Sonic Zhang6bd1fbe2009-09-09 10:46:19 +0000406#ifdef CONFIG_SERIAL_BFIN_UART0
407 &bfin_uart0_device,
408#endif
Javier Herreroab472a02007-10-29 16:14:44 +0800409#endif
Javier Herrerofb96c562007-12-21 18:26:44 +0800410
411#if defined(CONFIG_SERIAL_8250) || defined(CONFIG_SERIAL_8250_MODULE)
412 &serial8250_device,
413#endif
Javier Herrero7a5f8192008-01-27 19:53:08 +0800414
Graf Yang5be36d22008-04-25 03:09:15 +0800415#if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
Graf Yang42bd8bc2009-01-07 23:14:39 +0800416#ifdef CONFIG_BFIN_SIR0
417 &bfin_sir0_device,
418#endif
Graf Yang5be36d22008-04-25 03:09:15 +0800419#endif
420
Javier Herrero7a5f8192008-01-27 19:53:08 +0800421#if defined(CONFIG_KEYBOARD_OPENCORES) || defined(CONFIG_KEYBOARD_OPENCORES_MODULE)
422 &opencores_kbd_device,
423#endif
Javier Herreroab472a02007-10-29 16:14:44 +0800424};
425
426static int __init H8606_init(void)
427{
428 printk(KERN_INFO "HV Sistemas H8606 board support by http://www.hvsistemas.com\n");
Harvey Harrisonb85d8582008-04-23 09:39:01 +0800429 printk(KERN_INFO "%s(): registering device resources\n", __func__);
Javier Herrerofb96c562007-12-21 18:26:44 +0800430 platform_add_devices(h8606_devices, ARRAY_SIZE(h8606_devices));
Sonic Zhang7d157fb2011-11-07 18:40:10 +0800431#if defined(CONFIG_SPI_BFIN5XX) || defined(CONFIG_SPI_BFIN5XX_MODULE)
Javier Herreroab472a02007-10-29 16:14:44 +0800432 spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
433#endif
434 return 0;
435}
436
Mike Frysinger0feea172007-11-15 21:10:42 +0800437arch_initcall(H8606_init);
Sonic Zhangc13ce9f2009-09-23 09:37:46 +0000438
439static struct platform_device *H8606_early_devices[] __initdata = {
440#if defined(CONFIG_SERIAL_BFIN_CONSOLE) || defined(CONFIG_EARLY_PRINTK)
441#ifdef CONFIG_SERIAL_BFIN_UART0
442 &bfin_uart0_device,
443#endif
444#endif
445};
446
447void __init native_machine_early_platform_add_devices(void)
448{
449 printk(KERN_INFO "register early platform devices\n");
450 early_platform_add_devices(H8606_early_devices,
451 ARRAY_SIZE(H8606_early_devices));
452}