Skip to contentSkip to conversation

ARM i.MX25 clk: Fix gpt timer clock.

PATCH New Denis Carikli 4 participants 8 messages Jun 25, 2014 – Jun 28, 2014

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH v3 1/3 ARM i.MX25 clk: Fix gpt timer clock.

The gpt0 timer clock has been wrong since:
6bbaec5 ARM i.MX25: implement clocks using common clock framework

---
Changelog v2->v3:
- DTS part splitted out
- Added Sascha's ack from the previous unsplitted patch.
- Added non-dt specific commit message.
- No code changes

Changelog v1->v2:
- Also fixed the ipg clock for non-dt init.

---
 arch/arm/mach-imx/clk-imx25.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/mach-imx/clk-imx25.c +1 -1
index 887b508..e759a6d 100644
@@ -242,7 +242,7 @@ int __init mx25_clocks_init(void)
 {
 	__mx25_clocks_init(24000000);
 
-	clk_register_clkdev(clk[ipg], "ipg", "imx-gpt.0");
+	clk_register_clkdev(clk[gpt1_ipg], "ipg", "imx-gpt.0");
 	clk_register_clkdev(clk[gpt_ipg_per], "per", "imx-gpt.0");
 	/* i.mx25 has the i.mx21 type uart */
 	clk_register_clkdev(clk[uart1_ipg], "ipg", "imx21-uart.0");
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH v3 2/3 ARM: dts: i.MX25: Fix gpt timers clocks.

Without that fix, the board freeze during boot.

This appeared after the following commit:
496f065 ARM: i.MX: Use of_clk_get_by_name() for timer clocks for DT case.

---
Changelog v2->v3:
- Splitted out the non-dts part.
- Added Sascha's ack which applied on the previous non-splitted patch.
- No code/dts changes.

Changelog v1->v2:
- Also fixed the ipg clock
- Also fixed the ipg and per clocks for the other gpts

---
 arch/arm/boot/dts/imx25.dtsi |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
arch/arm/boot/dts/imx25.dtsi +4 -4
index bb74d95..c174039 100644
@@ -312,7 +312,7 @@
 			gpt4: timer at 53f84000 {
 				compatible = "fsl,imx25-gpt", "fsl,imx31-gpt";
 				reg = <0x53f84000 0x4000>;
-				clocks = <&clks 9>, <&clks 45>;
+				clocks = <&clks 95>, <&clks 47>;
 				clock-names = "ipg", "per";
 				interrupts = <1>;
 			};
@@ -320,7 +320,7 @@
 			gpt3: timer at 53f88000 {
 				compatible = "fsl,imx25-gpt", "fsl,imx31-gpt";
 				reg = <0x53f88000 0x4000>;
-				clocks = <&clks 9>, <&clks 47>;
+				clocks = <&clks 94>, <&clks 47>;
 				clock-names = "ipg", "per";
 				interrupts = <29>;
 			};
@@ -328,7 +328,7 @@
 			gpt2: timer at 53f8c000 {
 				compatible = "fsl,imx25-gpt", "fsl,imx31-gpt";
 				reg = <0x53f8c000 0x4000>;
-				clocks = <&clks 9>, <&clks 47>;
+				clocks = <&clks 93>, <&clks 47>;
 				clock-names = "ipg", "per";
 				interrupts = <53>;
 			};
@@ -336,7 +336,7 @@
 			gpt1: timer at 53f90000 {
 				compatible = "fsl,imx25-gpt", "fsl,imx31-gpt";
 				reg = <0x53f90000 0x4000>;
-				clocks = <&clks 9>, <&clks 47>;
+				clocks = <&clks 92>, <&clks 47>;
 				clock-names = "ipg", "per";
 				interrupts = <54>;
 			};
Signature · 1 line
1.7.9.5
#3 lore raw

PATCH v3 3/3 ARM: i.MX25 clk: Use of_clk_init() for DT case

In reply to Denis Carikli

Replace .init_time() hook with of_clk_init() for DT targets.

Based on:
d4347ee ARM: i.MX27 clk: Use of_clk_init() for DT case

---
Changelog v2->v3:
- Reworked the patch to look way smaller.
- Thanks to that the ccm global variable is now gone (now it's local).

Changelog v1->v2:
- Rebased.
- Removing the warning about the useless int i declaration.

---
 arch/arm/mach-imx/clk-imx25.c |   35 ++++++++++++++++++++---------------
 arch/arm/mach-imx/common.h    |    1 -
 arch/arm/mach-imx/imx25-dt.c  |    6 ------
 3 files changed, 20 insertions(+), 22 deletions(-)
arch/arm/mach-imx/clk-imx25.c +20 -15
index e759a6d..cab34c3 100644
@@ -32,8 +32,6 @@
 #include "hardware.h"
 #include "mx25.h"
 
-#define CRM_BASE	MX25_IO_ADDRESS(MX25_CRM_BASE_ADDR)
-
 #define CCM_MPCTL	0x00
 #define CCM_UPCTL	0x04
 #define CCM_CCTL	0x08
@@ -56,7 +54,7 @@
 #define CCM_LTR3	0x4c
 #define CCM_MCR		0x64
 
-#define ccm(x)	(CRM_BASE + (x))
+#define ccm(x)	(ccm_base + (x))
 
 static struct clk_onecell_data clk_data;
 
@@ -91,8 +89,11 @@ enum mx25_clks {
 
 static struct clk *clk[clk_max];
 
-static int __init __mx25_clocks_init(unsigned long osc_rate)
+static int __init __mx25_clocks_init(unsigned long osc_rate,
+				     void __iomem *ccm_base)
 {
+	BUG_ON(!ccm_base);
+
 	clk[dummy] = imx_clk_fixed("dummy", 0);
 	clk[osc] = imx_clk_fixed("osc", osc_rate);
 	clk[mpll] = imx_clk_pllv1("mpll", "osc", ccm(CCM_MPCTL));
@@ -240,7 +241,11 @@ static int __init __mx25_clocks_init(unsigned long osc_rate)
 
 int __init mx25_clocks_init(void)
 {
-	__mx25_clocks_init(24000000);
+	void __iomem *ccm;
+
+	ccm = ioremap(MX25_CRM_BASE_ADDR, SZ_16K);
+
+	__mx25_clocks_init(24000000, ccm);
 
 	clk_register_clkdev(clk[gpt1_ipg], "ipg", "imx-gpt.0");
 	clk_register_clkdev(clk[gpt_ipg_per], "per", "imx-gpt.0");
@@ -308,29 +313,29 @@ int __init mx25_clocks_init(void)
 	return 0;
 }
 
-int __init mx25_clocks_init_dt(void)
+static void __init mx25_clocks_init_dt(struct device_node *np)
 {
-	struct device_node *np;
+	struct device_node *refnp;
 	unsigned long osc_rate = 24000000;
+	void __iomem *ccm;
 
 	/* retrieve the freqency of fixed clocks from device tree */
-	for_each_compatible_node(np, NULL, "fixed-clock") {
+	for_each_compatible_node(refnp, NULL, "fixed-clock") {
 		u32 rate;
-		if (of_property_read_u32(np, "clock-frequency", &rate))
+		if (of_property_read_u32(refnp, "clock-frequency", &rate))
 			continue;
 
-		if (of_device_is_compatible(np, "fsl,imx-osc"))
+		if (of_device_is_compatible(refnp, "fsl,imx-osc"))
 			osc_rate = rate;
 	}
 
-	np = of_find_compatible_node(NULL, NULL, "fsl,imx25-ccm");
+	ccm = of_iomap(np, 0);
+	__mx25_clocks_init(osc_rate, ccm);
+
 	clk_data.clks = clk;
 	clk_data.clk_num = ARRAY_SIZE(clk);
 	of_clk_add_provider(np, of_clk_src_onecell_get, &clk_data);
 
-	__mx25_clocks_init(osc_rate);
-
 	mxc_timer_init_dt(of_find_compatible_node(NULL, NULL, "fsl,imx25-gpt"));
-
-	return 0;
 }
+CLK_OF_DECLARE(imx25_ccm, "fsl,imx25-ccm", mx25_clocks_init_dt);
arch/arm/mach-imx/common.h +0 -1
index 50ee9c2..08ab255 100644
@@ -55,7 +55,6 @@ int mx25_clocks_init(void);
 int mx27_clocks_init(unsigned long fref);
 int mx31_clocks_init(unsigned long fref);
 int mx35_clocks_init(void);
-int mx25_clocks_init_dt(void);
 int mx31_clocks_init_dt(void);
 struct platform_device *mxc_register_gpio(char *name, int id,
 	resource_size_t iobase, resource_size_t iosize, int irq, int irq_high);
arch/arm/mach-imx/imx25-dt.c +0 -6
index 42a65e0..cf8032b 100644
@@ -29,16 +29,10 @@ static const char * const imx25_dt_board_compat[] __initconst = {
 	NULL
 };
 
-static void __init imx25_timer_init(void)
-{
-	mx25_clocks_init_dt();
-}
-
 DT_MACHINE_START(IMX25_DT, "Freescale i.MX25 (Device Tree Support)")
 	.map_io		= mx25_map_io,
 	.init_early	= imx25_init_early,
 	.init_irq	= mx25_init_irq,
-	.init_time	= imx25_timer_init,
 	.init_machine	= imx25_dt_init,
 	.dt_compat	= imx25_dt_board_compat,
 	.restart	= mxc_restart,
Signature · 1 line
1.7.9.5
reviewer
#4 lore raw

PATCH v3 3/3 ARM: i.MX25 clk: Use of_clk_init() for DT case

arch/arm/mach-imx/clk-imx25.c static int __init __mx25_clocks_init(unsigned long osc_rate) · line 246

Quoted 6 lines · Denis Carikli

int __init mx25_clocks_init(void)
{

arch/arm/mach-imx/clk-imx25.c +3 -1
-       __mx25_clocks_init(24000000);
+       void __iomem *ccm;
+
+       ccm = ioremap(MX25_CRM_BASE_ADDR, SZ_16K);

Shouldn't the ccm base address be retrieved from dt?

#5 lore raw

PATCH v3 3/3 ARM: i.MX25 clk: Use of_clk_init() for DT case

Quoted 11 lines · Fabio Estevam

arch/arm/mach-imx/clk-imx25.c static int __init __mx25_clocks_init(unsigned long osc_rate) · line 246

Quoted 6 lines · Denis Carikli
  int __init mx25_clocks_init(void)
  {
arch/arm/mach-imx/clk-imx25.c +3 -1
-       __mx25_clocks_init(24000000);
+       void __iomem *ccm;
+
+       ccm = ioremap(MX25_CRM_BASE_ADDR, SZ_16K);

Shouldn't the ccm base address be retrieved from dt?

Yes, it is.

As I understand it mx25_clocks_init is called only by the boards files (mach-eukrea_cpuimx25.c and mach-mx25_3ds.c) while mx25_clocks_init_dt is what is used in the case of a DT boot (in imx25-dt.c).

Denis.

maintainer
#6 lore raw

PATCH v3 3/3 ARM: i.MX25 clk: Use of_clk_init() for DT case

In reply to Denis Carikli
Quoted 6 lines · Denis Carikli

Replace .init_time() hook with of_clk_init() for DT targets.

Based on:
d4347ee ARM: i.MX27 clk: Use of_clk_init() for DT case

Looks good now.

Sascha

Signature · 4 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |