Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Platform device support for Au1x00 SoCs. |
| 3 | * |
| 4 | * Copyright 2004, Matt Porter <mporter@kernel.crashing.org> |
| 5 | * |
Sergei Shtylyov | 6e76645 | 2008-04-04 00:02:53 +0400 | [diff] [blame] | 6 | * (C) Copyright Embedded Alley Solutions, Inc 2005 |
| 7 | * Author: Pantelis Antoniou <pantelis@embeddedalley.com> |
| 8 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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. |
| 12 | */ |
Sergei Shtylyov | ce28f94 | 2008-04-23 22:43:55 +0400 | [diff] [blame] | 13 | |
Ralf Baechle | 4b62220 | 2008-07-15 18:44:29 +0100 | [diff] [blame] | 14 | #include <linux/dma-mapping.h> |
Manuel Lauss | f667365 | 2010-07-21 14:30:50 +0200 | [diff] [blame] | 15 | #include <linux/etherdevice.h> |
Manuel Lauss | 40d8bc2 | 2011-05-08 10:42:18 +0200 | [diff] [blame] | 16 | #include <linux/init.h> |
Russell King | d052d1b | 2005-10-29 19:07:23 +0100 | [diff] [blame] | 17 | #include <linux/platform_device.h> |
Sergei Shtylyov | 6e76645 | 2008-04-04 00:02:53 +0400 | [diff] [blame] | 18 | #include <linux/serial_8250.h> |
Manuel Lauss | 40d8bc2 | 2011-05-08 10:42:18 +0200 | [diff] [blame] | 19 | #include <linux/slab.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 20 | |
Pete Popov | 26a940e | 2005-09-15 08:03:12 +0000 | [diff] [blame] | 21 | #include <asm/mach-au1x00/au1xxx.h> |
Manuel Lauss | f591eb1 | 2008-10-21 08:59:14 +0200 | [diff] [blame] | 22 | #include <asm/mach-au1x00/au1xxx_dbdma.h> |
| 23 | #include <asm/mach-au1x00/au1100_mmc.h> |
Florian Fainelli | 66f75cc | 2009-11-10 01:13:30 +0100 | [diff] [blame] | 24 | #include <asm/mach-au1x00/au1xxx_eth.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 | |
Manuel Lauss | f667365 | 2010-07-21 14:30:50 +0200 | [diff] [blame] | 26 | #include <prom.h> |
| 27 | |
Manuel Lauss | 7d172bf | 2010-09-25 15:13:46 +0200 | [diff] [blame] | 28 | static void alchemy_8250_pm(struct uart_port *port, unsigned int state, |
| 29 | unsigned int old_state) |
| 30 | { |
Manuel Lauss | cf745a3 | 2010-10-25 18:44:11 +0200 | [diff] [blame] | 31 | #ifdef CONFIG_SERIAL_8250 |
Manuel Lauss | 7d172bf | 2010-09-25 15:13:46 +0200 | [diff] [blame] | 32 | switch (state) { |
| 33 | case 0: |
Manuel Lauss | 8013020 | 2011-05-08 10:42:17 +0200 | [diff] [blame] | 34 | alchemy_uart_enable(CPHYSADDR(port->membase)); |
Manuel Lauss | 7d172bf | 2010-09-25 15:13:46 +0200 | [diff] [blame] | 35 | serial8250_do_pm(port, state, old_state); |
| 36 | break; |
| 37 | case 3: /* power off */ |
| 38 | serial8250_do_pm(port, state, old_state); |
Manuel Lauss | 8013020 | 2011-05-08 10:42:17 +0200 | [diff] [blame] | 39 | alchemy_uart_disable(CPHYSADDR(port->membase)); |
Manuel Lauss | 7d172bf | 2010-09-25 15:13:46 +0200 | [diff] [blame] | 40 | break; |
| 41 | default: |
| 42 | serial8250_do_pm(port, state, old_state); |
| 43 | break; |
| 44 | } |
Manuel Lauss | cf745a3 | 2010-10-25 18:44:11 +0200 | [diff] [blame] | 45 | #endif |
Manuel Lauss | 7d172bf | 2010-09-25 15:13:46 +0200 | [diff] [blame] | 46 | } |
| 47 | |
Manuel Lauss | b6e6d12 | 2009-10-15 19:07:34 +0200 | [diff] [blame] | 48 | #define PORT(_base, _irq) \ |
| 49 | { \ |
| 50 | .mapbase = _base, \ |
| 51 | .irq = _irq, \ |
| 52 | .regshift = 2, \ |
| 53 | .iotype = UPIO_AU, \ |
Manuel Lauss | 63ea336 | 2009-10-28 21:49:46 +0100 | [diff] [blame] | 54 | .flags = UPF_SKIP_TEST | UPF_IOREMAP | \ |
| 55 | UPF_FIXED_TYPE, \ |
| 56 | .type = PORT_16550A, \ |
Manuel Lauss | 7d172bf | 2010-09-25 15:13:46 +0200 | [diff] [blame] | 57 | .pm = alchemy_8250_pm, \ |
Sergei Shtylyov | 6e76645 | 2008-04-04 00:02:53 +0400 | [diff] [blame] | 58 | } |
| 59 | |
Manuel Lauss | 8013020 | 2011-05-08 10:42:17 +0200 | [diff] [blame] | 60 | static struct plat_serial8250_port au1x00_uart_data[][4] __initdata = { |
| 61 | [ALCHEMY_CPU_AU1000] = { |
| 62 | PORT(AU1000_UART0_PHYS_ADDR, AU1000_UART0_INT), |
| 63 | PORT(AU1000_UART1_PHYS_ADDR, AU1000_UART1_INT), |
| 64 | PORT(AU1000_UART2_PHYS_ADDR, AU1000_UART2_INT), |
| 65 | PORT(AU1000_UART3_PHYS_ADDR, AU1000_UART3_INT), |
| 66 | }, |
| 67 | [ALCHEMY_CPU_AU1500] = { |
| 68 | PORT(AU1000_UART0_PHYS_ADDR, AU1500_UART0_INT), |
| 69 | PORT(AU1000_UART3_PHYS_ADDR, AU1500_UART3_INT), |
| 70 | }, |
| 71 | [ALCHEMY_CPU_AU1100] = { |
| 72 | PORT(AU1000_UART0_PHYS_ADDR, AU1100_UART0_INT), |
| 73 | PORT(AU1000_UART1_PHYS_ADDR, AU1100_UART1_INT), |
| 74 | PORT(AU1000_UART3_PHYS_ADDR, AU1100_UART3_INT), |
| 75 | }, |
| 76 | [ALCHEMY_CPU_AU1550] = { |
| 77 | PORT(AU1000_UART0_PHYS_ADDR, AU1550_UART0_INT), |
| 78 | PORT(AU1000_UART1_PHYS_ADDR, AU1550_UART1_INT), |
| 79 | PORT(AU1000_UART3_PHYS_ADDR, AU1550_UART3_INT), |
| 80 | }, |
| 81 | [ALCHEMY_CPU_AU1200] = { |
| 82 | PORT(AU1000_UART0_PHYS_ADDR, AU1200_UART0_INT), |
| 83 | PORT(AU1000_UART1_PHYS_ADDR, AU1200_UART1_INT), |
| 84 | }, |
Sergei Shtylyov | 6e76645 | 2008-04-04 00:02:53 +0400 | [diff] [blame] | 85 | }; |
| 86 | |
| 87 | static struct platform_device au1xx0_uart_device = { |
| 88 | .name = "serial8250", |
| 89 | .id = PLAT8250_DEV_AU1X00, |
Sergei Shtylyov | 6e76645 | 2008-04-04 00:02:53 +0400 | [diff] [blame] | 90 | }; |
| 91 | |
Manuel Lauss | 8013020 | 2011-05-08 10:42:17 +0200 | [diff] [blame] | 92 | static void __init alchemy_setup_uarts(int ctype) |
| 93 | { |
| 94 | unsigned int uartclk = get_au1x00_uart_baud_base() * 16; |
| 95 | int s = sizeof(struct plat_serial8250_port); |
| 96 | int c = alchemy_get_uarts(ctype); |
| 97 | struct plat_serial8250_port *ports; |
| 98 | |
| 99 | ports = kzalloc(s * (c + 1), GFP_KERNEL); |
| 100 | if (!ports) { |
| 101 | printk(KERN_INFO "Alchemy: no memory for UART data\n"); |
| 102 | return; |
| 103 | } |
| 104 | memcpy(ports, au1x00_uart_data[ctype], s * c); |
| 105 | au1xx0_uart_device.dev.platform_data = ports; |
| 106 | |
| 107 | /* Fill up uartclk. */ |
| 108 | for (s = 0; s < c; s++) |
| 109 | ports[s].uartclk = uartclk; |
| 110 | if (platform_device_register(&au1xx0_uart_device)) |
| 111 | printk(KERN_INFO "Alchemy: failed to register UARTs\n"); |
| 112 | } |
| 113 | |
Manuel Lauss | b9581b8 | 2011-08-12 11:39:39 +0200 | [diff] [blame] | 114 | |
| 115 | /* The dmamask must be set for OHCI/EHCI to work */ |
| 116 | static u64 alchemy_ohci_dmamask = DMA_BIT_MASK(32); |
| 117 | static u64 __maybe_unused alchemy_ehci_dmamask = DMA_BIT_MASK(32); |
| 118 | |
| 119 | static unsigned long alchemy_ohci_data[][2] __initdata = { |
| 120 | [ALCHEMY_CPU_AU1000] = { AU1000_USB_OHCI_PHYS_ADDR, AU1000_USB_HOST_INT }, |
| 121 | [ALCHEMY_CPU_AU1500] = { AU1000_USB_OHCI_PHYS_ADDR, AU1500_USB_HOST_INT }, |
| 122 | [ALCHEMY_CPU_AU1100] = { AU1000_USB_OHCI_PHYS_ADDR, AU1100_USB_HOST_INT }, |
| 123 | [ALCHEMY_CPU_AU1550] = { AU1550_USB_OHCI_PHYS_ADDR, AU1550_USB_HOST_INT }, |
| 124 | [ALCHEMY_CPU_AU1200] = { AU1200_USB_OHCI_PHYS_ADDR, AU1200_USB_INT }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 125 | }; |
| 126 | |
Manuel Lauss | b9581b8 | 2011-08-12 11:39:39 +0200 | [diff] [blame] | 127 | static unsigned long alchemy_ehci_data[][2] __initdata = { |
| 128 | [ALCHEMY_CPU_AU1200] = { AU1200_USB_EHCI_PHYS_ADDR, AU1200_USB_INT }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 129 | }; |
| 130 | |
Manuel Lauss | b9581b8 | 2011-08-12 11:39:39 +0200 | [diff] [blame] | 131 | static int __init _new_usbres(struct resource **r, struct platform_device **d) |
| 132 | { |
| 133 | *r = kzalloc(sizeof(struct resource) * 2, GFP_KERNEL); |
| 134 | if (!*r) |
| 135 | return -ENOMEM; |
| 136 | *d = kzalloc(sizeof(struct platform_device), GFP_KERNEL); |
| 137 | if (!*d) { |
| 138 | kfree(*r); |
| 139 | return -ENOMEM; |
| 140 | } |
| 141 | |
| 142 | (*d)->dev.coherent_dma_mask = DMA_BIT_MASK(32); |
| 143 | (*d)->num_resources = 2; |
| 144 | (*d)->resource = *r; |
| 145 | |
| 146 | return 0; |
| 147 | } |
| 148 | |
| 149 | static void __init alchemy_setup_usb(int ctype) |
| 150 | { |
| 151 | struct resource *res; |
| 152 | struct platform_device *pdev; |
| 153 | |
| 154 | /* setup OHCI0. Every variant has one */ |
| 155 | if (_new_usbres(&res, &pdev)) |
| 156 | return; |
| 157 | |
| 158 | res[0].start = alchemy_ohci_data[ctype][0]; |
| 159 | res[0].end = res[0].start + 0x100 - 1; |
| 160 | res[0].flags = IORESOURCE_MEM; |
| 161 | res[1].start = alchemy_ohci_data[ctype][1]; |
| 162 | res[1].end = res[1].start; |
| 163 | res[1].flags = IORESOURCE_IRQ; |
| 164 | pdev->name = "au1xxx-ohci"; |
| 165 | pdev->id = 0; |
| 166 | pdev->dev.dma_mask = &alchemy_ohci_dmamask; |
| 167 | |
| 168 | if (platform_device_register(pdev)) |
| 169 | printk(KERN_INFO "Alchemy USB: cannot add OHCI0\n"); |
| 170 | |
| 171 | |
| 172 | /* setup EHCI0: Au1200 */ |
| 173 | if (ctype == ALCHEMY_CPU_AU1200) { |
| 174 | if (_new_usbres(&res, &pdev)) |
| 175 | return; |
| 176 | |
| 177 | res[0].start = alchemy_ehci_data[ctype][0]; |
| 178 | res[0].end = res[0].start + 0x100 - 1; |
| 179 | res[0].flags = IORESOURCE_MEM; |
| 180 | res[1].start = alchemy_ehci_data[ctype][1]; |
| 181 | res[1].end = res[1].start; |
| 182 | res[1].flags = IORESOURCE_IRQ; |
| 183 | pdev->name = "au1xxx-ehci"; |
| 184 | pdev->id = 0; |
| 185 | pdev->dev.dma_mask = &alchemy_ehci_dmamask; |
| 186 | |
| 187 | if (platform_device_register(pdev)) |
| 188 | printk(KERN_INFO "Alchemy USB: cannot add EHCI0\n"); |
| 189 | } |
| 190 | } |
| 191 | |
Pete Popov | 3b495f2 | 2005-04-04 01:06:19 +0000 | [diff] [blame] | 192 | /*** AU1100 LCD controller ***/ |
| 193 | |
| 194 | #ifdef CONFIG_FB_AU1100 |
| 195 | static struct resource au1100_lcd_resources[] = { |
| 196 | [0] = { |
Manuel Lauss | 7cc2e27 | 2011-08-12 11:39:40 +0200 | [diff] [blame] | 197 | .start = AU1100_LCD_PHYS_ADDR, |
| 198 | .end = AU1100_LCD_PHYS_ADDR + 0x800 - 1, |
Pete Popov | 3b495f2 | 2005-04-04 01:06:19 +0000 | [diff] [blame] | 199 | .flags = IORESOURCE_MEM, |
| 200 | }, |
| 201 | [1] = { |
| 202 | .start = AU1100_LCD_INT, |
| 203 | .end = AU1100_LCD_INT, |
| 204 | .flags = IORESOURCE_IRQ, |
| 205 | } |
| 206 | }; |
| 207 | |
Yang Hongyang | 284901a | 2009-04-06 19:01:15 -0700 | [diff] [blame] | 208 | static u64 au1100_lcd_dmamask = DMA_BIT_MASK(32); |
Pete Popov | 3b495f2 | 2005-04-04 01:06:19 +0000 | [diff] [blame] | 209 | |
| 210 | static struct platform_device au1100_lcd_device = { |
| 211 | .name = "au1100-lcd", |
| 212 | .id = 0, |
| 213 | .dev = { |
| 214 | .dma_mask = &au1100_lcd_dmamask, |
Yang Hongyang | 284901a | 2009-04-06 19:01:15 -0700 | [diff] [blame] | 215 | .coherent_dma_mask = DMA_BIT_MASK(32), |
Pete Popov | 3b495f2 | 2005-04-04 01:06:19 +0000 | [diff] [blame] | 216 | }, |
| 217 | .num_resources = ARRAY_SIZE(au1100_lcd_resources), |
| 218 | .resource = au1100_lcd_resources, |
| 219 | }; |
| 220 | #endif |
| 221 | |
Pete Popov | 64abf64 | 2005-09-14 16:17:59 +0000 | [diff] [blame] | 222 | #ifdef CONFIG_SOC_AU1200 |
Pete Popov | 64abf64 | 2005-09-14 16:17:59 +0000 | [diff] [blame] | 223 | |
Pete Popov | 64abf64 | 2005-09-14 16:17:59 +0000 | [diff] [blame] | 224 | static struct resource au1200_lcd_resources[] = { |
| 225 | [0] = { |
Manuel Lauss | 7cc2e27 | 2011-08-12 11:39:40 +0200 | [diff] [blame] | 226 | .start = AU1200_LCD_PHYS_ADDR, |
| 227 | .end = AU1200_LCD_PHYS_ADDR + 0x800 - 1, |
Pete Popov | 64abf64 | 2005-09-14 16:17:59 +0000 | [diff] [blame] | 228 | .flags = IORESOURCE_MEM, |
| 229 | }, |
| 230 | [1] = { |
| 231 | .start = AU1200_LCD_INT, |
| 232 | .end = AU1200_LCD_INT, |
| 233 | .flags = IORESOURCE_IRQ, |
| 234 | } |
| 235 | }; |
| 236 | |
Yang Hongyang | 284901a | 2009-04-06 19:01:15 -0700 | [diff] [blame] | 237 | static u64 au1200_lcd_dmamask = DMA_BIT_MASK(32); |
Pete Popov | 64abf64 | 2005-09-14 16:17:59 +0000 | [diff] [blame] | 238 | |
| 239 | static struct platform_device au1200_lcd_device = { |
| 240 | .name = "au1200-lcd", |
| 241 | .id = 0, |
| 242 | .dev = { |
| 243 | .dma_mask = &au1200_lcd_dmamask, |
Yang Hongyang | 284901a | 2009-04-06 19:01:15 -0700 | [diff] [blame] | 244 | .coherent_dma_mask = DMA_BIT_MASK(32), |
Pete Popov | 64abf64 | 2005-09-14 16:17:59 +0000 | [diff] [blame] | 245 | }, |
| 246 | .num_resources = ARRAY_SIZE(au1200_lcd_resources), |
| 247 | .resource = au1200_lcd_resources, |
| 248 | }; |
Pete Popov | 26a940e | 2005-09-15 08:03:12 +0000 | [diff] [blame] | 249 | |
Yang Hongyang | 284901a | 2009-04-06 19:01:15 -0700 | [diff] [blame] | 250 | static u64 au1xxx_mmc_dmamask = DMA_BIT_MASK(32); |
Pete Popov | ba264b3 | 2005-09-21 06:18:27 +0000 | [diff] [blame] | 251 | |
Manuel Lauss | f591eb1 | 2008-10-21 08:59:14 +0200 | [diff] [blame] | 252 | extern struct au1xmmc_platform_data au1xmmc_platdata[2]; |
| 253 | |
| 254 | static struct resource au1200_mmc0_resources[] = { |
| 255 | [0] = { |
Manuel Lauss | 5d4ddcb | 2011-05-08 10:42:19 +0200 | [diff] [blame] | 256 | .start = AU1100_SD0_PHYS_ADDR, |
| 257 | .end = AU1100_SD0_PHYS_ADDR + 0xfff, |
Manuel Lauss | f591eb1 | 2008-10-21 08:59:14 +0200 | [diff] [blame] | 258 | .flags = IORESOURCE_MEM, |
| 259 | }, |
| 260 | [1] = { |
| 261 | .start = AU1200_SD_INT, |
| 262 | .end = AU1200_SD_INT, |
| 263 | .flags = IORESOURCE_IRQ, |
| 264 | }, |
| 265 | [2] = { |
Manuel Lauss | f2e442f | 2011-08-12 11:39:42 +0200 | [diff] [blame^] | 266 | .start = AU1200_DSCR_CMD0_SDMS_TX0, |
| 267 | .end = AU1200_DSCR_CMD0_SDMS_TX0, |
Manuel Lauss | f591eb1 | 2008-10-21 08:59:14 +0200 | [diff] [blame] | 268 | .flags = IORESOURCE_DMA, |
| 269 | }, |
| 270 | [3] = { |
Manuel Lauss | f2e442f | 2011-08-12 11:39:42 +0200 | [diff] [blame^] | 271 | .start = AU1200_DSCR_CMD0_SDMS_RX0, |
| 272 | .end = AU1200_DSCR_CMD0_SDMS_RX0, |
Manuel Lauss | f591eb1 | 2008-10-21 08:59:14 +0200 | [diff] [blame] | 273 | .flags = IORESOURCE_DMA, |
| 274 | } |
| 275 | }; |
| 276 | |
| 277 | static struct platform_device au1200_mmc0_device = { |
Pete Popov | ba264b3 | 2005-09-21 06:18:27 +0000 | [diff] [blame] | 278 | .name = "au1xxx-mmc", |
| 279 | .id = 0, |
| 280 | .dev = { |
Manuel Lauss | f591eb1 | 2008-10-21 08:59:14 +0200 | [diff] [blame] | 281 | .dma_mask = &au1xxx_mmc_dmamask, |
Yang Hongyang | 284901a | 2009-04-06 19:01:15 -0700 | [diff] [blame] | 282 | .coherent_dma_mask = DMA_BIT_MASK(32), |
Manuel Lauss | f591eb1 | 2008-10-21 08:59:14 +0200 | [diff] [blame] | 283 | .platform_data = &au1xmmc_platdata[0], |
Pete Popov | ba264b3 | 2005-09-21 06:18:27 +0000 | [diff] [blame] | 284 | }, |
Manuel Lauss | f591eb1 | 2008-10-21 08:59:14 +0200 | [diff] [blame] | 285 | .num_resources = ARRAY_SIZE(au1200_mmc0_resources), |
| 286 | .resource = au1200_mmc0_resources, |
Pete Popov | ba264b3 | 2005-09-21 06:18:27 +0000 | [diff] [blame] | 287 | }; |
Manuel Lauss | f591eb1 | 2008-10-21 08:59:14 +0200 | [diff] [blame] | 288 | |
| 289 | #ifndef CONFIG_MIPS_DB1200 |
| 290 | static struct resource au1200_mmc1_resources[] = { |
| 291 | [0] = { |
Manuel Lauss | 5d4ddcb | 2011-05-08 10:42:19 +0200 | [diff] [blame] | 292 | .start = AU1100_SD1_PHYS_ADDR, |
| 293 | .end = AU1100_SD1_PHYS_ADDR + 0xfff, |
Manuel Lauss | f591eb1 | 2008-10-21 08:59:14 +0200 | [diff] [blame] | 294 | .flags = IORESOURCE_MEM, |
| 295 | }, |
| 296 | [1] = { |
| 297 | .start = AU1200_SD_INT, |
| 298 | .end = AU1200_SD_INT, |
| 299 | .flags = IORESOURCE_IRQ, |
| 300 | }, |
| 301 | [2] = { |
Manuel Lauss | f2e442f | 2011-08-12 11:39:42 +0200 | [diff] [blame^] | 302 | .start = AU1200_DSCR_CMD0_SDMS_TX1, |
| 303 | .end = AU1200_DSCR_CMD0_SDMS_TX1, |
Manuel Lauss | f591eb1 | 2008-10-21 08:59:14 +0200 | [diff] [blame] | 304 | .flags = IORESOURCE_DMA, |
| 305 | }, |
| 306 | [3] = { |
Manuel Lauss | f2e442f | 2011-08-12 11:39:42 +0200 | [diff] [blame^] | 307 | .start = AU1200_DSCR_CMD0_SDMS_RX1, |
| 308 | .end = AU1200_DSCR_CMD0_SDMS_RX1, |
Manuel Lauss | f591eb1 | 2008-10-21 08:59:14 +0200 | [diff] [blame] | 309 | .flags = IORESOURCE_DMA, |
| 310 | } |
| 311 | }; |
| 312 | |
| 313 | static struct platform_device au1200_mmc1_device = { |
| 314 | .name = "au1xxx-mmc", |
| 315 | .id = 1, |
| 316 | .dev = { |
| 317 | .dma_mask = &au1xxx_mmc_dmamask, |
Yang Hongyang | 284901a | 2009-04-06 19:01:15 -0700 | [diff] [blame] | 318 | .coherent_dma_mask = DMA_BIT_MASK(32), |
Manuel Lauss | f591eb1 | 2008-10-21 08:59:14 +0200 | [diff] [blame] | 319 | .platform_data = &au1xmmc_platdata[1], |
| 320 | }, |
| 321 | .num_resources = ARRAY_SIZE(au1200_mmc1_resources), |
| 322 | .resource = au1200_mmc1_resources, |
| 323 | }; |
| 324 | #endif /* #ifndef CONFIG_MIPS_DB1200 */ |
Pete Popov | ba264b3 | 2005-09-21 06:18:27 +0000 | [diff] [blame] | 325 | #endif /* #ifdef CONFIG_SOC_AU1200 */ |
| 326 | |
Manuel Lauss | 8b798c4 | 2008-01-27 18:14:52 +0100 | [diff] [blame] | 327 | /* All Alchemy demoboards with I2C have this #define in their headers */ |
| 328 | #ifdef SMBUS_PSC_BASE |
| 329 | static struct resource pbdb_smbus_resources[] = { |
| 330 | { |
Manuel Lauss | 7cc2e27 | 2011-08-12 11:39:40 +0200 | [diff] [blame] | 331 | .start = SMBUS_PSC_BASE, |
| 332 | .end = SMBUS_PSC_BASE + 0xfff, |
Manuel Lauss | 8b798c4 | 2008-01-27 18:14:52 +0100 | [diff] [blame] | 333 | .flags = IORESOURCE_MEM, |
| 334 | }, |
| 335 | }; |
| 336 | |
| 337 | static struct platform_device pbdb_smbus_device = { |
| 338 | .name = "au1xpsc_smbus", |
| 339 | .id = 0, /* bus number */ |
| 340 | .num_resources = ARRAY_SIZE(pbdb_smbus_resources), |
| 341 | .resource = pbdb_smbus_resources, |
| 342 | }; |
| 343 | #endif |
| 344 | |
Florian Fainelli | 66f75cc | 2009-11-10 01:13:30 +0100 | [diff] [blame] | 345 | /* Macro to help defining the Ethernet MAC resources */ |
Manuel Lauss | 553737a | 2011-08-02 19:50:57 +0200 | [diff] [blame] | 346 | #define MAC_RES_COUNT 4 /* MAC regs, MAC en, MAC INT, MACDMA regs */ |
| 347 | #define MAC_RES(_base, _enable, _irq, _macdma) \ |
Florian Fainelli | 66f75cc | 2009-11-10 01:13:30 +0100 | [diff] [blame] | 348 | { \ |
Manuel Lauss | 40d8bc2 | 2011-05-08 10:42:18 +0200 | [diff] [blame] | 349 | .start = _base, \ |
| 350 | .end = _base + 0xffff, \ |
Florian Fainelli | 66f75cc | 2009-11-10 01:13:30 +0100 | [diff] [blame] | 351 | .flags = IORESOURCE_MEM, \ |
| 352 | }, \ |
| 353 | { \ |
Manuel Lauss | 40d8bc2 | 2011-05-08 10:42:18 +0200 | [diff] [blame] | 354 | .start = _enable, \ |
| 355 | .end = _enable + 0x3, \ |
Florian Fainelli | 66f75cc | 2009-11-10 01:13:30 +0100 | [diff] [blame] | 356 | .flags = IORESOURCE_MEM, \ |
| 357 | }, \ |
| 358 | { \ |
| 359 | .start = _irq, \ |
| 360 | .end = _irq, \ |
| 361 | .flags = IORESOURCE_IRQ \ |
Manuel Lauss | 553737a | 2011-08-02 19:50:57 +0200 | [diff] [blame] | 362 | }, \ |
| 363 | { \ |
| 364 | .start = _macdma, \ |
| 365 | .end = _macdma + 0x1ff, \ |
| 366 | .flags = IORESOURCE_MEM, \ |
Florian Fainelli | 66f75cc | 2009-11-10 01:13:30 +0100 | [diff] [blame] | 367 | } |
| 368 | |
Manuel Lauss | 40d8bc2 | 2011-05-08 10:42:18 +0200 | [diff] [blame] | 369 | static struct resource au1xxx_eth0_resources[][MAC_RES_COUNT] __initdata = { |
| 370 | [ALCHEMY_CPU_AU1000] = { |
| 371 | MAC_RES(AU1000_MAC0_PHYS_ADDR, |
| 372 | AU1000_MACEN_PHYS_ADDR, |
Manuel Lauss | 553737a | 2011-08-02 19:50:57 +0200 | [diff] [blame] | 373 | AU1000_MAC0_DMA_INT, |
| 374 | AU1000_MACDMA0_PHYS_ADDR) |
Manuel Lauss | 40d8bc2 | 2011-05-08 10:42:18 +0200 | [diff] [blame] | 375 | }, |
| 376 | [ALCHEMY_CPU_AU1500] = { |
| 377 | MAC_RES(AU1500_MAC0_PHYS_ADDR, |
| 378 | AU1500_MACEN_PHYS_ADDR, |
Manuel Lauss | 553737a | 2011-08-02 19:50:57 +0200 | [diff] [blame] | 379 | AU1500_MAC0_DMA_INT, |
| 380 | AU1000_MACDMA0_PHYS_ADDR) |
Manuel Lauss | 40d8bc2 | 2011-05-08 10:42:18 +0200 | [diff] [blame] | 381 | }, |
| 382 | [ALCHEMY_CPU_AU1100] = { |
| 383 | MAC_RES(AU1000_MAC0_PHYS_ADDR, |
| 384 | AU1000_MACEN_PHYS_ADDR, |
Manuel Lauss | 553737a | 2011-08-02 19:50:57 +0200 | [diff] [blame] | 385 | AU1100_MAC0_DMA_INT, |
| 386 | AU1000_MACDMA0_PHYS_ADDR) |
Manuel Lauss | 40d8bc2 | 2011-05-08 10:42:18 +0200 | [diff] [blame] | 387 | }, |
| 388 | [ALCHEMY_CPU_AU1550] = { |
| 389 | MAC_RES(AU1000_MAC0_PHYS_ADDR, |
| 390 | AU1000_MACEN_PHYS_ADDR, |
Manuel Lauss | 553737a | 2011-08-02 19:50:57 +0200 | [diff] [blame] | 391 | AU1550_MAC0_DMA_INT, |
| 392 | AU1000_MACDMA0_PHYS_ADDR) |
Manuel Lauss | 40d8bc2 | 2011-05-08 10:42:18 +0200 | [diff] [blame] | 393 | }, |
Florian Fainelli | 66f75cc | 2009-11-10 01:13:30 +0100 | [diff] [blame] | 394 | }; |
| 395 | |
Florian Fainelli | 66f75cc | 2009-11-10 01:13:30 +0100 | [diff] [blame] | 396 | static struct au1000_eth_platform_data au1xxx_eth0_platform_data = { |
| 397 | .phy1_search_mac0 = 1, |
| 398 | }; |
| 399 | |
| 400 | static struct platform_device au1xxx_eth0_device = { |
| 401 | .name = "au1000-eth", |
| 402 | .id = 0, |
Manuel Lauss | 40d8bc2 | 2011-05-08 10:42:18 +0200 | [diff] [blame] | 403 | .num_resources = MAC_RES_COUNT, |
Florian Fainelli | 66f75cc | 2009-11-10 01:13:30 +0100 | [diff] [blame] | 404 | .dev.platform_data = &au1xxx_eth0_platform_data, |
| 405 | }; |
| 406 | |
Manuel Lauss | 40d8bc2 | 2011-05-08 10:42:18 +0200 | [diff] [blame] | 407 | static struct resource au1xxx_eth1_resources[][MAC_RES_COUNT] __initdata = { |
| 408 | [ALCHEMY_CPU_AU1000] = { |
| 409 | MAC_RES(AU1000_MAC1_PHYS_ADDR, |
| 410 | AU1000_MACEN_PHYS_ADDR + 4, |
Manuel Lauss | 553737a | 2011-08-02 19:50:57 +0200 | [diff] [blame] | 411 | AU1000_MAC1_DMA_INT, |
| 412 | AU1000_MACDMA1_PHYS_ADDR) |
Manuel Lauss | 40d8bc2 | 2011-05-08 10:42:18 +0200 | [diff] [blame] | 413 | }, |
| 414 | [ALCHEMY_CPU_AU1500] = { |
| 415 | MAC_RES(AU1500_MAC1_PHYS_ADDR, |
| 416 | AU1500_MACEN_PHYS_ADDR + 4, |
Manuel Lauss | 553737a | 2011-08-02 19:50:57 +0200 | [diff] [blame] | 417 | AU1500_MAC1_DMA_INT, |
| 418 | AU1000_MACDMA1_PHYS_ADDR) |
Manuel Lauss | 40d8bc2 | 2011-05-08 10:42:18 +0200 | [diff] [blame] | 419 | }, |
| 420 | [ALCHEMY_CPU_AU1550] = { |
| 421 | MAC_RES(AU1000_MAC1_PHYS_ADDR, |
| 422 | AU1000_MACEN_PHYS_ADDR + 4, |
Manuel Lauss | 553737a | 2011-08-02 19:50:57 +0200 | [diff] [blame] | 423 | AU1550_MAC1_DMA_INT, |
| 424 | AU1000_MACDMA1_PHYS_ADDR) |
Manuel Lauss | 40d8bc2 | 2011-05-08 10:42:18 +0200 | [diff] [blame] | 425 | }, |
Manuel Lauss | acc4d24 | 2010-02-26 17:22:02 +0100 | [diff] [blame] | 426 | }; |
| 427 | |
Florian Fainelli | 66f75cc | 2009-11-10 01:13:30 +0100 | [diff] [blame] | 428 | static struct au1000_eth_platform_data au1xxx_eth1_platform_data = { |
| 429 | .phy1_search_mac0 = 1, |
| 430 | }; |
| 431 | |
| 432 | static struct platform_device au1xxx_eth1_device = { |
| 433 | .name = "au1000-eth", |
| 434 | .id = 1, |
Manuel Lauss | 40d8bc2 | 2011-05-08 10:42:18 +0200 | [diff] [blame] | 435 | .num_resources = MAC_RES_COUNT, |
Florian Fainelli | 66f75cc | 2009-11-10 01:13:30 +0100 | [diff] [blame] | 436 | .dev.platform_data = &au1xxx_eth1_platform_data, |
| 437 | }; |
Florian Fainelli | 66f75cc | 2009-11-10 01:13:30 +0100 | [diff] [blame] | 438 | |
| 439 | void __init au1xxx_override_eth_cfg(unsigned int port, |
| 440 | struct au1000_eth_platform_data *eth_data) |
| 441 | { |
| 442 | if (!eth_data || port > 1) |
| 443 | return; |
| 444 | |
| 445 | if (port == 0) |
| 446 | memcpy(&au1xxx_eth0_platform_data, eth_data, |
| 447 | sizeof(struct au1000_eth_platform_data)); |
Florian Fainelli | 66f75cc | 2009-11-10 01:13:30 +0100 | [diff] [blame] | 448 | else |
| 449 | memcpy(&au1xxx_eth1_platform_data, eth_data, |
| 450 | sizeof(struct au1000_eth_platform_data)); |
Manuel Lauss | 40d8bc2 | 2011-05-08 10:42:18 +0200 | [diff] [blame] | 451 | } |
| 452 | |
| 453 | static void __init alchemy_setup_macs(int ctype) |
| 454 | { |
| 455 | int ret, i; |
| 456 | unsigned char ethaddr[6]; |
| 457 | struct resource *macres; |
| 458 | |
| 459 | /* Handle 1st MAC */ |
| 460 | if (alchemy_get_macs(ctype) < 1) |
| 461 | return; |
| 462 | |
| 463 | macres = kmalloc(sizeof(struct resource) * MAC_RES_COUNT, GFP_KERNEL); |
| 464 | if (!macres) { |
| 465 | printk(KERN_INFO "Alchemy: no memory for MAC0 resources\n"); |
| 466 | return; |
| 467 | } |
| 468 | memcpy(macres, au1xxx_eth0_resources[ctype], |
| 469 | sizeof(struct resource) * MAC_RES_COUNT); |
| 470 | au1xxx_eth0_device.resource = macres; |
| 471 | |
| 472 | i = prom_get_ethernet_addr(ethaddr); |
| 473 | if (!i && !is_valid_ether_addr(au1xxx_eth0_platform_data.mac)) |
| 474 | memcpy(au1xxx_eth0_platform_data.mac, ethaddr, 6); |
| 475 | |
| 476 | ret = platform_device_register(&au1xxx_eth0_device); |
Manuel Lauss | c78c488 | 2011-08-02 15:50:56 +0200 | [diff] [blame] | 477 | if (ret) |
Manuel Lauss | 40d8bc2 | 2011-05-08 10:42:18 +0200 | [diff] [blame] | 478 | printk(KERN_INFO "Alchemy: failed to register MAC0\n"); |
| 479 | |
| 480 | |
| 481 | /* Handle 2nd MAC */ |
| 482 | if (alchemy_get_macs(ctype) < 2) |
| 483 | return; |
| 484 | |
| 485 | macres = kmalloc(sizeof(struct resource) * MAC_RES_COUNT, GFP_KERNEL); |
| 486 | if (!macres) { |
| 487 | printk(KERN_INFO "Alchemy: no memory for MAC1 resources\n"); |
| 488 | return; |
| 489 | } |
| 490 | memcpy(macres, au1xxx_eth1_resources[ctype], |
| 491 | sizeof(struct resource) * MAC_RES_COUNT); |
| 492 | au1xxx_eth1_device.resource = macres; |
| 493 | |
| 494 | ethaddr[5] += 1; /* next addr for 2nd MAC */ |
| 495 | if (!i && !is_valid_ether_addr(au1xxx_eth1_platform_data.mac)) |
| 496 | memcpy(au1xxx_eth1_platform_data.mac, ethaddr, 6); |
| 497 | |
| 498 | /* Register second MAC if enabled in pinfunc */ |
| 499 | if (!(au_readl(SYS_PINFUNC) & (u32)SYS_PF_NI2)) { |
| 500 | ret = platform_device_register(&au1xxx_eth1_device); |
| 501 | if (ret) |
| 502 | printk(KERN_INFO "Alchemy: failed to register MAC1\n"); |
| 503 | } |
Florian Fainelli | 66f75cc | 2009-11-10 01:13:30 +0100 | [diff] [blame] | 504 | } |
| 505 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 506 | static struct platform_device *au1xxx_platform_devices[] __initdata = { |
Pete Popov | 3b495f2 | 2005-04-04 01:06:19 +0000 | [diff] [blame] | 507 | #ifdef CONFIG_FB_AU1100 |
| 508 | &au1100_lcd_device, |
| 509 | #endif |
Pete Popov | 64abf64 | 2005-09-14 16:17:59 +0000 | [diff] [blame] | 510 | #ifdef CONFIG_SOC_AU1200 |
Pete Popov | 64abf64 | 2005-09-14 16:17:59 +0000 | [diff] [blame] | 511 | &au1200_lcd_device, |
Manuel Lauss | f591eb1 | 2008-10-21 08:59:14 +0200 | [diff] [blame] | 512 | &au1200_mmc0_device, |
| 513 | #ifndef CONFIG_MIPS_DB1200 |
| 514 | &au1200_mmc1_device, |
| 515 | #endif |
Pete Popov | 64abf64 | 2005-09-14 16:17:59 +0000 | [diff] [blame] | 516 | #endif |
Manuel Lauss | 8b798c4 | 2008-01-27 18:14:52 +0100 | [diff] [blame] | 517 | #ifdef SMBUS_PSC_BASE |
| 518 | &pbdb_smbus_device, |
| 519 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 520 | }; |
| 521 | |
Sergei Shtylyov | c1dcb14 | 2008-04-30 23:18:41 +0400 | [diff] [blame] | 522 | static int __init au1xxx_platform_init(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 523 | { |
Manuel Lauss | 40d8bc2 | 2011-05-08 10:42:18 +0200 | [diff] [blame] | 524 | int err, ctype = alchemy_get_cputype(); |
Sergei Shtylyov | 6e76645 | 2008-04-04 00:02:53 +0400 | [diff] [blame] | 525 | |
Manuel Lauss | 8013020 | 2011-05-08 10:42:17 +0200 | [diff] [blame] | 526 | alchemy_setup_uarts(ctype); |
Manuel Lauss | 40d8bc2 | 2011-05-08 10:42:18 +0200 | [diff] [blame] | 527 | alchemy_setup_macs(ctype); |
Manuel Lauss | b9581b8 | 2011-08-12 11:39:39 +0200 | [diff] [blame] | 528 | alchemy_setup_usb(ctype); |
Manuel Lauss | f667365 | 2010-07-21 14:30:50 +0200 | [diff] [blame] | 529 | |
Wolfgang Grandegger | 0d5977d | 2010-07-17 16:38:48 +0200 | [diff] [blame] | 530 | err = platform_add_devices(au1xxx_platform_devices, |
| 531 | ARRAY_SIZE(au1xxx_platform_devices)); |
Wolfgang Grandegger | 0d5977d | 2010-07-17 16:38:48 +0200 | [diff] [blame] | 532 | return err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 533 | } |
| 534 | |
| 535 | arch_initcall(au1xxx_platform_init); |