[PATCH] arm64: dts: qcom: msm8917-xiaomi-wingtech: enable flash LED

Martin posted 1 patch 1 week, 5 days ago
.../dts/qcom/msm8917-xiaomi-wingtech.dtsi     | 23 +++++++++++++++++++
1 file changed, 23 insertions(+)
[PATCH] arm64: dts: qcom: msm8917-xiaomi-wingtech: enable flash LED
Posted by Martin 1 week, 5 days ago
From: hemisputnik <hemisputnik@proton.me>

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).

Signed-off-by: hemisputnik <hemisputnik@proton.me>
---
 .../dts/qcom/msm8917-xiaomi-wingtech.dtsi     | 23 +++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/arch/arm64/boot/dts/qcom/msm8917-xiaomi-wingtech.dtsi b/arch/arm64/boot/dts/qcom/msm8917-xiaomi-wingtech.dtsi
index 69eda5f42c06..c0b5094efced 100644
--- a/arch/arm64/boot/dts/qcom/msm8917-xiaomi-wingtech.dtsi
+++ b/arch/arm64/boot/dts/qcom/msm8917-xiaomi-wingtech.dtsi
@@ -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 {
-- 
2.55.0
Re: [PATCH] arm64: dts: qcom: msm8917-xiaomi-wingtech: enable flash LED
Posted by Konrad Dybcio 1 week, 4 days ago
On 9/12/26 3:41 PM, Martin wrote:
> From: hemisputnik <hemisputnik@proton.me>
> 
> Add SGM3780 flash LED controller to msm8917-xiaomi-wingtech device tree.

[...]

> +	flash-led-controller {

Please sort this entry alphabetically vs other nodes in the same scope

> +		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;

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