diff --git a/doc/releases/release-notes-4.0.rst b/doc/releases/release-notes-4.0.rst index a6735deeef1..49d03f5eb0a 100644 --- a/doc/releases/release-notes-4.0.rst +++ b/doc/releases/release-notes-4.0.rst @@ -139,6 +139,8 @@ Drivers and Sensors * lp5569: added ``charge-pump-mode`` property to configure the charge pump of the lp5569. + * lp5569: added ``enable-gpios`` property to describe the EN/PWM GPIO of the lp5569. + * LED Strip * LoRa diff --git a/drivers/led/lp5569.c b/drivers/led/lp5569.c index 72cb50fbce9..4a345a1c490 100644 --- a/drivers/led/lp5569.c +++ b/drivers/led/lp5569.c @@ -13,6 +13,7 @@ * The LP5569 is a 9-channel LED driver that communicates over I2C. */ +#include #include #include #include @@ -37,6 +38,7 @@ LOG_MODULE_REGISTER(lp5569, CONFIG_LED_LOG_LEVEL); struct lp5569_config { struct i2c_dt_spec bus; + struct gpio_dt_spec enable_gpio; const uint8_t cp_mode; }; @@ -85,6 +87,25 @@ static int lp5569_enable(const struct device *dev) return -ENODEV; } + /* flip the enable pin if specified */ + if (config->enable_gpio.port) { + if (!gpio_is_ready_dt(&config->enable_gpio)) { + LOG_ERR("Enable GPIO not ready"); + return -ENODEV; + } + + ret = gpio_pin_configure_dt(&config->enable_gpio, + GPIO_OUTPUT_ACTIVE); + if (ret < 0) { + LOG_ERR("Failed to configure enable_gpio, err: %d", + ret); + return ret; + } + + /* datasheet 7.9: t_en max 3 ms for chip initialization */ + k_msleep(3); + } + ret = i2c_reg_write_byte_dt(&config->bus, LP5569_CONFIG, LP5569_CHIP_EN); if (ret < 0) { @@ -159,6 +180,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), \ + .enable_gpio = GPIO_DT_SPEC_INST_GET_OR(id, enable_gpios, {0}), \ .cp_mode = DT_ENUM_IDX(DT_DRV_INST(id), charge_pump_mode), \ }; \ \ diff --git a/dts/bindings/led/ti,lp5569.yaml b/dts/bindings/led/ti,lp5569.yaml index 5893b1cbae8..dff5d9c2ec5 100644 --- a/dts/bindings/led/ti,lp5569.yaml +++ b/dts/bindings/led/ti,lp5569.yaml @@ -5,6 +5,11 @@ compatible: "ti,lp5569" include: i2c-device.yaml properties: + enable-gpios: + type: phandle-array + description: | + GPIO used to enable the lp5569. + charge-pump-mode: type: string default: "disabled"