Skip to contentSkip to conversation

dt: bindings: lm3601x: Introduce the lm3601x driver

PATCH Superseded Dan Murphy 2 participants 3 messages May 9, 2018

Subsystems (2)

v3 of 9 Superseded Latest is v9 →

lore
Share & tools
lore

Dan Murphy

author
#0 lore raw

PATCH v3 1/2 dt: bindings: lm3601x: Introduce the lm3601x driver

Introduce the device tree bindings for the lm3601x family of LED torch, flash and IR drivers.

---

v3 - Removed wildcard compatible - https://patchwork.kernel.org/patch/10386241/
v2 - No changes - https://patchwork.kernel.org/patch/10384587/

 .../devicetree/bindings/leds/leds-lm3601x.txt | 50 +++++++++++++++++++
 1 file changed, 50 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/leds/leds-lm3601x.txt
Documentation/devicetree/bindings/leds/leds-lm3601x.txt new file +50 -0
new file mode 100644
index 000000000000..a2fc350bc5f1
@@ -0,0 +1,50 @@
+* Texas Instruments - lm3601x Single-LED Flash Driver
+
+The LM3601X are ultra-small LED flash drivers that
+provides a high level of adjustability.
+
+Required properties:
+	- compatible : Can be one of the following
+		"ti,lm36010"
+		"ti,lm36011"
+	- reg : I2C slave address
+	- #address-cells : 1
+	- #size-cells : 0
+
+Required child properties:
+	- reg : 0 - Indicates to support and register a torch interface
+		1 - Indicates to support and register a strobe interface
+		2 - Indicates to support and register an ir interface
+
+Optional child properties:
+	- label : see Documentation/devicetree/bindings/leds/common.txt
+
+Example:
+led-controller@64 {
+	compatible = "ti,lm36010";
+	#address-cells = <1>;
+	#size-cells = <0>;
+	reg = <0x64>;
+
+	led@0 {
+		reg = <0>;
+		label = "white:torch";
+		led-max-microamp=<10000>;
+	};
+
+	led@1 {
+		reg = <1>;
+		label = "white:strobe";
+		flash-max-microamp=<10000>;
+		flash-max-timeout-us=<800>;
+	};
+
+	led@2 {
+		reg = <2>;
+		label = "invisible:ir";
+	};
+}
+
+For more product information please see the links below:
+http://www.ti.com/product/LM36010
+http://www.ti.com/product/LM36011
Signature · 1 line
2.17.0.582.gccdcbd54c
author
#1 lore raw

PATCH v3 2/2 leds: lm3601x: Introduce the lm3601x LED driver

Introduce the family of LED devices that can
drive a torch, strobe or IR LED.

The LED driver can be configured with a strobe
timer to execute a strobe flash. The IR LED
brightness is controlled via the torch brightness
register.

The data sheet for each the LM36010 and LM36011
LED drivers can be found here:
http://www.ti.com/product/LM36010
http://www.ti.com/product/LM36011

---

v3 - removed wildcard dt compatible, fixed copyright, fixed struct doc, removed
RO registers from default, added regmap volatile for FLAGS_REG, updated regmap cache type, fixed unlock and extra semi colon in strobe_set, removed unnecessary out label
in led register and fixed checking of the ret in brightness_set - https://patchwork.kernel.org/patch/10386243/

v2 - Fixed kbuild issue and removed unused cdev_strobe - https://patchwork.kernel.org/patch/10384585/

 drivers/leds/Kconfig        |   9 +
 drivers/leds/Makefile       |   1 +
 drivers/leds/leds-lm3601x.c | 611 ++++++++++++++++++++++++++++++++++++
 3 files changed, 621 insertions(+)
 create mode 100644 drivers/leds/leds-lm3601x.c
drivers/leds/Kconfig +9 -0
index 2c896c0e69e1..50ae536f343f 100644
@@ -145,6 +145,15 @@ config LEDS_LM3692X
 	  This option enables support for the TI LM3692x family
 	  of white LED string drivers used for backlighting.
 
+config LEDS_LM3601X
+	tristate "LED support for LM3601x Chips"
+	depends on LEDS_CLASS && I2C && OF
+	depends on LEDS_CLASS_FLASH
+	select REGMAP_I2C
+	help
+	  This option enables support for the TI LM3601x family
+	  of flash, torch and indicator classes.
+
 config LEDS_LOCOMO
 	tristate "LED Support for Locomo device"
 	depends on LEDS_CLASS
drivers/leds/Makefile +1 -0
index 91eca81cae82..b79807fe1b67 100644
@@ -76,6 +76,7 @@ obj-$(CONFIG_LEDS_MLXREG)		+= leds-mlxreg.o
 obj-$(CONFIG_LEDS_NIC78BX)		+= leds-nic78bx.o
 obj-$(CONFIG_LEDS_MT6323)		+= leds-mt6323.o
 obj-$(CONFIG_LEDS_LM3692X)		+= leds-lm3692x.o
+obj-$(CONFIG_LEDS_LM3601X)		+= leds-lm3601x.o
 
 # LED SPI Drivers
 obj-$(CONFIG_LEDS_DAC124S085)		+= leds-dac124s085.o
drivers/leds/leds-lm3601x.c new file +611 -0

611 lines not on this page · raw message

Signature · 1 line
2.17.0.582.gccdcbd54c
#2 lore raw

Re: [PATCH v3 2/2] leds: lm3601x: Introduce the lm3601x LED driver

Thank you for the patch! Perhaps something to improve:

Hi Dan,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on robh/for-next]
[also build test WARNING on v4.17-rc4 next-20180509]
[cannot apply to j.anaszewski-leds/for-next]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Dan-Murphy/dt-bindings-lm3601x-Introduce-the-lm3601x-driver/20180509-232022
base:   https://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git for-next

coccinelle warnings: (new ones prefixed by >>)

>> drivers/leds/leds-lm3601x.c:241:35-36: WARNING: Use ARRAY_SIZE

vim +241 drivers/leds/leds-lm3601x.c

224
225 static int lm3601x_strobe_set(struct led_classdev_flash *fled_cdev,
226 bool state)
227 {
228 struct lm3601x_led *led = fled_cdev_to_led(fled_cdev);
229 int ret;
230 int current_timeout;
231 int reg_count;
232 int i;
233 int timeout_reg_val = 0;
234
235 mutex_lock(&led->lock);
236
237 ret = regmap_read(led->regmap, LM3601X_CFG_REG, &current_timeout);
238 if (ret < 0)
239 goto out;
240

 > 241		reg_count = sizeof(strobe_timeouts) / sizeof(strobe_timeouts[0]);

242 for (i = 0; i < reg_count; i++) {
243 if (led->strobe_timeout > strobe_timeouts[i].timeout)
244 continue;
245
246 if (led->strobe_timeout <= strobe_timeouts[i].timeout) {
247 timeout_reg_val = (strobe_timeouts[i].reg_val << 1);
248 break;
249 }
250
251 ret = -EINVAL;
252 goto out;
253 }
254
255 if (led->strobe_timeout != current_timeout)
256 ret = regmap_update_bits(led->regmap, LM3601X_CFG_REG,
257 0x1e, timeout_reg_val);
258
259 if (state)
260 ret = regmap_update_bits(led->regmap, LM3601X_ENABLE_REG,
261 LM3601X_MODE_STROBE,
262 LM3601X_MODE_STROBE);
263 else
264 ret = regmap_update_bits(led->regmap, LM3601X_ENABLE_REG,
265 LM3601X_MODE_STROBE, LED_OFF);
266
267 ret = lm3601x_read_faults(led);
268 out:
269 mutex_unlock(&led->lock);
270 return ret;
271 }
272

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation