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