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>
This commit is contained in:
parent
47f9040bfa
commit
f53a401758
3 changed files with 29 additions and 0 deletions
|
@ -139,6 +139,8 @@ Drivers and Sensors
|
||||||
|
|
||||||
* lp5569: added ``charge-pump-mode`` property to configure the charge pump of the lp5569.
|
* 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
|
* LED Strip
|
||||||
|
|
||||||
* LoRa
|
* LoRa
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
* The LP5569 is a 9-channel LED driver that communicates over I2C.
|
* 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/i2c.h>
|
||||||
#include <zephyr/drivers/led.h>
|
#include <zephyr/drivers/led.h>
|
||||||
#include <zephyr/device.h>
|
#include <zephyr/device.h>
|
||||||
|
@ -37,6 +38,7 @@ LOG_MODULE_REGISTER(lp5569, CONFIG_LED_LOG_LEVEL);
|
||||||
|
|
||||||
struct lp5569_config {
|
struct lp5569_config {
|
||||||
struct i2c_dt_spec bus;
|
struct i2c_dt_spec bus;
|
||||||
|
struct gpio_dt_spec enable_gpio;
|
||||||
const uint8_t cp_mode;
|
const uint8_t cp_mode;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -85,6 +87,25 @@ static int lp5569_enable(const struct device *dev)
|
||||||
return -ENODEV;
|
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,
|
ret = i2c_reg_write_byte_dt(&config->bus, LP5569_CONFIG,
|
||||||
LP5569_CHIP_EN);
|
LP5569_CHIP_EN);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
|
@ -159,6 +180,7 @@ static const struct led_driver_api lp5569_led_api = {
|
||||||
#define LP5569_DEFINE(id) \
|
#define LP5569_DEFINE(id) \
|
||||||
static const struct lp5569_config lp5569_config_##id = { \
|
static const struct lp5569_config lp5569_config_##id = { \
|
||||||
.bus = I2C_DT_SPEC_INST_GET(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), \
|
.cp_mode = DT_ENUM_IDX(DT_DRV_INST(id), charge_pump_mode), \
|
||||||
}; \
|
}; \
|
||||||
\
|
\
|
||||||
|
|
|
@ -5,6 +5,11 @@ compatible: "ti,lp5569"
|
||||||
include: i2c-device.yaml
|
include: i2c-device.yaml
|
||||||
|
|
||||||
properties:
|
properties:
|
||||||
|
enable-gpios:
|
||||||
|
type: phandle-array
|
||||||
|
description: |
|
||||||
|
GPIO used to enable the lp5569.
|
||||||
|
|
||||||
charge-pump-mode:
|
charge-pump-mode:
|
||||||
type: string
|
type: string
|
||||||
default: "disabled"
|
default: "disabled"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue