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
From what I understand flash and torch correspond to the same LED, but flash
only stays on for a couple seconds and uses a different voltage regulator.
I'm not sure why there are both flash_0 and flash_1. Both seem to do the same.
My questions are: Is there something fundamentally wrong with this patch series?
Is it okay to have the driver only support the flash LEDs from QPNP (at least
for the time being)?
But also please give me any other feedback.
Thanks,
Nícolas
[1] https://github.com/AICP/kernel_lge_hammerhead/blob/n7.1/drivers/leds/leds-qpnp.c
[2] https://github.com/AICP/kernel_lge_hammerhead/blob/n7.1/Documentation/devicetree/bindings/leds/leds-qpnp.txt
[3] https://github.com/AICP/kernel_lge_hammerhead/blob/n7.1/arch/arm/boot/dts/msm-pm8941.dtsi
[4] https://github.com/AICP/kernel_lge_hammerhead/blob/n7.1/arch/arm/boot/dts/msm8974-leds.dtsi
My tree: https://gitlab.com/nfraprado/linux/
Nícolas F. R. A. Prado (3):
leds: Add driver for QPNP flash led
ARM: qcom_defconfig: Add QPNP flash LED support
ARM: dts: qcom: msm8974-hammerhead: Add support for the flash LED
.../qcom-msm8974-lge-nexus5-hammerhead.dts | 56 +
arch/arm/configs/qcom_defconfig | 1 +
drivers/leds/Kconfig | 9 +
drivers/leds/Makefile | 1 +
drivers/leds/leds-qpnp.c | 1351 +++++++++++++++++
5 files changed, 1418 insertions(+)
create mode 100644 drivers/leds/leds-qpnp.c
--
2.29.2
Add the necessary device tree nodes for the flash LED.
Signed-off-by: Nícolas F. R. A. Prado <[email protected]>
---
.../qcom-msm8974-lge-nexus5-hammerhead.dts | 56 +++++++++++++++++++
1 file changed, 56 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 32b474bfeec3..6aa93c236178 100644
--- a/arch/arm/boot/dts/qcom-msm8974-lge-nexus5-hammerhead.dts
+++ b/arch/arm/boot/dts/qcom-msm8974-lge-nexus5-hammerhead.dts
@@ -730,4 +730,60 @@ otg {
};
};
};
+ pm8941@1 {
+ qcom,leds@d300 {
+ status = "ok";
+
+ compatible = "qcom,leds-qpnp";
+ reg = <0xd300 0x100>;
+ label = "flash";
+ flash-boost-supply = <&pm8941_5vs1>;
+ torch-boost-supply = <&pm8941_5v>;
+ pm8941_flash0: qcom,flash_0 {
+ qcom,max-current = <1000>;
+ qcom,default-state = "off";
+ qcom,headroom = <3>;
+ qcom,duration = <1280>;
+ qcom,clamp-curr = <200>;
+ qcom,startup-dly = <3>;
+ qcom,safety-timer;
+ label = "flash";
+ linux,default-trigger =
+ "flash0_trigger";
+ qcom,id = <1>;
+ linux,name = "led:flash_0";
+ qcom,current = <620>;
+ };
+
+ pm8941_flash1: qcom,flash_1 {
+ qcom,max-current = <1000>;
+ qcom,default-state = "off";
+ qcom,headroom = <3>;
+ qcom,duration = <1280>;
+ qcom,clamp-curr = <200>;
+ qcom,startup-dly = <3>;
+ qcom,safety-timer;
+ linux,default-trigger =
+ "flash1_trigger";
+ label = "flash";
+ qcom,id = <2>;
+ linux,name = "led:flash_1";
+ qcom,current = <620>;
+ };
+
+ pm8941_torch: qcom,flash_torch {
+ qcom,max-current = <200>;
+ qcom,default-state = "off";
+ qcom,headroom = <0>;
+ qcom,startup-dly = <1>;
+ linux,default-trigger =
+ "torch_trigger";
+ label = "flash";
+ qcom,id = <2>;
+ linux,name = "led:flash_torch";
+ qcom,current = <90>;
+ qcom,torch-enable;
+ };
+ };
+ };
};
--
2.29.2