From: shawn.guo@freescale.com (Shawn Guo)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] arm/imx: factor device tree timer initialization
Date: Tue, 8 Apr 2014 16:02:57 +0800 [thread overview]
Message-ID: <20140408080256.GE2438@dragon> (raw)
In-Reply-To: <1396713465-1391-1-git-send-email-gilles.chanteperdrix@xenomai.org>
On Sat, Apr 05, 2014 at 05:57:45PM +0200, Gilles Chanteperdrix wrote:
>
> Signed-off-by: Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
> ---
> arch/arm/mach-imx/clk-imx25.c | 9 +--------
> arch/arm/mach-imx/clk-imx51-imx53.c | 18 ++++--------------
> arch/arm/mach-imx/clk-imx6q.c | 8 ++------
> arch/arm/mach-imx/clk-imx6sl.c | 6 +-----
> arch/arm/mach-imx/common.h | 2 ++
> arch/arm/mach-imx/time.c | 17 +++++++++++++++++
> 6 files changed, 27 insertions(+), 33 deletions(-)
Thanks for the patch. I applied it with 2 small fix-ups.
1. The idiom of the patch prefix should be "ARM: imx: ...".
2. The CONFIG_OF protection around mxc_timer_init_dt() is not really
necessary, since CONFIG_OF is always enabled for IMX platform.
Shawn
>
> diff --git a/arch/arm/mach-imx/clk-imx25.c b/arch/arm/mach-imx/clk-imx25.c
> index 69858c7..a2b85dc 100644
> --- a/arch/arm/mach-imx/clk-imx25.c
> +++ b/arch/arm/mach-imx/clk-imx25.c
> @@ -312,8 +312,6 @@ int __init mx25_clocks_init(void)
> int __init mx25_clocks_init_dt(void)
> {
> struct device_node *np;
> - void __iomem *base;
> - int irq;
> unsigned long osc_rate = 24000000;
>
> /* retrieve the freqency of fixed clocks from device tree */
> @@ -333,12 +331,7 @@ int __init mx25_clocks_init_dt(void)
>
> __mx25_clocks_init(osc_rate);
>
> - np = of_find_compatible_node(NULL, NULL, "fsl,imx25-gpt");
> - base = of_iomap(np, 0);
> - WARN_ON(!base);
> - irq = irq_of_parse_and_map(np, 0);
> -
> - mxc_timer_init(base, irq);
> + mxc_timer_init_dt(of_find_compatible_node(NULL, NULL, "fsl,imx25-gpt"));
>
> return 0;
> }
> diff --git a/arch/arm/mach-imx/clk-imx51-imx53.c b/arch/arm/mach-imx/clk-imx51-imx53.c
> index 19fca1f..f505a89 100644
> --- a/arch/arm/mach-imx/clk-imx51-imx53.c
> +++ b/arch/arm/mach-imx/clk-imx51-imx53.c
> @@ -324,9 +324,8 @@ static void __init mx5_clocks_common_init(unsigned long rate_ckil,
>
> static void __init mx50_clocks_init(struct device_node *np)
> {
> - void __iomem *base;
> unsigned long r;
> - int i, irq;
> + int i;
>
> clk[IMX5_CLK_PLL1_SW] = imx_clk_pllv2("pll1_sw", "osc", MX53_DPLL1_BASE);
> clk[IMX5_CLK_PLL2_SW] = imx_clk_pllv2("pll2_sw", "osc", MX53_DPLL2_BASE);
> @@ -374,11 +373,7 @@ static void __init mx50_clocks_init(struct device_node *np)
> r = clk_round_rate(clk[IMX5_CLK_USBOH3_PER_GATE], 54000000);
> clk_set_rate(clk[IMX5_CLK_USBOH3_PER_GATE], r);
>
> - np = of_find_compatible_node(NULL, NULL, "fsl,imx50-gpt");
> - base = of_iomap(np, 0);
> - WARN_ON(!base);
> - irq = irq_of_parse_and_map(np, 0);
> - mxc_timer_init(base, irq);
> + mxc_timer_init_dt(of_find_compatible_node(NULL, NULL, "fsl,imx50-gpt"));
> }
> CLK_OF_DECLARE(imx50_ccm, "fsl,imx50-ccm", mx50_clocks_init);
>
> @@ -494,9 +489,8 @@ CLK_OF_DECLARE(imx51_ccm, "fsl,imx51-ccm", mx51_clocks_init_dt);
>
> static void __init mx53_clocks_init(struct device_node *np)
> {
> - int i, irq;
> + int i;
> unsigned long r;
> - void __iomem *base;
>
> clk[IMX5_CLK_PLL1_SW] = imx_clk_pllv2("pll1_sw", "osc", MX53_DPLL1_BASE);
> clk[IMX5_CLK_PLL2_SW] = imx_clk_pllv2("pll2_sw", "osc", MX53_DPLL2_BASE);
> @@ -594,10 +588,6 @@ static void __init mx53_clocks_init(struct device_node *np)
> r = clk_round_rate(clk[IMX5_CLK_USBOH3_PER_GATE], 54000000);
> clk_set_rate(clk[IMX5_CLK_USBOH3_PER_GATE], r);
>
> - np = of_find_compatible_node(NULL, NULL, "fsl,imx53-gpt");
> - base = of_iomap(np, 0);
> - WARN_ON(!base);
> - irq = irq_of_parse_and_map(np, 0);
> - mxc_timer_init(base, irq);
> + mxc_timer_init_dt(of_find_compatible_node(NULL, NULL, "fsl,imx53-gpt"));
> }
> CLK_OF_DECLARE(imx53_ccm, "fsl,imx53-ccm", mx53_clocks_init);
> diff --git a/arch/arm/mach-imx/clk-imx6q.c b/arch/arm/mach-imx/clk-imx6q.c
> index 4d677f4..824107c 100644
> --- a/arch/arm/mach-imx/clk-imx6q.c
> +++ b/arch/arm/mach-imx/clk-imx6q.c
> @@ -144,7 +144,7 @@ static void __init imx6q_clocks_init(struct device_node *ccm_node)
> {
> struct device_node *np;
> void __iomem *base;
> - int i, irq;
> + int i;
> int ret;
>
> clk[dummy] = imx_clk_fixed("dummy", 0);
> @@ -485,10 +485,6 @@ static void __init imx6q_clocks_init(struct device_node *ccm_node)
> /* Set initial power mode */
> imx6q_set_lpm(WAIT_CLOCKED);
>
> - np = of_find_compatible_node(NULL, NULL, "fsl,imx6q-gpt");
> - base = of_iomap(np, 0);
> - WARN_ON(!base);
> - irq = irq_of_parse_and_map(np, 0);
> - mxc_timer_init(base, irq);
> + mxc_timer_init_dt(of_find_compatible_node(NULL, NULL, "fsl,imx6q-gpt"));
> }
> CLK_OF_DECLARE(imx6q, "fsl,imx6q-ccm", imx6q_clocks_init);
> diff --git a/arch/arm/mach-imx/clk-imx6sl.c b/arch/arm/mach-imx/clk-imx6sl.c
> index 4c86f30..f00489e 100644
> --- a/arch/arm/mach-imx/clk-imx6sl.c
> +++ b/arch/arm/mach-imx/clk-imx6sl.c
> @@ -70,7 +70,6 @@ static void __init imx6sl_clocks_init(struct device_node *ccm_node)
> {
> struct device_node *np;
> void __iomem *base;
> - int irq;
> int i;
>
> clks[IMX6SL_CLK_DUMMY] = imx_clk_fixed("dummy", 0);
> @@ -270,9 +269,6 @@ static void __init imx6sl_clocks_init(struct device_node *ccm_node)
> imx6q_set_lpm(WAIT_CLOCKED);
>
> np = of_find_compatible_node(NULL, NULL, "fsl,imx6sl-gpt");
> - base = of_iomap(np, 0);
> - WARN_ON(!base);
> - irq = irq_of_parse_and_map(np, 0);
> - mxc_timer_init(base, irq);
> + mxc_timer_init_dt(np);
> }
> CLK_OF_DECLARE(imx6sl, "fsl,imx6sl-ccm", imx6sl_clocks_init);
> diff --git a/arch/arm/mach-imx/common.h b/arch/arm/mach-imx/common.h
> index baf439d..7b62fa3 100644
> --- a/arch/arm/mach-imx/common.h
> +++ b/arch/arm/mach-imx/common.h
> @@ -17,6 +17,7 @@ struct irq_data;
> struct platform_device;
> struct pt_regs;
> struct clk;
> +struct device_node;
> enum mxc_cpu_pwr_mode;
>
> void mx1_map_io(void);
> @@ -56,6 +57,7 @@ void imx51_init_late(void);
> void imx53_init_late(void);
> void epit_timer_init(void __iomem *base, int irq);
> void mxc_timer_init(void __iomem *, int);
> +void mxc_timer_init_dt(struct device_node *);
> int mx1_clocks_init(unsigned long fref);
> int mx21_clocks_init(unsigned long lref, unsigned long fref);
> int mx25_clocks_init(void);
> diff --git a/arch/arm/mach-imx/time.c b/arch/arm/mach-imx/time.c
> index 1a3a5f6..2ca1387 100644
> --- a/arch/arm/mach-imx/time.c
> +++ b/arch/arm/mach-imx/time.c
> @@ -27,6 +27,9 @@
> #include <linux/clk.h>
> #include <linux/err.h>
> #include <linux/sched_clock.h>
> +#include <linux/of.h>
> +#include <linux/of_address.h>
> +#include <linux/of_irq.h>
>
> #include <asm/mach/time.h>
>
> @@ -316,3 +319,17 @@ void __init mxc_timer_init(void __iomem *base, int irq)
> /* Make irqs happen */
> setup_irq(irq, &mxc_timer_irq);
> }
> +
> +#ifdef CONFIG_OF
> +void __init mxc_timer_init_dt(struct device_node *np)
> +{
> + void __iomem *base;
> + int irq;
> +
> + base = of_iomap(np, 0);
> + WARN_ON(!base);
> + irq = irq_of_parse_and_map(np, 0);
> +
> + mxc_timer_init(base, irq);
> +}
> +#endif
> --
> 1.7.10.4
>
>
>
prev parent reply other threads:[~2014-04-08 8:02 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-05 15:57 [PATCH] arm/imx: factor device tree timer initialization Gilles Chanteperdrix
2014-04-08 8:02 ` Shawn Guo [this message]
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=20140408080256.GE2438@dragon \
--to=shawn.guo@freescale.com \
--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 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.