Skip to contentSkip to conversation

ARM: imx: make mxs_restart() work for DT boot

PATCH New Shawn Guo 2 participants 11 messages May 13, 2013

Subsystems (3)
lore
Share & tools
lore

Shawn Guo

author
#0 lore raw

cover ARM: imx: make mxs_restart() work for DT boot

The mxs_restart() currently only works for non-DT platforms. And per Russell's comment, it's not going to work reliably, because the restart routine could be called in atomic context while mxs_restart() is calling clk_prepare() there.

The series fixes above potential problem by moving clk_prepare() into initialization function mxc_arch_reset_init() and only keeping atomic part clk_enable() in mxs_restart().

Then a DT variant initialization function imx_arch_reset_init() is added, so that DT platforms can use mxs_restart() as well after invoking the initialization function.

Shawn Guo (3):
ARM: imx: include <asm/io.h> in hardware.h
ARM: imx: move clk_prepare() out from mxs_restart()
ARM: imx: create imx_arch_reset_init() for DT boot

 arch/arm/mach-imx/common.h     |    1 +
 arch/arm/mach-imx/hardware.h   |    1 +
 arch/arm/mach-imx/imx25-dt.c   |    2 ++
 arch/arm/mach-imx/imx27-dt.c   |    2 ++
 arch/arm/mach-imx/imx31-dt.c   |    2 ++
 arch/arm/mach-imx/imx51-dt.c   |    2 ++
 arch/arm/mach-imx/mach-imx53.c |    3 +++
 arch/arm/mach-imx/mm-imx1.c    |    2 +-
 arch/arm/mach-imx/mm-imx21.c   |    2 +-
 arch/arm/mach-imx/mm-imx25.c   |    2 +-
 arch/arm/mach-imx/mm-imx27.c   |    2 +-
 arch/arm/mach-imx/mm-imx3.c    |    4 ++--
 arch/arm/mach-imx/mm-imx5.c    |    3 +--
 arch/arm/mach-imx/system.c     |   47 +++++++++++++++++++++++++++++++---------
 14 files changed, 57 insertions(+), 18 deletions(-)
Signature · 1 line
1.7.9.5
author
#1 lore raw

PATCH 1/3 ARM: imx: include <asm/io.h> in hardware.h

As IOMEM is referenced in hardware.h, <asm/io.h> should be included there.

---
 arch/arm/mach-imx/hardware.h |    1 +
 1 file changed, 1 insertion(+)
arch/arm/mach-imx/hardware.h +1 -0
index 356131f..a3b0b04 100644
@@ -20,6 +20,7 @@
 #ifndef __ASM_ARCH_MXC_HARDWARE_H__
 #define __ASM_ARCH_MXC_HARDWARE_H__
 
+#include <asm/io.h>
 #include <asm/sizes.h>
 
 #define addr_in_module(addr, mod) \
Signature · 1 line
1.7.9.5
author
#2 lore raw

PATCH 2/3 ARM: imx: move clk_prepare() out from mxs_restart()

In reply to Shawn Guo

It's inappropriate to call clk_prepare() in mxs_restart(), because the restart routine could be called in atomic context. Move clk_get() and clk_prepare() into mxc_arch_reset_init() and only have the atomic part clk_enable() be called in mxs_restart().

As a result, mxc_arch_reset_init() needs to be called after clk gets initialized.

While there, it also changes printk(KERN_ERR ...) to pr_err() and adds __init annotation for mxc_arch_reset_init().

---
 arch/arm/mach-imx/imx25-dt.c   |    3 +++
 arch/arm/mach-imx/imx27-dt.c   |    3 +++
 arch/arm/mach-imx/imx31-dt.c   |    3 +++
 arch/arm/mach-imx/imx51-dt.c   |    3 +++
 arch/arm/mach-imx/mach-imx53.c |    3 +++
 arch/arm/mach-imx/mm-imx1.c    |    2 +-
 arch/arm/mach-imx/mm-imx21.c   |    2 +-
 arch/arm/mach-imx/mm-imx25.c   |    2 +-
 arch/arm/mach-imx/mm-imx27.c   |    2 +-
 arch/arm/mach-imx/mm-imx3.c    |    4 ++--
 arch/arm/mach-imx/mm-imx5.c    |    3 +--
 arch/arm/mach-imx/system.c     |   27 +++++++++++++++++----------
 12 files changed, 39 insertions(+), 18 deletions(-)
arch/arm/mach-imx/imx25-dt.c +3 -0
index 8234839..ec33991 100644
@@ -15,10 +15,13 @@
 #include <asm/mach/arch.h>
 #include <asm/mach/time.h>
 #include "common.h"
+#include "hardware.h"
 #include "mx25.h"
 
 static void __init imx25_dt_init(void)
 {
+	mxc_arch_reset_init(MX25_IO_ADDRESS(MX25_WDOG_BASE_ADDR));
+
 	of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
 }
 
arch/arm/mach-imx/imx27-dt.c +3 -0
index 4aaead0..93aef1a 100644
@@ -16,12 +16,15 @@
 #include <asm/mach/time.h>
 
 #include "common.h"
+#include "hardware.h"
 #include "mx27.h"
 
 static void __init imx27_dt_init(void)
 {
 	struct platform_device_info devinfo = { .name = "cpufreq-cpu0", };
 
+	mxc_arch_reset_init(MX27_IO_ADDRESS(MX27_WDOG_BASE_ADDR));
+
 	of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
 
 	platform_device_register_full(&devinfo);
arch/arm/mach-imx/imx31-dt.c +3 -0
index 67de611..d8b3b22 100644
@@ -16,10 +16,13 @@
 #include <asm/mach/time.h>
 
 #include "common.h"
+#include "hardware.h"
 #include "mx31.h"
 
 static void __init imx31_dt_init(void)
 {
+	mxc_arch_reset_init(MX31_IO_ADDRESS(MX31_WDOG_BASE_ADDR));
+
 	of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
 }
 
arch/arm/mach-imx/imx51-dt.c +3 -0
index ab24cc3..55f47a0 100644
@@ -17,12 +17,15 @@
 #include <asm/mach/time.h>
 
 #include "common.h"
+#include "hardware.h"
 #include "mx51.h"
 
 static void __init imx51_dt_init(void)
 {
 	struct platform_device_info devinfo = { .name = "cpufreq-cpu0", };
 
+	mxc_arch_reset_init(MX51_IO_ADDRESS(MX51_WDOG1_BASE_ADDR));
+
 	of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
 	platform_device_register_full(&devinfo);
 }
arch/arm/mach-imx/mach-imx53.c +3 -0
index f579c61..7a56561 100644
@@ -21,6 +21,7 @@
 #include <asm/mach/time.h>
 
 #include "common.h"
+#include "hardware.h"
 #include "mx53.h"
 
 static void __init imx53_qsb_init(void)
@@ -38,6 +39,8 @@ static void __init imx53_qsb_init(void)
 
 static void __init imx53_dt_init(void)
 {
+	mxc_arch_reset_init(MX53_IO_ADDRESS(MX53_WDOG1_BASE_ADDR));
+
 	if (of_machine_is_compatible("fsl,imx53-qsb"))
 		imx53_qsb_init();
 
arch/arm/mach-imx/mm-imx1.c +1 -1
index 3c609c5..e065fed 100644
@@ -39,7 +39,6 @@ void __init mx1_map_io(void)
 void __init imx1_init_early(void)
 {
 	mxc_set_cpu_type(MXC_CPU_MX1);
-	mxc_arch_reset_init(MX1_IO_ADDRESS(MX1_WDT_BASE_ADDR));
 	imx_iomuxv1_init(MX1_IO_ADDRESS(MX1_GPIO_BASE_ADDR),
 			MX1_NUM_GPIO_PORT);
 }
@@ -51,6 +50,7 @@ void __init mx1_init_irq(void)
 
 void __init imx1_soc_init(void)
 {
+	mxc_arch_reset_init(MX1_IO_ADDRESS(MX1_WDT_BASE_ADDR));
 	mxc_device_init();
 
 	mxc_register_gpio("imx1-gpio", 0, MX1_GPIO1_BASE_ADDR, SZ_256,
arch/arm/mach-imx/mm-imx21.c +1 -1
index d8ccd3a..2e91ab2 100644
@@ -66,7 +66,6 @@ void __init mx21_map_io(void)
 void __init imx21_init_early(void)
 {
 	mxc_set_cpu_type(MXC_CPU_MX21);
-	mxc_arch_reset_init(MX21_IO_ADDRESS(MX21_WDOG_BASE_ADDR));
 	imx_iomuxv1_init(MX21_IO_ADDRESS(MX21_GPIO_BASE_ADDR),
 			MX21_NUM_GPIO_PORT);
 }
@@ -82,6 +81,7 @@ static const struct resource imx21_audmux_res[] __initconst = {
 
 void __init imx21_soc_init(void)
 {
+	mxc_arch_reset_init(MX21_IO_ADDRESS(MX21_WDOG_BASE_ADDR));
 	mxc_device_init();
 
 	mxc_register_gpio("imx21-gpio", 0, MX21_GPIO1_BASE_ADDR, SZ_256, MX21_INT_GPIO, 0);
arch/arm/mach-imx/mm-imx25.c +1 -1
index 9357707..e065c11 100644
@@ -54,7 +54,6 @@ void __init imx25_init_early(void)
 {
 	mxc_set_cpu_type(MXC_CPU_MX25);
 	mxc_iomux_v3_init(MX25_IO_ADDRESS(MX25_IOMUXC_BASE_ADDR));
-	mxc_arch_reset_init(MX25_IO_ADDRESS(MX25_WDOG_BASE_ADDR));
 }
 
 void __init mx25_init_irq(void)
@@ -89,6 +88,7 @@ static const struct resource imx25_audmux_res[] __initconst = {
 
 void __init imx25_soc_init(void)
 {
+	mxc_arch_reset_init(MX25_IO_ADDRESS(MX25_WDOG_BASE_ADDR));
 	mxc_device_init();
 
 	/* i.mx25 has the i.mx35 type gpio */
arch/arm/mach-imx/mm-imx27.c +1 -1
index 4f1be65..7d82a5a 100644
@@ -66,7 +66,6 @@ void __init mx27_map_io(void)
 void __init imx27_init_early(void)
 {
 	mxc_set_cpu_type(MXC_CPU_MX27);
-	mxc_arch_reset_init(MX27_IO_ADDRESS(MX27_WDOG_BASE_ADDR));
 	imx_iomuxv1_init(MX27_IO_ADDRESS(MX27_GPIO_BASE_ADDR),
 			MX27_NUM_GPIO_PORT);
 }
@@ -82,6 +81,7 @@ static const struct resource imx27_audmux_res[] __initconst = {
 
 void __init imx27_soc_init(void)
 {
+	mxc_arch_reset_init(MX27_IO_ADDRESS(MX27_WDOG_BASE_ADDR));
 	mxc_device_init();
 
 	/* i.mx27 has the i.mx21 type gpio */
arch/arm/mach-imx/mm-imx3.c +2 -2
index e0e69a6..8f0f606 100644
@@ -138,7 +138,6 @@ void __init mx31_map_io(void)
 void __init imx31_init_early(void)
 {
 	mxc_set_cpu_type(MXC_CPU_MX31);
-	mxc_arch_reset_init(MX31_IO_ADDRESS(MX31_WDOG_BASE_ADDR));
 	arch_ioremap_caller = imx3_ioremap_caller;
 	arm_pm_idle = imx3_idle;
 	mx3_ccm_base = MX31_IO_ADDRESS(MX31_CCM_BASE_ADDR);
@@ -174,6 +173,7 @@ void __init imx31_soc_init(void)
 
 	imx3_init_l2x0();
 
+	mxc_arch_reset_init(MX31_IO_ADDRESS(MX31_WDOG_BASE_ADDR));
 	mxc_device_init();
 
 	mxc_register_gpio("imx31-gpio", 0, MX31_GPIO1_BASE_ADDR, SZ_16K, MX31_INT_GPIO1, 0);
@@ -216,7 +216,6 @@ void __init imx35_init_early(void)
 {
 	mxc_set_cpu_type(MXC_CPU_MX35);
 	mxc_iomux_v3_init(MX35_IO_ADDRESS(MX35_IOMUXC_BASE_ADDR));
-	mxc_arch_reset_init(MX35_IO_ADDRESS(MX35_WDOG_BASE_ADDR));
 	arm_pm_idle = imx3_idle;
 	arch_ioremap_caller = imx3_ioremap_caller;
 	mx3_ccm_base = MX35_IO_ADDRESS(MX35_CCM_BASE_ADDR);
@@ -272,6 +271,7 @@ void __init imx35_soc_init(void)
 
 	imx3_init_l2x0();
 
+	mxc_arch_reset_init(MX35_IO_ADDRESS(MX35_WDOG_BASE_ADDR));
 	mxc_device_init();
 
 	mxc_register_gpio("imx35-gpio", 0, MX35_GPIO1_BASE_ADDR, SZ_16K, MX35_INT_GPIO1, 0);
arch/arm/mach-imx/mm-imx5.c +1 -2
index b7c4e70..cf193d8 100644
@@ -83,7 +83,6 @@ void __init imx51_init_early(void)
 	imx51_ipu_mipi_setup();
 	mxc_set_cpu_type(MXC_CPU_MX51);
 	mxc_iomux_v3_init(MX51_IO_ADDRESS(MX51_IOMUXC_BASE_ADDR));
-	mxc_arch_reset_init(MX51_IO_ADDRESS(MX51_WDOG1_BASE_ADDR));
 	imx_src_init();
 }
 
@@ -91,7 +90,6 @@ void __init imx53_init_early(void)
 {
 	mxc_set_cpu_type(MXC_CPU_MX53);
 	mxc_iomux_v3_init(MX53_IO_ADDRESS(MX53_IOMUXC_BASE_ADDR));
-	mxc_arch_reset_init(MX53_IO_ADDRESS(MX53_WDOG1_BASE_ADDR));
 	imx_src_init();
 }
 
@@ -129,6 +127,7 @@ static const struct resource imx51_audmux_res[] __initconst = {
 
 void __init imx51_soc_init(void)
 {
+	mxc_arch_reset_init(MX51_IO_ADDRESS(MX51_WDOG1_BASE_ADDR));
 	mxc_device_init();
 
 	/* i.mx51 has the i.mx35 type gpio */
arch/arm/mach-imx/system.c +17 -10
index 695e0d7..02cf449 100644
@@ -30,6 +30,7 @@
 #include "hardware.h"
 
 static void __iomem *wdog_base;
+static struct clk *wdog_clk;
 
 /*
  * Reset the system. It is called by machine_restart().
@@ -38,16 +39,13 @@ void mxc_restart(char mode, const char *cmd)
 {
 	unsigned int wcr_enable;
 
-	if (cpu_is_mx1()) {
-		wcr_enable = (1 << 0);
-	} else {
-		struct clk *clk;
+	if (wdog_clk)
+		clk_enable(wdog_clk);
 
-		clk = clk_get_sys("imx2-wdt.0", NULL);
-		if (!IS_ERR(clk))
-			clk_prepare_enable(clk);
+	if (cpu_is_mx1())
+		wcr_enable = (1 << 0);
+	else
 		wcr_enable = (1 << 2);
-	}
 
 	/* Assert SRS signal */
 	__raw_writew(wcr_enable, wdog_base);
@@ -55,7 +53,7 @@ void mxc_restart(char mode, const char *cmd)
 	/* wait for reset to assert... */
 	mdelay(500);
 
-	printk(KERN_ERR "Watchdog reset failed to assert reset\n");
+	pr_err("%s: Watchdog reset failed to assert reset\n", __func__);
 
 	/* delay to allow the serial port to show the message */
 	mdelay(50);
@@ -64,7 +62,16 @@ void mxc_restart(char mode, const char *cmd)
 	soft_restart(0);
 }
 
-void mxc_arch_reset_init(void __iomem *base)
+void __init mxc_arch_reset_init(void __iomem *base)
 {
 	wdog_base = base;
+
+	wdog_clk = clk_get_sys("imx2-wdt.0", NULL);
+	if (IS_ERR(wdog_clk)) {
+		pr_warn("%s: failed to get wdog clock\n", __func__);
+		wdog_clk = NULL;
+		return;
+	}
+
+	clk_prepare(wdog_clk);
 }
Signature · 1 line
1.7.9.5
maintainer
#3 lore raw

PATCH 2/3 ARM: imx: move clk_prepare() out from mxs_restart()

Hi Shawn,

In the subject:

s/mxs_restart/mxc_restart/

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 |
author
#4 lore raw

PATCH 2/3 ARM: imx: move clk_prepare() out from mxs_restart()

Quoted 5 lines · Sascha Hauer

Hi Shawn,

In the subject:

s/mxs_restart/mxc_restart/

Thanks, Sascha. Fixed it and commit log as well.

Shawn

author
#5 lore raw

PATCH 3/3 ARM: imx: create imx_arch_reset_init() for DT boot

In reply to Shawn Guo

The mxc_arch_reset_init() uses static mapping and calls clk_get_sys() to get clock. It's suitable for non-DT boot but not for DT boot where dynamic mapping and of_clk_get() should be used instead. Create imx_arch_reset_init() as the DT variant of mxc_arch_reset_init(), and change DT platforms to use it.

---
 arch/arm/mach-imx/common.h     |    1 +
 arch/arm/mach-imx/imx25-dt.c   |    3 +--
 arch/arm/mach-imx/imx27-dt.c   |    3 +--
 arch/arm/mach-imx/imx31-dt.c   |    3 +--
 arch/arm/mach-imx/imx51-dt.c   |    3 +--
 arch/arm/mach-imx/mach-imx53.c |    2 +-
 arch/arm/mach-imx/system.c     |   20 ++++++++++++++++++++
 7 files changed, 26 insertions(+), 9 deletions(-)
arch/arm/mach-imx/common.h +1 -0
index c08ae3f..3ef909b 100644
@@ -74,6 +74,7 @@ extern struct platform_device *mxc_register_gpio(char *name, int id,
 extern void mxc_set_cpu_type(unsigned int type);
 extern void mxc_restart(char, const char *);
 extern void mxc_arch_reset_init(void __iomem *);
+extern void imx_arch_reset_init(void);
 extern int mx53_revision(void);
 extern int imx6q_revision(void);
 extern int mx53_display_revision(void);
arch/arm/mach-imx/imx25-dt.c +1 -2
index ec33991..a2575267 100644
@@ -15,12 +15,11 @@
 #include <asm/mach/arch.h>
 #include <asm/mach/time.h>
 #include "common.h"
-#include "hardware.h"
 #include "mx25.h"
 
 static void __init imx25_dt_init(void)
 {
-	mxc_arch_reset_init(MX25_IO_ADDRESS(MX25_WDOG_BASE_ADDR));
+	imx_arch_reset_init();
 
 	of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
 }
arch/arm/mach-imx/imx27-dt.c +1 -2
index 93aef1a..174e441 100644
@@ -16,14 +16,13 @@
 #include <asm/mach/time.h>
 
 #include "common.h"
-#include "hardware.h"
 #include "mx27.h"
 
 static void __init imx27_dt_init(void)
 {
 	struct platform_device_info devinfo = { .name = "cpufreq-cpu0", };
 
-	mxc_arch_reset_init(MX27_IO_ADDRESS(MX27_WDOG_BASE_ADDR));
+	imx_arch_reset_init();
 
 	of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
 
arch/arm/mach-imx/imx31-dt.c +1 -2
index d8b3b22..a07cdec 100644
@@ -16,12 +16,11 @@
 #include <asm/mach/time.h>
 
 #include "common.h"
-#include "hardware.h"
 #include "mx31.h"
 
 static void __init imx31_dt_init(void)
 {
-	mxc_arch_reset_init(MX31_IO_ADDRESS(MX31_WDOG_BASE_ADDR));
+	imx_arch_reset_init();
 
 	of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
 }
arch/arm/mach-imx/imx51-dt.c +1 -2
index 55f47a0..b2f5830 100644
@@ -17,14 +17,13 @@
 #include <asm/mach/time.h>
 
 #include "common.h"
-#include "hardware.h"
 #include "mx51.h"
 
 static void __init imx51_dt_init(void)
 {
 	struct platform_device_info devinfo = { .name = "cpufreq-cpu0", };
 
-	mxc_arch_reset_init(MX51_IO_ADDRESS(MX51_WDOG1_BASE_ADDR));
+	imx_arch_reset_init();
 
 	of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
 	platform_device_register_full(&devinfo);
arch/arm/mach-imx/mach-imx53.c +1 -1
index 7a56561..e0da2cc 100644
@@ -39,7 +39,7 @@ static void __init imx53_qsb_init(void)
 
 static void __init imx53_dt_init(void)
 {
-	mxc_arch_reset_init(MX53_IO_ADDRESS(MX53_WDOG1_BASE_ADDR));
+	imx_arch_reset_init();
 
 	if (of_machine_is_compatible("fsl,imx53-qsb"))
 		imx53_qsb_init();
arch/arm/mach-imx/system.c +20 -0
index 02cf449..973f01d 100644
@@ -21,6 +21,8 @@
 #include <linux/io.h>
 #include <linux/err.h>
 #include <linux/delay.h>
+#include <linux/of.h>
+#include <linux/of_address.h>
 
 #include <asm/system_misc.h>
 #include <asm/proc-fns.h>
@@ -75,3 +77,21 @@ void __init mxc_arch_reset_init(void __iomem *base)
 
 	clk_prepare(wdog_clk);
 }
+
+void __init imx_arch_reset_init(void)
+{
+	struct device_node *np;
+
+	np = of_find_compatible_node(NULL, NULL, "fsl,imx21-wdt");
+	wdog_base = of_iomap(np, 0);
+	WARN_ON(!wdog_base);
+
+	wdog_clk = of_clk_get(np, 0);
+	if (IS_ERR(wdog_clk)) {
+		pr_warn("%s: failed to get wdog clock\n", __func__);
+		wdog_clk = NULL;
+		return;
+	}
+
+	clk_prepare(wdog_clk);
+}
Signature · 1 line
1.7.9.5
maintainer
#6 lore raw

PATCH 3/3 ARM: imx: create imx_arch_reset_init() for DT boot

Quoted 5 lines · Shawn Guo

The mxc_arch_reset_init() uses static mapping and calls clk_get_sys() to get clock. It's suitable for non-DT boot but not for DT boot where dynamic mapping and of_clk_get() should be used instead. Create imx_arch_reset_init() as the DT variant of mxc_arch_reset_init(), and change DT platforms to use it.

Having mxc_arch_reset_init for !dt and the same functionality for dt named imx_arch_reset_init is a bit confusing. Maybe add _dt_ to the function name?

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 |
author
#7 lore raw

PATCH 3/3 ARM: imx: create imx_arch_reset_init() for DT boot

Quoted 10 lines · Sascha Hauer
Quoted 5 lines · Shawn Guo

The mxc_arch_reset_init() uses static mapping and calls clk_get_sys() to get clock. It's suitable for non-DT boot but not for DT boot where dynamic mapping and of_clk_get() should be used instead. Create imx_arch_reset_init() as the DT variant of mxc_arch_reset_init(), and change DT platforms to use it.

Having mxc_arch_reset_init for !dt and the same functionality for dt named imx_arch_reset_init is a bit confusing. Maybe add _dt_ to the function name?

Ok, will change it to mxc_arch_reset_init_dt() avoid the confusion.

Shawn

maintainer
#8 lore raw

PATCH 3/3 ARM: imx: create imx_arch_reset_init() for DT boot

Quoted 8 lines · Shawn Guo
Quoted 7 lines · Sascha Hauer
Quoted 5 lines · Shawn Guo

The mxc_arch_reset_init() uses static mapping and calls clk_get_sys() to get clock. It's suitable for non-DT boot but not for DT boot where dynamic mapping and of_clk_get() should be used instead. Create imx_arch_reset_init() as the DT variant of mxc_arch_reset_init(), and change DT platforms to use it.

Quoted 5 lines
Quoted 3 lines

Having mxc_arch_reset_init for !dt and the same functionality for dt named imx_arch_reset_init is a bit confusing. Maybe add _dt_ to the function name?

Ok, will change it to mxc_arch_reset_init_dt() avoid the confusion.

I think we both prefer 'imx' over 'mxc', but maybe changing this is topic for another patch.

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 |
author
#9 lore raw

PATCH v2 3/3 ARM: imx: create mxc_arch_reset_init_dt() for DT boot

In reply to Shawn Guo

The mxc_arch_reset_init() uses static mapping and calls clk_get_sys() to get clock. It's suitable for non-DT boot but not for DT boot where dynamic mapping and of_clk_get() should be used instead. Create mxc_arch_reset_init_dt() as the DT variant of mxc_arch_reset_init(), and change DT platforms to use it.

---
Changes since v1:
* Rename the new function as mxc_arch_reset_init_dt()

 arch/arm/mach-imx/common.h     |    1 +
 arch/arm/mach-imx/imx25-dt.c   |    3 +--
 arch/arm/mach-imx/imx27-dt.c   |    3 +--
 arch/arm/mach-imx/imx31-dt.c   |    3 +--
 arch/arm/mach-imx/imx51-dt.c   |    3 +--
 arch/arm/mach-imx/mach-imx53.c |    2 +-
 arch/arm/mach-imx/system.c     |   20 ++++++++++++++++++++
 7 files changed, 26 insertions(+), 9 deletions(-)
arch/arm/mach-imx/common.h +1 -0
index c08ae3f..963971e1 100644
@@ -74,6 +74,7 @@ extern struct platform_device *mxc_register_gpio(char *name, int id,
 extern void mxc_set_cpu_type(unsigned int type);
 extern void mxc_restart(char, const char *);
 extern void mxc_arch_reset_init(void __iomem *);
+extern void mxc_arch_reset_init_dt(void);
 extern int mx53_revision(void);
 extern int imx6q_revision(void);
 extern int mx53_display_revision(void);
arch/arm/mach-imx/imx25-dt.c +1 -2
index ec33991..3e1ec5f 100644
@@ -15,12 +15,11 @@
 #include <asm/mach/arch.h>
 #include <asm/mach/time.h>
 #include "common.h"
-#include "hardware.h"
 #include "mx25.h"
 
 static void __init imx25_dt_init(void)
 {
-	mxc_arch_reset_init(MX25_IO_ADDRESS(MX25_WDOG_BASE_ADDR));
+	mxc_arch_reset_init_dt();
 
 	of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
 }
arch/arm/mach-imx/imx27-dt.c +1 -2
index 93aef1a..4e235ec 100644
@@ -16,14 +16,13 @@
 #include <asm/mach/time.h>
 
 #include "common.h"
-#include "hardware.h"
 #include "mx27.h"
 
 static void __init imx27_dt_init(void)
 {
 	struct platform_device_info devinfo = { .name = "cpufreq-cpu0", };
 
-	mxc_arch_reset_init(MX27_IO_ADDRESS(MX27_WDOG_BASE_ADDR));
+	mxc_arch_reset_init_dt();
 
 	of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
 
arch/arm/mach-imx/imx31-dt.c +1 -2
index d8b3b22..818a1cc 100644
@@ -16,12 +16,11 @@
 #include <asm/mach/time.h>
 
 #include "common.h"
-#include "hardware.h"
 #include "mx31.h"
 
 static void __init imx31_dt_init(void)
 {
-	mxc_arch_reset_init(MX31_IO_ADDRESS(MX31_WDOG_BASE_ADDR));
+	mxc_arch_reset_init_dt();
 
 	of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
 }
arch/arm/mach-imx/imx51-dt.c +1 -2
index 55f47a0..53e43e5 100644
@@ -17,14 +17,13 @@
 #include <asm/mach/time.h>
 
 #include "common.h"
-#include "hardware.h"
 #include "mx51.h"
 
 static void __init imx51_dt_init(void)
 {
 	struct platform_device_info devinfo = { .name = "cpufreq-cpu0", };
 
-	mxc_arch_reset_init(MX51_IO_ADDRESS(MX51_WDOG1_BASE_ADDR));
+	mxc_arch_reset_init_dt();
 
 	of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
 	platform_device_register_full(&devinfo);
arch/arm/mach-imx/mach-imx53.c +1 -1
index 7a56561..74e7b94c 100644
@@ -39,7 +39,7 @@ static void __init imx53_qsb_init(void)
 
 static void __init imx53_dt_init(void)
 {
-	mxc_arch_reset_init(MX53_IO_ADDRESS(MX53_WDOG1_BASE_ADDR));
+	mxc_arch_reset_init_dt();
 
 	if (of_machine_is_compatible("fsl,imx53-qsb"))
 		imx53_qsb_init();
arch/arm/mach-imx/system.c +20 -0
index 02cf449..7cdc79a 100644
@@ -21,6 +21,8 @@
 #include <linux/io.h>
 #include <linux/err.h>
 #include <linux/delay.h>
+#include <linux/of.h>
+#include <linux/of_address.h>
 
 #include <asm/system_misc.h>
 #include <asm/proc-fns.h>
@@ -75,3 +77,21 @@ void __init mxc_arch_reset_init(void __iomem *base)
 
 	clk_prepare(wdog_clk);
 }
+
+void __init mxc_arch_reset_init_dt(void)
+{
+	struct device_node *np;
+
+	np = of_find_compatible_node(NULL, NULL, "fsl,imx21-wdt");
+	wdog_base = of_iomap(np, 0);
+	WARN_ON(!wdog_base);
+
+	wdog_clk = of_clk_get(np, 0);
+	if (IS_ERR(wdog_clk)) {
+		pr_warn("%s: failed to get wdog clock\n", __func__);
+		wdog_clk = NULL;
+		return;
+	}
+
+	clk_prepare(wdog_clk);
+}
Signature · 1 line
1.7.9.5
maintainer
#10 lore raw

PATCH v2 3/3 ARM: imx: create mxc_arch_reset_init_dt() for DT boot

Quoted 7 lines · Shawn Guo

The mxc_arch_reset_init() uses static mapping and calls clk_get_sys() to get clock. It's suitable for non-DT boot but not for DT boot where dynamic mapping and of_clk_get() should be used instead. Create mxc_arch_reset_init_dt() as the DT variant of mxc_arch_reset_init(), and change DT platforms to use it.

(For the whole series)

Sascha

Quoted 154 lines

---
Changes since v1:
* Rename the new function as mxc_arch_reset_init_dt()

 arch/arm/mach-imx/common.h     |    1 +
 arch/arm/mach-imx/imx25-dt.c   |    3 +--
 arch/arm/mach-imx/imx27-dt.c   |    3 +--
 arch/arm/mach-imx/imx31-dt.c   |    3 +--
 arch/arm/mach-imx/imx51-dt.c   |    3 +--
 arch/arm/mach-imx/mach-imx53.c |    2 +-
 arch/arm/mach-imx/system.c     |   20 ++++++++++++++++++++
 7 files changed, 26 insertions(+), 9 deletions(-)
arch/arm/mach-imx/common.h +1 -0
index c08ae3f..963971e1 100644
@@ -74,6 +74,7 @@ extern struct platform_device *mxc_register_gpio(char *name, int id,
 extern void mxc_set_cpu_type(unsigned int type);
 extern void mxc_restart(char, const char *);
 extern void mxc_arch_reset_init(void __iomem *);
+extern void mxc_arch_reset_init_dt(void);
 extern int mx53_revision(void);
 extern int imx6q_revision(void);
 extern int mx53_display_revision(void);
arch/arm/mach-imx/imx25-dt.c +1 -2
index ec33991..3e1ec5f 100644
@@ -15,12 +15,11 @@
 #include <asm/mach/arch.h>
 #include <asm/mach/time.h>
 #include "common.h"
-#include "hardware.h"
 #include "mx25.h"
 
 static void __init imx25_dt_init(void)
 {
-	mxc_arch_reset_init(MX25_IO_ADDRESS(MX25_WDOG_BASE_ADDR));
+	mxc_arch_reset_init_dt();
 
 	of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
 }
arch/arm/mach-imx/imx27-dt.c +1 -2
index 93aef1a..4e235ec 100644
@@ -16,14 +16,13 @@
 #include <asm/mach/time.h>
 
 #include "common.h"
-#include "hardware.h"
 #include "mx27.h"
 
 static void __init imx27_dt_init(void)
 {
 	struct platform_device_info devinfo = { .name = "cpufreq-cpu0", };
 
-	mxc_arch_reset_init(MX27_IO_ADDRESS(MX27_WDOG_BASE_ADDR));
+	mxc_arch_reset_init_dt();
 
 	of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
 
arch/arm/mach-imx/imx31-dt.c +1 -2
index d8b3b22..818a1cc 100644
@@ -16,12 +16,11 @@
 #include <asm/mach/time.h>
 
 #include "common.h"
-#include "hardware.h"
 #include "mx31.h"
 
 static void __init imx31_dt_init(void)
 {
-	mxc_arch_reset_init(MX31_IO_ADDRESS(MX31_WDOG_BASE_ADDR));
+	mxc_arch_reset_init_dt();
 
 	of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
 }
arch/arm/mach-imx/imx51-dt.c +1 -2
index 55f47a0..53e43e5 100644
@@ -17,14 +17,13 @@
 #include <asm/mach/time.h>
 
 #include "common.h"
-#include "hardware.h"
 #include "mx51.h"
 
 static void __init imx51_dt_init(void)
 {
 	struct platform_device_info devinfo = { .name = "cpufreq-cpu0", };
 
-	mxc_arch_reset_init(MX51_IO_ADDRESS(MX51_WDOG1_BASE_ADDR));
+	mxc_arch_reset_init_dt();
 
 	of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
 	platform_device_register_full(&devinfo);
arch/arm/mach-imx/mach-imx53.c +1 -1
index 7a56561..74e7b94c 100644
@@ -39,7 +39,7 @@ static void __init imx53_qsb_init(void)
 
 static void __init imx53_dt_init(void)
 {
-	mxc_arch_reset_init(MX53_IO_ADDRESS(MX53_WDOG1_BASE_ADDR));
+	mxc_arch_reset_init_dt();
 
 	if (of_machine_is_compatible("fsl,imx53-qsb"))
 		imx53_qsb_init();
arch/arm/mach-imx/system.c +20 -0
index 02cf449..7cdc79a 100644
@@ -21,6 +21,8 @@
 #include <linux/io.h>
 #include <linux/err.h>
 #include <linux/delay.h>
+#include <linux/of.h>
+#include <linux/of_address.h>
 
 #include <asm/system_misc.h>
 #include <asm/proc-fns.h>
@@ -75,3 +77,21 @@ void __init mxc_arch_reset_init(void __iomem *base)
 
 	clk_prepare(wdog_clk);
 }
+
+void __init mxc_arch_reset_init_dt(void)
+{
+	struct device_node *np;
+
+	np = of_find_compatible_node(NULL, NULL, "fsl,imx21-wdt");
+	wdog_base = of_iomap(np, 0);
+	WARN_ON(!wdog_base);
+
+	wdog_clk = of_clk_get(np, 0);
+	if (IS_ERR(wdog_clk)) {
+		pr_warn("%s: failed to get wdog clock\n", __func__);
+		wdog_clk = NULL;
+		return;
+	}
+
+	clk_prepare(wdog_clk);
+}
Signature · 1 line
1.7.9.5
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 |