TI LMU and Dedicated LED drivers
Subsystems (3)
cover TI LMU and Dedicated LED drivers
All
This is an attempt to create a common TI LMU code base that can be leveraged by dedicate LED drivers.
This code is by no means complete as I am looking for comments on the implementation and demonstrating the advantage of adding unique features within a dedicated LED driver while using common code to perform common features.
Assuming that the implementation can be used the code will be debugged and the DT bindings and TI-lmu code will be scrubbed.
Dan
Dan Murphy (8):
dt-bindings: ti-lmu: Remove LM3697
mfd: ti-lmu: Remove support for LM3697
dt-bindings: leds: Add bindings for lm3697 driver
leds: lm3697: Introduce the lm3697 driver
dt-bindings: leds: Add support for the LM3633
leds: lm3633: Introduce the lm3633 driver
dt-bindings: leds: Add the LM3632 LED dt binding
leds: lm3632: Introduce the TI LM3632 driver
Pavel Machek (1):
leds: add TI LMU backlight driver
.../devicetree/bindings/leds/leds-lm3632.txt | 53 ++ .../devicetree/bindings/leds/leds-lm3633.txt | 69 +++ .../devicetree/bindings/leds/leds-lm3697.txt | 98 ++++ .../devicetree/bindings/mfd/ti-lmu.txt | 26 +- drivers/leds/Kconfig | 29 + drivers/leds/Makefile | 4 + drivers/leds/leds-lm3632.c | 547 ++++++++++++++++++ drivers/leds/leds-lm3633.c | 430 ++++++++++++++ drivers/leds/leds-lm3697.c | 389 +++++++++++++ drivers/leds/ti-lmu-led-common.c | 175 ++++++ drivers/leds/ti-lmu-led-common.h | 43 ++ drivers/mfd/Kconfig | 2 +- drivers/mfd/ti-lmu.c | 17 - include/linux/mfd/ti-lmu-register.h | 44 -- include/linux/mfd/ti-lmu.h | 1 - 15 files changed, 1839 insertions(+), 88 deletions(-) create mode 100644 Documentation/devicetree/bindings/leds/leds-lm3632.txt create mode 100644 Documentation/devicetree/bindings/leds/leds-lm3633.txt create mode 100644 Documentation/devicetree/bindings/leds/leds-lm3697.txt create mode 100644 drivers/leds/leds-lm3632.c create mode 100644 drivers/leds/leds-lm3633.c create mode 100644 drivers/leds/leds-lm3697.c create mode 100644 drivers/leds/ti-lmu-led-common.c create mode 100644 drivers/leds/ti-lmu-led-common.h
Signature · 1 line
2.19.0
RFC PATCH 1/9 leds: add TI LMU backlight driver
From: Pavel Machek <[email protected]>
This adds backlight support for the following TI LMU
chips: LM3532, LM3631, LM3632, LM3633, LM3695 and LM3697.
It controls LEDs on Droid 4
smartphone, including keyboard and screen backlights.
[add LED subsystem support for keyboard backlight and rework DT binding according to Rob Herrings feedback]
--- drivers/leds/Kconfig | 8 ++ drivers/leds/Makefile | 1 + drivers/leds/ti-lmu-led-common.c | 175 +++++++++++++++++++++++++++++++ drivers/leds/ti-lmu-led-common.h | 43 ++++++++ 4 files changed, 227 insertions(+) create mode 100644 drivers/leds/ti-lmu-led-common.c create mode 100644 drivers/leds/ti-lmu-led-common.h
drivers/leds/Kconfig +8 -0
@@ -756,6 +756,14 @@ config LEDS_NIC78BX To compile this driver as a module, choose M here: the module will be called leds-nic78bx. +config LEDS_TI_LMU_COMMON + tristate "LED driver for TI LMU" + depends on REGMAP + help + Say Y to enable the LED driver for TI LMU devices. + This supports common features between the TI LM3532, LM3631, LM3632, + LM3633, LM3695 and LM3697. + comment "LED Triggers" source "drivers/leds/trigger/Kconfig"
drivers/leds/Makefile +1 -0
@@ -78,6 +78,7 @@ obj-$(CONFIG_LEDS_MT6323) += leds-mt6323.o obj-$(CONFIG_LEDS_LM3692X) += leds-lm3692x.o obj-$(CONFIG_LEDS_SC27XX_BLTC) += leds-sc27xx-bltc.o obj-$(CONFIG_LEDS_LM3601X) += leds-lm3601x.o +obj-$(CONFIG_LEDS_TI_LMU_COMMON) += ti-lmu-led-common.o # LED SPI Drivers obj-$(CONFIG_LEDS_CR0014114) += leds-cr0014114.o
drivers/leds/ti-lmu-led-common.c new file +175 -0
175 lines not on this page · raw message
drivers/leds/ti-lmu-led-common.h new file +43 -0
43 lines not on this page · raw message
Signature · 1 line
2.19.0
RFC PATCH 2/9 dt-bindings: ti-lmu: Remove LM3697
In reply to Dan MurphyRemove support for the LM3697 LED device
from the ti-lmu. The LM3697 will be supported
via a stand alone LED driver.
--- .../devicetree/bindings/mfd/ti-lmu.txt | 26 +------------------ 1 file changed, 1 insertion(+), 25 deletions(-)
Documentation/devicetree/bindings/mfd/ti-lmu.txt +1 -25
@@ -9,7 +9,6 @@ TI LMU driver supports lighting devices below. LM3632 Backlight and regulator LM3633 Backlight, LED and fault monitor LM3695 Backlight - LM3697 Backlight and fault monitor Required properties: - compatible: Should be one of:
@@ -18,11 +17,10 @@ Required properties: "ti,lm3632" "ti,lm3633" "ti,lm3695" - "ti,lm3697" - reg: I2C slave address. 0x11 for LM3632 0x29 for LM3631 - 0x36 for LM3633, LM3697 + 0x36 for LM3633 0x38 for LM3532 0x63 for LM3695
@@ -38,7 +36,6 @@ Optional nodes: Required properties: - compatible: Should be one of: "ti,lm3633-fault-monitor" - "ti,lm3697-fault-monitor" - leds: LED properties for LM3633. Please refer to [2]. - regulators: Regulator properties for LM3631 and LM3632. Please refer to [3].
@@ -220,24 +217,3 @@ lm3695@63 { }; }; }; - -lm3697@36 { - compatible = "ti,lm3697"; - reg = <0x36>; - - enable-gpios = <&pioC 2 GPIO_ACTIVE_HIGH>; - - backlight { - compatible = "ti,lm3697-backlight"; - - lcd { - led-sources = <0 1 2>; - ramp-up-msec = <200>; - ramp-down-msec = <200>; - }; - }; - - fault-monitor { - compatible = "ti,lm3697-fault-monitor"; - }; -};
Signature · 1 line
2.19.0
RFC PATCH 3/9 mfd: ti-lmu: Remove support for LM3697
In reply to Dan MurphyRemove support for the LM3697 from the ti-lmu
driver in favor of a dedicated LED driver.
--- drivers/mfd/Kconfig | 2 +- drivers/mfd/ti-lmu.c | 17 ----------- include/linux/mfd/ti-lmu-register.h | 44 ----------------------------- include/linux/mfd/ti-lmu.h | 1 - 4 files changed, 1 insertion(+), 63 deletions(-)
drivers/mfd/Kconfig +1 -1
@@ -1293,7 +1293,7 @@ config MFD_TI_LMU help Say yes here to enable support for TI LMU chips. - TI LMU MFD supports LM3532, LM3631, LM3632, LM3633, LM3695 and LM3697. + TI LMU MFD supports LM3532, LM3631, LM3632, LM3633, and LM3695. It consists of backlight, LED and regulator driver. It provides consistent device controls for lighting functions.
drivers/mfd/ti-lmu.c +0 -17
@@ -128,20 +128,6 @@ static struct mfd_cell lm3695_devices[] = { }, }; -static struct mfd_cell lm3697_devices[] = { - { - .name ="ti-lmu-backlight" , - .id =LM3697 , - .of_compatible ="ti,lm3697-backlight" , - }, -/* Monitoring driver for open/short circuit detection */ - { - .name ="ti-lmu-fault-monitor" , - .id =LM3697 , - .of_compatible ="ti,lm3697-fault-monitor" , - }, -}; -#define TI_LMU_DATA (chip, max_reg) \ static const struct ti_lmu_data chip##_data = \ { \
@@ -155,7 +141,6 @@ TI_LMU_DATA(lm3631, LM3631_MAX_REG);TI_LMU_DATA (lm3632,LM3632_MAX_REG );TI_LMU_DATA (lm3633,LM3633_MAX_REG );TI_LMU_DATA (lm3695,LM3695_MAX_REG ); -TI_LMU_DATA (lm3697,LM3697_MAX_REG );static const struct of_device_id ti_lmu_of_match[] = { { .compatible ="ti,lm3532" , .data = &lm3532_data },
@@ -163,7 +148,6 @@ static const struct of_device_id ti_lmu_of_match[] = { { .compatible = "ti,lm3632", .data = &lm3632_data }, { .compatible = "ti,lm3633", .data = &lm3633_data }, { .compatible = "ti,lm3695", .data = &lm3695_data }, - { .compatible = "ti,lm3697", .data = &lm3697_data }, { } };MODULE_DEVICE_TABLE (of, ti_lmu_of_match);
@@ -237,7 +221,6 @@ static const struct i2c_device_id ti_lmu_ids[] = { { "lm3632", LM3632 }, { "lm3633", LM3633 }, { "lm3695", LM3695 }, - { "lm3697", LM3697 }, { } };MODULE_DEVICE_TABLE (i2c, ti_lmu_ids);
include/linux/mfd/ti-lmu-register.h +0 -44
48 lines not on this page · raw message
include/linux/mfd/ti-lmu.h +0 -1
@@ -26,7 +26,6 @@ enum ti_lmu_id {LM3632 ,LM3633 ,LM3695 , -LM3697 , LMU_MAX_ID, };
Signature · 1 line
2.19.0
RFC PATCH 4/9 dt-bindings: leds: Add bindings for lm3697 driver
In reply to Dan MurphyAdd the device tree bindings for the lm3697
LED driver for backlighting and display.
--- .../devicetree/bindings/leds/leds-lm3697.txt | 98 +++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 Documentation/devicetree/bindings/leds/leds-lm3697.txt
Documentation/devicetree/bindings/leds/leds-lm3697.txt new file +98 -0
@@ -0,0 +1,98 @@ +* Texas Instruments - LM3697 Highly Efficient White LED Driver + +The LM3697 11-bit LED driver provides high- +performance backlight dimming for 1, 2, or 3 series +LED strings while delivering up to 90% efficiency. + +This device is suitable for display and keypad Lighting + +Required properties: + - compatible: + "ti,lm3697" + - reg : I2C slave address + - #address-cells : 1 + - #size-cells : 0 + +Optional properties: + - enable-gpios : GPIO pin to enable/disable the device + - vled-supply : LED supply + +Required child properties: + - reg : 0 - LED is Controlled by bank A + 1 - LED is Controlled by bank B + - led-sources : Indicates which HVLED string is associated to which + control bank. Each element in the array is associated + with a specific HVLED string. Element 0 is HVLED1, + element 1 is HVLED2 and element 2 HVLED3. + Additional information is contained + in Documentation/devicetree/bindings/leds/common.txt + 0 - HVLED is not active in this control bank + 1 - HVLED string is controlled by this control bank + +Optional child properties: + - runtime-ramp-up-msec: Current ramping from one brightness level to + the a higher brightness level. + Range from 2048 us - 117.44 s + - runtime-ramp-down-msec: Current ramping from one brightness level to + the a lower brightness level. + Range from 2048 us - 117.44 s + - label : see Documentation/devicetree/bindings/leds/common.txt + - linux,default-trigger : + see Documentation/devicetree/bindings/leds/common.txt + +Example: + +HVLED string 1 and 3 are controlled by control bank A and HVLED 2 string is +controlled by control bank B. + +led-controller@36 { + compatible = "ti,lm3697"; + reg = <0x36>; + #address-cells = <1>; + #size-cells = <0>; + + enable-gpios = <&gpio1 28 GPIO_ACTIVE_HIGH>; + vled-supply = <&vbatt>; + + led@0 { + reg = <0>; + led-sources = <1 0 1>; + runtime-ramp-up-msec = <5000>; + runtime-ramp-down-msec = <1000>; + label = "white:first_backlight_cluster"; + linux,default-trigger = "backlight"; + }; + + led@1 { + reg = <1>; + led-sources = <0 1 0>; + runtime-ramp-up-msec = <500>; + runtime-ramp-down-msec = <1000>; + label = "white:second_backlight_cluster"; + linux,default-trigger = "backlight"; + }; +} + +All HVLED strings controlled by control bank A + +led-controller@36 { + compatible = "ti,lm3697"; + reg = <0x36>; + #address-cells = <1>; + #size-cells = <0>; + + enable-gpios = <&gpio1 28 GPIO_ACTIVE_HIGH>; + vled-supply = <&vbatt>; + + led@0 { + reg = <0>; + led-sources = <1 1 1>; + runtime-ramp-up-msec = <500>; + runtime-ramp-down-msec = <1000>; + label = "white:backlight_cluster"; + linux,default-trigger = "backlight"; + }; +} + +For more product information please see the link below: +http://www.ti.com/lit/ds/symlink/lm3697.pdf
Signature · 1 line
2.19.0
RFC PATCH 5/9 leds: lm3697: Introduce the lm3697 driver
In reply to Dan MurphyIntroduce the lm3697 LED driver for
backlighting and display.
Datasheet location:
http://www.ti.com/lit/ds/symlink/lm3697.pdf
--- drivers/leds/Kconfig | 8 +- drivers/leds/Makefile | 1 + drivers/leds/leds-lm3697.c | 389 +++++++++++++++++++++++++++++++++++++ 3 files changed, 397 insertions(+), 1 deletion(-) create mode 100644 drivers/leds/leds-lm3697.c
drivers/leds/Kconfig +7 -1
@@ -756,9 +756,15 @@ config LEDS_NIC78BX To compile this driver as a module, choose M here: the module will be called leds-nic78bx. +config LEDS_LM3697 + tristate "LED driver for LM3697" + depends on LEDS_TI_LMU_COMMON + help + Say Y to enable the LED driver for TI LMU devices. + This supports the LED device LM3697. + config LEDS_TI_LMU_COMMON tristate "LED driver for TI LMU" - depends on REGMAP help Say Y to enable the LED driver for TI LMU devices. This supports common features between the TI LM3532, LM3631, LM3632,
drivers/leds/Makefile +1 -0
@@ -78,6 +78,7 @@ obj-$(CONFIG_LEDS_MT6323) += leds-mt6323.o obj-$(CONFIG_LEDS_LM3692X) += leds-lm3692x.o obj-$(CONFIG_LEDS_SC27XX_BLTC) += leds-sc27xx-bltc.o obj-$(CONFIG_LEDS_LM3601X) += leds-lm3601x.o +obj-$(CONFIG_LEDS_LM3697) += leds-lm3697.o obj-$(CONFIG_LEDS_TI_LMU_COMMON) += ti-lmu-led-common.o # LED SPI Drivers
drivers/leds/leds-lm3697.c new file +389 -0
389 lines not on this page · raw message
Signature · 1 line
2.19.0
RFC PATCH 6/9 dt-bindings: leds: Add support for the LM3633
In reply to Dan MurphyAdd support for the TI LM3633 LED driver.
This device has 9 control banks 3 high voltage
LED channels and 6 low voltage LED channels.
Data sheet:
http://www.ti.com/lit/ds/symlink/lm3633.pdf
--- .../devicetree/bindings/leds/leds-lm3633.txt | 69 +++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 Documentation/devicetree/bindings/leds/leds-lm3633.txt
Documentation/devicetree/bindings/leds/leds-lm3633.txt new file +69 -0
@@ -0,0 +1,69 @@ +* Texas Instruments - LM3633 Lighting Power Solution for Smartphone Handsets + +The LM3633 is a complete power source for +backlight, keypad, and indicator LEDs in smartphone +handsets. + +This device is suitable for display and keypad Lighting + +Required properties: + - compatible: + "ti,lm3633" + - reg : I2C slave address + - #address-cells : 1 + - #size-cells : 0 + +Optional properties: + - enable-gpios : GPIO pin to enable/disable the device + - vled-supply : LED supply + +Required child properties: + - reg : 0 - HVLED is Controlled by bank A + 1 - HVLED is Controlled by bank B + 2,3,4 - LVLED1, 2 and 3 are Controlled by bank C, D and E + 5,6,7 - LVLED4, 5 and 6 are Controlled by bank F, G and H + - led-sources : Indicates which LED string is associated to which + control bank. + 0 - LED is not active in this control bank + 1 - LED string is controlled by this control bank + +Optional child properties: + - label : see Documentation/devicetree/bindings/leds/common.txt + - linux,default-trigger : + see Documentation/devicetree/bindings/leds/common.txt + +Example: + +led-controller@36 { + compatible = "ti,lm3633"; + reg = <0x36>; + #address-cells = <1>; + #size-cells = <0>; + + enable-gpios = <&gpio1 28 GPIO_ACTIVE_HIGH>; + vled-supply = <&vbatt>; + + led@0 { + reg = <0>; + led-sources = <1 0 1>; + label = "white:first_backlight_cluster"; + linux,default-trigger = "backlight"; + }; + + led@1 { + reg = <1>; + led-sources = <0 1 0>; + label = "white:second_backlight_cluster"; + linux,default-trigger = "backlight"; + }; + + led@2 { + reg = <2>; + led-sources = <0 1 0>; + label = "white:indicator1"; + }; + +} + +For more product information please see the link below: +http://www.ti.com/lit/ds/symlink/lm3633.pdf
Signature · 1 line
2.19.0
RFC PATCH 7/9 leds: lm3633: Introduce the lm3633 driver
In reply to Dan MurphyIntroduce the LED LM3633 driver. This LED
driver has 9 total LED outputs with runtime
internal ramp configurations.
Data sheet:
http://www.ti.com/lit/ds/symlink/lm3633.pdf
--- drivers/leds/Kconfig | 8 + drivers/leds/Makefile | 1 + drivers/leds/leds-lm3633.c | 430 +++++++++++++++++++++++++++++++++++++ 3 files changed, 439 insertions(+) create mode 100644 drivers/leds/leds-lm3633.c
drivers/leds/Kconfig +8 -0
@@ -763,8 +763,16 @@ config LEDS_LM3697 Say Y to enable the LED driver for TI LMU devices. This supports the LED device LM3697. +config LEDS_LM3633 + tristate "LED driver for LM3633" + depends on LEDS_TI_LMU_COMMON + help + Say Y to enable the LED driver for TI LMU devices. + This supports the LED device LM3633. + config LEDS_TI_LMU_COMMON tristate "LED driver for TI LMU" + depends on REGMAP help Say Y to enable the LED driver for TI LMU devices. This supports common features between the TI LM3532, LM3631, LM3632,
drivers/leds/Makefile +1 -0
@@ -79,6 +79,7 @@ obj-$(CONFIG_LEDS_LM3692X) += leds-lm3692x.o obj-$(CONFIG_LEDS_SC27XX_BLTC) += leds-sc27xx-bltc.o obj-$(CONFIG_LEDS_LM3601X) += leds-lm3601x.o obj-$(CONFIG_LEDS_LM3697) += leds-lm3697.o +obj-$(CONFIG_LEDS_LM3633) += leds-lm3633.o obj-$(CONFIG_LEDS_TI_LMU_COMMON) += ti-lmu-led-common.o # LED SPI Drivers
drivers/leds/leds-lm3633.c new file +430 -0
430 lines not on this page · raw message
Signature · 1 line
2.19.0
RFC PATCH 8/9 dt-bindings: leds: Add the LM3632 LED dt binding
In reply to Dan MurphyAdd the TI LM3632 LED binding.
--- .../devicetree/bindings/leds/leds-lm3632.txt | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 Documentation/devicetree/bindings/leds/leds-lm3632.txt
Documentation/devicetree/bindings/leds/leds-lm3632.txt new file +53 -0
@@ -0,0 +1,53 @@ +* Texas Instruments - lm3632 Single-Chip Backlight and 1.5-A Flash LED Driver + +The LM3632A integrates LED drivers for both +the backlight of the LCD panel and the camera flash +along with the bias power for the LCD panel into one +device. + +Required properties: + - compatible : Can be one of the following + "ti,lm3632" + - reg : I2C slave address + - #address-cells : 1 + - #size-cells : 0 + +Required child properties: + - reg : 0 - Indicates a backlight mode + 1 - Indicates a Torch/Strobe (white LED) mode + +Required properties for flash LED child nodes: + See Documentation/devicetree/bindings/leds/common.txt + - flash-max-microamp : Range from 100mA - 1.5A + - flash-max-timeout-us : Range from 32ms - 1024ms + - led-max-microamp : Range from 25mA - 375mA + +Optional child properties: + - label : see Documentation/devicetree/bindings/leds/common.txt + - linux,default-trigger : + see Documentation/devicetree/bindings/leds/common.txt + +Example: +led-controller@11 { + compatible = "ti,lm3632"; + #address-cells = <1>; + #size-cells = <0>; + reg = <0x11>; + + led@0 { + reg = <0>; + label = "white:backlight"; + linux,default-trigger = "backlight"; + }; + + led@1 { + reg = <1>; + label = "white:torch"; + led-max-microamp = <375000>; + flash-max-microamp = <1500000>; + flash-max-timeout-us = <1000000>; + }; +} + +For more product information please see the links below: +http://www.ti.com/product/LM3632
Signature · 1 line
2.19.0
RFC PATCH 9/9 leds: lm3632: Introduce the TI LM3632 driver
In reply to Dan MurphyAdd the dedicated TI LM3632 LED driver. This LED device is capable of driving a backlight display.
In addition to the backlight the device has control of a strobe and torch output.
Data sheet:
http://www.ti.com/lit/ds/symlink/lm3632a.pdf
--- drivers/leds/Kconfig | 9 +- drivers/leds/Makefile | 1 + drivers/leds/leds-lm3632.c | 547 +++++++++++++++++++++++++++++++++++++ 3 files changed, 556 insertions(+), 1 deletion(-) create mode 100644 drivers/leds/leds-lm3632.c
drivers/leds/Kconfig +8 -1
@@ -764,8 +764,15 @@ config LEDS_LM3697 This supports the LED device LM3697. config LEDS_LM3633 - tristate "LED driver for LM3633" + tristate "LED driver for LM3632" depends on LEDS_TI_LMU_COMMON + help + Say Y to enable the LED driver for TI LMU devices. + This supports the LED device LM3632. + +config LEDS_LM3632 + tristate "LED driver for LM3632" + depends on LEDS_TI_LMU_COMMON help Say Y to enable the LED driver for TI LMU devices. This supports the LED device LM3633.
drivers/leds/Makefile +1 -0
@@ -79,6 +79,7 @@ obj-$(CONFIG_LEDS_LM3692X) += leds-lm3692x.o obj-$(CONFIG_LEDS_SC27XX_BLTC) += leds-sc27xx-bltc.o obj-$(CONFIG_LEDS_LM3601X) += leds-lm3601x.o obj-$(CONFIG_LEDS_LM3697) += leds-lm3697.o +obj-$(CONFIG_LEDS_LM3632) += leds-lm3632.o obj-$(CONFIG_LEDS_LM3633) += leds-lm3633.o obj-$(CONFIG_LEDS_TI_LMU_COMMON) += ti-lmu-led-common.o
drivers/leds/leds-lm3632.c new file +547 -0
547 lines not on this page · raw message
Signature · 1 line
2.19.0
Re: [RFC PATCH 1/9] leds: add TI LMU backlight driver
In reply to Dan Murphydrivers/leds/ti-lmu-led-common.c line 37
Quoted 12 lines · Dan Murphy
drivers/leds/ti-lmu-led-common.c new file +10
-0+static int ti_lmu_common_enable (struct ti_lmu_bank *lmu_bank,bool enable) +{ +struct regmap *regmap = lmu_bank->regmap; +unsigned long enable_time = lmu_bank->enable_usec; +u8 reg = lmu_bank->enable_reg; +u8 mask =BIT (lmu_bank->bank_id); +u8 val = (enable == true) ? mask :0 ; +int ret; + +return 0 ;
Hmm this early return probably needs to be left out on real hardawre?
drivers/leds/ti-lmu-led-common.c line 49
Quoted 12 lines
drivers/leds/ti-lmu-led-common.c new file +12
-0+if (!reg) +return -EINVAL ; + + ret =regmap_update_bits (regmap, reg, mask, val); +if (ret) +return ret; + +if (enable_time >0 ) +usleep_range (enable_time, enable_time +100 ); + +return 0 ; +}
Regards,
Tony
Re: [RFC PATCH 1/9] leds: add TI LMU backlight driver
Tony
Quoted 16 lines · Tony Lindgren
drivers/leds/ti-lmu-led-common.c line 37
Quoted 12 lines · Dan Murphy
drivers/leds/ti-lmu-led-common.c new file +10
-0+static int ti_lmu_common_enable (struct ti_lmu_bank *lmu_bank,bool enable) +{ +struct regmap *regmap = lmu_bank->regmap; +unsigned long enable_time = lmu_bank->enable_usec; +u8 reg = lmu_bank->enable_reg; +u8 mask =BIT (lmu_bank->bank_id); +u8 val = (enable == true) ? mask :0 ; +int ret; + +return 0 ;Hmm this early return probably needs to be left out on real hardawre?
Yes it does. I have not debugged or completed this function yet.
Quoted 17 lines
drivers/leds/ti-lmu-led-common.c line 49
Quoted 12 lines
drivers/leds/ti-lmu-led-common.c new file +12
-0+if (!reg) +return -EINVAL ; + + ret =regmap_update_bits (regmap, reg, mask, val); +if (ret) +return ret; + +if (enable_time >0 ) +usleep_range (enable_time, enable_time +100 ); + +return 0 ; +}Regards,
Tony
Signature · 2 lines
------------------ Dan Murphy
Re: [RFC PATCH 7/9] leds: lm3633: Introduce the lm3633 driver
In reply to Dan MurphyHi!
Quoted 8 lines
Introduce the LED LM3633 driver. This LED
driver has 9 total LED outputs with runtime
internal ramp configurations.Data sheet:
http://www.ti.com/lit/ds/symlink/lm3633.pdfSigned-off-by Dan Murphy <[email protected]>
I did some editing... and this code looks very similar to 3697 code.
Quoted 14 lines
drivers/leds/leds-lm3633.c new file +8
-0@@ -0,0 +1,430 @@ +// SPDX-License-Identifier: GPL-2.0 +// TI LM3633 LED chip family driver +// Copyright (C) 2018 Texas Instruments Incorporated - http://www.ti.com/ + +#include <linux/gpio/consumer.h> +#include <linux/i2c.h> +#include <linux/init.h> +#include <linux/leds.h>
drivers/leds/leds-lm3633.c line 18
Quoted 10 lines
drivers/leds/leds-lm3633.c new file +10
-0+#include <linux/module.h> +#include <linux/mutex.h> +#include <linux/of.h> +#include <linux/of_gpio.h> +#include <linux/regmap.h> +#include <linux/regulator/consumer.h> +#include <linux/slab.h> +#include <uapi/linux/uleds.h> + +#include "ti-lmu-led-common.h"
You might want to move includes to ti-lmu-led-common.h, so these are not repeated?
Quoted 9 lines
drivers/leds/leds-lm3633.c new file +9
-0+/** +* struct lm3633 - +* @enable_gpio - Hardware enable gpio +* @regulator - LED supply regulator pointer +* @client - Pointer to the I2C client +* @regmap - Devices register map +* @dev - Pointer to the devices device struct +* @lock - Lock for reading/writing the device +* @leds - Array of LED strings
drivers/leds/leds-lm3633.c line 123
Quoted 10 lines
drivers/leds/leds-lm3633.c new file +10
-0+*/ +struct lm3633 { +struct gpio_desc *enable_gpio; +struct regulator *regulator; +struct i2c_client *client; +struct regmap *regmap; +struct device *dev; +struct mutex lock; +struct lm3633_led leds[]; +};
Exactly same structure is used for 3697. Worth sharing?
drivers/leds/leds-lm3633.c line 150
Quoted 9 lines
drivers/leds/leds-lm3633.c new file +9
-0+static const struct regmap_config lm3633_regmap_config = { + .reg_bits =8 , + .val_bits =8 , + + .max_register =LM3633_CTRL_ENABLE , + .reg_defaults = lm3633_reg_defs, + .num_reg_defaults =ARRAY_SIZE (lm3633_reg_defs), + .cache_type =REGCACHE_FLAT , +};
Same regmap config. Maybe difficult to share.
Quoted 24 lines
drivers/leds/leds-lm3633.c new file +24
-0+static int lm3633_brightness_set (struct led_classdev *led_cdev, +enum led_brightness brt_val) +{ + struct lm3633_led *led = container_of(led_cdev, struct lm3633_led, + led_dev); +int ctrl_en_val; +int ret; + +mutex_lock (&led->priv->lock); + +if (led->control_bank ==LM3633_CONTROL_A ) { + led->lmu_data.msb_brightness_reg =LM3633_CTRL_A_BRT_MSB ; + led->lmu_data.lsb_brightness_reg =LM3633_CTRL_A_BRT_LSB ; + ctrl_en_val =LM3633_CTRL_A_EN ; + }else { + led->lmu_data.msb_brightness_reg =LM3633_CTRL_B_BRT_MSB ; + led->lmu_data.lsb_brightness_reg =LM3633_CTRL_B_BRT_LSB ; + ctrl_en_val =LM3633_CTRL_B_EN ; + } + +if (brt_val ==LED_OFF ) + ret =regmap_update_bits (led->priv->regmap,LM3633_CTRL_ENABLE , + ctrl_en_val, ~ctrl_en_val); +else
drivers/leds/leds-lm3633.c line 185
Quoted 10 lines
drivers/leds/leds-lm3633.c new file +10
-0+ ret =regmap_update_bits (led->priv->regmap,LM3633_CTRL_ENABLE , + ctrl_en_val, ctrl_en_val); + + ret =ti_lmu_common_set_brightness (&led->lmu_data, brt_val); +if (ret) +dev_err (&led->priv->client->dev,"Cannot write brightness\n" ); + +mutex_unlock (&led->priv->lock); +return ret; +}
Duplicate of 3697 function with different constants.
Quoted 11 lines
drivers/leds/leds-lm3633.c new file +11
-0+static int lm3633_set_control_bank (struct lm3633 *priv) +{ +u8 control_bank_config =0 ; +struct lm3633_led *led; +int ret, i; + + led = &priv->leds[0 ]; +if (led->control_bank ==LM3633_CONTROL_A ) + led = &priv->leds[1 ]; + +for (i =0 ; i <LM3633_MAX_HVLED_STRINGS ; i++)
drivers/leds/leds-lm3633.c line 207
Quoted 10 lines
drivers/leds/leds-lm3633.c new file +10
-0+if (led->hvled_strings[i] ==LM3633_HVLED_ASSIGNMENT ) + control_bank_config |=1 << i; + + ret =regmap_write (priv->regmap,LM3633_HVLED_OUTPUT_CONFIG , + control_bank_config); +if (ret) +dev_err (&priv->client->dev,"Cannot write OUTPUT config\n" ); + +return ret; +}
Duplicate of 3697 function.
Quoted 24 lines
drivers/leds/leds-lm3633.c new file +24
-0+static int lm3633_init (struct lm3633 *priv) +{ +struct lm3633_led *led; +int i, ret; + +if (priv->enable_gpio) { +gpiod_direction_output (priv->enable_gpio,1 ); + }else { + ret =regmap_write (priv->regmap,LM3633_RESET ,LM3633_SW_RESET ); +if (ret) { +dev_err (&priv->client->dev,"Cannot reset the device\n" ); + goto out; + } + } + + ret =regmap_write (priv->regmap,LM3633_CTRL_ENABLE ,0x0 ); +if (ret) { +dev_err (&priv->client->dev,"Cannot write ctrl enable\n" ); + goto out; + } + + ret =lm3633_set_control_bank (priv); +if (ret) +dev_err (&priv->client->dev,"Setting the CRTL bank failed\n" );
drivers/leds/leds-lm3633.c line 242
Quoted 10 lines
drivers/leds/leds-lm3633.c new file +10
-0+ +for (i =0 ; i <LM3633_MAX_CONTROL_BANKS ; i++) { + led = &priv->leds[i]; +ti_lmu_common_set_ramp (&led->lmu_data); +if (ret) +dev_err (&priv->client->dev,"Setting the ramp rate failed\n" ); + } +out: +return ret; +}
Duplicate of 3697 function.
Quoted 85 lines
drivers/leds/leds-lm3633.c new file +85
-0+static int lm3633_probe_dt (struct lm3633 *priv) +{ +struct fwnode_handle *child =NULL ; +struct lm3633_led *led; +const char *name; +int control_bank; +size_t i =0 ; +int ret; + + priv->enable_gpio =devm_gpiod_get_optional (&priv->client->dev, +"enable" ,GPIOD_OUT_LOW ); +if (IS_ERR (priv->enable_gpio)) { + ret =PTR_ERR (priv->enable_gpio); +dev_err (&priv->client->dev,"Failed to get enable gpio: %d\n" , + ret); +return ret; + } + + priv->regulator =devm_regulator_get (&priv->client->dev,"vled" ); +if (IS_ERR (priv->regulator)) + priv->regulator =NULL ; + +device_for_each_child_node (priv->dev, child) { + ret =fwnode_property_read_u32 (child,"reg" , &control_bank); +if (ret) { +dev_err (&priv->client->dev,"reg property missing\n" ); +fwnode_handle_put (child); + goto child_out; + } + +if (control_bank >LM3633_CONTROL_B ) { +dev_err (&priv->client->dev,"reg property is invalid\n" ); + ret = -EINVAL ; +fwnode_handle_put (child); + goto child_out; + } + + led = &priv->leds[i]; + + led->control_bank = control_bank; + led->lmu_data.bank_id = control_bank; + led->lmu_data.enable_reg =LM3633_CTRL_ENABLE ; + led->lmu_data.regmap = priv->regmap; +if (control_bank ==LM3633_CONTROL_A ) + led->lmu_data.runtime_ramp_reg =LM3633_CTRL_A_RAMP ; +else + led->lmu_data.runtime_ramp_reg =LM3633_CTRL_B_RAMP ; + +if (control_bank <=LM3633_CONTROL_B ) + ret =fwnode_property_read_u32_array (child,"led-sources" , + led->hvled_strings, +LM3633_MAX_HVLED_STRINGS ); +else + ret =fwnode_property_read_u32_array (child,"led-sources" , + led->lvled_strings, +LM3633_MAX_LVLED_STRINGS ); +if (ret) { +dev_err (&priv->client->dev,"led-sources property missing\n" ); +fwnode_handle_put (child); + goto child_out; + } + + ret =ti_lmu_common_get_ramp_params (&priv->client->dev, child, &led->lmu_data); +if (ret) +dev_warn (&priv->client->dev,"runtime-ramp properties missing\n" ); + +fwnode_property_read_string (child,"linux,default-trigger" , + &led->led_dev.default_trigger); + + ret =fwnode_property_read_string (child,"label" , &name); +if (ret) +snprintf (led->label,sizeof (led->label), +"%s::" , priv->client->name); +else +snprintf (led->label,sizeof (led->label), +"%s:%s" , priv->client->name, name); + + led->priv = priv; + led->led_dev.name = led->label; + led->led_dev.brightness_set_blocking = lm3633_brightness_set; + + ret =devm_led_classdev_register (priv->dev, &led->led_dev); +if (ret) { +dev_err (&priv->client->dev,"led register err: %d\n" , + ret);
drivers/leds/leds-lm3633.c line 338
Quoted 10 lines
drivers/leds/leds-lm3633.c new file +10
-0+fwnode_handle_put (child); + goto child_out; + } + + i++; + } + +child_out: +return ret; +}
Very similar, but not quite same.
Quoted 27 lines
drivers/leds/leds-lm3633.c new file +27
-0+static int lm3633_probe (struct i2c_client *client, +const struct i2c_device_id *id) +{ +struct lm3633 *led; +int count; +int ret; + + count =device_get_child_node_count (&client->dev); +if (!count) { +dev_err (&client->dev,"LEDs are not defined in device tree!" ); +return -ENODEV ; + } + + led =devm_kzalloc (&client->dev,struct_size (led, leds, count), +GFP_KERNEL ); +if (!led) +return -ENOMEM ; + +mutex_init (&led->lock); +i2c_set_clientdata (client, led); + + led->client = client; + led->dev = &client->dev; + led->regmap =devm_regmap_init_i2c (client, &lm3633_regmap_config); +if (IS_ERR (led->regmap)) { + ret =PTR_ERR (led->regmap); + dev_err(&client->dev, "Failed to allocate register map: %d\n",
drivers/leds/leds-lm3633.c line 376
Quoted 10 lines
drivers/leds/leds-lm3633.c new file +10
-0+ ret); +return ret; + } + + ret =lm3633_probe_dt (led); +if (ret) +return ret; + +return lm3633_init (led); +}
Duplicate.
Quoted 16 lines
drivers/leds/leds-lm3633.c new file +16
-0+static int lm3633_remove (struct i2c_client *client) +{ +struct lm3633 *led =i2c_get_clientdata (client); +int ret; + + ret =regmap_update_bits (led->regmap,LM3633_CTRL_ENABLE , +LM3633_CTRL_A_B_EN ,0 ); +if (ret) { +dev_err (&led->client->dev,"Failed to disable the device\n" ); +return ret; + } + +if (led->enable_gpio) +gpiod_direction_output (led->enable_gpio,0 ); + +if (led->regulator) {
drivers/leds/leds-lm3633.c line 403
Quoted 10 lines
drivers/leds/leds-lm3633.c new file +10
-0+ ret =regulator_disable (led->regulator); +if (ret) +dev_err (&led->client->dev, +"Failed to disable regulator\n" ); + } + +mutex_destroy (&led->lock); + +return 0 ; +}
Duplicate.
Can we get some more sharing? One way would be to have struct with all the constants (instead of #defines) use that...?
Thanks,
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Re: [RFC PATCH 7/9] leds: lm3633: Introduce the lm3633 driver
Pavel
Thanks for the review
Quoted 6 lines · Pavel Machek
Hi!
Quoted 4 lines
Introduce the LED LM3633 driver. This LED
driver has 9 total LED outputs with runtime
internal ramp configurations.
Quoted 7 lines
Quoted 4 lines
Data sheet:
http://www.ti.com/lit/ds/symlink/lm3633.pdfSigned-off-by Dan Murphy <[email protected]>I did some editing... and this code looks very similar to 3697 code.
Ok I will review each one. Keep in mind these drivers are by no means complete I anticipate this driver to look different then the 3697 code.
But I do expect a certain level of duplication of code as we see across all drivers.
Quoted 19 lines
Quoted 19 lines
drivers/leds/leds-lm3633.c new file +13
-0@@ -0,0 +1,430 @@ +// SPDX-License-Identifier: GPL-2.0 +// TI LM3633 LED chip family driver +// Copyright (C) 2018 Texas Instruments Incorporated - http://www.ti.com/ + +#include <linux/gpio/consumer.h> +#include <linux/i2c.h> +#include <linux/init.h> +#include <linux/leds.h> +#include <linux/module.h> +#include <linux/mutex.h> +#include <linux/of.h> +#include <linux/of_gpio.h> +#include <linux/regmap.h>
Quoted 9 lines
drivers/leds/leds-lm3633.c line 18
Quoted 5 lines
drivers/leds/leds-lm3633.c new file +5
-0+#include <linux/regulator/consumer.h> +#include <linux/slab.h> +#include <uapi/linux/uleds.h> + +#include "ti-lmu-led-common.h" You might want to move includes to
ti-lmu-led-common.h, so these are not repeated?
Sounds good
Quoted 13 lines
Quoted 13 lines
drivers/leds/leds-lm3633.c new file +13
-0+/** +* struct lm3633 - +* @enable_gpio - Hardware enable gpio +* @regulator - LED supply regulator pointer +* @client - Pointer to the I2C client +* @regmap - Devices register map +* @dev - Pointer to the devices device struct +* @lock - Lock for reading/writing the device +* @leds - Array of LED strings +*/ +struct lm3633 { +struct gpio_desc *enable_gpio; +struct regulator *regulator;
Quoted 8 lines
drivers/leds/leds-lm3633.c line 123
Quoted 6 lines
drivers/leds/leds-lm3633.c new file +6
-0+struct i2c_client *client; +struct regmap *regmap; +struct device *dev; +struct mutex lock; +struct lm3633_led leds[]; +};Exactly same structure is used for 3697. Worth sharing?
But it is not the same structure for the 3632. I anticipate this to change as I debug the code and add pwm support.
Quoted 12 lines
drivers/leds/leds-lm3633.c line 150
Quoted 10 lines
drivers/leds/leds-lm3633.c new file +9
-0+static const struct regmap_config lm3633_regmap_config = { + .reg_bits =8 , + .val_bits =8 , + + .max_register =LM3633_CTRL_ENABLE , + .reg_defaults = lm3633_reg_defs, + .num_reg_defaults =ARRAY_SIZE (lm3633_reg_defs), + .cache_type =REGCACHE_FLAT , +};Same regmap config. Maybe difficult to share.
Agreed.
Quoted 29 lines
Quoted 29 lines
drivers/leds/leds-lm3633.c new file +28
-0+static int lm3633_brightness_set (struct led_classdev *led_cdev, +enum led_brightness brt_val) +{ + struct lm3633_led *led = container_of(led_cdev, struct lm3633_led, + led_dev); +int ctrl_en_val; +int ret; + +mutex_lock (&led->priv->lock); + +if (led->control_bank ==LM3633_CONTROL_A ) { + led->lmu_data.msb_brightness_reg =LM3633_CTRL_A_BRT_MSB ; + led->lmu_data.lsb_brightness_reg =LM3633_CTRL_A_BRT_LSB ; + ctrl_en_val =LM3633_CTRL_A_EN ; + }else { + led->lmu_data.msb_brightness_reg =LM3633_CTRL_B_BRT_MSB ; + led->lmu_data.lsb_brightness_reg =LM3633_CTRL_B_BRT_LSB ; + ctrl_en_val =LM3633_CTRL_B_EN ; + } + +if (brt_val ==LED_OFF ) + ret =regmap_update_bits (led->priv->regmap,LM3633_CTRL_ENABLE , + ctrl_en_val, ~ctrl_en_val); +else + ret =regmap_update_bits (led->priv->regmap,LM3633_CTRL_ENABLE , + ctrl_en_val, ctrl_en_val); + + ret =ti_lmu_common_set_brightness (&led->lmu_data, brt_val);
Quoted 8 lines
drivers/leds/leds-lm3633.c line 185
Quoted 6 lines
drivers/leds/leds-lm3633.c new file +6
-0+if (ret) +dev_err (&led->priv->client->dev,"Cannot write brightness\n" ); + +mutex_unlock (&led->priv->lock); +return ret; +}Duplicate of 3697 function with different constants.
This will change to support all the control banks.
Quoted 16 lines
Quoted 16 lines
drivers/leds/leds-lm3633.c new file +15
-0+static int lm3633_set_control_bank (struct lm3633 *priv) +{ +u8 control_bank_config =0 ; +struct lm3633_led *led; +int ret, i; + + led = &priv->leds[0 ]; +if (led->control_bank ==LM3633_CONTROL_A ) + led = &priv->leds[1 ]; + +for (i =0 ; i <LM3633_MAX_HVLED_STRINGS ; i++) +if (led->hvled_strings[i] ==LM3633_HVLED_ASSIGNMENT ) + control_bank_config |=1 << i; + + ret = regmap_write(priv->regmap, LM3633_HVLED_OUTPUT_CONFIG,
Quoted 8 lines
drivers/leds/leds-lm3633.c line 207
Quoted 6 lines
drivers/leds/leds-lm3633.c new file +6
-0+ control_bank_config); +if (ret) +dev_err (&priv->client->dev,"Cannot write OUTPUT config\n" ); + +return ret; +}Duplicate of 3697 function.
This will change to support all the control banks.
Quoted 29 lines
Quoted 29 lines
drivers/leds/leds-lm3633.c new file +28
-0+static int lm3633_init (struct lm3633 *priv) +{ +struct lm3633_led *led; +int i, ret; + +if (priv->enable_gpio) { +gpiod_direction_output (priv->enable_gpio,1 ); + }else { + ret =regmap_write (priv->regmap,LM3633_RESET ,LM3633_SW_RESET ); +if (ret) { +dev_err (&priv->client->dev,"Cannot reset the device\n" ); + goto out; + } + } + + ret =regmap_write (priv->regmap,LM3633_CTRL_ENABLE ,0x0 ); +if (ret) { +dev_err (&priv->client->dev,"Cannot write ctrl enable\n" ); + goto out; + } + + ret =lm3633_set_control_bank (priv); +if (ret) +dev_err (&priv->client->dev,"Setting the CRTL bank failed\n" ); + +for (i =0 ; i <LM3633_MAX_CONTROL_BANKS ; i++) { + led = &priv->leds[i]; +ti_lmu_common_set_ramp (&led->lmu_data);
Quoted 8 lines
drivers/leds/leds-lm3633.c line 242
Quoted 6 lines
drivers/leds/leds-lm3633.c new file +6
-0+if (ret) +dev_err (&priv->client->dev,"Setting the ramp rate failed\n" ); + } +out: +return ret; +}Duplicate of 3697 function.
This will change to support all the control banks.
Quoted 90 lines
Quoted 90 lines
drivers/leds/leds-lm3633.c new file +89
-0+static int lm3633_probe_dt (struct lm3633 *priv) +{ +struct fwnode_handle *child =NULL ; +struct lm3633_led *led; +const char *name; +int control_bank; +size_t i =0 ; +int ret; + + priv->enable_gpio =devm_gpiod_get_optional (&priv->client->dev, +"enable" ,GPIOD_OUT_LOW ); +if (IS_ERR (priv->enable_gpio)) { + ret =PTR_ERR (priv->enable_gpio); +dev_err (&priv->client->dev,"Failed to get enable gpio: %d\n" , + ret); +return ret; + } + + priv->regulator =devm_regulator_get (&priv->client->dev,"vled" ); +if (IS_ERR (priv->regulator)) + priv->regulator =NULL ; + +device_for_each_child_node (priv->dev, child) { + ret =fwnode_property_read_u32 (child,"reg" , &control_bank); +if (ret) { +dev_err (&priv->client->dev,"reg property missing\n" ); +fwnode_handle_put (child); + goto child_out; + } + +if (control_bank >LM3633_CONTROL_B ) { +dev_err (&priv->client->dev,"reg property is invalid\n" ); + ret = -EINVAL ; +fwnode_handle_put (child); + goto child_out; + } + + led = &priv->leds[i]; + + led->control_bank = control_bank; + led->lmu_data.bank_id = control_bank; + led->lmu_data.enable_reg =LM3633_CTRL_ENABLE ; + led->lmu_data.regmap = priv->regmap; +if (control_bank ==LM3633_CONTROL_A ) + led->lmu_data.runtime_ramp_reg =LM3633_CTRL_A_RAMP ; +else + led->lmu_data.runtime_ramp_reg =LM3633_CTRL_B_RAMP ; + +if (control_bank <=LM3633_CONTROL_B ) + ret =fwnode_property_read_u32_array (child,"led-sources" , + led->hvled_strings, +LM3633_MAX_HVLED_STRINGS ); +else + ret =fwnode_property_read_u32_array (child,"led-sources" , + led->lvled_strings, +LM3633_MAX_LVLED_STRINGS ); +if (ret) { +dev_err (&priv->client->dev,"led-sources property missing\n" ); +fwnode_handle_put (child); + goto child_out; + } + + ret =ti_lmu_common_get_ramp_params (&priv->client->dev, child, &led->lmu_data); +if (ret) +dev_warn (&priv->client->dev,"runtime-ramp properties missing\n" ); + +fwnode_property_read_string (child,"linux,default-trigger" , + &led->led_dev.default_trigger); + + ret =fwnode_property_read_string (child,"label" , &name); +if (ret) +snprintf (led->label,sizeof (led->label), +"%s::" , priv->client->name); +else +snprintf (led->label,sizeof (led->label), +"%s:%s" , priv->client->name, name); + + led->priv = priv; + led->led_dev.name = led->label; + led->led_dev.brightness_set_blocking = lm3633_brightness_set; + + ret =devm_led_classdev_register (priv->dev, &led->led_dev); +if (ret) { +dev_err (&priv->client->dev,"led register err: %d\n" , + ret); +fwnode_handle_put (child); + goto child_out; + } +
Quoted 8 lines
drivers/leds/leds-lm3633.c line 338
Quoted 6 lines
drivers/leds/leds-lm3633.c new file +6
-0+ i++; + } + +child_out: +return ret; +}Very similar, but not quite same.
I know this function will definitely change to support the LVLED control bank setting. The main difference here is that the HVLED has a simple control bank configuration and the LVLED is highly configurable with multiple permutations.
As well as maybe the PWM support
Quoted 32 lines
Quoted 32 lines
drivers/leds/leds-lm3633.c new file +31
-0+static int lm3633_probe (struct i2c_client *client, +const struct i2c_device_id *id) +{ +struct lm3633 *led; +int count; +int ret; + + count =device_get_child_node_count (&client->dev); +if (!count) { +dev_err (&client->dev,"LEDs are not defined in device tree!" ); +return -ENODEV ; + } + + led =devm_kzalloc (&client->dev,struct_size (led, leds, count), +GFP_KERNEL ); +if (!led) +return -ENOMEM ; + +mutex_init (&led->lock); +i2c_set_clientdata (client, led); + + led->client = client; + led->dev = &client->dev; + led->regmap =devm_regmap_init_i2c (client, &lm3633_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-lm3633.c line 376
Quoted 6 lines
drivers/leds/leds-lm3633.c new file +6
-0+ ret =lm3633_probe_dt (led); +if (ret) +return ret; + +return lm3633_init (led); +}Duplicate.
I do expect the probes to be the same as in most cases.
Quoted 30 lines
Quoted 17 lines
drivers/leds/leds-lm3633.c new file +16
-0+static int lm3633_remove (struct i2c_client *client) +{ +struct lm3633 *led =i2c_get_clientdata (client); +int ret; + + ret =regmap_update_bits (led->regmap,LM3633_CTRL_ENABLE , +LM3633_CTRL_A_B_EN ,0 ); +if (ret) { +dev_err (&led->client->dev,"Failed to disable the device\n" ); +return ret; + } + +if (led->enable_gpio) +gpiod_direction_output (led->enable_gpio,0 ); + +if (led->regulator) {drivers/leds/leds-lm3633.c line 403
Quoted 10 lines
drivers/leds/leds-lm3633.c new file +10
-0+ ret =regulator_disable (led->regulator); +if (ret) +dev_err (&led->client->dev, +"Failed to disable regulator\n" ); + } + +mutex_destroy (&led->lock); + +return 0 ; +}Duplicate.
Quoted 2 lines
Can we get some more sharing? One way would be to have struct with all the constants (instead of #defines) use that...?
I will look at the adding common constants to but they should be common across more then just 2 devices. As you can see the LM3632 code is quite different when you add in the flash/torch support.
I am trying to keep the common as light weight as possible and not add code that cannot be used across multiple devices.
Dan
Quoted 5 lines
Thanks,
Pavel
Signature · 2 lines
------------------ Dan Murphy
Re: [RFC PATCH 7/9] leds: lm3633: Introduce the lm3633 driver
Hi!
Quoted 8 lines
Quoted 4 lines
Duplicate.
Can we get some more sharing? One way would be to have struct with all the constants (instead of #defines) use that...?
I will look at the adding common constants to but they should be common across more then just 2 devices. As you can see the LM3632 code is quite different when you add in the flash/torch support.
LM3632 is indeed different, I see.
On the other hand, I'd really like to see the code shared, even if it is just for 2 devices. (I believe that family is big enough that we'll likely see more sharing in future).
Thanks,
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Re: [RFC PATCH 7/9] leds: lm3633: Introduce the lm3633 driver
Pavel
Quoted 11 lines · Pavel Machek
Hi!
Quoted 8 lines
Quoted 4 lines
Duplicate.
Can we get some more sharing? One way would be to have struct with all the constants (instead of #defines) use that...?
I will look at the adding common constants to but they should be common across more then just 2 devices. As you can see the LM3632 code is quite different when you add in the flash/torch support.
Quoted 6 lines
LM3632 is indeed different, I see.
On the other hand, I'd really like to see the code shared, even if it is just for 2 devices. (I believe that family is big enough that we'll likely see more sharing in future).
Yes I have been looking at the other drivers I created that support 11 bit and I plan to move them over to call the common code if the code is accepted.
I just finished debugging and getting the 3632 and 3633 drivers working with flash/torch and configurable indicator support and there is a lot of code diff especially around the node parsing and configuration.
Dan
Quoted 4 lines
Thanks,
Pavel
Signature · 2 lines
------------------ Dan Murphy
Re: [RFC PATCH 9/9] leds: lm3632: Introduce the TI LM3632 driver
In reply to Dan MurphyQuoted 5 lines · Dan Murphy
Add the dedicated TI LM3632 LED driver. This LED device is capable of driving a backlight display.
In addition to the backlight the device has control of a strobe and torch output.
Is this in some way similar to 3639? That also seems to include flash and torch.
drivers/video/backlight/lm3639_bl.c
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Re: [RFC PATCH 9/9] leds: lm3632: Introduce the TI LM3632 driver
Pavel
Quoted 4 lines · Pavel Machek
Quoted 3 lines · Dan Murphy
Add the dedicated TI LM3632 LED driver. This LED device is capable of driving a backlight display.
Quoted 8 lines
Quoted 2 lines
In addition to the backlight the device has control of a strobe and torch output.
Is this in some way similar to 3639? That also seems to include flash and torch.
drivers/video/backlight/lm3639_bl.c
NICE!
Yes this driver looks to be good enough to use for the 3632 as well.
We would have to extend that driver to support the 3632, add firmware support, convert the led class registration to the flash LED registration and add the regulator support.
I can abandon the dedicated LED driver and update this one for the 3632. No reason to have duplicate code.
Dan
Pavel
Quoted 1 line
Signature · 2 lines
------------------ Dan Murphy