Lennert Buytenhek | 9dd0b19 | 2008-03-27 14:51:41 -0400 | [diff] [blame] | 1 | /* |
| 2 | * arch/arm/mach-orion5x/common.c |
| 3 | * |
| 4 | * Core functions for Marvell Orion 5x SoCs |
| 5 | * |
| 6 | * Maintainer: Tzachi Perelstein <tzachi@marvell.com> |
| 7 | * |
| 8 | * This file is licensed under the terms of the GNU General Public |
| 9 | * License version 2. This program is licensed "as is" without any |
| 10 | * warranty of any kind, whether express or implied. |
| 11 | */ |
| 12 | |
| 13 | #include <linux/kernel.h> |
| 14 | #include <linux/init.h> |
| 15 | #include <linux/platform_device.h> |
| 16 | #include <linux/serial_8250.h> |
| 17 | #include <linux/mbus.h> |
Lennert Buytenhek | 9dd0b19 | 2008-03-27 14:51:41 -0400 | [diff] [blame] | 18 | #include <linux/mv643xx_i2c.h> |
| 19 | #include <linux/ata_platform.h> |
Lennert Buytenhek | dcf1cec | 2008-09-25 16:23:48 +0200 | [diff] [blame] | 20 | #include <net/dsa.h> |
Lennert Buytenhek | 9dd0b19 | 2008-03-27 14:51:41 -0400 | [diff] [blame] | 21 | #include <asm/page.h> |
| 22 | #include <asm/setup.h> |
| 23 | #include <asm/timex.h> |
| 24 | #include <asm/mach/arch.h> |
| 25 | #include <asm/mach/map.h> |
| 26 | #include <asm/mach/time.h> |
Lennert Buytenhek | 4ee1f6b | 2010-10-15 16:50:26 +0200 | [diff] [blame] | 27 | #include <mach/bridge-regs.h> |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 28 | #include <mach/hardware.h> |
| 29 | #include <mach/orion5x.h> |
Lennert Buytenhek | 6f088f1 | 2008-08-09 13:44:58 +0200 | [diff] [blame] | 30 | #include <plat/ehci-orion.h> |
Saeed Bishara | 1d5a1a6 | 2008-06-16 23:25:12 -1100 | [diff] [blame] | 31 | #include <plat/mv_xor.h> |
Lennert Buytenhek | 6f088f1 | 2008-08-09 13:44:58 +0200 | [diff] [blame] | 32 | #include <plat/orion_nand.h> |
Nicolas Pitre | 3b937a7 | 2009-06-01 13:56:02 -0400 | [diff] [blame] | 33 | #include <plat/orion_wdt.h> |
Lennert Buytenhek | 6f088f1 | 2008-08-09 13:44:58 +0200 | [diff] [blame] | 34 | #include <plat/time.h> |
Andrew Lunn | 28a2b45 | 2011-05-15 13:32:41 +0200 | [diff] [blame] | 35 | #include <plat/common.h> |
Lennert Buytenhek | 9dd0b19 | 2008-03-27 14:51:41 -0400 | [diff] [blame] | 36 | #include "common.h" |
| 37 | |
| 38 | /***************************************************************************** |
| 39 | * I/O Address Mapping |
| 40 | ****************************************************************************/ |
| 41 | static struct map_desc orion5x_io_desc[] __initdata = { |
| 42 | { |
| 43 | .virtual = ORION5X_REGS_VIRT_BASE, |
| 44 | .pfn = __phys_to_pfn(ORION5X_REGS_PHYS_BASE), |
| 45 | .length = ORION5X_REGS_SIZE, |
Lennert Buytenhek | e7068ad | 2008-05-10 16:30:01 +0200 | [diff] [blame] | 46 | .type = MT_DEVICE, |
| 47 | }, { |
Lennert Buytenhek | 9dd0b19 | 2008-03-27 14:51:41 -0400 | [diff] [blame] | 48 | .virtual = ORION5X_PCIE_IO_VIRT_BASE, |
| 49 | .pfn = __phys_to_pfn(ORION5X_PCIE_IO_PHYS_BASE), |
| 50 | .length = ORION5X_PCIE_IO_SIZE, |
Lennert Buytenhek | e7068ad | 2008-05-10 16:30:01 +0200 | [diff] [blame] | 51 | .type = MT_DEVICE, |
| 52 | }, { |
Lennert Buytenhek | 9dd0b19 | 2008-03-27 14:51:41 -0400 | [diff] [blame] | 53 | .virtual = ORION5X_PCI_IO_VIRT_BASE, |
| 54 | .pfn = __phys_to_pfn(ORION5X_PCI_IO_PHYS_BASE), |
| 55 | .length = ORION5X_PCI_IO_SIZE, |
Lennert Buytenhek | e7068ad | 2008-05-10 16:30:01 +0200 | [diff] [blame] | 56 | .type = MT_DEVICE, |
| 57 | }, { |
Lennert Buytenhek | 9dd0b19 | 2008-03-27 14:51:41 -0400 | [diff] [blame] | 58 | .virtual = ORION5X_PCIE_WA_VIRT_BASE, |
| 59 | .pfn = __phys_to_pfn(ORION5X_PCIE_WA_PHYS_BASE), |
| 60 | .length = ORION5X_PCIE_WA_SIZE, |
Lennert Buytenhek | e7068ad | 2008-05-10 16:30:01 +0200 | [diff] [blame] | 61 | .type = MT_DEVICE, |
Lennert Buytenhek | 9dd0b19 | 2008-03-27 14:51:41 -0400 | [diff] [blame] | 62 | }, |
| 63 | }; |
| 64 | |
| 65 | void __init orion5x_map_io(void) |
| 66 | { |
| 67 | iotable_init(orion5x_io_desc, ARRAY_SIZE(orion5x_io_desc)); |
| 68 | } |
| 69 | |
Lennert Buytenhek | 044f6c7 | 2008-04-22 05:37:12 +0200 | [diff] [blame] | 70 | |
Lennert Buytenhek | 9dd0b19 | 2008-03-27 14:51:41 -0400 | [diff] [blame] | 71 | /***************************************************************************** |
Lennert Buytenhek | 044f6c7 | 2008-04-22 05:37:12 +0200 | [diff] [blame] | 72 | * EHCI |
Lennert Buytenhek | 9dd0b19 | 2008-03-27 14:51:41 -0400 | [diff] [blame] | 73 | ****************************************************************************/ |
Lennert Buytenhek | 044f6c7 | 2008-04-22 05:37:12 +0200 | [diff] [blame] | 74 | static struct orion_ehci_data orion5x_ehci_data = { |
| 75 | .dram = &orion5x_mbus_dram_info, |
Ronen Shitrit | fb6f552 | 2008-09-17 10:08:05 +0300 | [diff] [blame] | 76 | .phy_version = EHCI_PHY_ORION, |
Lennert Buytenhek | 9dd0b19 | 2008-03-27 14:51:41 -0400 | [diff] [blame] | 77 | }; |
| 78 | |
Andrew Lunn | 5c60255 | 2011-05-15 13:32:40 +0200 | [diff] [blame] | 79 | static u64 ehci_dmamask = DMA_BIT_MASK(32); |
Lennert Buytenhek | 9dd0b19 | 2008-03-27 14:51:41 -0400 | [diff] [blame] | 80 | |
Lennert Buytenhek | 9dd0b19 | 2008-03-27 14:51:41 -0400 | [diff] [blame] | 81 | |
Lennert Buytenhek | 044f6c7 | 2008-04-22 05:37:12 +0200 | [diff] [blame] | 82 | /***************************************************************************** |
| 83 | * EHCI0 |
| 84 | ****************************************************************************/ |
Lennert Buytenhek | 9dd0b19 | 2008-03-27 14:51:41 -0400 | [diff] [blame] | 85 | static struct resource orion5x_ehci0_resources[] = { |
| 86 | { |
| 87 | .start = ORION5X_USB0_PHYS_BASE, |
Lennert Buytenhek | 994cab8 | 2008-04-25 16:30:21 -0400 | [diff] [blame] | 88 | .end = ORION5X_USB0_PHYS_BASE + SZ_4K - 1, |
Lennert Buytenhek | 9dd0b19 | 2008-03-27 14:51:41 -0400 | [diff] [blame] | 89 | .flags = IORESOURCE_MEM, |
Lennert Buytenhek | e7068ad | 2008-05-10 16:30:01 +0200 | [diff] [blame] | 90 | }, { |
Lennert Buytenhek | 9dd0b19 | 2008-03-27 14:51:41 -0400 | [diff] [blame] | 91 | .start = IRQ_ORION5X_USB0_CTRL, |
| 92 | .end = IRQ_ORION5X_USB0_CTRL, |
| 93 | .flags = IORESOURCE_IRQ, |
| 94 | }, |
| 95 | }; |
| 96 | |
Lennert Buytenhek | 9dd0b19 | 2008-03-27 14:51:41 -0400 | [diff] [blame] | 97 | static struct platform_device orion5x_ehci0 = { |
| 98 | .name = "orion-ehci", |
| 99 | .id = 0, |
| 100 | .dev = { |
| 101 | .dma_mask = &ehci_dmamask, |
Andrew Lunn | 5c60255 | 2011-05-15 13:32:40 +0200 | [diff] [blame] | 102 | .coherent_dma_mask = DMA_BIT_MASK(32), |
Lennert Buytenhek | 9dd0b19 | 2008-03-27 14:51:41 -0400 | [diff] [blame] | 103 | .platform_data = &orion5x_ehci_data, |
| 104 | }, |
| 105 | .resource = orion5x_ehci0_resources, |
| 106 | .num_resources = ARRAY_SIZE(orion5x_ehci0_resources), |
| 107 | }; |
| 108 | |
Lennert Buytenhek | 044f6c7 | 2008-04-22 05:37:12 +0200 | [diff] [blame] | 109 | void __init orion5x_ehci0_init(void) |
| 110 | { |
| 111 | platform_device_register(&orion5x_ehci0); |
| 112 | } |
| 113 | |
| 114 | |
| 115 | /***************************************************************************** |
| 116 | * EHCI1 |
| 117 | ****************************************************************************/ |
| 118 | static struct resource orion5x_ehci1_resources[] = { |
| 119 | { |
| 120 | .start = ORION5X_USB1_PHYS_BASE, |
| 121 | .end = ORION5X_USB1_PHYS_BASE + SZ_4K - 1, |
| 122 | .flags = IORESOURCE_MEM, |
| 123 | }, { |
| 124 | .start = IRQ_ORION5X_USB1_CTRL, |
| 125 | .end = IRQ_ORION5X_USB1_CTRL, |
| 126 | .flags = IORESOURCE_IRQ, |
| 127 | }, |
| 128 | }; |
| 129 | |
Lennert Buytenhek | 9dd0b19 | 2008-03-27 14:51:41 -0400 | [diff] [blame] | 130 | static struct platform_device orion5x_ehci1 = { |
| 131 | .name = "orion-ehci", |
| 132 | .id = 1, |
| 133 | .dev = { |
| 134 | .dma_mask = &ehci_dmamask, |
Andrew Lunn | 5c60255 | 2011-05-15 13:32:40 +0200 | [diff] [blame] | 135 | .coherent_dma_mask = DMA_BIT_MASK(32), |
Lennert Buytenhek | 9dd0b19 | 2008-03-27 14:51:41 -0400 | [diff] [blame] | 136 | .platform_data = &orion5x_ehci_data, |
| 137 | }, |
| 138 | .resource = orion5x_ehci1_resources, |
| 139 | .num_resources = ARRAY_SIZE(orion5x_ehci1_resources), |
| 140 | }; |
| 141 | |
Lennert Buytenhek | 044f6c7 | 2008-04-22 05:37:12 +0200 | [diff] [blame] | 142 | void __init orion5x_ehci1_init(void) |
| 143 | { |
| 144 | platform_device_register(&orion5x_ehci1); |
| 145 | } |
Lennert Buytenhek | 9dd0b19 | 2008-03-27 14:51:41 -0400 | [diff] [blame] | 146 | |
Lennert Buytenhek | 044f6c7 | 2008-04-22 05:37:12 +0200 | [diff] [blame] | 147 | |
| 148 | /***************************************************************************** |
Andrew Lunn | 5c60255 | 2011-05-15 13:32:40 +0200 | [diff] [blame] | 149 | * GE00 |
Lennert Buytenhek | 044f6c7 | 2008-04-22 05:37:12 +0200 | [diff] [blame] | 150 | ****************************************************************************/ |
Lennert Buytenhek | 9dd0b19 | 2008-03-27 14:51:41 -0400 | [diff] [blame] | 151 | void __init orion5x_eth_init(struct mv643xx_eth_platform_data *eth_data) |
| 152 | { |
Andrew Lunn | 7e3819d | 2011-05-15 13:32:44 +0200 | [diff] [blame] | 153 | orion_ge00_init(eth_data, &orion5x_mbus_dram_info, |
| 154 | ORION5X_ETH_PHYS_BASE, IRQ_ORION5X_ETH_SUM, |
| 155 | IRQ_ORION5X_ETH_ERR, orion5x_tclk); |
Lennert Buytenhek | 9dd0b19 | 2008-03-27 14:51:41 -0400 | [diff] [blame] | 156 | } |
| 157 | |
Lennert Buytenhek | 9dd0b19 | 2008-03-27 14:51:41 -0400 | [diff] [blame] | 158 | |
Lennert Buytenhek | 044f6c7 | 2008-04-22 05:37:12 +0200 | [diff] [blame] | 159 | /***************************************************************************** |
Lennert Buytenhek | dcf1cec | 2008-09-25 16:23:48 +0200 | [diff] [blame] | 160 | * Ethernet switch |
| 161 | ****************************************************************************/ |
Lennert Buytenhek | dcf1cec | 2008-09-25 16:23:48 +0200 | [diff] [blame] | 162 | void __init orion5x_eth_switch_init(struct dsa_platform_data *d, int irq) |
| 163 | { |
Andrew Lunn | 7e3819d | 2011-05-15 13:32:44 +0200 | [diff] [blame] | 164 | orion_ge00_switch_init(d, irq); |
Lennert Buytenhek | dcf1cec | 2008-09-25 16:23:48 +0200 | [diff] [blame] | 165 | } |
| 166 | |
| 167 | |
| 168 | /***************************************************************************** |
Lennert Buytenhek | 044f6c7 | 2008-04-22 05:37:12 +0200 | [diff] [blame] | 169 | * I2C |
| 170 | ****************************************************************************/ |
Lennert Buytenhek | 044f6c7 | 2008-04-22 05:37:12 +0200 | [diff] [blame] | 171 | void __init orion5x_i2c_init(void) |
| 172 | { |
Andrew Lunn | aac7ffa | 2011-05-15 13:32:45 +0200 | [diff] [blame] | 173 | orion_i2c_init(I2C_PHYS_BASE, IRQ_ORION5X_I2C, 8); |
| 174 | |
Lennert Buytenhek | 044f6c7 | 2008-04-22 05:37:12 +0200 | [diff] [blame] | 175 | } |
| 176 | |
| 177 | |
Lennert Buytenhek | 9dd0b19 | 2008-03-27 14:51:41 -0400 | [diff] [blame] | 178 | /***************************************************************************** |
Lennert Buytenhek | 044f6c7 | 2008-04-22 05:37:12 +0200 | [diff] [blame] | 179 | * SATA |
Lennert Buytenhek | 9dd0b19 | 2008-03-27 14:51:41 -0400 | [diff] [blame] | 180 | ****************************************************************************/ |
| 181 | static struct resource orion5x_sata_resources[] = { |
Lennert Buytenhek | 9dd0b19 | 2008-03-27 14:51:41 -0400 | [diff] [blame] | 182 | { |
Lennert Buytenhek | e7068ad | 2008-05-10 16:30:01 +0200 | [diff] [blame] | 183 | .name = "sata base", |
| 184 | .start = ORION5X_SATA_PHYS_BASE, |
| 185 | .end = ORION5X_SATA_PHYS_BASE + 0x5000 - 1, |
| 186 | .flags = IORESOURCE_MEM, |
| 187 | }, { |
| 188 | .name = "sata irq", |
| 189 | .start = IRQ_ORION5X_SATA, |
| 190 | .end = IRQ_ORION5X_SATA, |
| 191 | .flags = IORESOURCE_IRQ, |
| 192 | }, |
Lennert Buytenhek | 9dd0b19 | 2008-03-27 14:51:41 -0400 | [diff] [blame] | 193 | }; |
| 194 | |
| 195 | static struct platform_device orion5x_sata = { |
Lennert Buytenhek | e7068ad | 2008-05-10 16:30:01 +0200 | [diff] [blame] | 196 | .name = "sata_mv", |
| 197 | .id = 0, |
Lennert Buytenhek | 9dd0b19 | 2008-03-27 14:51:41 -0400 | [diff] [blame] | 198 | .dev = { |
Andrew Lunn | 5c60255 | 2011-05-15 13:32:40 +0200 | [diff] [blame] | 199 | .coherent_dma_mask = DMA_BIT_MASK(32), |
Lennert Buytenhek | 9dd0b19 | 2008-03-27 14:51:41 -0400 | [diff] [blame] | 200 | }, |
Lennert Buytenhek | e7068ad | 2008-05-10 16:30:01 +0200 | [diff] [blame] | 201 | .num_resources = ARRAY_SIZE(orion5x_sata_resources), |
| 202 | .resource = orion5x_sata_resources, |
Lennert Buytenhek | 9dd0b19 | 2008-03-27 14:51:41 -0400 | [diff] [blame] | 203 | }; |
| 204 | |
| 205 | void __init orion5x_sata_init(struct mv_sata_platform_data *sata_data) |
| 206 | { |
| 207 | sata_data->dram = &orion5x_mbus_dram_info; |
| 208 | orion5x_sata.dev.platform_data = sata_data; |
| 209 | platform_device_register(&orion5x_sata); |
| 210 | } |
| 211 | |
Lennert Buytenhek | 044f6c7 | 2008-04-22 05:37:12 +0200 | [diff] [blame] | 212 | |
| 213 | /***************************************************************************** |
Lennert Buytenhek | d323ade | 2008-08-29 06:55:06 +0200 | [diff] [blame] | 214 | * SPI |
| 215 | ****************************************************************************/ |
Lennert Buytenhek | d323ade | 2008-08-29 06:55:06 +0200 | [diff] [blame] | 216 | void __init orion5x_spi_init() |
| 217 | { |
Andrew Lunn | 980f9f6 | 2011-05-15 13:32:46 +0200 | [diff] [blame^] | 218 | orion_spi_init(SPI_PHYS_BASE, orion5x_tclk); |
Lennert Buytenhek | d323ade | 2008-08-29 06:55:06 +0200 | [diff] [blame] | 219 | } |
| 220 | |
| 221 | |
| 222 | /***************************************************************************** |
Lennert Buytenhek | 044f6c7 | 2008-04-22 05:37:12 +0200 | [diff] [blame] | 223 | * UART0 |
| 224 | ****************************************************************************/ |
Lennert Buytenhek | 044f6c7 | 2008-04-22 05:37:12 +0200 | [diff] [blame] | 225 | void __init orion5x_uart0_init(void) |
| 226 | { |
Andrew Lunn | 28a2b45 | 2011-05-15 13:32:41 +0200 | [diff] [blame] | 227 | orion_uart0_init(UART0_VIRT_BASE, UART0_PHYS_BASE, |
| 228 | IRQ_ORION5X_UART0, orion5x_tclk); |
Lennert Buytenhek | 044f6c7 | 2008-04-22 05:37:12 +0200 | [diff] [blame] | 229 | } |
| 230 | |
Lennert Buytenhek | 044f6c7 | 2008-04-22 05:37:12 +0200 | [diff] [blame] | 231 | /***************************************************************************** |
| 232 | * UART1 |
| 233 | ****************************************************************************/ |
Lennert Buytenhek | 044f6c7 | 2008-04-22 05:37:12 +0200 | [diff] [blame] | 234 | void __init orion5x_uart1_init(void) |
| 235 | { |
Andrew Lunn | 28a2b45 | 2011-05-15 13:32:41 +0200 | [diff] [blame] | 236 | orion_uart1_init(UART1_VIRT_BASE, UART1_PHYS_BASE, |
| 237 | IRQ_ORION5X_UART1, orion5x_tclk); |
Lennert Buytenhek | 044f6c7 | 2008-04-22 05:37:12 +0200 | [diff] [blame] | 238 | } |
| 239 | |
Lennert Buytenhek | 9dd0b19 | 2008-03-27 14:51:41 -0400 | [diff] [blame] | 240 | /***************************************************************************** |
Saeed Bishara | 1d5a1a6 | 2008-06-16 23:25:12 -1100 | [diff] [blame] | 241 | * XOR engine |
| 242 | ****************************************************************************/ |
Saeed Bishara | f45964e | 2009-03-02 17:30:36 +0200 | [diff] [blame] | 243 | struct mv_xor_platform_shared_data orion5x_xor_shared_data = { |
| 244 | .dram = &orion5x_mbus_dram_info, |
| 245 | }; |
| 246 | |
Saeed Bishara | 1d5a1a6 | 2008-06-16 23:25:12 -1100 | [diff] [blame] | 247 | static struct resource orion5x_xor_shared_resources[] = { |
| 248 | { |
| 249 | .name = "xor low", |
| 250 | .start = ORION5X_XOR_PHYS_BASE, |
| 251 | .end = ORION5X_XOR_PHYS_BASE + 0xff, |
| 252 | .flags = IORESOURCE_MEM, |
| 253 | }, { |
| 254 | .name = "xor high", |
| 255 | .start = ORION5X_XOR_PHYS_BASE + 0x200, |
| 256 | .end = ORION5X_XOR_PHYS_BASE + 0x2ff, |
| 257 | .flags = IORESOURCE_MEM, |
| 258 | }, |
| 259 | }; |
| 260 | |
| 261 | static struct platform_device orion5x_xor_shared = { |
| 262 | .name = MV_XOR_SHARED_NAME, |
| 263 | .id = 0, |
Saeed Bishara | f45964e | 2009-03-02 17:30:36 +0200 | [diff] [blame] | 264 | .dev = { |
| 265 | .platform_data = &orion5x_xor_shared_data, |
| 266 | }, |
Saeed Bishara | 1d5a1a6 | 2008-06-16 23:25:12 -1100 | [diff] [blame] | 267 | .num_resources = ARRAY_SIZE(orion5x_xor_shared_resources), |
| 268 | .resource = orion5x_xor_shared_resources, |
| 269 | }; |
| 270 | |
Yang Hongyang | 284901a | 2009-04-06 19:01:15 -0700 | [diff] [blame] | 271 | static u64 orion5x_xor_dmamask = DMA_BIT_MASK(32); |
Saeed Bishara | 1d5a1a6 | 2008-06-16 23:25:12 -1100 | [diff] [blame] | 272 | |
| 273 | static struct resource orion5x_xor0_resources[] = { |
| 274 | [0] = { |
| 275 | .start = IRQ_ORION5X_XOR0, |
| 276 | .end = IRQ_ORION5X_XOR0, |
| 277 | .flags = IORESOURCE_IRQ, |
| 278 | }, |
| 279 | }; |
| 280 | |
| 281 | static struct mv_xor_platform_data orion5x_xor0_data = { |
| 282 | .shared = &orion5x_xor_shared, |
| 283 | .hw_id = 0, |
| 284 | .pool_size = PAGE_SIZE, |
| 285 | }; |
| 286 | |
| 287 | static struct platform_device orion5x_xor0_channel = { |
| 288 | .name = MV_XOR_NAME, |
| 289 | .id = 0, |
| 290 | .num_resources = ARRAY_SIZE(orion5x_xor0_resources), |
| 291 | .resource = orion5x_xor0_resources, |
| 292 | .dev = { |
| 293 | .dma_mask = &orion5x_xor_dmamask, |
Yang Hongyang | 6a35528 | 2009-04-06 19:01:13 -0700 | [diff] [blame] | 294 | .coherent_dma_mask = DMA_BIT_MASK(64), |
H Hartley Sweeten | ef4a677 | 2010-01-29 14:56:58 -0800 | [diff] [blame] | 295 | .platform_data = &orion5x_xor0_data, |
Saeed Bishara | 1d5a1a6 | 2008-06-16 23:25:12 -1100 | [diff] [blame] | 296 | }, |
| 297 | }; |
| 298 | |
| 299 | static struct resource orion5x_xor1_resources[] = { |
| 300 | [0] = { |
| 301 | .start = IRQ_ORION5X_XOR1, |
| 302 | .end = IRQ_ORION5X_XOR1, |
| 303 | .flags = IORESOURCE_IRQ, |
| 304 | }, |
| 305 | }; |
| 306 | |
| 307 | static struct mv_xor_platform_data orion5x_xor1_data = { |
| 308 | .shared = &orion5x_xor_shared, |
| 309 | .hw_id = 1, |
| 310 | .pool_size = PAGE_SIZE, |
| 311 | }; |
| 312 | |
| 313 | static struct platform_device orion5x_xor1_channel = { |
| 314 | .name = MV_XOR_NAME, |
| 315 | .id = 1, |
| 316 | .num_resources = ARRAY_SIZE(orion5x_xor1_resources), |
| 317 | .resource = orion5x_xor1_resources, |
| 318 | .dev = { |
| 319 | .dma_mask = &orion5x_xor_dmamask, |
Yang Hongyang | 6a35528 | 2009-04-06 19:01:13 -0700 | [diff] [blame] | 320 | .coherent_dma_mask = DMA_BIT_MASK(64), |
H Hartley Sweeten | ef4a677 | 2010-01-29 14:56:58 -0800 | [diff] [blame] | 321 | .platform_data = &orion5x_xor1_data, |
Saeed Bishara | 1d5a1a6 | 2008-06-16 23:25:12 -1100 | [diff] [blame] | 322 | }, |
| 323 | }; |
| 324 | |
| 325 | void __init orion5x_xor_init(void) |
| 326 | { |
| 327 | platform_device_register(&orion5x_xor_shared); |
| 328 | |
| 329 | /* |
| 330 | * two engines can't do memset simultaneously, this limitation |
| 331 | * satisfied by removing memset support from one of the engines. |
| 332 | */ |
| 333 | dma_cap_set(DMA_MEMCPY, orion5x_xor0_data.cap_mask); |
| 334 | dma_cap_set(DMA_XOR, orion5x_xor0_data.cap_mask); |
| 335 | platform_device_register(&orion5x_xor0_channel); |
| 336 | |
| 337 | dma_cap_set(DMA_MEMCPY, orion5x_xor1_data.cap_mask); |
| 338 | dma_cap_set(DMA_MEMSET, orion5x_xor1_data.cap_mask); |
| 339 | dma_cap_set(DMA_XOR, orion5x_xor1_data.cap_mask); |
| 340 | platform_device_register(&orion5x_xor1_channel); |
| 341 | } |
| 342 | |
Sebastian Andrzej Siewior | 3a8f744 | 2009-05-07 22:59:24 +0200 | [diff] [blame] | 343 | static struct resource orion5x_crypto_res[] = { |
| 344 | { |
| 345 | .name = "regs", |
| 346 | .start = ORION5X_CRYPTO_PHYS_BASE, |
| 347 | .end = ORION5X_CRYPTO_PHYS_BASE + 0xffff, |
| 348 | .flags = IORESOURCE_MEM, |
| 349 | }, { |
| 350 | .name = "sram", |
| 351 | .start = ORION5X_SRAM_PHYS_BASE, |
| 352 | .end = ORION5X_SRAM_PHYS_BASE + SZ_8K - 1, |
| 353 | .flags = IORESOURCE_MEM, |
| 354 | }, { |
| 355 | .name = "crypto interrupt", |
| 356 | .start = IRQ_ORION5X_CESA, |
| 357 | .end = IRQ_ORION5X_CESA, |
| 358 | .flags = IORESOURCE_IRQ, |
| 359 | }, |
| 360 | }; |
| 361 | |
| 362 | static struct platform_device orion5x_crypto_device = { |
| 363 | .name = "mv_crypto", |
| 364 | .id = -1, |
| 365 | .num_resources = ARRAY_SIZE(orion5x_crypto_res), |
| 366 | .resource = orion5x_crypto_res, |
| 367 | }; |
| 368 | |
Nicolas Pitre | 3fade49 | 2009-06-11 22:27:20 +0200 | [diff] [blame] | 369 | static int __init orion5x_crypto_init(void) |
Sebastian Andrzej Siewior | 3a8f744 | 2009-05-07 22:59:24 +0200 | [diff] [blame] | 370 | { |
| 371 | int ret; |
| 372 | |
| 373 | ret = orion5x_setup_sram_win(); |
| 374 | if (ret) |
| 375 | return ret; |
| 376 | |
| 377 | return platform_device_register(&orion5x_crypto_device); |
| 378 | } |
Saeed Bishara | 1d5a1a6 | 2008-06-16 23:25:12 -1100 | [diff] [blame] | 379 | |
| 380 | /***************************************************************************** |
Thomas Reitmayr | 9e058d4 | 2009-02-24 14:59:22 -0800 | [diff] [blame] | 381 | * Watchdog |
| 382 | ****************************************************************************/ |
Nicolas Pitre | 3b937a7 | 2009-06-01 13:56:02 -0400 | [diff] [blame] | 383 | static struct orion_wdt_platform_data orion5x_wdt_data = { |
Thomas Reitmayr | 9e058d4 | 2009-02-24 14:59:22 -0800 | [diff] [blame] | 384 | .tclk = 0, |
| 385 | }; |
| 386 | |
| 387 | static struct platform_device orion5x_wdt_device = { |
Nicolas Pitre | 3b937a7 | 2009-06-01 13:56:02 -0400 | [diff] [blame] | 388 | .name = "orion_wdt", |
Thomas Reitmayr | 9e058d4 | 2009-02-24 14:59:22 -0800 | [diff] [blame] | 389 | .id = -1, |
| 390 | .dev = { |
| 391 | .platform_data = &orion5x_wdt_data, |
| 392 | }, |
| 393 | .num_resources = 0, |
| 394 | }; |
| 395 | |
| 396 | void __init orion5x_wdt_init(void) |
| 397 | { |
| 398 | orion5x_wdt_data.tclk = orion5x_tclk; |
| 399 | platform_device_register(&orion5x_wdt_device); |
| 400 | } |
| 401 | |
| 402 | |
| 403 | /***************************************************************************** |
Lennert Buytenhek | 9dd0b19 | 2008-03-27 14:51:41 -0400 | [diff] [blame] | 404 | * Time handling |
| 405 | ****************************************************************************/ |
Lennert Buytenhek | 4ee1f6b | 2010-10-15 16:50:26 +0200 | [diff] [blame] | 406 | void __init orion5x_init_early(void) |
| 407 | { |
| 408 | orion_time_set_base(TIMER_VIRT_BASE); |
| 409 | } |
| 410 | |
Lennert Buytenhek | ebe35af | 2008-08-29 05:55:51 +0200 | [diff] [blame] | 411 | int orion5x_tclk; |
| 412 | |
| 413 | int __init orion5x_find_tclk(void) |
| 414 | { |
Lennert Buytenhek | d323ade | 2008-08-29 06:55:06 +0200 | [diff] [blame] | 415 | u32 dev, rev; |
| 416 | |
| 417 | orion5x_pcie_id(&dev, &rev); |
| 418 | if (dev == MV88F6183_DEV_ID && |
| 419 | (readl(MPP_RESET_SAMPLE) & 0x00000200) == 0) |
| 420 | return 133333333; |
| 421 | |
Lennert Buytenhek | ebe35af | 2008-08-29 05:55:51 +0200 | [diff] [blame] | 422 | return 166666667; |
| 423 | } |
| 424 | |
Lennert Buytenhek | 9dd0b19 | 2008-03-27 14:51:41 -0400 | [diff] [blame] | 425 | static void orion5x_timer_init(void) |
| 426 | { |
Lennert Buytenhek | ebe35af | 2008-08-29 05:55:51 +0200 | [diff] [blame] | 427 | orion5x_tclk = orion5x_find_tclk(); |
Lennert Buytenhek | 4ee1f6b | 2010-10-15 16:50:26 +0200 | [diff] [blame] | 428 | |
| 429 | orion_time_init(ORION5X_BRIDGE_VIRT_BASE, BRIDGE_INT_TIMER1_CLR, |
| 430 | IRQ_ORION5X_BRIDGE, orion5x_tclk); |
Lennert Buytenhek | 9dd0b19 | 2008-03-27 14:51:41 -0400 | [diff] [blame] | 431 | } |
| 432 | |
| 433 | struct sys_timer orion5x_timer = { |
Lennert Buytenhek | e7068ad | 2008-05-10 16:30:01 +0200 | [diff] [blame] | 434 | .init = orion5x_timer_init, |
Lennert Buytenhek | 9dd0b19 | 2008-03-27 14:51:41 -0400 | [diff] [blame] | 435 | }; |
| 436 | |
Lennert Buytenhek | 044f6c7 | 2008-04-22 05:37:12 +0200 | [diff] [blame] | 437 | |
Lennert Buytenhek | 9dd0b19 | 2008-03-27 14:51:41 -0400 | [diff] [blame] | 438 | /***************************************************************************** |
| 439 | * General |
| 440 | ****************************************************************************/ |
Lennert Buytenhek | 9dd0b19 | 2008-03-27 14:51:41 -0400 | [diff] [blame] | 441 | /* |
Lennert Buytenhek | b46926b | 2008-04-25 16:31:32 -0400 | [diff] [blame] | 442 | * Identify device ID and rev from PCIe configuration header space '0'. |
Lennert Buytenhek | 9dd0b19 | 2008-03-27 14:51:41 -0400 | [diff] [blame] | 443 | */ |
| 444 | static void __init orion5x_id(u32 *dev, u32 *rev, char **dev_name) |
| 445 | { |
| 446 | orion5x_pcie_id(dev, rev); |
| 447 | |
| 448 | if (*dev == MV88F5281_DEV_ID) { |
| 449 | if (*rev == MV88F5281_REV_D2) { |
| 450 | *dev_name = "MV88F5281-D2"; |
| 451 | } else if (*rev == MV88F5281_REV_D1) { |
| 452 | *dev_name = "MV88F5281-D1"; |
Lennert Buytenhek | ce72e36e | 2008-08-09 15:17:27 +0200 | [diff] [blame] | 453 | } else if (*rev == MV88F5281_REV_D0) { |
| 454 | *dev_name = "MV88F5281-D0"; |
Lennert Buytenhek | 9dd0b19 | 2008-03-27 14:51:41 -0400 | [diff] [blame] | 455 | } else { |
| 456 | *dev_name = "MV88F5281-Rev-Unsupported"; |
| 457 | } |
| 458 | } else if (*dev == MV88F5182_DEV_ID) { |
| 459 | if (*rev == MV88F5182_REV_A2) { |
| 460 | *dev_name = "MV88F5182-A2"; |
| 461 | } else { |
| 462 | *dev_name = "MV88F5182-Rev-Unsupported"; |
| 463 | } |
| 464 | } else if (*dev == MV88F5181_DEV_ID) { |
| 465 | if (*rev == MV88F5181_REV_B1) { |
| 466 | *dev_name = "MV88F5181-Rev-B1"; |
Lennert Buytenhek | d2b2a6b | 2008-05-31 08:30:40 +0200 | [diff] [blame] | 467 | } else if (*rev == MV88F5181L_REV_A1) { |
| 468 | *dev_name = "MV88F5181L-Rev-A1"; |
Lennert Buytenhek | 9dd0b19 | 2008-03-27 14:51:41 -0400 | [diff] [blame] | 469 | } else { |
Lennert Buytenhek | d2b2a6b | 2008-05-31 08:30:40 +0200 | [diff] [blame] | 470 | *dev_name = "MV88F5181(L)-Rev-Unsupported"; |
Lennert Buytenhek | 9dd0b19 | 2008-03-27 14:51:41 -0400 | [diff] [blame] | 471 | } |
Lennert Buytenhek | d323ade | 2008-08-29 06:55:06 +0200 | [diff] [blame] | 472 | } else if (*dev == MV88F6183_DEV_ID) { |
| 473 | if (*rev == MV88F6183_REV_B0) { |
| 474 | *dev_name = "MV88F6183-Rev-B0"; |
| 475 | } else { |
| 476 | *dev_name = "MV88F6183-Rev-Unsupported"; |
| 477 | } |
Lennert Buytenhek | 9dd0b19 | 2008-03-27 14:51:41 -0400 | [diff] [blame] | 478 | } else { |
| 479 | *dev_name = "Device-Unknown"; |
| 480 | } |
| 481 | } |
| 482 | |
| 483 | void __init orion5x_init(void) |
| 484 | { |
| 485 | char *dev_name; |
| 486 | u32 dev, rev; |
| 487 | |
| 488 | orion5x_id(&dev, &rev, &dev_name); |
Lennert Buytenhek | ebe35af | 2008-08-29 05:55:51 +0200 | [diff] [blame] | 489 | printk(KERN_INFO "Orion ID: %s. TCLK=%d.\n", dev_name, orion5x_tclk); |
| 490 | |
Lennert Buytenhek | 9dd0b19 | 2008-03-27 14:51:41 -0400 | [diff] [blame] | 491 | /* |
| 492 | * Setup Orion address map |
| 493 | */ |
| 494 | orion5x_setup_cpu_mbus_bridge(); |
Lennert Buytenhek | ce72e36e | 2008-08-09 15:17:27 +0200 | [diff] [blame] | 495 | |
| 496 | /* |
| 497 | * Don't issue "Wait for Interrupt" instruction if we are |
| 498 | * running on D0 5281 silicon. |
| 499 | */ |
| 500 | if (dev == MV88F5281_DEV_ID && rev == MV88F5281_REV_D0) { |
| 501 | printk(KERN_INFO "Orion: Applying 5281 D0 WFI workaround.\n"); |
| 502 | disable_hlt(); |
| 503 | } |
Thomas Reitmayr | 9e058d4 | 2009-02-24 14:59:22 -0800 | [diff] [blame] | 504 | |
| 505 | /* |
Nicolas Pitre | 3fade49 | 2009-06-11 22:27:20 +0200 | [diff] [blame] | 506 | * The 5082/5181l/5182/6082/6082l/6183 have crypto |
| 507 | * while 5180n/5181/5281 don't have crypto. |
| 508 | */ |
| 509 | if ((dev == MV88F5181_DEV_ID && rev >= MV88F5181L_REV_A0) || |
| 510 | dev == MV88F5182_DEV_ID || dev == MV88F6183_DEV_ID) |
| 511 | orion5x_crypto_init(); |
| 512 | |
| 513 | /* |
Thomas Reitmayr | 9e058d4 | 2009-02-24 14:59:22 -0800 | [diff] [blame] | 514 | * Register watchdog driver |
| 515 | */ |
| 516 | orion5x_wdt_init(); |
Lennert Buytenhek | 9dd0b19 | 2008-03-27 14:51:41 -0400 | [diff] [blame] | 517 | } |
| 518 | |
| 519 | /* |
| 520 | * Many orion-based systems have buggy bootloader implementations. |
| 521 | * This is a common fixup for bogus memory tags. |
| 522 | */ |
| 523 | void __init tag_fixup_mem32(struct machine_desc *mdesc, struct tag *t, |
| 524 | char **from, struct meminfo *meminfo) |
| 525 | { |
| 526 | for (; t->hdr.size; t = tag_next(t)) |
| 527 | if (t->hdr.tag == ATAG_MEM && |
| 528 | (!t->u.mem.size || t->u.mem.size & ~PAGE_MASK || |
| 529 | t->u.mem.start & ~PAGE_MASK)) { |
| 530 | printk(KERN_WARNING |
| 531 | "Clearing invalid memory bank %dKB@0x%08x\n", |
| 532 | t->u.mem.size / 1024, t->u.mem.start); |
| 533 | t->hdr.tag = 0; |
| 534 | } |
| 535 | } |