Loading Documentation/devicetree/bindings/leds/leds-qpnp-flash.txt +3 −0 Original line number Diff line number Diff line Loading @@ -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. Loading Loading @@ -107,6 +109,7 @@ Example: qcom,max-current = <200>; qcom,id = <0>; qcom,current = <120>; boost-voltage-max = <3600000>; }; }; drivers/leds/leds-qpnp-flash.c +34 −3 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -444,15 +445,27 @@ static void qpnp_flash_led_work(struct work_struct *work) flash_node->prgm_current = brightness; if (flash_node->boost_regulator && !flash_node->flash_on) { rc = regulator_enable(flash_node->boost_regulator); 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 enablement failed\n"); "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"); goto error_regulator_enable; } } if (flash_node->type == TORCH) { rc = qpnp_led_masked_write(led->spmi_dev, FLASH_LED_UNLOCK_SECURE(led->base), Loading Loading @@ -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); Loading Loading @@ -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 Loading
Documentation/devicetree/bindings/leds/leds-qpnp-flash.txt +3 −0 Original line number Diff line number Diff line Loading @@ -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. Loading Loading @@ -107,6 +109,7 @@ Example: qcom,max-current = <200>; qcom,id = <0>; qcom,current = <120>; boost-voltage-max = <3600000>; }; };
drivers/leds/leds-qpnp-flash.c +34 −3 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -444,15 +445,27 @@ static void qpnp_flash_led_work(struct work_struct *work) flash_node->prgm_current = brightness; if (flash_node->boost_regulator && !flash_node->flash_on) { rc = regulator_enable(flash_node->boost_regulator); 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 enablement failed\n"); "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"); goto error_regulator_enable; } } if (flash_node->type == TORCH) { rc = qpnp_led_masked_write(led->spmi_dev, FLASH_LED_UNLOCK_SECURE(led->base), Loading Loading @@ -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); Loading Loading @@ -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