Skip to contentSkip to conversation

ARM: dts: imx6q: add common compatible name for reused modules

PATCH New Anson Huang 4 participants 14 messages Jan 13, 2014 – Jan 14, 2014

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

PATCH v4 1/6 ARM: dts: imx6q: add common compatible name for reused modules

As some modules are common for all i.MX6 SOCs, to avoid checking cpu type for drivers that needs them, just add a new compatible name for them.

---
 arch/arm/boot/dts/imx6q.dtsi   |    2 +-
 arch/arm/boot/dts/imx6qdl.dtsi |    6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)
arch/arm/boot/dts/imx6q.dtsi +1 -1
index 021e0cb..5bc79c7 100644
@@ -91,7 +91,7 @@
 			};
 
 			iomuxc: iomuxc at 020e0000 {
-				compatible = "fsl,imx6q-iomuxc";
+				compatible = "fsl,imx6q-iomuxc", "fsl,iomuxc";
 
 				ipu2 {
 					pinctrl_ipu2_1: ipu2grp-1 {
arch/arm/boot/dts/imx6qdl.dtsi +3 -3
index 8a86502..cb9129b 100644
@@ -622,7 +622,7 @@
 			};
 
 			src: src at 020d8000 {
-				compatible = "fsl,imx6q-src", "fsl,imx51-src";
+				compatible = "fsl,imx6q-src", "fsl,imx51-src", "fsl,src";
 				reg = <0x020d8000 0x4000>;
 				interrupts = <0 91 IRQ_TYPE_LEVEL_HIGH>,
 					     <0 96 IRQ_TYPE_LEVEL_HIGH>;
@@ -630,7 +630,7 @@
 			};
 
 			gpc: gpc at 020dc000 {
-				compatible = "fsl,imx6q-gpc";
+				compatible = "fsl,imx6q-gpc", "fsl,gpc";
 				reg = <0x020dc000 0x4000>;
 				interrupts = <0 89 IRQ_TYPE_LEVEL_HIGH>,
 					     <0 90 IRQ_TYPE_LEVEL_HIGH>;
@@ -840,7 +840,7 @@
 			};
 
 			mmdc0: mmdc at 021b0000 { /* MMDC0 */
-				compatible = "fsl,imx6q-mmdc";
+				compatible = "fsl,imx6q-mmdc", "fsl,mmdc";
 				reg = <0x021b0000 0x4000>;
 			};
 
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH v4 2/6 ARM: imx: add suspend in ocram support on i.mx6q

When system enter suspend, we can set the DDR IO to high-Z state to save DDR IO's power, this operation can save many power(from ~26mA at 1.5V to ~15mA at 1.5V, measured on i.MX6Q/DL SabreSD board, R25) of DDR IO. To achieve that, we need to copy the suspend code to ocram and run the low level hardware related code(set DDR IO to high-Z) in ocram.

If there is no ocram space available, then system will still do suspend in DDR, hence no DDR IO will be set to high-Z.

The OCRAM usage layout is as below,

ocram suspend region:
======================== high address ======================

                              .
                              .
                              .
                              ^
                              ^
                              ^
                      imx6_suspend code
      reserved region(to make imx6_suspend aligned with 8)
             PM_INFO structure(imx6_cpu_pm_info)

======================== low address =======================

---
Changes since V3:
1. Add const to MMDC IO offset array;
2. Improve for-loop code to save code lines;
3. Use __aligned to save one variable of pm_info;
4. Remove unnecessary header files.

 arch/arm/mach-imx/Makefile       |    3 +-
 arch/arm/mach-imx/common.h       |    4 +-
 arch/arm/mach-imx/hardware.h     |    4 +-
 arch/arm/mach-imx/pm-imx6q.c     |  245 +++++++++++++++++++++++++++++-
 arch/arm/mach-imx/suspend-imx6.S |  303 ++++++++++++++++++++++++++++++++++++++
 5 files changed, 552 insertions(+), 7 deletions(-)
 create mode 100644 arch/arm/mach-imx/suspend-imx6.S
arch/arm/mach-imx/Makefile +2 -1
index befcaf5..3d96a45 100644
@@ -102,7 +102,8 @@ obj-$(CONFIG_SOC_IMX6Q) += clk-imx6q.o mach-imx6q.o
 obj-$(CONFIG_SOC_IMX6SL) += clk-imx6sl.o mach-imx6sl.o
 
 ifeq ($(CONFIG_PM),y)
-obj-$(CONFIG_SOC_IMX6Q) += pm-imx6q.o headsmp.o
+AFLAGS_suspend-imx6.o :=-Wa,-march=armv7-a
+obj-$(CONFIG_SOC_IMX6Q) += pm-imx6q.o headsmp.o suspend-imx6.o
 # i.MX6SL reuses i.MX6Q code
 obj-$(CONFIG_SOC_IMX6SL) += pm-imx6q.o headsmp.o
 endif
arch/arm/mach-imx/common.h +3 -1
index 4f4a95c..7c249e1 100644
@@ -1,5 +1,5 @@
 /*
- * Copyright 2004-2013 Freescale Semiconductor, Inc. All Rights Reserved.
+ * Copyright 2004-2014 Freescale Semiconductor, Inc. All Rights Reserved.
  */
 
 /*
@@ -145,10 +145,12 @@ void imx_cpu_die(unsigned int cpu);
 int imx_cpu_kill(unsigned int cpu);
 
 #ifdef CONFIG_PM
+void imx6_suspend(void);
 void imx6q_pm_init(void);
 void imx6q_pm_set_ccm_base(void __iomem *base);
 void imx5_pm_init(void);
 #else
+static inline void imx6_suspend(void) {}
 static inline void imx6q_pm_init(void) {}
 static inline void imx6q_pm_set_ccm_base(void __iomem *base) {}
 static inline void imx5_pm_init(void) {}
arch/arm/mach-imx/hardware.h +3 -1
index a3b0b04..abf43bb 100644
@@ -1,5 +1,5 @@
 /*
- * Copyright 2004-2007 Freescale Semiconductor, Inc. All Rights Reserved.
+ * Copyright 2004-2007, 2014 Freescale Semiconductor, Inc. All Rights Reserved.
  * Copyright 2008 Juergen Beisert, kernel at pengutronix.de
  *
  * This program is free software; you can redistribute it and/or
@@ -20,7 +20,9 @@
 #ifndef __ASM_ARCH_MXC_HARDWARE_H__
 #define __ASM_ARCH_MXC_HARDWARE_H__
 
+#ifndef __ASSEMBLY__
 #include <asm/io.h>
+#endif
 #include <asm/sizes.h>
 
 #define addr_in_module(addr, mod) \
arch/arm/mach-imx/pm-imx6q.c +241 -4

295 lines not on this page · raw message

arch/arm/mach-imx/suspend-imx6.S new file +303 -0

303 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#4 lore raw

PATCH v4 3/6 ARM: dts: imx6dl: add common compatible name for reused modules

In reply to Anson Huang

As some modules are common for all i.MX6 SOCs, to avoid checking cpu type for drivers that needs them, just add a new compatible name for them.

---
 arch/arm/boot/dts/imx6dl.dtsi |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/boot/dts/imx6dl.dtsi +1 -1
index e2ec0fb..0d264b7 100644
@@ -62,7 +62,7 @@
 
 		aips1: aips-bus at 02000000 {
 			iomuxc: iomuxc at 020e0000 {
-				compatible = "fsl,imx6dl-iomuxc";
+				compatible = "fsl,imx6dl-iomuxc", "fsl,iomuxc";
 			};
 
 			pxp: pxp at 020f0000 {
Signature · 1 line
1.7.9.5
#5 lore raw

PATCH v4 4/6 ARM: imx: add suspend in ocram support on i.mx6dl

In reply to Anson Huang

i.MX6DL's suspend in ocram function is derived from i.MX6Q, the only difference is the offset of DDR IO pins. It can lower the DDR IO power from ~26mA at 1.5V to ~15mA at 1.5V, measured on i.MX6Q/DL SabreSD board, R25.

---
 arch/arm/mach-imx/pm-imx6q.c |   16 ++++++++++++++++
 1 file changed, 16 insertions(+)
arch/arm/mach-imx/pm-imx6q.c +16 -0
index 42ac301..826bf8a 100644
@@ -100,6 +100,18 @@ static const u32 imx6q_mmdc_io_dsm_offset[] __initconst = {
 	0x74c			    /* GPR_ADDS */
 };
 
+static const u32 imx6dl_mmdc_io_dsm_offset[] __initconst = {
+	0x470, 0x474, 0x478, 0x47c, /* DQM0 ~ DQM3 */
+	0x480, 0x484, 0x488, 0x48c, /* DQM4 ~ DQM7 */
+	0x464, 0x490, 0x4ac, 0x4b0, /* CAS, RAS, SDCLK_0, SDCLK_1 */
+	0x4bc, 0x4c0, 0x4c4, 0x4c8, /* DRAM_SDQS0 ~ DRAM_SDQS3 */
+	0x4cc, 0x4d0, 0x4d4, 0x4d8, /* DRAM_SDQS4 ~ DRAM_SDQS7 */
+	0x764, 0x770, 0x778, 0x77c, /* GPR_B0DS ~ GPR_B3DS */
+	0x780, 0x784, 0x78c, 0x748, /* GPR_B4DS ~ GPR_B7DS */
+	0x4b4, 0x4b8, 0x750, 0x760, /* SODT0, SODT1, DDRMODE_CTL, DDRMODE */
+	0x74c			    /* GPR_ADDS */
+};
+
 /*
  * This structure is for passing necessary data for low level ocram
  * suspend code(arch/arm/mach-imx/suspend-imx6.S), if this struct
@@ -413,6 +425,10 @@ static int __init imx6q_ocram_suspend_init(void)
 		pm_info->cpu_type = MXC_CPU_IMX6Q;
 		pm_info->mmdc_io_num = ARRAY_SIZE(imx6q_mmdc_io_dsm_offset);
 		mmdc_offset_array = imx6q_mmdc_io_dsm_offset;
+	} else if (cpu_is_imx6dl()) {
+		pm_info->cpu_type = MXC_CPU_IMX6DL;
+		pm_info->mmdc_io_num = ARRAY_SIZE(imx6dl_mmdc_io_dsm_offset);
+		mmdc_offset_array = imx6dl_mmdc_io_dsm_offset;
 	}
 
 	if (!mmdc_offset_array) {
Signature · 1 line
1.7.9.5
#6 lore raw

PATCH v4 5/6 ARM: dts: imx6sl: add common compatible name for reused modules

In reply to Anson Huang

As some modules are common for all i.MX6 SOCs, to avoid checking cpu type for drivers that needs them, just add a new compatible name for them.

---
 arch/arm/boot/dts/imx6sl.dtsi |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
arch/arm/boot/dts/imx6sl.dtsi +4 -4
index a5ef3c3..01f65a2 100644
@@ -564,7 +564,7 @@
 			};
 
 			src: src at 020d8000 {
-				compatible = "fsl,imx6sl-src", "fsl,imx51-src";
+				compatible = "fsl,imx6sl-src", "fsl,imx51-src", "fsl,src";
 				reg = <0x020d8000 0x4000>;
 				interrupts = <0 91 IRQ_TYPE_LEVEL_HIGH>,
 					     <0 96 IRQ_TYPE_LEVEL_HIGH>;
@@ -572,7 +572,7 @@
 			};
 
 			gpc: gpc at 020dc000 {
-				compatible = "fsl,imx6sl-gpc", "fsl,imx6q-gpc";
+				compatible = "fsl,imx6sl-gpc", "fsl,imx6q-gpc", "fsl,gpc";
 				reg = <0x020dc000 0x4000>;
 				interrupts = <0 89 IRQ_TYPE_LEVEL_HIGH>;
 			};
@@ -584,7 +584,7 @@
 			};
 
 			iomuxc: iomuxc at 020e0000 {
-				compatible = "fsl,imx6sl-iomuxc";
+				compatible = "fsl,imx6sl-iomuxc", "fsl,iomuxc";
 				reg = <0x020e0000 0x4000>;
 			};
 
@@ -763,7 +763,7 @@
 			};
 
 			mmdc: mmdc at 021b0000 {
-				compatible = "fsl,imx6sl-mmdc", "fsl,imx6q-mmdc";
+				compatible = "fsl,imx6sl-mmdc", "fsl,imx6q-mmdc", "fsl,mmdc";
 				reg = <0x021b0000 0x4000>;
 			};
 
Signature · 1 line
1.7.9.5
#7 lore raw

PATCH v4 6/6 ARM: imx: add suspend in ocram support on i.mx6sl

In reply to Anson Huang

i.MX6SL's suspend in ocram function is derived from i.MX6Q, the only difference is the offset of DDR IO pins. It can lower the DDR IO power from ~10mA at 1.2V to ~1mA at 1.2V, measured on i.MX6SL EVK board, SH5.

---
 arch/arm/mach-imx/Makefile       |    2 +-
 arch/arm/mach-imx/pm-imx6q.c     |   12 +++++++
 arch/arm/mach-imx/suspend-imx6.S |   74 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 87 insertions(+), 1 deletion(-)
arch/arm/mach-imx/Makefile +1 -1
index 3d96a45..f2df89f 100644
@@ -105,7 +105,7 @@ ifeq ($(CONFIG_PM),y)
 AFLAGS_suspend-imx6.o :=-Wa,-march=armv7-a
 obj-$(CONFIG_SOC_IMX6Q) += pm-imx6q.o headsmp.o suspend-imx6.o
 # i.MX6SL reuses i.MX6Q code
-obj-$(CONFIG_SOC_IMX6SL) += pm-imx6q.o headsmp.o
+obj-$(CONFIG_SOC_IMX6SL) += pm-imx6q.o headsmp.o suspend-imx6.o
 endif
 
 # i.MX5 based machines
arch/arm/mach-imx/pm-imx6q.c +12 -0
index 826bf8a..175b229 100644
@@ -112,6 +112,14 @@ static const u32 imx6dl_mmdc_io_dsm_offset[] __initconst = {
 	0x74c			    /* GPR_ADDS */
 };
 
+static const u32 imx6sl_mmdc_io_dsm_offset[] __initconst = {
+	0x30c, 0x310, 0x314, 0x318, /* DQM0 ~ DQM3 */
+	0x5c4, 0x5cc, 0x5d4, 0x5d8, /* GPR_B0DS ~ GPR_B3DS */
+	0x300, 0x31c, 0x338, 0x5ac, /* CAS, RAS, SDCLK_0, GPR_ADDS */
+	0x33c, 0x340, 0x5b0, 0x5c0, /* SODT0, SODT1, DDRMODE_CTL, DDRMODE */
+	0x330, 0x334, 0x320,	    /* SDCKE0, SDCKE1, RESET */
+};
+
 /*
  * This structure is for passing necessary data for low level ocram
  * suspend code(arch/arm/mach-imx/suspend-imx6.S), if this struct
@@ -429,6 +437,10 @@ static int __init imx6q_ocram_suspend_init(void)
 		pm_info->cpu_type = MXC_CPU_IMX6DL;
 		pm_info->mmdc_io_num = ARRAY_SIZE(imx6dl_mmdc_io_dsm_offset);
 		mmdc_offset_array = imx6dl_mmdc_io_dsm_offset;
+	} else if (cpu_is_imx6sl()) {
+		pm_info->cpu_type = MXC_CPU_IMX6SL;
+		pm_info->mmdc_io_num = ARRAY_SIZE(imx6sl_mmdc_io_dsm_offset);
+		mmdc_offset_array = imx6sl_mmdc_io_dsm_offset;
 	}
 
 	if (!mmdc_offset_array) {
arch/arm/mach-imx/suspend-imx6.S +74 -0

108 lines not on this page · raw message

Signature · 1 line
1.7.9.5
maintainer
#8 lore raw

PATCH v4 1/6 ARM: dts: imx6q: add common compatible name for reused modules

In reply to Anson Huang
Quoted 46 lines · Anson Huang

As some modules are common for all i.MX6 SOCs, to avoid checking cpu type for drivers that needs them, just add a new compatible name for them.

---
 arch/arm/boot/dts/imx6q.dtsi   |    2 +-
 arch/arm/boot/dts/imx6qdl.dtsi |    6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)
arch/arm/boot/dts/imx6q.dtsi +1 -1
index 021e0cb..5bc79c7 100644
@@ -91,7 +91,7 @@
 			};
 
 			iomuxc: iomuxc at 020e0000 {
-				compatible = "fsl,imx6q-iomuxc";
+				compatible = "fsl,imx6q-iomuxc", "fsl,iomuxc";
 
 				ipu2 {
 					pinctrl_ipu2_1: ipu2grp-1 {
arch/arm/boot/dts/imx6qdl.dtsi +2 -2
index 8a86502..cb9129b 100644
@@ -622,7 +622,7 @@
 			};
 
 			src: src at 020d8000 {
-				compatible = "fsl,imx6q-src", "fsl,imx51-src";
+				compatible = "fsl,imx6q-src", "fsl,imx51-src", "fsl,src";
 				reg = <0x020d8000 0x4000>;
 				interrupts = <0 91 IRQ_TYPE_LEVEL_HIGH>,
 					     <0 96 IRQ_TYPE_LEVEL_HIGH>;
@@ -630,7 +630,7 @@
 			};
 
 			gpc: gpc at 020dc000 {
-				compatible = "fsl,imx6q-gpc";
+				compatible = "fsl,imx6q-gpc", "fsl,gpc";
 				reg = <0x020dc000 0x4000>;
 				interrupts = <0 89 IRQ_TYPE_LEVEL_HIGH>,
 					     <0 90 IRQ_TYPE_LEVEL_HIGH>;

arch/arm/boot/dts/imx6qdl.dtsi line 843

Quoted 5 lines
arch/arm/boot/dts/imx6qdl.dtsi +1 -1
@@ -840,7 +840,7 @@
 			};
 
 			mmdc0: mmdc at 021b0000 { /* MMDC0 */
-				compatible = "fsl,imx6q-mmdc";
+				compatible = "fsl,imx6q-mmdc", "fsl,mmdc";

This is not nice. Here you introduce a fsl,mmdc compatible claiming all mmdc are compatible to each other and in the driver code you have:

static const u32 imx6q_mmdc_io_dsm_offset[]
static const u32 imx6dl_mmdc_io_dsm_offset[]

which proves they are *not* compatible.

You do this just to share a

imx6_pm_get_base(&pm_info->mmdc_base, "fsl,mmdc");

across the different i.MX6 SoCs.

You can sanitize this by introducing a SoC struct which you populate differently for the SoCs

static pm_soc_data imx6q_data {
	.mmdc_compat = "fsl,imx6q-mmdc",
};

And by putting cpu_type, mmdc_io_num and others in this struct you can also remove the if(cpu_is_x()) else if (cpu_is_y()) else...

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

PATCH v4 2/6 ARM: imx: add suspend in ocram support on i.mx6q

In reply to Anson Huang
Quoted 2 lines · Anson Huang

#ifdef CONFIG_PM
+void imx6_suspend(void);

So, imx6_suspend() takes no arguments.

Quoted 1 line

+static int (*imx6_suspend_in_ocram_fn)(void __iomem *ocram_vbase);

Oh, it takes one argument.

arch/arm/mach-imx/pm-imx6q.c int imx6q_set_lpm(enum mxc_cpu_pwr_mode mode) · line 250

Quoted 6 lines
arch/arm/mach-imx/pm-imx6q.c +6 -0
+		/*
+		 * call low level suspend function in ocram,
+		 * as we need to float DDR IO.
+		 */
+		local_flush_tlb_all();
+		imx6_suspend_in_ocram_fn(suspend_ocram_base);

Yes, definitely takes one argument...

arch/arm/mach-imx/pm-imx6q.c void __init imx6q_pm_set_ccm_base(void __iomem *base) · line 434

Quoted 4 lines
arch/arm/mach-imx/pm-imx6q.c +4 -0
+	imx6_suspend_in_ocram_fn = (void *)fncpy(
+		suspend_ocram_base + sizeof(*pm_info),
+		&imx6_suspend,
+		MX6Q_SUSPEND_OCRAM_SIZE - sizeof(*pm_info));

This cast here is needed to work around the above confusion.

arch/arm/mach-imx/suspend-imx6.S line 93

Quoted 5 lines
arch/arm/mach-imx/suspend-imx6.S new file +5 -0
+ENTRY(imx6_suspend)
+	ldr	r1, [r0, #PM_INFO_PBASE_OFFSET]
+	ldr	r2, [r0, #PM_INFO_RESUME_ADDR_OFFSET]
+	ldr	r3, [r0, #PM_INFO_CPU_TYPE_OFFSET]
+	ldr	r4, [r0, #PM_INFO_PM_INFO_SIZE_OFFSET]

Yes, definitely takes one argument.

If you fix the prototype for imx6_suspend, you don't need to cast the result of fncpy(). Casts should always be avoided where possible.

Signature · 3 lines
FTTC broadband for 0.8mile line: 5.8Mbps down 500kbps up.  Estimation
in database were 13.1 to 19Mbit for a good line, about 7.5+ for a bad.
Estimate before purchase was "up to 13.2Mbit".
#3 lore raw

PATCH v4 2/6 ARM: imx: add suspend in ocram support on i.mx6q

Quoted 9 lines · Russell King - ARM Linux
Quoted 2 lines · Anson Huang

#ifdef CONFIG_PM
+void imx6_suspend(void);

So, imx6_suspend() takes no arguments.

Quoted 1 line

+static int (*imx6_suspend_in_ocram_fn)(void __iomem *ocram_vbase);

Oh, it takes one argument.

Great catch.

Anson,

The return type of imx6_suspend() and imx6_suspend_in_ocram_fn should be aligned too.

Shawn

Quoted 32 lines

arch/arm/mach-imx/pm-imx6q.c int imx6q_set_lpm(enum mxc_cpu_pwr_mode mode) · line 250

Quoted 7 lines
arch/arm/mach-imx/pm-imx6q.c +6 -0
+		/*
+		 * call low level suspend function in ocram,
+		 * as we need to float DDR IO.
+		 */
+		local_flush_tlb_all();
+		imx6_suspend_in_ocram_fn(suspend_ocram_base);

Yes, definitely takes one argument...

arch/arm/mach-imx/pm-imx6q.c void __init imx6q_pm_set_ccm_base(void __iomem *base) · line 434

Quoted 4 lines
arch/arm/mach-imx/pm-imx6q.c +4 -0
+	imx6_suspend_in_ocram_fn = (void *)fncpy(
+		suspend_ocram_base + sizeof(*pm_info),
+		&imx6_suspend,
+		MX6Q_SUSPEND_OCRAM_SIZE - sizeof(*pm_info));

This cast here is needed to work around the above confusion.

arch/arm/mach-imx/suspend-imx6.S line 93

Quoted 5 lines
arch/arm/mach-imx/suspend-imx6.S new file +5 -0
+ENTRY(imx6_suspend)
+	ldr	r1, [r0, #PM_INFO_PBASE_OFFSET]
+	ldr	r2, [r0, #PM_INFO_RESUME_ADDR_OFFSET]
+	ldr	r3, [r0, #PM_INFO_CPU_TYPE_OFFSET]
+	ldr	r4, [r0, #PM_INFO_PM_INFO_SIZE_OFFSET]

Yes, definitely takes one argument.

If you fix the prototype for imx6_suspend, you don't need to cast the result of fncpy(). Casts should always be avoided where possible.

Signature · 3 lines
FTTC broadband for 0.8mile line: 5.8Mbps down 500kbps up.  Estimation
in database were 13.1 to 19Mbit for a good line, about 7.5+ for a bad.
Estimate before purchase was "up to 13.2Mbit".
#9 lore raw

PATCH v4 1/6 ARM: dts: imx6q: add common compatible name for reused modules

In reply to Sascha Hauer
Quoted 24 lines · Sascha Hauer

Review line 843

Quoted 6 lines
(quoted diff) +1 -1
@@ -840,7 +840,7 @@
 			};
 
 			mmdc0: mmdc at 021b0000 { /* MMDC0 */
-				compatible = "fsl,imx6q-mmdc";
+				compatible = "fsl,imx6q-mmdc", "fsl,mmdc";

This is not nice. Here you introduce a fsl,mmdc compatible claiming all mmdc are compatible to each other and in the driver code you have:

static const u32 imx6q_mmdc_io_dsm_offset[]
static const u32 imx6dl_mmdc_io_dsm_offset[]

which proves they are *not* compatible.

You do this just to share a

imx6_pm_get_base(&pm_info->mmdc_base, "fsl,mmdc");

across the different i.MX6 SoCs.

You can sanitize this by introducing a SoC struct which you populate differently for the SoCs

Quoted 6 lines
static pm_soc_data imx6q_data {
	.mmdc_compat = "fsl,imx6q-mmdc",
};

And by putting cpu_type, mmdc_io_num and others in this struct you can also remove the if(cpu_is_x()) else if (cpu_is_y()) else...

Good point.

Anson, the change below is a demonstration of Sascha's suggestion. Sascha, correct me if I misunderstood your comment.

Shawn

---8<-----------

arch/arm/mach-imx/common.h +6 -2
index 7087d1a..4dd932a 100644
@@ -146,13 +146,17 @@ void imx_cpu_die(unsigned int cpu);
 int imx_cpu_kill(unsigned int cpu);
 
 #ifdef CONFIG_PM
-void imx6_suspend(void);
+void imx6_suspend(void __iomem *ocram_vbase);
 void imx6q_pm_init(void);
+void imx6dl_pm_init(void);
+void imx6sl_pm_init(void);
 void imx6q_pm_set_ccm_base(void __iomem *base);
 void imx5_pm_init(void);
 #else
-static inline void imx6_suspend(void) {}
+static inline void imx6_suspend(void __iomem *ocram_vbase) {}
 static inline void imx6q_pm_init(void) {}
+static inline void imx6dl_pm_init(void) {}
+static inline void imx6sl_pm_init(void) {}
 static inline void imx6q_pm_set_ccm_base(void __iomem *base) {}
 static inline void imx5_pm_init(void) {}
 #endif
arch/arm/mach-imx/mach-imx6q.c +1 -1
index e51e3da..3f7b4e3 100644
@@ -212,7 +212,7 @@ static void __init imx6q_init_machine(void)
 	of_platform_populate(NULL, of_default_bus_match_table, NULL, parent);
 
 	imx_anatop_init();
-	imx6q_pm_init();
+	cpu_is_imx6dl() ?  imx6dl_pm_init() : imx6q_pm_init();
 	imx6q_1588_init();
 }
 
arch/arm/mach-imx/mach-imx6sl.c +1 -2
index a26fdb2..ad32338 100644
@@ -58,8 +58,7 @@ static void __init imx6sl_init_machine(void)
 
 	imx6sl_fec_init();
 	imx_anatop_init();
-	/* Reuse imx6q pm code */
-	imx6q_pm_init();
+	imx6sl_pm_init();
 }
 
 static void __init imx6sl_init_irq(void)
arch/arm/mach-imx/pm-imx6q.c +84 -54

210 lines not on this page · raw message

maintainer
#10 lore raw

PATCH v4 1/6 ARM: dts: imx6q: add common compatible name for reused modules

Quoted 29 lines · Shawn Guo
Quoted 28 lines · Sascha Hauer

Review line 843

Quoted 6 lines
(quoted diff) +1 -1
@@ -840,7 +840,7 @@
 			};
 
 			mmdc0: mmdc at 021b0000 { /* MMDC0 */
-				compatible = "fsl,imx6q-mmdc";
+				compatible = "fsl,imx6q-mmdc", "fsl,mmdc";

This is not nice. Here you introduce a fsl,mmdc compatible claiming all mmdc are compatible to each other and in the driver code you have:

static const u32 imx6q_mmdc_io_dsm_offset[]
static const u32 imx6dl_mmdc_io_dsm_offset[]

which proves they are *not* compatible.

You do this just to share a

imx6_pm_get_base(&pm_info->mmdc_base, "fsl,mmdc");

across the different i.MX6 SoCs.

You can sanitize this by introducing a SoC struct which you populate differently for the SoCs

static pm_soc_data imx6q_data {
	.mmdc_compat = "fsl,imx6q-mmdc",
};
Quoted 7 lines
Quoted 2 lines

And by putting cpu_type, mmdc_io_num and others in this struct you can also remove the if(cpu_is_x()) else if (cpu_is_y()) else...

Good point.

Anson, the change below is a demonstration of Sascha's suggestion. Sascha, correct me if I misunderstood your comment.

Looks good. That's exactly what I meant. Maybe the cpu_type field can even be removed the way you did it.

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

PATCH v4 1/6 ARM: dts: imx6q: add common compatible name for reused modules

Quoted 33 lines · Sascha Hauer
Quoted 32 lines · Shawn Guo
Quoted 30 lines · Sascha Hauer

Review line 843

Quoted 6 lines
(quoted diff) +1 -1
@@ -840,7 +840,7 @@
 			};
 
 			mmdc0: mmdc at 021b0000 { /* MMDC0 */
-				compatible = "fsl,imx6q-mmdc";
+				compatible = "fsl,imx6q-mmdc", "fsl,mmdc";

This is not nice. Here you introduce a fsl,mmdc compatible claiming all mmdc are compatible to each other and in the driver code you have:

static const u32 imx6q_mmdc_io_dsm_offset[]
static const u32 imx6dl_mmdc_io_dsm_offset[]

which proves they are *not* compatible.

You do this just to share a

imx6_pm_get_base(&pm_info->mmdc_base, "fsl,mmdc");

across the different i.MX6 SoCs.

You can sanitize this by introducing a SoC struct which you populate differently for the SoCs

static pm_soc_data imx6q_data {
	.mmdc_compat = "fsl,imx6q-mmdc",
};

And by putting cpu_type, mmdc_io_num and others in this struct you can also remove the if(cpu_is_x()) else if (cpu_is_y()) else...

Quoted 7 lines
Quoted 4 lines

Good point.

Anson, the change below is a demonstration of Sascha's suggestion. Sascha, correct me if I misunderstood your comment.

Looks good. That's exactly what I meant. Maybe the cpu_type field can even be removed the way you did it.

Since the assembly function imx6_suspend() needs to check the cpu_type, we have to keep it in imx6_cpu_pm_info. So I assume you're suggesting we remove the field from imx6_pm_socdata and determine the cpu_type by comparing socdata pointer with particular imx6_pm_socdata like below?

	if (socdata == &imx6q_pm_data)
		pm_info->cpu_type = MXC_CPU_IMX6Q;
	else if (socdata == &imx6dl_pm_data)
		pm_info->cpu_type = MXC_CPU_IMX6DL;
	else if (socdata == &imx6sl_pm_data)
		pm_info->cpu_type = MXC_CPU_IMX6SL;

Looking at these if-clauses, I do not think we win too much from doing thing in this way.

Shawn

#13 lore raw

PATCH v4 1/6 ARM: dts: imx6q: add common compatible name for reused modules

In reply to Shawn Guo
Quoted 2 lines · Shawn Guo

Anson, the change below is a demonstration of Sascha's suggestion. Sascha, correct me if I misunderstood your comment.

<snip>

Quoted 93 lines
arch/arm/mach-imx/pm-imx6q.c +56 -26
@@ -88,36 +88,66 @@ struct imx6_pm_base {
 	void __iomem *vbase;
 };
 
-static const u32 imx6q_mmdc_io_dsm_offset[] __initconst = {
-	0x5ac, 0x5b4, 0x528, 0x520, /* DQM0 ~ DQM3 */
-	0x514, 0x510, 0x5bc, 0x5c4, /* DQM4 ~ DQM7 */
-	0x56c, 0x578, 0x588, 0x594, /* CAS, RAS, SDCLK_0, SDCLK_1 */
-	0x5a8, 0x5b0, 0x524, 0x51c, /* SDQS0 ~ SDQS3 */
-	0x518, 0x50c, 0x5b8, 0x5c0, /* SDQS4 ~ SDQS7 */
-	0x784, 0x788, 0x794, 0x79c, /* GPR_B0DS ~ GPR_B3DS */
-	0x7a0, 0x7a4, 0x7a8, 0x748, /* GPR_B4DS ~ GPR_B7DS */
-	0x59c, 0x5a0, 0x750, 0x774, /* SODT0, SODT1, DDRMODE_CTL, DDRMODE */
-	0x74c			    /* GPR_ADDS */
+struct imx6_pm_socdata {
+	u32 cpu_type;
+	const char *mmdc_compat;
+	const char *src_compat;
+	const char *iomuxc_compat;
+	const char *gpc_compat;
+	const u32 mmdc_io_offset[MX6_MAX_MMDC_IO_NUM];
+};
+
+static const struct imx6_pm_socdata imx6q_pm_data __initconst = {
+	.cpu_type = MXC_CPU_IMX6Q,
+	.mmdc_compat = "fsl,imx6q-mmdc",
+	.src_compat = "fsl,imx6q-src",
+	.iomuxc_compat = "fsl,imx6q-iomuxc",
+	.gpc_compat = "fsl,imx6q-gpc",
+	.mmdc_io_offset = {
+		0x5ac, 0x5b4, 0x528, 0x520, /* DQM0 ~ DQM3 */
+		0x514, 0x510, 0x5bc, 0x5c4, /* DQM4 ~ DQM7 */
+		0x56c, 0x578, 0x588, 0x594, /* CAS, RAS, SDCLK_0, SDCLK_1 */
+		0x5a8, 0x5b0, 0x524, 0x51c, /* SDQS0 ~ SDQS3 */
+		0x518, 0x50c, 0x5b8, 0x5c0, /* SDQS4 ~ SDQS7 */
+		0x784, 0x788, 0x794, 0x79c, /* GPR_B0DS ~ GPR_B3DS */
+		0x7a0, 0x7a4, 0x7a8, 0x748, /* GPR_B4DS ~ GPR_B7DS */
+		0x59c, 0x5a0, 0x750, 0x774, /* SODT0, SODT1, DDRMODE_CTL, DDRMODE */
+		0x74c,			    /* GPR_ADDS */
+	},
 };
 
-static const u32 imx6dl_mmdc_io_dsm_offset[] __initconst = {
-	0x470, 0x474, 0x478, 0x47c, /* DQM0 ~ DQM3 */
-	0x480, 0x484, 0x488, 0x48c, /* DQM4 ~ DQM7 */
-	0x464, 0x490, 0x4ac, 0x4b0, /* CAS, RAS, SDCLK_0, SDCLK_1 */
-	0x4bc, 0x4c0, 0x4c4, 0x4c8, /* DRAM_SDQS0 ~ DRAM_SDQS3 */
-	0x4cc, 0x4d0, 0x4d4, 0x4d8, /* DRAM_SDQS4 ~ DRAM_SDQS7 */
-	0x764, 0x770, 0x778, 0x77c, /* GPR_B0DS ~ GPR_B3DS */
-	0x780, 0x784, 0x78c, 0x748, /* GPR_B4DS ~ GPR_B7DS */
-	0x4b4, 0x4b8, 0x750, 0x760, /* SODT0, SODT1, DDRMODE_CTL, DDRMODE */
-	0x74c			    /* GPR_ADDS */
+static const struct imx6_pm_socdata imx6dl_pm_data __initconst = {
+	.cpu_type = MXC_CPU_IMX6DL,
+	.mmdc_compat = "fsl,imx6dl-mmdc",
+	.src_compat = "fsl,imx6dl-src",
+	.iomuxc_compat = "fsl,imx6dl-iomuxc",
+	.gpc_compat = "fsl,imx6dl-gpc",
+	.mmdc_io_offset = {
+		0x470, 0x474, 0x478, 0x47c, /* DQM0 ~ DQM3 */
+		0x480, 0x484, 0x488, 0x48c, /* DQM4 ~ DQM7 */
+		0x464, 0x490, 0x4ac, 0x4b0, /* CAS, RAS, SDCLK_0, SDCLK_1 */
+		0x4bc, 0x4c0, 0x4c4, 0x4c8, /* DRAM_SDQS0 ~ DRAM_SDQS3 */
+		0x4cc, 0x4d0, 0x4d4, 0x4d8, /* DRAM_SDQS4 ~ DRAM_SDQS7 */
+		0x764, 0x770, 0x778, 0x77c, /* GPR_B0DS ~ GPR_B3DS */
+		0x780, 0x784, 0x78c, 0x748, /* GPR_B4DS ~ GPR_B7DS */
+		0x4b4, 0x4b8, 0x750, 0x760, /* SODT0, SODT1, DDRMODE_CTL, DDRMODE */
+		0x74c,			    /* GPR_ADDS */
+	},
 };
 
-static const u32 imx6sl_mmdc_io_dsm_offset[] __initconst = {
-	0x30c, 0x310, 0x314, 0x318, /* DQM0 ~ DQM3 */
-	0x5c4, 0x5cc, 0x5d4, 0x5d8, /* GPR_B0DS ~ GPR_B3DS */
-	0x300, 0x31c, 0x338, 0x5ac, /* CAS, RAS, SDCLK_0, GPR_ADDS */
-	0x33c, 0x340, 0x5b0, 0x5c0, /* SODT0, SODT1, DDRMODE_CTL, DDRMODE */
-	0x330, 0x334, 0x320,	    /* SDCKE0, SDCKE1, RESET */
+static const struct imx6_pm_socdata imx6sl_pm_data __initconst = {
+	.cpu_type = MXC_CPU_IMX6SL,
+	.mmdc_compat = "fsl,imx6sl-mmdc",
+	.src_compat = "fsl,imx6sl-src",
+	.iomuxc_compat = "fsl,imx6sl-iomuxc",
+	.gpc_compat = "fsl,imx6sl-gpc",
+	.mmdc_io_offset = {
+		0x30c, 0x310, 0x314, 0x318, /* DQM0 ~ DQM3 */
+		0x5c4, 0x5cc, 0x5d4, 0x5d8, /* GPR_B0DS ~ GPR_B3DS */
+		0x300, 0x31c, 0x338, 0x5ac, /* CAS, RAS, SDCLK_0, GPR_ADDS */
+		0x33c, 0x340, 0x5b0, 0x5c0, /* SODT0, SODT1, DDRMODE_CTL, DDRMODE */
+		0x330, 0x334, 0x320,	    /* SDCKE0, SDCKE1, RESET */
+	},
 };
 
 /*

<snip>

arch/arm/mach-imx/pm-imx6q.c static int __init imx6q_ocram_suspend_init(void) · line 463

Quoted 2 lines
arch/arm/mach-imx/pm-imx6q.c +2 -0
+	pm_info->cpu_type = socdata->cpu_type;
+	pm_info->mmdc_io_num = ARRAY_SIZE(socdata->mmdc_io_offset);

I just recall this does not work now. The ARRAY_SIZE() will just be MX6_MAX_MMDC_IO_NUM for all 3 SoCs. We need to add a filed mmdc_io_num into imx6_pm_socdata and assign a correct number for each SoC.

Shawn

Quoted 1 line
arch/arm/mach-imx/pm-imx6q.c +1 -0
+	mmdc_offset_array = socdata->mmdc_io_offset;
maintainer
#12 lore raw

PATCH v4 1/6 ARM: dts: imx6q: add common compatible name for reused modules

In reply to Shawn Guo
Quoted 13 lines · Shawn Guo

Since the assembly function imx6_suspend() needs to check the cpu_type, we have to keep it in imx6_cpu_pm_info. So I assume you're suggesting we remove the field from imx6_pm_socdata and determine the cpu_type by comparing socdata pointer with particular imx6_pm_socdata like below?

	if (socdata == &imx6q_pm_data)
		pm_info->cpu_type = MXC_CPU_IMX6Q;
	else if (socdata == &imx6dl_pm_data)
		pm_info->cpu_type = MXC_CPU_IMX6DL;
	else if (socdata == &imx6sl_pm_data)
		pm_info->cpu_type = MXC_CPU_IMX6SL;
Quoted 2 lines

Looking at these if-clauses, I do not think we win too much from doing thing in this way.

Indeed not. I thought the cpu_type field would be unused now, but this is not the case.

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 |