summaryrefslogtreecommitdiffstats
path: root/drivers/of
diff options
context:
space:
mode:
authorMaxime Ripard <maxime.ripard@bootlin.com>2019-04-01 10:56:44 +0200
committerRob Herring <robh@kernel.org>2019-04-10 23:33:47 +0200
commitf83a6e5dea6cf71d39c6b70a07cbe99b4ef48fe1 (patch)
tree773797721d7faffa0054dc42421db2667a2d761e /drivers/of
parentof: address: Retrieve a parent through a callback in __of_translate_address (diff)
downloadlinux-f83a6e5dea6cf71d39c6b70a07cbe99b4ef48fe1.tar.xz
linux-f83a6e5dea6cf71d39c6b70a07cbe99b4ef48fe1.zip
of: address: Add support for the parent DMA bus
Some SoCs have devices that are using a separate bus from the main bus to perform DMA. These buses might have some restrictions and/or different mapping than from the CPU side, so we'd need to express those using the usual dma-ranges, but using a different DT node than the node's parent. Now that the generic interconnect bindings are available, we can model an interconnect with the reserved name "dma-mem" for those use-cases. Reviewed-by: Robin Murphy <robin.murphy@arm.com> Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com> Signed-off-by: Rob Herring <robh@kernel.org>
Diffstat (limited to 'drivers/of')
-rw-r--r--drivers/of/address.c28
1 files changed, 26 insertions, 2 deletions
diff --git a/drivers/of/address.c b/drivers/of/address.c
index 5359a80c4e8c..978427a9d5e6 100644
--- a/drivers/of/address.c
+++ b/drivers/of/address.c
@@ -677,12 +677,30 @@ u64 of_translate_address(struct device_node *dev, const __be32 *in_addr)
}
EXPORT_SYMBOL(of_translate_address);
+static struct device_node *__of_get_dma_parent(const struct device_node *np)
+{
+ struct of_phandle_args args;
+ int ret, index;
+
+ index = of_property_match_string(np, "interconnect-names", "dma-mem");
+ if (index < 0)
+ return of_get_parent(np);
+
+ ret = of_parse_phandle_with_args(np, "interconnects",
+ "#interconnect-cells",
+ index, &args);
+ if (ret < 0)
+ return of_get_parent(np);
+
+ return of_node_get(args.np);
+}
+
u64 of_translate_dma_address(struct device_node *dev, const __be32 *in_addr)
{
struct device_node *host;
u64 ret;
- ret = __of_translate_address(dev, of_get_parent,
+ ret = __of_translate_address(dev, __of_get_dma_parent,
in_addr, "dma-ranges", &host);
if (host) {
@@ -912,9 +930,15 @@ int of_dma_get_range(struct device_node *np, u64 *dma_addr, u64 *paddr, u64 *siz
return -EINVAL;
while (1) {
+ struct device_node *parent;
+
naddr = of_n_addr_cells(node);
nsize = of_n_size_cells(node);
- node = of_get_next_parent(node);
+
+ parent = __of_get_dma_parent(node);
+ of_node_put(node);
+
+ node = parent;
if (!node)
break;