2 * Platform device support for Au1x00 SoCs.
4 * Copyright 2004, Matt Porter <mporter@kernel.crashing.org>
6 * (C) Copyright Embedded Alley Solutions, Inc 2005
7 * Author: Pantelis Antoniou <pantelis@embeddedalley.com>
9 * This file is licensed under the terms of the GNU General Public
10 * License version 2. This program is licensed "as is" without any
11 * warranty of any kind, whether express or implied.
14 #include <linux/dma-mapping.h>
15 #include <linux/etherdevice.h>
16 #include <linux/platform_device.h>
17 #include <linux/serial_8250.h>
18 #include <linux/init.h>
20 #include <asm/mach-au1x00/au1xxx.h>
21 #include <asm/mach-au1x00/au1xxx_dbdma.h>
22 #include <asm/mach-au1x00/au1100_mmc.h>
23 #include <asm/mach-au1x00/au1xxx_eth.h>
27 static void alchemy_8250_pm(struct uart_port
*port
, unsigned int state
,
28 unsigned int old_state
)
30 #ifdef CONFIG_SERIAL_8250
33 if ((__raw_readl(port
->membase
+ UART_MOD_CNTRL
) & 3) != 3) {
34 /* power-on sequence as suggested in the databooks */
35 __raw_writel(0, port
->membase
+ UART_MOD_CNTRL
);
37 __raw_writel(1, port
->membase
+ UART_MOD_CNTRL
);
40 __raw_writel(3, port
->membase
+ UART_MOD_CNTRL
); /* full on */
42 serial8250_do_pm(port
, state
, old_state
);
44 case 3: /* power off */
45 serial8250_do_pm(port
, state
, old_state
);
46 __raw_writel(0, port
->membase
+ UART_MOD_CNTRL
);
50 serial8250_do_pm(port
, state
, old_state
);
56 #define PORT(_base, _irq) \
62 .flags = UPF_SKIP_TEST | UPF_IOREMAP | \
64 .type = PORT_16550A, \
65 .pm = alchemy_8250_pm, \
68 static struct plat_serial8250_port au1x00_uart_data
[] = {
69 #if defined(CONFIG_SOC_AU1000)
70 PORT(UART0_PHYS_ADDR
, AU1000_UART0_INT
),
71 PORT(UART1_PHYS_ADDR
, AU1000_UART1_INT
),
72 PORT(UART2_PHYS_ADDR
, AU1000_UART2_INT
),
73 PORT(UART3_PHYS_ADDR
, AU1000_UART3_INT
),
74 #elif defined(CONFIG_SOC_AU1500)
75 PORT(UART0_PHYS_ADDR
, AU1500_UART0_INT
),
76 PORT(UART3_PHYS_ADDR
, AU1500_UART3_INT
),
77 #elif defined(CONFIG_SOC_AU1100)
78 PORT(UART0_PHYS_ADDR
, AU1100_UART0_INT
),
79 PORT(UART1_PHYS_ADDR
, AU1100_UART1_INT
),
80 PORT(UART3_PHYS_ADDR
, AU1100_UART3_INT
),
81 #elif defined(CONFIG_SOC_AU1550)
82 PORT(UART0_PHYS_ADDR
, AU1550_UART0_INT
),
83 PORT(UART1_PHYS_ADDR
, AU1550_UART1_INT
),
84 PORT(UART3_PHYS_ADDR
, AU1550_UART3_INT
),
85 #elif defined(CONFIG_SOC_AU1200)
86 PORT(UART0_PHYS_ADDR
, AU1200_UART0_INT
),
87 PORT(UART1_PHYS_ADDR
, AU1200_UART1_INT
),
92 static struct platform_device au1xx0_uart_device
= {
94 .id
= PLAT8250_DEV_AU1X00
,
96 .platform_data
= au1x00_uart_data
,
100 /* OHCI (USB full speed host controller) */
101 static struct resource au1xxx_usb_ohci_resources
[] = {
103 .start
= USB_OHCI_BASE
,
104 .end
= USB_OHCI_BASE
+ USB_OHCI_LEN
- 1,
105 .flags
= IORESOURCE_MEM
,
108 .start
= FOR_PLATFORM_C_USB_HOST_INT
,
109 .end
= FOR_PLATFORM_C_USB_HOST_INT
,
110 .flags
= IORESOURCE_IRQ
,
114 /* The dmamask must be set for OHCI to work */
115 static u64 ohci_dmamask
= DMA_BIT_MASK(32);
117 static struct platform_device au1xxx_usb_ohci_device
= {
118 .name
= "au1xxx-ohci",
121 .dma_mask
= &ohci_dmamask
,
122 .coherent_dma_mask
= DMA_BIT_MASK(32),
124 .num_resources
= ARRAY_SIZE(au1xxx_usb_ohci_resources
),
125 .resource
= au1xxx_usb_ohci_resources
,
128 /*** AU1100 LCD controller ***/
130 #ifdef CONFIG_FB_AU1100
131 static struct resource au1100_lcd_resources
[] = {
133 .start
= LCD_PHYS_ADDR
,
134 .end
= LCD_PHYS_ADDR
+ 0x800 - 1,
135 .flags
= IORESOURCE_MEM
,
138 .start
= AU1100_LCD_INT
,
139 .end
= AU1100_LCD_INT
,
140 .flags
= IORESOURCE_IRQ
,
144 static u64 au1100_lcd_dmamask
= DMA_BIT_MASK(32);
146 static struct platform_device au1100_lcd_device
= {
147 .name
= "au1100-lcd",
150 .dma_mask
= &au1100_lcd_dmamask
,
151 .coherent_dma_mask
= DMA_BIT_MASK(32),
153 .num_resources
= ARRAY_SIZE(au1100_lcd_resources
),
154 .resource
= au1100_lcd_resources
,
158 #ifdef CONFIG_SOC_AU1200
159 /* EHCI (USB high speed host controller) */
160 static struct resource au1xxx_usb_ehci_resources
[] = {
162 .start
= USB_EHCI_BASE
,
163 .end
= USB_EHCI_BASE
+ USB_EHCI_LEN
- 1,
164 .flags
= IORESOURCE_MEM
,
167 .start
= AU1200_USB_INT
,
168 .end
= AU1200_USB_INT
,
169 .flags
= IORESOURCE_IRQ
,
173 static u64 ehci_dmamask
= DMA_BIT_MASK(32);
175 static struct platform_device au1xxx_usb_ehci_device
= {
176 .name
= "au1xxx-ehci",
179 .dma_mask
= &ehci_dmamask
,
180 .coherent_dma_mask
= DMA_BIT_MASK(32),
182 .num_resources
= ARRAY_SIZE(au1xxx_usb_ehci_resources
),
183 .resource
= au1xxx_usb_ehci_resources
,
186 /* Au1200 UDC (USB gadget controller) */
187 static struct resource au1xxx_usb_gdt_resources
[] = {
189 .start
= USB_UDC_BASE
,
190 .end
= USB_UDC_BASE
+ USB_UDC_LEN
- 1,
191 .flags
= IORESOURCE_MEM
,
194 .start
= AU1200_USB_INT
,
195 .end
= AU1200_USB_INT
,
196 .flags
= IORESOURCE_IRQ
,
200 static u64 udc_dmamask
= DMA_BIT_MASK(32);
202 static struct platform_device au1xxx_usb_gdt_device
= {
203 .name
= "au1xxx-udc",
206 .dma_mask
= &udc_dmamask
,
207 .coherent_dma_mask
= DMA_BIT_MASK(32),
209 .num_resources
= ARRAY_SIZE(au1xxx_usb_gdt_resources
),
210 .resource
= au1xxx_usb_gdt_resources
,
213 /* Au1200 UOC (USB OTG controller) */
214 static struct resource au1xxx_usb_otg_resources
[] = {
216 .start
= USB_UOC_BASE
,
217 .end
= USB_UOC_BASE
+ USB_UOC_LEN
- 1,
218 .flags
= IORESOURCE_MEM
,
221 .start
= AU1200_USB_INT
,
222 .end
= AU1200_USB_INT
,
223 .flags
= IORESOURCE_IRQ
,
227 static u64 uoc_dmamask
= DMA_BIT_MASK(32);
229 static struct platform_device au1xxx_usb_otg_device
= {
230 .name
= "au1xxx-uoc",
233 .dma_mask
= &uoc_dmamask
,
234 .coherent_dma_mask
= DMA_BIT_MASK(32),
236 .num_resources
= ARRAY_SIZE(au1xxx_usb_otg_resources
),
237 .resource
= au1xxx_usb_otg_resources
,
240 static struct resource au1200_lcd_resources
[] = {
242 .start
= LCD_PHYS_ADDR
,
243 .end
= LCD_PHYS_ADDR
+ 0x800 - 1,
244 .flags
= IORESOURCE_MEM
,
247 .start
= AU1200_LCD_INT
,
248 .end
= AU1200_LCD_INT
,
249 .flags
= IORESOURCE_IRQ
,
253 static u64 au1200_lcd_dmamask
= DMA_BIT_MASK(32);
255 static struct platform_device au1200_lcd_device
= {
256 .name
= "au1200-lcd",
259 .dma_mask
= &au1200_lcd_dmamask
,
260 .coherent_dma_mask
= DMA_BIT_MASK(32),
262 .num_resources
= ARRAY_SIZE(au1200_lcd_resources
),
263 .resource
= au1200_lcd_resources
,
266 static u64 au1xxx_mmc_dmamask
= DMA_BIT_MASK(32);
268 extern struct au1xmmc_platform_data au1xmmc_platdata
[2];
270 static struct resource au1200_mmc0_resources
[] = {
272 .start
= SD0_PHYS_ADDR
,
273 .end
= SD0_PHYS_ADDR
+ 0x7ffff,
274 .flags
= IORESOURCE_MEM
,
277 .start
= AU1200_SD_INT
,
278 .end
= AU1200_SD_INT
,
279 .flags
= IORESOURCE_IRQ
,
282 .start
= DSCR_CMD0_SDMS_TX0
,
283 .end
= DSCR_CMD0_SDMS_TX0
,
284 .flags
= IORESOURCE_DMA
,
287 .start
= DSCR_CMD0_SDMS_RX0
,
288 .end
= DSCR_CMD0_SDMS_RX0
,
289 .flags
= IORESOURCE_DMA
,
293 static struct platform_device au1200_mmc0_device
= {
294 .name
= "au1xxx-mmc",
297 .dma_mask
= &au1xxx_mmc_dmamask
,
298 .coherent_dma_mask
= DMA_BIT_MASK(32),
299 .platform_data
= &au1xmmc_platdata
[0],
301 .num_resources
= ARRAY_SIZE(au1200_mmc0_resources
),
302 .resource
= au1200_mmc0_resources
,
305 #ifndef CONFIG_MIPS_DB1200
306 static struct resource au1200_mmc1_resources
[] = {
308 .start
= SD1_PHYS_ADDR
,
309 .end
= SD1_PHYS_ADDR
+ 0x7ffff,
310 .flags
= IORESOURCE_MEM
,
313 .start
= AU1200_SD_INT
,
314 .end
= AU1200_SD_INT
,
315 .flags
= IORESOURCE_IRQ
,
318 .start
= DSCR_CMD0_SDMS_TX1
,
319 .end
= DSCR_CMD0_SDMS_TX1
,
320 .flags
= IORESOURCE_DMA
,
323 .start
= DSCR_CMD0_SDMS_RX1
,
324 .end
= DSCR_CMD0_SDMS_RX1
,
325 .flags
= IORESOURCE_DMA
,
329 static struct platform_device au1200_mmc1_device
= {
330 .name
= "au1xxx-mmc",
333 .dma_mask
= &au1xxx_mmc_dmamask
,
334 .coherent_dma_mask
= DMA_BIT_MASK(32),
335 .platform_data
= &au1xmmc_platdata
[1],
337 .num_resources
= ARRAY_SIZE(au1200_mmc1_resources
),
338 .resource
= au1200_mmc1_resources
,
340 #endif /* #ifndef CONFIG_MIPS_DB1200 */
341 #endif /* #ifdef CONFIG_SOC_AU1200 */
343 /* All Alchemy demoboards with I2C have this #define in their headers */
344 #ifdef SMBUS_PSC_BASE
345 static struct resource pbdb_smbus_resources
[] = {
347 .start
= CPHYSADDR(SMBUS_PSC_BASE
),
348 .end
= CPHYSADDR(SMBUS_PSC_BASE
+ 0xfffff),
349 .flags
= IORESOURCE_MEM
,
353 static struct platform_device pbdb_smbus_device
= {
354 .name
= "au1xpsc_smbus",
355 .id
= 0, /* bus number */
356 .num_resources
= ARRAY_SIZE(pbdb_smbus_resources
),
357 .resource
= pbdb_smbus_resources
,
361 /* Macro to help defining the Ethernet MAC resources */
362 #define MAC_RES(_base, _enable, _irq) \
364 .start = CPHYSADDR(_base), \
365 .end = CPHYSADDR(_base + 0xffff), \
366 .flags = IORESOURCE_MEM, \
369 .start = CPHYSADDR(_enable), \
370 .end = CPHYSADDR(_enable + 0x3), \
371 .flags = IORESOURCE_MEM, \
376 .flags = IORESOURCE_IRQ \
379 static struct resource au1xxx_eth0_resources
[] = {
380 #if defined(CONFIG_SOC_AU1000)
381 MAC_RES(AU1000_ETH0_BASE
, AU1000_MAC0_ENABLE
, AU1000_MAC0_DMA_INT
),
382 #elif defined(CONFIG_SOC_AU1100)
383 MAC_RES(AU1100_ETH0_BASE
, AU1100_MAC0_ENABLE
, AU1100_MAC0_DMA_INT
),
384 #elif defined(CONFIG_SOC_AU1550)
385 MAC_RES(AU1550_ETH0_BASE
, AU1550_MAC0_ENABLE
, AU1550_MAC0_DMA_INT
),
386 #elif defined(CONFIG_SOC_AU1500)
387 MAC_RES(AU1500_ETH0_BASE
, AU1500_MAC0_ENABLE
, AU1500_MAC0_DMA_INT
),
392 static struct au1000_eth_platform_data au1xxx_eth0_platform_data
= {
393 .phy1_search_mac0
= 1,
396 static struct platform_device au1xxx_eth0_device
= {
397 .name
= "au1000-eth",
399 .num_resources
= ARRAY_SIZE(au1xxx_eth0_resources
),
400 .resource
= au1xxx_eth0_resources
,
401 .dev
.platform_data
= &au1xxx_eth0_platform_data
,
404 #ifndef CONFIG_SOC_AU1100
405 static struct resource au1xxx_eth1_resources
[] = {
406 #if defined(CONFIG_SOC_AU1000)
407 MAC_RES(AU1000_ETH1_BASE
, AU1000_MAC1_ENABLE
, AU1000_MAC1_DMA_INT
),
408 #elif defined(CONFIG_SOC_AU1550)
409 MAC_RES(AU1550_ETH1_BASE
, AU1550_MAC1_ENABLE
, AU1550_MAC1_DMA_INT
),
410 #elif defined(CONFIG_SOC_AU1500)
411 MAC_RES(AU1500_ETH1_BASE
, AU1500_MAC1_ENABLE
, AU1500_MAC1_DMA_INT
),
415 static struct au1000_eth_platform_data au1xxx_eth1_platform_data
= {
416 .phy1_search_mac0
= 1,
419 static struct platform_device au1xxx_eth1_device
= {
420 .name
= "au1000-eth",
422 .num_resources
= ARRAY_SIZE(au1xxx_eth1_resources
),
423 .resource
= au1xxx_eth1_resources
,
424 .dev
.platform_data
= &au1xxx_eth1_platform_data
,
428 void __init
au1xxx_override_eth_cfg(unsigned int port
,
429 struct au1000_eth_platform_data
*eth_data
)
431 if (!eth_data
|| port
> 1)
435 memcpy(&au1xxx_eth0_platform_data
, eth_data
,
436 sizeof(struct au1000_eth_platform_data
));
437 #ifndef CONFIG_SOC_AU1100
439 memcpy(&au1xxx_eth1_platform_data
, eth_data
,
440 sizeof(struct au1000_eth_platform_data
));
444 static struct platform_device
*au1xxx_platform_devices
[] __initdata
= {
446 &au1xxx_usb_ohci_device
,
447 #ifdef CONFIG_FB_AU1100
450 #ifdef CONFIG_SOC_AU1200
451 &au1xxx_usb_ehci_device
,
452 &au1xxx_usb_gdt_device
,
453 &au1xxx_usb_otg_device
,
456 #ifndef CONFIG_MIPS_DB1200
460 #ifdef SMBUS_PSC_BASE
466 static int __init
au1xxx_platform_init(void)
468 unsigned int uartclk
= get_au1x00_uart_baud_base() * 16;
470 unsigned char ethaddr
[6];
472 /* Fill up uartclk. */
473 for (i
= 0; au1x00_uart_data
[i
].flags
; i
++)
474 au1x00_uart_data
[i
].uartclk
= uartclk
;
476 /* use firmware-provided mac addr if available and necessary */
477 i
= prom_get_ethernet_addr(ethaddr
);
478 if (!i
&& !is_valid_ether_addr(au1xxx_eth0_platform_data
.mac
))
479 memcpy(au1xxx_eth0_platform_data
.mac
, ethaddr
, 6);
481 err
= platform_add_devices(au1xxx_platform_devices
,
482 ARRAY_SIZE(au1xxx_platform_devices
));
483 #ifndef CONFIG_SOC_AU1100
484 ethaddr
[5] += 1; /* next addr for 2nd MAC */
485 if (!i
&& !is_valid_ether_addr(au1xxx_eth1_platform_data
.mac
))
486 memcpy(au1xxx_eth1_platform_data
.mac
, ethaddr
, 6);
488 /* Register second MAC if enabled in pinfunc */
489 if (!err
&& !(au_readl(SYS_PINFUNC
) & (u32
)SYS_PF_NI2
))
490 err
= platform_device_register(&au1xxx_eth1_device
);
496 arch_initcall(au1xxx_platform_init
);