linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: mkl@pengutronix.de (Marc Kleine-Budde)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/2] ARM: i.MX28: define ref_xtal frequency in DT
Date: Fri,  8 Nov 2013 14:48:40 +0100	[thread overview]
Message-ID: <1383918521-4668-2-git-send-email-mkl@pengutronix.de> (raw)
In-Reply-To: <1383918521-4668-1-git-send-email-mkl@pengutronix.de>

From: Juergen Beisert <jbe@pengutronix.de>

Instead of hardcoding the ref_xtal in the clk driver, get it from the DT.

Signed-off-by: Juergen Beisert <jbe@pengutronix.de>
Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 arch/arm/boot/dts/imx28.dtsi | 10 ++++++++++
 drivers/clk/mxs/clk-imx28.c  | 18 ++++++++++++++++--
 2 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/arch/arm/boot/dts/imx28.dtsi b/arch/arm/boot/dts/imx28.dtsi
index 7363fde..979c37d 100644
--- a/arch/arm/boot/dts/imx28.dtsi
+++ b/arch/arm/boot/dts/imx28.dtsi
@@ -43,6 +43,16 @@
 		};
 	};
 
+	clocks {
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		xtal-24m {
+			compatible = "fsl,mxs-xtal-24m", "fixed-clock";
+			clock-frequency = <24000000>;
+		};
+	};
+
 	apb at 80000000 {
 		compatible = "simple-bus";
 		#address-cells = <1>;
diff --git a/drivers/clk/mxs/clk-imx28.c b/drivers/clk/mxs/clk-imx28.c
index 4faf0af..874ca4e 100644
--- a/drivers/clk/mxs/clk-imx28.c
+++ b/drivers/clk/mxs/clk-imx28.c
@@ -156,7 +156,7 @@ static enum imx28_clk clks_init_on[] __initdata = {
 
 int __init mx28_clocks_init(void)
 {
-	struct device_node *np;
+	struct device_node *np, *np_tmp;
 	u32 i;
 
 	np = of_find_compatible_node(NULL, NULL, "fsl,imx28-digctl");
@@ -169,7 +169,21 @@ int __init mx28_clocks_init(void)
 
 	clk_misc_init();
 
-	clks[ref_xtal] = mxs_clk_fixed("ref_xtal", 24000000);
+	/* retrieve the crystal's frequencies from device tree */
+	for_each_compatible_node(np_tmp, NULL, "fixed-clock") {
+		u32 rate;
+
+		if (of_property_read_u32(np_tmp, "clock-frequency", &rate))
+			continue;
+
+		if (of_device_is_compatible(np_tmp, "fsl,mxs-xtal-24m"))
+			clks[ref_xtal] = mxs_clk_fixed("ref_xtal", rate);
+	}
+
+	/* if not set, use default frequency */
+	if (!clks[ref_xtal])
+		clks[ref_xtal] = mxs_clk_fixed("ref_xtal", 24000000);
+
 	clks[pll0] = mxs_clk_pll("pll0", "ref_xtal", PLL0CTRL0, 17, 480000000);
 	clks[pll1] = mxs_clk_pll("pll1", "ref_xtal", PLL1CTRL0, 17, 480000000);
 	clks[pll2] = mxs_clk_pll("pll2", "ref_xtal", PLL2CTRL0, 23, 50000000);
-- 
1.8.4.rc3

  reply	other threads:[~2013-11-08 13:48 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-08 13:48 [PATCH 0/2] ARM: i.MX28: define various external xtal frequencies in DT Marc Kleine-Budde
2013-11-08 13:48 ` Marc Kleine-Budde [this message]
2013-11-11  7:42   ` [PATCH 1/2] ARM: i.MX28: define ref_xtal frequency " Shawn Guo
2013-11-11  7:47   ` Shawn Guo
2013-11-08 13:48 ` [PATCH 2/2] ARM: i.MX28: define external RTC crystal " Marc Kleine-Budde

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=1383918521-4668-2-git-send-email-mkl@pengutronix.de \
    --to=mkl@pengutronix.de \
    --cc=linux-arm-kernel@lists.infradead.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).