Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5d8b2584 authored by Skylar Chang's avatar Skylar Chang
Browse files

msm: ipa3: add support for additional mappings to smmu



Add support for getting additional mappings from dtsi in
order to create a mapping on IPA SMMU context bank.

CRs-Fixed: 1046501
Change-Id: Ife4779ee6c20662e2c4d8ffcd16999a675461470
Acked-by: default avatarAdy Abraham <adya@qti.qualcomm.com>
Signed-off-by: default avatarSkylar Chang <chiaweic@codeaurora.org>
parent aee14e5d
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -117,6 +117,9 @@ IPA SMMU sub nodes

- qcom,iova-mapping: specifies the start address and size of iova space.

- qcom,additional-mapping: specifies any addtional mapping needed for this
				context bank. The format is <iova pa size>

IPA SMP2P sub nodes

-compatible: "qcom,smp2pgpio-map-ipa-1-out" - represents the out gpio from
@@ -193,7 +196,10 @@ qcom,ipa@fd4c0000 {
	ipa_smmu_ap: ipa_smmu_ap {
		compatible = "qcom,ipa-smmu-ap-cb";
		iommus = <&anoc2_smmu 0x30>;
		qcom,iova-mapping = <0x10000000 0x40000000>;
		qcom,iova-mapping = <0x20000000 0x40000000>;
		qcom,additional-mapping =
		/* modem tables in IMEM */
		<0x146BD000 0x146BD000 0x2000>;
	};

	ipa_smmu_wlan: ipa_smmu_wlan {
+41 −0
Original line number Diff line number Diff line
@@ -74,6 +74,15 @@
#define IPA3_ACTIVE_CLIENT_LOG_TYPE_RESOURCE 2
#define IPA3_ACTIVE_CLIENT_LOG_TYPE_SPECIAL 3

/* round addresses for closes page per SMMU requirements */
#define IPA_SMMU_ROUND_TO_PAGE(iova, pa, size, iova_p, pa_p, size_p) \
	do { \
		(iova_p) = rounddown((iova), PAGE_SIZE); \
		(pa_p) = rounddown((pa), PAGE_SIZE); \
		(size_p) = roundup((size) + (pa) - (pa_p), PAGE_SIZE); \
	} while (0)


/* The relative location in /lib/firmware where the FWs will reside */
#define IPA_FWS_PATH "ipa/ipa_fws.elf"

@@ -4921,6 +4930,9 @@ static int ipa_smmu_ap_cb_probe(struct device *dev)
	int fast = 1;
	int bypass = 1;
	u32 iova_ap_mapping[2];
	u32 add_map_size;
	const u32 *add_map;
	int i;

	IPADBG("AP CB probe: sub pdev=%p\n", dev);

@@ -5010,6 +5022,35 @@ static int ipa_smmu_ap_cb_probe(struct device *dev)
		return result;
	}

	add_map = of_get_property(dev->of_node,
		"qcom,additional-mapping", &add_map_size);
	if (add_map) {
		/* mapping size is an array of 3-tuple of u32*/
		if (add_map_size % (3 * sizeof(u32))) {
			IPAERR("wrong additional mapping format\n");
			cb->valid = false;
			return -EFAULT;
		}

		/* iterate of each entry of the additional mapping array */
		for (i = 0; i < add_map_size / sizeof(u32); i += 3) {
			u32 iova = be32_to_cpu(add_map[i]);
			u32 pa = be32_to_cpu(add_map[i + 1]);
			u32 size = be32_to_cpu(add_map[i + 2]);
			unsigned long iova_p;
			phys_addr_t pa_p;
			u32 size_p;

			IPA_SMMU_ROUND_TO_PAGE(iova, pa, size,
				iova_p, pa_p, size_p);
			IPADBG("mapping 0x%lx to 0x%pa size %d\n",
				iova_p, &pa_p, size_p);
			ipa3_iommu_map(cb->mapping->domain,
				iova_p, pa_p, size_p,
				IOMMU_READ | IOMMU_WRITE | IOMMU_DEVICE);
		}
	}

	smmu_info.present = true;

	if (!ipa3_bus_scale_table)