blob: 6b14555e5766aa73e16b298cc2dac3d054ff764c [file] [log] [blame]
Stanislav Samsonov794d15b2008-06-22 22:45:10 +02001/*
2 * arch/arm/mach-mv78xx0/addr-map.c
3 *
4 * Address map functions for Marvell MV78xx0 SoCs
5 *
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.
9 */
10
11#include <linux/kernel.h>
12#include <linux/init.h>
13#include <linux/mbus.h>
Russell Kingfced80c2008-09-06 12:10:45 +010014#include <linux/io.h>
Andrew Lunnb6d1c332011-12-07 21:48:05 +010015#include <plat/addr-map.h>
Stanislav Samsonov794d15b2008-06-22 22:45:10 +020016#include "common.h"
17
18/*
19 * Generic Address Decode Windows bit settings
20 */
Stanislav Samsonov794d15b2008-06-22 22:45:10 +020021#define TARGET_DEV_BUS 1
22#define TARGET_PCIE0 4
23#define TARGET_PCIE1 8
24#define TARGET_PCIE(i) ((i) ? TARGET_PCIE1 : TARGET_PCIE0)
25#define ATTR_DEV_SPI_ROM 0x1f
26#define ATTR_DEV_BOOT 0x2f
27#define ATTR_DEV_CS3 0x37
28#define ATTR_DEV_CS2 0x3b
29#define ATTR_DEV_CS1 0x3d
30#define ATTR_DEV_CS0 0x3e
31#define ATTR_PCIE_IO(l) (0xf0 & ~(0x10 << (l)))
32#define ATTR_PCIE_MEM(l) (0xf8 & ~(0x10 << (l)))
33
34/*
Stanislav Samsonov794d15b2008-06-22 22:45:10 +020035 * CPU Address Decode Windows registers
36 */
37#define WIN0_OFF(n) (BRIDGE_VIRT_BASE + 0x0000 + ((n) << 4))
38#define WIN8_OFF(n) (BRIDGE_VIRT_BASE + 0x0900 + (((n) - 8) << 4))
Stanislav Samsonov794d15b2008-06-22 22:45:10 +020039
40struct mbus_dram_target_info mv78xx0_mbus_dram_info;
41
42static void __init __iomem *win_cfg_base(int win)
43{
44 /*
45 * Find the control register base address for this window.
46 *
47 * BRIDGE_VIRT_BASE points to the right (CPU0's or CPU1's)
48 * MBUS bridge depending on which CPU core we're running on,
49 * so we don't need to take that into account here.
50 */
51
52 return (void __iomem *)((win < 8) ? WIN0_OFF(win) : WIN8_OFF(win));
53}
54
Andrew Lunnb6d1c332011-12-07 21:48:05 +010055/*
56 * Description of the windows needed by the platform code
57 */
58static struct __initdata orion_addr_map_cfg addr_map_cfg = {
59 .num_wins = 14,
60 .remappable_wins = 8,
61 .win_cfg_base = win_cfg_base,
62};
Stanislav Samsonov794d15b2008-06-22 22:45:10 +020063
64void __init mv78xx0_setup_cpu_mbus(void)
65{
Stanislav Samsonov794d15b2008-06-22 22:45:10 +020066 /*
Andrew Lunnb6d1c332011-12-07 21:48:05 +010067 * Disable, clear and configure windows.
Stanislav Samsonov794d15b2008-06-22 22:45:10 +020068 */
Andrew Lunnb6d1c332011-12-07 21:48:05 +010069 orion_config_wins(&addr_map_cfg, NULL);
Stanislav Samsonov794d15b2008-06-22 22:45:10 +020070
71 /*
72 * Setup MBUS dram target info.
73 */
Stanislav Samsonov794d15b2008-06-22 22:45:10 +020074 if (mv78xx0_core_index() == 0)
Andrew Lunnb6d1c332011-12-07 21:48:05 +010075 orion_setup_cpu_mbus_target(&addr_map_cfg,
76 &mv78xx0_mbus_dram_info,
77 DDR_WINDOW_CPU0_BASE);
Stanislav Samsonov794d15b2008-06-22 22:45:10 +020078 else
Andrew Lunnb6d1c332011-12-07 21:48:05 +010079 orion_setup_cpu_mbus_target(&addr_map_cfg,
80 &mv78xx0_mbus_dram_info,
81 DDR_WINDOW_CPU1_BASE);
Stanislav Samsonov794d15b2008-06-22 22:45:10 +020082}
83
84void __init mv78xx0_setup_pcie_io_win(int window, u32 base, u32 size,
85 int maj, int min)
86{
Andrew Lunnb6d1c332011-12-07 21:48:05 +010087 orion_setup_cpu_win(&addr_map_cfg, window, base, size,
88 TARGET_PCIE(maj), ATTR_PCIE_IO(min), -1);
Stanislav Samsonov794d15b2008-06-22 22:45:10 +020089}
90
91void __init mv78xx0_setup_pcie_mem_win(int window, u32 base, u32 size,
92 int maj, int min)
93{
Andrew Lunnb6d1c332011-12-07 21:48:05 +010094 orion_setup_cpu_win(&addr_map_cfg, window, base, size,
95 TARGET_PCIE(maj), ATTR_PCIE_MEM(min), -1);
Stanislav Samsonov794d15b2008-06-22 22:45:10 +020096}