leds: lm3692x: Allow to configure over voltage protection
Overvoltage protection is currently using the default of 29V. Make it configurable via DT. Signed-off-by: Guido Günther <agx@sigxcpu.org> Acked-by: Pavel Machek <pavel@ucw.cz> Signed-off-by: Pavel Machek <pavel@ucw.cz>
This commit is contained in:
parent
ebf59a4558
commit
cffd61a5c7
|
@ -114,6 +114,8 @@ struct lm3692x_led {
|
||||||
struct regulator *regulator;
|
struct regulator *regulator;
|
||||||
int led_enable;
|
int led_enable;
|
||||||
int model_id;
|
int model_id;
|
||||||
|
|
||||||
|
u8 boost_ctrl;
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct reg_default lm3692x_reg_defs[] = {
|
static const struct reg_default lm3692x_reg_defs[] = {
|
||||||
|
@ -249,10 +251,7 @@ static int lm3692x_init(struct lm3692x_led *led)
|
||||||
if (ret)
|
if (ret)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
ret = regmap_write(led->regmap, LM3692X_BOOST_CTRL,
|
ret = regmap_write(led->regmap, LM3692X_BOOST_CTRL, led->boost_ctrl);
|
||||||
LM3692X_BOOST_SW_1MHZ |
|
|
||||||
LM3692X_BOOST_SW_NO_SHIFT |
|
|
||||||
LM3692X_OCP_PROT_1_5A);
|
|
||||||
if (ret)
|
if (ret)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
|
@ -326,6 +325,7 @@ static int lm3692x_probe_dt(struct lm3692x_led *led)
|
||||||
{
|
{
|
||||||
struct fwnode_handle *child = NULL;
|
struct fwnode_handle *child = NULL;
|
||||||
struct led_init_data init_data = {};
|
struct led_init_data init_data = {};
|
||||||
|
u32 ovp;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
led->enable_gpio = devm_gpiod_get_optional(&led->client->dev,
|
led->enable_gpio = devm_gpiod_get_optional(&led->client->dev,
|
||||||
|
@ -350,6 +350,32 @@ static int lm3692x_probe_dt(struct lm3692x_led *led)
|
||||||
led->regulator = NULL;
|
led->regulator = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
led->boost_ctrl = LM3692X_BOOST_SW_1MHZ |
|
||||||
|
LM3692X_BOOST_SW_NO_SHIFT |
|
||||||
|
LM3692X_OCP_PROT_1_5A;
|
||||||
|
ret = device_property_read_u32(&led->client->dev,
|
||||||
|
"ti,ovp-microvolt", &ovp);
|
||||||
|
if (ret) {
|
||||||
|
led->boost_ctrl |= LM3692X_OVP_29V;
|
||||||
|
} else {
|
||||||
|
switch (ovp) {
|
||||||
|
case 17000000:
|
||||||
|
break;
|
||||||
|
case 21000000:
|
||||||
|
led->boost_ctrl |= LM3692X_OVP_21V;
|
||||||
|
break;
|
||||||
|
case 25000000:
|
||||||
|
led->boost_ctrl |= LM3692X_OVP_25V;
|
||||||
|
break;
|
||||||
|
case 29000000:
|
||||||
|
led->boost_ctrl |= LM3692X_OVP_29V;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
dev_err(&led->client->dev, "Invalid OVP %d\n", ovp);
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
child = device_get_next_child_node(&led->client->dev, child);
|
child = device_get_next_child_node(&led->client->dev, child);
|
||||||
if (!child) {
|
if (!child) {
|
||||||
dev_err(&led->client->dev, "No LED Child node\n");
|
dev_err(&led->client->dev, "No LED Child node\n");
|
||||||
|
|
Loading…
Reference in New Issue