2 * 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>
8 * Licensed under the GPL-2 or later.
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)
18 #include <linux/usb/isp1362.h>
20 #include <linux/irq.h>
23 #include <asm/bfin5xx_spi.h>
24 #include <asm/reboot.h>
25 #include <asm/portmux.h>
28 * Name the Board for the /proc/cpuinfo
30 const char bfin_board_name[] = "HV Sistemas H8606";
32 #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
33 static struct platform_device rtc_device = {
40 * Driver needs to know address, irq and flag pin.
42 #if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
43 static struct resource dm9000_resources[] = {
47 .flags = IORESOURCE_MEM,
52 .flags = IORESOURCE_MEM,
57 .flags = (IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE |
58 IORESOURCE_IRQ_SHAREABLE),
62 static struct platform_device dm9000_device = {
65 .resource = dm9000_resources,
66 .num_resources = ARRAY_SIZE(dm9000_resources),
70 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
71 #include <linux/smc91x.h>
73 static struct smc91x_platdata smc91x_info = {
74 .flags = SMC91X_USE_16BIT | SMC91X_NOWAIT,
75 .leda = RPC_LED_100_10,
76 .ledb = RPC_LED_TX_RX,
79 static struct resource smc91x_resources[] = {
81 .name = "smc91x-regs",
83 .end = 0x20300300 + 16,
84 .flags = IORESOURCE_MEM,
86 .start = IRQ_PROG_INTB,
88 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
92 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
96 static struct platform_device smc91x_device = {
99 .num_resources = ARRAY_SIZE(smc91x_resources),
100 .resource = smc91x_resources,
102 .platform_data = &smc91x_info,
107 #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
108 static struct resource net2272_bfin_resources[] = {
111 .end = 0x20300000 + 0x100,
112 .flags = IORESOURCE_MEM,
116 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
120 static struct platform_device net2272_bfin_device = {
123 .num_resources = ARRAY_SIZE(net2272_bfin_resources),
124 .resource = net2272_bfin_resources,
128 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
129 /* all SPI peripherals info goes here */
131 #if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE)
132 static struct mtd_partition bfin_spi_flash_partitions[] = {
134 .name = "bootloader (spi)",
137 .mask_flags = MTD_CAP_ROM
139 .name = "fpga (spi)",
143 .name = "linux kernel (spi)",
147 .name = "jffs2 root file system (spi)",
153 static struct flash_platform_data bfin_spi_flash_data = {
155 .parts = bfin_spi_flash_partitions,
156 .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
160 /* SPI flash chip (m25p64) */
161 static struct bfin5xx_spi_chip spi_flash_chip_info = {
162 .enable_dma = 0, /* use dma transfer with this chip*/
166 /* Notice: for blackfin, the speed_hz is the value of register
167 * SPI_BAUD, not the real baudrate */
168 static struct spi_board_info bfin_spi_board_info[] __initdata = {
169 #if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE)
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,
183 #if defined(CONFIG_SND_BF5XX_SOC_AD183X) || defined(CONFIG_SND_BF5XX_SOC_AD183X_MODULE)
185 .modalias = "ad183x",
195 static struct resource bfin_spi0_resource[] = {
197 .start = SPI0_REGBASE,
198 .end = SPI0_REGBASE + 0xFF,
199 .flags = IORESOURCE_MEM,
204 .flags = IORESOURCE_DMA,
209 .flags = IORESOURCE_IRQ,
214 /* SPI controller data */
215 static struct bfin5xx_spi_master bfin_spi0_info = {
217 .enable_dma = 1, /* master has the ability to do dma transfer */
218 .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
221 static struct platform_device bfin_spi0_device = {
223 .id = 0, /* Bus number */
224 .num_resources = ARRAY_SIZE(bfin_spi0_resource),
225 .resource = bfin_spi0_resource,
227 .platform_data = &bfin_spi0_info, /* Passed to driver */
230 #endif /* spi master and devices */
232 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
233 #ifdef CONFIG_SERIAL_BFIN_UART0
234 static struct resource bfin_uart0_resources[] = {
236 .start = BFIN_UART_THR,
237 .end = BFIN_UART_GCTL+2,
238 .flags = IORESOURCE_MEM,
241 .start = IRQ_UART0_RX,
242 .end = IRQ_UART0_RX + 1,
243 .flags = IORESOURCE_IRQ,
246 .start = IRQ_UART0_ERROR,
247 .end = IRQ_UART0_ERROR,
248 .flags = IORESOURCE_IRQ,
251 .start = CH_UART0_TX,
253 .flags = IORESOURCE_DMA,
256 .start = CH_UART0_RX,
258 .flags = IORESOURCE_DMA,
262 static unsigned short bfin_uart0_peripherals[] = {
263 P_UART0_TX, P_UART0_RX, 0
266 static struct platform_device bfin_uart0_device = {
269 .num_resources = ARRAY_SIZE(bfin_uart0_resources),
270 .resource = bfin_uart0_resources,
272 .platform_data = &bfin_uart0_peripherals, /* Passed to driver */
278 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
279 #ifdef CONFIG_BFIN_SIR0
280 static struct resource bfin_sir0_resources[] = {
284 .flags = IORESOURCE_MEM,
287 .start = IRQ_UART0_RX,
288 .end = IRQ_UART0_RX+1,
289 .flags = IORESOURCE_IRQ,
292 .start = CH_UART0_RX,
293 .end = CH_UART0_RX+1,
294 .flags = IORESOURCE_DMA,
298 static struct platform_device bfin_sir0_device = {
301 .num_resources = ARRAY_SIZE(bfin_sir0_resources),
302 .resource = bfin_sir0_resources,
307 #if defined(CONFIG_SERIAL_8250) || defined(CONFIG_SERIAL_8250_MODULE)
309 #include <linux/serial_8250.h>
310 #include <linux/serial.h>
313 * Configuration for two 16550 UARTS in FPGA at addresses 0x20200000 and 0x202000010.
314 * running at half system clock, both with interrupt output or-ed to PF8. Change to
315 * suit different FPGA configuration, or to suit real 16550 UARTS connected to the bus
318 static struct plat_serial8250_port serial8250_platform_data [] = {
320 .membase = (void *)0x20200000,
321 .mapbase = 0x20200000,
323 .irqflags = IRQF_TRIGGER_HIGH,
324 .flags = UPF_BOOT_AUTOCONF | UART_CONFIG_TYPE,
329 .membase = (void *)0x20200010,
330 .mapbase = 0x20200010,
332 .irqflags = IRQF_TRIGGER_HIGH,
333 .flags = UPF_BOOT_AUTOCONF | UART_CONFIG_TYPE,
341 static struct platform_device serial8250_device = {
342 .id = PLAT8250_DEV_PLATFORM,
343 .name = "serial8250",
345 .platform_data = serial8250_platform_data,
351 #if defined(CONFIG_KEYBOARD_OPENCORES) || defined(CONFIG_KEYBOARD_OPENCORES_MODULE)
354 * Configuration for one OpenCores keyboard controller in FPGA at address 0x20200030,
355 * interrupt output wired to PF9. Change to suit different FPGA configuration
358 static struct resource opencores_kbd_resources[] = {
361 .end = 0x20300030 + 2,
362 .flags = IORESOURCE_MEM,
367 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
371 static struct platform_device opencores_kbd_device = {
373 .name = "opencores-kbd",
374 .resource = opencores_kbd_resources,
375 .num_resources = ARRAY_SIZE(opencores_kbd_resources),
379 static struct platform_device *h8606_devices[] __initdata = {
380 #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
384 #if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
388 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
392 #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
393 &net2272_bfin_device,
396 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
400 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
401 #ifdef CONFIG_SERIAL_BFIN_UART0
406 #if defined(CONFIG_SERIAL_8250) || defined(CONFIG_SERIAL_8250_MODULE)
410 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
411 #ifdef CONFIG_BFIN_SIR0
416 #if defined(CONFIG_KEYBOARD_OPENCORES) || defined(CONFIG_KEYBOARD_OPENCORES_MODULE)
417 &opencores_kbd_device,
421 static int __init H8606_init(void)
423 printk(KERN_INFO "HV Sistemas H8606 board support by http://www.hvsistemas.com\n");
424 printk(KERN_INFO "%s(): registering device resources\n", __func__);
425 platform_add_devices(h8606_devices, ARRAY_SIZE(h8606_devices));
426 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
427 spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
432 arch_initcall(H8606_init);
434 static struct platform_device *H8606_early_devices[] __initdata = {
435 #if defined(CONFIG_SERIAL_BFIN_CONSOLE) || defined(CONFIG_EARLY_PRINTK)
436 #ifdef CONFIG_SERIAL_BFIN_UART0
442 void __init native_machine_early_platform_add_devices(void)
444 printk(KERN_INFO "register early platform devices\n");
445 early_platform_add_devices(H8606_early_devices,
446 ARRAY_SIZE(H8606_early_devices));