mirror of
https://github.com/followmsi/android_kernel_google_msm.git
synced 2024-11-06 23:17:41 +00:00
leds: leds-qpnp-flash: add regulator support for torch
Torch mode requires regulator support to work properly and provide an accurate current for LED. Change-Id: I8a13bfd4914f93590391886e89da3155cdad333b Signed-off-by: Chun Zhang <chunz@codeaurora.org>
This commit is contained in:
parent
384894c9b2
commit
f541cc9c3b
2 changed files with 37 additions and 3 deletions
|
@ -61,6 +61,8 @@ 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
|
||||
- boost-voltage-max : maximum voltage for flash LED boost regulator in uV. This attribute is
|
||||
: required if boost-supply is defined.
|
||||
- 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.
|
||||
|
@ -107,6 +109,7 @@ Example:
|
|||
qcom,max-current = <200>;
|
||||
qcom,id = <0>;
|
||||
qcom,current = <120>;
|
||||
boost-voltage-max = <3600000>;
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -140,6 +140,7 @@ struct flash_node_data {
|
|||
struct regulator *boost_regulator;
|
||||
struct work_struct work;
|
||||
struct delayed_work dwork;
|
||||
u32 boost_voltage_max;
|
||||
u16 duration;
|
||||
u16 max_current;
|
||||
u16 current_addr;
|
||||
|
@ -444,12 +445,24 @@ static void qpnp_flash_led_work(struct work_struct *work)
|
|||
flash_node->prgm_current = brightness;
|
||||
|
||||
if (flash_node->boost_regulator && !flash_node->flash_on) {
|
||||
if (regulator_count_voltages(flash_node->boost_regulator)
|
||||
> 0) {
|
||||
rc = regulator_set_voltage(flash_node->boost_regulator,
|
||||
flash_node->boost_voltage_max,
|
||||
flash_node->boost_voltage_max);
|
||||
if (rc) {
|
||||
dev_err(&led->spmi_dev->dev,
|
||||
"boost regulator set voltage failed\n");
|
||||
mutex_unlock(&led->flash_led_lock);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
rc = regulator_enable(flash_node->boost_regulator);
|
||||
if (rc) {
|
||||
dev_err(&led->spmi_dev->dev,
|
||||
"Boost regulator enablement failed\n");
|
||||
mutex_unlock(&led->flash_led_lock);
|
||||
return;
|
||||
goto error_regulator_enable;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -611,8 +624,13 @@ turn_off:
|
|||
}
|
||||
|
||||
exit_flash_led_work:
|
||||
if (flash_node->boost_regulator && flash_node->flash_on)
|
||||
if (flash_node->boost_regulator && flash_node->flash_on) {
|
||||
regulator_disable(flash_node->boost_regulator);
|
||||
error_regulator_enable:
|
||||
if (regulator_count_voltages(flash_node->boost_regulator) > 0)
|
||||
regulator_set_voltage(flash_node->boost_regulator,
|
||||
0, flash_node->boost_voltage_max);
|
||||
}
|
||||
|
||||
flash_node->flash_on = false;
|
||||
mutex_unlock(&led->flash_led_lock);
|
||||
|
@ -899,9 +917,22 @@ static int qpnp_flash_led_parse_each_led_dt(struct qpnp_flash_led *led,
|
|||
IS_ERR(flash_node->boost_regulator))
|
||||
schedule_delayed_work(&flash_node->dwork,
|
||||
FLASH_BOOST_REGULATOR_PROBE_DELAY_MS);
|
||||
|
||||
rc = of_property_read_u32(node, "boost-voltage-max", &val);
|
||||
if (!rc)
|
||||
flash_node->boost_voltage_max = val;
|
||||
else {
|
||||
dev_err(&led->spmi_dev->dev,
|
||||
"Unable to read maximum boost regulator voltage\n");
|
||||
goto error_regulator_config;
|
||||
}
|
||||
}
|
||||
|
||||
return rc;
|
||||
|
||||
error_regulator_config:
|
||||
regulator_put(flash_node->boost_regulator);
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int qpnp_flash_led_parse_common_dt(
|
||||
|
|
Loading…
Reference in a new issue