diff options
author | Andrew Lunn <andrew@lunn.ch> | 2011-12-07 15:48:05 -0500 |
---|---|---|
committer | Nicolas Pitre <nico@fluxnic.net> | 2011-12-13 18:46:20 -0500 |
commit | b6d1c33a31deb1784c1d34070db6e84fd6f9d870 (patch) | |
tree | 18739a6c79b10f0fe69c01be5571e7a5af4d0e21 /arch/arm/mach-mv78xx0 | |
parent | 527ef0550d79e3b3a0ef8f5061072075afef6aaf (diff) |
ARM: Orion: Consolidate the address map setup
Compile tested on Dove, orion5x, mv78xx0. Boot tested on Kirkwood.
Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Tested-by: Michael Walle <michael@walle.cc>
Acked-by: Nicolas Pitre <nico@linaro.org>
Signed-off-by: Nicolas Pitre <nico@fluxnic.net>
Diffstat (limited to 'arch/arm/mach-mv78xx0')
-rw-r--r-- | arch/arm/mach-mv78xx0/addr-map.c | 102 |
1 files changed, 21 insertions, 81 deletions
diff --git a/arch/arm/mach-mv78xx0/addr-map.c b/arch/arm/mach-mv78xx0/addr-map.c index 311d5b0e9bc7..6b14555e5766 100644 --- a/arch/arm/mach-mv78xx0/addr-map.c +++ b/arch/arm/mach-mv78xx0/addr-map.c | |||
@@ -12,12 +12,12 @@ | |||
12 | #include <linux/init.h> | 12 | #include <linux/init.h> |
13 | #include <linux/mbus.h> | 13 | #include <linux/mbus.h> |
14 | #include <linux/io.h> | 14 | #include <linux/io.h> |
15 | #include <plat/addr-map.h> | ||
15 | #include "common.h" | 16 | #include "common.h" |
16 | 17 | ||
17 | /* | 18 | /* |
18 | * Generic Address Decode Windows bit settings | 19 | * Generic Address Decode Windows bit settings |
19 | */ | 20 | */ |
20 | #define TARGET_DDR 0 | ||
21 | #define TARGET_DEV_BUS 1 | 21 | #define TARGET_DEV_BUS 1 |
22 | #define TARGET_PCIE0 4 | 22 | #define TARGET_PCIE0 4 |
23 | #define TARGET_PCIE1 8 | 23 | #define TARGET_PCIE1 8 |
@@ -32,21 +32,10 @@ | |||
32 | #define ATTR_PCIE_MEM(l) (0xf8 & ~(0x10 << (l))) | 32 | #define ATTR_PCIE_MEM(l) (0xf8 & ~(0x10 << (l))) |
33 | 33 | ||
34 | /* | 34 | /* |
35 | * Helpers to get DDR bank info | ||
36 | */ | ||
37 | #define DDR_BASE_CS_OFF(n) (0x0000 + ((n) << 3)) | ||
38 | #define DDR_SIZE_CS_OFF(n) (0x0004 + ((n) << 3)) | ||
39 | |||
40 | /* | ||
41 | * CPU Address Decode Windows registers | 35 | * CPU Address Decode Windows registers |
42 | */ | 36 | */ |
43 | #define WIN0_OFF(n) (BRIDGE_VIRT_BASE + 0x0000 + ((n) << 4)) | 37 | #define WIN0_OFF(n) (BRIDGE_VIRT_BASE + 0x0000 + ((n) << 4)) |
44 | #define WIN8_OFF(n) (BRIDGE_VIRT_BASE + 0x0900 + (((n) - 8) << 4)) | 38 | #define WIN8_OFF(n) (BRIDGE_VIRT_BASE + 0x0900 + (((n) - 8) << 4)) |
45 | #define WIN_CTRL_OFF 0x0000 | ||
46 | #define WIN_BASE_OFF 0x0004 | ||
47 | #define WIN_REMAP_LO_OFF 0x0008 | ||
48 | #define WIN_REMAP_HI_OFF 0x000c | ||
49 | |||
50 | 39 | ||
51 | struct mbus_dram_target_info mv78xx0_mbus_dram_info; | 40 | struct mbus_dram_target_info mv78xx0_mbus_dram_info; |
52 | 41 | ||
@@ -63,94 +52,45 @@ static void __init __iomem *win_cfg_base(int win) | |||
63 | return (void __iomem *)((win < 8) ? WIN0_OFF(win) : WIN8_OFF(win)); | 52 | return (void __iomem *)((win < 8) ? WIN0_OFF(win) : WIN8_OFF(win)); |
64 | } | 53 | } |
65 | 54 | ||
66 | static int __init cpu_win_can_remap(int win) | 55 | /* |
67 | { | 56 | * Description of the windows needed by the platform code |
68 | if (win < 8) | 57 | */ |
69 | return 1; | 58 | static struct __initdata orion_addr_map_cfg addr_map_cfg = { |
70 | 59 | .num_wins = 14, | |
71 | return 0; | 60 | .remappable_wins = 8, |
72 | } | 61 | .win_cfg_base = win_cfg_base, |
73 | 62 | }; | |
74 | static void __init setup_cpu_win(int win, u32 base, u32 size, | ||
75 | u8 target, u8 attr, int remap) | ||
76 | { | ||
77 | void __iomem *addr = win_cfg_base(win); | ||
78 | u32 ctrl; | ||
79 | |||
80 | base &= 0xffff0000; | ||
81 | ctrl = ((size - 1) & 0xffff0000) | (attr << 8) | (target << 4) | 1; | ||
82 | |||
83 | writel(base, addr + WIN_BASE_OFF); | ||
84 | writel(ctrl, addr + WIN_CTRL_OFF); | ||
85 | if (cpu_win_can_remap(win)) { | ||
86 | if (remap < 0) | ||
87 | remap = base; | ||
88 | |||
89 | writel(remap & 0xffff0000, addr + WIN_REMAP_LO_OFF); | ||
90 | writel(0, addr + WIN_REMAP_HI_OFF); | ||
91 | } | ||
92 | } | ||
93 | 63 | ||
94 | void __init mv78xx0_setup_cpu_mbus(void) | 64 | void __init mv78xx0_setup_cpu_mbus(void) |
95 | { | 65 | { |
96 | void __iomem *addr; | ||
97 | int i; | ||
98 | int cs; | ||
99 | |||
100 | /* | 66 | /* |
101 | * First, disable and clear windows. | 67 | * Disable, clear and configure windows. |
102 | */ | 68 | */ |
103 | for (i = 0; i < 14; i++) { | 69 | orion_config_wins(&addr_map_cfg, NULL); |
104 | addr = win_cfg_base(i); | ||
105 | |||
106 | writel(0, addr + WIN_BASE_OFF); | ||
107 | writel(0, addr + WIN_CTRL_OFF); | ||
108 | if (cpu_win_can_remap(i)) { | ||
109 | writel(0, addr + WIN_REMAP_LO_OFF); | ||
110 | writel(0, addr + WIN_REMAP_HI_OFF); | ||
111 | } | ||
112 | } | ||
113 | 70 | ||
114 | /* | 71 | /* |
115 | * Setup MBUS dram target info. | 72 | * Setup MBUS dram target info. |
116 | */ | 73 | */ |
117 | mv78xx0_mbus_dram_info.mbus_dram_target_id = TARGET_DDR; | ||
118 | |||
119 | if (mv78xx0_core_index() == 0) | 74 | if (mv78xx0_core_index() == 0) |
120 | addr = (void __iomem *)DDR_WINDOW_CPU0_BASE; | 75 | orion_setup_cpu_mbus_target(&addr_map_cfg, |
76 | &mv78xx0_mbus_dram_info, | ||
77 | DDR_WINDOW_CPU0_BASE); | ||
121 | else | 78 | else |
122 | addr = (void __iomem *)DDR_WINDOW_CPU1_BASE; | 79 | orion_setup_cpu_mbus_target(&addr_map_cfg, |
123 | 80 | &mv78xx0_mbus_dram_info, | |
124 | for (i = 0, cs = 0; i < 4; i++) { | 81 | DDR_WINDOW_CPU1_BASE); |
125 | u32 base = readl(addr + DDR_BASE_CS_OFF(i)); | ||
126 | u32 size = readl(addr + DDR_SIZE_CS_OFF(i)); | ||
127 | |||
128 | /* | ||
129 | * Chip select enabled? | ||
130 | */ | ||
131 | if (size & 1) { | ||
132 | struct mbus_dram_window *w; | ||
133 | |||
134 | w = &mv78xx0_mbus_dram_info.cs[cs++]; | ||
135 | w->cs_index = i; | ||
136 | w->mbus_attr = 0xf & ~(1 << i); | ||
137 | w->base = base & 0xffff0000; | ||
138 | w->size = (size | 0x0000ffff) + 1; | ||
139 | } | ||
140 | } | ||
141 | mv78xx0_mbus_dram_info.num_cs = cs; | ||
142 | } | 82 | } |
143 | 83 | ||
144 | void __init mv78xx0_setup_pcie_io_win(int window, u32 base, u32 size, | 84 | void __init mv78xx0_setup_pcie_io_win(int window, u32 base, u32 size, |
145 | int maj, int min) | 85 | int maj, int min) |
146 | { | 86 | { |
147 | setup_cpu_win(window, base, size, TARGET_PCIE(maj), | 87 | orion_setup_cpu_win(&addr_map_cfg, window, base, size, |
148 | ATTR_PCIE_IO(min), -1); | 88 | TARGET_PCIE(maj), ATTR_PCIE_IO(min), -1); |
149 | } | 89 | } |
150 | 90 | ||
151 | void __init mv78xx0_setup_pcie_mem_win(int window, u32 base, u32 size, | 91 | void __init mv78xx0_setup_pcie_mem_win(int window, u32 base, u32 size, |
152 | int maj, int min) | 92 | int maj, int min) |
153 | { | 93 | { |
154 | setup_cpu_win(window, base, size, TARGET_PCIE(maj), | 94 | orion_setup_cpu_win(&addr_map_cfg, window, base, size, |
155 | ATTR_PCIE_MEM(min), -1); | 95 | TARGET_PCIE(maj), ATTR_PCIE_MEM(min), -1); |
156 | } | 96 | } |