[PATCH 1/2] ARM: i.MX28: define ref_xtal frequency in DT
Shawn Guo
shawn.guo at linaro.org
Mon Nov 11 02:42:40 EST 2013
On Fri, Nov 08, 2013 at 02:48:40PM +0100, Marc Kleine-Budde wrote:
> From: Juergen Beisert <jbe at pengutronix.de>
>
> Instead of hardcoding the ref_xtal in the clk driver, get it from the DT.
>
> Signed-off-by: Juergen Beisert <jbe at pengutronix.de>
> Signed-off-by: Steffen Trumtrar <s.trumtrar at pengutronix.de>
> Signed-off-by: Marc Kleine-Budde <mkl at 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 {
To follow the common pattern, we may want to name the node in a generic
way, i.e. 'clock at 0'.
> + compatible = "fsl,mxs-xtal-24m", "fixed-clock";
DT maintainers start checking undocumented compatible strings. We may
need to find a place to document it, even though it's quite trivial.
Shawn
> + 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
>
More information about the linux-arm-kernel
mailing list