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> |
Russell King | d052d1b | 2005-10-29 19:07:23 +0100 | [diff] [blame] | 16 | #include <linux/platform_device.h> |
Sergei Shtylyov | 6e76645 | 2008-04-04 00:02:53 +0400 | [diff] [blame] | 17 | #include <linux/serial_8250.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 18 | #include <linux/init.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | |
Pete Popov | 26a940e | 2005-09-15 08:03:12 +0000 | [diff] [blame] | 20 | #include <asm/mach-au1x00/au1xxx.h> |
Manuel Lauss | f591eb1 | 2008-10-21 08:59:14 +0200 | [diff] [blame] | 21 | #include <asm/mach-au1x00/au1xxx_dbdma.h> |
| 22 | #include <asm/mach-au1x00/au1100_mmc.h> |
Florian Fainelli | 66f75cc | 2009-11-10 01:13:30 +0100 | [diff] [blame] | 23 | #include <asm/mach-au1x00/au1xxx_eth.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 24 | |
Manuel Lauss | f667365 | 2010-07-21 14:30:50 +0200 | [diff] [blame] | 25 | #include <prom.h> |
| 26 | |
Manuel Lauss | 7d172bf | 2010-09-25 15:13:46 +0200 | [diff] [blame^] | 27 | static 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 Lauss | b6e6d12 | 2009-10-15 19:07:34 +0200 | [diff] [blame] | 54 | #define PORT(_base, _irq) \ |
| 55 | { \ |
| 56 | .mapbase = _base, \ |
| 57 | .irq = _irq, \ |
| 58 | .regshift = 2, \ |
| 59 | .iotype = UPIO_AU, \ |
Manuel Lauss | 63ea336 | 2009-10-28 21:49:46 +0100 | [diff] [blame] | 60 | .flags = UPF_SKIP_TEST | UPF_IOREMAP | \ |
| 61 | UPF_FIXED_TYPE, \ |
| 62 | .type = PORT_16550A, \ |
Manuel Lauss | 7d172bf | 2010-09-25 15:13:46 +0200 | [diff] [blame^] | 63 | .pm = alchemy_8250_pm, \ |
Sergei Shtylyov | 6e76645 | 2008-04-04 00:02:53 +0400 | [diff] [blame] | 64 | } |
| 65 | |
| 66 | static struct plat_serial8250_port au1x00_uart_data[] = { |
Sergei Shtylyov | 6e76645 | 2008-04-04 00:02:53 +0400 | [diff] [blame] | 67 | #if defined(CONFIG_SOC_AU1000) |
Manuel Lauss | b6e6d12 | 2009-10-15 19:07:34 +0200 | [diff] [blame] | 68 | 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 Shtylyov | 6e76645 | 2008-04-04 00:02:53 +0400 | [diff] [blame] | 72 | #elif defined(CONFIG_SOC_AU1500) |
Manuel Lauss | b6e6d12 | 2009-10-15 19:07:34 +0200 | [diff] [blame] | 73 | PORT(UART0_PHYS_ADDR, AU1500_UART0_INT), |
| 74 | PORT(UART3_PHYS_ADDR, AU1500_UART3_INT), |
Sergei Shtylyov | 6e76645 | 2008-04-04 00:02:53 +0400 | [diff] [blame] | 75 | #elif defined(CONFIG_SOC_AU1100) |
Manuel Lauss | b6e6d12 | 2009-10-15 19:07:34 +0200 | [diff] [blame] | 76 | PORT(UART0_PHYS_ADDR, AU1100_UART0_INT), |
| 77 | PORT(UART1_PHYS_ADDR, AU1100_UART1_INT), |
| 78 | PORT(UART3_PHYS_ADDR, AU1100_UART3_INT), |
Sergei Shtylyov | 6e76645 | 2008-04-04 00:02:53 +0400 | [diff] [blame] | 79 | #elif defined(CONFIG_SOC_AU1550) |
Manuel Lauss | b6e6d12 | 2009-10-15 19:07:34 +0200 | [diff] [blame] | 80 | PORT(UART0_PHYS_ADDR, AU1550_UART0_INT), |
| 81 | PORT(UART1_PHYS_ADDR, AU1550_UART1_INT), |
| 82 | PORT(UART3_PHYS_ADDR, AU1550_UART3_INT), |
Sergei Shtylyov | 6e76645 | 2008-04-04 00:02:53 +0400 | [diff] [blame] | 83 | #elif defined(CONFIG_SOC_AU1200) |
Manuel Lauss | b6e6d12 | 2009-10-15 19:07:34 +0200 | [diff] [blame] | 84 | PORT(UART0_PHYS_ADDR, AU1200_UART0_INT), |
| 85 | PORT(UART1_PHYS_ADDR, AU1200_UART1_INT), |
Sergei Shtylyov | 6e76645 | 2008-04-04 00:02:53 +0400 | [diff] [blame] | 86 | #endif |
Sergei Shtylyov | 6e76645 | 2008-04-04 00:02:53 +0400 | [diff] [blame] | 87 | { }, |
| 88 | }; |
| 89 | |
| 90 | static 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 Popov | 64abf64 | 2005-09-14 16:17:59 +0000 | [diff] [blame] | 98 | /* OHCI (USB full speed host controller) */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 99 | static struct resource au1xxx_usb_ohci_resources[] = { |
| 100 | [0] = { |
| 101 | .start = USB_OHCI_BASE, |
Jordan Crouse | d5fb7f1 | 2006-01-20 14:09:54 -0800 | [diff] [blame] | 102 | .end = USB_OHCI_BASE + USB_OHCI_LEN - 1, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 103 | .flags = IORESOURCE_MEM, |
| 104 | }, |
| 105 | [1] = { |
Manuel Lauss | 7881446 | 2009-10-07 20:15:15 +0200 | [diff] [blame] | 106 | .start = FOR_PLATFORM_C_USB_HOST_INT, |
| 107 | .end = FOR_PLATFORM_C_USB_HOST_INT, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 108 | .flags = IORESOURCE_IRQ, |
| 109 | }, |
| 110 | }; |
| 111 | |
| 112 | /* The dmamask must be set for OHCI to work */ |
Yang Hongyang | 284901a | 2009-04-06 19:01:15 -0700 | [diff] [blame] | 113 | static u64 ohci_dmamask = DMA_BIT_MASK(32); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 114 | |
| 115 | static struct platform_device au1xxx_usb_ohci_device = { |
| 116 | .name = "au1xxx-ohci", |
| 117 | .id = 0, |
| 118 | .dev = { |
| 119 | .dma_mask = &ohci_dmamask, |
Yang Hongyang | 284901a | 2009-04-06 19:01:15 -0700 | [diff] [blame] | 120 | .coherent_dma_mask = DMA_BIT_MASK(32), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 121 | }, |
| 122 | .num_resources = ARRAY_SIZE(au1xxx_usb_ohci_resources), |
| 123 | .resource = au1xxx_usb_ohci_resources, |
| 124 | }; |
| 125 | |
Pete Popov | 3b495f2 | 2005-04-04 01:06:19 +0000 | [diff] [blame] | 126 | /*** AU1100 LCD controller ***/ |
| 127 | |
| 128 | #ifdef CONFIG_FB_AU1100 |
| 129 | static 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 Hongyang | 284901a | 2009-04-06 19:01:15 -0700 | [diff] [blame] | 142 | static u64 au1100_lcd_dmamask = DMA_BIT_MASK(32); |
Pete Popov | 3b495f2 | 2005-04-04 01:06:19 +0000 | [diff] [blame] | 143 | |
| 144 | static struct platform_device au1100_lcd_device = { |
| 145 | .name = "au1100-lcd", |
| 146 | .id = 0, |
| 147 | .dev = { |
| 148 | .dma_mask = &au1100_lcd_dmamask, |
Yang Hongyang | 284901a | 2009-04-06 19:01:15 -0700 | [diff] [blame] | 149 | .coherent_dma_mask = DMA_BIT_MASK(32), |
Pete Popov | 3b495f2 | 2005-04-04 01:06:19 +0000 | [diff] [blame] | 150 | }, |
| 151 | .num_resources = ARRAY_SIZE(au1100_lcd_resources), |
| 152 | .resource = au1100_lcd_resources, |
| 153 | }; |
| 154 | #endif |
| 155 | |
Pete Popov | 64abf64 | 2005-09-14 16:17:59 +0000 | [diff] [blame] | 156 | #ifdef CONFIG_SOC_AU1200 |
| 157 | /* EHCI (USB high speed host controller) */ |
| 158 | static 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 Lauss | 7881446 | 2009-10-07 20:15:15 +0200 | [diff] [blame] | 165 | .start = AU1200_USB_INT, |
| 166 | .end = AU1200_USB_INT, |
Pete Popov | 64abf64 | 2005-09-14 16:17:59 +0000 | [diff] [blame] | 167 | .flags = IORESOURCE_IRQ, |
| 168 | }, |
| 169 | }; |
| 170 | |
Yang Hongyang | 284901a | 2009-04-06 19:01:15 -0700 | [diff] [blame] | 171 | static u64 ehci_dmamask = DMA_BIT_MASK(32); |
Pete Popov | 64abf64 | 2005-09-14 16:17:59 +0000 | [diff] [blame] | 172 | |
| 173 | static struct platform_device au1xxx_usb_ehci_device = { |
| 174 | .name = "au1xxx-ehci", |
| 175 | .id = 0, |
| 176 | .dev = { |
| 177 | .dma_mask = &ehci_dmamask, |
Yang Hongyang | 284901a | 2009-04-06 19:01:15 -0700 | [diff] [blame] | 178 | .coherent_dma_mask = DMA_BIT_MASK(32), |
Pete Popov | 64abf64 | 2005-09-14 16:17:59 +0000 | [diff] [blame] | 179 | }, |
| 180 | .num_resources = ARRAY_SIZE(au1xxx_usb_ehci_resources), |
| 181 | .resource = au1xxx_usb_ehci_resources, |
| 182 | }; |
| 183 | |
| 184 | /* Au1200 UDC (USB gadget controller) */ |
| 185 | static 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 Hongyang | 284901a | 2009-04-06 19:01:15 -0700 | [diff] [blame] | 198 | static u64 udc_dmamask = DMA_BIT_MASK(32); |
Pete Popov | 64abf64 | 2005-09-14 16:17:59 +0000 | [diff] [blame] | 199 | |
| 200 | static struct platform_device au1xxx_usb_gdt_device = { |
| 201 | .name = "au1xxx-udc", |
| 202 | .id = 0, |
| 203 | .dev = { |
| 204 | .dma_mask = &udc_dmamask, |
Yang Hongyang | 284901a | 2009-04-06 19:01:15 -0700 | [diff] [blame] | 205 | .coherent_dma_mask = DMA_BIT_MASK(32), |
Pete Popov | 64abf64 | 2005-09-14 16:17:59 +0000 | [diff] [blame] | 206 | }, |
| 207 | .num_resources = ARRAY_SIZE(au1xxx_usb_gdt_resources), |
| 208 | .resource = au1xxx_usb_gdt_resources, |
| 209 | }; |
| 210 | |
| 211 | /* Au1200 UOC (USB OTG controller) */ |
| 212 | static 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 Hongyang | 284901a | 2009-04-06 19:01:15 -0700 | [diff] [blame] | 225 | static u64 uoc_dmamask = DMA_BIT_MASK(32); |
Pete Popov | 64abf64 | 2005-09-14 16:17:59 +0000 | [diff] [blame] | 226 | |
| 227 | static struct platform_device au1xxx_usb_otg_device = { |
| 228 | .name = "au1xxx-uoc", |
| 229 | .id = 0, |
| 230 | .dev = { |
| 231 | .dma_mask = &uoc_dmamask, |
Yang Hongyang | 284901a | 2009-04-06 19:01:15 -0700 | [diff] [blame] | 232 | .coherent_dma_mask = DMA_BIT_MASK(32), |
Pete Popov | 64abf64 | 2005-09-14 16:17:59 +0000 | [diff] [blame] | 233 | }, |
| 234 | .num_resources = ARRAY_SIZE(au1xxx_usb_otg_resources), |
| 235 | .resource = au1xxx_usb_otg_resources, |
| 236 | }; |
| 237 | |
Pete Popov | 64abf64 | 2005-09-14 16:17:59 +0000 | [diff] [blame] | 238 | static 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 Hongyang | 284901a | 2009-04-06 19:01:15 -0700 | [diff] [blame] | 251 | static u64 au1200_lcd_dmamask = DMA_BIT_MASK(32); |
Pete Popov | 64abf64 | 2005-09-14 16:17:59 +0000 | [diff] [blame] | 252 | |
| 253 | static struct platform_device au1200_lcd_device = { |
| 254 | .name = "au1200-lcd", |
| 255 | .id = 0, |
| 256 | .dev = { |
| 257 | .dma_mask = &au1200_lcd_dmamask, |
Yang Hongyang | 284901a | 2009-04-06 19:01:15 -0700 | [diff] [blame] | 258 | .coherent_dma_mask = DMA_BIT_MASK(32), |
Pete Popov | 64abf64 | 2005-09-14 16:17:59 +0000 | [diff] [blame] | 259 | }, |
| 260 | .num_resources = ARRAY_SIZE(au1200_lcd_resources), |
| 261 | .resource = au1200_lcd_resources, |
| 262 | }; |
Pete Popov | 26a940e | 2005-09-15 08:03:12 +0000 | [diff] [blame] | 263 | |
Yang Hongyang | 284901a | 2009-04-06 19:01:15 -0700 | [diff] [blame] | 264 | static u64 au1xxx_mmc_dmamask = DMA_BIT_MASK(32); |
Pete Popov | ba264b3 | 2005-09-21 06:18:27 +0000 | [diff] [blame] | 265 | |
Manuel Lauss | f591eb1 | 2008-10-21 08:59:14 +0200 | [diff] [blame] | 266 | extern struct au1xmmc_platform_data au1xmmc_platdata[2]; |
| 267 | |
| 268 | static 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 | |
| 291 | static struct platform_device au1200_mmc0_device = { |
Pete Popov | ba264b3 | 2005-09-21 06:18:27 +0000 | [diff] [blame] | 292 | .name = "au1xxx-mmc", |
| 293 | .id = 0, |
| 294 | .dev = { |
Manuel Lauss | f591eb1 | 2008-10-21 08:59:14 +0200 | [diff] [blame] | 295 | .dma_mask = &au1xxx_mmc_dmamask, |
Yang Hongyang | 284901a | 2009-04-06 19:01:15 -0700 | [diff] [blame] | 296 | .coherent_dma_mask = DMA_BIT_MASK(32), |
Manuel Lauss | f591eb1 | 2008-10-21 08:59:14 +0200 | [diff] [blame] | 297 | .platform_data = &au1xmmc_platdata[0], |
Pete Popov | ba264b3 | 2005-09-21 06:18:27 +0000 | [diff] [blame] | 298 | }, |
Manuel Lauss | f591eb1 | 2008-10-21 08:59:14 +0200 | [diff] [blame] | 299 | .num_resources = ARRAY_SIZE(au1200_mmc0_resources), |
| 300 | .resource = au1200_mmc0_resources, |
Pete Popov | ba264b3 | 2005-09-21 06:18:27 +0000 | [diff] [blame] | 301 | }; |
Manuel Lauss | f591eb1 | 2008-10-21 08:59:14 +0200 | [diff] [blame] | 302 | |
| 303 | #ifndef CONFIG_MIPS_DB1200 |
| 304 | static 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 | |
| 327 | static struct platform_device au1200_mmc1_device = { |
| 328 | .name = "au1xxx-mmc", |
| 329 | .id = 1, |
| 330 | .dev = { |
| 331 | .dma_mask = &au1xxx_mmc_dmamask, |
Yang Hongyang | 284901a | 2009-04-06 19:01:15 -0700 | [diff] [blame] | 332 | .coherent_dma_mask = DMA_BIT_MASK(32), |
Manuel Lauss | f591eb1 | 2008-10-21 08:59:14 +0200 | [diff] [blame] | 333 | .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 Popov | ba264b3 | 2005-09-21 06:18:27 +0000 | [diff] [blame] | 339 | #endif /* #ifdef CONFIG_SOC_AU1200 */ |
| 340 | |
Manuel Lauss | 8b798c4 | 2008-01-27 18:14:52 +0100 | [diff] [blame] | 341 | /* All Alchemy demoboards with I2C have this #define in their headers */ |
| 342 | #ifdef SMBUS_PSC_BASE |
| 343 | static struct resource pbdb_smbus_resources[] = { |
| 344 | { |
Sergei Shtylyov | 8e07c2c | 2008-04-05 22:16:21 +0400 | [diff] [blame] | 345 | .start = CPHYSADDR(SMBUS_PSC_BASE), |
| 346 | .end = CPHYSADDR(SMBUS_PSC_BASE + 0xfffff), |
Manuel Lauss | 8b798c4 | 2008-01-27 18:14:52 +0100 | [diff] [blame] | 347 | .flags = IORESOURCE_MEM, |
| 348 | }, |
| 349 | }; |
| 350 | |
| 351 | static 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 Fainelli | 66f75cc | 2009-11-10 01:13:30 +0100 | [diff] [blame] | 359 | /* 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 | |
| 377 | static 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 Fainelli | 66f75cc | 2009-11-10 01:13:30 +0100 | [diff] [blame] | 389 | |
| 390 | static struct au1000_eth_platform_data au1xxx_eth0_platform_data = { |
| 391 | .phy1_search_mac0 = 1, |
| 392 | }; |
| 393 | |
| 394 | static 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 Lauss | acc4d24 | 2010-02-26 17:22:02 +0100 | [diff] [blame] | 403 | static 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 Fainelli | 66f75cc | 2009-11-10 01:13:30 +0100 | [diff] [blame] | 413 | static struct au1000_eth_platform_data au1xxx_eth1_platform_data = { |
| 414 | .phy1_search_mac0 = 1, |
| 415 | }; |
| 416 | |
| 417 | static 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 | |
| 426 | void __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 Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 442 | static struct platform_device *au1xxx_platform_devices[] __initdata = { |
Sergei Shtylyov | 6e76645 | 2008-04-04 00:02:53 +0400 | [diff] [blame] | 443 | &au1xx0_uart_device, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 444 | &au1xxx_usb_ohci_device, |
Pete Popov | 3b495f2 | 2005-04-04 01:06:19 +0000 | [diff] [blame] | 445 | #ifdef CONFIG_FB_AU1100 |
| 446 | &au1100_lcd_device, |
| 447 | #endif |
Pete Popov | 64abf64 | 2005-09-14 16:17:59 +0000 | [diff] [blame] | 448 | #ifdef CONFIG_SOC_AU1200 |
Pete Popov | 64abf64 | 2005-09-14 16:17:59 +0000 | [diff] [blame] | 449 | &au1xxx_usb_ehci_device, |
Pete Popov | 64abf64 | 2005-09-14 16:17:59 +0000 | [diff] [blame] | 450 | &au1xxx_usb_gdt_device, |
| 451 | &au1xxx_usb_otg_device, |
| 452 | &au1200_lcd_device, |
Manuel Lauss | f591eb1 | 2008-10-21 08:59:14 +0200 | [diff] [blame] | 453 | &au1200_mmc0_device, |
| 454 | #ifndef CONFIG_MIPS_DB1200 |
| 455 | &au1200_mmc1_device, |
| 456 | #endif |
Pete Popov | 64abf64 | 2005-09-14 16:17:59 +0000 | [diff] [blame] | 457 | #endif |
Manuel Lauss | 8b798c4 | 2008-01-27 18:14:52 +0100 | [diff] [blame] | 458 | #ifdef SMBUS_PSC_BASE |
| 459 | &pbdb_smbus_device, |
| 460 | #endif |
Florian Fainelli | 66f75cc | 2009-11-10 01:13:30 +0100 | [diff] [blame] | 461 | &au1xxx_eth0_device, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 462 | }; |
| 463 | |
Sergei Shtylyov | c1dcb14 | 2008-04-30 23:18:41 +0400 | [diff] [blame] | 464 | static int __init au1xxx_platform_init(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 465 | { |
Sergei Shtylyov | 6e76645 | 2008-04-04 00:02:53 +0400 | [diff] [blame] | 466 | unsigned int uartclk = get_au1x00_uart_baud_base() * 16; |
Wolfgang Grandegger | 0d5977d | 2010-07-17 16:38:48 +0200 | [diff] [blame] | 467 | int err, i; |
Manuel Lauss | f667365 | 2010-07-21 14:30:50 +0200 | [diff] [blame] | 468 | unsigned char ethaddr[6]; |
Sergei Shtylyov | 6e76645 | 2008-04-04 00:02:53 +0400 | [diff] [blame] | 469 | |
| 470 | /* Fill up uartclk. */ |
Sergei Shtylyov | c1dcb14 | 2008-04-30 23:18:41 +0400 | [diff] [blame] | 471 | for (i = 0; au1x00_uart_data[i].flags; i++) |
Sergei Shtylyov | 6e76645 | 2008-04-04 00:02:53 +0400 | [diff] [blame] | 472 | au1x00_uart_data[i].uartclk = uartclk; |
| 473 | |
Manuel Lauss | f667365 | 2010-07-21 14:30:50 +0200 | [diff] [blame] | 474 | /* 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 Grandegger | 0d5977d | 2010-07-17 16:38:48 +0200 | [diff] [blame] | 479 | err = platform_add_devices(au1xxx_platform_devices, |
| 480 | ARRAY_SIZE(au1xxx_platform_devices)); |
Florian Fainelli | 66f75cc | 2009-11-10 01:13:30 +0100 | [diff] [blame] | 481 | #ifndef CONFIG_SOC_AU1100 |
Manuel Lauss | f667365 | 2010-07-21 14:30:50 +0200 | [diff] [blame] | 482 | 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 Fainelli | 66f75cc | 2009-11-10 01:13:30 +0100 | [diff] [blame] | 486 | /* Register second MAC if enabled in pinfunc */ |
Wolfgang Grandegger | 0d5977d | 2010-07-17 16:38:48 +0200 | [diff] [blame] | 487 | if (!err && !(au_readl(SYS_PINFUNC) & (u32)SYS_PF_NI2)) |
Manuel Lauss | f667365 | 2010-07-21 14:30:50 +0200 | [diff] [blame] | 488 | err = platform_device_register(&au1xxx_eth1_device); |
Florian Fainelli | 66f75cc | 2009-11-10 01:13:30 +0100 | [diff] [blame] | 489 | #endif |
| 490 | |
Wolfgang Grandegger | 0d5977d | 2010-07-17 16:38:48 +0200 | [diff] [blame] | 491 | return err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 492 | } |
| 493 | |
| 494 | arch_initcall(au1xxx_platform_init); |