arm64: dts: qcom: msm8917-xiaomi-wingtech: enable flash LED
PATCH 1/1 arm64: dts: qcom: msm8917-xiaomi-wingtech: enable flash LED
From: hemisputnik <[email protected]>
Add SGM3780 flash LED controller to msm8917-xiaomi-wingtech device tree.
Although the devices this device tree describes have a SGM3780, the existing driver for SGM3140 is compatible with it, hence why there is a fallback for it.
While there is no camera suppport in the device tree at the moment, having this allows using the LED as a torch.
Tested on Xiaomi Redmi 5A (xiaomi-riva).
--- .../dts/qcom/msm8917-xiaomi-wingtech.dtsi | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+)
arch/arm64/boot/dts/qcom/msm8917-xiaomi-wingtech.dtsi +23 -0
@@ -7,6 +7,7 @@ #include <dt-bindings/arm/qcom,ids.h> #include <dt-bindings/gpio/gpio.h> +#include <dt-bindings/leds/common.h> #include "msm8917.dtsi" #include "pm8937.dtsi"
@@ -25,6 +26,20 @@ pwm_backlight: backlight { default-brightness-level = <128>; }; + flash-led-controller { + compatible = "sgmicro,sgm3780", "sgmicro,sgm3140"; + enable-gpios = <&tlmm 93 GPIO_ACTIVE_HIGH>; + flash-gpios = <&tlmm 90 GPIO_ACTIVE_HIGH>; + + pinctrl-0 = <&flash_led_default>; + pinctrl-names = "default"; + + led { + function = LED_FUNCTION_FLASH; + color = <LED_COLOR_ID_WHITE>; + }; + }; + chosen { #address-cells = <2>; #size-cells = <2>;
@@ -306,6 +321,14 @@ tsp_int_rst_default: tsp-int-rst-default-state { drive-strength = <8>; bias-pull-up; }; + + flash_led_default: flash-led-default-state { + pins = "gpio90", "gpio93"; + function = "gpio"; + drive-strength = <2>; + bias-disable; + output-high; + }; }; &wcnss {
Signature · 1 line
2.55.0
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider: - [High] Setting 'output-high' in the pinctrl default state drives the flash LED pins high, turning on the…
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [High] Setting 'output-high' in the pinctrl default state drives the flash LED pins high, turning on the LED at maximum brightness during boot and bypassing safety timeouts.
- [Low] The new compatible string "sgmicro,sgm3780" is used but not documented in the YAML bindings.
- [Low] Missing flash-max-timeout-us property causes an unconditional kernel warning on boot.
--
commit 900520fbc3c9b249fa3d066d01078e01c28af4a8
Author: hemisputnik <[email protected]>
arm64: dts: qcom: msm8917-xiaomi-wingtech: enable flash LED
This commit adds the SGM3780 flash LED controller to the msm8917-xiaomi-wingtech device tree. It falls back to the existing sgm3140 driver compatibility to enable torch functionality.
Quoted 4 lines
arch/arm64/boot/dts/qcom/msm8917-xiaomi-wingtech.dtsi +0
-0
[ ... ]
arch/arm64/boot/dts/qcom/msm8917-xiaomi-wingtech.dtsi pwm_backlight: backlight { · line 30
Quoted 6 lines
arch/arm64/boot/dts/qcom/msm8917-xiaomi-wingtech.dtsi +2
-0@@ -25,6 +26,20 @@ pwm_backlight: backlight { default-brightness-level = <128>; }; + flash-led-controller { + compatible = "sgmicro,sgm3780", "sgmicro,sgm3140";
[Severity: Low]
Will make dtbs_check fail with this change? The new compatible string "sgmicro,sgm3780" doesn't appear to be documented in the YAML bindings yet.
arch/arm64/boot/dts/qcom/msm8917-xiaomi-wingtech.dtsi pwm_backlight: backlight { · line 39
Quoted 9 lines
arch/arm64/boot/dts/qcom/msm8917-xiaomi-wingtech.dtsi +9
-0+ enable-gpios = <&tlmm 93 GPIO_ACTIVE_HIGH>; + flash-gpios = <&tlmm 90 GPIO_ACTIVE_HIGH>; + + pinctrl-0 = <&flash_led_default>; + pinctrl-names = "default"; + + led { + function = LED_FUNCTION_FLASH; + color = <LED_COLOR_ID_WHITE>;
[Severity: Low]
Will this cause a kernel warning on every boot? The sgm3140 driver expects the flash-max-timeout-us property to be defined in the led child node.
If it is missing, the driver falls back to a default value but emits a dev_warn during probe, which can unnecessarily pollute the kernel log.
Quoted 3 lines
arch/arm64/boot/dts/qcom/msm8917-xiaomi-wingtech.dtsi +3
-0+ }; + }; +
[ ... ]
arch/arm64/boot/dts/qcom/msm8917-xiaomi-wingtech.dtsi tsp_int_rst_default: tsp-int-rst-default-state { · line 330
Quoted 11 lines
arch/arm64/boot/dts/qcom/msm8917-xiaomi-wingtech.dtsi +7
-0@@ -306,6 +321,14 @@ tsp_int_rst_default: tsp-int-rst-default-state { drive-strength = <8>; bias-pull-up; }; + + flash_led_default: flash-led-default-state { + pins = "gpio90", "gpio93"; + function = "gpio"; + drive-strength = <2>; + bias-disable; + output-high;
[Severity: High]
Does configuring output-high here risk permanent hardware damage?
The pinctrl framework applies the flash_led_default state during device binding, which sets the flash-gpios and enable-gpios pins high before the driver probes, or permanently if probing is deferred or fails.
This turns on the flash LED at maximum brightness during boot and bypasses the driver's safety timeouts. Flash LEDs are typically not designed for continuous operation at high brightness and can quickly overheat.
Quoted 2 lines
arch/arm64/boot/dts/qcom/msm8917-xiaomi-wingtech.dtsi +1
-0+ }; };
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Quoted 3 lines · Martin
From: hemisputnik <[email protected]>
Add SGM3780 flash LED controller to msm8917-xiaomi-wingtech device tree.
[...]
arch/arm64/boot/dts/qcom/msm8917-xiaomi-wingtech.dtsi pwm_backlight: backlight { · line 29
Quoted 1 line
arch/arm64/boot/dts/qcom/msm8917-xiaomi-wingtech.dtsi +1
-0+ flash-led-controller {
Please sort this entry alphabetically vs other nodes in the same scope
Quoted 17 lines
arch/arm64/boot/dts/qcom/msm8917-xiaomi-wingtech.dtsi +13
-0+ compatible = "sgmicro,sgm3780", "sgmicro,sgm3140"; + enable-gpios = <&tlmm 93 GPIO_ACTIVE_HIGH>; + flash-gpios = <&tlmm 90 GPIO_ACTIVE_HIGH>; + + pinctrl-0 = <&flash_led_default>; + pinctrl-names = "default"; + + led { + function = LED_FUNCTION_FLASH; + color = <LED_COLOR_ID_WHITE>; + }; + }; + chosen { #address-cells = <2>; #size-cells = <2>;
arch/arm64/boot/dts/qcom/msm8917-xiaomi-wingtech.dtsi tsp_int_rst_default: tsp-int-rst-default-state { · line 330
Quoted 10 lines
arch/arm64/boot/dts/qcom/msm8917-xiaomi-wingtech.dtsi +7
-0@@ -306,6 +321,14 @@ tsp_int_rst_default: tsp-int-rst-default-state { drive-strength = <8>; bias-pull-up; }; + + flash_led_default: flash-led-default-state { + pins = "gpio90", "gpio93"; + function = "gpio"; + drive-strength = <2>; + bias-disable; + output-high;
This essentially says "by default, if the OS doesn't do anything with these pins via drivers, I want the flash to shine", which I believe is rather undesirable.. let's drop the output-high line
Konrad