Lennert Buytenhek | 9dd0b19 | 2008-03-27 14:51:41 -0400 | [diff] [blame] | 1 | /* |
| 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 King | fced80c | 2008-09-06 12:10:45 +0100 | [diff] [blame] | 16 | #include <linux/io.h> |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 17 | #include <mach/hardware.h> |
Andrew Lunn | b6d1c33 | 2011-12-07 21:48:05 +0100 | [diff] [blame] | 18 | #include <plat/addr-map.h> |
Lennert Buytenhek | 9dd0b19 | 2008-03-27 14:51:41 -0400 | [diff] [blame] | 19 | #include "common.h" |
| 20 | |
| 21 | /* |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 22 | * The Orion has fully programmable address map. There's a separate address |
Lennert Buytenhek | b46926b | 2008-04-25 16:31:32 -0400 | [diff] [blame] | 23 | * map for each of the device _master_ interfaces, e.g. CPU, PCI, PCIe, USB, |
Lennert Buytenhek | 9dd0b19 | 2008-03-27 14:51:41 -0400 | [diff] [blame] | 24 | * 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 Buytenhek | b46926b | 2008-04-25 16:31:32 -0400 | [diff] [blame] | 30 | * Setup access to PCI and PCIe IO/MEM space is issued by this file. |
Lennert Buytenhek | 9dd0b19 | 2008-03-27 14:51:41 -0400 | [diff] [blame] | 31 | * 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 Buytenhek | da10989 | 2008-04-26 14:48:11 -0400 | [diff] [blame] | 38 | * Setup access for each master to DDR is issued by platform device setup. |
Lennert Buytenhek | 9dd0b19 | 2008-03-27 14:51:41 -0400 | [diff] [blame] | 39 | */ |
| 40 | |
| 41 | /* |
| 42 | * Generic Address Decode Windows bit settings |
| 43 | */ |
Lennert Buytenhek | 9dd0b19 | 2008-03-27 14:51:41 -0400 | [diff] [blame] | 44 | #define TARGET_DEV_BUS 1 |
| 45 | #define TARGET_PCI 3 |
| 46 | #define TARGET_PCIE 4 |
Sebastian Andrzej Siewior | 3a8f744 | 2009-05-07 22:59:24 +0200 | [diff] [blame] | 47 | #define TARGET_SRAM 9 |
Lennert Buytenhek | 9dd0b19 | 2008-03-27 14:51:41 -0400 | [diff] [blame] | 48 | #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 Siewior | 3a8f744 | 2009-05-07 22:59:24 +0200 | [diff] [blame] | 57 | #define ATTR_SRAM 0x0 |
Lennert Buytenhek | 9dd0b19 | 2008-03-27 14:51:41 -0400 | [diff] [blame] | 58 | |
Lennert Buytenhek | a18b658 | 2008-05-10 23:20:50 +0200 | [diff] [blame] | 59 | static int __initdata win_alloc_count; |
Lennert Buytenhek | 9dd0b19 | 2008-03-27 14:51:41 -0400 | [diff] [blame] | 60 | |
Andrew Lunn | b6d1c33 | 2011-12-07 21:48:05 +0100 | [diff] [blame] | 61 | static int __init cpu_win_can_remap(const struct orion_addr_map_cfg *cfg, |
| 62 | const int win) |
Lennert Buytenhek | 9dd0b19 | 2008-03-27 14:51:41 -0400 | [diff] [blame] | 63 | { |
| 64 | u32 dev, rev; |
| 65 | |
| 66 | orion5x_pcie_id(&dev, &rev); |
| 67 | if ((dev == MV88F5281_DEV_ID && win < 4) |
| 68 | || (dev == MV88F5182_DEV_ID && win < 2) |
Lennert Buytenhek | 7153c36 | 2009-08-03 16:25:12 +0200 | [diff] [blame] | 69 | || (dev == MV88F5181_DEV_ID && win < 2) |
| 70 | || (dev == MV88F6183_DEV_ID && win < 4)) |
Lennert Buytenhek | 9dd0b19 | 2008-03-27 14:51:41 -0400 | [diff] [blame] | 71 | return 1; |
| 72 | |
| 73 | return 0; |
| 74 | } |
| 75 | |
Andrew Lunn | b6d1c33 | 2011-12-07 21:48:05 +0100 | [diff] [blame] | 76 | /* |
| 77 | * Description of the windows needed by the platform code |
| 78 | */ |
Andrew Lunn | d2621b8 | 2012-05-10 15:59:44 +0200 | [diff] [blame] | 79 | static struct orion_addr_map_cfg addr_map_cfg __initdata = { |
Andrew Lunn | b6d1c33 | 2011-12-07 21:48:05 +0100 | [diff] [blame] | 80 | .num_wins = 8, |
| 81 | .cpu_win_can_remap = cpu_win_can_remap, |
Thomas Petazzoni | 9b7b7d8 | 2012-09-11 14:27:26 +0200 | [diff] [blame] | 82 | .bridge_virt_base = ORION5X_BRIDGE_VIRT_BASE, |
Andrew Lunn | b6d1c33 | 2011-12-07 21:48:05 +0100 | [diff] [blame] | 83 | }; |
Lennert Buytenhek | a18b658 | 2008-05-10 23:20:50 +0200 | [diff] [blame] | 84 | |
Andrew Lunn | b6d1c33 | 2011-12-07 21:48:05 +0100 | [diff] [blame] | 85 | static const struct __initdata orion_addr_map_info addr_map_info[] = { |
Lennert Buytenhek | 9dd0b19 | 2008-03-27 14:51:41 -0400 | [diff] [blame] | 86 | /* |
| 87 | * Setup windows for PCI+PCIe IO+MEM space. |
| 88 | */ |
Andrew Lunn | b6d1c33 | 2011-12-07 21:48:05 +0100 | [diff] [blame] | 89 | { 0, ORION5X_PCIE_IO_PHYS_BASE, ORION5X_PCIE_IO_SIZE, |
| 90 | TARGET_PCIE, ATTR_PCIE_IO, ORION5X_PCIE_IO_BUS_BASE |
| 91 | }, |
| 92 | { 1, ORION5X_PCI_IO_PHYS_BASE, ORION5X_PCI_IO_SIZE, |
| 93 | TARGET_PCI, ATTR_PCI_IO, ORION5X_PCI_IO_BUS_BASE |
| 94 | }, |
| 95 | { 2, ORION5X_PCIE_MEM_PHYS_BASE, ORION5X_PCIE_MEM_SIZE, |
| 96 | TARGET_PCIE, ATTR_PCIE_MEM, -1 |
| 97 | }, |
| 98 | { 3, ORION5X_PCI_MEM_PHYS_BASE, ORION5X_PCI_MEM_SIZE, |
| 99 | TARGET_PCI, ATTR_PCI_MEM, -1 |
| 100 | }, |
| 101 | /* End marker */ |
| 102 | { -1, 0, 0, 0, 0, 0 } |
| 103 | }; |
| 104 | |
| 105 | void __init orion5x_setup_cpu_mbus_bridge(void) |
| 106 | { |
| 107 | /* |
| 108 | * Disable, clear and configure windows. |
| 109 | */ |
| 110 | orion_config_wins(&addr_map_cfg, addr_map_info); |
Lennert Buytenhek | a18b658 | 2008-05-10 23:20:50 +0200 | [diff] [blame] | 111 | win_alloc_count = 4; |
Lennert Buytenhek | 9dd0b19 | 2008-03-27 14:51:41 -0400 | [diff] [blame] | 112 | |
| 113 | /* |
| 114 | * Setup MBUS dram target info. |
| 115 | */ |
Thomas Petazzoni | 9b7b7d8 | 2012-09-11 14:27:26 +0200 | [diff] [blame] | 116 | orion_setup_cpu_mbus_target(&addr_map_cfg, |
| 117 | (void __iomem *) ORION5X_DDR_WINDOW_CPU_BASE); |
Lennert Buytenhek | 9dd0b19 | 2008-03-27 14:51:41 -0400 | [diff] [blame] | 118 | } |
| 119 | |
| 120 | void __init orion5x_setup_dev_boot_win(u32 base, u32 size) |
| 121 | { |
Andrew Lunn | b6d1c33 | 2011-12-07 21:48:05 +0100 | [diff] [blame] | 122 | orion_setup_cpu_win(&addr_map_cfg, win_alloc_count++, base, size, |
| 123 | TARGET_DEV_BUS, ATTR_DEV_BOOT, -1); |
Lennert Buytenhek | 9dd0b19 | 2008-03-27 14:51:41 -0400 | [diff] [blame] | 124 | } |
| 125 | |
| 126 | void __init orion5x_setup_dev0_win(u32 base, u32 size) |
| 127 | { |
Andrew Lunn | b6d1c33 | 2011-12-07 21:48:05 +0100 | [diff] [blame] | 128 | orion_setup_cpu_win(&addr_map_cfg, win_alloc_count++, base, size, |
| 129 | TARGET_DEV_BUS, ATTR_DEV_CS0, -1); |
Lennert Buytenhek | 9dd0b19 | 2008-03-27 14:51:41 -0400 | [diff] [blame] | 130 | } |
| 131 | |
| 132 | void __init orion5x_setup_dev1_win(u32 base, u32 size) |
| 133 | { |
Andrew Lunn | b6d1c33 | 2011-12-07 21:48:05 +0100 | [diff] [blame] | 134 | orion_setup_cpu_win(&addr_map_cfg, win_alloc_count++, base, size, |
| 135 | TARGET_DEV_BUS, ATTR_DEV_CS1, -1); |
Lennert Buytenhek | 9dd0b19 | 2008-03-27 14:51:41 -0400 | [diff] [blame] | 136 | } |
| 137 | |
| 138 | void __init orion5x_setup_dev2_win(u32 base, u32 size) |
| 139 | { |
Andrew Lunn | b6d1c33 | 2011-12-07 21:48:05 +0100 | [diff] [blame] | 140 | orion_setup_cpu_win(&addr_map_cfg, win_alloc_count++, base, size, |
| 141 | TARGET_DEV_BUS, ATTR_DEV_CS2, -1); |
Lennert Buytenhek | 9dd0b19 | 2008-03-27 14:51:41 -0400 | [diff] [blame] | 142 | } |
| 143 | |
| 144 | void __init orion5x_setup_pcie_wa_win(u32 base, u32 size) |
| 145 | { |
Andrew Lunn | b6d1c33 | 2011-12-07 21:48:05 +0100 | [diff] [blame] | 146 | orion_setup_cpu_win(&addr_map_cfg, win_alloc_count++, base, size, |
| 147 | TARGET_PCIE, ATTR_PCIE_WA, -1); |
Lennert Buytenhek | 9dd0b19 | 2008-03-27 14:51:41 -0400 | [diff] [blame] | 148 | } |
Sebastian Andrzej Siewior | 3a8f744 | 2009-05-07 22:59:24 +0200 | [diff] [blame] | 149 | |
Andrew Lunn | b6d1c33 | 2011-12-07 21:48:05 +0100 | [diff] [blame] | 150 | void __init orion5x_setup_sram_win(void) |
Sebastian Andrzej Siewior | 3a8f744 | 2009-05-07 22:59:24 +0200 | [diff] [blame] | 151 | { |
Andrew Lunn | b6d1c33 | 2011-12-07 21:48:05 +0100 | [diff] [blame] | 152 | orion_setup_cpu_win(&addr_map_cfg, win_alloc_count++, |
| 153 | ORION5X_SRAM_PHYS_BASE, ORION5X_SRAM_SIZE, |
| 154 | TARGET_SRAM, ATTR_SRAM, -1); |
Sebastian Andrzej Siewior | 3a8f744 | 2009-05-07 22:59:24 +0200 | [diff] [blame] | 155 | } |