blob: 73ceb49de894d5c455ccbe7e8931423bae56b5ef [file] [log] [blame]
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -04001/*
2 * arch/arm/mach-orion5x/addr-map.c
3 *
4 * Address map functions for Marvell Orion 5x SoCs
5 *
6 * Maintainer: Tzachi Perelstein <tzachi@marvell.com>
7 *
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.
11 */
12
13#include <linux/kernel.h>
14#include <linux/init.h>
15#include <linux/mbus.h>
Russell Kingfced80c2008-09-06 12:10:45 +010016#include <linux/io.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010017#include <mach/hardware.h>
Andrew Lunnb6d1c332011-12-07 21:48:05 +010018#include <plat/addr-map.h>
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -040019#include "common.h"
20
21/*
Lucas De Marchi25985ed2011-03-30 22:57:33 -030022 * The Orion has fully programmable address map. There's a separate address
Lennert Buytenhekb46926b2008-04-25 16:31:32 -040023 * map for each of the device _master_ interfaces, e.g. CPU, PCI, PCIe, USB,
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -040024 * Gigabit Ethernet, DMA/XOR engines, etc. Each interface has its own
25 * address decode windows that allow it to access any of the Orion resources.
26 *
27 * CPU address decoding --
28 * Linux assumes that it is the boot loader that already setup the access to
29 * DDR and internal registers.
Lennert Buytenhekb46926b2008-04-25 16:31:32 -040030 * Setup access to PCI and PCIe IO/MEM space is issued by this file.
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -040031 * Setup access to various devices located on the device bus interface (e.g.
32 * flashes, RTC, etc) should be issued by machine-setup.c according to
33 * specific board population (by using orion5x_setup_*_win()).
34 *
35 * Non-CPU Masters address decoding --
36 * Unlike the CPU, we setup the access from Orion's master interfaces to DDR
37 * banks only (the typical use case).
Lennert Buytenhekda109892008-04-26 14:48:11 -040038 * Setup access for each master to DDR is issued by platform device setup.
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -040039 */
40
41/*
42 * Generic Address Decode Windows bit settings
43 */
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -040044#define TARGET_DEV_BUS 1
45#define TARGET_PCI 3
46#define TARGET_PCIE 4
Sebastian Andrzej Siewior3a8f7442009-05-07 22:59:24 +020047#define TARGET_SRAM 9
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -040048#define ATTR_PCIE_MEM 0x59
49#define ATTR_PCIE_IO 0x51
50#define ATTR_PCIE_WA 0x79
51#define ATTR_PCI_MEM 0x59
52#define ATTR_PCI_IO 0x51
53#define ATTR_DEV_CS0 0x1e
54#define ATTR_DEV_CS1 0x1d
55#define ATTR_DEV_CS2 0x1b
56#define ATTR_DEV_BOOT 0xf
Sebastian Andrzej Siewior3a8f7442009-05-07 22:59:24 +020057#define ATTR_SRAM 0x0
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -040058
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -040059struct mbus_dram_target_info orion5x_mbus_dram_info;
Lennert Buytenheka18b6582008-05-10 23:20:50 +020060static int __initdata win_alloc_count;
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -040061
Andrew Lunnb6d1c332011-12-07 21:48:05 +010062static int __init cpu_win_can_remap(const struct orion_addr_map_cfg *cfg,
63 const int win)
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -040064{
65 u32 dev, rev;
66
67 orion5x_pcie_id(&dev, &rev);
68 if ((dev == MV88F5281_DEV_ID && win < 4)
69 || (dev == MV88F5182_DEV_ID && win < 2)
Lennert Buytenhek7153c362009-08-03 16:25:12 +020070 || (dev == MV88F5181_DEV_ID && win < 2)
71 || (dev == MV88F6183_DEV_ID && win < 4))
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -040072 return 1;
73
74 return 0;
75}
76
Andrew Lunnb6d1c332011-12-07 21:48:05 +010077/*
78 * Description of the windows needed by the platform code
79 */
80static struct __initdata orion_addr_map_cfg addr_map_cfg = {
81 .num_wins = 8,
82 .cpu_win_can_remap = cpu_win_can_remap,
83 .bridge_virt_base = ORION5X_BRIDGE_VIRT_BASE,
84};
Lennert Buytenheka18b6582008-05-10 23:20:50 +020085
Andrew Lunnb6d1c332011-12-07 21:48:05 +010086static const struct __initdata orion_addr_map_info addr_map_info[] = {
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -040087 /*
88 * Setup windows for PCI+PCIe IO+MEM space.
89 */
Andrew Lunnb6d1c332011-12-07 21:48:05 +010090 { 0, ORION5X_PCIE_IO_PHYS_BASE, ORION5X_PCIE_IO_SIZE,
91 TARGET_PCIE, ATTR_PCIE_IO, ORION5X_PCIE_IO_BUS_BASE
92 },
93 { 1, ORION5X_PCI_IO_PHYS_BASE, ORION5X_PCI_IO_SIZE,
94 TARGET_PCI, ATTR_PCI_IO, ORION5X_PCI_IO_BUS_BASE
95 },
96 { 2, ORION5X_PCIE_MEM_PHYS_BASE, ORION5X_PCIE_MEM_SIZE,
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};
105
106void __init orion5x_setup_cpu_mbus_bridge(void)
107{
108 /*
109 * Disable, clear and configure windows.
110 */
111 orion_config_wins(&addr_map_cfg, addr_map_info);
Lennert Buytenheka18b6582008-05-10 23:20:50 +0200112 win_alloc_count = 4;
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -0400113
114 /*
115 * Setup MBUS dram target info.
116 */
Andrew Lunnb6d1c332011-12-07 21:48:05 +0100117 orion_setup_cpu_mbus_target(&addr_map_cfg, &orion5x_mbus_dram_info,
118 ORION5X_DDR_WINDOW_CPU_BASE);
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -0400119}
120
121void __init orion5x_setup_dev_boot_win(u32 base, u32 size)
122{
Andrew Lunnb6d1c332011-12-07 21:48:05 +0100123 orion_setup_cpu_win(&addr_map_cfg, win_alloc_count++, base, size,
124 TARGET_DEV_BUS, ATTR_DEV_BOOT, -1);
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -0400125}
126
127void __init orion5x_setup_dev0_win(u32 base, u32 size)
128{
Andrew Lunnb6d1c332011-12-07 21:48:05 +0100129 orion_setup_cpu_win(&addr_map_cfg, win_alloc_count++, base, size,
130 TARGET_DEV_BUS, ATTR_DEV_CS0, -1);
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -0400131}
132
133void __init orion5x_setup_dev1_win(u32 base, u32 size)
134{
Andrew Lunnb6d1c332011-12-07 21:48:05 +0100135 orion_setup_cpu_win(&addr_map_cfg, win_alloc_count++, base, size,
136 TARGET_DEV_BUS, ATTR_DEV_CS1, -1);
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -0400137}
138
139void __init orion5x_setup_dev2_win(u32 base, u32 size)
140{
Andrew Lunnb6d1c332011-12-07 21:48:05 +0100141 orion_setup_cpu_win(&addr_map_cfg, win_alloc_count++, base, size,
142 TARGET_DEV_BUS, ATTR_DEV_CS2, -1);
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -0400143}
144
145void __init orion5x_setup_pcie_wa_win(u32 base, u32 size)
146{
Andrew Lunnb6d1c332011-12-07 21:48:05 +0100147 orion_setup_cpu_win(&addr_map_cfg, win_alloc_count++, base, size,
148 TARGET_PCIE, ATTR_PCIE_WA, -1);
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -0400149}
Sebastian Andrzej Siewior3a8f7442009-05-07 22:59:24 +0200150
Andrew Lunnb6d1c332011-12-07 21:48:05 +0100151void __init orion5x_setup_sram_win(void)
Sebastian Andrzej Siewior3a8f7442009-05-07 22:59:24 +0200152{
Andrew Lunnb6d1c332011-12-07 21:48:05 +0100153 orion_setup_cpu_win(&addr_map_cfg, win_alloc_count++,
154 ORION5X_SRAM_PHYS_BASE, ORION5X_SRAM_SIZE,
155 TARGET_SRAM, ATTR_SRAM, -1);
Sebastian Andrzej Siewior3a8f7442009-05-07 22:59:24 +0200156}