linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Aisheng Dong <aisheng.dong@nxp.com>
To: "linux-clk@vger.kernel.org" <linux-clk@vger.kernel.org>
Cc: Aisheng Dong <aisheng.dong@nxp.com>,
	"sboyd@kernel.org" <sboyd@kernel.org>,
	"mturquette@baylibre.com" <mturquette@baylibre.com>,
	dl-linux-imx <linux-imx@nxp.com>,
	"kernel@pengutronix.de" <kernel@pengutronix.de>,
	Fabio Estevam <fabio.estevam@nxp.com>,
	"shawnguo@kernel.org" <shawnguo@kernel.org>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>
Subject: [PATCH 3/4] clk: imx: imx8qxp: add parsing clocks from device tree
Date: Thu, 21 Feb 2019 18:03:51 +0000	[thread overview]
Message-ID: <1550771836-10014-4-git-send-email-aisheng.dong@nxp.com> (raw)
In-Reply-To: <1550771836-10014-1-git-send-email-aisheng.dong@nxp.com>

add parsing clocks from device tree

Cc: Stephen Boyd <sboyd@kernel.org>
Cc: Shawn Guo <shawnguo@kernel.org>
Cc: Sascha Hauer <kernel@pengutronix.de>
Cc: Michael Turquette <mturquette@baylibre.com>
Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
---
 drivers/clk/imx/clk-imx8qxp.c | 43 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)

diff --git a/drivers/clk/imx/clk-imx8qxp.c b/drivers/clk/imx/clk-imx8qxp.c
index 83e2ef9..7c5f8c6 100644
--- a/drivers/clk/imx/clk-imx8qxp.c
+++ b/drivers/clk/imx/clk-imx8qxp.c
@@ -17,17 +17,60 @@
 #include <dt-bindings/clock/imx8-clock.h>
 #include <dt-bindings/firmware/imx/rsrc.h>
 
+static int imx_scu_parse_clks_from_dt(struct device *dev,
+				      const struct device_node *np)
+{
+	struct clk_hw *hw;
+	const char *name;
+	int clk_type;
+	int rsrc_id;
+	int ret;
+
+	ret = of_property_read_u32(np, "rsrc-id", &rsrc_id);
+	if (ret) {
+		dev_err(dev, "failed to parse rsrc-id\n");
+		return -EINVAL;
+	}
+
+	ret = of_property_read_u32(np, "clk-type", &clk_type);
+	if (ret) {
+		dev_err(dev, "failed to parse clk-type\n");
+		return -EINVAL;
+	}
+
+	ret = of_property_read_string(np, "clock-output-names", &name);
+	if (ret) {
+		dev_err(dev, "failed to parse clock-output-names\n");
+		return -EINVAL;
+	}
+
+	hw = imx_clk_scu(name, rsrc_id, clk_type);
+	if (IS_ERR(hw)) {
+		dev_err(dev, "failed to register clock\n");
+		return -EINVAL;
+	}
+
+	return devm_of_clk_add_hw_provider(dev, of_clk_hw_simple_get, hw);
+}
+
 static int imx8qxp_clk_probe(struct platform_device *pdev)
 {
 	struct device_node *ccm_node = pdev->dev.of_node;
 	struct clk_hw_onecell_data *clk_data;
 	struct clk_hw **clks;
+	u32 clock_cells;
 	int ret, i;
 
 	ret = imx_clk_scu_init();
 	if (ret)
 		return ret;
 
+	/* try new binding to parse clocks from device tree first */
+	of_property_read_u32(ccm_node, "#clock-cells", &clock_cells);
+
+	if (clock_cells == 0)
+		return imx_scu_parse_clks_from_dt(&pdev->dev, ccm_node);
+
 	clk_data = devm_kzalloc(&pdev->dev, struct_size(clk_data, hws,
 				IMX_SCU_CLK_END), GFP_KERNEL);
 	if (!clk_data)
-- 
2.7.4


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  parent reply	other threads:[~2019-02-21 18:04 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-21 18:03 [PATCH 0/4] clk: imx: scu: add parsing clocks from device tree support Aisheng Dong
2019-02-21 18:03 ` [PATCH 1/4] dt-bindings: firmware: imx-scu: new binding to parse clocks from device tree Aisheng Dong
2019-03-26 13:47   ` Rob Herring
2019-03-27 14:35     ` Aisheng Dong
2019-04-02 14:47       ` Aisheng Dong
2019-04-09 14:04         ` Aisheng Dong
2019-04-10 15:32       ` Rob Herring
2019-04-10 17:35         ` [EXT] " Aisheng Dong
2019-02-21 18:03 ` [PATCH 2/4] dt-bindings: clock: imx-lpcg: add support " Aisheng Dong
2019-02-25 19:46   ` Stephen Boyd
2019-02-26 10:07     ` Aisheng Dong
2019-03-18 15:10     ` Aisheng Dong
2019-04-02 14:55       ` Aisheng Dong
2019-02-21 18:03 ` Aisheng Dong [this message]
2019-02-21 18:03 ` [PATCH 4/4] clk: imx: imx8qxp-lpcg: add parsing " Aisheng Dong

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=1550771836-10014-4-git-send-email-aisheng.dong@nxp.com \
    --to=aisheng.dong@nxp.com \
    --cc=fabio.estevam@nxp.com \
    --cc=kernel@pengutronix.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-imx@nxp.com \
    --cc=mturquette@baylibre.com \
    --cc=sboyd@kernel.org \
    --cc=shawnguo@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: 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).