blob: 1584726088e4dd4525bd8e120c5fb48467ddc31c [file] [log] [blame]
Saeed Bisharaedabd382009-08-06 15:12:43 +03001/*
2 * arch/arm/mach-dove/addr-map.c
3 *
4 * Address map functions for Marvell Dove 88AP510 SoC
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>
14#include <linux/io.h>
15#include <asm/mach/arch.h>
16#include <asm/setup.h>
Andrew Lunnb6d1c332011-12-07 21:48:05 +010017#include <plat/addr-map.h>
Saeed Bisharaedabd382009-08-06 15:12:43 +030018#include "common.h"
19
20/*
21 * Generic Address Decode Windows bit settings
22 */
23#define TARGET_DDR 0x0
24#define TARGET_BOOTROM 0x1
25#define TARGET_CESA 0x3
26#define TARGET_PCIE0 0x4
27#define TARGET_PCIE1 0x8
28#define TARGET_SCRATCHPAD 0xd
29
30#define ATTR_CESA 0x01
31#define ATTR_BOOTROM 0xfd
32#define ATTR_DEV_SPI0_ROM 0xfe
33#define ATTR_DEV_SPI1_ROM 0xfb
34#define ATTR_PCIE_IO 0xe0
35#define ATTR_PCIE_MEM 0xe8
36#define ATTR_SCRATCHPAD 0x0
37
Saeed Bisharaedabd382009-08-06 15:12:43 +030038struct mbus_dram_target_info dove_mbus_dram_info;
39
40static inline void __iomem *ddr_map_sc(int i)
41{
42 return (void __iomem *)(DOVE_MC_VIRT_BASE + 0x100 + ((i) << 4));
43}
44
Andrew Lunnb6d1c332011-12-07 21:48:05 +010045/*
46 * Description of the windows needed by the platform code
47 */
48static struct __initdata orion_addr_map_cfg addr_map_cfg = {
49 .num_wins = 8,
50 .remappable_wins = 4,
51 .bridge_virt_base = BRIDGE_VIRT_BASE,
52};
Saeed Bisharaedabd382009-08-06 15:12:43 +030053
Andrew Lunnb6d1c332011-12-07 21:48:05 +010054static const struct __initdata orion_addr_map_info addr_map_info[] = {
55 /*
56 * Windows for PCIe IO+MEM space.
57 */
58 { 0, DOVE_PCIE0_IO_PHYS_BASE, DOVE_PCIE0_IO_SIZE,
59 TARGET_PCIE0, ATTR_PCIE_IO, DOVE_PCIE0_IO_BUS_BASE
60 },
61 { 1, DOVE_PCIE1_IO_PHYS_BASE, DOVE_PCIE1_IO_SIZE,
62 TARGET_PCIE1, ATTR_PCIE_IO, DOVE_PCIE1_IO_BUS_BASE
63 },
64 { 2, DOVE_PCIE0_MEM_PHYS_BASE, DOVE_PCIE0_MEM_SIZE,
65 TARGET_PCIE0, ATTR_PCIE_MEM, -1
66 },
67 { 3, DOVE_PCIE1_MEM_PHYS_BASE, DOVE_PCIE1_MEM_SIZE,
68 TARGET_PCIE1, ATTR_PCIE_MEM, -1
69 },
70 /*
71 * Window for CESA engine.
72 */
73 { 4, DOVE_CESA_PHYS_BASE, DOVE_CESA_SIZE,
74 TARGET_CESA, ATTR_CESA, -1
75 },
76 /*
77 * Window to the BootROM for Standby and Sleep Resume
78 */
79 { 5, DOVE_BOOTROM_PHYS_BASE, DOVE_BOOTROM_SIZE,
80 TARGET_BOOTROM, ATTR_BOOTROM, -1
81 },
82 /*
83 * Window to the PMU Scratch Pad space
84 */
85 { 6, DOVE_SCRATCHPAD_PHYS_BASE, DOVE_SCRATCHPAD_SIZE,
86 TARGET_SCRATCHPAD, ATTR_SCRATCHPAD, -1
87 },
88 /* End marker */
89 { -1, 0, 0, 0, 0, 0 }
90};
Saeed Bisharaedabd382009-08-06 15:12:43 +030091
92void __init dove_setup_cpu_mbus(void)
93{
94 int i;
95 int cs;
96
97 /*
Andrew Lunnb6d1c332011-12-07 21:48:05 +010098 * Disable, clear and configure windows.
Saeed Bisharaedabd382009-08-06 15:12:43 +030099 */
Andrew Lunnb6d1c332011-12-07 21:48:05 +0100100 orion_config_wins(&addr_map_cfg, addr_map_info);
Saeed Bisharaedabd382009-08-06 15:12:43 +0300101
102 /*
103 * Setup MBUS dram target info.
104 */
105 dove_mbus_dram_info.mbus_dram_target_id = TARGET_DDR;
106
107 for (i = 0, cs = 0; i < 2; i++) {
108 u32 map = readl(ddr_map_sc(i));
109
110 /*
111 * Chip select enabled?
112 */
113 if (map & 1) {
114 struct mbus_dram_window *w;
115
116 w = &dove_mbus_dram_info.cs[cs++];
117 w->cs_index = i;
118 w->mbus_attr = 0; /* CS address decoding done inside */
119 /* the DDR controller, no need to */
120 /* provide attributes */
121 w->base = map & 0xff800000;
122 w->size = 0x100000 << (((map & 0x000f0000) >> 16) - 4);
123 }
124 }
125 dove_mbus_dram_info.num_cs = cs;
126}