]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
net: ipa: Grab IMEM slice base/size from DTS
authorKonrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Mon, 2 Mar 2026 15:58:45 +0000 (16:58 +0100)
committerJakub Kicinski <kuba@kernel.org>
Wed, 4 Mar 2026 01:22:14 +0000 (17:22 -0800)
This is a detail that differ per chip, and not per IPA version (and
there are cases of the same IPA versions being implemented across very
very very different SoCs).

This region isn't actually used by the driver, but we most definitely
want to iommu-map it, so that IPA can poke at the data within.

Reviewed-by: Alex Elder <elder@riscstar.com>
Acked-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Signed-off-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Link: https://patch.msgid.link/20260302-topic-ipa_imem-v6-3-c0ebbf3eae9f@oss.qualcomm.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ipa/ipa_data.h
drivers/net/ipa/ipa_mem.c

index 2fd03f0799b207833f9f2b421ce043534720d718..f3bdc64cef05d00a47184ada4f128a5f1a84f934 100644 (file)
@@ -185,8 +185,13 @@ struct ipa_resource_data {
 struct ipa_mem_data {
        u32 local_count;
        const struct ipa_mem *local;
-       u32 imem_addr;
-       u32 imem_size;
+
+       /* These values are now passed via DT, but to support
+        * older systems we must allow this to be specified here.
+        */
+       u32 imem_addr; /* DEPRECATED */
+       u32 imem_size; /* DEPRECATED */
+
        u32 smem_size;
 };
 
index 835a3c9c1fd47167da3396424a1653ebcae81d40..078d32a18dbfdedbae08e4f62b63abb86b7bab26 100644 (file)
@@ -7,6 +7,7 @@
 #include <linux/dma-mapping.h>
 #include <linux/io.h>
 #include <linux/iommu.h>
+#include <linux/of_address.h>
 #include <linux/platform_device.h>
 #include <linux/types.h>
 
@@ -617,7 +618,9 @@ static void ipa_smem_exit(struct ipa *ipa)
 int ipa_mem_init(struct ipa *ipa, struct platform_device *pdev,
                 const struct ipa_mem_data *mem_data)
 {
+       struct device_node *ipa_slice_np;
        struct device *dev = &pdev->dev;
+       u32 imem_base, imem_size;
        struct resource *res;
        int ret;
 
@@ -656,7 +659,26 @@ int ipa_mem_init(struct ipa *ipa, struct platform_device *pdev,
        ipa->mem_addr = res->start;
        ipa->mem_size = resource_size(res);
 
-       ret = ipa_imem_init(ipa, mem_data->imem_addr, mem_data->imem_size);
+       ipa_slice_np = of_parse_phandle(dev->of_node, "sram", 0);
+       if (ipa_slice_np) {
+               struct resource sram_res;
+
+               ret = of_address_to_resource(ipa_slice_np, 0, &sram_res);
+               of_node_put(ipa_slice_np);
+               if (ret)
+                       goto err_unmap;
+
+               imem_base = sram_res.start;
+               imem_size = resource_size(&sram_res);
+       } else {
+               /* Backwards compatibility for DTs lacking
+                * an explicit reference
+                */
+               imem_base = mem_data->imem_addr;
+               imem_size = mem_data->imem_size;
+       }
+
+       ret = ipa_imem_init(ipa, imem_base, imem_size);
        if (ret)
                goto err_unmap;