* [PATCH 1/2] dt: bindings: lm3692x: Add bindings for lm3692x LED driver @ 2017-11-13 20:50 Dan Murphy 2017-11-13 20:50 ` [PATCH 2/2] leds: lm3692x: Introduce LM3692x dual string driver Dan Murphy [not found] ` <20171113205052.25884-1-dmurphy-l0cyMroinI0@public.gmane.org> 0 siblings, 2 replies; 10+ messages in thread From: Dan Murphy @ 2017-11-13 20:50 UTC (permalink / raw) To: robh+dt, mark.rutland, rpurdie, jacek.anaszewski, pavel Cc: devicetree, linux-kernel, linux-leds, Dan Murphy This adds the devicetree bindings for the LM3692x I2C LED string driver. Signed-off-by: Dan Murphy <dmurphy@ti.com> --- .../devicetree/bindings/leds/leds-lm3692x.txt | 28 ++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 Documentation/devicetree/bindings/leds/leds-lm3692x.txt diff --git a/Documentation/devicetree/bindings/leds/leds-lm3692x.txt b/Documentation/devicetree/bindings/leds/leds-lm3692x.txt new file mode 100644 index 000000000000..cfef67bd4100 --- /dev/null +++ b/Documentation/devicetree/bindings/leds/leds-lm3692x.txt @@ -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 -- 2.15.0.124.g7668cbc60 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 2/2] leds: lm3692x: Introduce LM3692x dual string driver 2017-11-13 20:50 [PATCH 1/2] dt: bindings: lm3692x: Add bindings for lm3692x LED driver Dan Murphy @ 2017-11-13 20:50 ` Dan Murphy 2017-11-15 10:45 ` Pavel Machek ` (2 more replies) [not found] ` <20171113205052.25884-1-dmurphy-l0cyMroinI0@public.gmane.org> 1 sibling, 3 replies; 10+ messages in thread From: Dan Murphy @ 2017-11-13 20:50 UTC (permalink / raw) To: robh+dt, mark.rutland, rpurdie, jacek.anaszewski, pavel Cc: devicetree, linux-kernel, linux-leds, Dan Murphy Introducing the LM3692x Dual-String white LED driver. Data sheet is located http://www.ti.com/lit/ds/snvsa29/snvsa29.pdf Signed-off-by: Dan Murphy <dmurphy@ti.com> --- drivers/leds/leds-lm3692x.c | 380 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 380 insertions(+) create mode 100644 drivers/leds/leds-lm3692x.c diff --git a/drivers/leds/leds-lm3692x.c b/drivers/leds/leds-lm3692x.c new file mode 100644 index 000000000000..beb753abc7b0 --- /dev/null +++ b/drivers/leds/leds-lm3692x.c @@ -0,0 +1,380 @@ +/* + * TI lm3692x LED Driver + * + * Copyright (C) 2017 Texas Instruments + * + * Author: Dan Murphy <dmurphy@ti.com> + * + * 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. + * + */ + +#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) + goto out; + + fault = read_buf; + + if (fault) + dev_err(&led->client->dev, "Detected a fault 0x%X\n", + fault); +out: + 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 led_brightness = (brt_val << 4) + 7; + int ret; + + if (brt_val == LED_OFF) + led_brightness = 0; + + 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, + (led_brightness & 0xff0) >> 4); + if (ret) { + dev_err(&led->client->dev, "Cannot write MSB\n"); + goto out; + } + + ret = regmap_write(led->regmap, LM3692X_BRT_LSB, + led_brightness & 0x07); + 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"); + } + + 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"); + /* + * 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"); + + 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"); + + ret = regmap_write(led->regmap, LM3692X_AUTO_FREQ_HI, 0x00); + if (ret) + dev_err(&led->client->dev, "Failed programming AUTO HI FREQ\n"); + + ret = regmap_write(led->regmap, LM3692X_AUTO_FREQ_LO, 0x00); + if (ret) + dev_err(&led->client->dev, "Failed programming AUTO LO FREQ\n"); + + + ret = regmap_write(led->regmap, LM3692X_BL_ADJ_THRESH, 0x00); + if (ret) + dev_err(&led->client->dev, "Failed programming BL Threshold\n"); + + 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; + + led = devm_kzalloc(&client->dev, sizeof(*led), GFP_KERNEL); + if (!led) + return -ENOMEM; + + if (client->dev.of_node) { + ret = of_property_read_string(np, "label", &led->label); + if (ret) + led->label = LM3692X_LED_NAME; + } + + 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)) + led->regulator = NULL; + + led->client = client; + led->led_dev.name = led->label; + led->led_dev.max_brightness = LED_FULL; + 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; + } + + ret = lm3692x_init(led); + if (ret) + return ret; + + ret = led_classdev_register(&client->dev, &led->led_dev); + 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); + + if (led->regulator) { + ret = regulator_disable(led->regulator); + if (ret) + dev_err(&led->client->dev, + "Failed to disable regulator\n"); + } + + 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, +}; +module_i2c_driver(lm3692x_driver); + +MODULE_DESCRIPTION("Texas Instruments LM3692X LED driver"); +MODULE_AUTHOR("Dan Murphy <dmurphy@ti.com>"); +MODULE_LICENSE("GPL"); -- 2.15.0.124.g7668cbc60 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH 2/2] leds: lm3692x: Introduce LM3692x dual string driver 2017-11-13 20:50 ` [PATCH 2/2] leds: lm3692x: Introduce LM3692x dual string driver Dan Murphy @ 2017-11-15 10:45 ` Pavel Machek 2017-11-15 12:47 ` Dan Murphy [not found] ` <20171113205052.25884-2-dmurphy-l0cyMroinI0@public.gmane.org> 2017-11-16 3:48 ` Andrew F. Davis 2 siblings, 1 reply; 10+ messages in thread From: Pavel Machek @ 2017-11-15 10:45 UTC (permalink / raw) To: Dan Murphy Cc: robh+dt, mark.rutland, rpurdie, jacek.anaszewski, devicetree, linux-kernel, linux-leds [-- Attachment #1: Type: text/plain, Size: 2716 bytes --] On Mon 2017-11-13 14:50:52, Dan Murphy wrote: > Introducing the LM3692x Dual-String white LED driver. > > Data sheet is located > http://www.ti.com/lit/ds/snvsa29/snvsa29.pdf > > Signed-off-by: Dan Murphy <dmurphy@ti.com> > --- > drivers/leds/leds-lm3692x.c | 380 ++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 380 insertions(+) > create mode 100644 drivers/leds/leds-lm3692x.c > > diff --git a/drivers/leds/leds-lm3692x.c b/drivers/leds/leds-lm3692x.c > new file mode 100644 > index 000000000000..beb753abc7b0 > --- /dev/null > +++ b/drivers/leds/leds-lm3692x.c > @@ -0,0 +1,380 @@ > +/* > + * TI lm3692x LED Driver > + * > + * Copyright (C) 2017 Texas Instruments > + * > + * Author: Dan Murphy <dmurphy@ti.com> > + * > + * 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. > + * > + */ I'd put data sheet link here. > +/** > + * 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 > + **/ Are you sure this is linuxdoc? Would */ at the end be enough? > +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) > + goto out; Just return here. > + /* > + * 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 > + */ "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"); > + > + 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"); > + > + ret = regmap_write(led->regmap, LM3692X_AUTO_FREQ_HI, 0x00); > + if (ret) > + dev_err(&led->client->dev, "Failed programming AUTO HI FREQ\n"); If something fails, is it wise to continue? Thanks, Pavel -- (english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html [-- Attachment #2: Digital signature --] [-- Type: application/pgp-signature, Size: 181 bytes --] ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 2/2] leds: lm3692x: Introduce LM3692x dual string driver 2017-11-15 10:45 ` Pavel Machek @ 2017-11-15 12:47 ` Dan Murphy 2017-11-15 13:00 ` Pavel Machek 0 siblings, 1 reply; 10+ messages in thread From: Dan Murphy @ 2017-11-15 12:47 UTC (permalink / raw) To: Pavel Machek Cc: robh+dt, mark.rutland, rpurdie, jacek.anaszewski, devicetree, linux-kernel, linux-leds Pavel Thanks On 11/15/2017 04:45 AM, Pavel Machek wrote: > On Mon 2017-11-13 14:50:52, Dan Murphy wrote: >> Introducing the LM3692x Dual-String white LED driver. >> >> Data sheet is located >> http://www.ti.com/lit/ds/snvsa29/snvsa29.pdf >> >> Signed-off-by: Dan Murphy <dmurphy@ti.com> >> --- >> drivers/leds/leds-lm3692x.c | 380 ++++++++++++++++++++++++++++++++++++++++++++ >> 1 file changed, 380 insertions(+) >> create mode 100644 drivers/leds/leds-lm3692x.c >> >> diff --git a/drivers/leds/leds-lm3692x.c b/drivers/leds/leds-lm3692x.c >> new file mode 100644 >> index 000000000000..beb753abc7b0 >> --- /dev/null >> +++ b/drivers/leds/leds-lm3692x.c >> @@ -0,0 +1,380 @@ >> +/* >> + * TI lm3692x LED Driver >> + * >> + * Copyright (C) 2017 Texas Instruments >> + * >> + * Author: Dan Murphy <dmurphy@ti.com> >> + * >> + * 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. >> + * >> + */ > > I'd put data sheet link here. OK > >> +/** >> + * 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 >> + **/ > > Are you sure this is linuxdoc? Would */ at the end be enough? I will fix this > >> +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) >> + goto out; > > Just return here. OK > >> + /* >> + * 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 >> + */ > > "per section 7.5.14 of the data sheet." OK > >> + 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"); >> + >> + 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"); >> + >> + ret = regmap_write(led->regmap, LM3692X_AUTO_FREQ_HI, 0x00); >> + if (ret) >> + dev_err(&led->client->dev, "Failed programming AUTO HI FREQ\n"); > > If something fails, is it wise to continue? > > Thanks, > Pavel > -- ------------------ Dan Murphy ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 2/2] leds: lm3692x: Introduce LM3692x dual string driver 2017-11-15 12:47 ` Dan Murphy @ 2017-11-15 13:00 ` Pavel Machek 2017-11-15 13:06 ` Dan Murphy 0 siblings, 1 reply; 10+ messages in thread From: Pavel Machek @ 2017-11-15 13:00 UTC (permalink / raw) To: Dan Murphy Cc: robh+dt, mark.rutland, rpurdie, jacek.anaszewski, devicetree, linux-kernel, linux-leds [-- Attachment #1: Type: text/plain, Size: 903 bytes --] Hi! > >> + 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"); > >> + > >> + 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"); > >> + > >> + ret = regmap_write(led->regmap, LM3692X_AUTO_FREQ_HI, 0x00); > >> + if (ret) > >> + dev_err(&led->client->dev, "Failed programming AUTO HI FREQ\n"); > > > > If something fails, is it wise to continue? If something fails, is it wise to continue? Pavel -- (english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html [-- Attachment #2: Digital signature --] [-- Type: application/pgp-signature, Size: 181 bytes --] ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 2/2] leds: lm3692x: Introduce LM3692x dual string driver 2017-11-15 13:00 ` Pavel Machek @ 2017-11-15 13:06 ` Dan Murphy 0 siblings, 0 replies; 10+ messages in thread From: Dan Murphy @ 2017-11-15 13:06 UTC (permalink / raw) To: Pavel Machek Cc: robh+dt, mark.rutland, rpurdie, jacek.anaszewski, devicetree, linux-kernel, linux-leds Pavel On 11/15/2017 07:00 AM, Pavel Machek wrote: > Hi! > >>>> + 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"); >>>> + >>>> + 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"); >>>> + >>>> + ret = regmap_write(led->regmap, LM3692X_AUTO_FREQ_HI, 0x00); >>>> + if (ret) >>>> + dev_err(&led->client->dev, "Failed programming AUTO HI FREQ\n"); >>> >>> If something fails, is it wise to continue? > > If something fails, is it wise to continue? > Sorry missed that comment. It is ok to continue but probably should goto out and return an error so the probe fails. Dan > Pavel > -- ------------------ Dan Murphy ^ permalink raw reply [flat|nested] 10+ messages in thread
[parent not found: <20171113205052.25884-2-dmurphy-l0cyMroinI0@public.gmane.org>]
* Re: [PATCH 2/2] leds: lm3692x: Introduce LM3692x dual string driver [not found] ` <20171113205052.25884-2-dmurphy-l0cyMroinI0@public.gmane.org> @ 2017-11-15 13:11 ` Dan Murphy 0 siblings, 0 replies; 10+ messages in thread From: Dan Murphy @ 2017-11-15 13:11 UTC (permalink / raw) To: robh+dt-DgEjT+Ai2ygdnm+yROfE0A, mark.rutland-5wv7dgnIgG8, rpurdie-Fm38FmjxZ/leoWH0uzbU5w, jacek.anaszewski-Re5JQEeQqe8AvxtiuMwx3w, pavel-+ZI9xUNit7I Cc: devicetree-u79uwXL29TY76Z2rM5mHXA, linux-kernel-u79uwXL29TY76Z2rM5mHXA, linux-leds-u79uwXL29TY76Z2rM5mHXA On 11/13/2017 02:50 PM, Dan Murphy wrote: > Introducing the LM3692x Dual-String white LED driver. > > Data sheet is located > http://www.ti.com/lit/ds/snvsa29/snvsa29.pdf > > Signed-off-by: Dan Murphy <dmurphy-l0cyMroinI0@public.gmane.org> > --- > drivers/leds/leds-lm3692x.c | 380 ++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 380 insertions(+) > create mode 100644 drivers/leds/leds-lm3692x.c > > diff --git a/drivers/leds/leds-lm3692x.c b/drivers/leds/leds-lm3692x.c > new file mode 100644 > index 000000000000..beb753abc7b0 > --- /dev/null > +++ b/drivers/leds/leds-lm3692x.c > @@ -0,0 +1,380 @@ > +/* > + * TI lm3692x LED Driver > + * > + * Copyright (C) 2017 Texas Instruments > + * > + * Author: Dan Murphy <dmurphy-l0cyMroinI0@public.gmane.org> > + * > + * 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. > + * > + */ > + > +#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) > + goto out; > + > + fault = read_buf; > + > + if (fault) > + dev_err(&led->client->dev, "Detected a fault 0x%X\n", > + fault); > +out: > + 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 led_brightness = (brt_val << 4) + 7; After a peer review with the hardware team it was determined that the brightness value calculation always sets the LSB to a value of 7. Therefore this will be changed in patch v2 so that the MSB will contain the brt_val and the LSB will contain the 3 MSB bits of the brt_val. So the values will look something like this: Code 0x00 thru code 0x1f --> LSB = 0 Code 0x20 thru code 0x3f --> LSB = 1, 0x101 up to 0x1f9 Code 0x40 thru code 0x5f --> LSB = 2, 0x202 up to 0x2fa Code 0x60 thru code 0x7f --> LSB = 3, 0x303 thru 0x3fb Code 0x80 thru code 0x9f --> LSB = 4, 0x404 thru 0x4fc . . Code 0xe0 thru code 0xff --> LSB = 7, 0x707 thru 0x7ff > + int ret; > + > + if (brt_val == LED_OFF) > + led_brightness = 0; > + > + 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, > + (led_brightness & 0xff0) >> 4); > + if (ret) { > + dev_err(&led->client->dev, "Cannot write MSB\n"); > + goto out; > + } > + > + ret = regmap_write(led->regmap, LM3692X_BRT_LSB, > + led_brightness & 0x07); > + 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"); > + } > + > + 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"); > + /* > + * 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"); > + > + 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"); > + > + ret = regmap_write(led->regmap, LM3692X_AUTO_FREQ_HI, 0x00); > + if (ret) > + dev_err(&led->client->dev, "Failed programming AUTO HI FREQ\n"); > + > + ret = regmap_write(led->regmap, LM3692X_AUTO_FREQ_LO, 0x00); > + if (ret) > + dev_err(&led->client->dev, "Failed programming AUTO LO FREQ\n"); > + > + > + ret = regmap_write(led->regmap, LM3692X_BL_ADJ_THRESH, 0x00); > + if (ret) > + dev_err(&led->client->dev, "Failed programming BL Threshold\n"); > + > + 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; > + > + led = devm_kzalloc(&client->dev, sizeof(*led), GFP_KERNEL); > + if (!led) > + return -ENOMEM; > + > + if (client->dev.of_node) { > + ret = of_property_read_string(np, "label", &led->label); > + if (ret) > + led->label = LM3692X_LED_NAME; > + } > + > + 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)) > + led->regulator = NULL; > + > + led->client = client; > + led->led_dev.name = led->label; > + led->led_dev.max_brightness = LED_FULL; > + 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; > + } > + > + ret = lm3692x_init(led); > + if (ret) > + return ret; > + > + ret = led_classdev_register(&client->dev, &led->led_dev); > + 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); > + > + if (led->regulator) { > + ret = regulator_disable(led->regulator); > + if (ret) > + dev_err(&led->client->dev, > + "Failed to disable regulator\n"); > + } > + > + 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, > +}; > +module_i2c_driver(lm3692x_driver); > + > +MODULE_DESCRIPTION("Texas Instruments LM3692X LED driver"); > +MODULE_AUTHOR("Dan Murphy <dmurphy-l0cyMroinI0@public.gmane.org>"); > +MODULE_LICENSE("GPL"); > -- ------------------ Dan Murphy -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 2/2] leds: lm3692x: Introduce LM3692x dual string driver 2017-11-13 20:50 ` [PATCH 2/2] leds: lm3692x: Introduce LM3692x dual string driver Dan Murphy 2017-11-15 10:45 ` Pavel Machek [not found] ` <20171113205052.25884-2-dmurphy-l0cyMroinI0@public.gmane.org> @ 2017-11-16 3:48 ` Andrew F. Davis [not found] ` <3e209041-561c-84a0-d0dd-253cf37f060a-l0cyMroinI0@public.gmane.org> 2 siblings, 1 reply; 10+ messages in thread From: Andrew F. Davis @ 2017-11-16 3:48 UTC (permalink / raw) To: Dan Murphy, robh+dt, mark.rutland, rpurdie, jacek.anaszewski, pavel Cc: devicetree, linux-kernel, linux-leds On 11/13/2017 02:50 PM, Dan Murphy wrote: > Introducing the LM3692x Dual-String white LED driver. > > Data sheet is located > http://www.ti.com/lit/ds/snvsa29/snvsa29.pdf > > Signed-off-by: Dan Murphy <dmurphy@ti.com> > --- Looks like v3 is posted but I can't find it in my mailbox :/ but the comments below should still be valid. > drivers/leds/leds-lm3692x.c | 380 ++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 380 insertions(+) > create mode 100644 drivers/leds/leds-lm3692x.c > > diff --git a/drivers/leds/leds-lm3692x.c b/drivers/leds/leds-lm3692x.c > new file mode 100644 > index 000000000000..beb753abc7b0 > --- /dev/null > +++ b/drivers/leds/leds-lm3692x.c > @@ -0,0 +1,380 @@ > +/* > + * TI lm3692x LED Driver > + * > + * Copyright (C) 2017 Texas Instruments > + * > + * Author: Dan Murphy <dmurphy@ti.com> > + * > + * 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. > + * > + */ > + > +#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)) The above look like you are just counting in binary, I'd just list the numbers then shift them by one. > +#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)) Same here, looks like a couple below too. > +#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) > + goto out; > + > + fault = read_buf; > + > + if (fault) > + dev_err(&led->client->dev, "Detected a fault 0x%X\n", > + fault); > +out: > + 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 led_brightness = (brt_val << 4) + 7; Magic numbers? BRIGHTNESS_SHIFT/MASK maybe? And below we undo the operation anyway before we write it to the register. Why not just drop that and to the shift/mask when you write it. > + int ret; > + > + if (brt_val == LED_OFF) > + led_brightness = 0; > + > + 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, > + (led_brightness & 0xff0) >> 4); > + if (ret) { > + dev_err(&led->client->dev, "Cannot write MSB\n"); > + goto out; > + } > + > + ret = regmap_write(led->regmap, LM3692X_BRT_LSB, > + led_brightness & 0x07); > + 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"); > + } > + > + 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"); > + /* > + * 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"); > + > + 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"); > + > + ret = regmap_write(led->regmap, LM3692X_AUTO_FREQ_HI, 0x00); > + if (ret) > + dev_err(&led->client->dev, "Failed programming AUTO HI FREQ\n"); > + > + ret = regmap_write(led->regmap, LM3692X_AUTO_FREQ_LO, 0x00); > + if (ret) > + dev_err(&led->client->dev, "Failed programming AUTO LO FREQ\n"); > + > + > + ret = regmap_write(led->regmap, LM3692X_BL_ADJ_THRESH, 0x00); > + if (ret) > + dev_err(&led->client->dev, "Failed programming BL Threshold\n"); > + > + 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; > + > + led = devm_kzalloc(&client->dev, sizeof(*led), GFP_KERNEL); > + if (!led) > + return -ENOMEM; > + > + if (client->dev.of_node) { > + ret = of_property_read_string(np, "label", &led->label); > + if (ret) > + led->label = LM3692X_LED_NAME; > + } > + > + 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)) > + led->regulator = NULL; > + > + led->client = client; > + led->led_dev.name = led->label; > + led->led_dev.max_brightness = LED_FULL; > + 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; > + } > + > + ret = lm3692x_init(led); > + if (ret) > + return ret; > + > + ret = led_classdev_register(&client->dev, &led->led_dev); > + 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); > + > + if (led->regulator) { > + ret = regulator_disable(led->regulator); > + if (ret) > + dev_err(&led->client->dev, > + "Failed to disable regulator\n"); > + } > + > + 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, > +}; > +module_i2c_driver(lm3692x_driver); > + > +MODULE_DESCRIPTION("Texas Instruments LM3692X LED driver"); > +MODULE_AUTHOR("Dan Murphy <dmurphy@ti.com>"); > +MODULE_LICENSE("GPL"); > ^ permalink raw reply [flat|nested] 10+ messages in thread
[parent not found: <3e209041-561c-84a0-d0dd-253cf37f060a-l0cyMroinI0@public.gmane.org>]
* Re: [PATCH 2/2] leds: lm3692x: Introduce LM3692x dual string driver [not found] ` <3e209041-561c-84a0-d0dd-253cf37f060a-l0cyMroinI0@public.gmane.org> @ 2017-11-16 12:46 ` Dan Murphy 0 siblings, 0 replies; 10+ messages in thread From: Dan Murphy @ 2017-11-16 12:46 UTC (permalink / raw) To: Andrew F. Davis, robh+dt-DgEjT+Ai2ygdnm+yROfE0A, mark.rutland-5wv7dgnIgG8, rpurdie-Fm38FmjxZ/leoWH0uzbU5w, jacek.anaszewski-Re5JQEeQqe8AvxtiuMwx3w, pavel-+ZI9xUNit7I Cc: devicetree-u79uwXL29TY76Z2rM5mHXA, linux-kernel-u79uwXL29TY76Z2rM5mHXA, linux-leds-u79uwXL29TY76Z2rM5mHXA Andrew Thanks On 11/15/2017 09:48 PM, Andrew F. Davis wrote: > On 11/13/2017 02:50 PM, Dan Murphy wrote: >> Introducing the LM3692x Dual-String white LED driver. >> >> Data sheet is located >> http://www.ti.com/lit/ds/snvsa29/snvsa29.pdf >> >> Signed-off-by: Dan Murphy <dmurphy-l0cyMroinI0@public.gmane.org> >> --- > > Looks like v3 is posted but I can't find it in my mailbox :/ but the > comments below should still be valid. v3 did post and some of the changes you pointed out were made > >> drivers/leds/leds-lm3692x.c | 380 ++++++++++++++++++++++++++++++++++++++++++++ >> 1 file changed, 380 insertions(+) >> create mode 100644 drivers/leds/leds-lm3692x.c >> >> diff --git a/drivers/leds/leds-lm3692x.c b/drivers/leds/leds-lm3692x.c >> new file mode 100644 >> index 000000000000..beb753abc7b0 >> --- /dev/null >> +++ b/drivers/leds/leds-lm3692x.c >> @@ -0,0 +1,380 @@ >> +/* >> + * TI lm3692x LED Driver >> + * >> + * Copyright (C) 2017 Texas Instruments >> + * >> + * Author: Dan Murphy <dmurphy-l0cyMroinI0@public.gmane.org> >> + * >> + * 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. >> + * >> + */ >> + >> +#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)) > > The above look like you are just counting in binary, I'd just list the > numbers then shift them by one. This is just another way to do it. Its just a matter of preference. > >> +#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)) > > Same here, looks like a couple below too. Same as above > >> +#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) >> + goto out; >> + >> + fault = read_buf; >> + >> + if (fault) >> + dev_err(&led->client->dev, "Detected a fault 0x%X\n", >> + fault); >> +out: >> + 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 led_brightness = (brt_val << 4) + 7; > > Magic numbers? > > BRIGHTNESS_SHIFT/MASK maybe? > > And below we undo the operation anyway before we write it to the > register. Why not just drop that and to the shift/mask when you write it. > v3 has this changed anyway to something newer. <snip> -- ------------------ Dan Murphy -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 10+ messages in thread
[parent not found: <20171113205052.25884-1-dmurphy-l0cyMroinI0@public.gmane.org>]
* Re: [PATCH 1/2] dt: bindings: lm3692x: Add bindings for lm3692x LED driver [not found] ` <20171113205052.25884-1-dmurphy-l0cyMroinI0@public.gmane.org> @ 2017-11-15 10:35 ` Pavel Machek 0 siblings, 0 replies; 10+ messages in thread From: Pavel Machek @ 2017-11-15 10:35 UTC (permalink / raw) To: Dan Murphy Cc: robh+dt-DgEjT+Ai2ygdnm+yROfE0A, mark.rutland-5wv7dgnIgG8, rpurdie-Fm38FmjxZ/leoWH0uzbU5w, jacek.anaszewski-Re5JQEeQqe8AvxtiuMwx3w, devicetree-u79uwXL29TY76Z2rM5mHXA, linux-kernel-u79uwXL29TY76Z2rM5mHXA, linux-leds-u79uwXL29TY76Z2rM5mHXA [-- Attachment #1: Type: text/plain, Size: 1498 bytes --] On Mon 2017-11-13 14:50:51, Dan Murphy wrote: > This adds the devicetree bindings for the LM3692x > I2C LED string driver. > > Signed-off-by: Dan Murphy <dmurphy-l0cyMroinI0@public.gmane.org> Acked-by: Pavel Machek <pavel-+ZI9xUNit7I@public.gmane.org> > diff --git a/Documentation/devicetree/bindings/leds/leds-lm3692x.txt b/Documentation/devicetree/bindings/leds/leds-lm3692x.txt > new file mode 100644 > index 000000000000..cfef67bd4100 > --- /dev/null > +++ b/Documentation/devicetree/bindings/leds/leds-lm3692x.txt > @@ -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 -- (english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html [-- Attachment #2: Digital signature --] [-- Type: application/pgp-signature, Size: 181 bytes --] ^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2017-11-16 12:46 UTC | newest] Thread overview: 10+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2017-11-13 20:50 [PATCH 1/2] dt: bindings: lm3692x: Add bindings for lm3692x LED driver Dan Murphy 2017-11-13 20:50 ` [PATCH 2/2] leds: lm3692x: Introduce LM3692x dual string driver Dan Murphy 2017-11-15 10:45 ` Pavel Machek 2017-11-15 12:47 ` Dan Murphy 2017-11-15 13:00 ` Pavel Machek 2017-11-15 13:06 ` Dan Murphy [not found] ` <20171113205052.25884-2-dmurphy-l0cyMroinI0@public.gmane.org> 2017-11-15 13:11 ` Dan Murphy 2017-11-16 3:48 ` Andrew F. Davis [not found] ` <3e209041-561c-84a0-d0dd-253cf37f060a-l0cyMroinI0@public.gmane.org> 2017-11-16 12:46 ` Dan Murphy [not found] ` <20171113205052.25884-1-dmurphy-l0cyMroinI0@public.gmane.org> 2017-11-15 10:35 ` [PATCH 1/2] dt: bindings: lm3692x: Add bindings for lm3692x LED driver Pavel Machek
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).