Re: [PATCH v3 1/2] leds: is31fl319x: Add shutdown pin and generate a 5ms low pulse when startup

2020-09-11 Thread Grant Feng

Thanks for the info.

Best regards,

                                                Grant

On 2020-09-09 17:18, Pavel Machek wrote:

On Tue 2020-08-25 16:22:05, Grant Feng wrote:

generate a 5ms low pulse on shutdown pin when startup, then the chip
becomes more stable in the complex EM environment.

Thanks, I applied the series.

Best regards,
Pavel





[PATCH v3 1/2] leds: is31fl319x: Add shutdown pin and generate a 5ms low pulse when startup

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

Signed-off-by: Grant Feng 
---
 drivers/leds/leds-is31fl319x.c | 18 ++
 1 file changed, 18 insertions(+)

diff --git a/drivers/leds/leds-is31fl319x.c b/drivers/leds/leds-is31fl319x.c
index ca6634b8683c..54ac50740d43 100644
--- a/drivers/leds/leds-is31fl319x.c
+++ b/drivers/leds/leds-is31fl319x.c
@@ -16,6 +16,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 
 /* register numbers */
 #define IS31FL319X_SHUTDOWN0x00
@@ -61,6 +63,7 @@
 struct is31fl319x_chip {
const struct is31fl319x_chipdef *cdef;
struct i2c_client   *client;
+   struct gpio_desc*shutdown_gpio;
struct regmap   *regmap;
struct mutexlock;
u32 audio_gain_db;
@@ -207,6 +210,15 @@ static int is31fl319x_parse_dt(struct device *dev,
if (!np)
return -ENODEV;
 
+   is31->shutdown_gpio = devm_gpiod_get_optional(dev,
+   "shutdown",
+   GPIOD_OUT_HIGH);
+   if (IS_ERR(is31->shutdown_gpio)) {
+   ret = PTR_ERR(is31->shutdown_gpio);
+   dev_err(dev, "Failed to get shutdown gpio: %d\n", ret);
+   return ret;
+   }
+
of_dev_id = of_match_device(of_is31fl319x_match, dev);
if (!of_dev_id) {
dev_err(dev, "Failed to match device with supported chips\n");
@@ -350,6 +362,12 @@ static int is31fl319x_probe(struct i2c_client *client,
if (err)
goto free_mutex;
 
+   if (is31->shutdown_gpio) {
+   gpiod_direction_output(is31->shutdown_gpio, 0);
+   mdelay(5);
+   gpiod_direction_output(is31->shutdown_gpio, 1);
+   }
+
is31->client = client;
is31->regmap = devm_regmap_init_i2c(client, _config);
if (IS_ERR(is31->regmap)) {
-- 
2.17.1




[PATCH v3 2/2] DT: leds: Add an optional property named 'shutdown-gpios'

2020-08-25 Thread Grant Feng
The chip enters hardware shutdown when the SDB pin is pulled low.
The chip releases hardware shutdown when the SDB pin is pulled high.

Signed-off-by: Grant Feng 
---
 Documentation/devicetree/bindings/leds/leds-is31fl319x.txt | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Documentation/devicetree/bindings/leds/leds-is31fl319x.txt 
b/Documentation/devicetree/bindings/leds/leds-is31fl319x.txt
index fc2603484544..676d43ec8169 100644
--- a/Documentation/devicetree/bindings/leds/leds-is31fl319x.txt
+++ b/Documentation/devicetree/bindings/leds/leds-is31fl319x.txt
@@ -16,6 +16,7 @@ Optional properties:
 - audio-gain-db : audio gain selection for external analog modulation input.
Valid values: 0 - 21, step by 3 (rounded down)
Default: 0
+- shutdown-gpios : Specifier of the GPIO connected to SDB pin of the chip.
 
 Each led is represented as a sub-node of the issi,is31fl319x device.
 There can be less leds subnodes than the chip can support but not more.
@@ -44,6 +45,7 @@ fancy_leds: leds@65 {
#address-cells = <1>;
#size-cells = <0>;
reg = <0x65>;
+   shutdown-gpios = < 11 GPIO_ACTIVE_HIGH>;
 
red_aux: led@1 {
label = "red:aux";
-- 
2.17.1




[PATCH v3 2/2] leds: Add an optional property named 'shutdown-gpios'

2020-08-25 Thread Grant Feng
The chip enters hardware shutdown when the SDB pin is pulled low.
The chip releases hardware shutdown when the SDB pin is pulled high.

Signed-off-by: Grant Feng 
---
 Documentation/devicetree/bindings/leds/leds-is31fl32xx.txt | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/Documentation/devicetree/bindings/leds/leds-is31fl32xx.txt 
b/Documentation/devicetree/bindings/leds/leds-is31fl32xx.txt
index 926c2117942c..ee761abb98a7 100644
--- a/Documentation/devicetree/bindings/leds/leds-is31fl32xx.txt
+++ b/Documentation/devicetree/bindings/leds/leds-is31fl32xx.txt
@@ -15,6 +15,8 @@ Required properties:
 - reg: I2C slave address
 - address-cells : must be 1
 - size-cells : must be 0
+- shutdown-gpios : (optional)
+  Specifier of the GPIO connected to SDB pin of the chip.
 
 LED sub-node properties:
 - reg : LED channel number (1..N)
@@ -31,6 +33,7 @@ is31fl3236: led-controller@3c {
reg = <0x3c>;
#address-cells = <1>;
#size-cells = <0>;
+   shutdown-gpios = < 11 GPIO_ACTIVE_HIGH>;
 
led@1 {
reg = <1>;
-- 
2.17.1




[PATCH v3 1/2] leds: is31fl32xx: Add shutdown pin and generate a 5ms low pulse when startup

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

Signed-off-by: Grant Feng 
---
 drivers/leds/leds-is31fl32xx.c | 24 +---
 1 file changed, 21 insertions(+), 3 deletions(-)

diff --git a/drivers/leds/leds-is31fl32xx.c b/drivers/leds/leds-is31fl32xx.c
index cd768f991da1..946ad2f71e00 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 *shutdown_gpio;
unsigned int num_leds;
struct is31fl32xx_led_data leds[];
 };
@@ -282,11 +285,17 @@ static int is31fl32xx_software_shutdown(struct 
is31fl32xx_priv *priv,
return 0;
 }
 
-static int is31fl32xx_init_regs(struct is31fl32xx_priv *priv)
+static int is31fl32xx_init(struct is31fl32xx_priv *priv)
 {
const struct is31fl32xx_chipdef *cdef = priv->cdef;
int ret;
 
+   if (priv->shutdown_gpio) {
+   gpiod_direction_output(priv->shutdown_gpio, 0);
+   mdelay(5);
+   gpiod_direction_output(priv->shutdown_gpio, 1);
+   }
+
ret = is31fl32xx_reset_regs(priv);
if (ret)
return ret;
@@ -372,6 +381,15 @@ static int is31fl32xx_parse_dt(struct device *dev,
struct device_node *child;
int ret = 0;
 
+   priv->shutdown_gpio = devm_gpiod_get_optional(dev,
+   "shutdown",
+   GPIOD_OUT_HIGH);
+   if (IS_ERR(priv->shutdown_gpio)) {
+   ret = PTR_ERR(priv->shutdown_gpio);
+   dev_err(dev, "Failed to get shutdown gpio: %d\n", ret);
+   return ret;
+   }
+
for_each_child_of_node(dev->of_node, child) {
struct is31fl32xx_led_data *led_data =
>leds[priv->num_leds];
@@ -453,11 +471,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(priv);
if (ret)
return ret;
 
-- 
2.17.1




Re: [PATCH v2 2/2] leds: Add an optional property named 'sdb-gpios'

2020-08-25 Thread Grant Feng



On 2020-08-25 6:21, Rob Herring wrote:

On Sat, Aug 08, 2020 at 11:37:31AM +0800, Grant Feng wrote:

The chip enters hardware shutdown when the SDB pin is pulled low.
The chip releases hardware shutdown when the SDB pin is pulled high.

Signed-off-by: Grant Feng 
---
  Documentation/devicetree/bindings/leds/leds-is31fl319x.txt | 2 ++
  1 file changed, 2 insertions(+)

diff --git a/Documentation/devicetree/bindings/leds/leds-is31fl319x.txt 
b/Documentation/devicetree/bindings/leds/leds-is31fl319x.txt
index fc2603484544..e8bef4be57dc 100644
--- a/Documentation/devicetree/bindings/leds/leds-is31fl319x.txt
+++ b/Documentation/devicetree/bindings/leds/leds-is31fl319x.txt
@@ -16,6 +16,7 @@ Optional properties:
  - audio-gain-db : audio gain selection for external analog modulation input.
Valid values: 0 - 21, step by 3 (rounded down)
Default: 0
+- sdb-gpios : Specifier of the GPIO connected to SDB pin.

We normally use 'shutdown-gpios' for a shutdown GPIO.

Thanks for the review.
  
  Each led is represented as a sub-node of the issi,is31fl319x device.

  There can be less leds subnodes than the chip can support but not more.
@@ -44,6 +45,7 @@ fancy_leds: leds@65 {
#address-cells = <1>;
#size-cells = <0>;
reg = <0x65>;
+   sdb-gpios = < 11 GPIO_ACTIVE_HIGH>;
  
  	red_aux: led@1 {

label = "red:aux";
--
2.17.1






[PATCH v2 1/2] leds: is31fl319x: Add sdb pin and generate a 5ms low pulse when startup

2020-08-07 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-is31fl319x.c | 18 ++
 1 file changed, 18 insertions(+)

diff --git a/drivers/leds/leds-is31fl319x.c b/drivers/leds/leds-is31fl319x.c
index ca6634b8683c..5c499a5895e0 100644
--- a/drivers/leds/leds-is31fl319x.c
+++ b/drivers/leds/leds-is31fl319x.c
@@ -16,6 +16,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 
 /* register numbers */
 #define IS31FL319X_SHUTDOWN0x00
@@ -61,6 +63,7 @@
 struct is31fl319x_chip {
const struct is31fl319x_chipdef *cdef;
struct i2c_client   *client;
+   struct gpio_desc*sdb_gpio;
struct regmap   *regmap;
struct mutexlock;
u32 audio_gain_db;
@@ -207,6 +210,15 @@ static int is31fl319x_parse_dt(struct device *dev,
if (!np)
return -ENODEV;
 
+   is31->sdb_gpio = devm_gpiod_get_optional(dev,
+   "sdb",
+   GPIOD_OUT_HIGH);
+   if (IS_ERR(is31->sdb_gpio)) {
+   ret = PTR_ERR(is31->sdb_gpio);
+   dev_err(dev, "Failed to get sdb gpio: %d\n", ret);
+   return ret;
+   }
+
of_dev_id = of_match_device(of_is31fl319x_match, dev);
if (!of_dev_id) {
dev_err(dev, "Failed to match device with supported chips\n");
@@ -350,6 +362,12 @@ static int is31fl319x_probe(struct i2c_client *client,
if (err)
goto free_mutex;
 
+   if (is31->sdb_gpio) {
+   gpiod_direction_output(is31->sdb_gpio, 0);
+   mdelay(5);
+   gpiod_direction_output(is31->sdb_gpio, 1);
+   }
+
is31->client = client;
is31->regmap = devm_regmap_init_i2c(client, _config);
if (IS_ERR(is31->regmap)) {
-- 
2.17.1




[PATCH v2 2/2] leds: Add an optional property named 'sdb-gpios'

2020-08-07 Thread Grant Feng
The chip enters hardware shutdown when the SDB pin is pulled low.
The chip releases hardware shutdown when the SDB pin is pulled high.

Signed-off-by: Grant Feng 
---
 Documentation/devicetree/bindings/leds/leds-is31fl319x.txt | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Documentation/devicetree/bindings/leds/leds-is31fl319x.txt 
b/Documentation/devicetree/bindings/leds/leds-is31fl319x.txt
index fc2603484544..e8bef4be57dc 100644
--- a/Documentation/devicetree/bindings/leds/leds-is31fl319x.txt
+++ b/Documentation/devicetree/bindings/leds/leds-is31fl319x.txt
@@ -16,6 +16,7 @@ Optional properties:
 - audio-gain-db : audio gain selection for external analog modulation input.
Valid values: 0 - 21, step by 3 (rounded down)
Default: 0
+- sdb-gpios : Specifier of the GPIO connected to SDB pin.
 
 Each led is represented as a sub-node of the issi,is31fl319x device.
 There can be less leds subnodes than the chip can support but not more.
@@ -44,6 +45,7 @@ fancy_leds: leds@65 {
#address-cells = <1>;
#size-cells = <0>;
reg = <0x65>;
+   sdb-gpios = < 11 GPIO_ACTIVE_HIGH>;
 
red_aux: led@1 {
label = "red:aux";
-- 
2.17.1




[PATCH v2 1/2] leds: is31fl32xx: Add sdb pin and generate a 5ms low pulse when startup

2020-08-07 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 | 24 +---
 1 file changed, 21 insertions(+), 3 deletions(-)

diff --git a/drivers/leds/leds-is31fl32xx.c b/drivers/leds/leds-is31fl32xx.c
index cd768f991da1..07b543120e06 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_gpio;
unsigned int num_leds;
struct is31fl32xx_led_data leds[];
 };
@@ -282,11 +285,17 @@ static int is31fl32xx_software_shutdown(struct 
is31fl32xx_priv *priv,
return 0;
 }
 
-static int is31fl32xx_init_regs(struct is31fl32xx_priv *priv)
+static int is31fl32xx_init(struct is31fl32xx_priv *priv)
 {
const struct is31fl32xx_chipdef *cdef = priv->cdef;
int ret;
 
+   if (priv->sdb_gpio) {
+   gpiod_direction_output(priv->sdb_gpio, 0);
+   mdelay(5);
+   gpiod_direction_output(priv->sdb_gpio, 1);
+   }
+
ret = is31fl32xx_reset_regs(priv);
if (ret)
return ret;
@@ -372,6 +381,15 @@ static int is31fl32xx_parse_dt(struct device *dev,
struct device_node *child;
int ret = 0;
 
+   priv->sdb_gpio = devm_gpiod_get_optional(dev,
+   "sdb",
+   GPIOD_OUT_HIGH);
+   if (IS_ERR(priv->sdb_gpio)) {
+   ret = PTR_ERR(priv->sdb_gpio);
+   dev_err(dev, "Failed to get sdb gpio: %d\n", ret);
+   return ret;
+   }
+
for_each_child_of_node(dev->of_node, child) {
struct is31fl32xx_led_data *led_data =
>leds[priv->num_leds];
@@ -453,11 +471,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(priv);
if (ret)
return ret;
 
-- 
2.17.1




[PATCH v2 2/2] leds: Add an optional property named 'sdb-gpios'

2020-08-07 Thread Grant Feng
The chip enters hardware shutdown when the SDB pin is pulled low.
The chip releases hardware shutdown when the SDB pin is pulled high.

Signed-off-by: Grant Feng 
---
 Documentation/devicetree/bindings/leds/leds-is31fl32xx.txt | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/Documentation/devicetree/bindings/leds/leds-is31fl32xx.txt 
b/Documentation/devicetree/bindings/leds/leds-is31fl32xx.txt
index 926c2117942c..94f02827fd83 100644
--- a/Documentation/devicetree/bindings/leds/leds-is31fl32xx.txt
+++ b/Documentation/devicetree/bindings/leds/leds-is31fl32xx.txt
@@ -15,6 +15,8 @@ Required properties:
 - reg: I2C slave address
 - address-cells : must be 1
 - size-cells : must be 0
+- sdb-gpios : (optional)
+  Specifier of the GPIO connected to SDB pin.
 
 LED sub-node properties:
 - reg : LED channel number (1..N)
@@ -31,6 +33,7 @@ is31fl3236: led-controller@3c {
reg = <0x3c>;
#address-cells = <1>;
#size-cells = <0>;
+   sdb-gpios = < 11 GPIO_ACTIVE_HIGH>;
 
led@1 {
reg = <1>;
-- 
2.17.1




Re: [PATCH 1/2] leds: is31fl319x: Add sdb pin and generate a 5ms low pulse when startup

2020-08-07 Thread Grant Feng

Thanks for the review, I will rewrit it.

Grant

On 2020-08-06 23:00, Dan Murphy wrote:

Grant

On 8/6/20 1:21 AM, Grant Feng wrote:

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-is31fl319x.c | 12 
  1 file changed, 12 insertions(+)

diff --git a/drivers/leds/leds-is31fl319x.c 
b/drivers/leds/leds-is31fl319x.c

index ca6634b8683c..b4f70002cec9 100644
--- a/drivers/leds/leds-is31fl319x.c
+++ b/drivers/leds/leds-is31fl319x.c
@@ -16,6 +16,8 @@
  #include 
  #include 
  #include 
+#include 
+#include 
    /* register numbers */
  #define IS31FL319X_SHUTDOWN    0x00
@@ -61,6 +63,7 @@
  struct is31fl319x_chip {
  const struct is31fl319x_chipdef *cdef;
  struct i2c_client   *client;
+    struct gpio_desc    *sdb_pin;
  struct regmap   *regmap;
  struct mutex    lock;
  u32 audio_gain_db;
@@ -265,6 +268,15 @@ static int is31fl319x_parse_dt(struct device *dev,
  is31->audio_gain_db = min(is31->audio_gain_db,
    IS31FL319X_AUDIO_GAIN_DB_MAX);
  +    is31->sdb_pin = gpiod_get(dev, "sdb", GPIOD_ASIS);


Since this is optional maybe use devm_gpiod_get_optional.

If this is required for stability then if the GPIO is not present then 
the parse_dt should return the error.


And use the devm_gpiod_get call.  Otherwise you are missing the 
gpiod_put when exiting or removing the driver.


Dan





[PATCH 1/2] leds: is31fl319x: Add sdb pin and generate a 5ms low pulse when startup

2020-08-06 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-is31fl319x.c | 12 
 1 file changed, 12 insertions(+)

diff --git a/drivers/leds/leds-is31fl319x.c b/drivers/leds/leds-is31fl319x.c
index ca6634b8683c..b4f70002cec9 100644
--- a/drivers/leds/leds-is31fl319x.c
+++ b/drivers/leds/leds-is31fl319x.c
@@ -16,6 +16,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 
 /* register numbers */
 #define IS31FL319X_SHUTDOWN0x00
@@ -61,6 +63,7 @@
 struct is31fl319x_chip {
const struct is31fl319x_chipdef *cdef;
struct i2c_client   *client;
+   struct gpio_desc*sdb_pin;
struct regmap   *regmap;
struct mutexlock;
u32 audio_gain_db;
@@ -265,6 +268,15 @@ static int is31fl319x_parse_dt(struct device *dev,
is31->audio_gain_db = min(is31->audio_gain_db,
  IS31FL319X_AUDIO_GAIN_DB_MAX);
 
+   is31->sdb_pin = gpiod_get(dev, "sdb", GPIOD_ASIS);
+   if (IS_ERR(is31->sdb_pin)) {
+   dev_warn(dev, "failed to get gpio_sdb, try default\r\n");
+   } else {
+   gpiod_direction_output(is31->sdb_pin, 0);
+   mdelay(5);
+   gpiod_direction_output(is31->sdb_pin, 1);
+   }
+
return 0;
 
 put_child_node:
-- 
2.17.1




[PATCH 2/2] DT: leds: Add an optional property named 'sdb-gpios'

2020-08-06 Thread Grant Feng
The chip enters hardware shutdown when the SDB pin is pulled low.
The chip releases hardware shutdown when the SDB pin is pulled high.

Signed-off-by: Grant Feng 
---
 Documentation/devicetree/bindings/leds/leds-is31fl319x.txt | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Documentation/devicetree/bindings/leds/leds-is31fl319x.txt 
b/Documentation/devicetree/bindings/leds/leds-is31fl319x.txt
index fc2603484544..e8bef4be57dc 100644
--- a/Documentation/devicetree/bindings/leds/leds-is31fl319x.txt
+++ b/Documentation/devicetree/bindings/leds/leds-is31fl319x.txt
@@ -16,6 +16,7 @@ Optional properties:
 - audio-gain-db : audio gain selection for external analog modulation input.
Valid values: 0 - 21, step by 3 (rounded down)
Default: 0
+- sdb-gpios : Specifier of the GPIO connected to SDB pin.
 
 Each led is represented as a sub-node of the issi,is31fl319x device.
 There can be less leds subnodes than the chip can support but not more.
@@ -44,6 +45,7 @@ fancy_leds: leds@65 {
#address-cells = <1>;
#size-cells = <0>;
reg = <0x65>;
+   sdb-gpios = < 11 GPIO_ACTIVE_HIGH>;
 
red_aux: led@1 {
label = "red:aux";
-- 
2.17.1




[PATCH] leds: Add an optional property named 'sdb-gpios'

2020-08-05 Thread Grant Feng
The chip enters hardware shutdown when the SDB pin is pulled low.
The chip releases hardware shutdown when the SDB pin is pulled high.

Signed-off-by: Grant Feng 
---
 Documentation/devicetree/bindings/leds/leds-is31fl32xx.txt | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/Documentation/devicetree/bindings/leds/leds-is31fl32xx.txt 
b/Documentation/devicetree/bindings/leds/leds-is31fl32xx.txt
index 926c2117942c..94f02827fd83 100644
--- a/Documentation/devicetree/bindings/leds/leds-is31fl32xx.txt
+++ b/Documentation/devicetree/bindings/leds/leds-is31fl32xx.txt
@@ -15,6 +15,8 @@ Required properties:
 - reg: I2C slave address
 - address-cells : must be 1
 - size-cells : must be 0
+- sdb-gpios : (optional)
+  Specifier of the GPIO connected to SDB pin.
 
 LED sub-node properties:
 - reg : LED channel number (1..N)
@@ -31,6 +33,7 @@ is31fl3236: led-controller@3c {
reg = <0x3c>;
#address-cells = <1>;
#size-cells = <0>;
+   sdb-gpios = < 11 GPIO_ACTIVE_HIGH>;
 
led@1 {
reg = <1>;
-- 
2.17.1




[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