Commit 6f82cb4e authored by Konrad Dybcio's avatar Konrad Dybcio Committed by Jakub Kicinski
Browse files

net: ipa: Grab IMEM slice base/size from DTS



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: default avatarAlex Elder <elder@riscstar.com>
Acked-by: default avatarDmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Reviewed-by: default avatarSimon Horman <horms@kernel.org>
Signed-off-by: default avatarKonrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Link: https://patch.msgid.link/20260302-topic-ipa_imem-v6-3-c0ebbf3eae9f@oss.qualcomm.com


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent f5a598ab
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -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;
};

+23 −1
Original line number Diff line number Diff line
@@ -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;