Skip to contentSkip to conversation

dt: bindings: lm3692x: Add bindings for lm3692x LED driver

PATCH Superseded Dan Murphy 5 participants 24 messages Nov 15, 2017 – Nov 28, 2017

Subsystems (2)

v3 of 11 Superseded Latest is v11 →

lore
Share & tools
lore

Dan Murphy

author
#0 lore raw

PATCH v3 1/2 dt: bindings: lm3692x: Add bindings for lm3692x LED driver

This adds the devicetree bindings for the LM3692x
I2C LED string driver.

---

v3 - No changes
v2 - No changes - https://patchwork.kernel.org/patch/10056677/

 .../devicetree/bindings/leds/leds-lm3692x.txt      | 28 ++++++++++++++++++++++
 1 file changed, 28 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/leds/leds-lm3692x.txt
Documentation/devicetree/bindings/leds/leds-lm3692x.txt new file +28 -0
new file mode 100644
index 000000000000..cfef67bd4100
@@ -0,0 +1,28 @@
+* Texas Instruments - LM3692x Highly Efficient Dual-String White LED Driver
+
+The LM36922 is an ultra-compact, highly efficient,
+two string white-LED driver designed for LCD display
+backlighting.
+
+Required properties:
+	- compatible:
+		"ti,lm3692x"
+	- reg -  I2C slave address
+
+Optional properties:
+	- label - Used for naming LEDs
+	- enable-gpio - gpio pin to enable/disable the device.
+	- supply - "vled" - LED supply
+
+Example:
+
+leds: leds@6 {
+	compatible = "ti,lm3692x";
+	reg = <0x36>;
+	label = "backlight_cluster";
+	enable-gpio = <&gpio1 28 GPIO_ACTIVE_HIGH>;
+	vled-supply = <&vbatt>;
+}
+
+For more product information please see the link below:
+http://www.ti.com/lit/ds/snvsa29/snvsa29.pdf
Signature · 6 lines
2.15.0.124.g7668cbc60

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
author
#1 lore raw

PATCH v3 2/2 leds: lm3692x: Introduce LM3692x dual string driver

Introducing the LM3692x Dual-String white LED driver.

Data sheet is located
http://www.ti.com/lit/ds/snvsa29/snvsa29.pdf

---

v3 - Add missing Makefile and Kconfig from v1 and v2 - https://patchwork.kernel.org/patch/10060075/

v2 - Added data sheet link, fixed linuxdoc format, returned on failure in init routine, return on fault_check failure, updated brightness calculation and fixed capitalization issue - https://patchwork.kernel.org/patch/10056675/

 drivers/leds/Kconfig        |   7 +
 drivers/leds/Makefile       |   1 +
 drivers/leds/leds-lm3692x.c | 390 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 398 insertions(+)
 create mode 100644 drivers/leds/leds-lm3692x.c
drivers/leds/Kconfig +7 -0
index 318a28fd58fe..1363e77a7d5f 100644
@@ -137,6 +137,13 @@ config LEDS_LM3642
 	  converter plus 1.5A constant current driver for a high-current
 	  white LED.
 
+config LEDS_LM3692X
+	tristate "LED support for LM3692x Chips"
+	depends on LEDS_CLASS && I2C
+	select REGMAP_I2C
+	help
+	  This option enables support for the TI LM3692x family
+	  of LED drivers.
 
 config LEDS_LOCOMO
 	tristate "LED Support for Locomo device"
drivers/leds/Makefile +1 -0
index a2a6b5a4f86d..987884a5b9a5 100644
@@ -74,6 +74,7 @@ obj-$(CONFIG_LEDS_PM8058)		+= leds-pm8058.o
 obj-$(CONFIG_LEDS_MLXCPLD)		+= leds-mlxcpld.o
 obj-$(CONFIG_LEDS_NIC78BX)		+= leds-nic78bx.o
 obj-$(CONFIG_LEDS_MT6323)		+= leds-mt6323.o
+obj-$(CONFIG_LEDS_LM3692X)		+= leds-lm3692x.o
 
 # LED SPI Drivers
 obj-$(CONFIG_LEDS_DAC124S085)		+= leds-dac124s085.o
drivers/leds/leds-lm3692x.c new file +390 -0

390 lines not on this page · raw message

Signature · 6 lines
2.15.0.124.g7668cbc60

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Acked-by on v3 2/2
#2 lore raw

Re: [PATCH v3 2/2] leds: lm3692x: Introduce LM3692x dual string driver

Hi!

Quoted 3 lines

Introducing the LM3692x Dual-String white LED driver.

Data sheet is located

"located at"? (Twice.)

drivers/leds/Kconfig config LEDS_LM3642 · line 146

Quoted 11 lines

http://www.ti.com/lit/ds/snvsa29/snvsa29.pdf

drivers/leds/Kconfig +7 -0
+config LEDS_LM3692X
+	tristate "LED support for LM3692x Chips"
+	depends on LEDS_CLASS && I2C
+	select REGMAP_I2C
+	help
+	  This option enables support for the TI LM3692x family
+	  of LED drivers.

"If unsure ..., module will be named..."

Might want to say this is for backlight LEDs here.

Quoted 7 lines
drivers/leds/leds-lm3692x.c new file +7 -0
+static int lm3692x_fault_check(struct lm3692x_led *led)
+{
+	int ret, fault;
+	unsigned int read_buf;
+
+	ret = regmap_read(led->regmap, LM3692X_FAULT_FLAGS, &read_buf);
+	if (ret)

drivers/leds/leds-lm3692x.c line 163

Quoted 10 lines
drivers/leds/leds-lm3692x.c new file +10 -0
+		return ret;
+
+	fault = read_buf;
+
+	if (fault)
+		dev_err(&led->client->dev, "Detected a fault 0x%X\n",
+			fault);
+
+	return ret;
+}

Get rid of "fault" variable?

Does fault need to be propagated to the caller?

Quoted 16 lines
drivers/leds/leds-lm3692x.c new file +16 -0
+static int lm3692x_init(struct lm3692x_led *led)
+{
+	int ret;
+
+	if (led->regulator) {
+		ret = regulator_enable(led->regulator);
+		if (ret)
+			dev_err(&led->client->dev,
+				"Failed to enable regulator\n");
+			goto out;
+	}
+
+	if (led->enable_gpio)
+		gpiod_direction_output(led->enable_gpio, 1);
+
+	ret = lm3692x_fault_check(led);

drivers/leds/leds-lm3692x.c line 222

Quoted 10 lines
drivers/leds/leds-lm3692x.c new file +10 -0
+	if (ret) {
+		dev_err(&led->client->dev, "Cannot read/clear faults\n");
+		goto out;
+	}
+
+	ret = regmap_write(led->regmap, LM3692X_BRT_CTRL, 0x00);
+	if (ret) {
+		dev_err(&led->client->dev, "Fail writing BRT CTRL\n");
+		goto out;
+	}

How often are those fails reached? Maybe regmap wrapper that would print "reading/writing register XY failed" would be enough?

Otherwise looks good,

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 v3 2/2] leds: lm3692x: Introduce LM3692x dual string driver

Pavel

Quoted 7 lines · Pavel Machek

Hi!

Quoted 3 lines

Introducing the LM3692x Dual-String white LED driver.

Data sheet is located

"located at"? (Twice.)

Actually it is 3x since I call it out in the dt binding as well.

So what to eliminate?

Quoted 15 lines

drivers/leds/Kconfig config LEDS_LM3642 · line 146

Quoted 12 lines

http://www.ti.com/lit/ds/snvsa29/snvsa29.pdf

drivers/leds/Kconfig +7 -0
+config LEDS_LM3692X
+	tristate "LED support for LM3692x Chips"
+	depends on LEDS_CLASS && I2C
+	select REGMAP_I2C
+	help
+	  This option enables support for the TI LM3692x family
+	  of LED drivers.

"If unsure ..., module will be named..."

Quoted 1 line

Might want to say this is for backlight LEDs here.

AcK

Quoted 21 lines
Quoted 8 lines
drivers/leds/leds-lm3692x.c new file +7 -0
+static int lm3692x_fault_check(struct lm3692x_led *led)
+{
+	int ret, fault;
+	unsigned int read_buf;
+
+	ret = regmap_read(led->regmap, LM3692X_FAULT_FLAGS, &read_buf);
+	if (ret)

drivers/leds/leds-lm3692x.c line 163

Quoted 10 lines
drivers/leds/leds-lm3692x.c new file +10 -0
+		return ret;
+
+	fault = read_buf;
+
+	if (fault)
+		dev_err(&led->client->dev, "Detected a fault 0x%X\n",
+			fault);
+
+	return ret;
+}

Get rid of "fault" variable?

Quoted 1 line

Does fault need to be propagated to the caller?

I should probably set ret to fail if I see a fault or as you suggest propagate the fault

Quoted 23 lines
Quoted 23 lines
drivers/leds/leds-lm3692x.c new file +21 -0
+static int lm3692x_init(struct lm3692x_led *led)
+{
+	int ret;
+
+	if (led->regulator) {
+		ret = regulator_enable(led->regulator);
+		if (ret)
+			dev_err(&led->client->dev,
+				"Failed to enable regulator\n");
+			goto out;
+	}
+
+	if (led->enable_gpio)
+		gpiod_direction_output(led->enable_gpio, 1);
+
+	ret = lm3692x_fault_check(led);
+	if (ret) {
+		dev_err(&led->client->dev, "Cannot read/clear faults\n");
+		goto out;
+	}
+
Quoted 8 lines

drivers/leds/leds-lm3692x.c line 222

Quoted 5 lines
drivers/leds/leds-lm3692x.c new file +5 -0
+	ret = regmap_write(led->regmap, LM3692X_BRT_CTRL, 0x00);
+	if (ret) {
+		dev_err(&led->client->dev, "Fail writing BRT CTRL\n");
+		goto out;
+	}

How often are those fails reached? Maybe regmap wrapper that would print "reading/writing register XY failed" would be enough?

Or maybe in the out label I can just dev_err once saying initializing the device failed. These are really only called at probe time. Its the only time init is called.

Dan

Quoted 6 lines

Otherwise looks good,

Pavel

Signature · 6 lines
------------------
Dan Murphy
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#4 lore raw

Re: [PATCH v3 2/2] leds: lm3692x: Introduce LM3692x dual string driver

In reply to Dan Murphy

Hi Dan,

Please find my comments below.

Quoted 341 lines · Dan Murphy

Introducing the LM3692x Dual-String white LED driver.

Data sheet is located
http://www.ti.com/lit/ds/snvsa29/snvsa29.pdf

---

v3 - Add missing Makefile and Kconfig from v1 and v2 - https://patchwork.kernel.org/patch/10060075/

v2 - Added data sheet link, fixed linuxdoc format, returned on failure in init routine, return on fault_check failure, updated brightness calculation and fixed capitalization issue - https://patchwork.kernel.org/patch/10056675/

 drivers/leds/Kconfig        |   7 +
 drivers/leds/Makefile       |   1 +
 drivers/leds/leds-lm3692x.c | 390 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 398 insertions(+)
 create mode 100644 drivers/leds/leds-lm3692x.c
drivers/leds/Kconfig +7 -0
index 318a28fd58fe..1363e77a7d5f 100644
@@ -137,6 +137,13 @@ config LEDS_LM3642
 	  converter plus 1.5A constant current driver for a high-current
 	  white LED.
 
+config LEDS_LM3692X
+	tristate "LED support for LM3692x Chips"
+	depends on LEDS_CLASS && I2C
+	select REGMAP_I2C
+	help
+	  This option enables support for the TI LM3692x family
+	  of LED drivers.
 
 config LEDS_LOCOMO
 	tristate "LED Support for Locomo device"
drivers/leds/Makefile +1 -0
index a2a6b5a4f86d..987884a5b9a5 100644
@@ -74,6 +74,7 @@ obj-$(CONFIG_LEDS_PM8058)		+= leds-pm8058.o
 obj-$(CONFIG_LEDS_MLXCPLD)		+= leds-mlxcpld.o
 obj-$(CONFIG_LEDS_NIC78BX)		+= leds-nic78bx.o
 obj-$(CONFIG_LEDS_MT6323)		+= leds-mt6323.o
+obj-$(CONFIG_LEDS_LM3692X)		+= leds-lm3692x.o
 
 # LED SPI Drivers
 obj-$(CONFIG_LEDS_DAC124S085)		+= leds-dac124s085.o
drivers/leds/leds-lm3692x.c new file +285 -0
new file mode 100644
index 000000000000..9fa7f5a20466
@@ -0,0 +1,390 @@
+/*
+ * TI lm3692x LED Driver
+ *
+ * Copyright (C) 2017 Texas Instruments
+ *
+ * Author: Dan Murphy <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * Data sheet is located
+ * http://www.ti.com/lit/ds/snvsa29/snvsa29.pdf
+ */
+
+#include <linux/i2c.h>
+#include <linux/init.h>
+#include <linux/leds.h>
+#include <linux/regmap.h>
+#include <linux/regulator/consumer.h>
+#include <linux/module.h>
+#include <linux/mutex.h>
+#include <linux/of.h>
+#include <linux/of_gpio.h>
+#include <linux/gpio/consumer.h>
+#include <linux/slab.h>
+
+#define LM3692X_LED_NAME	"lm3692x_led"
+
+#define LM3692X_REV		0x0
+#define LM3692X_RESET		0x1
+#define LM3692X_EN		0x10
+#define LM3692X_BRT_CTRL	0x11
+#define LM3692X_PWM_CTRL	0x12
+#define LM3692X_BOOST_CTRL	0x13
+#define LM3692X_AUTO_FREQ_HI	0x15
+#define LM3692X_AUTO_FREQ_LO	0x16
+#define LM3692X_BL_ADJ_THRESH	0x17
+#define LM3692X_BRT_LSB		0x18
+#define LM3692X_BRT_MSB		0x19
+#define LM3692X_FAULT_CTRL	0x1e
+#define LM3692X_FAULT_FLAGS	0x1f
+
+#define LM3692X_SW_RESET	BIT(0)
+#define LM3692X_DEVICE_EN	BIT(0)
+#define LM3692X_LED1_EN		BIT(1)
+#define LM3692X_LED2_EN		BIT(2)
+
+/* Brightness Control Bits */
+#define LM3692X_BL_ADJ_POL	BIT(0)
+#define LM3692X_RAMP_RATE_125us	0x00
+#define LM3692X_RAMP_RATE_250us	BIT(1)
+#define LM3692X_RAMP_RATE_500us BIT(2)
+#define LM3692X_RAMP_RATE_1ms	(BIT(1) | BIT(2))
+#define LM3692X_RAMP_RATE_2ms	BIT(3)
+#define LM3692X_RAMP_RATE_4ms	(BIT(3) | BIT(1))
+#define LM3692X_RAMP_RATE_8ms	(BIT(2) | BIT(3))
+#define LM3692X_RAMP_RATE_16ms	(BIT(1) | BIT(2) | BIT(3))
+#define LM3692X_RAMP_EN		BIT(4)
+#define LM3692X_BRHT_MODE_REG	0x00
+#define LM3692X_BRHT_MODE_PWM	BIT(5)
+#define LM3692X_BRHT_MODE_MULTI_RAMP BIT(6)
+#define LM3692X_BRHT_MODE_RAMP_MULTI (BIT(5) | BIT(6))
+#define LM3692X_MAP_MODE_EXP	BIT(7)
+
+/* PWM Register Bits */
+#define LM3692X_PWM_FILTER_100	BIT(0)
+#define LM3692X_PWM_FILTER_150	BIT(1)
+#define LM3692X_PWM_FILTER_200	(BIT(0) | BIT(1))
+#define LM3692X_PWM_HYSTER_1LSB BIT(2)
+#define LM3692X_PWM_HYSTER_2LSB	BIT(3)
+#define LM3692X_PWM_HYSTER_3LSB (BIT(3) | BIT(2))
+#define LM3692X_PWM_HYSTER_4LSB BIT(4)
+#define LM3692X_PWM_HYSTER_5LSB (BIT(4) | BIT(2))
+#define LM3692X_PWM_HYSTER_6LSB (BIT(4) | BIT(3))
+#define LM3692X_PWM_POLARITY	BIT(5)
+#define LM3692X_PWM_SAMP_4MHZ	BIT(6)
+#define LM3692X_PWM_SAMP_24MHZ	BIT(7)
+
+/* Boost Control Bits */
+#define LM3692X_OCP_PROT_1A	BIT(0)
+#define LM3692X_OCP_PROT_1_25A	BIT(1)
+#define LM3692X_OCP_PROT_1_5A	(BIT(0) | BIT(1))
+#define LM3692X_OVP_21V		BIT(2)
+#define LM3692X_OVP_25V		BIT(3)
+#define LM3692X_OVP_29V		(BIT(2) | BIT(3))
+#define LM3692X_MIN_IND_22UH	BIT(4)
+#define LM3692X_BOOST_SW_1MHZ	BIT(5)
+#define LM3692X_BOOST_SW_NO_SHIFT	BIT(6)
+
+/* Fault Control Bits */
+#define LM3692X_FAULT_CTRL_OVP BIT(0)
+#define LM3692X_FAULT_CTRL_OCP BIT(1)
+#define LM3692X_FAULT_CTRL_TSD BIT(2)
+#define LM3692X_FAULT_CTRL_OPEN BIT(3)
+
+/* Fault Flag Bits */
+#define LM3692X_FAULT_FLAG_OVP BIT(0)
+#define LM3692X_FAULT_FLAG_OCP BIT(1)
+#define LM3692X_FAULT_FLAG_TSD BIT(2)
+#define LM3692X_FAULT_FLAG_SHRT BIT(3)
+#define LM3692X_FAULT_FLAG_OPEN BIT(4)
+
+/**
+ * struct lm3692x_led -
+ * @lock - Lock for reading/writing the device
+ * @client - Pointer to the I2C client
+ * @led_dev - led class device pointer
+ * @regmap - Devices register map
+ * @enable_gpio - VDDIO/EN gpio to enable communication interface
+ * @regulator - LED supply regulator pointer
+ * @label - LED label
+ */
+struct lm3692x_led {
+	struct mutex lock;
+	struct i2c_client *client;
+	struct led_classdev led_dev;
+	struct regmap *regmap;
+	struct gpio_desc *enable_gpio;
+	struct regulator *regulator;
+	const char *label;
+};
+
+static const struct reg_default lm3692x_reg_defs[] = {
+	{LM3692X_EN, 0xf},
+	{LM3692X_BRT_CTRL, 0x61},
+	{LM3692X_PWM_CTRL, 0x73},
+	{LM3692X_BOOST_CTRL, 0x6f},
+	{LM3692X_AUTO_FREQ_HI, 0x0},
+	{LM3692X_AUTO_FREQ_LO, 0x0},
+	{LM3692X_BL_ADJ_THRESH, 0x0},
+	{LM3692X_BRT_LSB, 0x7},
+	{LM3692X_BRT_MSB, 0xff},
+	{LM3692X_FAULT_CTRL, 0x7},
+};
+
+static const struct regmap_config lm3692x_regmap_config = {
+	.reg_bits = 8,
+	.val_bits = 8,
+
+	.max_register = LM3692X_FAULT_FLAGS,
+	.reg_defaults = lm3692x_reg_defs,
+	.num_reg_defaults = ARRAY_SIZE(lm3692x_reg_defs),
+	.cache_type = REGCACHE_RBTREE,
+};
+
+static int lm3692x_fault_check(struct lm3692x_led *led)
+{
+	int ret, fault;
+	unsigned int read_buf;
+
+	ret = regmap_read(led->regmap, LM3692X_FAULT_FLAGS, &read_buf);
+	if (ret)
+		return ret;
+
+	fault = read_buf;
+
+	if (fault)
+		dev_err(&led->client->dev, "Detected a fault 0x%X\n",
+			fault);
+
+	return ret;
+}
+
+static int lm3692x_brightness_set(struct led_classdev *led_cdev,
+				enum led_brightness brt_val)
+{
+	struct lm3692x_led *led =
+			container_of(led_cdev, struct lm3692x_led, led_dev);
+	int ret;
+	int led_brightness_lsb = (brt_val >> 5);
+
+	mutex_lock(&led->lock);
+
+	ret = lm3692x_fault_check(led);
+	if (ret) {
+		dev_err(&led->client->dev, "Cannot read/clear faults\n");
+		goto out;
+	}
+
+	ret = regmap_write(led->regmap, LM3692X_BRT_MSB, brt_val);
+	if (ret) {
+		dev_err(&led->client->dev, "Cannot write MSB\n");
+		goto out;
+	}
+
+	ret = regmap_write(led->regmap, LM3692X_BRT_LSB, led_brightness_lsb);
+	if (ret) {
+		dev_err(&led->client->dev, "Cannot write LSB\n");
+		goto out;
+	}
+out:
+	mutex_unlock(&led->lock);
+	return ret;
+}
+
+static int lm3692x_init(struct lm3692x_led *led)
+{
+	int ret;
+
+	if (led->regulator) {
+		ret = regulator_enable(led->regulator);
+		if (ret)
+			dev_err(&led->client->dev,
+				"Failed to enable regulator\n");
+			goto out;
+	}
+
+	if (led->enable_gpio)
+		gpiod_direction_output(led->enable_gpio, 1);
+
+	ret = lm3692x_fault_check(led);
+	if (ret) {
+		dev_err(&led->client->dev, "Cannot read/clear faults\n");
+		goto out;
+	}
+
+	ret = regmap_write(led->regmap, LM3692X_BRT_CTRL, 0x00);
+	if (ret) {
+		dev_err(&led->client->dev, "Fail writing BRT CTRL\n");
+		goto out;
+	}
+
+	/*
+	 * For glitch free operation, the following data should
+	 * only be written while device enable bit is 0
+	 * per Section 7.5.14 of the data sheet
+	 */
+	ret = regmap_write(led->regmap, LM3692X_PWM_CTRL,
+		LM3692X_PWM_FILTER_100 | LM3692X_PWM_SAMP_24MHZ);
+	if (ret) {
+		dev_err(&led->client->dev, "Failed programming PWM CTRL\n");
+		goto out;
+	}
+
+	ret = regmap_write(led->regmap, LM3692X_BOOST_CTRL,
+			LM3692X_BRHT_MODE_RAMP_MULTI |
+			LM3692X_BL_ADJ_POL |
+			LM3692X_RAMP_RATE_250us);
+	if (ret) {
+		dev_err(&led->client->dev, "Failed programming BOOST CTRL\n");
+		goto out;
+	}
+
+	ret = regmap_write(led->regmap, LM3692X_AUTO_FREQ_HI, 0x00);
+	if (ret) {
+		dev_err(&led->client->dev, "Failed programming AUTO HI FREQ\n");
+		goto out;
+	}
+
+	ret = regmap_write(led->regmap, LM3692X_AUTO_FREQ_LO, 0x00);
+	if (ret) {
+		dev_err(&led->client->dev, "Failed programming AUTO LO FREQ\n");
+		goto out;
+	}
+
+	ret = regmap_write(led->regmap, LM3692X_BL_ADJ_THRESH, 0x00);
+	if (ret) {
+		dev_err(&led->client->dev, "Failed programming BL Threshold\n");
+		goto out;
+	}
+
+	ret = regmap_write(led->regmap, LM3692X_BRT_CTRL,
+			LM3692X_BL_ADJ_POL | LM3692X_PWM_HYSTER_4LSB);
+	if (ret)
+		dev_err(&led->client->dev, "Failed programming BRT CTRL\n");
+
+	return ret;
+out:
+
+	if (led->enable_gpio)
+		gpiod_direction_output(led->enable_gpio, 0);
+
+	if (led->regulator) {
+		ret = regulator_disable(led->regulator);
+		if (ret)
+			dev_err(&led->client->dev,
+				"Failed to disable regulator\n");
+	}
+
+	return ret;
+}
+
+static int lm3692x_probe(struct i2c_client *client,
+			const struct i2c_device_id *id)

drivers/leds/leds-lm3692x.c line 295

Quoted 10 lines
drivers/leds/leds-lm3692x.c new file +10 -0
+{
+	int ret;
+	struct lm3692x_led *led;
+	struct device_node *np = client->dev.of_node;
+
+	led = devm_kzalloc(&client->dev, sizeof(*led), GFP_KERNEL);
+	if (!led)
+		return -ENOMEM;
+
+	if (client->dev.of_node) {

We should fail in the opposite case.

drivers/leds/leds-lm3692x.c line 298

Quoted 3 lines
drivers/leds/leds-lm3692x.c new file +3 -0
+		ret = of_property_read_string(np, "label", &led->label);
+		if (ret)
+			led->label = LM3692X_LED_NAME;

LED label should be taken from the child node name if label property is not present. See Documentation/devicetree/bindings/leds/common.txt.

We have some mess in this area, but I'm going to sort it out soon (added you on CC to the related discussion).

Generally LED class device name should be composed by the LED class driver by taking label and prefixing it with "[devicename]:" string.

Quoted 7 lines
drivers/leds/leds-lm3692x.c new file +7 -0
+	}
+
+	led->enable_gpio = devm_gpiod_get_optional(&client->dev,
+						   "enable", GPIOD_OUT_LOW);
+	if (IS_ERR(led->enable_gpio)) {
+		ret = PTR_ERR(led->enable_gpio);
+		dev_err(&client->dev, "Failed to get enable gpio: %d\n", ret);

drivers/leds/leds-lm3692x.c line 315

Quoted 10 lines
drivers/leds/leds-lm3692x.c new file +10 -0
+		return ret;
+	}
+
+	led->regulator = devm_regulator_get(&client->dev, "vled");
+	if (IS_ERR(led->regulator))
+		led->regulator = NULL;
+
+	led->client = client;
+	led->led_dev.name = led->label;
+	led->led_dev.max_brightness = LED_FULL;

You can skip this line, it will be initialized to LED_FULL in of_led_classdev_register in this case.

Quoted 9 lines
drivers/leds/leds-lm3692x.c new file +9 -0
+	led->led_dev.brightness_set_blocking = lm3692x_brightness_set;
+
+	mutex_init(&led->lock);
+
+	i2c_set_clientdata(client, led);
+
+	led->regmap = devm_regmap_init_i2c(client, &lm3692x_regmap_config);
+	if (IS_ERR(led->regmap)) {
+		ret = PTR_ERR(led->regmap);

drivers/leds/leds-lm3692x.c line 334

Quoted 10 lines
drivers/leds/leds-lm3692x.c new file +10 -0
+		dev_err(&client->dev, "Failed to allocate register map: %d\n",
+			ret);
+		return ret;
+	}
+
+	ret = lm3692x_init(led);
+	if (ret)
+		return ret;
+
+	ret = led_classdev_register(&client->dev, &led->led_dev);

Please use devm_* prefixed version.

Quoted 14 lines
drivers/leds/leds-lm3692x.c new file +14 -0
+	if (ret) {
+		dev_err(&client->dev, "led register err: %d\n", ret);
+		return ret;
+	}
+
+	return 0;
+}
+
+static int lm3692x_remove(struct i2c_client *client)
+{
+	struct lm3692x_led *led = i2c_get_clientdata(client);
+	int ret;
+
+	led_classdev_unregister(&led->led_dev);

drivers/leds/leds-lm3692x.c line 358

Quoted 10 lines
drivers/leds/leds-lm3692x.c new file +10 -0
+
+	if (led->enable_gpio)
+		gpiod_direction_output(led->enable_gpio, 0);
+
+	if (led->regulator) {
+		ret = regulator_disable(led->regulator);
+		if (ret)
+			dev_err(&led->client->dev,
+				"Failed to disable regulator\n");
+	}

mutex_destroy(&led->lock)

Quoted 22 lines
drivers/leds/leds-lm3692x.c new file +22 -0
+
+	return 0;
+}
+
+static const struct i2c_device_id lm3692x_id[] = {
+	{ "lm3692x", 0 },
+	{ }
+};
+MODULE_DEVICE_TABLE(i2c, lm3692x_id);
+
+#ifdef CONFIG_OF
+static const struct of_device_id of_lm3692x_leds_match[] = {
+	{ .compatible = "ti,lm3692x", },
+	{},
+};
+MODULE_DEVICE_TABLE(of, of_lm3692x_leds_match);
+#endif
+
+static struct i2c_driver lm3692x_driver = {
+	.driver = {
+		.name	= "lm3692x",
+		.of_match_table = of_match_ptr(of_lm3692x_leds_match),

drivers/leds/leds-lm3692x.c line 390

Quoted 10 lines
drivers/leds/leds-lm3692x.c new file +10 -0
+	},
+	.probe		= lm3692x_probe,
+	.remove		= lm3692x_remove,
+	.id_table	= lm3692x_id,
+};
+module_i2c_driver(lm3692x_driver);
+
+MODULE_DESCRIPTION("Texas Instruments LM3692X LED driver");
+MODULE_AUTHOR("Dan Murphy <[email protected]>");
+MODULE_LICENSE("GPL");

According to your license info it should be "GPL v2"

Signature · 7 lines
Best regards,
Jacek Anaszewski

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
author
#5 lore raw

Re: [PATCH v3 2/2] leds: lm3692x: Introduce LM3692x dual string driver

Jacek

Thanks

Quoted 350 lines · Jacek Anaszewski

Hi Dan,

Please find my comments below.

Quoted 345 lines · Dan Murphy

Introducing the LM3692x Dual-String white LED driver.

Data sheet is located
http://www.ti.com/lit/ds/snvsa29/snvsa29.pdf

---

v3 - Add missing Makefile and Kconfig from v1 and v2 - https://patchwork.kernel.org/patch/10060075/

v2 - Added data sheet link, fixed linuxdoc format, returned on failure in init routine, return on fault_check failure, updated brightness calculation and fixed capitalization issue - https://patchwork.kernel.org/patch/10056675/

 drivers/leds/Kconfig        |   7 +
 drivers/leds/Makefile       |   1 +
 drivers/leds/leds-lm3692x.c | 390 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 398 insertions(+)
 create mode 100644 drivers/leds/leds-lm3692x.c
drivers/leds/Kconfig +7 -0
index 318a28fd58fe..1363e77a7d5f 100644
@@ -137,6 +137,13 @@ config LEDS_LM3642
 	  converter plus 1.5A constant current driver for a high-current
 	  white LED.
 
+config LEDS_LM3692X
+	tristate "LED support for LM3692x Chips"
+	depends on LEDS_CLASS && I2C
+	select REGMAP_I2C
+	help
+	  This option enables support for the TI LM3692x family
+	  of LED drivers.
 
 config LEDS_LOCOMO
 	tristate "LED Support for Locomo device"
drivers/leds/Makefile +1 -0
index a2a6b5a4f86d..987884a5b9a5 100644
@@ -74,6 +74,7 @@ obj-$(CONFIG_LEDS_PM8058)		+= leds-pm8058.o
 obj-$(CONFIG_LEDS_MLXCPLD)		+= leds-mlxcpld.o
 obj-$(CONFIG_LEDS_NIC78BX)		+= leds-nic78bx.o
 obj-$(CONFIG_LEDS_MT6323)		+= leds-mt6323.o
+obj-$(CONFIG_LEDS_LM3692X)		+= leds-lm3692x.o
 
 # LED SPI Drivers
 obj-$(CONFIG_LEDS_DAC124S085)		+= leds-dac124s085.o
drivers/leds/leds-lm3692x.c new file +289 -0
new file mode 100644
index 000000000000..9fa7f5a20466
@@ -0,0 +1,390 @@
+/*
+ * TI lm3692x LED Driver
+ *
+ * Copyright (C) 2017 Texas Instruments
+ *
+ * Author: Dan Murphy <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * Data sheet is located
+ * http://www.ti.com/lit/ds/snvsa29/snvsa29.pdf
+ */
+
+#include <linux/i2c.h>
+#include <linux/init.h>
+#include <linux/leds.h>
+#include <linux/regmap.h>
+#include <linux/regulator/consumer.h>
+#include <linux/module.h>
+#include <linux/mutex.h>
+#include <linux/of.h>
+#include <linux/of_gpio.h>
+#include <linux/gpio/consumer.h>
+#include <linux/slab.h>
+
+#define LM3692X_LED_NAME	"lm3692x_led"
+
+#define LM3692X_REV		0x0
+#define LM3692X_RESET		0x1
+#define LM3692X_EN		0x10
+#define LM3692X_BRT_CTRL	0x11
+#define LM3692X_PWM_CTRL	0x12
+#define LM3692X_BOOST_CTRL	0x13
+#define LM3692X_AUTO_FREQ_HI	0x15
+#define LM3692X_AUTO_FREQ_LO	0x16
+#define LM3692X_BL_ADJ_THRESH	0x17
+#define LM3692X_BRT_LSB		0x18
+#define LM3692X_BRT_MSB		0x19
+#define LM3692X_FAULT_CTRL	0x1e
+#define LM3692X_FAULT_FLAGS	0x1f
+
+#define LM3692X_SW_RESET	BIT(0)
+#define LM3692X_DEVICE_EN	BIT(0)
+#define LM3692X_LED1_EN		BIT(1)
+#define LM3692X_LED2_EN		BIT(2)
+
+/* Brightness Control Bits */
+#define LM3692X_BL_ADJ_POL	BIT(0)
+#define LM3692X_RAMP_RATE_125us	0x00
+#define LM3692X_RAMP_RATE_250us	BIT(1)
+#define LM3692X_RAMP_RATE_500us BIT(2)
+#define LM3692X_RAMP_RATE_1ms	(BIT(1) | BIT(2))
+#define LM3692X_RAMP_RATE_2ms	BIT(3)
+#define LM3692X_RAMP_RATE_4ms	(BIT(3) | BIT(1))
+#define LM3692X_RAMP_RATE_8ms	(BIT(2) | BIT(3))
+#define LM3692X_RAMP_RATE_16ms	(BIT(1) | BIT(2) | BIT(3))
+#define LM3692X_RAMP_EN		BIT(4)
+#define LM3692X_BRHT_MODE_REG	0x00
+#define LM3692X_BRHT_MODE_PWM	BIT(5)
+#define LM3692X_BRHT_MODE_MULTI_RAMP BIT(6)
+#define LM3692X_BRHT_MODE_RAMP_MULTI (BIT(5) | BIT(6))
+#define LM3692X_MAP_MODE_EXP	BIT(7)
+
+/* PWM Register Bits */
+#define LM3692X_PWM_FILTER_100	BIT(0)
+#define LM3692X_PWM_FILTER_150	BIT(1)
+#define LM3692X_PWM_FILTER_200	(BIT(0) | BIT(1))
+#define LM3692X_PWM_HYSTER_1LSB BIT(2)
+#define LM3692X_PWM_HYSTER_2LSB	BIT(3)
+#define LM3692X_PWM_HYSTER_3LSB (BIT(3) | BIT(2))
+#define LM3692X_PWM_HYSTER_4LSB BIT(4)
+#define LM3692X_PWM_HYSTER_5LSB (BIT(4) | BIT(2))
+#define LM3692X_PWM_HYSTER_6LSB (BIT(4) | BIT(3))
+#define LM3692X_PWM_POLARITY	BIT(5)
+#define LM3692X_PWM_SAMP_4MHZ	BIT(6)
+#define LM3692X_PWM_SAMP_24MHZ	BIT(7)
+
+/* Boost Control Bits */
+#define LM3692X_OCP_PROT_1A	BIT(0)
+#define LM3692X_OCP_PROT_1_25A	BIT(1)
+#define LM3692X_OCP_PROT_1_5A	(BIT(0) | BIT(1))
+#define LM3692X_OVP_21V		BIT(2)
+#define LM3692X_OVP_25V		BIT(3)
+#define LM3692X_OVP_29V		(BIT(2) | BIT(3))
+#define LM3692X_MIN_IND_22UH	BIT(4)
+#define LM3692X_BOOST_SW_1MHZ	BIT(5)
+#define LM3692X_BOOST_SW_NO_SHIFT	BIT(6)
+
+/* Fault Control Bits */
+#define LM3692X_FAULT_CTRL_OVP BIT(0)
+#define LM3692X_FAULT_CTRL_OCP BIT(1)
+#define LM3692X_FAULT_CTRL_TSD BIT(2)
+#define LM3692X_FAULT_CTRL_OPEN BIT(3)
+
+/* Fault Flag Bits */
+#define LM3692X_FAULT_FLAG_OVP BIT(0)
+#define LM3692X_FAULT_FLAG_OCP BIT(1)
+#define LM3692X_FAULT_FLAG_TSD BIT(2)
+#define LM3692X_FAULT_FLAG_SHRT BIT(3)
+#define LM3692X_FAULT_FLAG_OPEN BIT(4)
+
+/**
+ * struct lm3692x_led -
+ * @lock - Lock for reading/writing the device
+ * @client - Pointer to the I2C client
+ * @led_dev - led class device pointer
+ * @regmap - Devices register map
+ * @enable_gpio - VDDIO/EN gpio to enable communication interface
+ * @regulator - LED supply regulator pointer
+ * @label - LED label
+ */
+struct lm3692x_led {
+	struct mutex lock;
+	struct i2c_client *client;
+	struct led_classdev led_dev;
+	struct regmap *regmap;
+	struct gpio_desc *enable_gpio;
+	struct regulator *regulator;
+	const char *label;
+};
+
+static const struct reg_default lm3692x_reg_defs[] = {
+	{LM3692X_EN, 0xf},
+	{LM3692X_BRT_CTRL, 0x61},
+	{LM3692X_PWM_CTRL, 0x73},
+	{LM3692X_BOOST_CTRL, 0x6f},
+	{LM3692X_AUTO_FREQ_HI, 0x0},
+	{LM3692X_AUTO_FREQ_LO, 0x0},
+	{LM3692X_BL_ADJ_THRESH, 0x0},
+	{LM3692X_BRT_LSB, 0x7},
+	{LM3692X_BRT_MSB, 0xff},
+	{LM3692X_FAULT_CTRL, 0x7},
+};
+
+static const struct regmap_config lm3692x_regmap_config = {
+	.reg_bits = 8,
+	.val_bits = 8,
+
+	.max_register = LM3692X_FAULT_FLAGS,
+	.reg_defaults = lm3692x_reg_defs,
+	.num_reg_defaults = ARRAY_SIZE(lm3692x_reg_defs),
+	.cache_type = REGCACHE_RBTREE,
+};
+
+static int lm3692x_fault_check(struct lm3692x_led *led)
+{
+	int ret, fault;
+	unsigned int read_buf;
+
+	ret = regmap_read(led->regmap, LM3692X_FAULT_FLAGS, &read_buf);
+	if (ret)
+		return ret;
+
+	fault = read_buf;
+
+	if (fault)
+		dev_err(&led->client->dev, "Detected a fault 0x%X\n",
+			fault);
+
+	return ret;
+}
+
+static int lm3692x_brightness_set(struct led_classdev *led_cdev,
+				enum led_brightness brt_val)
+{
+	struct lm3692x_led *led =
+			container_of(led_cdev, struct lm3692x_led, led_dev);
+	int ret;
+	int led_brightness_lsb = (brt_val >> 5);
+
+	mutex_lock(&led->lock);
+
+	ret = lm3692x_fault_check(led);
+	if (ret) {
+		dev_err(&led->client->dev, "Cannot read/clear faults\n");
+		goto out;
+	}
+
+	ret = regmap_write(led->regmap, LM3692X_BRT_MSB, brt_val);
+	if (ret) {
+		dev_err(&led->client->dev, "Cannot write MSB\n");
+		goto out;
+	}
+
+	ret = regmap_write(led->regmap, LM3692X_BRT_LSB, led_brightness_lsb);
+	if (ret) {
+		dev_err(&led->client->dev, "Cannot write LSB\n");
+		goto out;
+	}
+out:
+	mutex_unlock(&led->lock);
+	return ret;
+}
+
+static int lm3692x_init(struct lm3692x_led *led)
+{
+	int ret;
+
+	if (led->regulator) {
+		ret = regulator_enable(led->regulator);
+		if (ret)
+			dev_err(&led->client->dev,
+				"Failed to enable regulator\n");
+			goto out;
+	}
+
+	if (led->enable_gpio)
+		gpiod_direction_output(led->enable_gpio, 1);
+
+	ret = lm3692x_fault_check(led);
+	if (ret) {
+		dev_err(&led->client->dev, "Cannot read/clear faults\n");
+		goto out;
+	}
+
+	ret = regmap_write(led->regmap, LM3692X_BRT_CTRL, 0x00);
+	if (ret) {
+		dev_err(&led->client->dev, "Fail writing BRT CTRL\n");
+		goto out;
+	}
+
+	/*
+	 * For glitch free operation, the following data should
+	 * only be written while device enable bit is 0
+	 * per Section 7.5.14 of the data sheet
+	 */
+	ret = regmap_write(led->regmap, LM3692X_PWM_CTRL,
+		LM3692X_PWM_FILTER_100 | LM3692X_PWM_SAMP_24MHZ);
+	if (ret) {
+		dev_err(&led->client->dev, "Failed programming PWM CTRL\n");
+		goto out;
+	}
+
+	ret = regmap_write(led->regmap, LM3692X_BOOST_CTRL,
+			LM3692X_BRHT_MODE_RAMP_MULTI |
+			LM3692X_BL_ADJ_POL |
+			LM3692X_RAMP_RATE_250us);
+	if (ret) {
+		dev_err(&led->client->dev, "Failed programming BOOST CTRL\n");
+		goto out;
+	}
+
+	ret = regmap_write(led->regmap, LM3692X_AUTO_FREQ_HI, 0x00);
+	if (ret) {
+		dev_err(&led->client->dev, "Failed programming AUTO HI FREQ\n");
+		goto out;
+	}
+
+	ret = regmap_write(led->regmap, LM3692X_AUTO_FREQ_LO, 0x00);
+	if (ret) {
+		dev_err(&led->client->dev, "Failed programming AUTO LO FREQ\n");
+		goto out;
+	}
+
+	ret = regmap_write(led->regmap, LM3692X_BL_ADJ_THRESH, 0x00);
+	if (ret) {
+		dev_err(&led->client->dev, "Failed programming BL Threshold\n");
+		goto out;
+	}
+
+	ret = regmap_write(led->regmap, LM3692X_BRT_CTRL,
+			LM3692X_BL_ADJ_POL | LM3692X_PWM_HYSTER_4LSB);
+	if (ret)
+		dev_err(&led->client->dev, "Failed programming BRT CTRL\n");
+
+	return ret;
+out:
+
+	if (led->enable_gpio)
+		gpiod_direction_output(led->enable_gpio, 0);
+
+	if (led->regulator) {
+		ret = regulator_disable(led->regulator);
+		if (ret)
+			dev_err(&led->client->dev,
+				"Failed to disable regulator\n");
+	}
+
+	return ret;
+}
+
+static int lm3692x_probe(struct i2c_client *client,
+			const struct i2c_device_id *id)
+{
+	int ret;
+	struct lm3692x_led *led;
+	struct device_node *np = client->dev.of_node;
Quoted 8 lines

drivers/leds/leds-lm3692x.c line 295

Quoted 6 lines
drivers/leds/leds-lm3692x.c new file +6 -0
+
+	led = devm_kzalloc(&client->dev, sizeof(*led), GFP_KERNEL);
+	if (!led)
+		return -ENOMEM;
+
+	if (client->dev.of_node) {

We should fail in the opposite case.

OK

Quoted 8 lines

drivers/leds/leds-lm3692x.c line 298

Quoted 4 lines
drivers/leds/leds-lm3692x.c new file +3 -0
+		ret = of_property_read_string(np, "label", &led->label);
+		if (ret)
+			led->label = LM3692X_LED_NAME;

LED label should be taken from the child node name if label property is not present. See Documentation/devicetree/bindings/leds/common.txt.

Quoted 5 lines

We have some mess in this area, but I'm going to sort it out soon (added you on CC to the related discussion).

Generally LED class device name should be composed by the LED class driver by taking label and prefixing it with "[devicename]:" string.

OK

Quoted 13 lines
Quoted 13 lines
drivers/leds/leds-lm3692x.c new file +12 -0
+	}
+
+	led->enable_gpio = devm_gpiod_get_optional(&client->dev,
+						   "enable", GPIOD_OUT_LOW);
+	if (IS_ERR(led->enable_gpio)) {
+		ret = PTR_ERR(led->enable_gpio);
+		dev_err(&client->dev, "Failed to get enable gpio: %d\n", ret);
+		return ret;
+	}
+
+	led->regulator = devm_regulator_get(&client->dev, "vled");
+	if (IS_ERR(led->regulator))
Quoted 8 lines

drivers/leds/leds-lm3692x.c line 315

Quoted 5 lines
drivers/leds/leds-lm3692x.c new file +5 -0
+		led->regulator = NULL;
+
+	led->client = client;
+	led->led_dev.name = led->label;
+	led->led_dev.max_brightness = LED_FULL;

You can skip this line, it will be initialized to LED_FULL in of_led_classdev_register in this case.

OK

Quoted 15 lines
Quoted 15 lines
drivers/leds/leds-lm3692x.c new file +13 -0
+	led->led_dev.brightness_set_blocking = lm3692x_brightness_set;
+
+	mutex_init(&led->lock);
+
+	i2c_set_clientdata(client, led);
+
+	led->regmap = devm_regmap_init_i2c(client, &lm3692x_regmap_config);
+	if (IS_ERR(led->regmap)) {
+		ret = PTR_ERR(led->regmap);
+		dev_err(&client->dev, "Failed to allocate register map: %d\n",
+			ret);
+		return ret;
+	}
Quoted 8 lines

drivers/leds/leds-lm3692x.c line 334

Quoted 6 lines
drivers/leds/leds-lm3692x.c new file +6 -0
+
+	ret = lm3692x_init(led);
+	if (ret)
+		return ret;
+
+	ret = led_classdev_register(&client->dev, &led->led_dev);

Please use devm_* prefixed version.

OK

Quoted 19 lines
Quoted 19 lines
drivers/leds/leds-lm3692x.c new file +18 -0
+	if (ret) {
+		dev_err(&client->dev, "led register err: %d\n", ret);
+		return ret;
+	}
+
+	return 0;
+}
+
+static int lm3692x_remove(struct i2c_client *client)
+{
+	struct lm3692x_led *led = i2c_get_clientdata(client);
+	int ret;
+
+	led_classdev_unregister(&led->led_dev);
+
+	if (led->enable_gpio)
+		gpiod_direction_output(led->enable_gpio, 0);
+
Quoted 8 lines

drivers/leds/leds-lm3692x.c line 279

Quoted 6 lines
drivers/leds/leds-lm3692x.c new file +6 -0
+	if (led->regulator) {
+		ret = regulator_disable(led->regulator);
+		if (ret)
+			dev_err(&led->client->dev,
+				"Failed to disable regulator\n");
+	}

mutex_destroy(&led->lock)

OK

Quoted 27 lines
Quoted 27 lines
drivers/leds/leds-lm3692x.c new file +26 -0
+
+	return 0;
+}
+
+static const struct i2c_device_id lm3692x_id[] = {
+	{ "lm3692x", 0 },
+	{ }
+};
+MODULE_DEVICE_TABLE(i2c, lm3692x_id);
+
+#ifdef CONFIG_OF
+static const struct of_device_id of_lm3692x_leds_match[] = {
+	{ .compatible = "ti,lm3692x", },
+	{},
+};
+MODULE_DEVICE_TABLE(of, of_lm3692x_leds_match);
+#endif
+
+static struct i2c_driver lm3692x_driver = {
+	.driver = {
+		.name	= "lm3692x",
+		.of_match_table = of_match_ptr(of_lm3692x_leds_match),
+	},
+	.probe		= lm3692x_probe,
+	.remove		= lm3692x_remove,
+	.id_table	= lm3692x_id,
Quoted 9 lines

drivers/leds/leds-lm3692x.c line 390

Quoted 6 lines
drivers/leds/leds-lm3692x.c new file +6 -0
+};
+module_i2c_driver(lm3692x_driver);
+
+MODULE_DESCRIPTION("Texas Instruments LM3692X LED driver");
+MODULE_AUTHOR("Dan Murphy <[email protected]>");
+MODULE_LICENSE("GPL");

According to your license info it should be "GPL v2"

OK

Dan

Signature · 2 lines
------------------
Dan Murphy
#6 lore raw
In reply to Dan Murphy

Hi Dan,

Thanks for the patch.

Quoted 20 lines · Dan Murphy

This adds the devicetree bindings for the LM3692x
I2C LED string driver.

---

v3 - No changes
v2 - No changes - https://patchwork.kernel.org/patch/10056677/

 .../devicetree/bindings/leds/leds-lm3692x.txt      | 28 ++++++++++++++++++++++
 1 file changed, 28 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/leds/leds-lm3692x.txt
Documentation/devicetree/bindings/leds/leds-lm3692x.txt new file +0 -0
new file mode 100644
index 000000000000..cfef67bd4100

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

Quoted 5 lines
Documentation/devicetree/bindings/leds/leds-lm3692x.txt new file +5 -0
@@ -0,0 +1,28 @@
+* Texas Instruments - LM3692x Highly Efficient Dual-String White LED Driver
+
+The LM36922 is an ultra-compact, highly efficient,
+two string white-LED driver designed for LCD display
+backlighting.

Shouldn't the driver be targeted for backlight subsystem then?

Adding backlight maintainers.

Best regards,
Jacek Anaszewski

Quoted 13 lines
Documentation/devicetree/bindings/leds/leds-lm3692x.txt new file +12 -0
+Required properties:
+	- compatible:
+		"ti,lm3692x"
+	- reg -  I2C slave address
+
+Optional properties:
+	- label - Used for naming LEDs
+	- enable-gpio - gpio pin to enable/disable the device.
+	- supply - "vled" - LED supply
+
+Example:
+

Documentation/devicetree/bindings/leds/leds-lm3692x.txt line 28

Quoted 10 lines
Documentation/devicetree/bindings/leds/leds-lm3692x.txt new file +10 -0
+leds: leds@6 {
+	compatible = "ti,lm3692x";
+	reg = <0x36>;
+	label = "backlight_cluster";
+	enable-gpio = <&gpio1 28 GPIO_ACTIVE_HIGH>;
+	vled-supply = <&vbatt>;
+}
+
+For more product information please see the link below:
+http://www.ti.com/lit/ds/snvsa29/snvsa29.pdf

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

author
#7 lore raw

Jacek

Quoted 33 lines · Jacek Anaszewski

Hi Dan,

Thanks for the patch.

Quoted 20 lines · Dan Murphy

This adds the devicetree bindings for the LM3692x
I2C LED string driver.

---

v3 - No changes
v2 - No changes - https://patchwork.kernel.org/patch/10056677/

 .../devicetree/bindings/leds/leds-lm3692x.txt      | 28 ++++++++++++++++++++++
 1 file changed, 28 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/leds/leds-lm3692x.txt
Documentation/devicetree/bindings/leds/leds-lm3692x.txt new file +0 -0
new file mode 100644
index 000000000000..cfef67bd4100

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

Quoted 5 lines
Documentation/devicetree/bindings/leds/leds-lm3692x.txt new file +5 -0
@@ -0,0 +1,28 @@
+* Texas Instruments - LM3692x Highly Efficient Dual-String White LED Driver
+
+The LM36922 is an ultra-compact, highly efficient,
+two string white-LED driver designed for LCD display
+backlighting.

Shouldn't the driver be targeted for backlight subsystem then?

Quoted 2 lines

Adding backlight maintainers.

Great point! I was not aware of the backlight subsystem.

Looks like I need to create a back light version as well.

Like the lp8788 did since this can be used as a LED driver beyond display back lighting.

Unless the maintainers don't want it.

Dan

Signature · 6 lines
------------------
Dan Murphy
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#8 lore raw

Hi!

Quoted 11 lines
Quoted 4 lines

Shouldn't the driver be targeted for backlight subsystem then?

Adding backlight maintainers.

Great point! I was not aware of the backlight subsystem.

Looks like I need to create a back light version as well.

Like the lp8788 did since this can be used as a LED driver beyond display back lighting.

No, definitely not two drivers for lp8788 hardware.

If that does not yet exist... you want to create glue layer to be able to use LED as a display backlight. (It may already exist, no idea).

...

Actually or maybe a LED trigger. Just set LED's trigger to "this is display backlight".

Other solutions are acceptable, but not two hardware drivers.

Thanks,
Pavel

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

Hi Dan and Pavel,

Quoted 7 lines · Pavel Machek

Hi!

Quoted 5 lines
Quoted 4 lines

Shouldn't the driver be targeted for backlight subsystem then?

Adding backlight maintainers.

Quoted 8 lines
Quoted 6 lines

Great point! I was not aware of the backlight subsystem.

Looks like I need to create a back light version as well.

Like the lp8788 did since this can be used as a LED driver beyond display back lighting.

No, definitely not two drivers for lp8788 hardware.

I agree.

Quoted 7 lines

If that does not yet exist... you want to create glue layer to be able to use LED as a display backlight. (It may already exist, no idea).

...

Actually or maybe a LED trigger. Just set LED's trigger to "this is display backlight".

There is one already:

drivers/leds/trigger/ledtrig-backlight.c

It adds a LED class device to the fb_notifier_list (drivers/video/fbdev/core/fb_notify.c)

using fb_register_client(). The same is used in backlight_device_register (drivers/video/backlight/backlight.c).

Actually why do you want to have this driver in the LED subsystem, if it is advertised as "designed for LCD display backlighting"?

As a side note I can say that I've been always wondering why the two subsystems for similar type of hardware.

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

Jacek

Quoted 33 lines · Jacek Anaszewski

Hi Dan and Pavel,

Quoted 7 lines · Pavel Machek

Hi!

Quoted 5 lines
Quoted 4 lines

Shouldn't the driver be targeted for backlight subsystem then?

Adding backlight maintainers.

Quoted 8 lines
Quoted 6 lines

Great point! I was not aware of the backlight subsystem.

Looks like I need to create a back light version as well.

Like the lp8788 did since this can be used as a LED driver beyond display back lighting.

No, definitely not two drivers for lp8788 hardware.

I agree.

Quoted 7 lines

If that does not yet exist... you want to create glue layer to be able to use LED as a display backlight. (It may already exist, no idea).

...

Actually or maybe a LED trigger. Just set LED's trigger to "this is display backlight".

There is one already:

drivers/leds/trigger/ledtrig-backlight.c

Quoted 8 lines

It adds a LED class device to the fb_notifier_list (drivers/video/fbdev/core/fb_notify.c)

using fb_register_client(). The same is used in backlight_device_register (drivers/video/backlight/backlight.c).

Actually why do you want to have this driver in the LED subsystem, if it is advertised as "designed for LCD display backlighting"?

Well this is also advertised as a driver for Smart phone and tablet devices. And having worked with the Android lighting solutions this is the preferred subsystem for Android. The Android OS manages the led brightness based on ALS values and in turn calls into the driver to control the brightness register through the vendor provided lighting HAL.

I am going to look at the backlight source to figure out how to get the same functionality using the backlight subsystem. Otherwise I will plug in this driver to the backlight subsystem through the notifier.

Quoted 3 lines

As a side note I can say that I've been always wondering why the two subsystems for similar type of hardware.

This is my worry too. Why do we need both subsystems to do the same thing?

I don't see either having one advantage over the other.

Dan

Quoted 1 line
Signature · 6 lines
------------------
Dan Murphy
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#11 lore raw
Quoted 53 lines · Dan Murphy

Jacek

Quoted 33 lines · Jacek Anaszewski

Hi Dan and Pavel,

Quoted 7 lines · Pavel Machek

Hi!

Quoted 5 lines
Quoted 4 lines

Shouldn't the driver be targeted for backlight subsystem then?

Adding backlight maintainers.

Quoted 8 lines
Quoted 6 lines

Great point! I was not aware of the backlight subsystem.

Looks like I need to create a back light version as well.

Like the lp8788 did since this can be used as a LED driver beyond display back lighting.

No, definitely not two drivers for lp8788 hardware.

I agree.

Quoted 7 lines

If that does not yet exist... you want to create glue layer to be able to use LED as a display backlight. (It may already exist, no idea).

...

Actually or maybe a LED trigger. Just set LED's trigger to "this is display backlight".

There is one already:

drivers/leds/trigger/ledtrig-backlight.c

Quoted 8 lines

It adds a LED class device to the fb_notifier_list (drivers/video/fbdev/core/fb_notify.c)

using fb_register_client(). The same is used in backlight_device_register (drivers/video/backlight/backlight.c).

Actually why do you want to have this driver in the LED subsystem, if it is advertised as "designed for LCD display backlighting"?

Well this is also advertised as a driver for Smart phone and tablet devices. And having worked with the Android lighting solutions this is the preferred subsystem for Android. The Android OS manages the led brightness based on ALS values and in
turn calls into the driver to control the brightness register through the vendor provided lighting HAL.

Quoted 4 lines

I am going to look at the backlight source to figure out how to get the same functionality using the backlight subsystem.
Otherwise I will plug in this driver to the backlight subsystem through the notifier.

I also developed Android devices for a long time.
I think that modifying HAL will not be difficult.

Also, backlight subsystem will be similar with LED subsystem. You can grasp it easily.

Best regards,
Jingoo Han

Quoted 6 lines
Quoted 4 lines

As a side note I can say that I've been always wondering why the two subsystems for similar type of hardware.

This is my worry too. Why do we need both subsystems to do the same

thing?

Quoted 11 lines

I don't see either having one advantage over the other.

Dan

Quoted 1 line

--
------------------
Dan Murphy

#12 lore raw
In reply to Dan Murphy

Hi!

Quoted 18 lines
Quoted 18 lines
Quoted 7 lines

If that does not yet exist... you want to create glue layer to be able to use LED as a display backlight. (It may already exist, no idea).

...

Actually or maybe a LED trigger. Just set LED's trigger to "this is display backlight".

There is one already:

drivers/leds/trigger/ledtrig-backlight.c

It adds a LED class device to the fb_notifier_list (drivers/video/fbdev/core/fb_notify.c)

using fb_register_client(). The same is used in backlight_device_register (drivers/video/backlight/backlight.c).

Quoted 7 lines
Quoted 2 lines

Actually why do you want to have this driver in the LED subsystem, if it is advertised as "designed for LCD display backlighting"?

Well this is also advertised as a driver for Smart phone and tablet devices. And having worked with the Android lighting solutions this is the preferred subsystem for Android. The Android OS manages the led brightness based on ALS values and in turn calls into the driver to control the brightness register through the vendor provided lighting HAL.

Well.. if it can control other LEDs than just backlight, I believe it can stay in the LED subsystem.

Quoted 3 lines

I am going to look at the backlight source to figure out how to get the same functionality using the backlight subsystem. Otherwise I will plug in this driver to the backlight subsystem through the notifier.

The backlight trigger should be ok.

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
#13 lore raw
Quoted 27 lines · Pavel Machek

Hi!

Quoted 1 line
Quoted 1 line
Quoted 1 line

If that does not yet exist... you want to create glue layer to be

able

Quoted 14 lines
Quoted 14 lines
Quoted 6 lines

to use LED as a display backlight. (It may already exist, no idea).

...

Actually or maybe a LED trigger. Just set LED's trigger to "this is display backlight".

There is one already:

drivers/leds/trigger/ledtrig-backlight.c

It adds a LED class device to the fb_notifier_list (drivers/video/fbdev/core/fb_notify.c)

Quoted 7 lines
Quoted 5 lines

using fb_register_client(). The same is used in backlight_device_register (drivers/video/backlight/backlight.c).

Actually why do you want to have this driver in the LED subsystem, if it is advertised as "designed for LCD display backlighting"?

Well this is also advertised as a driver for Smart phone and tablet

devices. And having worked with the Android lighting

Quoted 8 lines
Quoted 1 line

solutions this is the preferred subsystem for Android. The Android OS

manages the led brightness based on ALS values and in

Quoted 1 line

turn calls into the driver to control the brightness register through

the vendor provided lighting HAL.

Quoted 1 line

Well.. if it can control other LEDs than just backlight, I believe it can stay in the LED subsystem.

I also agree with your opinion.

Best regards,
Jingoo Han

Quoted 11 lines
Quoted 2 lines

I am going to look at the backlight source to figure out how to get the

same functionality using the backlight subsystem.

Quoted 1 line

Otherwise I will plug in this driver to the backlight subsystem through

the notifier.

Quoted 1 line

The backlight trigger should be ok.

Best regards,

Pavel

Quoted 4 lines

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

author
#14 lore raw

Pavel and Jacek

Quoted 30 lines · Jingoo Han
Quoted 29 lines · Pavel Machek

Hi!

Quoted 1 line
Quoted 1 line
Quoted 1 line

If that does not yet exist... you want to create glue layer to be

able

Quoted 14 lines
Quoted 14 lines
Quoted 6 lines

to use LED as a display backlight. (It may already exist, no idea).

...

Actually or maybe a LED trigger. Just set LED's trigger to "this is display backlight".

There is one already:

drivers/leds/trigger/ledtrig-backlight.c

It adds a LED class device to the fb_notifier_list (drivers/video/fbdev/core/fb_notify.c)

Quoted 7 lines
Quoted 5 lines

using fb_register_client(). The same is used in backlight_device_register (drivers/video/backlight/backlight.c).

Actually why do you want to have this driver in the LED subsystem, if it is advertised as "designed for LCD display backlighting"?

Well this is also advertised as a driver for Smart phone and tablet

devices. And having worked with the Android lighting

Quoted 1 line

solutions this is the preferred subsystem for Android. The Android OS

manages the led brightness based on ALS values and in

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

turn calls into the driver to control the brightness register through

the vendor provided lighting HAL.

Quoted 1 line

Well.. if it can control other LEDs than just backlight, I believe it can stay in the LED subsystem.

I also agree with your opinion.

I will make the necessary changes for v4.

Just a heads up I won't be posting v4 until after the US holiday so you don't think I abandoned everything.

Dan

Quoted 21 lines

Best regards,
Jingoo Han

Quoted 11 lines
Quoted 2 lines

I am going to look at the backlight source to figure out how to get the

same functionality using the backlight subsystem.

Quoted 1 line

Otherwise I will plug in this driver to the backlight subsystem through

the notifier.

Quoted 1 line

The backlight trigger should be ok.

Best regards,

Pavel

Quoted 4 lines

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

Signature · 6 lines
------------------
Dan Murphy
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#15 lore raw

Hi!

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

Well.. if it can control other LEDs than just backlight, I believe it can stay in the LED subsystem.

I also agree with your opinion.

I will make the necessary changes for v4.

I'm not sure if you need to make any changes. Just add default trigger to the dts and you should be done.

Quoted 2 lines

Just a heads up I won't be posting v4 until after the US holiday so you don't think I abandoned everything.

:-)
Pavel

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

Pavel

Quoted 5 lines · Pavel Machek

Hi!

Quoted 3 lines
Quoted 3 lines
Quoted 2 lines

Well.. if it can control other LEDs than just backlight, I believe it can stay in the LED subsystem.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

I also agree with your opinion.

I will make the necessary changes for v4.

I'm not sure if you need to make any changes. Just add default trigger to the dts and you should be done.

Sorry what I meant was changes for the additional v3 comments.

Dan

Quoted 6 lines
Quoted 2 lines

Just a heads up I won't be posting v4 until after the US holiday so you don't think I abandoned everything.

:-)
Pavel

Signature · 2 lines
------------------
Dan Murphy
maintainer
#17 lore raw
In reply to Dan Murphy
Quoted 20 lines · Dan Murphy

This adds the devicetree bindings for the LM3692x
I2C LED string driver.

---

v3 - No changes
v2 - No changes - https://patchwork.kernel.org/patch/10056677/

 .../devicetree/bindings/leds/leds-lm3692x.txt      | 28 ++++++++++++++++++++++
 1 file changed, 28 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/leds/leds-lm3692x.txt
Documentation/devicetree/bindings/leds/leds-lm3692x.txt new file +0 -0
new file mode 100644
index 000000000000..cfef67bd4100

Documentation/devicetree/bindings/leds/leds-lm3692x.txt line 9

Quoted 9 lines
Documentation/devicetree/bindings/leds/leds-lm3692x.txt new file +9 -0
@@ -0,0 +1,28 @@
+* Texas Instruments - LM3692x Highly Efficient Dual-String White LED Driver
+
+The LM36922 is an ultra-compact, highly efficient,
+two string white-LED driver designed for LCD display
+backlighting.
+
+Required properties:
+	- compatible:
+		"ti,lm3692x"

Don't use wildcards in compatible strings.

Documentation/devicetree/bindings/leds/leds-lm3692x.txt line 14

Quoted 5 lines
Documentation/devicetree/bindings/leds/leds-lm3692x.txt new file +5 -0
+	- reg -  I2C slave address
+
+Optional properties:
+	- label - Used for naming LEDs
+	- enable-gpio - gpio pin to enable/disable the device.

enable-gpios is the preferred form.

Documentation/devicetree/bindings/leds/leds-lm3692x.txt line 15

Quoted 1 line
Documentation/devicetree/bindings/leds/leds-lm3692x.txt new file +1 -0
+	- supply - "vled" - LED supply

vled-supply - ...

Quoted 16 lines
Documentation/devicetree/bindings/leds/leds-lm3692x.txt new file +13 -0
+
+Example:
+
+leds: leds@6 {
+	compatible = "ti,lm3692x";
+	reg = <0x36>;
+	label = "backlight_cluster";
+	enable-gpio = <&gpio1 28 GPIO_ACTIVE_HIGH>;
+	vled-supply = <&vbatt>;
+}
+
+For more product information please see the link below:
+http://www.ti.com/lit/ds/snvsa29/snvsa29.pdf
Signature · 1 line
2.15.0.124.g7668cbc60

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

author
#18 lore raw

Rob

Thanks for the review

Quoted 24 lines · Rob Herring
Quoted 23 lines · Dan Murphy

This adds the devicetree bindings for the LM3692x
I2C LED string driver.

---

v3 - No changes
v2 - No changes - https://patchwork.kernel.org/patch/10056677/

 .../devicetree/bindings/leds/leds-lm3692x.txt      | 28 ++++++++++++++++++++++
 1 file changed, 28 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/leds/leds-lm3692x.txt
Documentation/devicetree/bindings/leds/leds-lm3692x.txt new file +3 -0
new file mode 100644
index 000000000000..cfef67bd4100
@@ -0,0 +1,28 @@
+* Texas Instruments - LM3692x Highly Efficient Dual-String White LED Driver
+
+The LM36922 is an ultra-compact, highly efficient,
Quoted 8 lines

Documentation/devicetree/bindings/leds/leds-lm3692x.txt line 9

Quoted 6 lines
Documentation/devicetree/bindings/leds/leds-lm3692x.txt new file +6 -0
+two string white-LED driver designed for LCD display
+backlighting.
+
+Required properties:
+	- compatible:
+		"ti,lm3692x"

Don't use wildcards in compatible strings.

Do you mean to remove the x? How do we denote a family of parts then?

Quoted 8 lines

Documentation/devicetree/bindings/leds/leds-lm3692x.txt line 14

Quoted 6 lines
Documentation/devicetree/bindings/leds/leds-lm3692x.txt new file +5 -0
+	- reg -  I2C slave address
+
+Optional properties:
+	- label - Used for naming LEDs
+	- enable-gpio - gpio pin to enable/disable the device.

enable-gpios is the preferred form.

ack

Quoted 5 lines

Documentation/devicetree/bindings/leds/leds-lm3692x.txt line 15

Quoted 2 lines
Documentation/devicetree/bindings/leds/leds-lm3692x.txt new file +1 -0
+	- supply - "vled" - LED supply

vled-supply - ...

ack

Quoted 16 lines
Quoted 16 lines
Documentation/devicetree/bindings/leds/leds-lm3692x.txt new file +13 -0
+
+Example:
+
+leds: leds@6 {
+	compatible = "ti,lm3692x";
+	reg = <0x36>;
+	label = "backlight_cluster";
+	enable-gpio = <&gpio1 28 GPIO_ACTIVE_HIGH>;
+	vled-supply = <&vbatt>;
+}
+
+For more product information please see the link below:
+http://www.ti.com/lit/ds/snvsa29/snvsa29.pdf
Signature · 1 line
2.15.0.124.g7668cbc60
Signature · 2 lines
------------------
Dan Murphy
maintainer
#19 lore raw
Quoted 38 lines · Dan Murphy

Rob

Thanks for the review

Quoted 24 lines · Rob Herring
Quoted 23 lines · Dan Murphy

This adds the devicetree bindings for the LM3692x
I2C LED string driver.

---

v3 - No changes
v2 - No changes - https://patchwork.kernel.org/patch/10056677/

 .../devicetree/bindings/leds/leds-lm3692x.txt      | 28 ++++++++++++++++++++++
 1 file changed, 28 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/leds/leds-lm3692x.txt
Documentation/devicetree/bindings/leds/leds-lm3692x.txt new file +3 -0
new file mode 100644
index 000000000000..cfef67bd4100
@@ -0,0 +1,28 @@
+* Texas Instruments - LM3692x Highly Efficient Dual-String White LED Driver
+
+The LM36922 is an ultra-compact, highly efficient,
Quoted 8 lines

Documentation/devicetree/bindings/leds/leds-lm3692x.txt line 9

Quoted 6 lines
Documentation/devicetree/bindings/leds/leds-lm3692x.txt new file +6 -0
+two string white-LED driver designed for LCD display
+backlighting.
+
+Required properties:
+    - compatible:
+            "ti,lm3692x"

Don't use wildcards in compatible strings.

Quoted 1 line

Do you mean to remove the x? How do we denote a family of parts then?

Yes. With a compatible string for each one. You can have multiple compatible strings if some are a superset of others.

Rob
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#20 lore raw

dts: fun with chip names Re: [PATCH v3 1/2] dt: bindings: lm3692x: Add bindings for lm3692x LED driver

In reply to Dan Murphy

Hi!

Quoted 8 lines
Quoted 5 lines

Documentation/devicetree/bindings/leds/leds-lm3692x.txt line 9

Quoted 3 lines
Documentation/devicetree/bindings/leds/leds-lm3692x.txt new file +3 -0
+Required properties:
+	- compatible:
+		"ti,lm3692x"

Don't use wildcards in compatible strings.

Do you mean to remove the x? How do we denote a family of parts then?

I guess you should specify the exact chip.

Which will present interesting problem for me on Nokia N9/N950; in one case, compatible chip is produced by two companies, and it looks like some machines have one and some have the other; but we'd like to share the dts as user has no chance telling them apart (and it is not important, anyway).

In second case, chip is refered as APDS990X and I don't know where to get more exact data.

Pavel

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

Re: dts: fun with chip names Re: [PATCH v3 1/2] dt: bindings: lm3692x: Add bindings for lm3692x LED driver

Quoted 13 lines · Pavel Machek

Hi!

Quoted 8 lines
Quoted 5 lines

Documentation/devicetree/bindings/leds/leds-lm3692x.txt line 9

Quoted 3 lines
Documentation/devicetree/bindings/leds/leds-lm3692x.txt new file +3 -0
+Required properties:
+  - compatible:
+          "ti,lm3692x"

Don't use wildcards in compatible strings.

Do you mean to remove the x? How do we denote a family of parts then?

I guess you should specify the exact chip.

Quoted 8 lines

Which will present interesting problem for me on Nokia N9/N950; in one case, compatible chip is produced by two companies, and it looks like some machines have one and some have the other; but we'd like to share the dts as user has no chance telling them apart (and it is not important, anyway).

In second case, chip is refered as APDS990X and I don't know where to get more exact data.

There's always exceptions to rules. Just make the case for it. IIRC, there was the same case for the BT chip.

Rob

author
#22 lore raw

Re: dts: fun with chip names Re: [PATCH v3 1/2] dt: bindings: lm3692x: Add bindings for lm3692x LED driver

Quoted 20 lines · Rob Herring
Quoted 19 lines · Pavel Machek

Hi!

Quoted 8 lines
Quoted 5 lines

Documentation/devicetree/bindings/leds/leds-lm3692x.txt line 9

Quoted 3 lines
Documentation/devicetree/bindings/leds/leds-lm3692x.txt new file +3 -0
+Required properties:
+  - compatible:
+          "ti,lm3692x"

Don't use wildcards in compatible strings.

Do you mean to remove the x? How do we denote a family of parts then?

I guess you should specify the exact chip.

Which will present interesting problem for me on Nokia N9/N950; in one case, compatible chip is produced by two companies, and it looks like some machines have one and some have the other; but we'd like to share the dts as user has no chance telling them apart (and it is not important, anyway).

Quoted 6 lines
Quoted 2 lines

In second case, chip is refered as APDS990X and I don't know where to get more exact data.

There's always exceptions to rules. Just make the case for it. IIRC, there was the same case for the BT chip.

Not sure how I got looped into the dts fun. But I am going to call out the specific chips out in the compatible strings. There are currently only 2 devices supported by this driver. The delta between the chips is one supports a third string of LEDs. 1 bit in 1 register.

Dan

Quoted 2 lines

Rob

Signature · 6 lines
------------------
Dan Murphy
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#23 lore raw
In reply to Dan Murphy

Hi Dan,

Quoted 32 lines · Dan Murphy

This adds the devicetree bindings for the LM3692x
I2C LED string driver.

---

v3 - No changes
v2 - No changes - https://patchwork.kernel.org/patch/10056677/

 .../devicetree/bindings/leds/leds-lm3692x.txt      | 28 ++++++++++++++++++++++
 1 file changed, 28 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/leds/leds-lm3692x.txt
Documentation/devicetree/bindings/leds/leds-lm3692x.txt new file +12 -0
new file mode 100644
index 000000000000..cfef67bd4100
@@ -0,0 +1,28 @@
+* Texas Instruments - LM3692x Highly Efficient Dual-String White LED Driver
+
+The LM36922 is an ultra-compact, highly efficient,
+two string white-LED driver designed for LCD display
+backlighting.
+
+Required properties:
+	- compatible:
+		"ti,lm3692x"
+	- reg -  I2C slave address
+
+Optional properties:

Documentation/devicetree/bindings/leds/leds-lm3692x.txt line 22

Quoted 10 lines
Documentation/devicetree/bindings/leds/leds-lm3692x.txt new file +10 -0
+	- label - Used for naming LEDs
+	- enable-gpio - gpio pin to enable/disable the device.
+	- supply - "vled" - LED supply
+
+Example:
+
+leds: leds@6 {
+	compatible = "ti,lm3692x";
+	reg = <0x36>;
+	label = "backlight_cluster";

Documentation/devicetree/bindings/leds/common.txt states that each LED component has to be represented as a child node (for consistency it should apply also to the arrangements with one LED).

Quoted 7 lines
Documentation/devicetree/bindings/leds/leds-lm3692x.txt new file +6 -0
+	enable-gpio = <&gpio1 28 GPIO_ACTIVE_HIGH>;
+	vled-supply = <&vbatt>;
+}
+
+For more product information please see the link below:
+http://www.ti.com/lit/ds/snvsa29/snvsa29.pdf
Signature · 2 lines
Best regards,
Jacek Anaszewski