aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-orion5x
diff options
context:
space:
mode:
authorAndrew Lunn <andrew@lunn.ch>2011-12-07 15:48:05 -0500
committerNicolas Pitre <nico@fluxnic.net>2011-12-13 18:46:20 -0500
commitb6d1c33a31deb1784c1d34070db6e84fd6f9d870 (patch)
tree18739a6c79b10f0fe69c01be5571e7a5af4d0e21 /arch/arm/mach-orion5x
parent527ef0550d79e3b3a0ef8f5061072075afef6aaf (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-orion5x')
-rw-r--r--arch/arm/mach-orion5x/addr-map.c146
-rw-r--r--arch/arm/mach-orion5x/common.c7
-rw-r--r--arch/arm/mach-orion5x/common.h2
-rw-r--r--arch/arm/mach-orion5x/include/mach/orion5x.h2
4 files changed, 51 insertions, 106 deletions
diff --git a/arch/arm/mach-orion5x/addr-map.c b/arch/arm/mach-orion5x/addr-map.c
index 5ceafdccc456..73ceb49de894 100644
--- a/arch/arm/mach-orion5x/addr-map.c
+++ b/arch/arm/mach-orion5x/addr-map.c
@@ -14,8 +14,8 @@
14#include <linux/init.h> 14#include <linux/init.h>
15#include <linux/mbus.h> 15#include <linux/mbus.h>
16#include <linux/io.h> 16#include <linux/io.h>
17#include <linux/errno.h>
18#include <mach/hardware.h> 17#include <mach/hardware.h>
18#include <plat/addr-map.h>
19#include "common.h" 19#include "common.h"
20 20
21/* 21/*
@@ -41,7 +41,6 @@
41/* 41/*
42 * Generic Address Decode Windows bit settings 42 * Generic Address Decode Windows bit settings
43 */ 43 */
44#define TARGET_DDR 0
45#define TARGET_DEV_BUS 1 44#define TARGET_DEV_BUS 1
46#define TARGET_PCI 3 45#define TARGET_PCI 3
47#define TARGET_PCIE 4 46#define TARGET_PCIE 4
@@ -57,27 +56,11 @@
57#define ATTR_DEV_BOOT 0xf 56#define ATTR_DEV_BOOT 0xf
58#define ATTR_SRAM 0x0 57#define ATTR_SRAM 0x0
59 58
60/*
61 * Helpers to get DDR bank info
62 */
63#define ORION5X_DDR_REG(x) (ORION5X_DDR_VIRT_BASE | (x))
64#define DDR_BASE_CS(n) ORION5X_DDR_REG(0x1500 + ((n) << 3))
65#define DDR_SIZE_CS(n) ORION5X_DDR_REG(0x1504 + ((n) << 3))
66
67/*
68 * CPU Address Decode Windows registers
69 */
70#define ORION5X_BRIDGE_REG(x) (ORION5X_BRIDGE_VIRT_BASE | (x))
71#define CPU_WIN_CTRL(n) ORION5X_BRIDGE_REG(0x000 | ((n) << 4))
72#define CPU_WIN_BASE(n) ORION5X_BRIDGE_REG(0x004 | ((n) << 4))
73#define CPU_WIN_REMAP_LO(n) ORION5X_BRIDGE_REG(0x008 | ((n) << 4))
74#define CPU_WIN_REMAP_HI(n) ORION5X_BRIDGE_REG(0x00c | ((n) << 4))
75
76
77struct mbus_dram_target_info orion5x_mbus_dram_info; 59struct mbus_dram_target_info orion5x_mbus_dram_info;
78static int __initdata win_alloc_count; 60static int __initdata win_alloc_count;
79 61
80static int __init orion5x_cpu_win_can_remap(int win) 62static int __init cpu_win_can_remap(const struct orion_addr_map_cfg *cfg,
63 const int win)
81{ 64{
82 u32 dev, rev; 65 u32 dev, rev;
83 66
@@ -91,116 +74,83 @@ static int __init orion5x_cpu_win_can_remap(int win)
91 return 0; 74 return 0;
92} 75}
93 76
94static int __init setup_cpu_win(int win, u32 base, u32 size, 77/*
95 u8 target, u8 attr, int remap) 78 * Description of the windows needed by the platform code
96{ 79 */
97 if (win >= 8) { 80static struct __initdata orion_addr_map_cfg addr_map_cfg = {
98 printk(KERN_ERR "setup_cpu_win: trying to allocate " 81 .num_wins = 8,
99 "window %d\n", win); 82 .cpu_win_can_remap = cpu_win_can_remap,
100 return -ENOSPC; 83 .bridge_virt_base = ORION5X_BRIDGE_VIRT_BASE,
101 } 84};
102
103 writel(base & 0xffff0000, CPU_WIN_BASE(win));
104 writel(((size - 1) & 0xffff0000) | (attr << 8) | (target << 4) | 1,
105 CPU_WIN_CTRL(win));
106
107 if (orion5x_cpu_win_can_remap(win)) {
108 if (remap < 0)
109 remap = base;
110
111 writel(remap & 0xffff0000, CPU_WIN_REMAP_LO(win));
112 writel(0, CPU_WIN_REMAP_HI(win));
113 }
114 return 0;
115}
116
117void __init orion5x_setup_cpu_mbus_bridge(void)
118{
119 int i;
120 int cs;
121 85
86static const struct __initdata orion_addr_map_info addr_map_info[] = {
122 /* 87 /*
123 * First, disable and clear windows. 88 * Setup windows for PCI+PCIe IO+MEM space.
124 */ 89 */
125 for (i = 0; i < 8; i++) { 90 { 0, ORION5X_PCIE_IO_PHYS_BASE, ORION5X_PCIE_IO_SIZE,
126 writel(0, CPU_WIN_BASE(i)); 91 TARGET_PCIE, ATTR_PCIE_IO, ORION5X_PCIE_IO_BUS_BASE
127 writel(0, CPU_WIN_CTRL(i)); 92 },
128 if (orion5x_cpu_win_can_remap(i)) { 93 { 1, ORION5X_PCI_IO_PHYS_BASE, ORION5X_PCI_IO_SIZE,
129 writel(0, CPU_WIN_REMAP_LO(i)); 94 TARGET_PCI, ATTR_PCI_IO, ORION5X_PCI_IO_BUS_BASE
130 writel(0, CPU_WIN_REMAP_HI(i)); 95 },
131 } 96 { 2, ORION5X_PCIE_MEM_PHYS_BASE, ORION5X_PCIE_MEM_SIZE,
132 } 97 TARGET_PCIE, ATTR_PCIE_MEM, -1
98 },
99 { 3, ORION5X_PCI_MEM_PHYS_BASE, ORION5X_PCI_MEM_SIZE,
100 TARGET_PCI, ATTR_PCI_MEM, -1
101 },
102 /* End marker */
103 { -1, 0, 0, 0, 0, 0 }
104};
133 105
106void __init orion5x_setup_cpu_mbus_bridge(void)
107{
134 /* 108 /*
135 * Setup windows for PCI+PCIe IO+MEM space. 109 * Disable, clear and configure windows.
136 */ 110 */
137 setup_cpu_win(0, ORION5X_PCIE_IO_PHYS_BASE, ORION5X_PCIE_IO_SIZE, 111 orion_config_wins(&addr_map_cfg, addr_map_info);
138 TARGET_PCIE, ATTR_PCIE_IO, ORION5X_PCIE_IO_BUS_BASE);
139 setup_cpu_win(1, ORION5X_PCI_IO_PHYS_BASE, ORION5X_PCI_IO_SIZE,
140 TARGET_PCI, ATTR_PCI_IO, ORION5X_PCI_IO_BUS_BASE);
141 setup_cpu_win(2, ORION5X_PCIE_MEM_PHYS_BASE, ORION5X_PCIE_MEM_SIZE,
142 TARGET_PCIE, ATTR_PCIE_MEM, -1);
143 setup_cpu_win(3, ORION5X_PCI_MEM_PHYS_BASE, ORION5X_PCI_MEM_SIZE,
144 TARGET_PCI, ATTR_PCI_MEM, -1);
145 win_alloc_count = 4; 112 win_alloc_count = 4;
146 113
147 /* 114 /*
148 * Setup MBUS dram target info. 115 * Setup MBUS dram target info.
149 */ 116 */
150 orion5x_mbus_dram_info.mbus_dram_target_id = TARGET_DDR; 117 orion_setup_cpu_mbus_target(&addr_map_cfg, &orion5x_mbus_dram_info,
151 118 ORION5X_DDR_WINDOW_CPU_BASE);
152 for (i = 0, cs = 0; i < 4; i++) {
153 u32 base = readl(DDR_BASE_CS(i));
154 u32 size = readl(DDR_SIZE_CS(i));
155
156 /*
157 * Chip select enabled?
158 */
159 if (size & 1) {
160 struct mbus_dram_window *w;
161
162 w = &orion5x_mbus_dram_info.cs[cs++];
163 w->cs_index = i;
164 w->mbus_attr = 0xf & ~(1 << i);
165 w->base = base & 0xffff0000;
166 w->size = (size | 0x0000ffff) + 1;
167 }
168 }
169 orion5x_mbus_dram_info.num_cs = cs;
170} 119}
171 120
172void __init orion5x_setup_dev_boot_win(u32 base, u32 size) 121void __init orion5x_setup_dev_boot_win(u32 base, u32 size)
173{ 122{
174 setup_cpu_win(win_alloc_count++, base, size, 123 orion_setup_cpu_win(&addr_map_cfg, win_alloc_count++, base, size,
175 TARGET_DEV_BUS, ATTR_DEV_BOOT, -1); 124 TARGET_DEV_BUS, ATTR_DEV_BOOT, -1);
176} 125}
177 126
178void __init orion5x_setup_dev0_win(u32 base, u32 size) 127void __init orion5x_setup_dev0_win(u32 base, u32 size)
179{ 128{
180 setup_cpu_win(win_alloc_count++, base, size, 129 orion_setup_cpu_win(&addr_map_cfg, win_alloc_count++, base, size,
181 TARGET_DEV_BUS, ATTR_DEV_CS0, -1); 130 TARGET_DEV_BUS, ATTR_DEV_CS0, -1);
182} 131}
183 132
184void __init orion5x_setup_dev1_win(u32 base, u32 size) 133void __init orion5x_setup_dev1_win(u32 base, u32 size)
185{ 134{
186 setup_cpu_win(win_alloc_count++, base, size, 135 orion_setup_cpu_win(&addr_map_cfg, win_alloc_count++, base, size,
187 TARGET_DEV_BUS, ATTR_DEV_CS1, -1); 136 TARGET_DEV_BUS, ATTR_DEV_CS1, -1);
188} 137}
189 138
190void __init orion5x_setup_dev2_win(u32 base, u32 size) 139void __init orion5x_setup_dev2_win(u32 base, u32 size)
191{ 140{
192 setup_cpu_win(win_alloc_count++, base, size, 141 orion_setup_cpu_win(&addr_map_cfg, win_alloc_count++, base, size,
193 TARGET_DEV_BUS, ATTR_DEV_CS2, -1); 142 TARGET_DEV_BUS, ATTR_DEV_CS2, -1);
194} 143}
195 144
196void __init orion5x_setup_pcie_wa_win(u32 base, u32 size) 145void __init orion5x_setup_pcie_wa_win(u32 base, u32 size)
197{ 146{
198 setup_cpu_win(win_alloc_count++, base, size, 147 orion_setup_cpu_win(&addr_map_cfg, win_alloc_count++, base, size,
199 TARGET_PCIE, ATTR_PCIE_WA, -1); 148 TARGET_PCIE, ATTR_PCIE_WA, -1);
200} 149}
201 150
202int __init orion5x_setup_sram_win(void) 151void __init orion5x_setup_sram_win(void)
203{ 152{
204 return setup_cpu_win(win_alloc_count++, ORION5X_SRAM_PHYS_BASE, 153 orion_setup_cpu_win(&addr_map_cfg, win_alloc_count++,
205 ORION5X_SRAM_SIZE, TARGET_SRAM, ATTR_SRAM, -1); 154 ORION5X_SRAM_PHYS_BASE, ORION5X_SRAM_SIZE,
155 TARGET_SRAM, ATTR_SRAM, -1);
206} 156}
diff --git a/arch/arm/mach-orion5x/common.c b/arch/arm/mach-orion5x/common.c
index 22ace0bf2f92..47ca0ee44a6a 100644
--- a/arch/arm/mach-orion5x/common.c
+++ b/arch/arm/mach-orion5x/common.c
@@ -169,12 +169,7 @@ void __init orion5x_xor_init(void)
169 ****************************************************************************/ 169 ****************************************************************************/
170static void __init orion5x_crypto_init(void) 170static void __init orion5x_crypto_init(void)
171{ 171{
172 int ret; 172 orion5x_setup_sram_win();
173
174 ret = orion5x_setup_sram_win();
175 if (ret)
176 return;
177
178 orion_crypto_init(ORION5X_CRYPTO_PHYS_BASE, ORION5X_SRAM_PHYS_BASE, 173 orion_crypto_init(ORION5X_CRYPTO_PHYS_BASE, ORION5X_SRAM_PHYS_BASE,
179 SZ_8K, IRQ_ORION5X_CESA); 174 SZ_8K, IRQ_ORION5X_CESA);
180} 175}
diff --git a/arch/arm/mach-orion5x/common.h b/arch/arm/mach-orion5x/common.h
index 909489f4d23e..465e8a458bfb 100644
--- a/arch/arm/mach-orion5x/common.h
+++ b/arch/arm/mach-orion5x/common.h
@@ -27,7 +27,7 @@ void orion5x_setup_dev0_win(u32 base, u32 size);
27void orion5x_setup_dev1_win(u32 base, u32 size); 27void orion5x_setup_dev1_win(u32 base, u32 size);
28void orion5x_setup_dev2_win(u32 base, u32 size); 28void orion5x_setup_dev2_win(u32 base, u32 size);
29void orion5x_setup_pcie_wa_win(u32 base, u32 size); 29void orion5x_setup_pcie_wa_win(u32 base, u32 size);
30int orion5x_setup_sram_win(void); 30void orion5x_setup_sram_win(void);
31 31
32void orion5x_ehci0_init(void); 32void orion5x_ehci0_init(void);
33void orion5x_ehci1_init(void); 33void orion5x_ehci1_init(void);
diff --git a/arch/arm/mach-orion5x/include/mach/orion5x.h b/arch/arm/mach-orion5x/include/mach/orion5x.h
index 0a28bbc76891..2745f5d95b3f 100644
--- a/arch/arm/mach-orion5x/include/mach/orion5x.h
+++ b/arch/arm/mach-orion5x/include/mach/orion5x.h
@@ -69,7 +69,7 @@
69 ******************************************************************************/ 69 ******************************************************************************/
70 70
71#define ORION5X_DDR_VIRT_BASE (ORION5X_REGS_VIRT_BASE | 0x00000) 71#define ORION5X_DDR_VIRT_BASE (ORION5X_REGS_VIRT_BASE | 0x00000)
72 72#define ORION5X_DDR_WINDOW_CPU_BASE (ORION5X_DDR_VIRT_BASE | 0x1500)
73#define ORION5X_DEV_BUS_PHYS_BASE (ORION5X_REGS_PHYS_BASE | 0x10000) 73#define ORION5X_DEV_BUS_PHYS_BASE (ORION5X_REGS_PHYS_BASE | 0x10000)
74#define ORION5X_DEV_BUS_VIRT_BASE (ORION5X_REGS_VIRT_BASE | 0x10000) 74#define ORION5X_DEV_BUS_VIRT_BASE (ORION5X_REGS_VIRT_BASE | 0x10000)
75#define ORION5X_DEV_BUS_REG(x) (ORION5X_DEV_BUS_VIRT_BASE | (x)) 75#define ORION5X_DEV_BUS_REG(x) (ORION5X_DEV_BUS_VIRT_BASE | (x))