diff mbox series

[4/4] ARM: dts: qcom: msm8974-hammerhead: Add vibrator

Message ID 20230427-hammerhead-vibra-v1-4-e87eeb94da51@z3ntu.xyz (mailing list archive)
State Mainlined
Commit e0a6590d8ceb7d6c4e35b5b5eb368d9fb800487f
Headers show
Series Add haptics support to Nexus 5 using pwm-vibra driver | expand

Commit Message

Luca Weiss April 27, 2023, 8:34 p.m. UTC
The Nexus 5 has a vibrator connected to the clock output of GP1_CLK
which we can use with the clk-pwm driver, then we can use that pwm with
pwm-vibrator to get haptics functionality.

This patch is based on Brian Masney's previous patch with clk-vibrator.

Signed-off-by: Luca Weiss <luca@z3ntu.xyz>
---
 .../dts/qcom-msm8974-lge-nexus5-hammerhead.dts     | 35 ++++++++++++++++++++++
 1 file changed, 35 insertions(+)

Comments

Brian Masney April 27, 2023, 11:34 p.m. UTC | #1
On Thu, Apr 27, 2023 at 10:34:29PM +0200, Luca Weiss wrote:
> The Nexus 5 has a vibrator connected to the clock output of GP1_CLK
> which we can use with the clk-pwm driver, then we can use that pwm with
> pwm-vibrator to get haptics functionality.
> 
> This patch is based on Brian Masney's previous patch with clk-vibrator.
> 
> Signed-off-by: Luca Weiss <luca@z3ntu.xyz>

Reviewed-by: Brian Masney <bmasney@redhat.com>
Caleb Connolly April 28, 2023, 10:11 a.m. UTC | #2
On 27/04/2023 21:34, Luca Weiss wrote:
> The Nexus 5 has a vibrator connected to the clock output of GP1_CLK
> which we can use with the clk-pwm driver, then we can use that pwm with
> pwm-vibrator to get haptics functionality.
> 
> This patch is based on Brian Masney's previous patch with clk-vibrator.
> 
> Signed-off-by: Luca Weiss <luca@z3ntu.xyz>

Reviewed-by: Caleb Connolly <caleb.connolly@linaro.org>
> ---
>   .../dts/qcom-msm8974-lge-nexus5-hammerhead.dts     | 35 ++++++++++++++++++++++
>   1 file changed, 35 insertions(+)
> 
> diff --git a/arch/arm/boot/dts/qcom-msm8974-lge-nexus5-hammerhead.dts b/arch/arm/boot/dts/qcom-msm8974-lge-nexus5-hammerhead.dts
> index ab35f2d644c0..fea8a6be9021 100644
> --- a/arch/arm/boot/dts/qcom-msm8974-lge-nexus5-hammerhead.dts
> +++ b/arch/arm/boot/dts/qcom-msm8974-lge-nexus5-hammerhead.dts
> @@ -41,6 +41,25 @@ key-volume-down {
>   		};
>   	};
>   
> +	clk_pwm: pwm {
> +		compatible = "clk-pwm";
> +		clocks = <&mmcc CAMSS_GP1_CLK>;
> +
> +		pinctrl-0 = <&vibrator_pin>;
> +		pinctrl-names = "default";
> +
> +		#pwm-cells = <2>;
> +	};
> +
> +	vibrator {
> +		compatible = "pwm-vibrator";
> +		pwms = <&clk_pwm 0 100000>;
> +		pwm-names = "enable";
> +
> +		vcc-supply = <&pm8941_l19>;
> +		enable-gpios = <&tlmm 60 GPIO_ACTIVE_HIGH>;
> +	};
> +
>   	vreg_wlan: wlan-regulator {
>   		compatible = "regulator-fixed";
>   
> @@ -637,6 +656,22 @@ shutdown-pins {
>   			function = "gpio";
>   		};
>   	};
> +
> +	vibrator_pin: vibrator-state {
> +		core-pins {
> +			pins = "gpio27";
> +			function = "gp1_clk";
> +			drive-strength = <6>;
> +			bias-disable;
> +		};
> +
> +		enable-pins {
> +			pins = "gpio60";
> +			function = "gpio";
> +			drive-strength = <2>;
> +			bias-disable;
> +		};
> +	};
>   };
>   
>   &usb {
>
Konrad Dybcio May 2, 2023, 10:40 a.m. UTC | #3
On 27.04.2023 22:34, Luca Weiss wrote:
> The Nexus 5 has a vibrator connected to the clock output of GP1_CLK
> which we can use with the clk-pwm driver, then we can use that pwm with
> pwm-vibrator to get haptics functionality.
> 
> This patch is based on Brian Masney's previous patch with clk-vibrator.
> 
> Signed-off-by: Luca Weiss <luca@z3ntu.xyz>
> ---
>  .../dts/qcom-msm8974-lge-nexus5-hammerhead.dts     | 35 ++++++++++++++++++++++
>  1 file changed, 35 insertions(+)
> 
> diff --git a/arch/arm/boot/dts/qcom-msm8974-lge-nexus5-hammerhead.dts b/arch/arm/boot/dts/qcom-msm8974-lge-nexus5-hammerhead.dts
> index ab35f2d644c0..fea8a6be9021 100644
> --- a/arch/arm/boot/dts/qcom-msm8974-lge-nexus5-hammerhead.dts
> +++ b/arch/arm/boot/dts/qcom-msm8974-lge-nexus5-hammerhead.dts
> @@ -41,6 +41,25 @@ key-volume-down {
>  		};
>  	};
>  
> +	clk_pwm: pwm {
> +		compatible = "clk-pwm";
> +		clocks = <&mmcc CAMSS_GP1_CLK>;
Are you sure it's <&mmcc CAMSS_GP1_CLK> and not <&gcc GCC_GP1_CLK>?

Konrad
> +
> +		pinctrl-0 = <&vibrator_pin>;
> +		pinctrl-names = "default";
> +
> +		#pwm-cells = <2>;
> +	};
> +
> +	vibrator {
> +		compatible = "pwm-vibrator";
> +		pwms = <&clk_pwm 0 100000>;
> +		pwm-names = "enable";
> +
> +		vcc-supply = <&pm8941_l19>;
> +		enable-gpios = <&tlmm 60 GPIO_ACTIVE_HIGH>;
> +	};
> +
>  	vreg_wlan: wlan-regulator {
>  		compatible = "regulator-fixed";
>  
> @@ -637,6 +656,22 @@ shutdown-pins {
>  			function = "gpio";
>  		};
>  	};
> +
> +	vibrator_pin: vibrator-state {
> +		core-pins {
> +			pins = "gpio27";
> +			function = "gp1_clk";
> +			drive-strength = <6>;
> +			bias-disable;
> +		};
> +
> +		enable-pins {
> +			pins = "gpio60";
> +			function = "gpio";
> +			drive-strength = <2>;
> +			bias-disable;
> +		};
> +	};
>  };
>  
>  &usb {
>
Luca Weiss May 2, 2023, 3:28 p.m. UTC | #4
On Dienstag, 2. Mai 2023 12:40:40 CEST Konrad Dybcio wrote:
> On 27.04.2023 22:34, Luca Weiss wrote:
> > The Nexus 5 has a vibrator connected to the clock output of GP1_CLK
> > which we can use with the clk-pwm driver, then we can use that pwm with
> > pwm-vibrator to get haptics functionality.
> > 
> > This patch is based on Brian Masney's previous patch with clk-vibrator.
> > 
> > Signed-off-by: Luca Weiss <luca@z3ntu.xyz>
> > ---
> > 
> >  .../dts/qcom-msm8974-lge-nexus5-hammerhead.dts     | 35
> >  ++++++++++++++++++++++ 1 file changed, 35 insertions(+)
> > 
> > diff --git a/arch/arm/boot/dts/qcom-msm8974-lge-nexus5-hammerhead.dts
> > b/arch/arm/boot/dts/qcom-msm8974-lge-nexus5-hammerhead.dts index
> > ab35f2d644c0..fea8a6be9021 100644
> > --- a/arch/arm/boot/dts/qcom-msm8974-lge-nexus5-hammerhead.dts
> > +++ b/arch/arm/boot/dts/qcom-msm8974-lge-nexus5-hammerhead.dts
> > @@ -41,6 +41,25 @@ key-volume-down {
> > 
> >  		};
> >  	
> >  	};
> > 
> > +	clk_pwm: pwm {
> > +		compatible = "clk-pwm";
> > +		clocks = <&mmcc CAMSS_GP1_CLK>;
> 
> Are you sure it's <&mmcc CAMSS_GP1_CLK> and not <&gcc GCC_GP1_CLK>?

Quite sure.

The driver uses:

	cam_gp1_clk = clk_get(&pdev->dev, "cam_gp1_clk");

and this comes from the clock-8974.c driver

	CLK_LOOKUP("cam_gp1_clk", camss_gp1_clk.c, "vibrator"),

Regards
Luca

> 
> Konrad
> 
> > +
> > +		pinctrl-0 = <&vibrator_pin>;
> > +		pinctrl-names = "default";
> > +
> > +		#pwm-cells = <2>;
> > +	};
> > +
> > +	vibrator {
> > +		compatible = "pwm-vibrator";
> > +		pwms = <&clk_pwm 0 100000>;
> > +		pwm-names = "enable";
> > +
> > +		vcc-supply = <&pm8941_l19>;
> > +		enable-gpios = <&tlmm 60 GPIO_ACTIVE_HIGH>;
> > +	};
> > +
> > 
> >  	vreg_wlan: wlan-regulator {
> >  	
> >  		compatible = "regulator-fixed";
> > 
> > @@ -637,6 +656,22 @@ shutdown-pins {
> > 
> >  			function = "gpio";
> >  		
> >  		};
> >  	
> >  	};
> > 
> > +
> > +	vibrator_pin: vibrator-state {
> > +		core-pins {
> > +			pins = "gpio27";
> > +			function = "gp1_clk";
> > +			drive-strength = <6>;
> > +			bias-disable;
> > +		};
> > +
> > +		enable-pins {
> > +			pins = "gpio60";
> > +			function = "gpio";
> > +			drive-strength = <2>;
> > +			bias-disable;
> > +		};
> > +	};
> > 
> >  };
> >  
> >  &usb {
Konrad Dybcio May 2, 2023, 3:31 p.m. UTC | #5
On 2.05.2023 17:28, Luca Weiss wrote:
> On Dienstag, 2. Mai 2023 12:40:40 CEST Konrad Dybcio wrote:
>> On 27.04.2023 22:34, Luca Weiss wrote:
>>> The Nexus 5 has a vibrator connected to the clock output of GP1_CLK
>>> which we can use with the clk-pwm driver, then we can use that pwm with
>>> pwm-vibrator to get haptics functionality.
>>>
>>> This patch is based on Brian Masney's previous patch with clk-vibrator.
>>>
>>> Signed-off-by: Luca Weiss <luca@z3ntu.xyz>
>>> ---
>>>
>>>  .../dts/qcom-msm8974-lge-nexus5-hammerhead.dts     | 35
>>>  ++++++++++++++++++++++ 1 file changed, 35 insertions(+)
>>>
>>> diff --git a/arch/arm/boot/dts/qcom-msm8974-lge-nexus5-hammerhead.dts
>>> b/arch/arm/boot/dts/qcom-msm8974-lge-nexus5-hammerhead.dts index
>>> ab35f2d644c0..fea8a6be9021 100644
>>> --- a/arch/arm/boot/dts/qcom-msm8974-lge-nexus5-hammerhead.dts
>>> +++ b/arch/arm/boot/dts/qcom-msm8974-lge-nexus5-hammerhead.dts
>>> @@ -41,6 +41,25 @@ key-volume-down {
>>>
>>>  		};
>>>  	
>>>  	};
>>>
>>> +	clk_pwm: pwm {
>>> +		compatible = "clk-pwm";
>>> +		clocks = <&mmcc CAMSS_GP1_CLK>;
>>
>> Are you sure it's <&mmcc CAMSS_GP1_CLK> and not <&gcc GCC_GP1_CLK>?
> 
> Quite sure.
> 
> The driver uses:
> 
> 	cam_gp1_clk = clk_get(&pdev->dev, "cam_gp1_clk");
> 
> and this comes from the clock-8974.c driver
> 
> 	CLK_LOOKUP("cam_gp1_clk", camss_gp1_clk.c, "vibrator"),
> 
> Regards
> Luca
ugh that hurts my brain but fine, maybe the camss clock had a
pad closer to the vibrator pcb traces..

Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org>

Konrad
> 
>>
>> Konrad
>>
>>> +
>>> +		pinctrl-0 = <&vibrator_pin>;
>>> +		pinctrl-names = "default";
>>> +
>>> +		#pwm-cells = <2>;
>>> +	};
>>> +
>>> +	vibrator {
>>> +		compatible = "pwm-vibrator";
>>> +		pwms = <&clk_pwm 0 100000>;
>>> +		pwm-names = "enable";
>>> +
>>> +		vcc-supply = <&pm8941_l19>;
>>> +		enable-gpios = <&tlmm 60 GPIO_ACTIVE_HIGH>;
>>> +	};
>>> +
>>>
>>>  	vreg_wlan: wlan-regulator {
>>>  	
>>>  		compatible = "regulator-fixed";
>>>
>>> @@ -637,6 +656,22 @@ shutdown-pins {
>>>
>>>  			function = "gpio";
>>>  		
>>>  		};
>>>  	
>>>  	};
>>>
>>> +
>>> +	vibrator_pin: vibrator-state {
>>> +		core-pins {
>>> +			pins = "gpio27";
>>> +			function = "gp1_clk";
>>> +			drive-strength = <6>;
>>> +			bias-disable;
>>> +		};
>>> +
>>> +		enable-pins {
>>> +			pins = "gpio60";
>>> +			function = "gpio";
>>> +			drive-strength = <2>;
>>> +			bias-disable;
>>> +		};
>>> +	};
>>>
>>>  };
>>>  
>>>  &usb {
> 
> 
> 
>
diff mbox series

Patch

diff --git a/arch/arm/boot/dts/qcom-msm8974-lge-nexus5-hammerhead.dts b/arch/arm/boot/dts/qcom-msm8974-lge-nexus5-hammerhead.dts
index ab35f2d644c0..fea8a6be9021 100644
--- a/arch/arm/boot/dts/qcom-msm8974-lge-nexus5-hammerhead.dts
+++ b/arch/arm/boot/dts/qcom-msm8974-lge-nexus5-hammerhead.dts
@@ -41,6 +41,25 @@  key-volume-down {
 		};
 	};
 
+	clk_pwm: pwm {
+		compatible = "clk-pwm";
+		clocks = <&mmcc CAMSS_GP1_CLK>;
+
+		pinctrl-0 = <&vibrator_pin>;
+		pinctrl-names = "default";
+
+		#pwm-cells = <2>;
+	};
+
+	vibrator {
+		compatible = "pwm-vibrator";
+		pwms = <&clk_pwm 0 100000>;
+		pwm-names = "enable";
+
+		vcc-supply = <&pm8941_l19>;
+		enable-gpios = <&tlmm 60 GPIO_ACTIVE_HIGH>;
+	};
+
 	vreg_wlan: wlan-regulator {
 		compatible = "regulator-fixed";
 
@@ -637,6 +656,22 @@  shutdown-pins {
 			function = "gpio";
 		};
 	};
+
+	vibrator_pin: vibrator-state {
+		core-pins {
+			pins = "gpio27";
+			function = "gp1_clk";
+			drive-strength = <6>;
+			bias-disable;
+		};
+
+		enable-pins {
+			pins = "gpio60";
+			function = "gpio";
+			drive-strength = <2>;
+			bias-disable;
+		};
+	};
 };
 
 &usb {