Skip to contentSkip to conversation

ARM: OMAP4: Fix gpmc_fck clock

PATCH Superseded Florian Vaussard 2 participants 7 messages Feb 17, 2014 – Feb 19, 2014

Subsystems (3)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

cover ARM: OMAP4: Fix gpmc_fck clock

Hello,

Trying to get my SMSC9221 working on OMAP4 with DT, I faced a misconfigured gpmc_fck (dummy clock set to 0) resulting in serveral division-by-zero, misconfigured timings and driver lost in the La La Land.

To solve this, patch 1 removes gpmc_fck from the dummy clocks, and patch 2 adds the gpmc_fck DT node and reference it from the gpmc node.

Tested on DuoVero/Parlor (OMAP4430) with SMSC9221.

Regards,
Florian

---
Tero: I hopped to have figured out correctly the clock type and topology based on the TRM, but this is not the easiest part of the OMAP family :)

Florian Vaussard (2):
CLK: TI: OMAP4: Remove gpmc_fck from dummy clocks
ARM: DTS: OMAP4: Add gpmc_fck clock node

 arch/arm/boot/dts/omap4.dtsi           | 2 ++
 arch/arm/boot/dts/omap44xx-clocks.dtsi | 6 ++++++
 drivers/clk/ti/clk-44xx.c              | 1 -
 3 files changed, 8 insertions(+), 1 deletion(-)
Signature · 1 line
1.8.1.2
#1 lore raw

PATCH 1/2 CLK: TI: OMAP4: Remove gpmc_fck from dummy clocks

When arch/arm/mach-omap2/gpmc.c calls clk_get(..., "fck"), it will get a dummy clock and try to use it. As the rate is configured to zero, this will result in several divisions by zero, and misconfigured timings, with devices on the bus being lost in the La La Land.

It is better to remove gpmc_fck from the dummy clocks, so that gpmc.c can fail gracefully.

---
 drivers/clk/ti/clk-44xx.c | 1 -
 1 file changed, 1 deletion(-)
drivers/clk/ti/clk-44xx.c +0 -1
index ae00218..02517a8 100644
@@ -222,7 +222,6 @@ static struct ti_dt_clk omap44xx_clks[] = {
 	DT_CLK(NULL, "auxclk5_src_ck", "auxclk5_src_ck"),
 	DT_CLK(NULL, "auxclk5_ck", "auxclk5_ck"),
 	DT_CLK(NULL, "auxclkreq5_ck", "auxclkreq5_ck"),
-	DT_CLK("50000000.gpmc", "fck", "dummy_ck"),
 	DT_CLK("omap_i2c.1", "ick", "dummy_ck"),
 	DT_CLK("omap_i2c.2", "ick", "dummy_ck"),
 	DT_CLK("omap_i2c.3", "ick", "dummy_ck"),
Signature · 1 line
1.8.1.2
#2 lore raw

PATCH 2/2 ARM: DTS: OMAP4: Add gpmc_fck clock node

In reply to Florian Vaussard

Add the gpmc_fck clock, derived from l3_ick, and reference it from the GPMC node to get it correctly working.

---
 arch/arm/boot/dts/omap4.dtsi           | 2 ++
 arch/arm/boot/dts/omap44xx-clocks.dtsi | 6 ++++++
 2 files changed, 8 insertions(+)
arch/arm/boot/dts/omap4.dtsi +2 -0
index d3f8a6e..8a0cc71 100644
@@ -275,6 +275,8 @@
 			gpmc,num-waitpins = <4>;
 			ti,hwmods = "gpmc";
 			ti,no-idle-on-init;
+			clocks = <&gpmc_fck>;
+			clock-names = "fck";
 		};
 
 		uart1: serial at 4806a000 {
arch/arm/boot/dts/omap44xx-clocks.dtsi +6 -0
index c821ff5..ae2c441 100644
@@ -1036,6 +1036,12 @@
 		ti,index-power-of-two;
 	};
 
+	gpmc_fck: gpmc_fck {
+		#clock-cells = <0>;
+		compatible = "ti,clkdm-gate-clock";
+		clocks = <&l3_div_ck>;
+	};
+
 	gpio2_dbclk: gpio2_dbclk {
 		#clock-cells = <0>;
 		compatible = "ti,gate-clock";
Signature · 1 line
1.8.1.2
#3 lore raw

PATCH 2/2 ARM: DTS: OMAP4: Add gpmc_fck clock node

Quoted 27 lines · Florian Vaussard

Add the gpmc_fck clock, derived from l3_ick, and reference it from the GPMC node to get it correctly working.

---
  arch/arm/boot/dts/omap4.dtsi           | 2 ++
  arch/arm/boot/dts/omap44xx-clocks.dtsi | 6 ++++++
  2 files changed, 8 insertions(+)
arch/arm/boot/dts/omap4.dtsi +2 -0
index d3f8a6e..8a0cc71 100644
@@ -275,6 +275,8 @@
  			gpmc,num-waitpins = <4>;
  			ti,hwmods = "gpmc";
  			ti,no-idle-on-init;
+			clocks = <&gpmc_fck>;
+			clock-names = "fck";
  		};
 
  		uart1: serial at 4806a000 {
arch/arm/boot/dts/omap44xx-clocks.dtsi +0 -0
index c821ff5..ae2c441 100644

arch/arm/boot/dts/omap44xx-clocks.dtsi line 1044

Quoted 9 lines
arch/arm/boot/dts/omap44xx-clocks.dtsi +6 -0
@@ -1036,6 +1036,12 @@
  		ti,index-power-of-two;
  	};
 
+	gpmc_fck: gpmc_fck {
+		#clock-cells = <0>;
+		compatible = "ti,clkdm-gate-clock";
+		clocks = <&l3_div_ck>;
+	};
+

Why not implement a proper gate clock for CM_L3_2_GPMC_CLKCTRL? The approach you have taken looks good to me otherwise.

-Tero

Quoted 4 lines
arch/arm/boot/dts/omap44xx-clocks.dtsi +0 -0
  	gpio2_dbclk: gpio2_dbclk {
  		#clock-cells = <0>;
  		compatible = "ti,gate-clock";
#4 lore raw

PATCH 2/2 ARM: DTS: OMAP4: Add gpmc_fck clock node

Hi,

Quoted 32 lines · Tero Kristo
Quoted 31 lines · Florian Vaussard

Add the gpmc_fck clock, derived from l3_ick, and reference it from the GPMC node to get it correctly working.

---
  arch/arm/boot/dts/omap4.dtsi           | 2 ++
  arch/arm/boot/dts/omap44xx-clocks.dtsi | 6 ++++++
  2 files changed, 8 insertions(+)
arch/arm/boot/dts/omap4.dtsi +2 -0
index d3f8a6e..8a0cc71 100644
@@ -275,6 +275,8 @@
              gpmc,num-waitpins = <4>;
              ti,hwmods = "gpmc";
              ti,no-idle-on-init;
+            clocks = <&gpmc_fck>;
+            clock-names = "fck";
          };
 
          uart1: serial at 4806a000 {
arch/arm/boot/dts/omap44xx-clocks.dtsi +0 -0
index c821ff5..ae2c441 100644
@@ -1036,6 +1036,12 @@
          ti,index-power-of-two;
      };
 
Quoted 10 lines

arch/arm/boot/dts/omap44xx-clocks.dtsi line 1044

Quoted 6 lines
arch/arm/boot/dts/omap44xx-clocks.dtsi +6 -0
+    gpmc_fck: gpmc_fck {
+        #clock-cells = <0>;
+        compatible = "ti,clkdm-gate-clock";
+        clocks = <&l3_div_ck>;
+    };
+

Why not implement a proper gate clock for CM_L3_2_GPMC_CLKCTRL? The approach you have taken looks good to me otherwise.

So something like:

        gpmc_fck: gpmc_fck {
                #clock-cells = <0>;
                compatible = "ti,gate-clock";
                clocks = <&l3_div_ck>;
                reg = <(CM_L3_2_GPMC_CLKCTRL)>;
                ti,bit-shift = <0>;
        };

? I was not sure for gate-clock, as setting the bit will enable the clock only if the corresponding clock domain (CD_L3_2) is enabled as well.

Regards,
Florian

#5 lore raw

PATCH 2/2 ARM: DTS: OMAP4: Add gpmc_fck clock node

Quoted 56 lines · Florian Vaussard

Hi,

Quoted 32 lines · Tero Kristo
Quoted 31 lines · Florian Vaussard

Add the gpmc_fck clock, derived from l3_ick, and reference it from the GPMC node to get it correctly working.

---
   arch/arm/boot/dts/omap4.dtsi           | 2 ++
   arch/arm/boot/dts/omap44xx-clocks.dtsi | 6 ++++++
   2 files changed, 8 insertions(+)
arch/arm/boot/dts/omap4.dtsi +2 -0
index d3f8a6e..8a0cc71 100644
@@ -275,6 +275,8 @@
               gpmc,num-waitpins = <4>;
               ti,hwmods = "gpmc";
               ti,no-idle-on-init;
+            clocks = <&gpmc_fck>;
+            clock-names = "fck";
           };
 
           uart1: serial at 4806a000 {
arch/arm/boot/dts/omap44xx-clocks.dtsi +0 -0
index c821ff5..ae2c441 100644
@@ -1036,6 +1036,12 @@
           ti,index-power-of-two;
       };
 
Quoted 10 lines

arch/arm/boot/dts/omap44xx-clocks.dtsi line 1044

Quoted 6 lines
arch/arm/boot/dts/omap44xx-clocks.dtsi +6 -0
+    gpmc_fck: gpmc_fck {
+        #clock-cells = <0>;
+        compatible = "ti,clkdm-gate-clock";
+        clocks = <&l3_div_ck>;
+    };
+

Why not implement a proper gate clock for CM_L3_2_GPMC_CLKCTRL? The approach you have taken looks good to me otherwise.

So something like:

         gpmc_fck: gpmc_fck {
                 #clock-cells = <0>;
                 compatible = "ti,gate-clock";
                 clocks = <&l3_div_ck>;
                 reg = <(CM_L3_2_GPMC_CLKCTRL)>;
                 ti,bit-shift = <0>;
         };
Quoted 2 lines

? I was not sure for gate-clock, as setting the bit will enable the clock only if the corresponding clock domain (CD_L3_2) is enabled as well.

Actually you may want not to add a gate clock for this, as this would result in duplicate control to the same bits... hwmod is already controlling this. Do you need the clkdm control for something? If not, you could just link the gpmc node directly to use l3_div_ck as the provider for its clock rate. Looking at the driver, I think you don't need it for anything else.

-Tero

#6 lore raw

PATCH 2/2 ARM: DTS: OMAP4: Add gpmc_fck clock node

Quoted 62 lines · Tero Kristo
Quoted 57 lines · Florian Vaussard

Hi,

Quoted 33 lines · Tero Kristo
Quoted 32 lines · Florian Vaussard

Add the gpmc_fck clock, derived from l3_ick, and reference it from the GPMC node to get it correctly working.

---
   arch/arm/boot/dts/omap4.dtsi           | 2 ++
   arch/arm/boot/dts/omap44xx-clocks.dtsi | 6 ++++++
   2 files changed, 8 insertions(+)
arch/arm/boot/dts/omap4.dtsi +2 -0
index d3f8a6e..8a0cc71 100644
@@ -275,6 +275,8 @@
               gpmc,num-waitpins = <4>;
               ti,hwmods = "gpmc";
               ti,no-idle-on-init;
+            clocks = <&gpmc_fck>;
+            clock-names = "fck";
           };
 
           uart1: serial at 4806a000 {
arch/arm/boot/dts/omap44xx-clocks.dtsi +0 -0
index c821ff5..ae2c441 100644
@@ -1036,6 +1036,12 @@
           ti,index-power-of-two;
       };
 
Quoted 10 lines

arch/arm/boot/dts/omap44xx-clocks.dtsi line 1044

Quoted 6 lines
arch/arm/boot/dts/omap44xx-clocks.dtsi +6 -0
+    gpmc_fck: gpmc_fck {
+        #clock-cells = <0>;
+        compatible = "ti,clkdm-gate-clock";
+        clocks = <&l3_div_ck>;
+    };
+

Why not implement a proper gate clock for CM_L3_2_GPMC_CLKCTRL? The approach you have taken looks good to me otherwise.

So something like:

         gpmc_fck: gpmc_fck {
                 #clock-cells = <0>;
                 compatible = "ti,gate-clock";
                 clocks = <&l3_div_ck>;
                 reg = <(CM_L3_2_GPMC_CLKCTRL)>;
                 ti,bit-shift = <0>;
         };
Quoted 3 lines

? I was not sure for gate-clock, as setting the bit will enable the clock only if the corresponding clock domain (CD_L3_2) is enabled as well.

Quoted 7 lines

Actually you may want not to add a gate clock for this, as this would result in duplicate control to the same bits... hwmod is already controlling this. Do you need the clkdm control for something? If not, you could just link the gpmc node directly to use l3_div_ck as the provider for its clock rate. Looking at the driver, I think you don't need it for anything else.

I missed the hwmod bit. So your solution seems the most reasonable for now. I will send a v2 shortly. Thanks for your help.

Regards,
Florian