mbox series

[0/8] Add PMI632 PMIC and RGB LED on sdm632-fairphone-fp3

Message ID 20230414-pmi632-v1-0-fe94dc414832@z3ntu.xyz
Headers show
Series Add PMI632 PMIC and RGB LED on sdm632-fairphone-fp3 | expand

Message

Luca Weiss April 13, 2023, 11:17 p.m. UTC
Add support for the PMI632 PMIC in the spmi-gpio & qcom-lpg driver, add
the dtsi for the PMIC and enable the notification LED on fairphone-fp3.

Signed-off-by: Luca Weiss <luca@z3ntu.xyz>
---
Luca Weiss (8):
      dt-bindings: pinctrl: qcom,pmic-gpio: add PMI632
      pinctrl: qcom: spmi-gpio: Add PMI632 support
      dt-bindings: leds: qcom-lpg: Add compatible for PMI632 LPG block
      leds: qcom-lpg: Add support for PMI632 LPG
      dt-bindings: iio: adc: qcom,spmi-vadc: Allow 1/16 for pre-scaling
      dt-bindings: mfd: qcom-spmi-pmic: Add PMI632 compatible
      arm64: dts: qcom: Add PMI632 PMIC
      arm64: dts: qcom: sdm632-fairphone-fp3: Add notification LED

 .../bindings/iio/adc/qcom,spmi-vadc.yaml           |   2 +-
 .../devicetree/bindings/leds/leds-qcom-lpg.yaml    |   1 +
 .../devicetree/bindings/mfd/qcom,spmi-pmic.yaml    |   1 +
 .../bindings/pinctrl/qcom,pmic-gpio.yaml           |   2 +
 arch/arm64/boot/dts/qcom/pmi632.dtsi               | 165 +++++++++++++++++++++
 arch/arm64/boot/dts/qcom/sdm632-fairphone-fp3.dts  |  29 ++++
 drivers/leds/rgb/leds-qcom-lpg.c                   |  15 ++
 drivers/pinctrl/qcom/pinctrl-spmi-gpio.c           |   1 +
 8 files changed, 215 insertions(+), 1 deletion(-)
---
base-commit: c83fb1e4acf528c29b0729525cf23544f8121b3d
change-id: 20230414-pmi632-4ae03225ae75

Best regards,

Comments

Konrad Dybcio April 13, 2023, 11:27 p.m. UTC | #1
On 14.04.2023 01:17, Luca Weiss wrote:
> Add support for the 8 GPIOs found on PMI632.
> 
> Signed-off-by: Luca Weiss <luca@z3ntu.xyz>
> ---
As I've started doing more and more lately, I'll hijack this
patch to discuss the general approach..

I have a feeling that you'll get some comments about
this match list growing, especially since the driver data
is already filled in dt (gpio-ranges).. perhaps we can improve
this..

Especially considering the "qcom,spmi-gpio" fallback is there
(unless we care about 2015 DTs like 0804308fdd3c) that are
unlikely to still work nowadays. Old DTs also used interrupts=<>
to list out all the GPIOs (among the other SPMI fluff) individually
(see e.g. 5f540fb4821a).

Krzysztof, WDYT? Would it be worth taking all of that old junk into
account, or should we keep it as-is?

Konrad
>  drivers/pinctrl/qcom/pinctrl-spmi-gpio.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/pinctrl/qcom/pinctrl-spmi-gpio.c b/drivers/pinctrl/qcom/pinctrl-spmi-gpio.c
> index ea3485344f06..40cab13e5a83 100644
> --- a/drivers/pinctrl/qcom/pinctrl-spmi-gpio.c
> +++ b/drivers/pinctrl/qcom/pinctrl-spmi-gpio.c
> @@ -1232,6 +1232,7 @@ static const struct of_device_id pmic_gpio_of_match[] = {
>  	{ .compatible = "qcom,pm8994-gpio", .data = (void *) 22 },
>  	{ .compatible = "qcom,pm8998-gpio", .data = (void *) 26 },
>  	{ .compatible = "qcom,pma8084-gpio", .data = (void *) 22 },
> +	{ .compatible = "qcom,pmi632-gpio", .data = (void *) 8 },
>  	{ .compatible = "qcom,pmi8950-gpio", .data = (void *) 2 },
>  	{ .compatible = "qcom,pmi8994-gpio", .data = (void *) 10 },
>  	{ .compatible = "qcom,pmi8998-gpio", .data = (void *) 14 },
>
Konrad Dybcio April 13, 2023, 11:33 p.m. UTC | #2
On 14.04.2023 01:17, Luca Weiss wrote:
> The PMI632 PMIC contains 5 PWM channels, 3 of which can be used for
> LEDs.
> 
> For the LED pattern it doesn't have LUT like other PMICs but uses SDAM
> instead. This is not currently implemented in the driver but since LPG
> works fine without it, add support for the PMIC now.
> 
> Signed-off-by: Luca Weiss <luca@z3ntu.xyz>
> ---
Matches everything i see in 4.19!

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

Konrad
>  drivers/leds/rgb/leds-qcom-lpg.c | 15 +++++++++++++++
>  1 file changed, 15 insertions(+)
> 
> diff --git a/drivers/leds/rgb/leds-qcom-lpg.c b/drivers/leds/rgb/leds-qcom-lpg.c
> index 67f48f222109..51763ecb8c1e 100644
> --- a/drivers/leds/rgb/leds-qcom-lpg.c
> +++ b/drivers/leds/rgb/leds-qcom-lpg.c
> @@ -1353,6 +1353,20 @@ static const struct lpg_data pm8994_lpg_data = {
>  	},
>  };
>  
> +/* PMI632 uses SDAM instead of LUT for pattern */
> +static const struct lpg_data pmi632_lpg_data = {
> +	.triled_base = 0xd000,
> +
> +	.num_channels = 5,
> +	.channels = (const struct lpg_channel_data[]) {
> +		{ .base = 0xb300, .triled_mask = BIT(7) },
> +		{ .base = 0xb400, .triled_mask = BIT(6) },
> +		{ .base = 0xb500, .triled_mask = BIT(5) },
> +		{ .base = 0xb600 },
> +		{ .base = 0xb700 },
> +	},
> +};
> +
>  static const struct lpg_data pmi8994_lpg_data = {
>  	.lut_base = 0xb000,
>  	.lut_size = 24,
> @@ -1436,6 +1450,7 @@ static const struct of_device_id lpg_of_table[] = {
>  	{ .compatible = "qcom,pm8916-pwm", .data = &pm8916_pwm_data },
>  	{ .compatible = "qcom,pm8941-lpg", .data = &pm8941_lpg_data },
>  	{ .compatible = "qcom,pm8994-lpg", .data = &pm8994_lpg_data },
> +	{ .compatible = "qcom,pmi632-lpg", .data = &pmi632_lpg_data },
>  	{ .compatible = "qcom,pmi8994-lpg", .data = &pmi8994_lpg_data },
>  	{ .compatible = "qcom,pmi8998-lpg", .data = &pmi8998_lpg_data },
>  	{ .compatible = "qcom,pmc8180c-lpg", .data = &pm8150l_lpg_data },
>
Konrad Dybcio April 13, 2023, 11:36 p.m. UTC | #3
On 14.04.2023 01:17, Luca Weiss wrote:
> The phone features a notification LED connected to the pmi632. Configure
> the RGB led found on it.
> 
> Signed-off-by: Luca Weiss <luca@z3ntu.xyz>
> ---
>  arch/arm64/boot/dts/qcom/sdm632-fairphone-fp3.dts | 29 +++++++++++++++++++++++
>  1 file changed, 29 insertions(+)
> 
> diff --git a/arch/arm64/boot/dts/qcom/sdm632-fairphone-fp3.dts b/arch/arm64/boot/dts/qcom/sdm632-fairphone-fp3.dts
> index 70e683b7e4fc..301eca9a4f31 100644
> --- a/arch/arm64/boot/dts/qcom/sdm632-fairphone-fp3.dts
> +++ b/arch/arm64/boot/dts/qcom/sdm632-fairphone-fp3.dts
> @@ -4,8 +4,10 @@
>   */
>  /dts-v1/;
>  
> +#include <dt-bindings/leds/common.h>
>  #include "sdm632.dtsi"
>  #include "pm8953.dtsi"
> +#include "pmi632.dtsi"
>  
>  / {
>  	model = "Fairphone 3";
> @@ -83,6 +85,33 @@ &pm8953_resin {
>  	linux,code = <KEY_VOLUMEDOWN>;
>  };
>  
> +&pmi632_lpg {
qcom,power-source?

Konrad
> +	status = "okay";
> +
> +	multi-led {
> +		color = <LED_COLOR_ID_RGB>;
> +		function = LED_FUNCTION_STATUS;
> +
> +		#address-cells = <1>;
> +		#size-cells = <0>;
> +
> +		led@1 {
> +			reg = <1>;
> +			color = <LED_COLOR_ID_RED>;
> +		};
> +
> +		led@2 {
> +			reg = <2>;
> +			color = <LED_COLOR_ID_GREEN>;
> +		};
> +
> +		led@3 {
> +			reg = <3>;
> +			color = <LED_COLOR_ID_BLUE>;
> +		};
> +	};
> +};
> +
>  &sdhc_1 {
>  	status = "okay";
>  	vmmc-supply = <&pm8953_l8>;
>
Krzysztof Kozlowski April 14, 2023, 7:56 a.m. UTC | #4
On 14/04/2023 01:17, Luca Weiss wrote:
> The channel ADC5_USB_IN_V_16 is using 1/16 pre-scaling on at least
> pm7250b and pmi632. Allow that in the schema.
> 
> Signed-off-by: Luca Weiss <luca@z3ntu.xyz>
> ---
>  Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 


Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>

Best regards,
Krzysztof
Krzysztof Kozlowski April 14, 2023, 7:56 a.m. UTC | #5
On 14/04/2023 01:17, Luca Weiss wrote:
> Document support for the pmi632, often found with the sdm632 SoC.
> 
> Signed-off-by: Luca Weiss <luca@z3ntu.xyz>
> ---
>  Documentation/devicetree/bindings/mfd/qcom,spmi-pmic.yaml | 1 +

Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>

Best regards,
Krzysztof
Pavel Machek April 14, 2023, 12:22 p.m. UTC | #6
On Fri 2023-04-14 01:17:48, Luca Weiss wrote:
> The PMI632 PMIC contains 5 PWM channels, 3 of which can be used for
> LEDs.
> 
> For the LED pattern it doesn't have LUT like other PMICs but uses SDAM
> instead. This is not currently implemented in the driver but since LPG
> works fine without it, add support for the PMIC now.
> 
> Signed-off-by: Luca Weiss <luca@z3ntu.xyz>

Acked-by: Pavel Machek <pavel@ucw.cz>
Pavel Machek April 14, 2023, 12:24 p.m. UTC | #7
On Fri 2023-04-14 01:17:52, Luca Weiss wrote:
> The phone features a notification LED connected to the pmi632. Configure
> the RGB led found on it.

Could you document the usage in Documentation/leds/well-known-leds.txt
so that all phones share the same name for the RGB notification LED?

Thanks,
								Pavel
Pavel Machek April 14, 2023, 12:26 p.m. UTC | #8
On Fri 2023-04-14 01:17:50, Luca Weiss wrote:
> Document support for the pmi632, often found with the sdm632 SoC.
> 
> Signed-off-by: Luca Weiss <luca@z3ntu.xyz>

5,6: Acked-by: Pavel Machek <pavel@ucw.cz>
Luca Weiss April 14, 2023, 3:48 p.m. UTC | #9
On Freitag, 14. April 2023 14:24:06 CEST Pavel Machek wrote:
> On Fri 2023-04-14 01:17:52, Luca Weiss wrote:
> > The phone features a notification LED connected to the pmi632. Configure
> > the RGB led found on it.
> 
> Could you document the usage in Documentation/leds/well-known-leds.txt
> so that all phones share the same name for the RGB notification LED?

This dts results in /sys/class/leds/rgb:status like (presumably) all of these 
existing in-tree users:
* qcom-msm8974-lge-nexus5-hammerhead.dts
* qcom-msm8974-sony-xperia-rhine.dtsi
* qcom-msm8974pro-fairphone-fp2.dts
* qcom-msm8974pro-sony-xperia-shinano-castor.dts
* freescale/imx8mq-librem5.dtsi
* qcom/msm8996-xiaomi-common.dtsi
* qcom/sdm630-sony-xperia-nile.dtsi
* qcom/sdm845-shift-axolotl.dts

However I can send a patch adding it to this txt doc since it doesn't seem to 
be there yet.

Regards
Luca

> 
> Thanks,
> 								
Pavel
Luca Weiss April 14, 2023, 3:49 p.m. UTC | #10
On Freitag, 14. April 2023 01:36:38 CEST Konrad Dybcio wrote:
> On 14.04.2023 01:17, Luca Weiss wrote:
> > The phone features a notification LED connected to the pmi632. Configure
> > the RGB led found on it.
> > 
> > Signed-off-by: Luca Weiss <luca@z3ntu.xyz>
> > ---
> > 
> >  arch/arm64/boot/dts/qcom/sdm632-fairphone-fp3.dts | 29
> >  +++++++++++++++++++++++ 1 file changed, 29 insertions(+)
> > 
> > diff --git a/arch/arm64/boot/dts/qcom/sdm632-fairphone-fp3.dts
> > b/arch/arm64/boot/dts/qcom/sdm632-fairphone-fp3.dts index
> > 70e683b7e4fc..301eca9a4f31 100644
> > --- a/arch/arm64/boot/dts/qcom/sdm632-fairphone-fp3.dts
> > +++ b/arch/arm64/boot/dts/qcom/sdm632-fairphone-fp3.dts
> > @@ -4,8 +4,10 @@
> > 
> >   */
> >  
> >  /dts-v1/;
> > 
> > +#include <dt-bindings/leds/common.h>
> > 
> >  #include "sdm632.dtsi"
> >  #include "pm8953.dtsi"
> > 
> > +#include "pmi632.dtsi"
> > 
> >  / {
> >  
> >  	model = "Fairphone 3";
> > 
> > @@ -83,6 +85,33 @@ &pm8953_resin {
> > 
> >  	linux,code = <KEY_VOLUMEDOWN>;
> >  
> >  };
> > 
> > +&pmi632_lpg {
> 
> qcom,power-source?

This property is only used if triled_has_src_sel is set in the driver (which 
it isn't on pmi632), only on pm8941 & pmi8994 it is set.

Regards
Luca

> 
> Konrad
> 
> > +	status = "okay";
> > +
> > +	multi-led {
> > +		color = <LED_COLOR_ID_RGB>;
> > +		function = LED_FUNCTION_STATUS;
> > +
> > +		#address-cells = <1>;
> > +		#size-cells = <0>;
> > +
> > +		led@1 {
> > +			reg = <1>;
> > +			color = <LED_COLOR_ID_RED>;
> > +		};
> > +
> > +		led@2 {
> > +			reg = <2>;
> > +			color = <LED_COLOR_ID_GREEN>;
> > +		};
> > +
> > +		led@3 {
> > +			reg = <3>;
> > +			color = <LED_COLOR_ID_BLUE>;
> > +		};
> > +	};
> > +};
> > +
> > 
> >  &sdhc_1 {
> >  
> >  	status = "okay";
> >  	vmmc-supply = <&pm8953_l8>;
Jonathan Cameron April 15, 2023, 4:20 p.m. UTC | #11
On Fri, 14 Apr 2023 09:56:07 +0200
Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> wrote:

> On 14/04/2023 01:17, Luca Weiss wrote:
> > The channel ADC5_USB_IN_V_16 is using 1/16 pre-scaling on at least
> > pm7250b and pmi632. Allow that in the schema.
> > 
> > Signed-off-by: Luca Weiss <luca@z3ntu.xyz>
> > ---
> >  Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >   
> 
> 
> Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
> 
> Best regards,
> Krzysztof
> 

Applied this patch to the IIO togreg branch initially pushed out as testing
for 0-day to poke at it.

I'm doubtful this one will make the upcoming merge window but seems unlikely
the rest will all make it either so that shouldn't be a problem.

Jonathan