diff options
author | Christian Marangi <ansuelsmth@gmail.com> | 2024-07-12 03:45:54 +0300 |
---|---|---|
committer | Lee Jones <lee@kernel.org> | 2024-07-12 10:32:37 +0300 |
commit | b0eed397623f897d3ccac9bda2bd2f53331b571a (patch) | |
tree | 2fd6859df0b6686d2d52aa44ec6ac5b8f8ad7871 /drivers/leds/leds-lp5569.c | |
parent | 2a498d626df7e8d97e798799ebbc30d0482d52e8 (diff) | |
download | linux-b0eed397623f897d3ccac9bda2bd2f53331b571a.tar.xz |
leds: leds-lp5569: Enable chip after chip configuration
Documentation say that clock internal config needs to be set BEFORE chip
is enabled. Align code to this and move the CHIP enable after the CHIP
is configured.
While at it also make use of STATUS reg and check when STARTUP is
completed instead of sleep for 1-2 ms.
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
Link: https://lore.kernel.org/r/20240712004556.15601-3-ansuelsmth@gmail.com
Signed-off-by: Lee Jones <lee@kernel.org>
Diffstat (limited to 'drivers/leds/leds-lp5569.c')
-rw-r--r-- | drivers/leds/leds-lp5569.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/drivers/leds/leds-lp5569.c b/drivers/leds/leds-lp5569.c index c976b10b6558..786f2aa35319 100644 --- a/drivers/leds/leds-lp5569.c +++ b/drivers/leds/leds-lp5569.c @@ -8,6 +8,7 @@ #include <linux/delay.h> #include <linux/firmware.h> #include <linux/i2c.h> +#include <linux/iopoll.h> #include <linux/leds.h> #include <linux/module.h> #include <linux/mutex.h> @@ -92,6 +93,8 @@ #define LP5569_ENG2_MUX_ADDR 0xd0 #define LP5569_ENG3_MUX_ADDR 0xe0 +#define LP5569_STARTUP_SLEEP 500 + #define LEDn_STATUS_FAULT(n, status) ((status) >> (n) & BIT(0)) #define LP5569_DEFAULT_CONFIG \ @@ -169,14 +172,7 @@ out: static int lp5569_post_init_device(struct lp55xx_chip *chip) { int ret; - int val; - - ret = lp55xx_write(chip, LP5569_REG_ENABLE, LP5569_ENABLE); - if (ret) - return ret; - - /* Chip startup time is 500 us, 1 - 2 ms gives some margin */ - usleep_range(1000, 2000); + u8 val; val = LP5569_DEFAULT_CONFIG; val |= FIELD_PREP(LP5569_CP_MODE_MASK, chip->pdata->charge_pump_mode); @@ -199,6 +195,13 @@ static int lp5569_post_init_device(struct lp55xx_chip *chip) return ret; } + ret = lp55xx_write(chip, LP5569_REG_ENABLE, LP5569_ENABLE); + if (ret) + return ret; + + read_poll_timeout(lp55xx_read, ret, !(val & LP5569_STARTUP_BUSY), + LP5569_STARTUP_SLEEP, LP5569_STARTUP_SLEEP * 10, false, + chip, LP5569_REG_STATUS, &val); return lp5569_init_program_engine(chip); } |