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

Commit 00a1ef12 authored by Jordan Crouse's avatar Jordan Crouse
Browse files

msm: kgsl: Move the IOMMU clocks to the KGSL device



Move ownership of the IOMMU clocks to the KGSL device and get them from
there during IOMMU probe.  This ensures that the clocks are owned by a
proper platform device that can sync_state() after we are done probing.

Change-Id: Ic0dedbad97783984f7d8d1c3c2252a1a8a812d77
Signed-off-by: default avatarJordan Crouse <jcrouse@codeaurora.org>
parent 0c46c9a3
Loading
Loading
Loading
Loading
+30 −15
Original line number Diff line number Diff line
@@ -2515,13 +2515,17 @@ static const struct {
	{ "qcom,force-32bit", KGSL_MMU_FORCE_32BIT },
};

static const char * const kgsl_iommu_clocks[] = {
	"gcc_gpu_memnoc_gfx",
	"gcc_gpu_snoc_dvm_gfx",
	"gpu_cc_ahb",
};

static int _kgsl_iommu_probe(struct kgsl_device *device,
		struct device_node *node)
{
	const char *cname;
	struct property *prop;
	u32 reg_val[2];
	int i = 0, ret;
	int ret, i, index = 0;
	struct kgsl_iommu *iommu = KGSL_IOMMU_PRIV(device);
	struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
	struct platform_device *pdev = of_find_device_by_node(node);
@@ -2538,23 +2542,34 @@ static int _kgsl_iommu_probe(struct kgsl_device *device,
	iommu->regstart = reg_val[0];
	iommu->regsize = reg_val[1];

	of_property_for_each_string(node, "clock-names", prop, cname) {
		struct clk *c = devm_clk_get(&pdev->dev, cname);
	/* Get the clock from the KGSL device */
	for (i = 0; i < ARRAY_SIZE(kgsl_iommu_clocks); i++) {
		struct clk *c;

		if (IS_ERR(c)) {
			dev_err(device->dev,
				"dt: Couldn't get clock: %s\n", cname);
			platform_device_put(pdev);
			return -ENODEV;
		}
		if (i >= KGSL_IOMMU_MAX_CLKS) {
			dev_err(device->dev, "dt: too many clocks defined.\n");
		/*
		 * First try to get the clocks from the parent device and if
		 * that doesn't work fall back to getting them from the iommu
		 * platform device
		 */
		c = devm_clk_get(&device->pdev->dev, kgsl_iommu_clocks[i]);
		if (IS_ERR(c))
			c = devm_clk_get(&pdev->dev, kgsl_iommu_clocks[i]);

		/*
		 * The list of clock names may diverge over the years so don't
		 * worry if we can't get a specific clock, eventually we'll get
		 * all the ones we need if we walk the list
		 */
		if (IS_ERR(c))
			continue;

		if (index >= KGSL_IOMMU_MAX_CLKS) {
			dev_err(device->dev, "dt: too many clocks defined\n");
			platform_device_put(pdev);
			return -EINVAL;
		}

		iommu->clks[i] = c;
		++i;
		iommu->clks[index++] = c;
	}

	for (i = 0; i < ARRAY_SIZE(kgsl_iommu_features); i++) {