Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a1159b35 authored by Chun Zhang's avatar Chun Zhang
Browse files

leds: leds-qpnp-flash: create flash LED driver



Add driver for flash LED module which is part of PMIC.
Flash LED supports flash light and torch light for camera
and other userspace apps.

Change-Id: Ie1e2df2995e6acdffa3d183ec924599d9f4b3b6e
Signed-off-by: default avatarChun Zhang <chunz@codeaurora.org>
parent 27dc99b6
Loading
Loading
Loading
Loading
+112 −0
Original line number Diff line number Diff line
Qualcomm Technologies PNP Flash LED

QPNP (Qualcomm Technologies Plug N Play) Flash LED (Light
Emitting Diode) driver is used to provide illumination to
camera sensor when background light is dim to capture good
picture. It can also be used for flashlight/torch application.
It is part of PMIC on Qualcomm Technologies reference platforms.
The PMIC is connected to the host processor via SPMI bus.

Required properties:
- compatible		: should be "qcom,qpnp-flash-led"
- reg			: base address and size for flash LED modules

Optional properties:
- qcom,headroom		: headroom to use. Values should be 250, 300,
			  400 and 500 in mV.
- qcom,startup-dly	: delay before flashing after flash executed.
			  Values should 10, 32, 64, and 128 in us.
- qcom,clamp-curr	: current to clamp at when voltage droop happens.
			  Values are in integer from 0 to 1000 inclusive,
			  indicating 0 to 1000 mA.
- qcom,self-check-enabled : boolean type. self fault check enablement
- qcom,thermal-derate-enabled : boolean type. derate enablement when module
				temperature reaches threshold
- qcom,thermal-derate-threshold : thermal threshold for derate. Values
				should be 80, 90, 100, 110, 120, 130 in C.
- qcom,thermal-derate-rate	: derate rate when module temperature
				reaches threshold. Values should be
				"2_PERCENT", "2P5_PERCENT", "4_PERCENT",
				"5_PERCENT" in string.
- qcom,current-ramp-enabled	: boolean type. stepped current ramp enablement
- qcom,ramp-up-step		: current ramp up rate. Values should be
				  "0P2US", "0P4US", "0P8US", "1P6US", "3P3US",
				  "6P7US", "13P5US", "27US".
- qcom,ramp-dn-step		: current ramp down rate. Values should be
				  "0P2US", "0P4US", "0P8US", "1P6US", "3P3US",
				  "6P7US", "13P5US", "27US".
- qcom,vph-pwr-droop-enabled	: boolean type. VPH power droop enablement. Enablement
				  allows current clamp when phone power drops below
				  pre-determined threshold
- qcom,vph-pwr-droop-threshold	: VPH power threshold for module to clamp current.
				  Values are 2500 - 3200 in mV with 100 mV steps.
- qcom,vph-pwr-droop-debounce-time : debounce time for module to confirm a voltage
				     droop is happening. Values are 0, 10, 32, 64
				     in us.
- qcom,pmic-charger-support	: Boolean type. This tells if flash utilizes charger boost
				  support

Required properties inside child node. Chile node contains settings for each individual LED:
- label			: type of led that will be used, either "flash" or "torch".
- qcom,led-name		: name of the LED. Accepted values are "led:flash_0",
			  "led:flash_1", "led:torch_0", "led:torch_1"
- qcom,default-led-trigger	: trigger for the camera flash and torch. Accepted values are
				"flash0_trigger", "flash1_trigger", "torch0_trigger", torch1_trigger"
- qcom,id		: enumerated ID for each physical LED. Accepted values are "0",
			  "1", etc..
- qcom,max-current	: maximum current allowed on this LED. Valid values should be
			  integer from 0 to 1000 inclusive, indicating 0 to 1000 mA.

Optional properties inside child node:
- qcom,current		: default current intensity for LED. Accepted values should be
			  integer from 0 t 1000 inclusive, indicating 0 to 1000 mA.
- boost-supply		: flash LED boost power source for flash LED
- qcom,duration		: duration for flash LED. When duration time expires, hardware
			  will turn off flash LED. Values should be from 10 ms to 1280 ms
			  with 10 ms incremental step. Not applicable to torch.

Example:
	qcom,leds@d300 {
		compatible = "qcom,qpnp-flash-led";
		status = "okay";
		reg = <0xd300 0x100>;
		label = "flash";
		qcom,headroom = <500>;
		qcom,startup-dly = <128>;
		qcom,clamp-curr = <200>;
		qcom,pmic-charger-support;
		qcom,self-check-enabled;
		qcom,thermal-derate-enabled;
		qcom,thermal-derate-threshold = <80>;
		qcom,thermal-derate-rate = "4_PERCENT";
		qcom,current-ramp-enabled;
		qcom,ramp_up_step = "27US";
		qcom,ramp_dn_step = "27US";
		qcom,vph-pwr-droop-enabled;
		qcom,vph-pwr-droop-threshold = <3200>;
		qcom,vph-pwr-droop-debounce-time = <10>;

		pm8226_flash0: qcom,flash_0 {
			label = "flash";
			qcom,led-name = "led:flash_0";
			qcom,default-led-trigger =
					"flash0_trigger";
			qcom,max-current = <1000>;
			qcom,duration = <1280>;
			qcom,id = <0>;
			qcom,current = <625>;
			boost-supply = <&pm8226_chg_boost>;
		};

		pm8226_torch: qcom,torch_0 {
			label = "torch";
			qcom,led-name = "led:torch_0";
			qcom,default-led-trigger =
					"torch0_trigger";
			boost-supply = <&pm8226_chg_boost>;
			qcom,max-current = <200>;
			qcom,id = <0>;
			qcom,current = <120>;
		};
	};
+10 −0
Original line number Diff line number Diff line
@@ -297,6 +297,16 @@ config LEDS_QPNP
	  To compile this driver as a module, choose M here: the module will
	  be called leds-qpnp.

config LEDS_QPNP_FLASH
	tristate "Support for QPNP Flash LEDs"
	depends on SPMI && OF_SPMI
	help
	  This driver supports the leds functionality of Qualcomm Technologies
	  PNP PMIC.  It includes Flash Led.

	  To compile this driver as a module, choose M here: the module will
	  be called leds-qpnp-flash.

config LEDS_QPNP_WLED
	tristate "Support for QPNP WLED"
	depends on SPMI && OF_SPMI
+1 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ obj-$(CONFIG_LEDS_COBALT_RAQ) += leds-cobalt-raq.o
obj-$(CONFIG_LEDS_SUNFIRE)		+= leds-sunfire.o
obj-$(CONFIG_LEDS_PCA9532)		+= leds-pca9532.o
obj-$(CONFIG_LEDS_QPNP)			+= leds-qpnp.o
obj-$(CONFIG_LEDS_QPNP_FLASH)		+= leds-qpnp-flash.o
obj-$(CONFIG_LEDS_QPNP_WLED)		+= leds-qpnp-wled.o
obj-$(CONFIG_LEDS_GPIO_REGISTER)	+= leds-gpio-register.o
obj-$(CONFIG_LEDS_GPIO)			+= leds-gpio.o