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

Commit 183d58f5 authored by Kiran Gunda's avatar Kiran Gunda
Browse files

leds: qpnp-flash: Add snapshot of leds-qpnp-flash driver



This is snapshot of the leds-qpnp-flash driver as of msm-4.4
'commit d851b0621739 ("leds: qpnp-flash: Fix Use-after-free(UAF)
for debugfs")'.

Change-Id: I9753ab4e0fee03a957960003efc2941bc48616ac
Signed-off-by: default avatarKiran Gunda <kgunda@codeaurora.org>
parent 0bbf24ae
Loading
Loading
Loading
Loading
+180 −0
Original line number Diff line number Diff line
Qualcomm Technologies Inc. PNP Flash LED

QPNP (Qualcomm Technologies Inc. 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 Inc. 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 95, 105, 115, 125 in C.
- qcom,thermal-derate-rate	: derate rate when module temperature
				reaches threshold. Values should be
				"1_PERCENT", "1P25_PERCENT", "2_PERCENT",
				"2P5_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
- qcom,headroom-sense-ch0-enabled: Boolean type. This configures headroom sensing enablement
				   for LED channel 0
- qcom,headroom-sense-ch1-enabled: Boolean type. This configures headroom sensing enablement
				   for LED channel 1
- qcom,power-detect-enabled	: Boolean type. This enables driver to get maximum flash LED
				  current at current battery level to avoid intensity clamp
				  when battery voltage is low
- qcom,otst2-moduled-enabled	: Boolean type. This enables driver to enable MASK to support
				OTST2 connection.
- qcom,follow-otst2-rb-disabled	: Boolean type. This allows driver to reset/deset module.
				By default, driver resets module. This entry allows driver to
				bypass reset module sequence.
- qcom,die-current-derate-enabled: Boolean type. This enables driver to get maximum flash LED
                                   current, based on PMIC die temperature threshold to
				   avoid significant current derate from hardware. This property
				   is not needed if PMIC is older than PMI8994v2.0.
- qcom,die-temp-vadc		: VADC channel source for flash LED. This property is not
				  needed if PMIC is older than PMI8994v2.0.
- qcom,die-temp-threshold       : Integer type array for PMIC die temperature threshold.
				  Array should have at least one value. Values should be in
				  celcius. This property is not needed if PMIC is older than
				  PMI8994v2.0.
- qcom,die-temp-derate-current	: Integer type arrray for PMIC die temperature derate
				  current. Array should have at least one value. Values
				  should be in mA. This property is not needed if PMIC is older
				  than PMI8994v2.0.

Required properties inside child node. Chile node contains settings for each individual LED.
Each LED hardware needs a node for itself and a switch node to control brightness.
For the purpose of turning on/off LED and better regulator control, "led:switch" node
is introduced. "led:switch" acquires several existing properties from other nodes for
operational simplification. For backward compatibility purpose, switch node can be optional:
- 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.
- qcom,pmic-revid	: PMIC revision id source. This property is needed for PMI8996
			revision check.

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.
- 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. It is required for LED:SWITCH node to handle
		LED used as flash.
- reg<n>	: reg<n> (<n> represents number. eg 0,1,2,..) property is to add support for
		multiple power sources. It includes two properties regulator-name and max-voltage.
		Required property inside regulator node:
		- regulator-name	: This denotes this node is a regulator node and which
					regulator to use.
		Optional property inside regulator node:
		- max-voltage		: This specifies max voltage of regulator. Some switch
					or boost regulator does not need this property.

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>;
		qcom,headroom-sense-ch0-enabled;
		qcom,headroom-sense-ch1-enabled;
		qcom,die-current-derate-enabled;
		qcom,die-temp-vadc = <&pmi8994_vadc>;
		qcom,die-temp-threshold = <85 80 75 70 65>;
		qcom,die-temp-derate-current = <400 800 1200 1600 2000>;
		qcom,pmic-revid = <&pmi8994_revid>;

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

		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>;
			qcom,max-current = <200>;
			reg0 {
				regulator-name =
					 "pm8226_chg_boost";
				max-voltage = <3600000>;
			};
		};

		pm8226_switch: qcom,switch {
			lable = "switch";
			qcom,led-name = "led:switch";
			qcom,default-led-trigger =
					"switch_trigger";
			qcom,id = <2>;
			qcom,current = <625>;
			qcom,duration = <1280>;
			qcom,max-current = <1000>;
			reg0 {
				regulator-name =
					"pm8226_chg_boost";
				max-voltage = <3600000>;
			};
		};
	};
+9 −0
Original line number Diff line number Diff line
@@ -668,6 +668,15 @@ config LEDS_QPNP
	  LEDs in both PWM and light pattern generator (LPG) modes.  For older
	  PMICs, it also supports WLEDs and flash LEDs.

config LEDS_QPNP_FLASH
	tristate "Support for QPNP Flash LEDs"
	depends on LEDS_CLASS && MFD_SPMI_PMIC
	help
	  This driver supports the flash LED functionality of Qualcomm
	  Technologies, Inc. QPNP PMICs.  This driver supports PMICs up through
	  PM8994.  It can configure the flash LED target current for several
	  independent channels.

config LEDS_QPNP_FLASH_V2
	tristate "Support for QPNP V2 Flash LEDs"
	depends on LEDS_CLASS && MFD_SPMI_PMIC
+1 −0
Original line number Diff line number Diff line
@@ -72,6 +72,7 @@ obj-$(CONFIG_LEDS_IS31FL32XX) += leds-is31fl32xx.o
obj-$(CONFIG_LEDS_PM8058)		+= leds-pm8058.o
obj-$(CONFIG_LEDS_MLXCPLD)		+= leds-mlxcpld.o
obj-$(CONFIG_LEDS_QPNP)			+= leds-qpnp.o
obj-$(CONFIG_LEDS_QPNP_FLASH)		+= leds-qpnp-flash.o
obj-$(CONFIG_LEDS_QPNP_FLASH_V2)	+= leds-qpnp-flash-v2.o
obj-$(CONFIG_LEDS_QPNP_WLED)		+= leds-qpnp-wled.o
obj-$(CONFIG_LEDS_QPNP_HAPTICS)	+= leds-qpnp-haptics.o
+2709 −0

File added.

Preview size limit exceeded, changes collapsed.