Skip to contentSkip to conversation

dt-bindings: leds: Add bindings for lm3697 driver

PATCH Superseded Dan Murphy 4 participants 11 messages Aug 17, 2018 – Sep 7, 2018

Subsystems (2)

v5 of 11 Superseded Latest is v11 →

lore
Share & tools
lore

Dan Murphy

author
#0 lore raw

PATCH v5 1/2 dt-bindings: leds: Add bindings for lm3697 driver

Add the device tree bindings for the lm3697
LED driver for backlighting and display.

---

v5 - Fix the comment for the example - https://lore.kernel.org/patchwork/patch/975060/

v4 - Removed HVLED definition in favor of HVLED place definition - https://lore.kernel.org/patchwork/patch/974812/
v3 - Updated subject with prefered title - https://lore.kernel.org/patchwork/patch/972337/
v2 - Fixed subject and patch commit message - https://lore.kernel.org/patchwork/patch/971326/

 .../devicetree/bindings/leds/leds-lm3697.txt  | 86 +++++++++++++++++++
 1 file changed, 86 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/leds/leds-lm3697.txt
Documentation/devicetree/bindings/leds/leds-lm3697.txt new file +86 -0
new file mode 100644
index 000000000000..76a529c69438
@@ -0,0 +1,86 @@
+* Texas Instruments - LM3697 Highly Efficient White LED Driver
+
+The LM3697 11-bit LED driver provides high-
+performance backlight dimming for 1, 2, or 3 series
+LED strings while delivering up to 90% efficiency.
+
+This device is suitable for Display and Keypad Lighting
+
+Required properties:
+	- compatible:
+		"ti,lm3967"
+	- reg :  I2C slave address
+	- #address-cells : 1
+	- #size-cells : 0
+
+Optional properties:
+	- enable-gpios : gpio pin to enable/disable the device.
+	- vled-supply : LED supply
+
+Required child properties:
+	- reg : 0 - LED is Controlled by bank A
+		1 - LED is Controlled by bank B
+	- led-sources : Indicates which HVLED string is associated to which
+			control bank.  Each element in the array is associated
+			with a specific HVLED string.  Element 0 is HVLED1,
+			element 1 is HVLED2 and element 2 HVLED3.
+			Additional information is contained
+			in Documentation/devicetree/bindings/leds/common.txt
+			0 - HVLED is not active in this control bank
+			1 - HVLED string is controlled by this control bank
+
+Optional child properties:
+	- label : see Documentation/devicetree/bindings/leds/common.txt
+	- linux,default-trigger :
+	   see Documentation/devicetree/bindings/leds/common.txt
+
+Example:
+
+HVLED string 1 and 3 are controlled by control bank A and HVLED 2 string is
+controlled by control bank B.
+
+led-controller@36 {
+	compatible = "ti,lm3967";
+	reg = <0x36>;
+	#address-cells = <1>;
+	#size-cells = <0>;
+
+	enable-gpios = <&gpio1 28 GPIO_ACTIVE_HIGH>;
+	vled-supply = <&vbatt>;
+
+	led@0 {
+		reg = <0>;
+		led-sources = <1 0 1>;
+		label = "white:first_backlight_cluster";
+		linux,default-trigger = "backlight";
+	};
+
+	led@1 {
+		reg = <1>;
+		led-sources = <0 1 0>;
+		label = "white:second_backlight_cluster";
+		linux,default-trigger = "backlight";
+	};
+}
+
+All HVLED strings controlled by control bank A
+
+led-controller@36 {
+	compatible = "ti,lm3967";
+	reg = <0x36>;
+	#address-cells = <1>;
+	#size-cells = <0>;
+
+	enable-gpios = <&gpio1 28 GPIO_ACTIVE_HIGH>;
+	vled-supply = <&vbatt>;
+
+	led@0 {
+		reg = <0>;
+		led-sources = <1 1 1>;
+		label = "white:backlight_cluster";
+		linux,default-trigger = "backlight";
+	};
+}
+
+For more product information please see the link below:
+http://www.ti.com/lit/ds/symlink/lm3697.pdf
Signature · 1 line
2.17.0.582.gccdcbd54c
author
#1 lore raw

PATCH v5 2/2 leds: lm3697: Introduce the lm3697 driver

Introduce the lm3697 LED driver for
backlighting and display.

Datasheet location:
http://www.ti.com/lit/ds/symlink/lm3697.pdf

---

v5 - Fix nitpick issues with code - https://lore.kernel.org/patchwork/patch/975061/

v4 - Made modifications to the control bank routine to accomodate the DT changes
https://lore.kernel.org/patchwork/patch/974811/
v3 - Add code to support led-sources and control bank configuration also fix other miscellaneous issues reported- https://lore.kernel.org/patchwork/patch/972336/
v2 - Removed unneed 'of' calls in dt_parse, fixed comment, fixed checkpatch error, and change led registration - https://lore.kernel.org/patchwork/patch/971327/

 drivers/leds/Kconfig       |   9 +
 drivers/leds/Makefile      |   1 +
 drivers/leds/leds-lm3697.c | 379 +++++++++++++++++++++++++++++++++++++
 3 files changed, 389 insertions(+)
 create mode 100644 drivers/leds/leds-lm3697.c
drivers/leds/Kconfig +9 -0
index 44097a3e0fcc..784cbe375724 100644
@@ -151,6 +151,15 @@ config LEDS_LM3642
 	  converter plus 1.5A constant current driver for a high-current
 	  white LED.
 
+config LEDS_LM3697
+	tristate "LED support for LM3697 Chip"
+	depends on LEDS_CLASS && I2C
+	select REGMAP_I2C
+	help
+	  This option enables support for LEDs connected to LM3697.
+	  The LM3697 is an 11 bit high performance backlight driver for
+	  keypad and display lighting.
+
 config LEDS_LM3692X
 	tristate "LED support for LM3692x Chips"
 	depends on LEDS_CLASS && I2C && OF
drivers/leds/Makefile +1 -0
index 420b5d2cfa62..2813f089f3db 100644
@@ -19,6 +19,7 @@ obj-$(CONFIG_LEDS_LOCOMO)		+= leds-locomo.o
 obj-$(CONFIG_LEDS_LM3530)		+= leds-lm3530.o
 obj-$(CONFIG_LEDS_LM3533)		+= leds-lm3533.o
 obj-$(CONFIG_LEDS_LM3642)		+= leds-lm3642.o
+obj-$(CONFIG_LEDS_LM3697)		+= leds-lm3697.o
 obj-$(CONFIG_LEDS_MIKROTIK_RB532)	+= leds-rb532.o
 obj-$(CONFIG_LEDS_S3C24XX)		+= leds-s3c24xx.o
 obj-$(CONFIG_LEDS_NET48XX)		+= leds-net48xx.o
drivers/leds/leds-lm3697.c new file +379 -0

379 lines not on this page · raw message

Signature · 1 line
2.17.0.582.gccdcbd54c
#2 lore raw

Re: [PATCH v5 2/2] leds: lm3697: Introduce the lm3697 driver

Hi!

Quoted 10 lines

+/**
+ * struct lm3697 -
+ * @enable_gpio - Hardware enable gpio
+ * @regulator - LED supply regulator pointer
+ * @client - Pointer to the I2C client
+ * @regmap - Devices register map
+ * @dev - Pointer to the devices device struct
+ * @lock - Lock for reading/writing the device
+ * @leds - Array of LED strings.
+ */

extra .

drivers/leds/leds-lm3697.c line 155

Quoted 6 lines
drivers/leds/leds-lm3697.c new file +6 -0
+	ret = regmap_write(led->priv->regmap, brt_msb_reg, brt_val);
+	if (ret) {
+		dev_err(&led->priv->client->dev, "Cannot write MSB\n");
+		goto out;
+	}
+out:

I'd avoid this goto.

drivers/leds/leds-lm3697.c line 168

Quoted 9 lines
drivers/leds/leds-lm3697.c new file +9 -0
+static int lm3697_set_control_bank(struct lm3697 *priv)
+{
+	u8 control_bank_config = 0;
+	struct lm3697_led *led;
+	int ret, i;
+
+	led = &priv->leds[0];
+	if (led->control_bank == LM3697_CONTROL_A)
+		led = &priv->leds[1];

I'd expect CONTROL_A to correspond to leds[0]...?

drivers/leds/leds-lm3697.c line 173

Quoted 4 lines
drivers/leds/leds-lm3697.c new file +4 -0
+	for (i = 0; i < LM3697_MAX_LED_STRINGS; i++) {
+		if (led->hvled_strings[i] == LM3697_HVLED_ASSIGNMENT)
+			control_bank_config |= 1 << i;
+	}

Extra {}s.

drivers/leds/leds-lm3697.c line 231

Quoted 3 lines
drivers/leds/leds-lm3697.c new file +3 -0
+	priv->regulator = devm_regulator_get(&priv->client->dev, "vled");
+	if (IS_ERR(priv->regulator))
+		priv->regulator = NULL;

If vled regulator is specified in dt and _get fails, is it worth a warning?

Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
author
#3 lore raw

Re: [PATCH v5 2/2] leds: lm3697: Introduce the lm3697 driver

Jacek

Quoted 43 lines · Pavel Machek

Hi!

Quoted 10 lines

+/**
+ * struct lm3697 -
+ * @enable_gpio - Hardware enable gpio
+ * @regulator - LED supply regulator pointer
+ * @client - Pointer to the I2C client
+ * @regmap - Devices register map
+ * @dev - Pointer to the devices device struct
+ * @lock - Lock for reading/writing the device
+ * @leds - Array of LED strings.
+ */

extra .

drivers/leds/leds-lm3697.c line 155

Quoted 6 lines
drivers/leds/leds-lm3697.c new file +6 -0
+	ret = regmap_write(led->priv->regmap, brt_msb_reg, brt_val);
+	if (ret) {
+		dev_err(&led->priv->client->dev, "Cannot write MSB\n");
+		goto out;
+	}
+out:

I'd avoid this goto.

drivers/leds/leds-lm3697.c line 168

Quoted 9 lines
drivers/leds/leds-lm3697.c new file +9 -0
+static int lm3697_set_control_bank(struct lm3697 *priv)
+{
+	u8 control_bank_config = 0;
+	struct lm3697_led *led;
+	int ret, i;
+
+	led = &priv->leds[0];
+	if (led->control_bank == LM3697_CONTROL_A)
+		led = &priv->leds[1];

I'd expect CONTROL_A to correspond to leds[0]...?

drivers/leds/leds-lm3697.c line 173

Quoted 4 lines
drivers/leds/leds-lm3697.c new file +4 -0
+	for (i = 0; i < LM3697_MAX_LED_STRINGS; i++) {
+		if (led->hvled_strings[i] == LM3697_HVLED_ASSIGNMENT)
+			control_bank_config |= 1 << i;
+	}

Extra {}s.

Quoted 9 lines

drivers/leds/leds-lm3697.c line 231

Quoted 3 lines
drivers/leds/leds-lm3697.c new file +3 -0
+	priv->regulator = devm_regulator_get(&priv->client->dev, "vled");
+	if (IS_ERR(priv->regulator))
+		priv->regulator = NULL;

If vled regulator is specified in dt and _get fails, is it worth a warning?

Pavel

Do you want v6 or a new patch on top?

Dan

Signature · 2 lines
------------------
Dan Murphy
#4 lore raw

Re: [PATCH v5 2/2] leds: lm3697: Introduce the lm3697 driver

Dan,

Quoted 53 lines · Dan Murphy

Jacek

Quoted 50 lines · Pavel Machek

Hi!

Quoted 10 lines

+/**
+ * struct lm3697 -
+ * @enable_gpio - Hardware enable gpio
+ * @regulator - LED supply regulator pointer
+ * @client - Pointer to the I2C client
+ * @regmap - Devices register map
+ * @dev - Pointer to the devices device struct
+ * @lock - Lock for reading/writing the device
+ * @leds - Array of LED strings.
+ */

extra .

drivers/leds/leds-lm3697.c line 155

Quoted 6 lines
drivers/leds/leds-lm3697.c new file +6 -0
+	ret = regmap_write(led->priv->regmap, brt_msb_reg, brt_val);
+	if (ret) {
+		dev_err(&led->priv->client->dev, "Cannot write MSB\n");
+		goto out;
+	}
+out:

I'd avoid this goto.

drivers/leds/leds-lm3697.c line 168

Quoted 9 lines
drivers/leds/leds-lm3697.c new file +9 -0
+static int lm3697_set_control_bank(struct lm3697 *priv)
+{
+	u8 control_bank_config = 0;
+	struct lm3697_led *led;
+	int ret, i;
+
+	led = &priv->leds[0];
+	if (led->control_bank == LM3697_CONTROL_A)
+		led = &priv->leds[1];

I'd expect CONTROL_A to correspond to leds[0]...?

drivers/leds/leds-lm3697.c line 173

Quoted 4 lines
drivers/leds/leds-lm3697.c new file +4 -0
+	for (i = 0; i < LM3697_MAX_LED_STRINGS; i++) {
+		if (led->hvled_strings[i] == LM3697_HVLED_ASSIGNMENT)
+			control_bank_config |= 1 << i;
+	}

Extra {}s.

drivers/leds/leds-lm3697.c line 231

Quoted 3 lines
drivers/leds/leds-lm3697.c new file +3 -0
+	priv->regulator = devm_regulator_get(&priv->client->dev, "vled");
+	if (IS_ERR(priv->regulator))
+		priv->regulator = NULL;

If vled regulator is specified in dt and _get fails, is it worth a warning?

Quoted 4 lines
Quoted 2 lines

Pavel

Do you want v6 or a new patch on top?

Please submit v6.

Signature · 2 lines
Best regards,
Jacek Anaszewski
author
#5 lore raw

Re: [PATCH v5 2/2] leds: lm3697: Introduce the lm3697 driver

In reply to Pavel Machek

Pavel

Quoted 2 lines · Pavel Machek

Hi!

I am going to go ahead and update this code anyway and if we get the ti-lmu code in then we can adapt this code to use that framework

Quoted 11 lines
Quoted 10 lines

+/**
+ * struct lm3697 -
+ * @enable_gpio - Hardware enable gpio
+ * @regulator - LED supply regulator pointer
+ * @client - Pointer to the I2C client
+ * @regmap - Devices register map
+ * @dev - Pointer to the devices device struct
+ * @lock - Lock for reading/writing the device
+ * @leds - Array of LED strings.
+ */

Quoted 1 line

extra .

ACK

Quoted 9 lines

drivers/leds/leds-lm3697.c line 155

Quoted 7 lines
drivers/leds/leds-lm3697.c new file +6 -0
+	ret = regmap_write(led->priv->regmap, brt_msb_reg, brt_val);
+	if (ret) {
+		dev_err(&led->priv->client->dev, "Cannot write MSB\n");
+		goto out;
+	}
+out:

I'd avoid this goto.

Ack

Quoted 12 lines

drivers/leds/leds-lm3697.c line 168

Quoted 10 lines
drivers/leds/leds-lm3697.c new file +9 -0
+static int lm3697_set_control_bank(struct lm3697 *priv)
+{
+	u8 control_bank_config = 0;
+	struct lm3697_led *led;
+	int ret, i;
+
+	led = &priv->leds[0];
+	if (led->control_bank == LM3697_CONTROL_A)
+		led = &priv->leds[1];

I'd expect CONTROL_A to correspond to leds[0]...?

Not always there can be a situation where all HVLEDs can be configured for control bank B

Quoted 7 lines

drivers/leds/leds-lm3697.c line 173

Quoted 5 lines
drivers/leds/leds-lm3697.c new file +4 -0
+	for (i = 0; i < LM3697_MAX_LED_STRINGS; i++) {
+		if (led->hvled_strings[i] == LM3697_HVLED_ASSIGNMENT)
+			control_bank_config |= 1 << i;
+	}

Extra {}s.

Ack

Quoted 7 lines

drivers/leds/leds-lm3697.c line 231

Quoted 4 lines
drivers/leds/leds-lm3697.c new file +3 -0
+	priv->regulator = devm_regulator_get(&priv->client->dev, "vled");
+	if (IS_ERR(priv->regulator))
+		priv->regulator = NULL;

If vled regulator is specified in dt and _get fails, is it worth a warning?

Hmmm. That would be annoying on boot to have a warning on an optional parameter. But if we need it I can add it.

Dan

Quoted 3 lines

Pavel

Signature · 2 lines
------------------
Dan Murphy
maintainer Reviewed-by on v5 1/2
#6 lore raw
In reply to Dan Murphy
Quoted 8 lines · Dan Murphy

Add the device tree bindings for the lm3697
LED driver for backlighting and display.

---

v5 - Fix the comment for the example - https://lore.kernel.org/patchwork/patch/975060/

Quoted 8 lines

v4 - Removed HVLED definition in favor of HVLED place definition - https://lore.kernel.org/patchwork/patch/974812/
v3 - Updated subject with prefered title - https://lore.kernel.org/patchwork/patch/972337/
v2 - Fixed subject and patch commit message - https://lore.kernel.org/patchwork/patch/971326/

 .../devicetree/bindings/leds/leds-lm3697.txt  | 86 +++++++++++++++++++
 1 file changed, 86 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/leds/leds-lm3697.txt
Acked-by on v5 1/2
#7 lore raw
In reply to Dan Murphy
Quoted 4 lines · Dan Murphy

Add the device tree bindings for the lm3697
LED driver for backlighting and display.

Some nits are below.

Documentation/devicetree/bindings/leds/leds-lm3697.txt line 5

Quoted 3 lines
Documentation/devicetree/bindings/leds/leds-lm3697.txt new file +3 -0
+The LM3697 11-bit LED driver provides high-
+performance backlight dimming for 1, 2, or 3 series
+LED strings while delivering up to 90% efficiency.

LED core is 8-bit only... so full dynamic range can not be currently used in linux -- right? Is there any plan to change/fix that?

Quoted 1 line

+This device is suitable for Display and Keypad Lighting

"display and keypad lighting."

Documentation/devicetree/bindings/leds/leds-lm3697.txt line 17

Quoted 2 lines
Documentation/devicetree/bindings/leds/leds-lm3697.txt new file +2 -0
+Optional properties:
+	- enable-gpios : gpio pin to enable/disable the device.

Remove "." at end of sentence, for consistency. "GPIO"?

Quoted 1 line

+All HVLED strings controlled by control bank A

":"?

Quoted 19 lines
Documentation/devicetree/bindings/leds/leds-lm3697.txt new file +19 -0
+led-controller@36 {
+	compatible = "ti,lm3967";
+	reg = <0x36>;
+	#address-cells = <1>;
+	#size-cells = <0>;
+
+	enable-gpios = <&gpio1 28 GPIO_ACTIVE_HIGH>;
+	vled-supply = <&vbatt>;
+
+	led@0 {
+		reg = <0>;
+		led-sources = <1 1 1>;
+		label = "white:backlight_cluster";
+		linux,default-trigger = "backlight";
+	};
+}
+
+For more product information please see the link below:
+http://www.ti.com/lit/ds/symlink/lm3697.pdf
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#8 lore raw

Hi Pavel,

Quoted 8 lines · Pavel Machek
Quoted 4 lines · Dan Murphy

Add the device tree bindings for the lm3697
LED driver for backlighting and display.

Quoted 7 lines

Some nits are below.

Documentation/devicetree/bindings/leds/leds-lm3697.txt line 5

Quoted 3 lines
Documentation/devicetree/bindings/leds/leds-lm3697.txt new file +3 -0
+The LM3697 11-bit LED driver provides high-
+performance backlight dimming for 1, 2, or 3 series
+LED strings while delivering up to 90% efficiency.

LED core is 8-bit only...

That's not true since this commit:

commit 1bd465e6b0e2b559db47420fea686507a01cfab0

Author: Guennadi Liakhovetski <[email protected]>
Date:   Sat Jan 10 18:54:39 2009 +0000

leds: allow led-drivers to use a variable range of brightness values

This patch allows drivers to override the default maximum brightness
value
of 255. We take care to preserve backwards-compatibility as much as possible, so that user-space ABI doesn't change for existing drivers. LED trigger code has also been updated to use the per-LED maximum.

but I missed that max_brightness is not initialized in the driver, so the core will set it to LED_FULL (255) anyway.

Quoted 36 lines

so full dynamic range can not be currently
used in linux -- right? Is there any plan to change/fix that?

Quoted 1 line

+This device is suitable for Display and Keypad Lighting

"display and keypad lighting."

Documentation/devicetree/bindings/leds/leds-lm3697.txt line 17

Quoted 2 lines
Documentation/devicetree/bindings/leds/leds-lm3697.txt new file +2 -0
+Optional properties:
+	- enable-gpios : gpio pin to enable/disable the device.

Remove "." at end of sentence, for consistency. "GPIO"?

Quoted 1 line

+All HVLED strings controlled by control bank A

":"?

Quoted 19 lines
Documentation/devicetree/bindings/leds/leds-lm3697.txt new file +19 -0
+led-controller@36 {
+	compatible = "ti,lm3967";
+	reg = <0x36>;
+	#address-cells = <1>;
+	#size-cells = <0>;
+
+	enable-gpios = <&gpio1 28 GPIO_ACTIVE_HIGH>;
+	vled-supply = <&vbatt>;
+
+	led@0 {
+		reg = <0>;
+		led-sources = <1 1 1>;
+		label = "white:backlight_cluster";
+		linux,default-trigger = "backlight";
+	};
+}
+
+For more product information please see the link below:
+http://www.ti.com/lit/ds/symlink/lm3697.pdf
Signature · 2 lines
Best regards,
Jacek Anaszewski
author
#9 lore raw
In reply to Pavel Machek

Pavel

Quoted 8 lines · Pavel Machek
Quoted 4 lines · Dan Murphy

Add the device tree bindings for the lm3697
LED driver for backlighting and display.

Quoted 9 lines

Some nits are below.

Documentation/devicetree/bindings/leds/leds-lm3697.txt line 5

Quoted 3 lines
Documentation/devicetree/bindings/leds/leds-lm3697.txt new file +3 -0
+The LM3697 11-bit LED driver provides high-
+performance backlight dimming for 1, 2, or 3 series
+LED strings while delivering up to 90% efficiency.

LED core is 8-bit only... so full dynamic range can not be currently used in linux -- right? Is there any plan to change/fix that?

Jacek answered this.

Quoted 4 lines
Quoted 1 line

+This device is suitable for Display and Keypad Lighting

"display and keypad lighting."

Ack

Quoted 8 lines

Documentation/devicetree/bindings/leds/leds-lm3697.txt line 17

Quoted 2 lines
Documentation/devicetree/bindings/leds/leds-lm3697.txt new file +2 -0
+Optional properties:
+	- enable-gpios : gpio pin to enable/disable the device.

Remove "." at end of sentence, for consistency. "GPIO"?

Quoted 1 line

+All HVLED strings controlled by control bank A

":"?

Not sure what you are asking for here.

Quoted 21 lines
Quoted 20 lines
Documentation/devicetree/bindings/leds/leds-lm3697.txt new file +19 -0
+led-controller@36 {
+	compatible = "ti,lm3967";
+	reg = <0x36>;
+	#address-cells = <1>;
+	#size-cells = <0>;
+
+	enable-gpios = <&gpio1 28 GPIO_ACTIVE_HIGH>;
+	vled-supply = <&vbatt>;
+
+	led@0 {
+		reg = <0>;
+		led-sources = <1 1 1>;
+		label = "white:backlight_cluster";
+		linux,default-trigger = "backlight";
+	};
+}
+
+For more product information please see the link below:
+http://www.ti.com/lit/ds/symlink/lm3697.pdf
Signature · 2 lines
------------------
Dan Murphy
#10 lore raw

Hi!

Quoted 5 lines
Quoted 3 lines
Quoted 1 line

+All HVLED strings controlled by control bank A

":"?

Not sure what you are asking for here.

Text looked like missing ":" at end of line.

Best regards,
Pavel

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