From: Konrad Dybcio <konrad.dybcio@linaro.org> To: Rob Clark <robdclark@gmail.com>, Will Deacon <will@kernel.org>, Robin Murphy <robin.murphy@arm.com>, Joerg Roedel <joro@8bytes.org> Cc: iommu@lists.linux.dev, linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Stephan Gerhold <stephan@gerhold.net>, Marijn Suijten <marijn.suijten@somainline.org>, Konrad Dybcio <konrad.dybcio@linaro.org> Subject: [PATCH 2/2] iommu/qcom: Always consume all clocks Date: Wed, 17 Apr 2024 22:07:00 +0200 [thread overview] Message-ID: <20240416-topic-qcom_iommu-v1-2-fabe55b3b7b3@linaro.org> (raw) In-Reply-To: <20240416-topic-qcom_iommu-v1-0-fabe55b3b7b3@linaro.org> Some platforms provide more clocks than others, we already have the DT schema to ensure sanity here plus these clocks simply need to be on. Use devm_clk_bulk_get_all and get rid of some boilerplate. Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org> --- drivers/iommu/arm/arm-smmu/qcom_iommu.c | 38 +++++++-------------------------- 1 file changed, 8 insertions(+), 30 deletions(-) diff --git a/drivers/iommu/arm/arm-smmu/qcom_iommu.c b/drivers/iommu/arm/arm-smmu/qcom_iommu.c index 3dca9293c509..ace69030a422 100644 --- a/drivers/iommu/arm/arm-smmu/qcom_iommu.c +++ b/drivers/iommu/arm/arm-smmu/qcom_iommu.c @@ -34,13 +34,6 @@ #define SMMU_INTR_SEL_NS 0x2000 -enum qcom_iommu_clk { - CLK_IFACE, - CLK_BUS, - CLK_TBU, - CLK_NUM, -}; - struct qcom_iommu_ctx { struct device *dev; void __iomem *base; @@ -54,7 +47,8 @@ struct qcom_iommu_dev { /* IOMMU core code handle */ struct iommu_device iommu; struct device *dev; - struct clk_bulk_data clks[CLK_NUM]; + struct clk_bulk_data *clks; + int num_clks; void __iomem *local_base; u32 sec_id; u8 max_asid; @@ -781,7 +775,6 @@ static int qcom_iommu_device_probe(struct platform_device *pdev) struct qcom_iommu_dev *qcom_iommu; struct device *dev = &pdev->dev; struct resource *res; - struct clk *clk; int ret, max_asid = 0; /* find the max asid (which is 1:1 to ctx bank idx), so we know how @@ -804,26 +797,11 @@ static int qcom_iommu_device_probe(struct platform_device *pdev) return PTR_ERR(qcom_iommu->local_base); } - clk = devm_clk_get(dev, "iface"); - if (IS_ERR(clk)) { - dev_err(dev, "failed to get iface clock\n"); - return PTR_ERR(clk); - } - qcom_iommu->clks[CLK_IFACE].clk = clk; - - clk = devm_clk_get(dev, "bus"); - if (IS_ERR(clk)) { - dev_err(dev, "failed to get bus clock\n"); - return PTR_ERR(clk); - } - qcom_iommu->clks[CLK_BUS].clk = clk; + ret = devm_clk_bulk_get_all(dev, &qcom_iommu->clks); + if (ret <= 0) + return dev_err_probe(dev, ret, "Couldn't get clocks\n"); - clk = devm_clk_get_optional(dev, "tbu"); - if (IS_ERR(clk)) { - dev_err(dev, "failed to get tbu clock\n"); - return PTR_ERR(clk); - } - qcom_iommu->clks[CLK_TBU].clk = clk; + qcom_iommu->num_clks = ret; if (of_property_read_u32(dev->of_node, "qcom,iommu-secure-id", &qcom_iommu->sec_id)) { @@ -891,7 +869,7 @@ static int __maybe_unused qcom_iommu_resume(struct device *dev) struct qcom_iommu_dev *qcom_iommu = dev_get_drvdata(dev); int ret; - ret = clk_bulk_prepare_enable(CLK_NUM, qcom_iommu->clks); + ret = clk_bulk_prepare_enable(qcom_iommu->num_clks, qcom_iommu->clks); if (ret < 0) return ret; @@ -905,7 +883,7 @@ static int __maybe_unused qcom_iommu_suspend(struct device *dev) { struct qcom_iommu_dev *qcom_iommu = dev_get_drvdata(dev); - clk_bulk_disable_unprepare(CLK_NUM, qcom_iommu->clks); + clk_bulk_disable_unprepare(qcom_iommu->num_clks, qcom_iommu->clks); return 0; } -- 2.44.0
WARNING: multiple messages have this Message-ID (diff)
From: Konrad Dybcio <konrad.dybcio@linaro.org> To: Rob Clark <robdclark@gmail.com>, Will Deacon <will@kernel.org>, Robin Murphy <robin.murphy@arm.com>, Joerg Roedel <joro@8bytes.org> Cc: iommu@lists.linux.dev, linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Stephan Gerhold <stephan@gerhold.net>, Marijn Suijten <marijn.suijten@somainline.org>, Konrad Dybcio <konrad.dybcio@linaro.org> Subject: [PATCH 2/2] iommu/qcom: Always consume all clocks Date: Wed, 17 Apr 2024 22:07:00 +0200 [thread overview] Message-ID: <20240416-topic-qcom_iommu-v1-2-fabe55b3b7b3@linaro.org> (raw) In-Reply-To: <20240416-topic-qcom_iommu-v1-0-fabe55b3b7b3@linaro.org> Some platforms provide more clocks than others, we already have the DT schema to ensure sanity here plus these clocks simply need to be on. Use devm_clk_bulk_get_all and get rid of some boilerplate. Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org> --- drivers/iommu/arm/arm-smmu/qcom_iommu.c | 38 +++++++-------------------------- 1 file changed, 8 insertions(+), 30 deletions(-) diff --git a/drivers/iommu/arm/arm-smmu/qcom_iommu.c b/drivers/iommu/arm/arm-smmu/qcom_iommu.c index 3dca9293c509..ace69030a422 100644 --- a/drivers/iommu/arm/arm-smmu/qcom_iommu.c +++ b/drivers/iommu/arm/arm-smmu/qcom_iommu.c @@ -34,13 +34,6 @@ #define SMMU_INTR_SEL_NS 0x2000 -enum qcom_iommu_clk { - CLK_IFACE, - CLK_BUS, - CLK_TBU, - CLK_NUM, -}; - struct qcom_iommu_ctx { struct device *dev; void __iomem *base; @@ -54,7 +47,8 @@ struct qcom_iommu_dev { /* IOMMU core code handle */ struct iommu_device iommu; struct device *dev; - struct clk_bulk_data clks[CLK_NUM]; + struct clk_bulk_data *clks; + int num_clks; void __iomem *local_base; u32 sec_id; u8 max_asid; @@ -781,7 +775,6 @@ static int qcom_iommu_device_probe(struct platform_device *pdev) struct qcom_iommu_dev *qcom_iommu; struct device *dev = &pdev->dev; struct resource *res; - struct clk *clk; int ret, max_asid = 0; /* find the max asid (which is 1:1 to ctx bank idx), so we know how @@ -804,26 +797,11 @@ static int qcom_iommu_device_probe(struct platform_device *pdev) return PTR_ERR(qcom_iommu->local_base); } - clk = devm_clk_get(dev, "iface"); - if (IS_ERR(clk)) { - dev_err(dev, "failed to get iface clock\n"); - return PTR_ERR(clk); - } - qcom_iommu->clks[CLK_IFACE].clk = clk; - - clk = devm_clk_get(dev, "bus"); - if (IS_ERR(clk)) { - dev_err(dev, "failed to get bus clock\n"); - return PTR_ERR(clk); - } - qcom_iommu->clks[CLK_BUS].clk = clk; + ret = devm_clk_bulk_get_all(dev, &qcom_iommu->clks); + if (ret <= 0) + return dev_err_probe(dev, ret, "Couldn't get clocks\n"); - clk = devm_clk_get_optional(dev, "tbu"); - if (IS_ERR(clk)) { - dev_err(dev, "failed to get tbu clock\n"); - return PTR_ERR(clk); - } - qcom_iommu->clks[CLK_TBU].clk = clk; + qcom_iommu->num_clks = ret; if (of_property_read_u32(dev->of_node, "qcom,iommu-secure-id", &qcom_iommu->sec_id)) { @@ -891,7 +869,7 @@ static int __maybe_unused qcom_iommu_resume(struct device *dev) struct qcom_iommu_dev *qcom_iommu = dev_get_drvdata(dev); int ret; - ret = clk_bulk_prepare_enable(CLK_NUM, qcom_iommu->clks); + ret = clk_bulk_prepare_enable(qcom_iommu->num_clks, qcom_iommu->clks); if (ret < 0) return ret; @@ -905,7 +883,7 @@ static int __maybe_unused qcom_iommu_suspend(struct device *dev) { struct qcom_iommu_dev *qcom_iommu = dev_get_drvdata(dev); - clk_bulk_disable_unprepare(CLK_NUM, qcom_iommu->clks); + clk_bulk_disable_unprepare(qcom_iommu->num_clks, qcom_iommu->clks); return 0; } -- 2.44.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2024-04-17 20:07 UTC|newest] Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top 2024-04-17 20:06 [PATCH 0/2] Small qcom_iommu cleanups Konrad Dybcio 2024-04-17 20:06 ` Konrad Dybcio 2024-04-17 20:06 ` [PATCH 1/2] iommu/qcom: Remove useless forward definition Konrad Dybcio 2024-04-17 20:06 ` Konrad Dybcio 2024-04-17 20:36 ` Bjorn Andersson 2024-04-17 20:36 ` Bjorn Andersson 2024-04-17 20:07 ` Konrad Dybcio [this message] 2024-04-17 20:07 ` [PATCH 2/2] iommu/qcom: Always consume all clocks Konrad Dybcio 2024-04-17 20:37 ` Bjorn Andersson 2024-04-17 20:37 ` Bjorn Andersson
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20240416-topic-qcom_iommu-v1-2-fabe55b3b7b3@linaro.org \ --to=konrad.dybcio@linaro.org \ --cc=iommu@lists.linux.dev \ --cc=joro@8bytes.org \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-arm-msm@vger.kernel.org \ --cc=linux-kernel@vger.kernel.org \ --cc=marijn.suijten@somainline.org \ --cc=robdclark@gmail.com \ --cc=robin.murphy@arm.com \ --cc=stephan@gerhold.net \ --cc=will@kernel.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.