Blame view
arch/arm/mach-dove/common.c
12.6 KB
edabd38e1
|
1 2 3 4 5 6 7 8 9 |
/* * arch/arm/mach-dove/common.c * * Core functions for Marvell Dove 88AP510 System On Chip * * This file is licensed under the terms of the GNU General Public * License version 2. This program is licensed "as is" without any * warranty of any kind, whether express or implied. */ |
2f129bf4a
|
10 |
#include <linux/clk-provider.h> |
b3af7a1ff
|
11 12 |
#include <linux/dma-mapping.h> #include <linux/init.h> |
81d2ef7c4
|
13 14 |
#include <linux/of.h> #include <linux/of_platform.h> |
b3af7a1ff
|
15 16 17 |
#include <linux/platform_data/dma-mv_xor.h> #include <linux/platform_data/usb-ehci-orion.h> #include <linux/platform_device.h> |
573a652fb
|
18 |
#include <asm/hardware/cache-tauros2.h> |
b3af7a1ff
|
19 |
#include <asm/mach/arch.h> |
edabd38e1
|
20 21 |
#include <asm/mach/map.h> #include <asm/mach/time.h> |
edabd38e1
|
22 |
#include <mach/bridge-regs.h> |
b3af7a1ff
|
23 |
#include <mach/pm.h> |
28a2b4505
|
24 |
#include <plat/common.h> |
b3af7a1ff
|
25 26 |
#include <plat/irq.h> #include <plat/time.h> |
edabd38e1
|
27 |
#include "common.h" |
89a7fbfb5
|
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
/* These can go away once Dove uses the mvebu-mbus DT binding */ #define DOVE_MBUS_PCIE0_MEM_TARGET 0x4 #define DOVE_MBUS_PCIE0_MEM_ATTR 0xe8 #define DOVE_MBUS_PCIE0_IO_TARGET 0x4 #define DOVE_MBUS_PCIE0_IO_ATTR 0xe0 #define DOVE_MBUS_PCIE1_MEM_TARGET 0x8 #define DOVE_MBUS_PCIE1_MEM_ATTR 0xe8 #define DOVE_MBUS_PCIE1_IO_TARGET 0x8 #define DOVE_MBUS_PCIE1_IO_ATTR 0xe0 #define DOVE_MBUS_CESA_TARGET 0x3 #define DOVE_MBUS_CESA_ATTR 0x1 #define DOVE_MBUS_BOOTROM_TARGET 0x1 #define DOVE_MBUS_BOOTROM_ATTR 0xfd #define DOVE_MBUS_SCRATCHPAD_TARGET 0xd #define DOVE_MBUS_SCRATCHPAD_ATTR 0x0 |
edabd38e1
|
43 44 45 46 47 |
/***************************************************************************** * I/O Address Mapping ****************************************************************************/ static struct map_desc dove_io_desc[] __initdata = { { |
c3c5a2815
|
48 |
.virtual = (unsigned long) DOVE_SB_REGS_VIRT_BASE, |
edabd38e1
|
49 50 51 52 |
.pfn = __phys_to_pfn(DOVE_SB_REGS_PHYS_BASE), .length = DOVE_SB_REGS_SIZE, .type = MT_DEVICE, }, { |
c3c5a2815
|
53 |
.virtual = (unsigned long) DOVE_NB_REGS_VIRT_BASE, |
edabd38e1
|
54 55 56 |
.pfn = __phys_to_pfn(DOVE_NB_REGS_PHYS_BASE), .length = DOVE_NB_REGS_SIZE, .type = MT_DEVICE, |
edabd38e1
|
57 58 59 60 61 62 63 64 65 |
}, }; void __init dove_map_io(void) { iotable_init(dove_io_desc, ARRAY_SIZE(dove_io_desc)); } /***************************************************************************** |
2f129bf4a
|
66 67 |
* CLK tree ****************************************************************************/ |
5817d10b8
|
68 |
static int dove_tclk; |
521674718
|
69 70 |
static DEFINE_SPINLOCK(gating_lock); |
2f129bf4a
|
71 |
static struct clk *tclk; |
521674718
|
72 73 |
static struct clk __init *dove_register_gate(const char *name, const char *parent, u8 bit_idx) |
2f129bf4a
|
74 |
{ |
521674718
|
75 76 77 78 |
return clk_register_gate(NULL, name, parent, 0, (void __iomem *)CLOCK_GATING_CONTROL, bit_idx, 0, &gating_lock); } |
5817d10b8
|
79 |
static void __init dove_clk_init(void) |
2f129bf4a
|
80 |
{ |
521674718
|
81 82 83 |
struct clk *usb0, *usb1, *sata, *pex0, *pex1, *sdio0, *sdio1; struct clk *nand, *camera, *i2s0, *i2s1, *crypto, *ac97, *pdma; struct clk *xor0, *xor1, *ge, *gephy; |
4574b8866
|
84 |
|
2f129bf4a
|
85 |
tclk = clk_register_fixed_rate(NULL, "tclk", NULL, CLK_IS_ROOT, |
5817d10b8
|
86 |
dove_tclk); |
4574b8866
|
87 |
|
521674718
|
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
usb0 = dove_register_gate("usb0", "tclk", CLOCK_GATING_BIT_USB0); usb1 = dove_register_gate("usb1", "tclk", CLOCK_GATING_BIT_USB1); sata = dove_register_gate("sata", "tclk", CLOCK_GATING_BIT_SATA); pex0 = dove_register_gate("pex0", "tclk", CLOCK_GATING_BIT_PCIE0); pex1 = dove_register_gate("pex1", "tclk", CLOCK_GATING_BIT_PCIE1); sdio0 = dove_register_gate("sdio0", "tclk", CLOCK_GATING_BIT_SDIO0); sdio1 = dove_register_gate("sdio1", "tclk", CLOCK_GATING_BIT_SDIO1); nand = dove_register_gate("nand", "tclk", CLOCK_GATING_BIT_NAND); camera = dove_register_gate("camera", "tclk", CLOCK_GATING_BIT_CAMERA); i2s0 = dove_register_gate("i2s0", "tclk", CLOCK_GATING_BIT_I2S0); i2s1 = dove_register_gate("i2s1", "tclk", CLOCK_GATING_BIT_I2S1); crypto = dove_register_gate("crypto", "tclk", CLOCK_GATING_BIT_CRYPTO); ac97 = dove_register_gate("ac97", "tclk", CLOCK_GATING_BIT_AC97); pdma = dove_register_gate("pdma", "tclk", CLOCK_GATING_BIT_PDMA); xor0 = dove_register_gate("xor0", "tclk", CLOCK_GATING_BIT_XOR0); xor1 = dove_register_gate("xor1", "tclk", CLOCK_GATING_BIT_XOR1); gephy = dove_register_gate("gephy", "tclk", CLOCK_GATING_BIT_GIGA_PHY); ge = dove_register_gate("ge", "gephy", CLOCK_GATING_BIT_GBE); orion_clkdev_add(NULL, "orion_spi.0", tclk); orion_clkdev_add(NULL, "orion_spi.1", tclk); orion_clkdev_add(NULL, "orion_wdt", tclk); orion_clkdev_add(NULL, "mv64xxx_i2c.0", tclk); orion_clkdev_add(NULL, "orion-ehci.0", usb0); orion_clkdev_add(NULL, "orion-ehci.1", usb1); |
3fbcd3d0a
|
114 115 |
orion_clkdev_add(NULL, "mv643xx_eth_port.0", ge); orion_clkdev_add(NULL, "sata_mv.0", sata); |
521674718
|
116 117 118 119 120 121 |
orion_clkdev_add("0", "pcie", pex0); orion_clkdev_add("1", "pcie", pex1); orion_clkdev_add(NULL, "sdhci-dove.0", sdio0); orion_clkdev_add(NULL, "sdhci-dove.1", sdio1); orion_clkdev_add(NULL, "orion_nand", nand); orion_clkdev_add(NULL, "cafe1000-ccic.0", camera); |
64ddf1f89
|
122 123 |
orion_clkdev_add(NULL, "mvebu-audio.0", i2s0); orion_clkdev_add(NULL, "mvebu-audio.1", i2s1); |
521674718
|
124 125 126 |
orion_clkdev_add(NULL, "mv_crypto", crypto); orion_clkdev_add(NULL, "dove-ac97", ac97); orion_clkdev_add(NULL, "dove-pdma", pdma); |
0dddee7a7
|
127 128 |
orion_clkdev_add(NULL, MV_XOR_NAME ".0", xor0); orion_clkdev_add(NULL, MV_XOR_NAME ".1", xor1); |
2f129bf4a
|
129 130 131 |
} /***************************************************************************** |
edabd38e1
|
132 133 |
* EHCI0 ****************************************************************************/ |
edabd38e1
|
134 135 |
void __init dove_ehci0_init(void) { |
720533535
|
136 |
orion_ehci_init(DOVE_USB0_PHYS_BASE, IRQ_DOVE_USB0, EHCI_PHY_NA); |
edabd38e1
|
137 138 139 140 141 |
} /***************************************************************************** * EHCI1 ****************************************************************************/ |
edabd38e1
|
142 143 |
void __init dove_ehci1_init(void) { |
db33f4de9
|
144 |
orion_ehci_1_init(DOVE_USB1_PHYS_BASE, IRQ_DOVE_USB1); |
edabd38e1
|
145 146 147 148 149 |
} /***************************************************************************** * GE00 ****************************************************************************/ |
edabd38e1
|
150 151 |
void __init dove_ge00_init(struct mv643xx_eth_platform_data *eth_data) { |
30e0f5803
|
152 |
orion_ge00_init(eth_data, DOVE_GE00_PHYS_BASE, |
58569aee5
|
153 154 |
IRQ_DOVE_GE00_SUM, IRQ_DOVE_GE00_ERR, 1600); |
edabd38e1
|
155 156 157 158 159 |
} /***************************************************************************** * SoC RTC ****************************************************************************/ |
887c206a2
|
160 |
static void __init dove_rtc_init(void) |
edabd38e1
|
161 |
{ |
f6eaccb30
|
162 |
orion_rtc_init(DOVE_RTC_PHYS_BASE, IRQ_DOVE_RTC); |
edabd38e1
|
163 164 165 166 167 |
} /***************************************************************************** * SATA ****************************************************************************/ |
edabd38e1
|
168 169 |
void __init dove_sata_init(struct mv_sata_platform_data *sata_data) { |
db33f4de9
|
170 |
orion_sata_init(sata_data, DOVE_SATA_PHYS_BASE, IRQ_DOVE_SATA); |
9e613f8a7
|
171 |
|
edabd38e1
|
172 173 174 175 176 |
} /***************************************************************************** * UART0 ****************************************************************************/ |
edabd38e1
|
177 178 |
void __init dove_uart0_init(void) { |
28a2b4505
|
179 |
orion_uart0_init(DOVE_UART0_VIRT_BASE, DOVE_UART0_PHYS_BASE, |
74c335761
|
180 |
IRQ_DOVE_UART_0, tclk); |
edabd38e1
|
181 182 183 184 185 |
} /***************************************************************************** * UART1 ****************************************************************************/ |
edabd38e1
|
186 187 |
void __init dove_uart1_init(void) { |
28a2b4505
|
188 |
orion_uart1_init(DOVE_UART1_VIRT_BASE, DOVE_UART1_PHYS_BASE, |
74c335761
|
189 |
IRQ_DOVE_UART_1, tclk); |
edabd38e1
|
190 191 192 193 194 |
} /***************************************************************************** * UART2 ****************************************************************************/ |
edabd38e1
|
195 196 |
void __init dove_uart2_init(void) { |
28a2b4505
|
197 |
orion_uart2_init(DOVE_UART2_VIRT_BASE, DOVE_UART2_PHYS_BASE, |
74c335761
|
198 |
IRQ_DOVE_UART_2, tclk); |
edabd38e1
|
199 200 201 202 203 |
} /***************************************************************************** * UART3 ****************************************************************************/ |
edabd38e1
|
204 205 |
void __init dove_uart3_init(void) { |
28a2b4505
|
206 |
orion_uart3_init(DOVE_UART3_VIRT_BASE, DOVE_UART3_PHYS_BASE, |
74c335761
|
207 |
IRQ_DOVE_UART_3, tclk); |
edabd38e1
|
208 209 210 |
} /***************************************************************************** |
980f9f601
|
211 |
* SPI |
edabd38e1
|
212 |
****************************************************************************/ |
edabd38e1
|
213 214 |
void __init dove_spi0_init(void) { |
4574b8866
|
215 |
orion_spi_init(DOVE_SPI0_PHYS_BASE); |
edabd38e1
|
216 |
} |
edabd38e1
|
217 218 |
void __init dove_spi1_init(void) { |
4574b8866
|
219 |
orion_spi_1_init(DOVE_SPI1_PHYS_BASE); |
edabd38e1
|
220 221 222 223 224 |
} /***************************************************************************** * I2C ****************************************************************************/ |
edabd38e1
|
225 226 |
void __init dove_i2c_init(void) { |
aac7ffa3e
|
227 |
orion_i2c_init(DOVE_I2C_PHYS_BASE, IRQ_DOVE_I2C, 10); |
edabd38e1
|
228 229 230 231 232 |
} /***************************************************************************** * Time handling ****************************************************************************/ |
4ee1f6b57
|
233 234 235 |
void __init dove_init_early(void) { orion_time_set_base(TIMER_VIRT_BASE); |
7d5549027
|
236 237 238 |
mvebu_mbus_init("marvell,dove-mbus", BRIDGE_WINS_BASE, BRIDGE_WINS_SZ, DOVE_MC_WINS_BASE, DOVE_MC_WINS_SZ); |
4ee1f6b57
|
239 |
} |
5817d10b8
|
240 |
static int __init dove_find_tclk(void) |
edabd38e1
|
241 |
{ |
edabd38e1
|
242 243 |
return 166666667; } |
6bb27d734
|
244 |
void __init dove_timer_init(void) |
edabd38e1
|
245 |
{ |
5817d10b8
|
246 |
dove_tclk = dove_find_tclk(); |
4ee1f6b57
|
247 |
orion_time_init(BRIDGE_VIRT_BASE, BRIDGE_INT_TIMER1_CLR, |
5817d10b8
|
248 |
IRQ_DOVE_BRIDGE, dove_tclk); |
edabd38e1
|
249 |
} |
edabd38e1
|
250 |
/***************************************************************************** |
edabd38e1
|
251 252 |
* XOR 0 ****************************************************************************/ |
887c206a2
|
253 |
static void __init dove_xor0_init(void) |
edabd38e1
|
254 |
{ |
db33f4de9
|
255 |
orion_xor0_init(DOVE_XOR0_PHYS_BASE, DOVE_XOR0_HIGH_PHYS_BASE, |
ee9627234
|
256 |
IRQ_DOVE_XOR_00, IRQ_DOVE_XOR_01); |
edabd38e1
|
257 258 259 260 261 |
} /***************************************************************************** * XOR 1 ****************************************************************************/ |
887c206a2
|
262 |
static void __init dove_xor1_init(void) |
edabd38e1
|
263 |
{ |
ee9627234
|
264 265 |
orion_xor1_init(DOVE_XOR1_PHYS_BASE, DOVE_XOR1_HIGH_PHYS_BASE, IRQ_DOVE_XOR_10, IRQ_DOVE_XOR_11); |
edabd38e1
|
266 |
} |
16bc90af1
|
267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 |
/***************************************************************************** * SDIO ****************************************************************************/ static u64 sdio_dmamask = DMA_BIT_MASK(32); static struct resource dove_sdio0_resources[] = { { .start = DOVE_SDIO0_PHYS_BASE, .end = DOVE_SDIO0_PHYS_BASE + 0xff, .flags = IORESOURCE_MEM, }, { .start = IRQ_DOVE_SDIO0, .end = IRQ_DOVE_SDIO0, .flags = IORESOURCE_IRQ, }, }; static struct platform_device dove_sdio0 = { |
930e2fe75
|
285 |
.name = "sdhci-dove", |
16bc90af1
|
286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 |
.id = 0, .dev = { .dma_mask = &sdio_dmamask, .coherent_dma_mask = DMA_BIT_MASK(32), }, .resource = dove_sdio0_resources, .num_resources = ARRAY_SIZE(dove_sdio0_resources), }; void __init dove_sdio0_init(void) { platform_device_register(&dove_sdio0); } static struct resource dove_sdio1_resources[] = { { .start = DOVE_SDIO1_PHYS_BASE, .end = DOVE_SDIO1_PHYS_BASE + 0xff, .flags = IORESOURCE_MEM, }, { .start = IRQ_DOVE_SDIO1, .end = IRQ_DOVE_SDIO1, .flags = IORESOURCE_IRQ, }, }; static struct platform_device dove_sdio1 = { |
930e2fe75
|
313 |
.name = "sdhci-dove", |
16bc90af1
|
314 315 316 317 318 319 320 321 322 323 324 325 326 |
.id = 1, .dev = { .dma_mask = &sdio_dmamask, .coherent_dma_mask = DMA_BIT_MASK(32), }, .resource = dove_sdio1_resources, .num_resources = ARRAY_SIZE(dove_sdio1_resources), }; void __init dove_sdio1_init(void) { platform_device_register(&dove_sdio1); } |
7d5549027
|
327 328 329 330 |
void __init dove_setup_cpu_wins(void) { /* * The PCIe windows will no longer be statically allocated |
89a7fbfb5
|
331 332 333 |
* here once Dove is migrated to the pci-mvebu driver. The * non-PCIe windows will no longer be created here once Dove * fully moves to DT. |
7d5549027
|
334 |
*/ |
89a7fbfb5
|
335 336 |
mvebu_mbus_add_window_remap_by_id(DOVE_MBUS_PCIE0_IO_TARGET, DOVE_MBUS_PCIE0_IO_ATTR, |
7d5549027
|
337 338 |
DOVE_PCIE0_IO_PHYS_BASE, DOVE_PCIE0_IO_SIZE, |
89a7fbfb5
|
339 340 341 |
DOVE_PCIE0_IO_BUS_BASE); mvebu_mbus_add_window_remap_by_id(DOVE_MBUS_PCIE1_IO_TARGET, DOVE_MBUS_PCIE1_IO_ATTR, |
7d5549027
|
342 343 |
DOVE_PCIE1_IO_PHYS_BASE, DOVE_PCIE1_IO_SIZE, |
89a7fbfb5
|
344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 |
DOVE_PCIE1_IO_BUS_BASE); mvebu_mbus_add_window_by_id(DOVE_MBUS_PCIE0_MEM_TARGET, DOVE_MBUS_PCIE0_MEM_ATTR, DOVE_PCIE0_MEM_PHYS_BASE, DOVE_PCIE0_MEM_SIZE); mvebu_mbus_add_window_by_id(DOVE_MBUS_PCIE1_MEM_TARGET, DOVE_MBUS_PCIE1_MEM_ATTR, DOVE_PCIE1_MEM_PHYS_BASE, DOVE_PCIE1_MEM_SIZE); mvebu_mbus_add_window_by_id(DOVE_MBUS_CESA_TARGET, DOVE_MBUS_CESA_ATTR, DOVE_CESA_PHYS_BASE, DOVE_CESA_SIZE); mvebu_mbus_add_window_by_id(DOVE_MBUS_BOOTROM_TARGET, DOVE_MBUS_BOOTROM_ATTR, DOVE_BOOTROM_PHYS_BASE, DOVE_BOOTROM_SIZE); mvebu_mbus_add_window_by_id(DOVE_MBUS_SCRATCHPAD_TARGET, DOVE_MBUS_SCRATCHPAD_ATTR, DOVE_SCRATCHPAD_PHYS_BASE, DOVE_SCRATCHPAD_SIZE); |
7d5549027
|
365 |
} |
edabd38e1
|
366 367 |
void __init dove_init(void) { |
5817d10b8
|
368 369 370 |
pr_info("Dove 88AP510 SoC, TCLK = %d MHz. ", (dove_tclk + 499999) / 1000000); |
edabd38e1
|
371 |
|
573a652fb
|
372 |
#ifdef CONFIG_CACHE_TAUROS2 |
5cc581579
|
373 |
tauros2_init(0); |
573a652fb
|
374 |
#endif |
7d5549027
|
375 |
dove_setup_cpu_wins(); |
edabd38e1
|
376 |
|
2f129bf4a
|
377 |
/* Setup root of clk tree */ |
5817d10b8
|
378 |
dove_clk_init(); |
2f129bf4a
|
379 |
|
edabd38e1
|
380 381 382 383 384 |
/* internal devices that every board has */ dove_rtc_init(); dove_xor0_init(); dove_xor1_init(); } |
6ca6ff972
|
385 |
|
7b6d864b4
|
386 |
void dove_restart(enum reboot_mode mode, const char *cmd) |
6ca6ff972
|
387 388 389 390 391 392 393 394 395 396 397 398 399 400 |
{ /* * Enable soft reset to assert RSTOUTn. */ writel(SOFT_RESET_OUT_EN, RSTOUTn_MASK); /* * Assert soft reset. */ writel(SOFT_RESET, SYSTEM_SOFT_RESET); while (1) ; } |