Skip to contentSkip to conversation

backlight_lm3630a: add enable_gpios property

PATCH Superseded Andreas Kemnade 3 participants 8 messages Sep 11, 2019 – Sep 12, 2019

Subsystems (4)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v3 cover backlight_lm3630a: add enable_gpios property

To be able to handle the HWEN pin of the lm3630a, add an enable gpio to the driver and a property.

Tested on Kobo Clara HD.

Changes in v2:
simplification and reordering

Changes in v3:
added acked-by
removed legacy include

Andreas Kemnade (2):
dt-bindings: backlight: lm3630a: add enable_gpios
backlight: lm3630a: add an enable gpio for the HWEN pin

 .../bindings/leds/backlight/lm3630a-backlight.yaml       | 5 +++++
 drivers/video/backlight/lm3630a_bl.c                     | 9 +++++++++
 2 files changed, 14 insertions(+)
Signature · 1 line
2.20.1
#1 lore raw

PATCH v3 1/2 dt-bindings: backlight: lm3630a: add enable_gpios

add enable-gpios to describe HWEN pin

---
changes in v2: added example
changes in v3: added Acked-by

 .../bindings/leds/backlight/lm3630a-backlight.yaml           | 5 +++++
 1 file changed, 5 insertions(+)
Documentation/devicetree/bindings/leds/backlight/lm3630a-backlight.yaml +5 -0
index dc129d9a329e..1fa83feffe16 100644
@@ -29,6 +29,10 @@ properties:
   '#size-cells':
     const: 0
 
+  enable-gpios:
+    description: GPIO to use to enable/disable the backlight (HWEN pin).
+    maxItems: 1
+
 required:
   - compatible
   - reg
@@ -92,6 +96,7 @@ examples:
     i2c {
         #address-cells = <1>;
         #size-cells = <0>;
+        enable-gpios = <&gpio2 5 GPIO_ACTIVE_HIGH>;
 
         led-controller@38 {
                 compatible = "ti,lm3630a";
Signature · 1 line
2.20.1
Reviewed-by on v3 1/2
#2 lore raw

Re: [PATCH v3 1/2] dt-bindings: backlight: lm3630a: add enable_gpios

Andreas

Quoted 26 lines · Andreas Kemnade

add enable-gpios to describe HWEN pin

---
changes in v2: added example
changes in v3: added Acked-by

  .../bindings/leds/backlight/lm3630a-backlight.yaml           | 5 +++++
  1 file changed, 5 insertions(+)
Documentation/devicetree/bindings/leds/backlight/lm3630a-backlight.yaml +4 -0
index dc129d9a329e..1fa83feffe16 100644
@@ -29,6 +29,10 @@ properties:
    '#size-cells':
      const: 0
 
+  enable-gpios:
+    description: GPIO to use to enable/disable the backlight (HWEN pin).
+    maxItems: 1
+
  required:
    - compatible
    - reg

Documentation/devicetree/bindings/leds/backlight/lm3630a-backlight.yaml examples: · line 102

Quoted 7 lines
Documentation/devicetree/bindings/leds/backlight/lm3630a-backlight.yaml +1 -0
@@ -92,6 +96,7 @@ examples:
      i2c {
          #address-cells = <1>;
          #size-cells = <0>;
+        enable-gpios = <&gpio2 5 GPIO_ACTIVE_HIGH>;
 
          led-controller@38 {
                  compatible = "ti,lm3630a";

Looks good to me

#3 lore raw

Re: [PATCH v3 1/2] dt-bindings: backlight: lm3630a: add enable_gpios

Quoted 34 lines · On Thu, 12 Sep 2019 06:39:50 -0500 Dan Murphy <[email protected]> wrote:

Andreas

Quoted 31 lines · Andreas Kemnade

add enable-gpios to describe HWEN pin

---
changes in v2: added example
changes in v3: added Acked-by

  .../bindings/leds/backlight/lm3630a-backlight.yaml           | 5 +++++
  1 file changed, 5 insertions(+)
Documentation/devicetree/bindings/leds/backlight/lm3630a-backlight.yaml +5 -0
index dc129d9a329e..1fa83feffe16 100644
@@ -29,6 +29,10 @@ properties:
    '#size-cells':
      const: 0
 
+  enable-gpios:
+    description: GPIO to use to enable/disable the backlight (HWEN pin).
+    maxItems: 1
+
  required:
    - compatible
    - reg
@@ -92,6 +96,7 @@ examples:
      i2c {
          #address-cells = <1>;
          #size-cells = <0>;
+        enable-gpios = <&gpio2 5 GPIO_ACTIVE_HIGH>;
 
Quoted 5 lines

Documentation/devicetree/bindings/leds/backlight/lm3630a-backlight.yaml examples: · line 102

Quoted 2 lines
Documentation/devicetree/bindings/leds/backlight/lm3630a-backlight.yaml +0 -0
          led-controller@38 {
                  compatible = "ti,lm3630a";  

Looks good to me

well, the enable-gpios is still at the same place as in v2. This was sent before your comments to v2 have been arrived.

Regards,
Andreas

#4 lore raw

Re: [PATCH v3 1/2] dt-bindings: backlight: lm3630a: add enable_gpios

Andreas

Quoted 37 lines · Andreas Kemnade
Quoted 34 lines · On Thu, 12 Sep 2019 06:39:50 -0500 Dan Murphy <[email protected]> wrote:

Andreas

Quoted 31 lines · Andreas Kemnade

add enable-gpios to describe HWEN pin

---
changes in v2: added example
changes in v3: added Acked-by

   .../bindings/leds/backlight/lm3630a-backlight.yaml           | 5 +++++
   1 file changed, 5 insertions(+)
Documentation/devicetree/bindings/leds/backlight/lm3630a-backlight.yaml +5 -0
index dc129d9a329e..1fa83feffe16 100644
@@ -29,6 +29,10 @@ properties:
     '#size-cells':
       const: 0
 
+  enable-gpios:
+    description: GPIO to use to enable/disable the backlight (HWEN pin).
+    maxItems: 1
+
   required:
     - compatible
     - reg
@@ -92,6 +96,7 @@ examples:
       i2c {
           #address-cells = <1>;
           #size-cells = <0>;
+        enable-gpios = <&gpio2 5 GPIO_ACTIVE_HIGH>;
 
Quoted 6 lines
Quoted 4 lines

Documentation/devicetree/bindings/leds/backlight/lm3630a-backlight.yaml examples: · line 102

Quoted 2 lines
Documentation/devicetree/bindings/leds/backlight/lm3630a-backlight.yaml +0 -0
           led-controller@38 {
                   compatible = "ti,lm3630a";

Looks good to me

well, the enable-gpios is still at the same place as in v2. This was sent before your comments to v2 have been arrived.

Ah I overlooked that.  Yeah that still needs to move I assumed you moved it.

Dan

Quoted 2 lines

Regards,
Andreas

#5 lore raw

PATCH v3 2/2 backlight: lm3630a: add an enable gpio for the HWEN pin

In reply to Andreas Kemnade

For now just enable it in the probe function to allow i2c access. Disabling also means resetting the register values to default and according to the datasheet does not give power savings.

Tested on Kobo Clara HD.

---
changes in v2:
- simplification
- correct gpio direction initialisation

changes in v3:
- removed legacy include

 drivers/video/backlight/lm3630a_bl.c | 9 +++++++++
 1 file changed, 9 insertions(+)
drivers/video/backlight/lm3630a_bl.c +9 -0
index 8f84f3684f04..d9e67b9b2571 100644
@@ -12,6 +12,7 @@
 #include <linux/uaccess.h>
 #include <linux/interrupt.h>
 #include <linux/regmap.h>
+#include <linux/gpio/consumer.h>
 #include <linux/pwm.h>
 #include <linux/platform_data/lm3630a_bl.h>
 
@@ -48,6 +49,7 @@ struct lm3630a_chip {
 	struct lm3630a_platform_data *pdata;
 	struct backlight_device *bleda;
 	struct backlight_device *bledb;
+	struct gpio_desc *enable_gpio;
 	struct regmap *regmap;
 	struct pwm_device *pwmd;
 };
@@ -535,6 +537,13 @@ static int lm3630a_probe(struct i2c_client *client,
 	}
 	pchip->pdata = pdata;
 
+	pchip->enable_gpio = devm_gpiod_get_optional(&client->dev, "enable",
+						GPIOD_OUT_HIGH);
+	if (IS_ERR(pchip->enable_gpio)) {
+		rval = PTR_ERR(pchip->enable_gpio);
+		return rval;
+	}
+
 	/* chip initialize */
 	rval = lm3630a_chip_init(pchip);
 	if (rval < 0) {
Signature · 1 line
2.20.1
Reviewed-by on v3 2/2
#6 lore raw

Re: [PATCH v3 2/2] backlight: lm3630a: add an enable gpio for the HWEN pin

Quoted 8 lines · Andreas Kemnade

For now just enable it in the probe function to allow i2c access. Disabling also means resetting the register values to default and according to the datasheet does not give power savings.

Tested on Kobo Clara HD.

Make sure Dan is happy w.r.t. his review comments but if this driver is unchanged when you spin v4 (for the DT changes) then feel free to add:

Daniel.

Quoted 48 lines

---
changes in v2:
- simplification
- correct gpio direction initialisation

changes in v3:
- removed legacy include

 drivers/video/backlight/lm3630a_bl.c | 9 +++++++++
 1 file changed, 9 insertions(+)
drivers/video/backlight/lm3630a_bl.c +9 -0
index 8f84f3684f04..d9e67b9b2571 100644
@@ -12,6 +12,7 @@
 #include <linux/uaccess.h>
 #include <linux/interrupt.h>
 #include <linux/regmap.h>
+#include <linux/gpio/consumer.h>
 #include <linux/pwm.h>
 #include <linux/platform_data/lm3630a_bl.h>
 
@@ -48,6 +49,7 @@ struct lm3630a_chip {
 	struct lm3630a_platform_data *pdata;
 	struct backlight_device *bleda;
 	struct backlight_device *bledb;
+	struct gpio_desc *enable_gpio;
 	struct regmap *regmap;
 	struct pwm_device *pwmd;
 };
@@ -535,6 +537,13 @@ static int lm3630a_probe(struct i2c_client *client,
 	}
 	pchip->pdata = pdata;
 
+	pchip->enable_gpio = devm_gpiod_get_optional(&client->dev, "enable",
+						GPIOD_OUT_HIGH);
+	if (IS_ERR(pchip->enable_gpio)) {
+		rval = PTR_ERR(pchip->enable_gpio);
+		return rval;
+	}
+
 	/* chip initialize */
 	rval = lm3630a_chip_init(pchip);
 	if (rval < 0) {
Signature · 1 line
2.20.1
Reviewed-by on v3 2/2
#7 lore raw

Re: [PATCH v3 2/2] backlight: lm3630a: add an enable gpio for the HWEN pin

In reply to Andreas Kemnade

Andreas

Quoted 43 lines · Andreas Kemnade

For now just enable it in the probe function to allow i2c access. Disabling also means resetting the register values to default and according to the datasheet does not give power savings.

Tested on Kobo Clara HD.

---
changes in v2:
- simplification
- correct gpio direction initialisation

changes in v3:
- removed legacy include

  drivers/video/backlight/lm3630a_bl.c | 9 +++++++++
  1 file changed, 9 insertions(+)
drivers/video/backlight/lm3630a_bl.c +2 -0
index 8f84f3684f04..d9e67b9b2571 100644
@@ -12,6 +12,7 @@
  #include <linux/uaccess.h>
  #include <linux/interrupt.h>
  #include <linux/regmap.h>
+#include <linux/gpio/consumer.h>
  #include <linux/pwm.h>
  #include <linux/platform_data/lm3630a_bl.h>
 
@@ -48,6 +49,7 @@ struct lm3630a_chip {
  	struct lm3630a_platform_data *pdata;
  	struct backlight_device *bleda;
  	struct backlight_device *bledb;
+	struct gpio_desc *enable_gpio;
  	struct regmap *regmap;
  	struct pwm_device *pwmd;
  };
@@ -535,6 +537,13 @@ static int lm3630a_probe(struct i2c_client *client,
  	}
  	pchip->pdata = pdata;
 

drivers/video/backlight/lm3630a_bl.c static int lm3630a_probe(struct i2c_client *client, · line 549

Quoted 10 lines
drivers/video/backlight/lm3630a_bl.c +7 -0
+	pchip->enable_gpio = devm_gpiod_get_optional(&client->dev, "enable",
+						GPIOD_OUT_HIGH);
+	if (IS_ERR(pchip->enable_gpio)) {
+		rval = PTR_ERR(pchip->enable_gpio);
+		return rval;
+	}
+
  	/* chip initialize */
  	rval = lm3630a_chip_init(pchip);
  	if (rval < 0) {

Thanks for the explanation

It looks good to me