From 47f9040bfa8c90ec05d6b13ae65a0cbe3bb747d9 Mon Sep 17 00:00:00 2001 From: Emil Juhl Date: Thu, 21 Mar 2024 10:07:46 +0100 Subject: [PATCH] drivers: led: lp5569: add charge pump configuration The lp5569 controller contains an internal charge pump which can be useful for driving LEDs with a forward voltage greater than the lp5569 supply. Taking advantage of the charge pump can alleviate the need for an external boost converter. Add a dts property, charge-pump-mode, to the ti,lp5569 binding with which the cp_mode bits of the MISC register will be configured. Following the datasheet, the possible configurations are: 0x00 -> disabled (default) 0x01 -> 1x mode 0x10 -> 1.5x mode 0x11 -> auto mode Signed-off-by: Emil Juhl --- doc/releases/release-notes-4.0.rst | 2 ++ drivers/led/lp5569.c | 6 +++++- dts/bindings/led/ti,lp5569.yaml | 15 +++++++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/doc/releases/release-notes-4.0.rst b/doc/releases/release-notes-4.0.rst index 3ec6f68c477..a6735deeef1 100644 --- a/doc/releases/release-notes-4.0.rst +++ b/doc/releases/release-notes-4.0.rst @@ -137,6 +137,8 @@ Drivers and Sensors * LED + * lp5569: added ``charge-pump-mode`` property to configure the charge pump of the lp5569. + * LED Strip * LoRa diff --git a/drivers/led/lp5569.c b/drivers/led/lp5569.c index e469c22574e..72cb50fbce9 100644 --- a/drivers/led/lp5569.c +++ b/drivers/led/lp5569.c @@ -30,12 +30,14 @@ LOG_MODULE_REGISTER(lp5569, CONFIG_LED_LOG_LEVEL); #define LP5569_MISC 0x2F #define LP5569_POWERSAVE_EN BIT(5) +#define LP5569_CP_MODE_SHIFT 3 /* PWM base Register for controlling the duty-cycle */ #define LP5569_LED0_PWM 0x16 struct lp5569_config { struct i2c_dt_spec bus; + const uint8_t cp_mode; }; static int lp5569_led_set_brightness(const struct device *dev, uint32_t led, @@ -91,7 +93,8 @@ static int lp5569_enable(const struct device *dev) } ret = i2c_reg_write_byte_dt(&config->bus, LP5569_MISC, - LP5569_POWERSAVE_EN); + LP5569_POWERSAVE_EN | + (config->cp_mode << LP5569_CP_MODE_SHIFT)); if (ret < 0) { LOG_ERR("LED reg update failed"); return ret; @@ -156,6 +159,7 @@ static const struct led_driver_api lp5569_led_api = { #define LP5569_DEFINE(id) \ static const struct lp5569_config lp5569_config_##id = { \ .bus = I2C_DT_SPEC_INST_GET(id), \ + .cp_mode = DT_ENUM_IDX(DT_DRV_INST(id), charge_pump_mode), \ }; \ \ PM_DEVICE_DT_INST_DEFINE(id, lp5569_pm_action); \ diff --git a/dts/bindings/led/ti,lp5569.yaml b/dts/bindings/led/ti,lp5569.yaml index 1d84ba257c5..5893b1cbae8 100644 --- a/dts/bindings/led/ti,lp5569.yaml +++ b/dts/bindings/led/ti,lp5569.yaml @@ -3,3 +3,18 @@ description: TI LP5569 LED compatible: "ti,lp5569" include: i2c-device.yaml + +properties: + charge-pump-mode: + type: string + default: "disabled" + enum: + - "disabled" + - "1x" + - "1x5" + - "auto" + description: | + If provided, configures the internal charge-pump mode in the MISC + register. This can be useful to supply a higher voltage to the LEDs, than + what the lp5569 is being supplied. + The default corresponds to the reset value of the register.