Browse Source

drivers: led: lp5569: add enable-gpios

The lp5569 features a double functioning pin for enable and pwm control.
The chip, however, uses the first rising edge to initialize and get ready
for i2c communication, and then the pin alters function to pwm mode.

Add support for providing enable-gpios to the lp5569 in the dts, which
will make sure to assert the pin and wait for the chip to initialize
before attempting further configuration of the chip.

Signed-off-by: Emil Juhl <emdj@bang-olufsen.dk>
pull/75883/head
Emil Juhl 1 year ago committed by Fabio Baltieri
parent
commit
f53a401758
  1. 2
      doc/releases/release-notes-4.0.rst
  2. 22
      drivers/led/lp5569.c
  3. 5
      dts/bindings/led/ti,lp5569.yaml

2
doc/releases/release-notes-4.0.rst

@ -139,6 +139,8 @@ Drivers and Sensors @@ -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

22
drivers/led/lp5569.c

@ -13,6 +13,7 @@ @@ -13,6 +13,7 @@
* The LP5569 is a 9-channel LED driver that communicates over I2C.
*/
#include <zephyr/drivers/gpio.h>
#include <zephyr/drivers/i2c.h>
#include <zephyr/drivers/led.h>
#include <zephyr/device.h>
@ -37,6 +38,7 @@ LOG_MODULE_REGISTER(lp5569, CONFIG_LED_LOG_LEVEL); @@ -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) @@ -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 = { @@ -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), \
}; \
\

5
dts/bindings/led/ti,lp5569.yaml

@ -5,6 +5,11 @@ compatible: "ti,lp5569" @@ -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"

Loading…
Cancel
Save