2 * arch/arm/mach-loki/addr-map.c
4 * Address map functions for Marvell Loki (88RC8480) SoCs
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.
11 #include <linux/kernel.h>
12 #include <linux/init.h>
13 #include <linux/mbus.h>
15 #include <mach/hardware.h>
19 * Generic Address Decode Windows bit settings
22 #define TARGET_DEV_BUS 1
23 #define TARGET_PCIE0 3
24 #define TARGET_PCIE1 4
25 #define ATTR_DEV_BOOT 0x0f
26 #define ATTR_DEV_CS2 0x1b
27 #define ATTR_DEV_CS1 0x1d
28 #define ATTR_DEV_CS0 0x1e
29 #define ATTR_PCIE_IO 0x51
30 #define ATTR_PCIE_MEM 0x59
33 * Helpers to get DDR bank info
35 #define DDR_SIZE_CS(n) DDR_REG(0x1500 + ((n) << 3))
36 #define DDR_BASE_CS(n) DDR_REG(0x1504 + ((n) << 3))
39 * CPU Address Decode Windows registers
41 #define BRIDGE_REG(x) (BRIDGE_VIRT_BASE | (x))
42 #define CPU_WIN_CTRL(n) BRIDGE_REG(0x000 | ((n) << 4))
43 #define CPU_WIN_BASE(n) BRIDGE_REG(0x004 | ((n) << 4))
44 #define CPU_WIN_REMAP_LO(n) BRIDGE_REG(0x008 | ((n) << 4))
45 #define CPU_WIN_REMAP_HI(n) BRIDGE_REG(0x00c | ((n) << 4))
48 struct mbus_dram_target_info loki_mbus_dram_info;
50 static void __init setup_cpu_win(int win, u32 base, u32 size,
51 u8 target, u8 attr, int remap)
56 ctrl = ((size - 1) & 0xffff0000) | (attr << 8) | (1 << 5) | target;
58 writel(base, CPU_WIN_BASE(win));
59 writel(ctrl, CPU_WIN_CTRL(win));
64 writel(remap & 0xffff0000, CPU_WIN_REMAP_LO(win));
65 writel(0, CPU_WIN_REMAP_HI(win));
69 void __init loki_setup_cpu_mbus(void)
75 * First, disable and clear windows.
77 for (i = 0; i < 8; i++) {
78 writel(0, CPU_WIN_BASE(i));
79 writel(0, CPU_WIN_CTRL(i));
81 writel(0, CPU_WIN_REMAP_LO(i));
82 writel(0, CPU_WIN_REMAP_HI(i));
87 * Setup windows for PCIe IO+MEM space.
89 setup_cpu_win(2, LOKI_PCIE0_MEM_PHYS_BASE, LOKI_PCIE0_MEM_SIZE,
90 TARGET_PCIE0, ATTR_PCIE_MEM, -1);
91 setup_cpu_win(3, LOKI_PCIE1_MEM_PHYS_BASE, LOKI_PCIE1_MEM_SIZE,
92 TARGET_PCIE1, ATTR_PCIE_MEM, -1);
95 * Setup MBUS dram target info.
97 loki_mbus_dram_info.mbus_dram_target_id = TARGET_DDR;
99 for (i = 0, cs = 0; i < 4; i++) {
100 u32 base = readl(DDR_BASE_CS(i));
101 u32 size = readl(DDR_SIZE_CS(i));
104 * Chip select enabled?
107 struct mbus_dram_window *w;
109 w = &loki_mbus_dram_info.cs[cs++];
111 w->mbus_attr = 0xf & ~(1 << i);
112 w->base = base & 0xffff0000;
113 w->size = (size | 0x0000ffff) + 1;
116 loki_mbus_dram_info.num_cs = cs;
119 void __init loki_setup_dev_boot_win(u32 base, u32 size)
121 setup_cpu_win(4, base, size, TARGET_DEV_BUS, ATTR_DEV_BOOT, -1);