diff mbox series

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

Message ID 20200803102935.24364-1-von81@163.com
State New
Headers show
Series [v1] leds: is31fl32xx: Add sdb pin and generate a 5ms low pulse when startup | expand

Commit Message

Grant Feng Aug. 3, 2020, 10:29 a.m. UTC
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 <von81@163.com>
---
 drivers/leds/leds-is31fl32xx.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)
diff mbox series

Patch

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 <linux/module.h>
 #include <linux/of.h>
 #include <linux/of_device.h>
+#include <linux/delay.h>
+#include <linux/gpio/consumer.h>
 
 /* 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;