blob: 3691630931d6100ae901d8adbddcc6ccb6cf960e [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Platform device support for Au1x00 SoCs.
3 *
4 * Copyright 2004, Matt Porter <mporter@kernel.crashing.org>
5 *
Sergei Shtylyov6e766452008-04-04 00:02:53 +04006 * (C) Copyright Embedded Alley Solutions, Inc 2005
7 * Author: Pantelis Antoniou <pantelis@embeddedalley.com>
8 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07009 * 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.
12 */
Sergei Shtylyovce28f942008-04-23 22:43:55 +040013
Ralf Baechle4b622202008-07-15 18:44:29 +010014#include <linux/dma-mapping.h>
Manuel Laussf6673652010-07-21 14:30:50 +020015#include <linux/etherdevice.h>
Russell Kingd052d1b2005-10-29 19:07:23 +010016#include <linux/platform_device.h>
Sergei Shtylyov6e766452008-04-04 00:02:53 +040017#include <linux/serial_8250.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070018#include <linux/init.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070019
Pete Popov26a940e2005-09-15 08:03:12 +000020#include <asm/mach-au1x00/au1xxx.h>
Manuel Laussf591eb12008-10-21 08:59:14 +020021#include <asm/mach-au1x00/au1xxx_dbdma.h>
22#include <asm/mach-au1x00/au1100_mmc.h>
Florian Fainelli66f75cc2009-11-10 01:13:30 +010023#include <asm/mach-au1x00/au1xxx_eth.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070024
Manuel Laussf6673652010-07-21 14:30:50 +020025#include <prom.h>
26
Manuel Lauss7d172bf2010-09-25 15:13:46 +020027static void alchemy_8250_pm(struct uart_port *port, unsigned int state,
28 unsigned int old_state)
29{
30 switch (state) {
31 case 0:
32 if ((__raw_readl(port->membase + UART_MOD_CNTRL) & 3) != 3) {
33 /* power-on sequence as suggested in the databooks */
34 __raw_writel(0, port->membase + UART_MOD_CNTRL);
35 wmb();
36 __raw_writel(1, port->membase + UART_MOD_CNTRL);
37 wmb();
38 }
39 __raw_writel(3, port->membase + UART_MOD_CNTRL); /* full on */
40 wmb();
41 serial8250_do_pm(port, state, old_state);
42 break;
43 case 3: /* power off */
44 serial8250_do_pm(port, state, old_state);
45 __raw_writel(0, port->membase + UART_MOD_CNTRL);
46 wmb();
47 break;
48 default:
49 serial8250_do_pm(port, state, old_state);
50 break;
51 }
52}
53
Manuel Laussb6e6d122009-10-15 19:07:34 +020054#define PORT(_base, _irq) \
55 { \
56 .mapbase = _base, \
57 .irq = _irq, \
58 .regshift = 2, \
59 .iotype = UPIO_AU, \
Manuel Lauss63ea3362009-10-28 21:49:46 +010060 .flags = UPF_SKIP_TEST | UPF_IOREMAP | \
61 UPF_FIXED_TYPE, \
62 .type = PORT_16550A, \
Manuel Lauss7d172bf2010-09-25 15:13:46 +020063 .pm = alchemy_8250_pm, \
Sergei Shtylyov6e766452008-04-04 00:02:53 +040064 }
65
66static struct plat_serial8250_port au1x00_uart_data[] = {
Sergei Shtylyov6e766452008-04-04 00:02:53 +040067#if defined(CONFIG_SOC_AU1000)
Manuel Laussb6e6d122009-10-15 19:07:34 +020068 PORT(UART0_PHYS_ADDR, AU1000_UART0_INT),
69 PORT(UART1_PHYS_ADDR, AU1000_UART1_INT),
70 PORT(UART2_PHYS_ADDR, AU1000_UART2_INT),
71 PORT(UART3_PHYS_ADDR, AU1000_UART3_INT),
Sergei Shtylyov6e766452008-04-04 00:02:53 +040072#elif defined(CONFIG_SOC_AU1500)
Manuel Laussb6e6d122009-10-15 19:07:34 +020073 PORT(UART0_PHYS_ADDR, AU1500_UART0_INT),
74 PORT(UART3_PHYS_ADDR, AU1500_UART3_INT),
Sergei Shtylyov6e766452008-04-04 00:02:53 +040075#elif defined(CONFIG_SOC_AU1100)
Manuel Laussb6e6d122009-10-15 19:07:34 +020076 PORT(UART0_PHYS_ADDR, AU1100_UART0_INT),
77 PORT(UART1_PHYS_ADDR, AU1100_UART1_INT),
78 PORT(UART3_PHYS_ADDR, AU1100_UART3_INT),
Sergei Shtylyov6e766452008-04-04 00:02:53 +040079#elif defined(CONFIG_SOC_AU1550)
Manuel Laussb6e6d122009-10-15 19:07:34 +020080 PORT(UART0_PHYS_ADDR, AU1550_UART0_INT),
81 PORT(UART1_PHYS_ADDR, AU1550_UART1_INT),
82 PORT(UART3_PHYS_ADDR, AU1550_UART3_INT),
Sergei Shtylyov6e766452008-04-04 00:02:53 +040083#elif defined(CONFIG_SOC_AU1200)
Manuel Laussb6e6d122009-10-15 19:07:34 +020084 PORT(UART0_PHYS_ADDR, AU1200_UART0_INT),
85 PORT(UART1_PHYS_ADDR, AU1200_UART1_INT),
Sergei Shtylyov6e766452008-04-04 00:02:53 +040086#endif
Sergei Shtylyov6e766452008-04-04 00:02:53 +040087 { },
88};
89
90static struct platform_device au1xx0_uart_device = {
91 .name = "serial8250",
92 .id = PLAT8250_DEV_AU1X00,
93 .dev = {
94 .platform_data = au1x00_uart_data,
95 },
96};
97
Pete Popov64abf642005-09-14 16:17:59 +000098/* OHCI (USB full speed host controller) */
Linus Torvalds1da177e2005-04-16 15:20:36 -070099static struct resource au1xxx_usb_ohci_resources[] = {
100 [0] = {
101 .start = USB_OHCI_BASE,
Jordan Croused5fb7f12006-01-20 14:09:54 -0800102 .end = USB_OHCI_BASE + USB_OHCI_LEN - 1,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700103 .flags = IORESOURCE_MEM,
104 },
105 [1] = {
Manuel Lauss78814462009-10-07 20:15:15 +0200106 .start = FOR_PLATFORM_C_USB_HOST_INT,
107 .end = FOR_PLATFORM_C_USB_HOST_INT,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700108 .flags = IORESOURCE_IRQ,
109 },
110};
111
112/* The dmamask must be set for OHCI to work */
Yang Hongyang284901a2009-04-06 19:01:15 -0700113static u64 ohci_dmamask = DMA_BIT_MASK(32);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700114
115static struct platform_device au1xxx_usb_ohci_device = {
116 .name = "au1xxx-ohci",
117 .id = 0,
118 .dev = {
119 .dma_mask = &ohci_dmamask,
Yang Hongyang284901a2009-04-06 19:01:15 -0700120 .coherent_dma_mask = DMA_BIT_MASK(32),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700121 },
122 .num_resources = ARRAY_SIZE(au1xxx_usb_ohci_resources),
123 .resource = au1xxx_usb_ohci_resources,
124};
125
Pete Popov3b495f22005-04-04 01:06:19 +0000126/*** AU1100 LCD controller ***/
127
128#ifdef CONFIG_FB_AU1100
129static struct resource au1100_lcd_resources[] = {
130 [0] = {
131 .start = LCD_PHYS_ADDR,
132 .end = LCD_PHYS_ADDR + 0x800 - 1,
133 .flags = IORESOURCE_MEM,
134 },
135 [1] = {
136 .start = AU1100_LCD_INT,
137 .end = AU1100_LCD_INT,
138 .flags = IORESOURCE_IRQ,
139 }
140};
141
Yang Hongyang284901a2009-04-06 19:01:15 -0700142static u64 au1100_lcd_dmamask = DMA_BIT_MASK(32);
Pete Popov3b495f22005-04-04 01:06:19 +0000143
144static struct platform_device au1100_lcd_device = {
145 .name = "au1100-lcd",
146 .id = 0,
147 .dev = {
148 .dma_mask = &au1100_lcd_dmamask,
Yang Hongyang284901a2009-04-06 19:01:15 -0700149 .coherent_dma_mask = DMA_BIT_MASK(32),
Pete Popov3b495f22005-04-04 01:06:19 +0000150 },
151 .num_resources = ARRAY_SIZE(au1100_lcd_resources),
152 .resource = au1100_lcd_resources,
153};
154#endif
155
Pete Popov64abf642005-09-14 16:17:59 +0000156#ifdef CONFIG_SOC_AU1200
157/* EHCI (USB high speed host controller) */
158static struct resource au1xxx_usb_ehci_resources[] = {
159 [0] = {
160 .start = USB_EHCI_BASE,
161 .end = USB_EHCI_BASE + USB_EHCI_LEN - 1,
162 .flags = IORESOURCE_MEM,
163 },
164 [1] = {
Manuel Lauss78814462009-10-07 20:15:15 +0200165 .start = AU1200_USB_INT,
166 .end = AU1200_USB_INT,
Pete Popov64abf642005-09-14 16:17:59 +0000167 .flags = IORESOURCE_IRQ,
168 },
169};
170
Yang Hongyang284901a2009-04-06 19:01:15 -0700171static u64 ehci_dmamask = DMA_BIT_MASK(32);
Pete Popov64abf642005-09-14 16:17:59 +0000172
173static struct platform_device au1xxx_usb_ehci_device = {
174 .name = "au1xxx-ehci",
175 .id = 0,
176 .dev = {
177 .dma_mask = &ehci_dmamask,
Yang Hongyang284901a2009-04-06 19:01:15 -0700178 .coherent_dma_mask = DMA_BIT_MASK(32),
Pete Popov64abf642005-09-14 16:17:59 +0000179 },
180 .num_resources = ARRAY_SIZE(au1xxx_usb_ehci_resources),
181 .resource = au1xxx_usb_ehci_resources,
182};
183
184/* Au1200 UDC (USB gadget controller) */
185static struct resource au1xxx_usb_gdt_resources[] = {
186 [0] = {
187 .start = USB_UDC_BASE,
188 .end = USB_UDC_BASE + USB_UDC_LEN - 1,
189 .flags = IORESOURCE_MEM,
190 },
191 [1] = {
192 .start = AU1200_USB_INT,
193 .end = AU1200_USB_INT,
194 .flags = IORESOURCE_IRQ,
195 },
196};
197
Yang Hongyang284901a2009-04-06 19:01:15 -0700198static u64 udc_dmamask = DMA_BIT_MASK(32);
Pete Popov64abf642005-09-14 16:17:59 +0000199
200static struct platform_device au1xxx_usb_gdt_device = {
201 .name = "au1xxx-udc",
202 .id = 0,
203 .dev = {
204 .dma_mask = &udc_dmamask,
Yang Hongyang284901a2009-04-06 19:01:15 -0700205 .coherent_dma_mask = DMA_BIT_MASK(32),
Pete Popov64abf642005-09-14 16:17:59 +0000206 },
207 .num_resources = ARRAY_SIZE(au1xxx_usb_gdt_resources),
208 .resource = au1xxx_usb_gdt_resources,
209};
210
211/* Au1200 UOC (USB OTG controller) */
212static struct resource au1xxx_usb_otg_resources[] = {
213 [0] = {
214 .start = USB_UOC_BASE,
215 .end = USB_UOC_BASE + USB_UOC_LEN - 1,
216 .flags = IORESOURCE_MEM,
217 },
218 [1] = {
219 .start = AU1200_USB_INT,
220 .end = AU1200_USB_INT,
221 .flags = IORESOURCE_IRQ,
222 },
223};
224
Yang Hongyang284901a2009-04-06 19:01:15 -0700225static u64 uoc_dmamask = DMA_BIT_MASK(32);
Pete Popov64abf642005-09-14 16:17:59 +0000226
227static struct platform_device au1xxx_usb_otg_device = {
228 .name = "au1xxx-uoc",
229 .id = 0,
230 .dev = {
231 .dma_mask = &uoc_dmamask,
Yang Hongyang284901a2009-04-06 19:01:15 -0700232 .coherent_dma_mask = DMA_BIT_MASK(32),
Pete Popov64abf642005-09-14 16:17:59 +0000233 },
234 .num_resources = ARRAY_SIZE(au1xxx_usb_otg_resources),
235 .resource = au1xxx_usb_otg_resources,
236};
237
Pete Popov64abf642005-09-14 16:17:59 +0000238static struct resource au1200_lcd_resources[] = {
239 [0] = {
240 .start = LCD_PHYS_ADDR,
241 .end = LCD_PHYS_ADDR + 0x800 - 1,
242 .flags = IORESOURCE_MEM,
243 },
244 [1] = {
245 .start = AU1200_LCD_INT,
246 .end = AU1200_LCD_INT,
247 .flags = IORESOURCE_IRQ,
248 }
249};
250
Yang Hongyang284901a2009-04-06 19:01:15 -0700251static u64 au1200_lcd_dmamask = DMA_BIT_MASK(32);
Pete Popov64abf642005-09-14 16:17:59 +0000252
253static struct platform_device au1200_lcd_device = {
254 .name = "au1200-lcd",
255 .id = 0,
256 .dev = {
257 .dma_mask = &au1200_lcd_dmamask,
Yang Hongyang284901a2009-04-06 19:01:15 -0700258 .coherent_dma_mask = DMA_BIT_MASK(32),
Pete Popov64abf642005-09-14 16:17:59 +0000259 },
260 .num_resources = ARRAY_SIZE(au1200_lcd_resources),
261 .resource = au1200_lcd_resources,
262};
Pete Popov26a940e2005-09-15 08:03:12 +0000263
Yang Hongyang284901a2009-04-06 19:01:15 -0700264static u64 au1xxx_mmc_dmamask = DMA_BIT_MASK(32);
Pete Popovba264b32005-09-21 06:18:27 +0000265
Manuel Laussf591eb12008-10-21 08:59:14 +0200266extern struct au1xmmc_platform_data au1xmmc_platdata[2];
267
268static struct resource au1200_mmc0_resources[] = {
269 [0] = {
270 .start = SD0_PHYS_ADDR,
271 .end = SD0_PHYS_ADDR + 0x7ffff,
272 .flags = IORESOURCE_MEM,
273 },
274 [1] = {
275 .start = AU1200_SD_INT,
276 .end = AU1200_SD_INT,
277 .flags = IORESOURCE_IRQ,
278 },
279 [2] = {
280 .start = DSCR_CMD0_SDMS_TX0,
281 .end = DSCR_CMD0_SDMS_TX0,
282 .flags = IORESOURCE_DMA,
283 },
284 [3] = {
285 .start = DSCR_CMD0_SDMS_RX0,
286 .end = DSCR_CMD0_SDMS_RX0,
287 .flags = IORESOURCE_DMA,
288 }
289};
290
291static struct platform_device au1200_mmc0_device = {
Pete Popovba264b32005-09-21 06:18:27 +0000292 .name = "au1xxx-mmc",
293 .id = 0,
294 .dev = {
Manuel Laussf591eb12008-10-21 08:59:14 +0200295 .dma_mask = &au1xxx_mmc_dmamask,
Yang Hongyang284901a2009-04-06 19:01:15 -0700296 .coherent_dma_mask = DMA_BIT_MASK(32),
Manuel Laussf591eb12008-10-21 08:59:14 +0200297 .platform_data = &au1xmmc_platdata[0],
Pete Popovba264b32005-09-21 06:18:27 +0000298 },
Manuel Laussf591eb12008-10-21 08:59:14 +0200299 .num_resources = ARRAY_SIZE(au1200_mmc0_resources),
300 .resource = au1200_mmc0_resources,
Pete Popovba264b32005-09-21 06:18:27 +0000301};
Manuel Laussf591eb12008-10-21 08:59:14 +0200302
303#ifndef CONFIG_MIPS_DB1200
304static struct resource au1200_mmc1_resources[] = {
305 [0] = {
306 .start = SD1_PHYS_ADDR,
307 .end = SD1_PHYS_ADDR + 0x7ffff,
308 .flags = IORESOURCE_MEM,
309 },
310 [1] = {
311 .start = AU1200_SD_INT,
312 .end = AU1200_SD_INT,
313 .flags = IORESOURCE_IRQ,
314 },
315 [2] = {
316 .start = DSCR_CMD0_SDMS_TX1,
317 .end = DSCR_CMD0_SDMS_TX1,
318 .flags = IORESOURCE_DMA,
319 },
320 [3] = {
321 .start = DSCR_CMD0_SDMS_RX1,
322 .end = DSCR_CMD0_SDMS_RX1,
323 .flags = IORESOURCE_DMA,
324 }
325};
326
327static struct platform_device au1200_mmc1_device = {
328 .name = "au1xxx-mmc",
329 .id = 1,
330 .dev = {
331 .dma_mask = &au1xxx_mmc_dmamask,
Yang Hongyang284901a2009-04-06 19:01:15 -0700332 .coherent_dma_mask = DMA_BIT_MASK(32),
Manuel Laussf591eb12008-10-21 08:59:14 +0200333 .platform_data = &au1xmmc_platdata[1],
334 },
335 .num_resources = ARRAY_SIZE(au1200_mmc1_resources),
336 .resource = au1200_mmc1_resources,
337};
338#endif /* #ifndef CONFIG_MIPS_DB1200 */
Pete Popovba264b32005-09-21 06:18:27 +0000339#endif /* #ifdef CONFIG_SOC_AU1200 */
340
Manuel Lauss8b798c42008-01-27 18:14:52 +0100341/* All Alchemy demoboards with I2C have this #define in their headers */
342#ifdef SMBUS_PSC_BASE
343static struct resource pbdb_smbus_resources[] = {
344 {
Sergei Shtylyov8e07c2c2008-04-05 22:16:21 +0400345 .start = CPHYSADDR(SMBUS_PSC_BASE),
346 .end = CPHYSADDR(SMBUS_PSC_BASE + 0xfffff),
Manuel Lauss8b798c42008-01-27 18:14:52 +0100347 .flags = IORESOURCE_MEM,
348 },
349};
350
351static struct platform_device pbdb_smbus_device = {
352 .name = "au1xpsc_smbus",
353 .id = 0, /* bus number */
354 .num_resources = ARRAY_SIZE(pbdb_smbus_resources),
355 .resource = pbdb_smbus_resources,
356};
357#endif
358
Florian Fainelli66f75cc2009-11-10 01:13:30 +0100359/* Macro to help defining the Ethernet MAC resources */
360#define MAC_RES(_base, _enable, _irq) \
361 { \
362 .start = CPHYSADDR(_base), \
363 .end = CPHYSADDR(_base + 0xffff), \
364 .flags = IORESOURCE_MEM, \
365 }, \
366 { \
367 .start = CPHYSADDR(_enable), \
368 .end = CPHYSADDR(_enable + 0x3), \
369 .flags = IORESOURCE_MEM, \
370 }, \
371 { \
372 .start = _irq, \
373 .end = _irq, \
374 .flags = IORESOURCE_IRQ \
375 }
376
377static struct resource au1xxx_eth0_resources[] = {
378#if defined(CONFIG_SOC_AU1000)
379 MAC_RES(AU1000_ETH0_BASE, AU1000_MAC0_ENABLE, AU1000_MAC0_DMA_INT),
380#elif defined(CONFIG_SOC_AU1100)
381 MAC_RES(AU1100_ETH0_BASE, AU1100_MAC0_ENABLE, AU1100_MAC0_DMA_INT),
382#elif defined(CONFIG_SOC_AU1550)
383 MAC_RES(AU1550_ETH0_BASE, AU1550_MAC0_ENABLE, AU1550_MAC0_DMA_INT),
384#elif defined(CONFIG_SOC_AU1500)
385 MAC_RES(AU1500_ETH0_BASE, AU1500_MAC0_ENABLE, AU1500_MAC0_DMA_INT),
386#endif
387};
388
Florian Fainelli66f75cc2009-11-10 01:13:30 +0100389
390static struct au1000_eth_platform_data au1xxx_eth0_platform_data = {
391 .phy1_search_mac0 = 1,
392};
393
394static struct platform_device au1xxx_eth0_device = {
395 .name = "au1000-eth",
396 .id = 0,
397 .num_resources = ARRAY_SIZE(au1xxx_eth0_resources),
398 .resource = au1xxx_eth0_resources,
399 .dev.platform_data = &au1xxx_eth0_platform_data,
400};
401
402#ifndef CONFIG_SOC_AU1100
Manuel Laussacc4d242010-02-26 17:22:02 +0100403static struct resource au1xxx_eth1_resources[] = {
404#if defined(CONFIG_SOC_AU1000)
405 MAC_RES(AU1000_ETH1_BASE, AU1000_MAC1_ENABLE, AU1000_MAC1_DMA_INT),
406#elif defined(CONFIG_SOC_AU1550)
407 MAC_RES(AU1550_ETH1_BASE, AU1550_MAC1_ENABLE, AU1550_MAC1_DMA_INT),
408#elif defined(CONFIG_SOC_AU1500)
409 MAC_RES(AU1500_ETH1_BASE, AU1500_MAC1_ENABLE, AU1500_MAC1_DMA_INT),
410#endif
411};
412
Florian Fainelli66f75cc2009-11-10 01:13:30 +0100413static struct au1000_eth_platform_data au1xxx_eth1_platform_data = {
414 .phy1_search_mac0 = 1,
415};
416
417static struct platform_device au1xxx_eth1_device = {
418 .name = "au1000-eth",
419 .id = 1,
420 .num_resources = ARRAY_SIZE(au1xxx_eth1_resources),
421 .resource = au1xxx_eth1_resources,
422 .dev.platform_data = &au1xxx_eth1_platform_data,
423};
424#endif
425
426void __init au1xxx_override_eth_cfg(unsigned int port,
427 struct au1000_eth_platform_data *eth_data)
428{
429 if (!eth_data || port > 1)
430 return;
431
432 if (port == 0)
433 memcpy(&au1xxx_eth0_platform_data, eth_data,
434 sizeof(struct au1000_eth_platform_data));
435#ifndef CONFIG_SOC_AU1100
436 else
437 memcpy(&au1xxx_eth1_platform_data, eth_data,
438 sizeof(struct au1000_eth_platform_data));
439#endif
440}
441
Linus Torvalds1da177e2005-04-16 15:20:36 -0700442static struct platform_device *au1xxx_platform_devices[] __initdata = {
Sergei Shtylyov6e766452008-04-04 00:02:53 +0400443 &au1xx0_uart_device,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700444 &au1xxx_usb_ohci_device,
Pete Popov3b495f22005-04-04 01:06:19 +0000445#ifdef CONFIG_FB_AU1100
446 &au1100_lcd_device,
447#endif
Pete Popov64abf642005-09-14 16:17:59 +0000448#ifdef CONFIG_SOC_AU1200
Pete Popov64abf642005-09-14 16:17:59 +0000449 &au1xxx_usb_ehci_device,
Pete Popov64abf642005-09-14 16:17:59 +0000450 &au1xxx_usb_gdt_device,
451 &au1xxx_usb_otg_device,
452 &au1200_lcd_device,
Manuel Laussf591eb12008-10-21 08:59:14 +0200453 &au1200_mmc0_device,
454#ifndef CONFIG_MIPS_DB1200
455 &au1200_mmc1_device,
456#endif
Pete Popov64abf642005-09-14 16:17:59 +0000457#endif
Manuel Lauss8b798c42008-01-27 18:14:52 +0100458#ifdef SMBUS_PSC_BASE
459 &pbdb_smbus_device,
460#endif
Florian Fainelli66f75cc2009-11-10 01:13:30 +0100461 &au1xxx_eth0_device,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700462};
463
Sergei Shtylyovc1dcb142008-04-30 23:18:41 +0400464static int __init au1xxx_platform_init(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700465{
Sergei Shtylyov6e766452008-04-04 00:02:53 +0400466 unsigned int uartclk = get_au1x00_uart_baud_base() * 16;
Wolfgang Grandegger0d5977d2010-07-17 16:38:48 +0200467 int err, i;
Manuel Laussf6673652010-07-21 14:30:50 +0200468 unsigned char ethaddr[6];
Sergei Shtylyov6e766452008-04-04 00:02:53 +0400469
470 /* Fill up uartclk. */
Sergei Shtylyovc1dcb142008-04-30 23:18:41 +0400471 for (i = 0; au1x00_uart_data[i].flags; i++)
Sergei Shtylyov6e766452008-04-04 00:02:53 +0400472 au1x00_uart_data[i].uartclk = uartclk;
473
Manuel Laussf6673652010-07-21 14:30:50 +0200474 /* use firmware-provided mac addr if available and necessary */
475 i = prom_get_ethernet_addr(ethaddr);
476 if (!i && !is_valid_ether_addr(au1xxx_eth0_platform_data.mac))
477 memcpy(au1xxx_eth0_platform_data.mac, ethaddr, 6);
478
Wolfgang Grandegger0d5977d2010-07-17 16:38:48 +0200479 err = platform_add_devices(au1xxx_platform_devices,
480 ARRAY_SIZE(au1xxx_platform_devices));
Florian Fainelli66f75cc2009-11-10 01:13:30 +0100481#ifndef CONFIG_SOC_AU1100
Manuel Laussf6673652010-07-21 14:30:50 +0200482 ethaddr[5] += 1; /* next addr for 2nd MAC */
483 if (!i && !is_valid_ether_addr(au1xxx_eth1_platform_data.mac))
484 memcpy(au1xxx_eth1_platform_data.mac, ethaddr, 6);
485
Florian Fainelli66f75cc2009-11-10 01:13:30 +0100486 /* Register second MAC if enabled in pinfunc */
Wolfgang Grandegger0d5977d2010-07-17 16:38:48 +0200487 if (!err && !(au_readl(SYS_PINFUNC) & (u32)SYS_PF_NI2))
Manuel Laussf6673652010-07-21 14:30:50 +0200488 err = platform_device_register(&au1xxx_eth1_device);
Florian Fainelli66f75cc2009-11-10 01:13:30 +0100489#endif
490
Wolfgang Grandegger0d5977d2010-07-17 16:38:48 +0200491 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700492}
493
494arch_initcall(au1xxx_platform_init);