mbox series

[RFC,0/3] Add support for the flash LED on Nexus 5

Message ID 20201106165737.1029106-1-nfraprado@protonmail.com
Headers show
Series Add support for the flash LED on Nexus 5 | expand

Message

NĂ­colas F. R. A. Prado Nov. 6, 2020, 4:58 p.m. UTC
Hi,

this patch series adds support for the flash LED on Nexus 5.

The first patch adds the driver for the QPNP flash LED. The code for the driver
was ported from [1], which was for the 3.4 kernel. That driver originally
supported multiple LED types: WLED, Flash/Torch, RGB, MPP and KPDBL as described
in [2], but this port only contains support for Flash/Torch, and the code for
the others was removed just because it was easier to test. Also, it was
originally an SPMI driver, but here I made it into a platform driver that
matches an SPMI device and uses regmap to read and write on the addresses.

The second patch adds the driver as a module in qcom's defconfig, which is the
one used by the Nexus 5.

The third patch adds the relevant nodes to Nexus 5's device tree. These nodes
were copied from [3] and [4], only changing the flash-boost-supply and
torch-boost-supply properties to point to the regulator nodes already defined
upstream at qcom-pm8941.dtsi. Again, I'm not sure if the nodes should be kept on
separate .dtsi as they were downstream, I just did what was easier for testing.

The flash LED can be tested on a Nexus 5 with the following:

To turn the LED on:
echo 1 > /sys/class/leds/led\:flash_torch/brightness

To turn the LED on only for a couple seconds:
echo 1 > /sys/class/leds/led\:flash_0/brightness

Comments

Bjorn Andersson Nov. 22, 2020, 4:44 a.m. UTC | #1
On Fri 06 Nov 10:58 CST 2020, N?colas F. R. A. Prado wrote:

> Add driver for the QPNP flash LED. It works over SPMI and is part of the
> PM8941 PMIC.
> 
> Signed-off-by: NĂ­colas F. R. A. Prado <nfraprado@protonmail.com>
> ---
>  drivers/leds/Kconfig     |    9 +
>  drivers/leds/Makefile    |    1 +
>  drivers/leds/leds-qpnp.c | 1351 ++++++++++++++++++++++++++++++++++++++
>  3 files changed, 1361 insertions(+)
>  create mode 100644 drivers/leds/leds-qpnp.c
> 
> diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig
> index 849d3c5f908e..ca5f6e81c064 100644
> --- a/drivers/leds/Kconfig
> +++ b/drivers/leds/Kconfig
> @@ -928,6 +928,15 @@ config LEDS_ACER_A500
>  	  This option enables support for the Power Button LED of
>  	  Acer Iconia Tab A500.
>  
> +config LEDS_QPNP
> +	tristate "Support for QPNP LEDs"
> +	depends on SPMI
> +	help
> +	  This driver supports the flash/torch led of Qualcomm PNP PMIC.
> +
> +	  To compile this driver as a module, choose M here: the module will
> +	  be called leds-qpnp.
> +

Downstream they seem to have a single "led driver" dealing with all the
LED related interfaces in the PMIC. We have WLED upstream already and
I've been poking at an "LPG" driver.

So as you look into Jacek's request please make this a "qcom spmi flash
driver", instead of a "qpnp leds" driver.

Regards,
Bjorn