Re: [PATCH 2/2] leds: lm3601x: Introduce the lm3601x LED driver
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-20180507] [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/20180508-074439 base: https://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git for-next config: ia64-allmodconfig (attached as .config) compiler: ia64-linux-gcc (GCC) 7.2.0 reproduce: wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree make.cross ARCH=ia64 All warnings (new ones prefixed by >>): In file included from drivers/leds/leds-lm3601x.c:13:0: drivers/leds/leds-lm3601x.c: In function 'lm3601x_strobe_brightness_set': >> drivers/leds/leds-lm3601x.c:272:6: warning: large integer implicitly >> truncated to unsigned type [-Woverflow] ~LM3601X_MODE_STROBE, LED_OFF); ^ include/linux/regmap.h:76:36: note: in definition of macro 'regmap_update_bits' regmap_update_bits_base(map, reg, mask, val, NULL, false, false) ^~~~ vim +272 drivers/leds/leds-lm3601x.c 258 259 static int lm3601x_strobe_brightness_set(struct led_classdev *cdev, 260 enum led_brightness brightness) 261 { 262 struct led_classdev_flash *fled_cdev = lcdev_to_flcdev(cdev); 263 struct lm3601x_led *led = fled_cdev_to_led(fled_cdev); 264 int ret; 265 u8 brightness_val; 266 267 mutex_lock(>lock); 268 ret = lm3601x_read_faults(led); 269 270 if (brightness == LED_OFF) { 271 ret = regmap_update_bits(led->regmap, LM3601X_ENABLE_REG, > 272 ~LM3601X_MODE_STROBE, LED_OFF); 273 goto out; 274 } 275 276 if (brightness == LED_ON) 277 brightness_val = LED_ON; 278 else 279 brightness_val = (brightness/2); 280 281 ret = regmap_write(led->regmap, LM3601X_LED_FLASH_REG, brightness_val); 282 283 out: 284 mutex_unlock(>lock); 285 return ret; 286 } 287 --- 0-DAY kernel test infrastructureOpen Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation .config.gz Description: application/gzip
Re: [PATCH 2/2] leds: lm3601x: Introduce the lm3601x LED driver
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-20180507] [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/20180508-074439 base: https://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git for-next config: ia64-allmodconfig (attached as .config) compiler: ia64-linux-gcc (GCC) 7.2.0 reproduce: wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree make.cross ARCH=ia64 All warnings (new ones prefixed by >>): In file included from drivers/leds/leds-lm3601x.c:13:0: drivers/leds/leds-lm3601x.c: In function 'lm3601x_strobe_brightness_set': >> drivers/leds/leds-lm3601x.c:272:6: warning: large integer implicitly >> truncated to unsigned type [-Woverflow] ~LM3601X_MODE_STROBE, LED_OFF); ^ include/linux/regmap.h:76:36: note: in definition of macro 'regmap_update_bits' regmap_update_bits_base(map, reg, mask, val, NULL, false, false) ^~~~ vim +272 drivers/leds/leds-lm3601x.c 258 259 static int lm3601x_strobe_brightness_set(struct led_classdev *cdev, 260 enum led_brightness brightness) 261 { 262 struct led_classdev_flash *fled_cdev = lcdev_to_flcdev(cdev); 263 struct lm3601x_led *led = fled_cdev_to_led(fled_cdev); 264 int ret; 265 u8 brightness_val; 266 267 mutex_lock(>lock); 268 ret = lm3601x_read_faults(led); 269 270 if (brightness == LED_OFF) { 271 ret = regmap_update_bits(led->regmap, LM3601X_ENABLE_REG, > 272 ~LM3601X_MODE_STROBE, LED_OFF); 273 goto out; 274 } 275 276 if (brightness == LED_ON) 277 brightness_val = LED_ON; 278 else 279 brightness_val = (brightness/2); 280 281 ret = regmap_write(led->regmap, LM3601X_LED_FLASH_REG, brightness_val); 282 283 out: 284 mutex_unlock(>lock); 285 return ret; 286 } 287 --- 0-DAY kernel test infrastructureOpen Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation .config.gz Description: application/gzip
[PATCH 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 Signed-off-by: Dan Murphy--- drivers/leds/Kconfig| 9 + drivers/leds/Makefile | 1 + drivers/leds/leds-lm3601x.c | 593 3 files changed, 603 insertions(+) create mode 100644 drivers/leds/leds-lm3601x.c diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig index 2c896c0e69e1..50ae536f343f 100644 --- a/drivers/leds/Kconfig +++ b/drivers/leds/Kconfig @@ -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 diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile index 91eca81cae82..b79807fe1b67 100644 --- a/drivers/leds/Makefile +++ b/drivers/leds/Makefile @@ -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 diff --git a/drivers/leds/leds-lm3601x.c b/drivers/leds/leds-lm3601x.c new file mode 100644 index ..c386779e5dfa --- /dev/null +++ b/drivers/leds/leds-lm3601x.c @@ -0,0 +1,593 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Flash and torch driver for Texas Instruments LM3601X LED + * Flash driver chip family + * Copyright (C) 2018 Texas Instruments + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#define LM3601X_LED_TORCH 0x0 +#define LM3601X_LED_STROBE 0x1 +#define LM3601X_LED_IR 0x2 + +/* Registers */ +#define LM3601X_ENABLE_REG 0x01 +#define LM3601X_CFG_REG0x02 +#define LM3601X_LED_FLASH_REG 0x03 +#define LM3601X_LED_TORCH_REG 0x04 +#define LM3601X_FLAGS_REG 0x05 +#define LM3601X_DEV_ID_REG 0x06 + +#define LM3601X_SW_RESET BIT(7) + +/* Enable Mode bits */ +#define LM3601X_MODE_STANDBY 0x00 +#define LM3601X_MODE_IR_DRVBIT(0) +#define LM3601X_MODE_TORCH BIT(1) +#define LM3601X_MODE_STROBE(BIT(0) | BIT(1)) +#define LM3601X_STRB_ENBIT(2) +#define LM3601X_STRB_LVL_TRIG ~BIT(3) +#define LM3601X_STRB_EDGE_TRIG BIT(3) +#define LM3601X_IVFM_ENBIT(4) + +#define LM36010_BOOST_LIMIT_19 ~BIT(5) +#define LM36010_BOOST_LIMIT_28 BIT(5) +#define LM36010_BOOST_FREQ_2MHZ~BIT(6) +#define LM36010_BOOST_FREQ_4MHZBIT(6) +#define LM36010_BOOST_MODE_NORM~BIT(7) +#define LM36010_BOOST_MODE_PASSBIT(7) + +/* Flag Mask */ +#define LM3601X_FLASH_TIME_OUT BIT(0) +#define LM3601X_UVLO_FAULT BIT(1) +#define LM3601X_THERM_SHUTDOWN BIT(2) +#define LM3601X_THERM_CURR BIT(3) +#define LM36010_CURR_LIMIT BIT(4) +#define LM3601X_SHORT_FAULTBIT(5) +#define LM3601X_IVFM_TRIP BIT(6) +#define LM36010_OVP_FAULT BIT(7) + +#define LM3601X_MIN_TORCH_I_UA 2400 +#define LM3601X_MIN_STROBE_I_MA11 + +enum lm3601x_type { + CHIP_LM36010 = 0, + CHIP_LM36011, +}; + +struct lm3601x_max_timeouts { + int timeout; + int reg_val; +}; + +/** + * struct lm3601x_led - + * @lock - Lock for reading/writing the device + * @regmap - Devices register map + * @client - Pointer to the I2C client + * @cdev_strobe - led class device pointer for the strobe + * @cdev_torch - led class device pointer for the torch + * @cdev_ir - led class device pointer for infrared + * @fled_cdev - flash led class device pointer + * @strobe_node - DT device node for the strobe + * @torch - LED label for the torch + * @strobe - LED label for the strobe + * @ir - LED label for the infrared + * @last_flag - last known flags register value + * @strobe_timeout - the timeout for the strobe + * @torch_current_max - maximum current for the torch + * @strobe_current_max - maximum current for the strobe + * @max_strobe_timeout - maximum timeout for the strobe + */ +struct lm3601x_led { + struct mutex lock; + struct regmap *regmap; + struct i2c_client *client; + + struct led_classdev cdev_strobe; + struct led_classdev cdev_torch; + struct
[PATCH 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 Signed-off-by: Dan Murphy --- drivers/leds/Kconfig| 9 + drivers/leds/Makefile | 1 + drivers/leds/leds-lm3601x.c | 593 3 files changed, 603 insertions(+) create mode 100644 drivers/leds/leds-lm3601x.c diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig index 2c896c0e69e1..50ae536f343f 100644 --- a/drivers/leds/Kconfig +++ b/drivers/leds/Kconfig @@ -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 diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile index 91eca81cae82..b79807fe1b67 100644 --- a/drivers/leds/Makefile +++ b/drivers/leds/Makefile @@ -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 diff --git a/drivers/leds/leds-lm3601x.c b/drivers/leds/leds-lm3601x.c new file mode 100644 index ..c386779e5dfa --- /dev/null +++ b/drivers/leds/leds-lm3601x.c @@ -0,0 +1,593 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Flash and torch driver for Texas Instruments LM3601X LED + * Flash driver chip family + * Copyright (C) 2018 Texas Instruments + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#define LM3601X_LED_TORCH 0x0 +#define LM3601X_LED_STROBE 0x1 +#define LM3601X_LED_IR 0x2 + +/* Registers */ +#define LM3601X_ENABLE_REG 0x01 +#define LM3601X_CFG_REG0x02 +#define LM3601X_LED_FLASH_REG 0x03 +#define LM3601X_LED_TORCH_REG 0x04 +#define LM3601X_FLAGS_REG 0x05 +#define LM3601X_DEV_ID_REG 0x06 + +#define LM3601X_SW_RESET BIT(7) + +/* Enable Mode bits */ +#define LM3601X_MODE_STANDBY 0x00 +#define LM3601X_MODE_IR_DRVBIT(0) +#define LM3601X_MODE_TORCH BIT(1) +#define LM3601X_MODE_STROBE(BIT(0) | BIT(1)) +#define LM3601X_STRB_ENBIT(2) +#define LM3601X_STRB_LVL_TRIG ~BIT(3) +#define LM3601X_STRB_EDGE_TRIG BIT(3) +#define LM3601X_IVFM_ENBIT(4) + +#define LM36010_BOOST_LIMIT_19 ~BIT(5) +#define LM36010_BOOST_LIMIT_28 BIT(5) +#define LM36010_BOOST_FREQ_2MHZ~BIT(6) +#define LM36010_BOOST_FREQ_4MHZBIT(6) +#define LM36010_BOOST_MODE_NORM~BIT(7) +#define LM36010_BOOST_MODE_PASSBIT(7) + +/* Flag Mask */ +#define LM3601X_FLASH_TIME_OUT BIT(0) +#define LM3601X_UVLO_FAULT BIT(1) +#define LM3601X_THERM_SHUTDOWN BIT(2) +#define LM3601X_THERM_CURR BIT(3) +#define LM36010_CURR_LIMIT BIT(4) +#define LM3601X_SHORT_FAULTBIT(5) +#define LM3601X_IVFM_TRIP BIT(6) +#define LM36010_OVP_FAULT BIT(7) + +#define LM3601X_MIN_TORCH_I_UA 2400 +#define LM3601X_MIN_STROBE_I_MA11 + +enum lm3601x_type { + CHIP_LM36010 = 0, + CHIP_LM36011, +}; + +struct lm3601x_max_timeouts { + int timeout; + int reg_val; +}; + +/** + * struct lm3601x_led - + * @lock - Lock for reading/writing the device + * @regmap - Devices register map + * @client - Pointer to the I2C client + * @cdev_strobe - led class device pointer for the strobe + * @cdev_torch - led class device pointer for the torch + * @cdev_ir - led class device pointer for infrared + * @fled_cdev - flash led class device pointer + * @strobe_node - DT device node for the strobe + * @torch - LED label for the torch + * @strobe - LED label for the strobe + * @ir - LED label for the infrared + * @last_flag - last known flags register value + * @strobe_timeout - the timeout for the strobe + * @torch_current_max - maximum current for the torch + * @strobe_current_max - maximum current for the strobe + * @max_strobe_timeout - maximum timeout for the strobe + */ +struct lm3601x_led { + struct mutex lock; + struct regmap *regmap; + struct i2c_client *client; + + struct led_classdev cdev_strobe; + struct led_classdev cdev_torch; + struct led_classdev