linux-leds.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] leds: leds-lp5569: Fix typo in driver name
@ 2024-07-04  1:55 Christian Marangi
  2024-07-04  1:55 ` [PATCH 2/3] leds: leds-lp5569: Better handle enabling clock internal setting Christian Marangi
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Christian Marangi @ 2024-07-04  1:55 UTC (permalink / raw)
  To: Pavel Machek, Lee Jones, linux-leds, linux-kernel; +Cc: Christian Marangi

Remove extra x from driver name as this was a typo from copy-paste
error.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
---
 drivers/leds/leds-lp5569.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/leds/leds-lp5569.c b/drivers/leds/leds-lp5569.c
index 7ccd8dd6026a..b7a74d6c19ca 100644
--- a/drivers/leds/leds-lp5569.c
+++ b/drivers/leds/leds-lp5569.c
@@ -529,7 +529,7 @@ MODULE_DEVICE_TABLE(of, of_lp5569_leds_match);
 
 static struct i2c_driver lp5569_driver = {
 	.driver = {
-		.name	= "lp5569x",
+		.name	= "lp5569",
 		.of_match_table = of_lp5569_leds_match,
 	},
 	.probe		= lp55xx_probe,
-- 
2.45.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/3] leds: leds-lp5569: Better handle enabling clock internal setting
  2024-07-04  1:55 [PATCH 1/3] leds: leds-lp5569: Fix typo in driver name Christian Marangi
@ 2024-07-04  1:55 ` Christian Marangi
  2024-07-04  1:55 ` [PATCH 3/3] leds: leds-lp5569: Enable chip after chip configuration Christian Marangi
  2024-07-11 15:51 ` [PATCH 1/3] leds: leds-lp5569: Fix typo in driver name Lee Jones
  2 siblings, 0 replies; 4+ messages in thread
From: Christian Marangi @ 2024-07-04  1:55 UTC (permalink / raw)
  To: Pavel Machek, Lee Jones, linux-leds, linux-kernel; +Cc: Christian Marangi

Better handle enabling clock internal setting. In further testing it was
notice that internal clock config MUST be set before clock output config
or the LED CHIP might stop working.

This wasn't documented and was actually found on devices that have 2
chip chained where one chip provide clock for the other.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
---
 drivers/leds/leds-lp5569.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/drivers/leds/leds-lp5569.c b/drivers/leds/leds-lp5569.c
index b7a74d6c19ca..2b4f358bc63a 100644
--- a/drivers/leds/leds-lp5569.c
+++ b/drivers/leds/leds-lp5569.c
@@ -179,20 +179,25 @@ static int lp5569_post_init_device(struct lp55xx_chip *chip)
 
 	val = LP5569_DEFAULT_CONFIG;
 	val |= FIELD_PREP(LP5569_CP_MODE_MASK, chip->pdata->charge_pump_mode);
+	ret = lp55xx_write(chip, LP5569_REG_MISC, val);
+	if (ret)
+		return ret;
 
 	if (chip->pdata->clock_mode == LP55XX_CLOCK_INT) {
+		/* Internal clock MUST be configured before CLK output */
+		ret = lp55xx_update_bits(chip, LP5569_REG_MISC,
+					 LP5569_INTERNAL_CLK,
+					 LP5569_INTERNAL_CLK);
+		if (ret)
+			return ret;
+
 		ret = lp55xx_update_bits(chip, LP5569_REG_IO_CONTROL,
 					 LP5569_CLK_OUTPUT,
 					 LP5569_CLK_OUTPUT);
 		if (ret)
 			return ret;
-
-		val |= LP5569_INTERNAL_CLK;
 	}
 
-	ret = lp55xx_write(chip, LP5569_REG_MISC, val);
-	if (ret)
-		return ret;
 
 	return lp5569_init_program_engine(chip);
 }
-- 
2.45.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 3/3] leds: leds-lp5569: Enable chip after chip configuration
  2024-07-04  1:55 [PATCH 1/3] leds: leds-lp5569: Fix typo in driver name Christian Marangi
  2024-07-04  1:55 ` [PATCH 2/3] leds: leds-lp5569: Better handle enabling clock internal setting Christian Marangi
@ 2024-07-04  1:55 ` Christian Marangi
  2024-07-11 15:51 ` [PATCH 1/3] leds: leds-lp5569: Fix typo in driver name Lee Jones
  2 siblings, 0 replies; 4+ messages in thread
From: Christian Marangi @ 2024-07-04  1:55 UTC (permalink / raw)
  To: Pavel Machek, Lee Jones, linux-leds, linux-kernel; +Cc: Christian Marangi

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>
---
 drivers/leds/leds-lp5569.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/drivers/leds/leds-lp5569.c b/drivers/leds/leds-lp5569.c
index 2b4f358bc63a..cd1a189c542f 100644
--- a/drivers/leds/leds-lp5569.c
+++ b/drivers/leds/leds-lp5569.c
@@ -7,6 +7,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>
@@ -91,6 +92,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 \
@@ -170,13 +173,6 @@ 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);
-
 	val = LP5569_DEFAULT_CONFIG;
 	val |= FIELD_PREP(LP5569_CP_MODE_MASK, chip->pdata->charge_pump_mode);
 	ret = lp55xx_write(chip, LP5569_REG_MISC, val);
@@ -198,6 +194,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);
 }
-- 
2.45.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/3] leds: leds-lp5569: Fix typo in driver name
  2024-07-04  1:55 [PATCH 1/3] leds: leds-lp5569: Fix typo in driver name Christian Marangi
  2024-07-04  1:55 ` [PATCH 2/3] leds: leds-lp5569: Better handle enabling clock internal setting Christian Marangi
  2024-07-04  1:55 ` [PATCH 3/3] leds: leds-lp5569: Enable chip after chip configuration Christian Marangi
@ 2024-07-11 15:51 ` Lee Jones
  2 siblings, 0 replies; 4+ messages in thread
From: Lee Jones @ 2024-07-11 15:51 UTC (permalink / raw)
  To: Pavel Machek, Lee Jones, linux-leds, linux-kernel,
	Christian Marangi

On Thu, 04 Jul 2024 03:55:40 +0200, Christian Marangi wrote:
> Remove extra x from driver name as this was a typo from copy-paste
> error.
> 
> 

Applied, thanks!

[1/3] leds: leds-lp5569: Fix typo in driver name
      commit: 16748df87358e3addc54135eb0106139d1acc104
[2/3] leds: leds-lp5569: Better handle enabling clock internal setting
      commit: 2aebbea1864a0a920d8b5c9324cb2a46665972e9
[3/3] leds: leds-lp5569: Enable chip after chip configuration
      commit: d9cc80b1c9b40a33c022e125b7f9555813c7f385

--
Lee Jones [李琼斯]


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-07-11 15:51 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-04  1:55 [PATCH 1/3] leds: leds-lp5569: Fix typo in driver name Christian Marangi
2024-07-04  1:55 ` [PATCH 2/3] leds: leds-lp5569: Better handle enabling clock internal setting Christian Marangi
2024-07-04  1:55 ` [PATCH 3/3] leds: leds-lp5569: Enable chip after chip configuration Christian Marangi
2024-07-11 15:51 ` [PATCH 1/3] leds: leds-lp5569: Fix typo in driver name Lee Jones

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).