diff mbox

ARM: dts: imx: fix clocks for cspi

Message ID 1369309085-31146-1-git-send-email-jonas@microbit.se (mailing list archive)
State New, archived
Headers show

Commit Message

Jonas Andersson May 23, 2013, 11:38 a.m. UTC
The CSPI controller has only one clock, but the driver spi-imx.c needs clock "per" to calculate bitrate divisor.

Signed-off-by: Jonas Andersson <jonas@microbit.se>
---
 arch/arm/boot/dts/imx25.dtsi | 12 ++++++------
 arch/arm/boot/dts/imx27.dtsi |  6 +++---
 arch/arm/boot/dts/imx51.dtsi |  2 +-
 arch/arm/boot/dts/imx53.dtsi |  2 +-
 4 files changed, 11 insertions(+), 11 deletions(-)

Comments

Sascha Hauer May 23, 2013, 11:57 a.m. UTC | #1
On Thu, May 23, 2013 at 01:38:05PM +0200, Jonas Andersson wrote:
> The CSPI controller has only one clock, but the driver spi-imx.c needs clock "per" to calculate bitrate divisor.
> 
> Signed-off-by: Jonas Andersson <jonas@microbit.se>

Acked-by: Sascha Hauer <s.hauer@pengutronix.de>

Sascha

> ---
>  arch/arm/boot/dts/imx25.dtsi | 12 ++++++------
>  arch/arm/boot/dts/imx27.dtsi |  6 +++---
>  arch/arm/boot/dts/imx51.dtsi |  2 +-
>  arch/arm/boot/dts/imx53.dtsi |  2 +-
>  4 files changed, 11 insertions(+), 11 deletions(-)
> 
> diff --git a/arch/arm/boot/dts/imx25.dtsi b/arch/arm/boot/dts/imx25.dtsi
> index d2550e0..7011539 100644
> --- a/arch/arm/boot/dts/imx25.dtsi
> +++ b/arch/arm/boot/dts/imx25.dtsi
> @@ -141,8 +141,8 @@
>  				#size-cells = <0>;
>  				compatible = "fsl,imx25-cspi", "fsl,imx35-cspi";
>  				reg = <0x43fa4000 0x4000>;
> -				clocks = <&clks 62>;
> -				clock-names = "ipg";
> +				clocks = <&clks 62>, <&clks 62>;
> +				clock-names = "ipg", "per";
>  				interrupts = <14>;
>  				status = "disabled";
>  			};
> @@ -182,8 +182,8 @@
>  				compatible = "fsl,imx25-cspi", "fsl,imx35-cspi";
>  				reg = <0x50004000 0x4000>;
>  				interrupts = <0>;
> -				clocks = <&clks 80>;
> -				clock-names = "ipg";
> +				clocks = <&clks 80>, <&clks 80>;
> +				clock-names = "ipg", "per";
>  				status = "disabled";
>  			};
>  
> @@ -210,8 +210,8 @@
>  				#size-cells = <0>;
>  				compatible = "fsl,imx25-cspi", "fsl,imx35-cspi";
>  				reg = <0x50010000 0x4000>;
> -				clocks = <&clks 79>;
> -				clock-names = "ipg";
> +				clocks = <&clks 79>, <&clks 79>;
> +				clock-names = "ipg", "per";
>  				interrupts = <13>;
>  				status = "disabled";
>  			};
> diff --git a/arch/arm/boot/dts/imx27.dtsi b/arch/arm/boot/dts/imx27.dtsi
> index ff4bd48..75bd113 100644
> --- a/arch/arm/boot/dts/imx27.dtsi
> +++ b/arch/arm/boot/dts/imx27.dtsi
> @@ -131,7 +131,7 @@
>  				compatible = "fsl,imx27-cspi";
>  				reg = <0x1000e000 0x1000>;
>  				interrupts = <16>;
> -				clocks = <&clks 53>, <&clks 0>;
> +				clocks = <&clks 53>, <&clks 53>;
>  				clock-names = "ipg", "per";
>  				status = "disabled";
>  			};
> @@ -142,7 +142,7 @@
>  				compatible = "fsl,imx27-cspi";
>  				reg = <0x1000f000 0x1000>;
>  				interrupts = <15>;
> -				clocks = <&clks 52>, <&clks 0>;
> +				clocks = <&clks 52>, <&clks 52>;
>  				clock-names = "ipg", "per";
>  				status = "disabled";
>  			};
> @@ -223,7 +223,7 @@
>  				compatible = "fsl,imx27-cspi";
>  				reg = <0x10017000 0x1000>;
>  				interrupts = <6>;
> -				clocks = <&clks 51>, <&clks 0>;
> +				clocks = <&clks 51>, <&clks 51>;
>  				clock-names = "ipg", "per";
>  				status = "disabled";
>  			};
> diff --git a/arch/arm/boot/dts/imx51.dtsi b/arch/arm/boot/dts/imx51.dtsi
> index 21bb786..53fdde6 100644
> --- a/arch/arm/boot/dts/imx51.dtsi
> +++ b/arch/arm/boot/dts/imx51.dtsi
> @@ -631,7 +631,7 @@
>  				compatible = "fsl,imx51-cspi", "fsl,imx35-cspi";
>  				reg = <0x83fc0000 0x4000>;
>  				interrupts = <38>;
> -				clocks = <&clks 55>, <&clks 0>;
> +				clocks = <&clks 55>, <&clks 55>;
>  				clock-names = "ipg", "per";
>  				status = "disabled";
>  			};
> diff --git a/arch/arm/boot/dts/imx53.dtsi b/arch/arm/boot/dts/imx53.dtsi
> index 845982e..eb83aa0 100644
> --- a/arch/arm/boot/dts/imx53.dtsi
> +++ b/arch/arm/boot/dts/imx53.dtsi
> @@ -714,7 +714,7 @@
>  				compatible = "fsl,imx53-cspi", "fsl,imx35-cspi";
>  				reg = <0x63fc0000 0x4000>;
>  				interrupts = <38>;
> -				clocks = <&clks 55>, <&clks 0>;
> +				clocks = <&clks 55>, <&clks 55>;
>  				clock-names = "ipg", "per";
>  				status = "disabled";
>  			};
> -- 
> 1.8.1.4
> 
>
Alexander Shiyan May 23, 2013, 12:01 p.m. UTC | #2
> The CSPI controller has only one clock, but the driver spi-imx.c needs clock "per" to calculate bitrate divisor.
> 
> Signed-off-by: Jonas Andersson <jonas@microbit.se>
> ---
>  arch/arm/boot/dts/imx25.dtsi | 12 ++++++------
>  arch/arm/boot/dts/imx27.dtsi |  6 +++---
>  arch/arm/boot/dts/imx51.dtsi |  2 +-
>  arch/arm/boot/dts/imx53.dtsi |  2 +-
>  4 files changed, 11 insertions(+), 11 deletions(-)
> 
> diff --git a/arch/arm/boot/dts/imx25.dtsi b/arch/arm/boot/dts/imx25.dtsi
> index d2550e0..7011539 100644
> --- a/arch/arm/boot/dts/imx25.dtsi
> +++ b/arch/arm/boot/dts/imx25.dtsi
> @@ -141,8 +141,8 @@
>  				#size-cells = <0>;
>  				compatible = "fsl,imx25-cspi", "fsl,imx35-cspi";
>  				reg = <0x43fa4000 0x4000>;
> -				clocks = <&clks 62>;
> -				clock-names = "ipg";
> +				clocks = <&clks 62>, <&clks 62>;
> +				clock-names = "ipg", "per";
>  				interrupts = <14>;
>  				status = "disabled";
>  			};

Why you do not use "dummy" clock for "per" here?
This variant will request/enable one clock two times.

---
Alexander Shiyan May 23, 2013, 12:10 p.m. UTC | #3
> > The CSPI controller has only one clock, but the driver spi-imx.c needs clock "per" to calculate bitrate divisor.
> > 
> > Signed-off-by: Jonas Andersson <jonas@microbit.se>
> > ---
> >  arch/arm/boot/dts/imx25.dtsi | 12 ++++++------
> >  arch/arm/boot/dts/imx27.dtsi |  6 +++---
> >  arch/arm/boot/dts/imx51.dtsi |  2 +-
> >  arch/arm/boot/dts/imx53.dtsi |  2 +-
> >  4 files changed, 11 insertions(+), 11 deletions(-)
> > 
> > diff --git a/arch/arm/boot/dts/imx25.dtsi b/arch/arm/boot/dts/imx25.dtsi
> > index d2550e0..7011539 100644
> > --- a/arch/arm/boot/dts/imx25.dtsi
> > +++ b/arch/arm/boot/dts/imx25.dtsi
> > @@ -141,8 +141,8 @@
> >  				#size-cells = <0>;
> >  				compatible = "fsl,imx25-cspi", "fsl,imx35-cspi";
> >  				reg = <0x43fa4000 0x4000>;
> > -				clocks = <&clks 62>;
> > -				clock-names = "ipg";
> > +				clocks = <&clks 62>, <&clks 62>;
> > +				clock-names = "ipg", "per";
> >  				interrupts = <14>;
> >  				status = "disabled";
> >  			};

Sorry, typo.

> Why you do not use "dummy" clock for "per" here?

*for "ipg"

> This variant will request/enable one clock two times.
 
---
Sascha Hauer May 23, 2013, 12:36 p.m. UTC | #4
On Thu, May 23, 2013 at 04:10:59PM +0400, Alexander Shiyan wrote:
> > > The CSPI controller has only one clock, but the driver spi-imx.c needs clock "per" to calculate bitrate divisor.
> > > 
> > > Signed-off-by: Jonas Andersson <jonas@microbit.se>
> > > ---
> > >  arch/arm/boot/dts/imx25.dtsi | 12 ++++++------
> > >  arch/arm/boot/dts/imx27.dtsi |  6 +++---
> > >  arch/arm/boot/dts/imx51.dtsi |  2 +-
> > >  arch/arm/boot/dts/imx53.dtsi |  2 +-
> > >  4 files changed, 11 insertions(+), 11 deletions(-)
> > > 
> > > diff --git a/arch/arm/boot/dts/imx25.dtsi b/arch/arm/boot/dts/imx25.dtsi
> > > index d2550e0..7011539 100644
> > > --- a/arch/arm/boot/dts/imx25.dtsi
> > > +++ b/arch/arm/boot/dts/imx25.dtsi
> > > @@ -141,8 +141,8 @@
> > >  				#size-cells = <0>;
> > >  				compatible = "fsl,imx25-cspi", "fsl,imx35-cspi";
> > >  				reg = <0x43fa4000 0x4000>;
> > > -				clocks = <&clks 62>;
> > > -				clock-names = "ipg";
> > > +				clocks = <&clks 62>, <&clks 62>;
> > > +				clock-names = "ipg", "per";
> > >  				interrupts = <14>;
> > >  				status = "disabled";
> > >  			};
> 
> Sorry, typo.
> 
> > Why you do not use "dummy" clock for "per" here?
> 
> *for "ipg"

Because the same clock is used for the register clock and the baudrate
clock. You have to enable the ipg clock to access registers.

> 
> > This variant will request/enable one clock two times.

Indeed, but what's the problem with this?

Sascha
Alexander Shiyan May 23, 2013, 2:28 p.m. UTC | #5
> On Thu, May 23, 2013 at 04:10:59PM +0400, Alexander Shiyan wrote:
> > > > The CSPI controller has only one clock, but the driver spi-imx.c needs clock "per" to calculate bitrate divisor.
> > > > 
> > > > Signed-off-by: Jonas Andersson <jonas@microbit.se>
> > > > ---
> > > >  arch/arm/boot/dts/imx25.dtsi | 12 ++++++------
> > > >  arch/arm/boot/dts/imx27.dtsi |  6 +++---
> > > >  arch/arm/boot/dts/imx51.dtsi |  2 +-
> > > >  arch/arm/boot/dts/imx53.dtsi |  2 +-
> > > >  4 files changed, 11 insertions(+), 11 deletions(-)
> > > > 
> > > > diff --git a/arch/arm/boot/dts/imx25.dtsi b/arch/arm/boot/dts/imx25.dtsi
> > > > index d2550e0..7011539 100644
> > > > --- a/arch/arm/boot/dts/imx25.dtsi
> > > > +++ b/arch/arm/boot/dts/imx25.dtsi
> > > > @@ -141,8 +141,8 @@
> > > >  				#size-cells = <0>;
> > > >  				compatible = "fsl,imx25-cspi", "fsl,imx35-cspi";
> > > >  				reg = <0x43fa4000 0x4000>;
> > > > -				clocks = <&clks 62>;
> > > > -				clock-names = "ipg";
> > > > +				clocks = <&clks 62>, <&clks 62>;
> > > > +				clock-names = "ipg", "per";
> > > >  				interrupts = <14>;
> > > >  				status = "disabled";
> > > >  			};
> > 
> > Sorry, typo.
> > 
> > > Why you do not use "dummy" clock for "per" here?
> > 
> > *for "ipg"
> 
> Because the same clock is used for the register clock and the baudrate
> clock. You have to enable the ipg clock to access registers.

I am not see any "ipg" clock usage in the spi driver. If "ipg" clock is
a dependency for "per" clock, it should be registered in ccm as parent.
Is not it?

---
Sascha Hauer May 23, 2013, 5:33 p.m. UTC | #6
On Thu, May 23, 2013 at 06:28:10PM +0400, Alexander Shiyan wrote:
> > On Thu, May 23, 2013 at 04:10:59PM +0400, Alexander Shiyan wrote:
> > > > > The CSPI controller has only one clock, but the driver spi-imx.c needs clock "per" to calculate bitrate divisor.
> > > > > 
> > > > > Signed-off-by: Jonas Andersson <jonas@microbit.se>
> > > > > ---
> > > > >  arch/arm/boot/dts/imx25.dtsi | 12 ++++++------
> > > > >  arch/arm/boot/dts/imx27.dtsi |  6 +++---
> > > > >  arch/arm/boot/dts/imx51.dtsi |  2 +-
> > > > >  arch/arm/boot/dts/imx53.dtsi |  2 +-
> > > > >  4 files changed, 11 insertions(+), 11 deletions(-)
> > > > > 
> > > > > diff --git a/arch/arm/boot/dts/imx25.dtsi b/arch/arm/boot/dts/imx25.dtsi
> > > > > index d2550e0..7011539 100644
> > > > > --- a/arch/arm/boot/dts/imx25.dtsi
> > > > > +++ b/arch/arm/boot/dts/imx25.dtsi
> > > > > @@ -141,8 +141,8 @@
> > > > >  				#size-cells = <0>;
> > > > >  				compatible = "fsl,imx25-cspi", "fsl,imx35-cspi";
> > > > >  				reg = <0x43fa4000 0x4000>;
> > > > > -				clocks = <&clks 62>;
> > > > > -				clock-names = "ipg";
> > > > > +				clocks = <&clks 62>, <&clks 62>;
> > > > > +				clock-names = "ipg", "per";
> > > > >  				interrupts = <14>;
> > > > >  				status = "disabled";
> > > > >  			};
> > > 
> > > Sorry, typo.
> > > 
> > > > Why you do not use "dummy" clock for "per" here?
> > > 
> > > *for "ipg"
> > 
> > Because the same clock is used for the register clock and the baudrate
> > clock. You have to enable the ipg clock to access registers.
> 
> I am not see any "ipg" clock usage in the spi driver.

It's the register clock. The driver enables it in order to access the
registers.

> If "ipg" clock is
> a dependency for "per" clock, it should be registered in ccm as parent.

Look, the eCSPI unit has two clock inputs, one for accessing the
registers (ipg) and one for generating the SPI bit clock (per). Now the
CSPI unit only has a single clock input, so the 100% correct way would
be to specify only a single clock for this unit. However, since we
handle both units with the same driver the simplest way to cope with
it is to provide the very same clock twice, once for the register access
and once for generating the SPI bit clock.
And yes, we have to specify the real clock twice and can't replace one
with a dummy clock, because if we specify a dummy clock for the ipg
clock, then the driver couldn't access the registers even if it enabled
the clock. If we would replace the SPI bit clock with a dummy clock then
the device couldn't send data even if the driver enabled the bit clock.
(That of course only becomes relevant when the driver actually
en/disables the clocks during runtime and not only once during probe).

Sascha
Alexander Shiyan May 24, 2013, 4:16 a.m. UTC | #7
> > > On Thu, May 23, 2013 at 04:10:59PM +0400, Alexander Shiyan wrote:
> > > > > > The CSPI controller has only one clock, but the driver spi-imx.c needs clock "per" to calculate bitrate divisor.
> > > > > > 
> > > > > > Signed-off-by: Jonas Andersson <jonas@microbit.se>
> > > > > > ---
> > > > > >  arch/arm/boot/dts/imx25.dtsi | 12 ++++++------
> > > > > >  arch/arm/boot/dts/imx27.dtsi |  6 +++---
> > > > > >  arch/arm/boot/dts/imx51.dtsi |  2 +-
> > > > > >  arch/arm/boot/dts/imx53.dtsi |  2 +-
> > > > > >  4 files changed, 11 insertions(+), 11 deletions(-)
> > > > > > 
> > > > > > diff --git a/arch/arm/boot/dts/imx25.dtsi b/arch/arm/boot/dts/imx25.dtsi
> > > > > > index d2550e0..7011539 100644
> > > > > > --- a/arch/arm/boot/dts/imx25.dtsi
> > > > > > +++ b/arch/arm/boot/dts/imx25.dtsi
> > > > > > @@ -141,8 +141,8 @@
> > > > > >  				#size-cells = <0>;
> > > > > >  				compatible = "fsl,imx25-cspi", "fsl,imx35-cspi";
> > > > > >  				reg = <0x43fa4000 0x4000>;
> > > > > > -				clocks = <&clks 62>;
> > > > > > -				clock-names = "ipg";
> > > > > > +				clocks = <&clks 62>, <&clks 62>;
> > > > > > +				clock-names = "ipg", "per";
> > > > > >  				interrupts = <14>;
> > > > > >  				status = "disabled";
> > > > > >  			};
> > > > 
> > > > Sorry, typo.
> > > > 
> > > > > Why you do not use "dummy" clock for "per" here?
> > > > 
> > > > *for "ipg"
> > > 
> > > Because the same clock is used for the register clock and the baudrate
> > > clock. You have to enable the ipg clock to access registers.
> > 
> > I am not see any "ipg" clock usage in the spi driver.
> 
> It's the register clock. The driver enables it in order to access the
> registers.
> 
> > If "ipg" clock is
> > a dependency for "per" clock, it should be registered in ccm as parent.
> 
> Look, the eCSPI unit has two clock inputs, one for accessing the
> registers (ipg) and one for generating the SPI bit clock (per). Now the
> CSPI unit only has a single clock input, so the 100% correct way would
> be to specify only a single clock for this unit. However, since we
> handle both units with the same driver the simplest way to cope with
> it is to provide the very same clock twice, once for the register access
> and once for generating the SPI bit clock.
> And yes, we have to specify the real clock twice and can't replace one
> with a dummy clock, because if we specify a dummy clock for the ipg
> clock, then the driver couldn't access the registers even if it enabled
> the clock. If we would replace the SPI bit clock with a dummy clock then
> the device couldn't send data even if the driver enabled the bit clock.
> (That of course only becomes relevant when the driver actually
> en/disables the clocks during runtime and not only once during probe).

Well, I completely forgot about the clock for registers.
Everything looks right then.
However, it would be nice to add a few words about the clocks in the
Documentation/devicetree/bindings/spi/fsl-imx~spi.txt
Thanks for the clarification.

---
Shawn Guo May 24, 2013, 5:42 a.m. UTC | #8
On Thu, May 23, 2013 at 01:38:05PM +0200, Jonas Andersson wrote:
> The CSPI controller has only one clock, but the driver spi-imx.c needs clock "per" to calculate bitrate divisor.
> 
> Signed-off-by: Jonas Andersson <jonas@microbit.se>

Applied, thanks.
diff mbox

Patch

diff --git a/arch/arm/boot/dts/imx25.dtsi b/arch/arm/boot/dts/imx25.dtsi
index d2550e0..7011539 100644
--- a/arch/arm/boot/dts/imx25.dtsi
+++ b/arch/arm/boot/dts/imx25.dtsi
@@ -141,8 +141,8 @@ 
 				#size-cells = <0>;
 				compatible = "fsl,imx25-cspi", "fsl,imx35-cspi";
 				reg = <0x43fa4000 0x4000>;
-				clocks = <&clks 62>;
-				clock-names = "ipg";
+				clocks = <&clks 62>, <&clks 62>;
+				clock-names = "ipg", "per";
 				interrupts = <14>;
 				status = "disabled";
 			};
@@ -182,8 +182,8 @@ 
 				compatible = "fsl,imx25-cspi", "fsl,imx35-cspi";
 				reg = <0x50004000 0x4000>;
 				interrupts = <0>;
-				clocks = <&clks 80>;
-				clock-names = "ipg";
+				clocks = <&clks 80>, <&clks 80>;
+				clock-names = "ipg", "per";
 				status = "disabled";
 			};
 
@@ -210,8 +210,8 @@ 
 				#size-cells = <0>;
 				compatible = "fsl,imx25-cspi", "fsl,imx35-cspi";
 				reg = <0x50010000 0x4000>;
-				clocks = <&clks 79>;
-				clock-names = "ipg";
+				clocks = <&clks 79>, <&clks 79>;
+				clock-names = "ipg", "per";
 				interrupts = <13>;
 				status = "disabled";
 			};
diff --git a/arch/arm/boot/dts/imx27.dtsi b/arch/arm/boot/dts/imx27.dtsi
index ff4bd48..75bd113 100644
--- a/arch/arm/boot/dts/imx27.dtsi
+++ b/arch/arm/boot/dts/imx27.dtsi
@@ -131,7 +131,7 @@ 
 				compatible = "fsl,imx27-cspi";
 				reg = <0x1000e000 0x1000>;
 				interrupts = <16>;
-				clocks = <&clks 53>, <&clks 0>;
+				clocks = <&clks 53>, <&clks 53>;
 				clock-names = "ipg", "per";
 				status = "disabled";
 			};
@@ -142,7 +142,7 @@ 
 				compatible = "fsl,imx27-cspi";
 				reg = <0x1000f000 0x1000>;
 				interrupts = <15>;
-				clocks = <&clks 52>, <&clks 0>;
+				clocks = <&clks 52>, <&clks 52>;
 				clock-names = "ipg", "per";
 				status = "disabled";
 			};
@@ -223,7 +223,7 @@ 
 				compatible = "fsl,imx27-cspi";
 				reg = <0x10017000 0x1000>;
 				interrupts = <6>;
-				clocks = <&clks 51>, <&clks 0>;
+				clocks = <&clks 51>, <&clks 51>;
 				clock-names = "ipg", "per";
 				status = "disabled";
 			};
diff --git a/arch/arm/boot/dts/imx51.dtsi b/arch/arm/boot/dts/imx51.dtsi
index 21bb786..53fdde6 100644
--- a/arch/arm/boot/dts/imx51.dtsi
+++ b/arch/arm/boot/dts/imx51.dtsi
@@ -631,7 +631,7 @@ 
 				compatible = "fsl,imx51-cspi", "fsl,imx35-cspi";
 				reg = <0x83fc0000 0x4000>;
 				interrupts = <38>;
-				clocks = <&clks 55>, <&clks 0>;
+				clocks = <&clks 55>, <&clks 55>;
 				clock-names = "ipg", "per";
 				status = "disabled";
 			};
diff --git a/arch/arm/boot/dts/imx53.dtsi b/arch/arm/boot/dts/imx53.dtsi
index 845982e..eb83aa0 100644
--- a/arch/arm/boot/dts/imx53.dtsi
+++ b/arch/arm/boot/dts/imx53.dtsi
@@ -714,7 +714,7 @@ 
 				compatible = "fsl,imx53-cspi", "fsl,imx35-cspi";
 				reg = <0x63fc0000 0x4000>;
 				interrupts = <38>;
-				clocks = <&clks 55>, <&clks 0>;
+				clocks = <&clks 55>, <&clks 55>;
 				clock-names = "ipg", "per";
 				status = "disabled";
 			};