Re: [PATCH v1] leds: is31fl32xx: Add sdb pin and generate a 5ms low pulse when startup

2020-08-05 Thread Pavel Machek
On Mon 2020-08-03 18:29:35, Grant Feng wrote:
> generate a 5ms low pulse on sdb pin when startup, then the chip
> becomes more stable in the complex EM environment.

Thanks, applied.
Pavel

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) 
http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html


signature.asc
Description: PGP signature


[PATCH v1] leds: is31fl32xx: Add sdb pin and generate a 5ms low pulse when startup

2020-08-03 Thread Grant Feng
generate a 5ms low pulse on sdb pin when startup, then the chip
becomes more stable in the complex EM environment.

Signed-off-by: Grant Feng 
---
 drivers/leds/leds-is31fl32xx.c | 16 ++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/drivers/leds/leds-is31fl32xx.c b/drivers/leds/leds-is31fl32xx.c
index cd768f991da1..e0f8734223c0 100644
--- a/drivers/leds/leds-is31fl32xx.c
+++ b/drivers/leds/leds-is31fl32xx.c
@@ -16,6 +16,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 
 /* Used to indicate a device has no such register */
 #define IS31FL32XX_REG_NONE 0xFF
@@ -43,6 +45,7 @@ struct is31fl32xx_led_data {
 struct is31fl32xx_priv {
const struct is31fl32xx_chipdef *cdef;
struct i2c_client *client;
+   struct gpio_desc *sdb_pin;
unsigned int num_leds;
struct is31fl32xx_led_data leds[];
 };
@@ -405,6 +408,15 @@ static int is31fl32xx_parse_dt(struct device *dev,
priv->num_leds++;
}
 
+   priv->sdb_pin = gpiod_get(dev, "sdb", GPIOD_ASIS);
+   if (IS_ERR(priv->sdb_pin)) {
+   dev_warn(dev, "failed to get SDB GPIO, try default\r\n");
+   } else {
+   gpiod_direction_output(priv->sdb_pin, 0);
+   mdelay(5);
+   gpiod_direction_output(priv->sdb_pin, 1);
+   }
+
return 0;
 
 err:
@@ -453,11 +465,11 @@ static int is31fl32xx_probe(struct i2c_client *client,
priv->cdef = cdef;
i2c_set_clientdata(client, priv);
 
-   ret = is31fl32xx_init_regs(priv);
+   ret = is31fl32xx_parse_dt(dev, priv);
if (ret)
return ret;
 
-   ret = is31fl32xx_parse_dt(dev, priv);
+   ret = is31fl32xx_init_regs(priv);
if (ret)
return ret;
 
-- 
2.17.1