From: thor.thayer@linux.intel.com
To: dinguyen@kernel.org, robh+dt@kernel.org, mark.rutland@arm.com,
will.deacon@arm.com, robin.murphy@arm.com, joro@8bytes.org,
aisheng.dong@nxp.com, sboyd@kernel.org
Cc: vivek.gautam@codeaurora.org, linux-clk@vger.kernel.org,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
iommu@lists.linux-foundation.org,
Thor Thayer <thor.thayer@linux.intel.com>
Subject: [PATCHv4 2/2] iommu/arm-smmu: Get clock config from device tree
Date: Fri, 5 Oct 2018 15:57:00 -0500 [thread overview]
Message-ID: <1538773020-27784-3-git-send-email-thor.thayer@linux.intel.com> (raw)
In-Reply-To: <1538773020-27784-1-git-send-email-thor.thayer@linux.intel.com>
From: Thor Thayer <thor.thayer@linux.intel.com>
Currently the clocks are specified in a structure as well as
in the device tree. Since all the information about clocks can be
pulled from the device tree, parse the device tree for the clock
information if specified.
This patch is dependent upon the following patch series that
adds clocks to the driver.
"[v16,0/5] iommu/arm-smmu: Add runtime pm/sleep support"
https://patchwork.kernel.org/cover/10581891/
particularly this patch which adds the clocks:
"[v16,1/5] iommu/arm-smmu: Add pm_runtime/sleep ops"
https://patchwork.kernel.org/patch/10581899/
Request testing on different platforms for verification.
This patch was tested on a Stratix10 SOCFPGA.
Signed-off-by: Thor Thayer <thor.thayer@linux.intel.com>
---
v4 Change dependency on pending patch series that adds clocks.
Add code for parsing device tree for the clocks.
v3 Change dependency on device tree bulk clock patches.
v2 Add structure for SOCFPGA and add dependency on clock patch.
---
drivers/iommu/arm-smmu.c | 30 +++++++++++++++++++++++++++---
1 file changed, 27 insertions(+), 3 deletions(-)
diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c
index d315ca637097..3dd10663b09c 100644
--- a/drivers/iommu/arm-smmu.c
+++ b/drivers/iommu/arm-smmu.c
@@ -44,6 +44,7 @@
#include <linux/module.h>
#include <linux/of.h>
#include <linux/of_address.h>
+#include <linux/of_clk.h>
#include <linux/of_device.h>
#include <linux/of_iommu.h>
#include <linux/pci.h>
@@ -2139,6 +2140,7 @@ static int arm_smmu_device_dt_probe(struct platform_device *pdev,
const struct arm_smmu_match_data *data;
struct device *dev = &pdev->dev;
bool legacy_binding;
+ const char **parent_names;
if (of_property_read_u32(dev->of_node, "#global-interrupts",
&smmu->num_global_irqs)) {
@@ -2149,9 +2151,25 @@ static int arm_smmu_device_dt_probe(struct platform_device *pdev,
data = of_device_get_match_data(dev);
smmu->version = data->version;
smmu->model = data->model;
- smmu->num_clks = data->num_clks;
-
- arm_smmu_fill_clk_data(smmu, data->clks);
+ smmu->num_clks = of_clk_get_parent_count(dev->of_node);
+ /* check to see if clocks were specified in DT */
+ if (smmu->num_clks) {
+ unsigned int i;
+
+ parent_names = kmalloc_array(smmu->num_clks,
+ sizeof(*parent_names),
+ GFP_KERNEL);
+ if (!parent_names)
+ goto fail_clk_name;
+
+ for (i = 0; i < smmu->num_clks; i++) {
+ if (of_property_read_string_index(dev->of_node,
+ "clock-names", i,
+ &parent_names[i]))
+ goto fail_clk_name;
+ }
+ arm_smmu_fill_clk_data(smmu, parent_names);
+ }
parse_driver_options(smmu);
@@ -2171,6 +2189,12 @@ static int arm_smmu_device_dt_probe(struct platform_device *pdev,
smmu->features |= ARM_SMMU_FEAT_COHERENT_WALK;
return 0;
+
+fail_clk_name:
+ kfree(parent_names);
+ /* clock-names required for clocks in devm_clk_bulk_get() */
+ dev_err(dev, "Error: clock-name required in device tree\n");
+ return -ENOMEM;
}
static void arm_smmu_bus_init(void)
--
2.7.4
next prev parent reply other threads:[~2018-10-05 20:57 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-05 20:56 [PATCHv4 0/2] iommu/arm-smmu: Add Stratix10 SMMU Support thor.thayer
2018-10-05 20:56 ` [PATCHv4 1/2] arm64: dts: stratix10: Add Stratix10 SMMU support thor.thayer
2018-10-05 20:57 ` thor.thayer [this message]
2018-11-21 17:48 ` [PATCHv4 2/2] iommu/arm-smmu: Get clock config from device tree Will Deacon
2018-10-30 13:38 ` [PATCHv4 0/2] iommu/arm-smmu: Add Stratix10 SMMU Support Thor Thayer
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=1538773020-27784-3-git-send-email-thor.thayer@linux.intel.com \
--to=thor.thayer@linux.intel.com \
--cc=aisheng.dong@nxp.com \
--cc=devicetree@vger.kernel.org \
--cc=dinguyen@kernel.org \
--cc=iommu@lists.linux-foundation.org \
--cc=joro@8bytes.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=robh+dt@kernel.org \
--cc=robin.murphy@arm.com \
--cc=sboyd@kernel.org \
--cc=vivek.gautam@codeaurora.org \
--cc=will.deacon@arm.com \
/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: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).