diff mbox

[v3,4/4] mvebu: wrt1900ac: Use pwm-fan rather than gpio-fan

Message ID 20170324141815.7252-5-ralph.sennhauser@gmail.com
State New
Headers show

Commit Message

Ralph Sennhauser March 24, 2017, 2:18 p.m. UTC
From: Andrew Lunn <andrew@lunn.ch>

The mvebu GPIO driver can also perform PWM on some pins. Use the pwm-fan
driver to control the fan of the WRT1900AC, giving us finer grained control
over its speed and hence noise.

Signed-off-by: Andrew Lunn <andrew@lunn.ch>
URL: https://patchwork.ozlabs.org/patch/427291/
Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
---
 arch/arm/boot/dts/armada-xp-linksys-mamba.dts | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

Comments

Andrew Lunn March 24, 2017, 2:35 p.m. UTC | #1
> +	pwm_fan {
>  		/* SUNON HA4010V4-0000-C99 */
> -		compatible = "gpio-fan";
> -		gpios = <&gpio0 24 0>;
>  
> -		gpio-fan,speed-map = <0    0
> -				      4500 1>;
> +		compatible = "pwm-fan";
> +		pwms = <&gpio0 24 4000 0>;

Hi Ralph

I believe this last 0 is the flags parameter. Now that we have
#pwm-cells = 1, i think this last 0 should be dropped.

	  Andrew
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Ralph Sennhauser March 24, 2017, 10:23 p.m. UTC | #2
On Fri, 24 Mar 2017 15:35:05 +0100
Andrew Lunn <andrew@lunn.ch> wrote:

> > +	pwm_fan {
> >  		/* SUNON HA4010V4-0000-C99 */
> > -		compatible = "gpio-fan";
> > -		gpios = <&gpio0 24 0>;
> >  
> > -		gpio-fan,speed-map = <0    0
> > -				      4500 1>;
> > +		compatible = "pwm-fan";
> > +		pwms = <&gpio0 24 4000 0>;  
> 
> Hi Ralph
> 
> I believe this last 0 is the flags parameter. Now that we have
> #pwm-cells = 1, i think this last 0 should be dropped.
> 
> 	  Andrew

Missed it. Duly noted like the other comments.

Thanks
Ralph
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Ralph Sennhauser March 26, 2017, 9:05 p.m. UTC | #3
On Fri, 24 Mar 2017 15:35:05 +0100
Andrew Lunn <andrew@lunn.ch> wrote:

> > +	pwm_fan {
> >  		/* SUNON HA4010V4-0000-C99 */
> > -		compatible = "gpio-fan";
> > -		gpios = <&gpio0 24 0>;
> >  
> > -		gpio-fan,speed-map = <0    0
> > -				      4500 1>;
> > +		compatible = "pwm-fan";
> > +		pwms = <&gpio0 24 4000 0>;  
> 
> Hi Ralph
> 
> I believe this last 0 is the flags parameter. Now that we have
> #pwm-cells = 1, i think this last 0 should be dropped.
> 
> 	  Andrew

Hi Andrew,

isn't the 4000 (period?) pwm-cell #2 and 0 (flags?) pwm-cell #3? I
actually expect "pwms = <&gpio0 24>;" here or "#pwm-cells = <2>;"

Ralph
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Andrew Lunn March 27, 2017, 1:17 p.m. UTC | #4
On Sun, Mar 26, 2017 at 11:05:58PM +0200, Ralph Sennhauser wrote:
> On Fri, 24 Mar 2017 15:35:05 +0100
> Andrew Lunn <andrew@lunn.ch> wrote:
> 
> > > +	pwm_fan {
> > >  		/* SUNON HA4010V4-0000-C99 */
> > > -		compatible = "gpio-fan";
> > > -		gpios = <&gpio0 24 0>;
> > >  
> > > -		gpio-fan,speed-map = <0    0
> > > -				      4500 1>;
> > > +		compatible = "pwm-fan";
> > > +		pwms = <&gpio0 24 4000 0>;  
> > 
> > Hi Ralph
> > 
> > I believe this last 0 is the flags parameter. Now that we have
> > #pwm-cells = 1, i think this last 0 should be dropped.
> > 
> > 	  Andrew
> 
> Hi Andrew,
> 
> isn't the 4000 (period?) pwm-cell #2 and 0 (flags?) pwm-cell #3? I
> actually expect "pwms = <&gpio0 24>;" here or "#pwm-cells = <2>;"

Hi Ralph

From Documentation/devicetree/bindings/pwm/pwm.txt:

        pwm-list ::= <single-pwm> [pwm-list]
        single-pwm ::= <pwm-phandle> <pwm-specifier>
        pwm-phandle : phandle to PWM controller node
        pwm-specifier : array of #pwm-cells specifying the given PWM
                        (controller specific)

Our pwm-list has a single single-pwm.
phandle is &gpio0.
The remaining parts are the specifier, or which there should be #pwm-calls.

From Documentation/devicetree/bindings/pwm/pwm.txt again:

pwm-specifier typically encodes the chip-relative PWM number and the PWM
period in nanoseconds.

Optionally, the pwm-specifier can encode a number of flags (defined in
<dt-bindings/pwm/pwm.h>) in a third cell:
- PWM_POLARITY_INVERTED: invert the PWM signal polarity

So we are using the 24th PWM and 4000 nanosecod period. We don't want
any flags.

So

pwms = <&gpio0 24 4000>;  

has a phandle, and then 2 cells.

    Andrew
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/arch/arm/boot/dts/armada-xp-linksys-mamba.dts b/arch/arm/boot/dts/armada-xp-linksys-mamba.dts
index 3744ba3..836b275e 100644
--- a/arch/arm/boot/dts/armada-xp-linksys-mamba.dts
+++ b/arch/arm/boot/dts/armada-xp-linksys-mamba.dts
@@ -293,13 +293,11 @@ 
 		};
 	};
 
-	gpio_fan {
+	pwm_fan {
 		/* SUNON HA4010V4-0000-C99 */
-		compatible = "gpio-fan";
-		gpios = <&gpio0 24 0>;
 
-		gpio-fan,speed-map = <0    0
-				      4500 1>;
+		compatible = "pwm-fan";
+		pwms = <&gpio0 24 4000 0>;
 	};
 
 	dsa {