blob: 7167972b1277d059f977c1b675b60c7f6c851f1b [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
Russell Kingd052d1b2005-10-29 19:07:23 +010014#include <linux/platform_device.h>
Sergei Shtylyov6e766452008-04-04 00:02:53 +040015#include <linux/serial_8250.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070016#include <linux/init.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070017
Pete Popov26a940e2005-09-15 08:03:12 +000018#include <asm/mach-au1x00/au1xxx.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070019
Sergei Shtylyov6e766452008-04-04 00:02:53 +040020#define PORT(_base, _irq) \
21 { \
22 .iobase = _base, \
23 .membase = (void __iomem *)_base,\
24 .mapbase = CPHYSADDR(_base), \
25 .irq = _irq, \
26 .regshift = 2, \
27 .iotype = UPIO_AU, \
28 .flags = UPF_SKIP_TEST \
29 }
30
31static struct plat_serial8250_port au1x00_uart_data[] = {
32#if defined(CONFIG_SERIAL_8250_AU1X00)
33#if defined(CONFIG_SOC_AU1000)
34 PORT(UART0_ADDR, AU1000_UART0_INT),
35 PORT(UART1_ADDR, AU1000_UART1_INT),
36 PORT(UART2_ADDR, AU1000_UART2_INT),
37 PORT(UART3_ADDR, AU1000_UART3_INT),
38#elif defined(CONFIG_SOC_AU1500)
39 PORT(UART0_ADDR, AU1500_UART0_INT),
40 PORT(UART3_ADDR, AU1500_UART3_INT),
41#elif defined(CONFIG_SOC_AU1100)
42 PORT(UART0_ADDR, AU1100_UART0_INT),
43 PORT(UART1_ADDR, AU1100_UART1_INT),
44 PORT(UART3_ADDR, AU1100_UART3_INT),
45#elif defined(CONFIG_SOC_AU1550)
46 PORT(UART0_ADDR, AU1550_UART0_INT),
47 PORT(UART1_ADDR, AU1550_UART1_INT),
48 PORT(UART3_ADDR, AU1550_UART3_INT),
49#elif defined(CONFIG_SOC_AU1200)
50 PORT(UART0_ADDR, AU1200_UART0_INT),
51 PORT(UART1_ADDR, AU1200_UART1_INT),
52#endif
53#endif /* CONFIG_SERIAL_8250_AU1X00 */
54 { },
55};
56
57static struct platform_device au1xx0_uart_device = {
58 .name = "serial8250",
59 .id = PLAT8250_DEV_AU1X00,
60 .dev = {
61 .platform_data = au1x00_uart_data,
62 },
63};
64
Pete Popov64abf642005-09-14 16:17:59 +000065/* OHCI (USB full speed host controller) */
Linus Torvalds1da177e2005-04-16 15:20:36 -070066static struct resource au1xxx_usb_ohci_resources[] = {
67 [0] = {
68 .start = USB_OHCI_BASE,
Jordan Croused5fb7f12006-01-20 14:09:54 -080069 .end = USB_OHCI_BASE + USB_OHCI_LEN - 1,
Linus Torvalds1da177e2005-04-16 15:20:36 -070070 .flags = IORESOURCE_MEM,
71 },
72 [1] = {
73 .start = AU1000_USB_HOST_INT,
74 .end = AU1000_USB_HOST_INT,
75 .flags = IORESOURCE_IRQ,
76 },
77};
78
79/* The dmamask must be set for OHCI to work */
80static u64 ohci_dmamask = ~(u32)0;
81
82static struct platform_device au1xxx_usb_ohci_device = {
83 .name = "au1xxx-ohci",
84 .id = 0,
85 .dev = {
86 .dma_mask = &ohci_dmamask,
87 .coherent_dma_mask = 0xffffffff,
88 },
89 .num_resources = ARRAY_SIZE(au1xxx_usb_ohci_resources),
90 .resource = au1xxx_usb_ohci_resources,
91};
92
Pete Popov3b495f22005-04-04 01:06:19 +000093/*** AU1100 LCD controller ***/
94
95#ifdef CONFIG_FB_AU1100
96static struct resource au1100_lcd_resources[] = {
97 [0] = {
98 .start = LCD_PHYS_ADDR,
99 .end = LCD_PHYS_ADDR + 0x800 - 1,
100 .flags = IORESOURCE_MEM,
101 },
102 [1] = {
103 .start = AU1100_LCD_INT,
104 .end = AU1100_LCD_INT,
105 .flags = IORESOURCE_IRQ,
106 }
107};
108
109static u64 au1100_lcd_dmamask = ~(u32)0;
110
111static struct platform_device au1100_lcd_device = {
112 .name = "au1100-lcd",
113 .id = 0,
114 .dev = {
115 .dma_mask = &au1100_lcd_dmamask,
116 .coherent_dma_mask = 0xffffffff,
117 },
118 .num_resources = ARRAY_SIZE(au1100_lcd_resources),
119 .resource = au1100_lcd_resources,
120};
121#endif
122
Pete Popov64abf642005-09-14 16:17:59 +0000123#ifdef CONFIG_SOC_AU1200
124/* EHCI (USB high speed host controller) */
125static struct resource au1xxx_usb_ehci_resources[] = {
126 [0] = {
127 .start = USB_EHCI_BASE,
128 .end = USB_EHCI_BASE + USB_EHCI_LEN - 1,
129 .flags = IORESOURCE_MEM,
130 },
131 [1] = {
132 .start = AU1000_USB_HOST_INT,
133 .end = AU1000_USB_HOST_INT,
134 .flags = IORESOURCE_IRQ,
135 },
136};
137
138static u64 ehci_dmamask = ~(u32)0;
139
140static struct platform_device au1xxx_usb_ehci_device = {
141 .name = "au1xxx-ehci",
142 .id = 0,
143 .dev = {
144 .dma_mask = &ehci_dmamask,
145 .coherent_dma_mask = 0xffffffff,
146 },
147 .num_resources = ARRAY_SIZE(au1xxx_usb_ehci_resources),
148 .resource = au1xxx_usb_ehci_resources,
149};
150
151/* Au1200 UDC (USB gadget controller) */
152static struct resource au1xxx_usb_gdt_resources[] = {
153 [0] = {
154 .start = USB_UDC_BASE,
155 .end = USB_UDC_BASE + USB_UDC_LEN - 1,
156 .flags = IORESOURCE_MEM,
157 },
158 [1] = {
159 .start = AU1200_USB_INT,
160 .end = AU1200_USB_INT,
161 .flags = IORESOURCE_IRQ,
162 },
163};
164
Pete Popovba264b32005-09-21 06:18:27 +0000165static struct resource au1xxx_mmc_resources[] = {
166 [0] = {
167 .start = SD0_PHYS_ADDR,
168 .end = SD0_PHYS_ADDR + 0x40,
169 .flags = IORESOURCE_MEM,
170 },
171 [1] = {
172 .start = SD1_PHYS_ADDR,
173 .end = SD1_PHYS_ADDR + 0x40,
174 .flags = IORESOURCE_MEM,
175 },
176 [2] = {
177 .start = AU1200_SD_INT,
178 .end = AU1200_SD_INT,
179 .flags = IORESOURCE_IRQ,
180 }
181};
182
Pete Popov64abf642005-09-14 16:17:59 +0000183static u64 udc_dmamask = ~(u32)0;
184
185static struct platform_device au1xxx_usb_gdt_device = {
186 .name = "au1xxx-udc",
187 .id = 0,
188 .dev = {
189 .dma_mask = &udc_dmamask,
190 .coherent_dma_mask = 0xffffffff,
191 },
192 .num_resources = ARRAY_SIZE(au1xxx_usb_gdt_resources),
193 .resource = au1xxx_usb_gdt_resources,
194};
195
196/* Au1200 UOC (USB OTG controller) */
197static struct resource au1xxx_usb_otg_resources[] = {
198 [0] = {
199 .start = USB_UOC_BASE,
200 .end = USB_UOC_BASE + USB_UOC_LEN - 1,
201 .flags = IORESOURCE_MEM,
202 },
203 [1] = {
204 .start = AU1200_USB_INT,
205 .end = AU1200_USB_INT,
206 .flags = IORESOURCE_IRQ,
207 },
208};
209
210static u64 uoc_dmamask = ~(u32)0;
211
212static struct platform_device au1xxx_usb_otg_device = {
213 .name = "au1xxx-uoc",
214 .id = 0,
215 .dev = {
216 .dma_mask = &uoc_dmamask,
217 .coherent_dma_mask = 0xffffffff,
218 },
219 .num_resources = ARRAY_SIZE(au1xxx_usb_otg_resources),
220 .resource = au1xxx_usb_otg_resources,
221};
222
Pete Popov64abf642005-09-14 16:17:59 +0000223static struct resource au1200_lcd_resources[] = {
224 [0] = {
225 .start = LCD_PHYS_ADDR,
226 .end = LCD_PHYS_ADDR + 0x800 - 1,
227 .flags = IORESOURCE_MEM,
228 },
229 [1] = {
230 .start = AU1200_LCD_INT,
231 .end = AU1200_LCD_INT,
232 .flags = IORESOURCE_IRQ,
233 }
234};
235
Pete Popov26a940e2005-09-15 08:03:12 +0000236static struct resource au1200_ide0_resources[] = {
237 [0] = {
238 .start = AU1XXX_ATA_PHYS_ADDR,
Sergei Shtylyovb4dcaea2008-04-17 01:14:33 +0200239 .end = AU1XXX_ATA_PHYS_ADDR + AU1XXX_ATA_PHYS_LEN - 1,
Pete Popov26a940e2005-09-15 08:03:12 +0000240 .flags = IORESOURCE_MEM,
241 },
242 [1] = {
243 .start = AU1XXX_ATA_INT,
244 .end = AU1XXX_ATA_INT,
245 .flags = IORESOURCE_IRQ,
246 }
247};
248
Pete Popov64abf642005-09-14 16:17:59 +0000249static u64 au1200_lcd_dmamask = ~(u32)0;
250
251static struct platform_device au1200_lcd_device = {
252 .name = "au1200-lcd",
253 .id = 0,
254 .dev = {
255 .dma_mask = &au1200_lcd_dmamask,
256 .coherent_dma_mask = 0xffffffff,
257 },
258 .num_resources = ARRAY_SIZE(au1200_lcd_resources),
259 .resource = au1200_lcd_resources,
260};
Pete Popov26a940e2005-09-15 08:03:12 +0000261
262
263static u64 ide0_dmamask = ~(u32)0;
264
265static struct platform_device au1200_ide0_device = {
266 .name = "au1200-ide",
267 .id = 0,
268 .dev = {
269 .dma_mask = &ide0_dmamask,
270 .coherent_dma_mask = 0xffffffff,
271 },
272 .num_resources = ARRAY_SIZE(au1200_ide0_resources),
273 .resource = au1200_ide0_resources,
274};
275
Pete Popovba264b32005-09-21 06:18:27 +0000276static u64 au1xxx_mmc_dmamask = ~(u32)0;
277
278static struct platform_device au1xxx_mmc_device = {
279 .name = "au1xxx-mmc",
280 .id = 0,
281 .dev = {
282 .dma_mask = &au1xxx_mmc_dmamask,
283 .coherent_dma_mask = 0xffffffff,
284 },
285 .num_resources = ARRAY_SIZE(au1xxx_mmc_resources),
286 .resource = au1xxx_mmc_resources,
287};
288#endif /* #ifdef CONFIG_SOC_AU1200 */
289
Pete Popovefe29c02005-09-15 23:42:27 +0000290static struct platform_device au1x00_pcmcia_device = {
291 .name = "au1x00-pcmcia",
292 .id = 0,
293};
294
Pete Popov0c9ec462005-09-21 21:39:44 +0000295#ifdef CONFIG_MIPS_DB1200
296
297static struct resource smc91x_resources[] = {
298 [0] = {
299 .name = "smc91x-regs",
300 .start = AU1XXX_SMC91111_PHYS_ADDR,
301 .end = AU1XXX_SMC91111_PHYS_ADDR + 0xfffff,
302 .flags = IORESOURCE_MEM,
303 },
304 [1] = {
305 .start = AU1XXX_SMC91111_IRQ,
306 .end = AU1XXX_SMC91111_IRQ,
307 .flags = IORESOURCE_IRQ,
308 },
309};
310
311static struct platform_device smc91x_device = {
312 .name = "smc91x",
Ralf Baechlea3dddd52006-03-11 08:18:41 +0000313 .id = -1,
Pete Popov0c9ec462005-09-21 21:39:44 +0000314 .num_resources = ARRAY_SIZE(smc91x_resources),
315 .resource = smc91x_resources,
316};
317
318#endif
319
Manuel Lauss8b798c42008-01-27 18:14:52 +0100320/* All Alchemy demoboards with I2C have this #define in their headers */
321#ifdef SMBUS_PSC_BASE
322static struct resource pbdb_smbus_resources[] = {
323 {
324 .start = SMBUS_PSC_BASE,
325 .end = SMBUS_PSC_BASE + 0x24 - 1,
326 .flags = IORESOURCE_MEM,
327 },
328};
329
330static struct platform_device pbdb_smbus_device = {
331 .name = "au1xpsc_smbus",
332 .id = 0, /* bus number */
333 .num_resources = ARRAY_SIZE(pbdb_smbus_resources),
334 .resource = pbdb_smbus_resources,
335};
336#endif
337
Linus Torvalds1da177e2005-04-16 15:20:36 -0700338static struct platform_device *au1xxx_platform_devices[] __initdata = {
Sergei Shtylyov6e766452008-04-04 00:02:53 +0400339 &au1xx0_uart_device,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700340 &au1xxx_usb_ohci_device,
Pete Popovefe29c02005-09-15 23:42:27 +0000341 &au1x00_pcmcia_device,
Pete Popov3b495f22005-04-04 01:06:19 +0000342#ifdef CONFIG_FB_AU1100
343 &au1100_lcd_device,
344#endif
Pete Popov64abf642005-09-14 16:17:59 +0000345#ifdef CONFIG_SOC_AU1200
Pete Popov64abf642005-09-14 16:17:59 +0000346 &au1xxx_usb_ehci_device,
Pete Popov64abf642005-09-14 16:17:59 +0000347 &au1xxx_usb_gdt_device,
348 &au1xxx_usb_otg_device,
349 &au1200_lcd_device,
Pete Popov26a940e2005-09-15 08:03:12 +0000350 &au1200_ide0_device,
Pete Popovba264b32005-09-21 06:18:27 +0000351 &au1xxx_mmc_device,
Pete Popov64abf642005-09-14 16:17:59 +0000352#endif
Pete Popov0c9ec462005-09-21 21:39:44 +0000353#ifdef CONFIG_MIPS_DB1200
Ralf Baechlea3dddd52006-03-11 08:18:41 +0000354 &smc91x_device,
Pete Popov0c9ec462005-09-21 21:39:44 +0000355#endif
Manuel Lauss8b798c42008-01-27 18:14:52 +0100356#ifdef SMBUS_PSC_BASE
357 &pbdb_smbus_device,
358#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700359};
360
Ralf Baechle070c7b82007-07-10 09:35:12 +0100361int __init au1xxx_platform_init(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700362{
Sergei Shtylyov6e766452008-04-04 00:02:53 +0400363 unsigned int uartclk = get_au1x00_uart_baud_base() * 16;
364 int i;
365
366 /* Fill up uartclk. */
367 for (i = 0; au1x00_uart_data[i].flags ; i++)
368 au1x00_uart_data[i].uartclk = uartclk;
369
Linus Torvalds1da177e2005-04-16 15:20:36 -0700370 return platform_add_devices(au1xxx_platform_devices, ARRAY_SIZE(au1xxx_platform_devices));
371}
372
373arch_initcall(au1xxx_platform_init);