Stanislav Samsonov | 794d15b | 2008-06-22 22:45:10 +0200 | [diff] [blame] | 1 | /* |
| 2 | * arch/arm/mach-mv78xx0/common.c |
| 3 | * |
| 4 | * Core functions for Marvell MV78xx0 SoCs |
| 5 | * |
| 6 | * This file is licensed under the terms of the GNU General Public |
| 7 | * License version 2. This program is licensed "as is" without any |
| 8 | * warranty of any kind, whether express or implied. |
| 9 | */ |
| 10 | |
| 11 | #include <linux/kernel.h> |
| 12 | #include <linux/init.h> |
| 13 | #include <linux/platform_device.h> |
| 14 | #include <linux/serial_8250.h> |
| 15 | #include <linux/mbus.h> |
Riku Voipio | 6935994 | 2009-03-03 21:13:50 +0200 | [diff] [blame] | 16 | #include <linux/mv643xx_i2c.h> |
Stanislav Samsonov | 794d15b | 2008-06-22 22:45:10 +0200 | [diff] [blame] | 17 | #include <linux/ata_platform.h> |
Lennert Buytenhek | 712424f | 2009-02-20 02:31:58 +0100 | [diff] [blame] | 18 | #include <linux/ethtool.h> |
Stanislav Samsonov | 794d15b | 2008-06-22 22:45:10 +0200 | [diff] [blame] | 19 | #include <asm/mach/map.h> |
| 20 | #include <asm/mach/time.h> |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 21 | #include <mach/mv78xx0.h> |
Nicolas Pitre | fdd8b07 | 2009-04-22 20:08:17 +0100 | [diff] [blame] | 22 | #include <mach/bridge-regs.h> |
Lennert Buytenhek | 6f088f1 | 2008-08-09 13:44:58 +0200 | [diff] [blame] | 23 | #include <plat/cache-feroceon-l2.h> |
| 24 | #include <plat/ehci-orion.h> |
| 25 | #include <plat/orion_nand.h> |
| 26 | #include <plat/time.h> |
Andrew Lunn | 28a2b45 | 2011-05-15 13:32:41 +0200 | [diff] [blame] | 27 | #include <plat/common.h> |
Stanislav Samsonov | 794d15b | 2008-06-22 22:45:10 +0200 | [diff] [blame] | 28 | #include "common.h" |
| 29 | |
Andrew Lunn | 28a2b45 | 2011-05-15 13:32:41 +0200 | [diff] [blame] | 30 | static int get_tclk(void); |
Stanislav Samsonov | 794d15b | 2008-06-22 22:45:10 +0200 | [diff] [blame] | 31 | |
| 32 | /***************************************************************************** |
| 33 | * Common bits |
| 34 | ****************************************************************************/ |
| 35 | int mv78xx0_core_index(void) |
| 36 | { |
| 37 | u32 extra; |
| 38 | |
| 39 | /* |
| 40 | * Read Extra Features register. |
| 41 | */ |
| 42 | __asm__("mrc p15, 1, %0, c15, c1, 0" : "=r" (extra)); |
| 43 | |
| 44 | return !!(extra & 0x00004000); |
| 45 | } |
| 46 | |
| 47 | static int get_hclk(void) |
| 48 | { |
| 49 | int hclk; |
| 50 | |
| 51 | /* |
| 52 | * HCLK tick rate is configured by DEV_D[7:5] pins. |
| 53 | */ |
| 54 | switch ((readl(SAMPLE_AT_RESET_LOW) >> 5) & 7) { |
| 55 | case 0: |
| 56 | hclk = 166666667; |
| 57 | break; |
| 58 | case 1: |
| 59 | hclk = 200000000; |
| 60 | break; |
| 61 | case 2: |
| 62 | hclk = 266666667; |
| 63 | break; |
| 64 | case 3: |
| 65 | hclk = 333333333; |
| 66 | break; |
| 67 | case 4: |
| 68 | hclk = 400000000; |
| 69 | break; |
| 70 | default: |
| 71 | panic("unknown HCLK PLL setting: %.8x\n", |
| 72 | readl(SAMPLE_AT_RESET_LOW)); |
| 73 | } |
| 74 | |
| 75 | return hclk; |
| 76 | } |
| 77 | |
| 78 | static void get_pclk_l2clk(int hclk, int core_index, int *pclk, int *l2clk) |
| 79 | { |
| 80 | u32 cfg; |
| 81 | |
| 82 | /* |
| 83 | * Core #0 PCLK/L2CLK is configured by bits [13:8], core #1 |
| 84 | * PCLK/L2CLK by bits [19:14]. |
| 85 | */ |
| 86 | if (core_index == 0) { |
| 87 | cfg = (readl(SAMPLE_AT_RESET_LOW) >> 8) & 0x3f; |
| 88 | } else { |
| 89 | cfg = (readl(SAMPLE_AT_RESET_LOW) >> 14) & 0x3f; |
| 90 | } |
| 91 | |
| 92 | /* |
| 93 | * Bits [11:8] ([17:14] for core #1) configure the PCLK:HCLK |
| 94 | * ratio (1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5, 5.5, 6). |
| 95 | */ |
| 96 | *pclk = ((u64)hclk * (2 + (cfg & 0xf))) >> 1; |
| 97 | |
| 98 | /* |
| 99 | * Bits [13:12] ([19:18] for core #1) configure the PCLK:L2CLK |
| 100 | * ratio (1, 2, 3). |
| 101 | */ |
| 102 | *l2clk = *pclk / (((cfg >> 4) & 3) + 1); |
| 103 | } |
| 104 | |
| 105 | static int get_tclk(void) |
| 106 | { |
| 107 | int tclk; |
| 108 | |
| 109 | /* |
| 110 | * TCLK tick rate is configured by DEV_A[2:0] strap pins. |
| 111 | */ |
| 112 | switch ((readl(SAMPLE_AT_RESET_HIGH) >> 6) & 7) { |
| 113 | case 1: |
| 114 | tclk = 166666667; |
| 115 | break; |
| 116 | case 3: |
| 117 | tclk = 200000000; |
| 118 | break; |
| 119 | default: |
| 120 | panic("unknown TCLK PLL setting: %.8x\n", |
| 121 | readl(SAMPLE_AT_RESET_HIGH)); |
| 122 | } |
| 123 | |
| 124 | return tclk; |
| 125 | } |
| 126 | |
| 127 | |
| 128 | /***************************************************************************** |
| 129 | * I/O Address Mapping |
| 130 | ****************************************************************************/ |
| 131 | static struct map_desc mv78xx0_io_desc[] __initdata = { |
| 132 | { |
| 133 | .virtual = MV78XX0_CORE_REGS_VIRT_BASE, |
| 134 | .pfn = 0, |
| 135 | .length = MV78XX0_CORE_REGS_SIZE, |
| 136 | .type = MT_DEVICE, |
| 137 | }, { |
| 138 | .virtual = MV78XX0_PCIE_IO_VIRT_BASE(0), |
| 139 | .pfn = __phys_to_pfn(MV78XX0_PCIE_IO_PHYS_BASE(0)), |
| 140 | .length = MV78XX0_PCIE_IO_SIZE * 8, |
| 141 | .type = MT_DEVICE, |
| 142 | }, { |
| 143 | .virtual = MV78XX0_REGS_VIRT_BASE, |
| 144 | .pfn = __phys_to_pfn(MV78XX0_REGS_PHYS_BASE), |
| 145 | .length = MV78XX0_REGS_SIZE, |
| 146 | .type = MT_DEVICE, |
| 147 | }, |
| 148 | }; |
| 149 | |
| 150 | void __init mv78xx0_map_io(void) |
| 151 | { |
| 152 | unsigned long phys; |
| 153 | |
| 154 | /* |
| 155 | * Map the right set of per-core registers depending on |
| 156 | * which core we are running on. |
| 157 | */ |
| 158 | if (mv78xx0_core_index() == 0) { |
| 159 | phys = MV78XX0_CORE0_REGS_PHYS_BASE; |
| 160 | } else { |
| 161 | phys = MV78XX0_CORE1_REGS_PHYS_BASE; |
| 162 | } |
| 163 | mv78xx0_io_desc[0].pfn = __phys_to_pfn(phys); |
| 164 | |
| 165 | iotable_init(mv78xx0_io_desc, ARRAY_SIZE(mv78xx0_io_desc)); |
| 166 | } |
| 167 | |
| 168 | |
| 169 | /***************************************************************************** |
| 170 | * EHCI |
| 171 | ****************************************************************************/ |
| 172 | static struct orion_ehci_data mv78xx0_ehci_data = { |
| 173 | .dram = &mv78xx0_mbus_dram_info, |
Ronen Shitrit | fb6f552 | 2008-09-17 10:08:05 +0300 | [diff] [blame] | 174 | .phy_version = EHCI_PHY_NA, |
Stanislav Samsonov | 794d15b | 2008-06-22 22:45:10 +0200 | [diff] [blame] | 175 | }; |
| 176 | |
Andrew Lunn | 5c60255 | 2011-05-15 13:32:40 +0200 | [diff] [blame] | 177 | static u64 ehci_dmamask = DMA_BIT_MASK(32); |
Stanislav Samsonov | 794d15b | 2008-06-22 22:45:10 +0200 | [diff] [blame] | 178 | |
| 179 | |
| 180 | /***************************************************************************** |
| 181 | * EHCI0 |
| 182 | ****************************************************************************/ |
| 183 | static struct resource mv78xx0_ehci0_resources[] = { |
| 184 | { |
| 185 | .start = USB0_PHYS_BASE, |
Andrew Lunn | 5c60255 | 2011-05-15 13:32:40 +0200 | [diff] [blame] | 186 | .end = USB0_PHYS_BASE + SZ_4K - 1, |
Stanislav Samsonov | 794d15b | 2008-06-22 22:45:10 +0200 | [diff] [blame] | 187 | .flags = IORESOURCE_MEM, |
| 188 | }, { |
| 189 | .start = IRQ_MV78XX0_USB_0, |
| 190 | .end = IRQ_MV78XX0_USB_0, |
| 191 | .flags = IORESOURCE_IRQ, |
| 192 | }, |
| 193 | }; |
| 194 | |
| 195 | static struct platform_device mv78xx0_ehci0 = { |
| 196 | .name = "orion-ehci", |
| 197 | .id = 0, |
| 198 | .dev = { |
| 199 | .dma_mask = &ehci_dmamask, |
Andrew Lunn | 5c60255 | 2011-05-15 13:32:40 +0200 | [diff] [blame] | 200 | .coherent_dma_mask = DMA_BIT_MASK(32), |
Stanislav Samsonov | 794d15b | 2008-06-22 22:45:10 +0200 | [diff] [blame] | 201 | .platform_data = &mv78xx0_ehci_data, |
| 202 | }, |
| 203 | .resource = mv78xx0_ehci0_resources, |
| 204 | .num_resources = ARRAY_SIZE(mv78xx0_ehci0_resources), |
| 205 | }; |
| 206 | |
| 207 | void __init mv78xx0_ehci0_init(void) |
| 208 | { |
| 209 | platform_device_register(&mv78xx0_ehci0); |
| 210 | } |
| 211 | |
| 212 | |
| 213 | /***************************************************************************** |
| 214 | * EHCI1 |
| 215 | ****************************************************************************/ |
| 216 | static struct resource mv78xx0_ehci1_resources[] = { |
| 217 | { |
| 218 | .start = USB1_PHYS_BASE, |
Andrew Lunn | 5c60255 | 2011-05-15 13:32:40 +0200 | [diff] [blame] | 219 | .end = USB1_PHYS_BASE + SZ_4K - 1, |
Stanislav Samsonov | 794d15b | 2008-06-22 22:45:10 +0200 | [diff] [blame] | 220 | .flags = IORESOURCE_MEM, |
| 221 | }, { |
| 222 | .start = IRQ_MV78XX0_USB_1, |
| 223 | .end = IRQ_MV78XX0_USB_1, |
| 224 | .flags = IORESOURCE_IRQ, |
| 225 | }, |
| 226 | }; |
| 227 | |
| 228 | static struct platform_device mv78xx0_ehci1 = { |
| 229 | .name = "orion-ehci", |
| 230 | .id = 1, |
| 231 | .dev = { |
| 232 | .dma_mask = &ehci_dmamask, |
Andrew Lunn | 5c60255 | 2011-05-15 13:32:40 +0200 | [diff] [blame] | 233 | .coherent_dma_mask = DMA_BIT_MASK(32), |
Stanislav Samsonov | 794d15b | 2008-06-22 22:45:10 +0200 | [diff] [blame] | 234 | .platform_data = &mv78xx0_ehci_data, |
| 235 | }, |
| 236 | .resource = mv78xx0_ehci1_resources, |
| 237 | .num_resources = ARRAY_SIZE(mv78xx0_ehci1_resources), |
| 238 | }; |
| 239 | |
| 240 | void __init mv78xx0_ehci1_init(void) |
| 241 | { |
| 242 | platform_device_register(&mv78xx0_ehci1); |
| 243 | } |
| 244 | |
| 245 | |
| 246 | /***************************************************************************** |
| 247 | * EHCI2 |
| 248 | ****************************************************************************/ |
| 249 | static struct resource mv78xx0_ehci2_resources[] = { |
| 250 | { |
| 251 | .start = USB2_PHYS_BASE, |
Andrew Lunn | 5c60255 | 2011-05-15 13:32:40 +0200 | [diff] [blame] | 252 | .end = USB2_PHYS_BASE + SZ_4K - 1, |
Stanislav Samsonov | 794d15b | 2008-06-22 22:45:10 +0200 | [diff] [blame] | 253 | .flags = IORESOURCE_MEM, |
| 254 | }, { |
| 255 | .start = IRQ_MV78XX0_USB_2, |
| 256 | .end = IRQ_MV78XX0_USB_2, |
| 257 | .flags = IORESOURCE_IRQ, |
| 258 | }, |
| 259 | }; |
| 260 | |
| 261 | static struct platform_device mv78xx0_ehci2 = { |
| 262 | .name = "orion-ehci", |
| 263 | .id = 2, |
| 264 | .dev = { |
| 265 | .dma_mask = &ehci_dmamask, |
Andrew Lunn | 5c60255 | 2011-05-15 13:32:40 +0200 | [diff] [blame] | 266 | .coherent_dma_mask = DMA_BIT_MASK(32), |
Stanislav Samsonov | 794d15b | 2008-06-22 22:45:10 +0200 | [diff] [blame] | 267 | .platform_data = &mv78xx0_ehci_data, |
| 268 | }, |
| 269 | .resource = mv78xx0_ehci2_resources, |
| 270 | .num_resources = ARRAY_SIZE(mv78xx0_ehci2_resources), |
| 271 | }; |
| 272 | |
| 273 | void __init mv78xx0_ehci2_init(void) |
| 274 | { |
| 275 | platform_device_register(&mv78xx0_ehci2); |
| 276 | } |
| 277 | |
| 278 | |
| 279 | /***************************************************************************** |
| 280 | * GE00 |
| 281 | ****************************************************************************/ |
Stanislav Samsonov | 794d15b | 2008-06-22 22:45:10 +0200 | [diff] [blame] | 282 | void __init mv78xx0_ge00_init(struct mv643xx_eth_platform_data *eth_data) |
| 283 | { |
Andrew Lunn | 7e3819d | 2011-05-15 13:32:44 +0200 | [diff] [blame^] | 284 | orion_ge00_init(eth_data, &mv78xx0_mbus_dram_info, |
| 285 | GE00_PHYS_BASE, IRQ_MV78XX0_GE00_SUM, |
| 286 | IRQ_MV78XX0_GE_ERR, get_tclk()); |
Stanislav Samsonov | 794d15b | 2008-06-22 22:45:10 +0200 | [diff] [blame] | 287 | } |
| 288 | |
| 289 | |
| 290 | /***************************************************************************** |
| 291 | * GE01 |
| 292 | ****************************************************************************/ |
Stanislav Samsonov | 794d15b | 2008-06-22 22:45:10 +0200 | [diff] [blame] | 293 | void __init mv78xx0_ge01_init(struct mv643xx_eth_platform_data *eth_data) |
| 294 | { |
Andrew Lunn | 7e3819d | 2011-05-15 13:32:44 +0200 | [diff] [blame^] | 295 | orion_ge01_init(eth_data, &mv78xx0_mbus_dram_info, |
| 296 | GE01_PHYS_BASE, IRQ_MV78XX0_GE01_SUM, |
| 297 | NO_IRQ, get_tclk()); |
Stanislav Samsonov | 794d15b | 2008-06-22 22:45:10 +0200 | [diff] [blame] | 298 | } |
| 299 | |
| 300 | |
| 301 | /***************************************************************************** |
| 302 | * GE10 |
| 303 | ****************************************************************************/ |
Stanislav Samsonov | 794d15b | 2008-06-22 22:45:10 +0200 | [diff] [blame] | 304 | void __init mv78xx0_ge10_init(struct mv643xx_eth_platform_data *eth_data) |
| 305 | { |
Lennert Buytenhek | 712424f | 2009-02-20 02:31:58 +0100 | [diff] [blame] | 306 | u32 dev, rev; |
| 307 | |
Lennert Buytenhek | 712424f | 2009-02-20 02:31:58 +0100 | [diff] [blame] | 308 | /* |
| 309 | * On the Z0, ge10 and ge11 are internally connected back |
| 310 | * to back, and not brought out. |
| 311 | */ |
| 312 | mv78xx0_pcie_id(&dev, &rev); |
| 313 | if (dev == MV78X00_Z0_DEV_ID) { |
| 314 | eth_data->phy_addr = MV643XX_ETH_PHY_NONE; |
| 315 | eth_data->speed = SPEED_1000; |
| 316 | eth_data->duplex = DUPLEX_FULL; |
| 317 | } |
| 318 | |
Andrew Lunn | 7e3819d | 2011-05-15 13:32:44 +0200 | [diff] [blame^] | 319 | orion_ge10_init(eth_data, &mv78xx0_mbus_dram_info, |
| 320 | GE10_PHYS_BASE, IRQ_MV78XX0_GE10_SUM, |
| 321 | NO_IRQ, get_tclk()); |
Stanislav Samsonov | 794d15b | 2008-06-22 22:45:10 +0200 | [diff] [blame] | 322 | } |
| 323 | |
| 324 | |
| 325 | /***************************************************************************** |
| 326 | * GE11 |
| 327 | ****************************************************************************/ |
Stanislav Samsonov | 794d15b | 2008-06-22 22:45:10 +0200 | [diff] [blame] | 328 | void __init mv78xx0_ge11_init(struct mv643xx_eth_platform_data *eth_data) |
| 329 | { |
Lennert Buytenhek | 712424f | 2009-02-20 02:31:58 +0100 | [diff] [blame] | 330 | u32 dev, rev; |
| 331 | |
Lennert Buytenhek | 712424f | 2009-02-20 02:31:58 +0100 | [diff] [blame] | 332 | /* |
| 333 | * On the Z0, ge10 and ge11 are internally connected back |
| 334 | * to back, and not brought out. |
| 335 | */ |
| 336 | mv78xx0_pcie_id(&dev, &rev); |
| 337 | if (dev == MV78X00_Z0_DEV_ID) { |
| 338 | eth_data->phy_addr = MV643XX_ETH_PHY_NONE; |
| 339 | eth_data->speed = SPEED_1000; |
| 340 | eth_data->duplex = DUPLEX_FULL; |
| 341 | } |
| 342 | |
Andrew Lunn | 7e3819d | 2011-05-15 13:32:44 +0200 | [diff] [blame^] | 343 | orion_ge11_init(eth_data, &mv78xx0_mbus_dram_info, |
| 344 | GE11_PHYS_BASE, IRQ_MV78XX0_GE11_SUM, |
| 345 | NO_IRQ, get_tclk()); |
Stanislav Samsonov | 794d15b | 2008-06-22 22:45:10 +0200 | [diff] [blame] | 346 | } |
| 347 | |
Riku Voipio | 6935994 | 2009-03-03 21:13:50 +0200 | [diff] [blame] | 348 | /***************************************************************************** |
| 349 | * I2C bus 0 |
| 350 | ****************************************************************************/ |
| 351 | |
| 352 | static struct mv64xxx_i2c_pdata mv78xx0_i2c_0_pdata = { |
| 353 | .freq_m = 8, /* assumes 166 MHz TCLK */ |
| 354 | .freq_n = 3, |
| 355 | .timeout = 1000, /* Default timeout of 1 second */ |
| 356 | }; |
| 357 | |
| 358 | static struct resource mv78xx0_i2c_0_resources[] = { |
| 359 | { |
Riku Voipio | 6935994 | 2009-03-03 21:13:50 +0200 | [diff] [blame] | 360 | .start = I2C_0_PHYS_BASE, |
| 361 | .end = I2C_0_PHYS_BASE + 0x1f, |
| 362 | .flags = IORESOURCE_MEM, |
| 363 | }, { |
Riku Voipio | 6935994 | 2009-03-03 21:13:50 +0200 | [diff] [blame] | 364 | .start = IRQ_MV78XX0_I2C_0, |
| 365 | .end = IRQ_MV78XX0_I2C_0, |
| 366 | .flags = IORESOURCE_IRQ, |
| 367 | }, |
| 368 | }; |
| 369 | |
| 370 | |
| 371 | static struct platform_device mv78xx0_i2c_0 = { |
| 372 | .name = MV64XXX_I2C_CTLR_NAME, |
| 373 | .id = 0, |
| 374 | .num_resources = ARRAY_SIZE(mv78xx0_i2c_0_resources), |
| 375 | .resource = mv78xx0_i2c_0_resources, |
| 376 | .dev = { |
| 377 | .platform_data = &mv78xx0_i2c_0_pdata, |
| 378 | }, |
| 379 | }; |
| 380 | |
| 381 | /***************************************************************************** |
| 382 | * I2C bus 1 |
| 383 | ****************************************************************************/ |
| 384 | |
| 385 | static struct mv64xxx_i2c_pdata mv78xx0_i2c_1_pdata = { |
| 386 | .freq_m = 8, /* assumes 166 MHz TCLK */ |
| 387 | .freq_n = 3, |
| 388 | .timeout = 1000, /* Default timeout of 1 second */ |
| 389 | }; |
| 390 | |
| 391 | static struct resource mv78xx0_i2c_1_resources[] = { |
| 392 | { |
Riku Voipio | 6935994 | 2009-03-03 21:13:50 +0200 | [diff] [blame] | 393 | .start = I2C_1_PHYS_BASE, |
| 394 | .end = I2C_1_PHYS_BASE + 0x1f, |
| 395 | .flags = IORESOURCE_MEM, |
| 396 | }, { |
Riku Voipio | 6935994 | 2009-03-03 21:13:50 +0200 | [diff] [blame] | 397 | .start = IRQ_MV78XX0_I2C_1, |
| 398 | .end = IRQ_MV78XX0_I2C_1, |
| 399 | .flags = IORESOURCE_IRQ, |
| 400 | }, |
| 401 | }; |
| 402 | |
| 403 | |
| 404 | static struct platform_device mv78xx0_i2c_1 = { |
| 405 | .name = MV64XXX_I2C_CTLR_NAME, |
| 406 | .id = 1, |
| 407 | .num_resources = ARRAY_SIZE(mv78xx0_i2c_1_resources), |
| 408 | .resource = mv78xx0_i2c_1_resources, |
| 409 | .dev = { |
| 410 | .platform_data = &mv78xx0_i2c_1_pdata, |
| 411 | }, |
| 412 | }; |
| 413 | |
| 414 | void __init mv78xx0_i2c_init(void) |
| 415 | { |
| 416 | platform_device_register(&mv78xx0_i2c_0); |
| 417 | platform_device_register(&mv78xx0_i2c_1); |
| 418 | } |
Stanislav Samsonov | 794d15b | 2008-06-22 22:45:10 +0200 | [diff] [blame] | 419 | |
| 420 | /***************************************************************************** |
| 421 | * SATA |
| 422 | ****************************************************************************/ |
| 423 | static struct resource mv78xx0_sata_resources[] = { |
| 424 | { |
| 425 | .name = "sata base", |
| 426 | .start = SATA_PHYS_BASE, |
| 427 | .end = SATA_PHYS_BASE + 0x5000 - 1, |
| 428 | .flags = IORESOURCE_MEM, |
| 429 | }, { |
| 430 | .name = "sata irq", |
| 431 | .start = IRQ_MV78XX0_SATA, |
| 432 | .end = IRQ_MV78XX0_SATA, |
| 433 | .flags = IORESOURCE_IRQ, |
| 434 | }, |
| 435 | }; |
| 436 | |
| 437 | static struct platform_device mv78xx0_sata = { |
| 438 | .name = "sata_mv", |
| 439 | .id = 0, |
| 440 | .dev = { |
Andrew Lunn | 5c60255 | 2011-05-15 13:32:40 +0200 | [diff] [blame] | 441 | .coherent_dma_mask = DMA_BIT_MASK(32), |
Stanislav Samsonov | 794d15b | 2008-06-22 22:45:10 +0200 | [diff] [blame] | 442 | }, |
| 443 | .num_resources = ARRAY_SIZE(mv78xx0_sata_resources), |
| 444 | .resource = mv78xx0_sata_resources, |
| 445 | }; |
| 446 | |
| 447 | void __init mv78xx0_sata_init(struct mv_sata_platform_data *sata_data) |
| 448 | { |
| 449 | sata_data->dram = &mv78xx0_mbus_dram_info; |
| 450 | mv78xx0_sata.dev.platform_data = sata_data; |
| 451 | platform_device_register(&mv78xx0_sata); |
| 452 | } |
| 453 | |
| 454 | |
| 455 | /***************************************************************************** |
| 456 | * UART0 |
| 457 | ****************************************************************************/ |
Stanislav Samsonov | 794d15b | 2008-06-22 22:45:10 +0200 | [diff] [blame] | 458 | void __init mv78xx0_uart0_init(void) |
| 459 | { |
Andrew Lunn | 28a2b45 | 2011-05-15 13:32:41 +0200 | [diff] [blame] | 460 | orion_uart0_init(UART0_VIRT_BASE, UART0_PHYS_BASE, |
| 461 | IRQ_MV78XX0_UART_0, get_tclk()); |
Stanislav Samsonov | 794d15b | 2008-06-22 22:45:10 +0200 | [diff] [blame] | 462 | } |
| 463 | |
| 464 | |
| 465 | /***************************************************************************** |
| 466 | * UART1 |
| 467 | ****************************************************************************/ |
Stanislav Samsonov | 794d15b | 2008-06-22 22:45:10 +0200 | [diff] [blame] | 468 | void __init mv78xx0_uart1_init(void) |
| 469 | { |
Andrew Lunn | 28a2b45 | 2011-05-15 13:32:41 +0200 | [diff] [blame] | 470 | orion_uart1_init(UART1_VIRT_BASE, UART1_PHYS_BASE, |
| 471 | IRQ_MV78XX0_UART_1, get_tclk()); |
Stanislav Samsonov | 794d15b | 2008-06-22 22:45:10 +0200 | [diff] [blame] | 472 | } |
| 473 | |
| 474 | |
| 475 | /***************************************************************************** |
| 476 | * UART2 |
| 477 | ****************************************************************************/ |
Stanislav Samsonov | 794d15b | 2008-06-22 22:45:10 +0200 | [diff] [blame] | 478 | void __init mv78xx0_uart2_init(void) |
| 479 | { |
Andrew Lunn | 28a2b45 | 2011-05-15 13:32:41 +0200 | [diff] [blame] | 480 | orion_uart2_init(UART2_VIRT_BASE, UART2_PHYS_BASE, |
| 481 | IRQ_MV78XX0_UART_2, get_tclk()); |
Stanislav Samsonov | 794d15b | 2008-06-22 22:45:10 +0200 | [diff] [blame] | 482 | } |
| 483 | |
Stanislav Samsonov | 794d15b | 2008-06-22 22:45:10 +0200 | [diff] [blame] | 484 | /***************************************************************************** |
| 485 | * UART3 |
| 486 | ****************************************************************************/ |
Stanislav Samsonov | 794d15b | 2008-06-22 22:45:10 +0200 | [diff] [blame] | 487 | void __init mv78xx0_uart3_init(void) |
| 488 | { |
Andrew Lunn | 28a2b45 | 2011-05-15 13:32:41 +0200 | [diff] [blame] | 489 | orion_uart3_init(UART3_VIRT_BASE, UART3_PHYS_BASE, |
| 490 | IRQ_MV78XX0_UART_3, get_tclk()); |
Stanislav Samsonov | 794d15b | 2008-06-22 22:45:10 +0200 | [diff] [blame] | 491 | } |
| 492 | |
Stanislav Samsonov | 794d15b | 2008-06-22 22:45:10 +0200 | [diff] [blame] | 493 | /***************************************************************************** |
| 494 | * Time handling |
| 495 | ****************************************************************************/ |
Lennert Buytenhek | 4ee1f6b | 2010-10-15 16:50:26 +0200 | [diff] [blame] | 496 | void __init mv78xx0_init_early(void) |
| 497 | { |
| 498 | orion_time_set_base(TIMER_VIRT_BASE); |
| 499 | } |
| 500 | |
Stanislav Samsonov | 794d15b | 2008-06-22 22:45:10 +0200 | [diff] [blame] | 501 | static void mv78xx0_timer_init(void) |
| 502 | { |
Lennert Buytenhek | 4ee1f6b | 2010-10-15 16:50:26 +0200 | [diff] [blame] | 503 | orion_time_init(BRIDGE_VIRT_BASE, BRIDGE_INT_TIMER1_CLR, |
| 504 | IRQ_MV78XX0_TIMER_1, get_tclk()); |
Stanislav Samsonov | 794d15b | 2008-06-22 22:45:10 +0200 | [diff] [blame] | 505 | } |
| 506 | |
| 507 | struct sys_timer mv78xx0_timer = { |
| 508 | .init = mv78xx0_timer_init, |
| 509 | }; |
| 510 | |
| 511 | |
| 512 | /***************************************************************************** |
| 513 | * General |
| 514 | ****************************************************************************/ |
Lennert Buytenhek | cfdeb63 | 2009-02-20 02:31:35 +0100 | [diff] [blame] | 515 | static char * __init mv78xx0_id(void) |
| 516 | { |
| 517 | u32 dev, rev; |
| 518 | |
| 519 | mv78xx0_pcie_id(&dev, &rev); |
| 520 | |
| 521 | if (dev == MV78X00_Z0_DEV_ID) { |
| 522 | if (rev == MV78X00_REV_Z0) |
| 523 | return "MV78X00-Z0"; |
| 524 | else |
| 525 | return "MV78X00-Rev-Unsupported"; |
| 526 | } else if (dev == MV78100_DEV_ID) { |
| 527 | if (rev == MV78100_REV_A0) |
| 528 | return "MV78100-A0"; |
Lennert Buytenhek | 662aece | 2009-09-30 13:02:42 -0700 | [diff] [blame] | 529 | else if (rev == MV78100_REV_A1) |
| 530 | return "MV78100-A1"; |
Lennert Buytenhek | cfdeb63 | 2009-02-20 02:31:35 +0100 | [diff] [blame] | 531 | else |
| 532 | return "MV78100-Rev-Unsupported"; |
| 533 | } else if (dev == MV78200_DEV_ID) { |
| 534 | if (rev == MV78100_REV_A0) |
| 535 | return "MV78200-A0"; |
| 536 | else |
| 537 | return "MV78200-Rev-Unsupported"; |
| 538 | } else { |
| 539 | return "Device-Unknown"; |
| 540 | } |
| 541 | } |
| 542 | |
Stanislav Samsonov | 794d15b | 2008-06-22 22:45:10 +0200 | [diff] [blame] | 543 | static int __init is_l2_writethrough(void) |
| 544 | { |
| 545 | return !!(readl(CPU_CONTROL) & L2_WRITETHROUGH); |
| 546 | } |
| 547 | |
| 548 | void __init mv78xx0_init(void) |
| 549 | { |
| 550 | int core_index; |
| 551 | int hclk; |
| 552 | int pclk; |
| 553 | int l2clk; |
| 554 | int tclk; |
| 555 | |
| 556 | core_index = mv78xx0_core_index(); |
| 557 | hclk = get_hclk(); |
| 558 | get_pclk_l2clk(hclk, core_index, &pclk, &l2clk); |
| 559 | tclk = get_tclk(); |
| 560 | |
Lennert Buytenhek | cfdeb63 | 2009-02-20 02:31:35 +0100 | [diff] [blame] | 561 | printk(KERN_INFO "%s ", mv78xx0_id()); |
| 562 | printk("core #%d, ", core_index); |
Stanislav Samsonov | 794d15b | 2008-06-22 22:45:10 +0200 | [diff] [blame] | 563 | printk("PCLK = %dMHz, ", (pclk + 499999) / 1000000); |
| 564 | printk("L2 = %dMHz, ", (l2clk + 499999) / 1000000); |
| 565 | printk("HCLK = %dMHz, ", (hclk + 499999) / 1000000); |
| 566 | printk("TCLK = %dMHz\n", (tclk + 499999) / 1000000); |
| 567 | |
| 568 | mv78xx0_setup_cpu_mbus(); |
| 569 | |
| 570 | #ifdef CONFIG_CACHE_FEROCEON_L2 |
| 571 | feroceon_l2_init(is_l2_writethrough()); |
| 572 | #endif |
Stanislav Samsonov | 794d15b | 2008-06-22 22:45:10 +0200 | [diff] [blame] | 573 | } |