diff --git a/drivers/gpu/msm/kgsl_iommu.c b/drivers/gpu/msm/kgsl_iommu.c index 3c7e4ba64e63..18da7050d17e 100644 --- a/drivers/gpu/msm/kgsl_iommu.c +++ b/drivers/gpu/msm/kgsl_iommu.c @@ -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++) {