aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/bus
diff options
context:
space:
mode:
authorEzequiel Garcia <ezequiel.garcia@free-electrons.com>2013-07-26 09:17:47 -0400
committerJason Cooper <jason@lakedaemon.net>2013-08-06 10:10:34 -0400
commit79d946837c042fba3e9ba2726f3cfa56aa408e16 (patch)
tree653155108fb343b6ef5f5a40b8f601d351f0fcd8 /drivers/bus
parentbb24cab39c7b6971db88d9a72d8d661b9ee887ea (diff)
bus: mvebu-mbus: Add new API for the PCIe memory and IO aperture
We add two optional properties to the MBus DT binding, to encode the PCIe memory and IO aperture. This allows such information to be retrieved by -for instance- the pci driver to allocate the MBus decoding windows. Correspondingly, and in order to retrieve this information, we add two new APIs. Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com> Tested-by: Andrew Lunn <andrew@lunn.ch> Tested-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com> Signed-off-by: Jason Cooper <jason@lakedaemon.net>
Diffstat (limited to 'drivers/bus')
-rw-r--r--drivers/bus/mvebu-mbus.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/drivers/bus/mvebu-mbus.c b/drivers/bus/mvebu-mbus.c
index 78b8c0436f0b..929fed1f6eb9 100644
--- a/drivers/bus/mvebu-mbus.c
+++ b/drivers/bus/mvebu-mbus.c
@@ -142,6 +142,8 @@ struct mvebu_mbus_state {
142 struct dentry *debugfs_root; 142 struct dentry *debugfs_root;
143 struct dentry *debugfs_sdram; 143 struct dentry *debugfs_sdram;
144 struct dentry *debugfs_devs; 144 struct dentry *debugfs_devs;
145 struct resource pcie_mem_aperture;
146 struct resource pcie_io_aperture;
145 const struct mvebu_mbus_soc_data *soc; 147 const struct mvebu_mbus_soc_data *soc;
146 int hw_io_coherency; 148 int hw_io_coherency;
147}; 149};
@@ -821,6 +823,20 @@ int mvebu_mbus_del_window(phys_addr_t base, size_t size)
821 return 0; 823 return 0;
822} 824}
823 825
826void mvebu_mbus_get_pcie_mem_aperture(struct resource *res)
827{
828 if (!res)
829 return;
830 *res = mbus_state.pcie_mem_aperture;
831}
832
833void mvebu_mbus_get_pcie_io_aperture(struct resource *res)
834{
835 if (!res)
836 return;
837 *res = mbus_state.pcie_io_aperture;
838}
839
824static __init int mvebu_mbus_debugfs_init(void) 840static __init int mvebu_mbus_debugfs_init(void)
825{ 841{
826 struct mvebu_mbus_state *s = &mbus_state; 842 struct mvebu_mbus_state *s = &mbus_state;
@@ -1023,6 +1039,35 @@ static int __init mbus_dt_setup(struct mvebu_mbus_state *mbus,
1023 return 0; 1039 return 0;
1024} 1040}
1025 1041
1042static void __init mvebu_mbus_get_pcie_resources(struct device_node *np,
1043 struct resource *mem,
1044 struct resource *io)
1045{
1046 u32 reg[2];
1047 int ret;
1048
1049 /*
1050 * These are optional, so we clear them and they'll
1051 * be zero if they are missing from the DT.
1052 */
1053 memset(mem, 0, sizeof(struct resource));
1054 memset(io, 0, sizeof(struct resource));
1055
1056 ret = of_property_read_u32_array(np, "pcie-mem-aperture", reg, ARRAY_SIZE(reg));
1057 if (!ret) {
1058 mem->start = reg[0];
1059 mem->end = mem->start + reg[1];
1060 mem->flags = IORESOURCE_MEM;
1061 }
1062
1063 ret = of_property_read_u32_array(np, "pcie-io-aperture", reg, ARRAY_SIZE(reg));
1064 if (!ret) {
1065 io->start = reg[0];
1066 io->end = io->start + reg[1];
1067 io->flags = IORESOURCE_IO;
1068 }
1069}
1070
1026int __init mvebu_mbus_dt_init(void) 1071int __init mvebu_mbus_dt_init(void)
1027{ 1072{
1028 struct resource mbuswins_res, sdramwins_res; 1073 struct resource mbuswins_res, sdramwins_res;
@@ -1062,6 +1107,10 @@ int __init mvebu_mbus_dt_init(void)
1062 return -EINVAL; 1107 return -EINVAL;
1063 } 1108 }
1064 1109
1110 /* Get optional pcie-{mem,io}-aperture properties */
1111 mvebu_mbus_get_pcie_resources(np, &mbus_state.pcie_mem_aperture,
1112 &mbus_state.pcie_io_aperture);
1113
1065 ret = mvebu_mbus_common_init(&mbus_state, 1114 ret = mvebu_mbus_common_init(&mbus_state,
1066 mbuswins_res.start, 1115 mbuswins_res.start,
1067 resource_size(&mbuswins_res), 1116 resource_size(&mbuswins_res),