Skip to contentSkip to conversation

Add i.MX6 SoCs mmdc ipg clocks management

PATCH Applied Anson Huang 4 participants 20 messages Aug 31, 2018 – Nov 5, 2018

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

cover Add i.MX6 SoCs mmdc ipg clocks management

i.MX6 SoCs have MMDC driver which will access MMDC registers, and the register access need to have MMDC IPG clocks enabled, current MMDC driver does NOT handle the MMDC IPG clocks at all, most of the i.MX6 SoCs clock tree have MMDC0 IPG clock registered and have flag CLK_IS_CRITICAL set, but some i.MX6 SoCs does NOT register the MMDC IPG clock at all, it depends on default HW status which is NOT reliable.

To make it more formal, this patch set add all available MMDC IPG clocks into clock tree, and add optional clocks enable operation in MMDC driver to make sure IPG clock is enabled before accessing registers, and passing MMDC IPG clock info from device tree MMDC node.

In order to NOT break old device tree, this patch set does NOT remove the CLK_IS_CRITIAL flag for MMDC0 IPG clock.

Anson Huang (7):
ARM: imx: add mmdc ipg clock operation for mmdc
clk: imx6ul: add mmdc1 ipg clock
clk: imx6sx: add mmdc1 ipg clock
clk: imx6sll: add mmdc1 ipg clock
clk: imx6sl: add mmdc ipg clocks
clk: imx6q: add mmdc0 ipg clock
ARM: dts: imx6: add mmdc ipg clock

 arch/arm/boot/dts/imx6qdl.dtsi            |  1 +
 arch/arm/boot/dts/imx6sl.dtsi             |  1 +
 arch/arm/boot/dts/imx6sll.dtsi            |  1 +
 arch/arm/boot/dts/imx6sx.dtsi             |  1 +
 arch/arm/boot/dts/imx6ul.dtsi             |  1 +
 arch/arm/mach-imx/mmdc.c                  | 14 ++++++++++++++
 drivers/clk/imx/clk-imx6q.c               |  1 +
 drivers/clk/imx/clk-imx6sl.c              |  2 ++
 drivers/clk/imx/clk-imx6sll.c             |  1 +
 drivers/clk/imx/clk-imx6sx.c              |  1 +
 drivers/clk/imx/clk-imx6ul.c              |  1 +
 include/dt-bindings/clock/imx6qdl-clock.h |  3 ++-
 include/dt-bindings/clock/imx6sl-clock.h  |  4 +++-
 include/dt-bindings/clock/imx6sll-clock.h |  3 ++-
 include/dt-bindings/clock/imx6sx-clock.h  |  3 ++-
 include/dt-bindings/clock/imx6ul-clock.h  |  3 ++-
 16 files changed, 36 insertions(+), 5 deletions(-)
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/7 ARM: imx: add mmdc ipg clock operation for mmdc

i.MX6 SoCs have MMDC ipg clock for registers access, to make sure MMDC registers access successfully, add optional clock enable for MMDC driver.

---
 arch/arm/mach-imx/mmdc.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
arch/arm/mach-imx/mmdc.c +14 -0
index 04b3bf7..e49e068 100644
@@ -11,6 +11,7 @@
  * http://www.gnu.org/copyleft/gpl.html
  */
 
+#include <linux/clk.h>
 #include <linux/hrtimer.h>
 #include <linux/init.h>
 #include <linux/interrupt.h>
@@ -546,7 +547,20 @@ static int imx_mmdc_probe(struct platform_device *pdev)
 {
 	struct device_node *np = pdev->dev.of_node;
 	void __iomem *mmdc_base, *reg;
+	struct clk *mmdc_ipg_clk;
 	u32 val;
+	int err;
+
+	/* the ipg clock is optional */
+	mmdc_ipg_clk = devm_clk_get(&pdev->dev, NULL);
+	if (IS_ERR(mmdc_ipg_clk))
+		mmdc_ipg_clk = NULL;
+
+	err = clk_prepare_enable(mmdc_ipg_clk);
+	if (err) {
+		dev_err(&pdev->dev, "Unable to enable mmdc ipg clock.\n");
+		return err;
+	}
 
 	mmdc_base = of_iomap(np, 0);
 	WARN_ON(!mmdc_base);
Signature · 1 line
2.7.4
Applied
#2 lore raw

Re: [PATCH 1/7] ARM: imx: add mmdc ipg clock operation for mmdc

Quoted 5 lines · Anson Huang

i.MX6 SoCs have MMDC ipg clock for registers access, to make sure MMDC registers access successfully, add optional clock enable for MMDC driver.

Applied this one, thanks.

#3 lore raw

PATCH 2/7 clk: imx6ul: add mmdc1 ipg clock

In reply to Anson Huang

i.MX6UL has MMDC1 ipg clock in CCM CCGR, add it into clock tree for clock management.

---
 drivers/clk/imx/clk-imx6ul.c             | 1 +
 include/dt-bindings/clock/imx6ul-clock.h | 3 ++-
 2 files changed, 3 insertions(+), 1 deletion(-)
drivers/clk/imx/clk-imx6ul.c +1 -0
index 361b43f..fd60d15 100644
@@ -408,6 +408,7 @@ static void __init imx6ul_clocks_init(struct device_node *ccm_node)
 	clks[IMX6UL_CLK_WDOG1]		= imx_clk_gate2("wdog1",	"ipg",		base + 0x74,	16);
 	clks[IMX6UL_CLK_MMDC_P0_FAST]	= imx_clk_gate_flags("mmdc_p0_fast", "mmdc_podf", base + 0x74,	20, CLK_IS_CRITICAL);
 	clks[IMX6UL_CLK_MMDC_P0_IPG]	= imx_clk_gate2_flags("mmdc_p0_ipg",	"ipg",		base + 0x74,	24, CLK_IS_CRITICAL);
+	clks[IMX6UL_CLK_MMDC_P1_IPG]	= imx_clk_gate2("mmdc_p1_ipg",	"ipg",		base + 0x74,	26);
 	clks[IMX6UL_CLK_AXI]		= imx_clk_gate_flags("axi",	"axi_podf",	base + 0x74,	28, CLK_IS_CRITICAL);
 
 	/* CCGR4 */
include/dt-bindings/clock/imx6ul-clock.h +2 -1
index f8e0476..f718aac 100644
@@ -259,7 +259,8 @@
 #define IMX6UL_CLK_GPIO3		246
 #define IMX6UL_CLK_GPIO4		247
 #define IMX6UL_CLK_GPIO5		248
+#define IMX6UL_CLK_MMDC_P1_IPG		249
 
-#define IMX6UL_CLK_END			249
+#define IMX6UL_CLK_END			250
 
 #endif /* __DT_BINDINGS_CLOCK_IMX6UL_H */
Signature · 1 line
2.7.4
maintainer
#4 lore raw

PATCH 2/7 clk: imx6ul: add mmdc1 ipg clock

Quoted 9 lines · Anson Huang

i.MX6UL has MMDC1 ipg clock in CCM CCGR, add it into clock tree for clock management.

---
 drivers/clk/imx/clk-imx6ul.c             | 1 +
 include/dt-bindings/clock/imx6ul-clock.h | 3 ++-
 2 files changed, 3 insertions(+), 1 deletion(-)
#6 lore raw

PATCH 3/7 clk: imx6sx: add mmdc1 ipg clock

In reply to Anson Huang

i.MX6SX has MMDC1 ipg clock in CCM CCGR, add it into clock tree for clock management.

---
 drivers/clk/imx/clk-imx6sx.c             | 1 +
 include/dt-bindings/clock/imx6sx-clock.h | 3 ++-
 2 files changed, 3 insertions(+), 1 deletion(-)
drivers/clk/imx/clk-imx6sx.c +1 -0
index d9f2890..18527a3 100644
@@ -431,6 +431,7 @@ static void __init imx6sx_clocks_init(struct device_node *ccm_node)
 	clks[IMX6SX_CLK_MLB]          = imx_clk_gate2("mlb",           "ahb",               base + 0x74, 18);
 	clks[IMX6SX_CLK_MMDC_P0_FAST] = imx_clk_gate2_flags("mmdc_p0_fast", "mmdc_podf", base + 0x74, 20, CLK_IS_CRITICAL);
 	clks[IMX6SX_CLK_MMDC_P0_IPG]  = imx_clk_gate2_flags("mmdc_p0_ipg", "ipg", base + 0x74, 24, CLK_IS_CRITICAL);
+	clks[IMX6SX_CLK_MMDC_P1_IPG]  = imx_clk_gate2("mmdc_p1_ipg", "ipg", base + 0x74, 26);
 	clks[IMX6SX_CLK_OCRAM]        = imx_clk_gate2_flags("ocram", "ocram_podf", base + 0x74, 28, CLK_IS_CRITICAL);
 
 	/* CCGR4 */
include/dt-bindings/clock/imx6sx-clock.h +2 -1
index cd2d6c5..fb420c7 100644
@@ -279,6 +279,7 @@
 #define IMX6SX_CLK_LVDS2_OUT		266
 #define IMX6SX_CLK_LVDS2_IN		267
 #define IMX6SX_CLK_ANACLK2		268
-#define IMX6SX_CLK_CLK_END		269
+#define IMX6SX_CLK_MMDC_P1_IPG		269
+#define IMX6SX_CLK_CLK_END		270
 
 #endif /* __DT_BINDINGS_CLOCK_IMX6SX_H */
Signature · 1 line
2.7.4
maintainer
#7 lore raw

PATCH 3/7 clk: imx6sx: add mmdc1 ipg clock

Quoted 9 lines · Anson Huang

i.MX6SX has MMDC1 ipg clock in CCM CCGR, add it into clock tree for clock management.

---
 drivers/clk/imx/clk-imx6sx.c             | 1 +
 include/dt-bindings/clock/imx6sx-clock.h | 3 ++-
 2 files changed, 3 insertions(+), 1 deletion(-)
#9 lore raw

PATCH 4/7 clk: imx6sll: add mmdc1 ipg clock

In reply to Anson Huang

i.MX6SLL has MMDC1 ipg clock in CCM CCGR, add it into clock tree for clock management.

---
 drivers/clk/imx/clk-imx6sll.c             | 1 +
 include/dt-bindings/clock/imx6sll-clock.h | 3 ++-
 2 files changed, 3 insertions(+), 1 deletion(-)
drivers/clk/imx/clk-imx6sll.c +1 -0
index 52379ee..3bd2044 100644
@@ -293,6 +293,7 @@ static void __init imx6sll_clocks_init(struct device_node *ccm_node)
 	clks[IMX6SLL_CLK_WDOG1]		= imx_clk_gate2("wdog1",	"ipg",		base + 0x74, 16);
 	clks[IMX6SLL_CLK_MMDC_P0_FAST]	= imx_clk_gate_flags("mmdc_p0_fast", "mmdc_podf",  base + 0x74,	20, CLK_IS_CRITICAL);
 	clks[IMX6SLL_CLK_MMDC_P0_IPG]	= imx_clk_gate2_flags("mmdc_p0_ipg", "ipg",	   base + 0x74,	24, CLK_IS_CRITICAL);
+	clks[IMX6SLL_CLK_MMDC_P1_IPG]	= imx_clk_gate2("mmdc_p1_ipg", "ipg",	   base + 0x74,	26);
 	clks[IMX6SLL_CLK_OCRAM]		= imx_clk_gate_flags("ocram","ahb",		   base + 0x74,	28, CLK_IS_CRITICAL);
 
 	/* CCGR4 */
include/dt-bindings/clock/imx6sll-clock.h +2 -1
index 1036475..f446710 100644
@@ -203,7 +203,8 @@
 #define IMX6SLL_CLK_GPIO4               176
 #define IMX6SLL_CLK_GPIO5               177
 #define IMX6SLL_CLK_GPIO6               178
+#define IMX6SLL_CLK_MMDC_P1_IPG		179
 
-#define IMX6SLL_CLK_END			179
+#define IMX6SLL_CLK_END			180
 
 #endif /* __DT_BINDINGS_CLOCK_IMX6SLL_H */
Signature · 1 line
2.7.4
maintainer
#10 lore raw

PATCH 4/7 clk: imx6sll: add mmdc1 ipg clock

Quoted 9 lines · Anson Huang

i.MX6SLL has MMDC1 ipg clock in CCM CCGR, add it into clock tree for clock management.

---
 drivers/clk/imx/clk-imx6sll.c             | 1 +
 include/dt-bindings/clock/imx6sll-clock.h | 3 ++-
 2 files changed, 3 insertions(+), 1 deletion(-)
#12 lore raw

PATCH 5/7 clk: imx6sl: add mmdc ipg clocks

In reply to Anson Huang

i.MX6SL has MMDC0 and MMDC1 ipg clock in CCM CCGR, add them into clock tree for clock management.

---
 drivers/clk/imx/clk-imx6sl.c             | 2 ++
 include/dt-bindings/clock/imx6sl-clock.h | 4 +++-
 2 files changed, 5 insertions(+), 1 deletion(-)
drivers/clk/imx/clk-imx6sl.c +2 -0
index eb6bcbf..6fcfbbd 100644
@@ -386,6 +386,8 @@ static void __init imx6sl_clocks_init(struct device_node *ccm_node)
 	clks[IMX6SL_CLK_LCDIF_AXI]    = imx_clk_gate2("lcdif_axi",    "lcdif_axi_podf",    base + 0x74, 6);
 	clks[IMX6SL_CLK_LCDIF_PIX]    = imx_clk_gate2("lcdif_pix",    "lcdif_pix_podf",    base + 0x74, 8);
 	clks[IMX6SL_CLK_EPDC_PIX]     = imx_clk_gate2("epdc_pix",     "epdc_pix_podf",     base + 0x74, 10);
+	clks[IMX6SL_CLK_MMDC_P0_IPG]  = imx_clk_gate2_flags("mmdc_p0_ipg",  "ipg",         base + 0x74,	24, CLK_IS_CRITICAL);
+	clks[IMX6SL_CLK_MMDC_P1_IPG]  = imx_clk_gate2("mmdc_p1_ipg",  "ipg",	  	   base + 0x74,	26);
 	clks[IMX6SL_CLK_OCRAM]        = imx_clk_gate2("ocram",        "ocram_podf",        base + 0x74, 28);
 	clks[IMX6SL_CLK_PWM1]         = imx_clk_gate2("pwm1",         "perclk",            base + 0x78, 16);
 	clks[IMX6SL_CLK_PWM2]         = imx_clk_gate2("pwm2",         "perclk",            base + 0x78, 18);
include/dt-bindings/clock/imx6sl-clock.h +3 -1
index e14573e..cfbfc39 100644
@@ -175,6 +175,8 @@
 #define IMX6SL_CLK_SSI2_IPG		162
 #define IMX6SL_CLK_SSI3_IPG		163
 #define IMX6SL_CLK_SPDIF_GCLK		164
-#define IMX6SL_CLK_END			165
+#define IMX6SL_CLK_MMDC_P0_IPG		165
+#define IMX6SL_CLK_MMDC_P1_IPG		166
+#define IMX6SL_CLK_END			167
 
 #endif /* __DT_BINDINGS_CLOCK_IMX6SL_H */
Signature · 1 line
2.7.4
maintainer
#13 lore raw

PATCH 5/7 clk: imx6sl: add mmdc ipg clocks

Quoted 9 lines · Anson Huang

i.MX6SL has MMDC0 and MMDC1 ipg clock in CCM CCGR, add them into clock tree for clock management.

---
 drivers/clk/imx/clk-imx6sl.c             | 2 ++
 include/dt-bindings/clock/imx6sl-clock.h | 4 +++-
 2 files changed, 5 insertions(+), 1 deletion(-)
#15 lore raw

PATCH 6/7 clk: imx6q: add mmdc0 ipg clock

In reply to Anson Huang

i.MX6Q has MMDC0 ipg clock in CCM CCGR, add it into clock tree for clock management.

---
 drivers/clk/imx/clk-imx6q.c               | 1 +
 include/dt-bindings/clock/imx6qdl-clock.h | 3 ++-
 2 files changed, 3 insertions(+), 1 deletion(-)
drivers/clk/imx/clk-imx6q.c +1 -0
index 8c7c2fc..bbe0c60 100644
@@ -789,6 +789,7 @@ static void __init imx6q_clocks_init(struct device_node *ccm_node)
 		clk[IMX6QDL_CLK_MLB] = imx_clk_gate2("mlb",            "axi",               base + 0x74, 18);
 	clk[IMX6QDL_CLK_MMDC_CH0_AXI] = imx_clk_gate2_flags("mmdc_ch0_axi",  "mmdc_ch0_axi_podf", base + 0x74, 20, CLK_IS_CRITICAL);
 	clk[IMX6QDL_CLK_MMDC_CH1_AXI] = imx_clk_gate2("mmdc_ch1_axi",  "mmdc_ch1_axi_podf", base + 0x74, 22);
+	clk[IMX6QDL_CLK_MMDC_P0_IPG]  = imx_clk_gate2_flags("mmdc_p0_ipg",   "ipg",         base + 0x74, 24, CLK_IS_CRITICAL);
 	clk[IMX6QDL_CLK_OCRAM]        = imx_clk_gate2("ocram",         "ahb",               base + 0x74, 28);
 	clk[IMX6QDL_CLK_OPENVG_AXI]   = imx_clk_gate2("openvg_axi",    "axi",               base + 0x74, 30);
 	clk[IMX6QDL_CLK_PCIE_AXI]     = imx_clk_gate2("pcie_axi",      "pcie_axi_sel",      base + 0x78, 0);
include/dt-bindings/clock/imx6qdl-clock.h +2 -1
index 7ad171b..87b068f 100644
@@ -273,6 +273,7 @@
 #define IMX6QDL_CLK_MLB_PODF			260
 #define IMX6QDL_CLK_EPIT1			261
 #define IMX6QDL_CLK_EPIT2			262
-#define IMX6QDL_CLK_END				263
+#define IMX6QDL_CLK_MMDC_P0_IPG			263
+#define IMX6QDL_CLK_END				264
 
 #endif /* __DT_BINDINGS_CLOCK_IMX6QDL_H */
Signature · 1 line
2.7.4
maintainer
#16 lore raw

PATCH 6/7 clk: imx6q: add mmdc0 ipg clock

Quoted 9 lines · Anson Huang

i.MX6Q has MMDC0 ipg clock in CCM CCGR, add it into clock tree for clock management.

---
 drivers/clk/imx/clk-imx6q.c               | 1 +
 include/dt-bindings/clock/imx6qdl-clock.h | 3 ++-
 2 files changed, 3 insertions(+), 1 deletion(-)
#18 lore raw

PATCH 7/7 ARM: dts: imx6: add mmdc ipg clock

In reply to Anson Huang

i.MX6 SoCs has MMDC clock gates in CCM CCGR, add
clock property for MMDC driver's clock operation.

---
 arch/arm/boot/dts/imx6qdl.dtsi | 1 +
 arch/arm/boot/dts/imx6sl.dtsi  | 1 +
 arch/arm/boot/dts/imx6sll.dtsi | 1 +
 arch/arm/boot/dts/imx6sx.dtsi  | 1 +
 arch/arm/boot/dts/imx6ul.dtsi  | 1 +
 5 files changed, 5 insertions(+)
arch/arm/boot/dts/imx6qdl.dtsi +1 -0
index 61d2d26..5d33729 100644
@@ -1115,6 +1115,7 @@
 			mmdc0: mmdc at 21b0000 { /* MMDC0 */
 				compatible = "fsl,imx6q-mmdc";
 				reg = <0x021b0000 0x4000>;
+				clocks = <&clks IMX6QDL_CLK_MMDC_P0_IPG>;
 			};
 
 			mmdc1: mmdc at 21b4000 { /* MMDC1 */
arch/arm/boot/dts/imx6sl.dtsi +1 -0
index 7a4f5da..63a18e1 100644
@@ -921,6 +921,7 @@
 			mmdc: mmdc at 21b0000 {
 				compatible = "fsl,imx6sl-mmdc", "fsl,imx6q-mmdc";
 				reg = <0x021b0000 0x4000>;
+				clocks = <&clks IMX6SL_CLK_MMDC_P0_IPG>;
 			};
 
 			rngb: rngb at 21b4000 {
arch/arm/boot/dts/imx6sll.dtsi +1 -0
index ed9a980..e462f76 100644
@@ -770,6 +770,7 @@
 			mmdc: memory-controller at 21b0000 {
 				compatible = "fsl,imx6sll-mmdc", "fsl,imx6q-mmdc";
 				reg = <0x021b0000 0x4000>;
+				clocks = <&clks IMX6SLL_CLK_MMDC_P0_IPG>;
 			};
 
 			ocotp: ocotp-ctrl at 21bc000 {
arch/arm/boot/dts/imx6sx.dtsi +1 -0
index 844caa3..ba4ab79 100644
@@ -1002,6 +1002,7 @@
 			mmdc: mmdc at 21b0000 {
 				compatible = "fsl,imx6sx-mmdc", "fsl,imx6q-mmdc";
 				reg = <0x021b0000 0x4000>;
+				clocks = <&clks IMX6SX_CLK_MMDC_P0_IPG>;
 			};
 
 			fec2: ethernet at 21b4000 {
arch/arm/boot/dts/imx6ul.dtsi +1 -0
index 448d765..2019ad5 100644
@@ -916,6 +916,7 @@
 			mmdc: mmdc at 21b0000 {
 				compatible = "fsl,imx6ul-mmdc", "fsl,imx6q-mmdc";
 				reg = <0x021b0000 0x4000>;
+				clocks = <&clks IMX6UL_CLK_MMDC_P0_IPG>;
 			};
 
 			weim: weim at 21b8000 {
Signature · 1 line
2.7.4
Applied
#19 lore raw

Re: [PATCH 7/7] ARM: dts: imx6: add mmdc ipg clock

Quoted 4 lines · Anson Huang

i.MX6 SoCs has MMDC clock gates in CCM CCGR, add
clock property for MMDC driver's clock operation.

Applied, thanks.