Skip to contentSkip to conversation

ARM: imx31: clock initialization fixes

PATCH New Vladimir Zapolskiy 5 participants 12 messages Sep 26, 2016 – Nov 1, 2016

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

v2 cover ARM: imx31: clock initialization fixes

The change is tested on qemu kzm target and mx31lite board, while both targets don't have DTS in upstream, I had to write simple DTS files for them, because the proposed change is for i.MX31 targets with OF support.

i.MX31/OF/clock initialization seems to be broken currently, if the series is not applied I can not get a working clock source during early boot stage on a board with DTB supplied.

Changes from v1 to v2, thanks to Uwe and Stephen for review:
* added one more new fix in imx31.dtsi which moves CCM device node to AIPS2 bus,
* included to the series a fix of CCM interrupts in imx31.dtsi, the change was sent as a separate patch, the change is included to avoid a patch application dependency,
* as suggested by Uwe reworded one of the commits removing "stack corruption" mentioning, the overwritten value is passed in a register,
* as suggested by Uwe squashed clk-imx31.c and imx31-dt.c changes to avoid a runtime problem if only one of two patches are applied

Vladimir Zapolskiy (4):
ARM: dts: imx31: fix clock control module interrupts description
ARM: dts: imx31: move CCM device node to AIPS2 bus devices
clk: imx31: fix rewritten input argument of mx31_clocks_init()
ARM: clk: imx31: properly init clocks for machines with DT

 .../devicetree/bindings/clock/imx31-clock.txt      |  2 +-
 arch/arm/boot/dts/imx31.dtsi                       | 14 +++---
 arch/arm/mach-imx/common.h                         |  1 -
 arch/arm/mach-imx/imx31-dt.c                       |  6 ---
 drivers/clk/imx/clk-imx31.c                        | 52 +++++++++++-----------
 5 files changed, 34 insertions(+), 41 deletions(-)
Signature · 1 line
2.8.1
#1 lore raw

PATCH v2 1/4 ARM: dts: imx31: fix clock control module interrupts description

The type of AVIC interrupt controller found on i.MX31 is one-cell, namely 31 for CCM DVFS and 53 for CCM, however for clock control module its interrupts are specified as 3-cells, fix it.

Fixes ef0e4a606fb6 ("ARM: mx31: Replace clk_register_clkdev with clock DT lookup")

---
Changes from v1 to v2:
* added Rob's Acked-by tag.

 Documentation/devicetree/bindings/clock/imx31-clock.txt | 2 +-
 arch/arm/boot/dts/imx31.dtsi                            | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/clock/imx31-clock.txt +1 -1
index 19df842..8163d56 100644
@@ -77,7 +77,7 @@ Examples:
 clks: ccm at 53f80000{
 	compatible = "fsl,imx31-ccm";
 	reg = <0x53f80000 0x4000>;
-	interrupts = <0 31 0x04 0 53 0x04>;
+	interrupts = <31>, <53>;
 	#clock-cells = <1>;
 };
 
arch/arm/boot/dts/imx31.dtsi +1 -1
index 1ce7ae9..3e0893e 100644
@@ -122,7 +122,7 @@
 			clks: ccm at 53f80000{
 				compatible = "fsl,imx31-ccm";
 				reg = <0x53f80000 0x4000>;
-				interrupts = <0 31 0x04 0 53 0x04>;
+				interrupts = <31>, <53>;
 				#clock-cells = <1>;
 			};
 		};
Signature · 1 line
2.8.1
#2 lore raw

PATCH v2 2/4 ARM: dts: imx31: move CCM device node to AIPS2 bus devices

In reply to Vladimir Zapolskiy

i.MX31 Clock Control Module controller is found on AIPS2 bus, move it there from SPBA bus to avoid a conflict of device IO space mismatch.

Fixes ef0e4a606fb6 ("ARM: mx31: Replace clk_register_clkdev with clock DT lookup")

---
Changes from v1 to v2:
* new change in the series

 arch/arm/boot/dts/imx31.dtsi | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
arch/arm/boot/dts/imx31.dtsi +7 -7
index 3e0893e..8d4c0e3 100644
@@ -118,13 +118,6 @@
 				interrupts = <19>;
 				clocks = <&clks 25>;
 			};
-
-			clks: ccm at 53f80000{
-				compatible = "fsl,imx31-ccm";
-				reg = <0x53f80000 0x4000>;
-				interrupts = <31>, <53>;
-				#clock-cells = <1>;
-			};
 		};
 
 		aips at 53f00000 { /* AIPS2 */
@@ -134,6 +127,13 @@
 			reg = <0x53f00000 0x100000>;
 			ranges;
 
+			clks: ccm at 53f80000{
+				compatible = "fsl,imx31-ccm";
+				reg = <0x53f80000 0x4000>;
+				interrupts = <31>, <53>;
+				#clock-cells = <1>;
+			};
+
 			gpt: timer at 53f90000 {
 				compatible = "fsl,imx31-gpt";
 				reg = <0x53f90000 0x4000>;
Signature · 1 line
2.8.1
#3 lore raw

PATCH v2 2/4 ARM: dts: imx31: move CCM device node to AIPS2 bus devices

Hello Vladimir,

Quoted 5 lines · Vladimir Zapolskiy

i.MX31 Clock Control Module controller is found on AIPS2 bus, move it there from SPBA bus to avoid a conflict of device IO space mismatch.

Fixes ef0e4a606fb6 ("ARM: mx31: Replace clk_register_clkdev with clock DT lookup")

out of interest: Which kind of machine do you work with? I assume this isn't just a finger exercise with qemu?

Best regards
Uwe

Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-K?nig            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
#4 lore raw

PATCH v2 3/4 clk: imx31: fix rewritten input argument of mx31_clocks_init()

In reply to Vladimir Zapolskiy

Function mx31_clocks_init() is called during clock intialization on legacy boards with reference clock frequency passed as its input argument, this can be verified by examination of the function declaration found in arch/arm/mach-imx/common.h and actual function users which include that header file.

Inside CCF driver the function ignores its input argument, by chance the used value in the function body is the same as input arguments on side of all callers.

Fixes d9388c843237 ("clk: imx31: Do not call mxc_timer_init twice when booting with DT")

---
Changes from v1 to v2:
* reworded commit message, thanks to Uwe for review

 drivers/clk/imx/clk-imx31.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/clk/imx/clk-imx31.c +1 -3
index 6a96414..6a49ba2 100644
@@ -157,10 +157,8 @@ static void __init _mx31_clocks_init(unsigned long fref)
 	}
 }
 
-int __init mx31_clocks_init(void)
+int __init mx31_clocks_init(unsigned long fref)
 {
-	u32 fref = 26000000; /* default */
-
 	_mx31_clocks_init(fref);
 
 	clk_register_clkdev(clk[gpt_gate], "per", "imx-gpt.0");
Signature · 1 line
2.8.1
#5 lore raw

PATCH v2 3/4 clk: imx31: fix rewritten input argument of mx31_clocks_init()

Hello,

Quoted 6 lines · Vladimir Zapolskiy

Function mx31_clocks_init() is called during clock intialization on legacy boards with reference clock frequency passed as its input argument, this can be verified by examination of the function declaration found in arch/arm/mach-imx/common.h and actual function users which include that header file.

Quoted 6 lines

Inside CCF driver the function ignores its input argument, by chance the used value in the function body is the same as input arguments on side of all callers.

Fixes d9388c843237 ("clk: imx31: Do not call mxc_timer_init twice when booting with DT")

Thanks
Uwe

Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-K?nig            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
#6 lore raw

PATCH v2 3/4 clk: imx31: fix rewritten input argument of mx31_clocks_init()

In reply to Vladimir Zapolskiy
Quoted 6 lines · Vladimir Zapolskiy

Function mx31_clocks_init() is called during clock intialization on legacy boards with reference clock frequency passed as its input argument, this can be verified by examination of the function declaration found in arch/arm/mach-imx/common.h and actual function users which include that header file.

Quoted 7 lines

Inside CCF driver the function ignores its input argument, by chance the used value in the function body is the same as input arguments on side of all callers.

Fixes d9388c843237 ("clk: imx31: Do not call mxc_timer_init twice when booting with DT")

---

Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
#7 lore raw

PATCH v2 4/4 ARM: clk: imx31: properly init clocks for machines with DT

In reply to Vladimir Zapolskiy

Clock initialization for i.MX31 powered machines with DT support should be done by a call of an init function registered with CLK_OF_DECLARE() in common clock framework.

The change converts exported mx31_clocks_init_dt() into a static initialization function registered by CLK_OF_DECLARE().

---
Changes from v1 to v2:
* this change is a squashed change of arch/arm and clk changes, if only one of two changes is applied there is a compilation time or runtime issue.

 arch/arm/mach-imx/common.h   |  1 -
 arch/arm/mach-imx/imx31-dt.c |  6 ------
 drivers/clk/imx/clk-imx31.c  | 50 +++++++++++++++++++++++---------------------
 3 files changed, 26 insertions(+), 31 deletions(-)
arch/arm/mach-imx/common.h +0 -1
index a8f4693..e97d8cb 100644
@@ -48,7 +48,6 @@ int mx21_clocks_init(unsigned long lref, unsigned long fref);
 int mx27_clocks_init(unsigned long fref);
 int mx31_clocks_init(unsigned long fref);
 int mx35_clocks_init(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);
 void mxc_set_cpu_type(unsigned int type);
arch/arm/mach-imx/imx31-dt.c +0 -6
index 62e6b4f..668d74b 100644
@@ -23,11 +23,6 @@ static const char * const imx31_dt_board_compat[] __initconst = {
 	NULL
 };
 
-static void __init imx31_dt_timer_init(void)
-{
-	mx31_clocks_init_dt();
-}
-
 /* FIXME: replace with DT binding */
 static const struct resource imx31_rnga_res[] __initconst = {
 	DEFINE_RES_MEM(MX31_RNGA_BASE_ADDR, SZ_16K),
@@ -43,7 +38,6 @@ DT_MACHINE_START(IMX31_DT, "Freescale i.MX31 (Device Tree Support)")
 	.map_io		= mx31_map_io,
 	.init_early	= imx31_init_early,
 	.init_irq	= mx31_init_irq,
-	.init_time	= imx31_dt_timer_init,
 	.init_machine	= imx31_dt_mach_init,
 	.dt_compat	= imx31_dt_board_compat,
 MACHINE_END
drivers/clk/imx/clk-imx31.c +26 -24

87 lines not on this page · raw message

Signature · 1 line
2.8.1
#8 lore raw

PATCH v2 4/4 ARM: clk: imx31: properly init clocks for machines with DT

Quoted 9 lines · Vladimir Zapolskiy

Clock initialization for i.MX31 powered machines with DT support should be done by a call of an init function registered with CLK_OF_DECLARE() in common clock framework.

The change converts exported mx31_clocks_init_dt() into a static initialization function registered by CLK_OF_DECLARE().

---

Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
#9 lore raw

v2 cover ARM: imx31: clock initialization fixes

In reply to Vladimir Zapolskiy
Quoted 25 lines · Vladimir Zapolskiy

The change is tested on qemu kzm target and mx31lite board, while both targets don't have DTS in upstream, I had to write simple DTS files for them, because the proposed change is for i.MX31 targets with OF support.

i.MX31/OF/clock initialization seems to be broken currently, if the series is not applied I can not get a working clock source during early boot stage on a board with DTB supplied.

Changes from v1 to v2, thanks to Uwe and Stephen for review:
* added one more new fix in imx31.dtsi which moves CCM device node to AIPS2 bus,
* included to the series a fix of CCM interrupts in imx31.dtsi, the change was sent as a separate patch, the change is included to avoid a patch application dependency,
* as suggested by Uwe reworded one of the commits removing "stack corruption" mentioning, the overwritten value is passed in a register,
* as suggested by Uwe squashed clk-imx31.c and imx31-dt.c changes to avoid a runtime problem if only one of two patches are applied

Vladimir Zapolskiy (4):
ARM: dts: imx31: fix clock control module interrupts description
ARM: dts: imx31: move CCM device node to AIPS2 bus devices
clk: imx31: fix rewritten input argument of mx31_clocks_init()
ARM: clk: imx31: properly init clocks for machines with DT

Quoted 5 lines
 .../devicetree/bindings/clock/imx31-clock.txt      |  2 +-
 arch/arm/boot/dts/imx31.dtsi                       | 14 +++---
 arch/arm/mach-imx/common.h                         |  1 -
 arch/arm/mach-imx/imx31-dt.c                       |  6 ---
 drivers/clk/imx/clk-imx31.c                        | 52 +++++++++++-----------

Hi Stephen,

Can I have you ACK on the clk file, so that we can merge the series from arm-soc tree? Thanks.

Shawn

#10 lore raw

v2 cover ARM: imx31: clock initialization fixes

Quoted 32 lines · Shawn Guo
Quoted 25 lines · Vladimir Zapolskiy

The change is tested on qemu kzm target and mx31lite board, while both targets don't have DTS in upstream, I had to write simple DTS files for them, because the proposed change is for i.MX31 targets with OF support.

i.MX31/OF/clock initialization seems to be broken currently, if the series is not applied I can not get a working clock source during early boot stage on a board with DTB supplied.

Changes from v1 to v2, thanks to Uwe and Stephen for review:
* added one more new fix in imx31.dtsi which moves CCM device node to AIPS2 bus,
* included to the series a fix of CCM interrupts in imx31.dtsi, the change was sent as a separate patch, the change is included to avoid a patch application dependency,
* as suggested by Uwe reworded one of the commits removing "stack corruption" mentioning, the overwritten value is passed in a register,
* as suggested by Uwe squashed clk-imx31.c and imx31-dt.c changes to avoid a runtime problem if only one of two patches are applied

Vladimir Zapolskiy (4):
ARM: dts: imx31: fix clock control module interrupts description
ARM: dts: imx31: move CCM device node to AIPS2 bus devices
clk: imx31: fix rewritten input argument of mx31_clocks_init()
ARM: clk: imx31: properly init clocks for machines with DT

Quoted 5 lines
 .../devicetree/bindings/clock/imx31-clock.txt      |  2 +-
 arch/arm/boot/dts/imx31.dtsi                       | 14 +++---
 arch/arm/mach-imx/common.h                         |  1 -
 arch/arm/mach-imx/imx31-dt.c                       |  6 ---
 drivers/clk/imx/clk-imx31.c                        | 52 +++++++++++-----------
Quoted 5 lines

Hi Stephen,

Can I have you ACK on the clk file, so that we can merge the series from arm-soc tree? Thanks.

Done.

Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
Applied
#11 lore raw

v2 cover ARM: imx31: clock initialization fixes

In reply to Vladimir Zapolskiy
Quoted 5 lines · Vladimir Zapolskiy

Vladimir Zapolskiy (4):
ARM: dts: imx31: fix clock control module interrupts description
ARM: dts: imx31: move CCM device node to AIPS2 bus devices
clk: imx31: fix rewritten input argument of mx31_clocks_init()
ARM: clk: imx31: properly init clocks for machines with DT

Applied all, thanks.