2 * Address map functions for Marvell 370 / XP SoCs
4 * Copyright (C) 2012 Marvell
6 * Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
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.
13 #include <linux/kernel.h>
14 #include <linux/init.h>
15 #include <linux/mbus.h>
18 #include <linux/of_address.h>
19 #include <plat/addr-map.h>
22 * Generic Address Decode Windows bit settings
24 #define ARMADA_XP_TARGET_DEV_BUS 1
25 #define ARMADA_XP_ATTR_DEV_BOOTROM 0x1D
26 #define ARMADA_XP_TARGET_ETH1 3
27 #define ARMADA_XP_TARGET_PCIE_0_2 4
28 #define ARMADA_XP_TARGET_ETH0 7
29 #define ARMADA_XP_TARGET_PCIE_1_3 8
31 #define ARMADA_370_TARGET_DEV_BUS 1
32 #define ARMADA_370_ATTR_DEV_BOOTROM 0x1D
33 #define ARMADA_370_TARGET_PCIE_0 4
34 #define ARMADA_370_TARGET_PCIE_1 8
36 #define ARMADA_WINDOW_8_PLUS_OFFSET 0x90
37 #define ARMADA_SDRAM_ADDR_DECODING_OFFSET 0x180
39 static const struct __initdata orion_addr_map_info
40 armada_xp_addr_map_info
[] = {
42 * Window for the BootROM, needed for SMP on Armada XP
44 { 0, 0xfff00000, SZ_1M
, ARMADA_XP_TARGET_DEV_BUS
,
45 ARMADA_XP_ATTR_DEV_BOOTROM
, -1 },
47 { -1, 0, 0, 0, 0, 0 },
50 static const struct __initdata orion_addr_map_info
51 armada_370_addr_map_info
[] = {
53 { -1, 0, 0, 0, 0, 0 },
56 static struct of_device_id of_addr_decoding_controller_table
[] = {
57 { .compatible
= "marvell,armada-addr-decoding-controller" },
58 { /* end of list */ },
62 armada_cfg_base(const struct orion_addr_map_cfg
*cfg
, int win
)
66 /* The register layout is a bit annoying and the below code
67 * tries to cope with it.
68 * - At offset 0x0, there are the registers for the first 8
69 * windows, with 4 registers of 32 bits per window (ctrl,
70 * base, remap low, remap high)
71 * - Then at offset 0x80, there is a hole of 0x10 bytes for
72 * the internal registers base address and internal units
73 * sync barrier register.
74 * - Then at offset 0x90, there the registers for 12
75 * windows, with only 2 registers of 32 bits per window
81 offset
= ARMADA_WINDOW_8_PLUS_OFFSET
+ ((win
- 8) << 3);
83 return cfg
->bridge_virt_base
+ offset
;
86 static struct __initdata orion_addr_map_cfg addr_map_cfg
= {
89 .win_cfg_base
= armada_cfg_base
,
92 static int __init
armada_setup_cpu_mbus(void)
94 struct device_node
*np
;
95 void __iomem
*mbus_unit_addr_decoding_base
;
96 void __iomem
*sdram_addr_decoding_base
;
98 np
= of_find_matching_node(NULL
, of_addr_decoding_controller_table
);
102 mbus_unit_addr_decoding_base
= of_iomap(np
, 0);
103 BUG_ON(!mbus_unit_addr_decoding_base
);
105 sdram_addr_decoding_base
=
106 mbus_unit_addr_decoding_base
+
107 ARMADA_SDRAM_ADDR_DECODING_OFFSET
;
109 addr_map_cfg
.bridge_virt_base
= mbus_unit_addr_decoding_base
;
111 if (of_find_compatible_node(NULL
, NULL
, "marvell,coherency-fabric"))
112 addr_map_cfg
.hw_io_coherency
= 1;
115 * Disable, clear and configure windows.
117 if (of_machine_is_compatible("marvell,armadaxp"))
118 orion_config_wins(&addr_map_cfg
, armada_xp_addr_map_info
);
119 else if (of_machine_is_compatible("marvell,armada370"))
120 orion_config_wins(&addr_map_cfg
, armada_370_addr_map_info
);
122 pr_err("Unsupported SoC\n");
127 * Setup MBUS dram target info.
129 orion_setup_cpu_mbus_target(&addr_map_cfg
,
130 sdram_addr_decoding_base
);
134 /* Using a early_initcall is needed so that this initialization gets
135 * done before the SMP initialization, which requires the BootROM to
137 early_initcall(armada_setup_cpu_mbus
);