From: shawn.guo@linaro.org (Shawn Guo)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH V2 3/3] ARM: imx: source gpt per clk from OSC for system timer
Date: Wed, 10 Sep 2014 19:49:38 +0800 [thread overview]
Message-ID: <20140910114936.GE22579@dragon> (raw)
In-Reply-To: <7fd82b8c08c54f4dadb6b7402231a086@BN1PR0301MB0628.namprd03.prod.outlook.com>
On Wed, Sep 10, 2014 at 07:43:41AM +0000, Anson.Huang at freescale.com wrote:
> diff --git a/arch/arm/mach-imx/clk-imx6q.c b/arch/arm/mach-imx/clk-imx6q.c index 4ee6e77a0fdf..3f0401e27b38 100644
> --- a/arch/arm/mach-imx/clk-imx6q.c
> +++ b/arch/arm/mach-imx/clk-imx6q.c
> @@ -245,6 +245,7 @@ static void __init imx6q_clocks_init(struct device_node *ccm_node)
> clk[IMX6QDL_CLK_PLL3_80M] = imx_clk_fixed_factor("pll3_80m", "pll3_usb_otg", 1, 6);
> clk[IMX6QDL_CLK_PLL3_60M] = imx_clk_fixed_factor("pll3_60m", "pll3_usb_otg", 1, 8);
> clk[IMX6QDL_CLK_TWD] = imx_clk_fixed_factor("twd", "arm", 1, 2);
> + clk[IMX6QDL_CLK_GPT_3M] = imx_clk_fixed_factor("gpt_3m", "osc", 1, 8);
> if (cpu_is_imx6dl()) {
> clk[IMX6QDL_CLK_GPU2D_AXI] = imx_clk_fixed_factor("gpu2d_axi", "mmdc_ch0_axi_podf", 1, 1);
> clk[IMX6QDL_CLK_GPU3D_AXI] = imx_clk_fixed_factor("gpu3d_axi", "mmdc_ch0_axi_podf", 1, 1); @@ -469,6 +470,13 @@ static void __init imx6q_clocks_init(struct device_node *ccm_node)
>
> clk_register_clkdev(clk[IMX6QDL_CLK_ENET_REF], "enet_ref", NULL);
>
> + /*
> + * The gpt_3m clock is not available on i.MX6Q TO1.0. Let's point it
> + * to clock gpt_ipg_per to ease the gpt driver code.
> + */
> + if (cpu_is_imx6q() && imx_get_soc_revision() == IMX_CHIP_REVISION_1_0)
> + clk[IMX6QDL_CLK_GPT_3M] = clk[IMX6QDL_CLK_GPT_IPG_PER];
> +
> if ((imx_get_soc_revision() != IMX_CHIP_REVISION_1_0) ||
> cpu_is_imx6dl()) {
> clk_set_parent(clk[IMX6QDL_CLK_LDB_DI0_SEL], clk[IMX6QDL_CLK_PLL5_VIDEO_DIV]);
>
> diff --git a/arch/arm/mach-imx/time.c b/arch/arm/mach-imx/time.c index bf92e5a351c0..c0ad839516b0 100644
> --- a/arch/arm/mach-imx/time.c
> +++ b/arch/arm/mach-imx/time.c
> @@ -312,10 +317,21 @@ static void __init _mxc_timer_init(int irq,
> __raw_writel(0, timer_base + MXC_TCTL);
> __raw_writel(0, timer_base + MXC_TPRER); /* see datasheet note */
>
> - if (timer_is_v2())
> - tctl_val = V2_TCTL_CLK_PER | V2_TCTL_FRR | V2_TCTL_WAITEN | MXC_TCTL_TEN;
> - else
> + if (timer_is_v2()) {
> + tctl_val = V2_TCTL_FRR | V2_TCTL_WAITEN | MXC_TCTL_TEN;
> + if (clk_get_rate(clk_per) == V2_TIMER_RATE_OSC_DIV8) {
> /* Is the assumption corrrect ??? */
> [Anson] I am afraid that i.MX6Q TO1.0 can NOT meet it, as there is no gpt_3m available for i.MX6Q TO1.0, but we have it in dtb and clk driver.
>
> + tctl_val |= V2_TCTL_CLK_OSC_DIV8;
> + if (cpu_is_imx6dl() || cpu_is_imx6sx()) {
> + /* 24 / 8 = 3 MHz */
> + __raw_writel(7 << V2_TPRER_PRE24M, timer_base + MXC_TPRER);
> + tctl_val |= V2_TCTL_24MEN;
> + }
> + } else {
> + tctl_val |= V2_TCTL_CLK_PER;
> + }
> + } else {
> tctl_val = MX1_2_TCTL_FRR | MX1_2_TCTL_CLK_PCLK1 | MXC_TCTL_TEN;
> + }
>
> __raw_writel(tctl_val, timer_base + MXC_TCTL);
>
> @@ -349,9 +365,13 @@ static void __init mxc_timer_init_dt(struct device_node *np)
> WARN_ON(!timer_base);
> irq = irq_of_parse_and_map(np, 0);
>
> - clk_per = of_clk_get_by_name(np, "per");
> clk_ipg = of_clk_get_by_name(np, "ipg");
>
> + /* Try osc_per clock first, and fall back to per clock otherwise */
> + clk_per = of_clk_get_by_name(np, "osc_per");
> + if (!IS_ERR(clk_per))
> + clk_per = of_clk_get_by_name(np, "per");
> +
> [Anson] For i.MX6Q TO1.0, there is no GPT_3M clock for GPT, but in dtb, there is osc_per, so clk_per will be initialized by osc_per, and the clk rate read in _mxc_timer_init function will be 3000000 and go to the GPT_3M clk source path, which will NOT work for i.MX6Q TO1.0.
>
I had the following change for clk-imx6q.c as above. Shouldn't it
handle the i.MX6Q TO1.0 case well?
if (cpu_is_imx6q() && imx_get_soc_revision() == IMX_CHIP_REVISION_1_0)
clk[IMX6QDL_CLK_GPT_3M] = clk[IMX6QDL_CLK_GPT_IPG_PER];
Shawn
> _mxc_timer_init(irq, clk_per, clk_ipg); } CLOCKSOURCE_OF_DECLARE(mx1_timer, "fsl,imx1-gpt", mxc_timer_init_dt);
>
WARNING: multiple messages have this Message-ID (diff)
From: Shawn Guo <shawn.guo-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
To: "Anson.Huang-KZfg59tc24xl57MIdRCFDg@public.gmane.org"
<Anson.Huang-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
Cc: Fabio Estevam <festevam-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
Sascha Hauer <kernel-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>,
"devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
<devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
"linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org"
<linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org>
Subject: Re: [PATCH V2 3/3] ARM: imx: source gpt per clk from OSC for system timer
Date: Wed, 10 Sep 2014 19:49:38 +0800 [thread overview]
Message-ID: <20140910114936.GE22579@dragon> (raw)
In-Reply-To: <7fd82b8c08c54f4dadb6b7402231a086-RQSpjbwlmjRcEY/EnGXkZZwN6zqB+hSMnBOFsp37pqbUKgpGm//BTAC/G2K4zDHf@public.gmane.org>
On Wed, Sep 10, 2014 at 07:43:41AM +0000, Anson.Huang-KZfg59tc24xl57MIdRCFDg@public.gmane.org wrote:
> diff --git a/arch/arm/mach-imx/clk-imx6q.c b/arch/arm/mach-imx/clk-imx6q.c index 4ee6e77a0fdf..3f0401e27b38 100644
> --- a/arch/arm/mach-imx/clk-imx6q.c
> +++ b/arch/arm/mach-imx/clk-imx6q.c
> @@ -245,6 +245,7 @@ static void __init imx6q_clocks_init(struct device_node *ccm_node)
> clk[IMX6QDL_CLK_PLL3_80M] = imx_clk_fixed_factor("pll3_80m", "pll3_usb_otg", 1, 6);
> clk[IMX6QDL_CLK_PLL3_60M] = imx_clk_fixed_factor("pll3_60m", "pll3_usb_otg", 1, 8);
> clk[IMX6QDL_CLK_TWD] = imx_clk_fixed_factor("twd", "arm", 1, 2);
> + clk[IMX6QDL_CLK_GPT_3M] = imx_clk_fixed_factor("gpt_3m", "osc", 1, 8);
> if (cpu_is_imx6dl()) {
> clk[IMX6QDL_CLK_GPU2D_AXI] = imx_clk_fixed_factor("gpu2d_axi", "mmdc_ch0_axi_podf", 1, 1);
> clk[IMX6QDL_CLK_GPU3D_AXI] = imx_clk_fixed_factor("gpu3d_axi", "mmdc_ch0_axi_podf", 1, 1); @@ -469,6 +470,13 @@ static void __init imx6q_clocks_init(struct device_node *ccm_node)
>
> clk_register_clkdev(clk[IMX6QDL_CLK_ENET_REF], "enet_ref", NULL);
>
> + /*
> + * The gpt_3m clock is not available on i.MX6Q TO1.0. Let's point it
> + * to clock gpt_ipg_per to ease the gpt driver code.
> + */
> + if (cpu_is_imx6q() && imx_get_soc_revision() == IMX_CHIP_REVISION_1_0)
> + clk[IMX6QDL_CLK_GPT_3M] = clk[IMX6QDL_CLK_GPT_IPG_PER];
> +
> if ((imx_get_soc_revision() != IMX_CHIP_REVISION_1_0) ||
> cpu_is_imx6dl()) {
> clk_set_parent(clk[IMX6QDL_CLK_LDB_DI0_SEL], clk[IMX6QDL_CLK_PLL5_VIDEO_DIV]);
>
> diff --git a/arch/arm/mach-imx/time.c b/arch/arm/mach-imx/time.c index bf92e5a351c0..c0ad839516b0 100644
> --- a/arch/arm/mach-imx/time.c
> +++ b/arch/arm/mach-imx/time.c
> @@ -312,10 +317,21 @@ static void __init _mxc_timer_init(int irq,
> __raw_writel(0, timer_base + MXC_TCTL);
> __raw_writel(0, timer_base + MXC_TPRER); /* see datasheet note */
>
> - if (timer_is_v2())
> - tctl_val = V2_TCTL_CLK_PER | V2_TCTL_FRR | V2_TCTL_WAITEN | MXC_TCTL_TEN;
> - else
> + if (timer_is_v2()) {
> + tctl_val = V2_TCTL_FRR | V2_TCTL_WAITEN | MXC_TCTL_TEN;
> + if (clk_get_rate(clk_per) == V2_TIMER_RATE_OSC_DIV8) {
> /* Is the assumption corrrect ??? */
> [Anson] I am afraid that i.MX6Q TO1.0 can NOT meet it, as there is no gpt_3m available for i.MX6Q TO1.0, but we have it in dtb and clk driver.
>
> + tctl_val |= V2_TCTL_CLK_OSC_DIV8;
> + if (cpu_is_imx6dl() || cpu_is_imx6sx()) {
> + /* 24 / 8 = 3 MHz */
> + __raw_writel(7 << V2_TPRER_PRE24M, timer_base + MXC_TPRER);
> + tctl_val |= V2_TCTL_24MEN;
> + }
> + } else {
> + tctl_val |= V2_TCTL_CLK_PER;
> + }
> + } else {
> tctl_val = MX1_2_TCTL_FRR | MX1_2_TCTL_CLK_PCLK1 | MXC_TCTL_TEN;
> + }
>
> __raw_writel(tctl_val, timer_base + MXC_TCTL);
>
> @@ -349,9 +365,13 @@ static void __init mxc_timer_init_dt(struct device_node *np)
> WARN_ON(!timer_base);
> irq = irq_of_parse_and_map(np, 0);
>
> - clk_per = of_clk_get_by_name(np, "per");
> clk_ipg = of_clk_get_by_name(np, "ipg");
>
> + /* Try osc_per clock first, and fall back to per clock otherwise */
> + clk_per = of_clk_get_by_name(np, "osc_per");
> + if (!IS_ERR(clk_per))
> + clk_per = of_clk_get_by_name(np, "per");
> +
> [Anson] For i.MX6Q TO1.0, there is no GPT_3M clock for GPT, but in dtb, there is osc_per, so clk_per will be initialized by osc_per, and the clk rate read in _mxc_timer_init function will be 3000000 and go to the GPT_3M clk source path, which will NOT work for i.MX6Q TO1.0.
>
I had the following change for clk-imx6q.c as above. Shouldn't it
handle the i.MX6Q TO1.0 case well?
if (cpu_is_imx6q() && imx_get_soc_revision() == IMX_CHIP_REVISION_1_0)
clk[IMX6QDL_CLK_GPT_3M] = clk[IMX6QDL_CLK_GPT_IPG_PER];
Shawn
> _mxc_timer_init(irq, clk_per, clk_ipg); } CLOCKSOURCE_OF_DECLARE(mx1_timer, "fsl,imx1-gpt", mxc_timer_init_dt);
>
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2014-09-10 11:49 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-05 3:26 [PATCH V2 0/3] move gpt per clk parent from ipg_per to OSC Anson Huang
2014-09-05 3:26 ` Anson Huang
2014-09-05 3:26 ` [PATCH V2 1/3] ARM: imx: add gpt_3m clk for i.mx6qdl Anson Huang
2014-09-05 3:26 ` Anson Huang
2014-09-05 3:26 ` [PATCH V2 2/3] ARM: dts: imx6: make gpt per clock can be from OSC Anson Huang
2014-09-05 3:26 ` Anson Huang
2014-09-05 3:26 ` [PATCH V2 3/3] ARM: imx: source gpt per clk from OSC for system timer Anson Huang
2014-09-05 3:26 ` Anson Huang
2014-09-05 12:09 ` Fabio Estevam
2014-09-05 12:09 ` Fabio Estevam
2014-09-05 12:58 ` Anson.Huang at freescale.com
2014-09-05 12:58 ` Anson.Huang-KZfg59tc24xl57MIdRCFDg
2014-09-10 7:33 ` Shawn Guo
2014-09-10 7:33 ` Shawn Guo
2014-09-10 7:43 ` Anson.Huang at freescale.com
2014-09-10 7:43 ` Anson.Huang-KZfg59tc24xl57MIdRCFDg
2014-09-10 11:49 ` Shawn Guo [this message]
2014-09-10 11:49 ` Shawn Guo
[not found] ` <8DDD46F6-AA96-4E14-ADD6-45A1AD12423C@freescale.com>
2014-09-10 13:01 ` Shawn Guo
2014-09-10 13:01 ` Shawn Guo
2014-09-10 7:36 ` Shawn Guo
2014-09-10 7:36 ` Shawn Guo
2014-09-10 7:45 ` Anson.Huang at freescale.com
2014-09-10 7:45 ` Anson.Huang-KZfg59tc24xl57MIdRCFDg
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=20140910114936.GE22579@dragon \
--to=shawn.guo@linaro.org \
--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.