Skip to contentSkip to conversation

dt-bindings: backlight: Add Texas Instruments LM3509

PATCH Superseded Patrick Gansterer 3 participants 7 messages Mar 8, 2024 – Mar 9, 2024

Subsystems (4)

v2 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/2 dt-bindings: backlight: Add Texas Instruments LM3509

Add Device Tree bindings for Texas Instruments LM3509 - a High Efficiency Boost for White LED's and/or OLED Displays

---
Changes in v2:
Add device tree nodes for each output
Addressed multiple smaller review comments

v1: https://lore.kernel.org/all/[email protected]/

 .../bindings/leds/backlight/ti,lm3509.yaml    | 138 ++++++++++++++++++
 1 file changed, 138 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/leds/backlight/ti,lm3509.yaml
Documentation/devicetree/bindings/leds/backlight/ti,lm3509.yaml new file +138 -0
new file mode 100644
index 000000000000..84ffd12d2f8e
@@ -0,0 +1,138 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/leds/backlight/ti,lm3509.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: TI LM3509 High Efficiency Boost for White LED's and/or OLED Displays
+
+maintainers:
+  - Patrick Gansterer <[email protected]>
+
+description:
+  The LM3509 current mode boost converter offers two separate outputs.
+  https://www.ti.com/product/LM3509
+
+properties:
+  compatible:
+    const: ti,lm3509
+
+  reg:
+    maxItems: 1
+
+  "#address-cells":
+    const: 1
+
+  "#size-cells":
+    const: 0
+
+  reset-gpios:
+    maxItems: 1
+
+  ti,brightness-rate-of-change-us:
+    description: Brightness Rate of Change in microseconds.
+    enum: [51, 13000, 26000, 52000]
+
+  ti,oled-mode:
+    description: Enable OLED mode.
+    type: boolean
+
+required:
+  - compatible
+  - reg
+
+patternProperties:
+  "^led@[01]$":
+    type: object
+    description: Properties for a string of connected LEDs.
+
+    allOf:
+      - $ref: common.yaml#
+
+    properties:
+      reg:
+        description:
+          The control register that is used to program the two current sinks.
+          The LM3509 has two registers (BMAIN and BSUB) and are represented
+          as 0 or 1 in this property. The two current sinks can be controlled
+          independently with both registers, or register BMAIN can be
+          configured to control both sinks with the led-sources property.
+        minimum: 0
+        maximum: 1
+
+      label:
+        maxItems: 1
+
+      led-sources:
+        allOf:
+          - minItems: 1
+            maxItems: 2
+            items:
+              minimum: 0
+              maximum: 1
+
+      default-brightness:
+        minimum: 0
+        maximum: 31
+
+      max-brightness:
+        minimum: 0
+        maximum: 31
+
+    required:
+      - reg
+
+    unevaluatedProperties: false
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/gpio/gpio.h>
+    i2c {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        backlight@36 {
+            compatible = "ti,lm3509";
+            reg = <0x36>;
+            reset-gpios = <&gpio2 5 GPIO_ACTIVE_LOW>;
+
+            ti,oled-mode;
+            ti,brightness-rate-of-change-us = <52000>;
+
+            #address-cells = <1>;
+            #size-cells = <0>;
+
+            led@0 {
+                reg = <0>;
+                led-sources = <0 1>;
+                label = "lcd-backlight";
+                default-brightness = <12>;
+                max-brightness = <31>;
+            };
+        };
+    };
+  - |
+    i2c {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        backlight@36 {
+            compatible = "ti,lm3509";
+            reg = <0x36>;
+
+            #address-cells = <1>;
+            #size-cells = <0>;
+
+            led@0 {
+                reg = <0>;
+                default-brightness = <12>;
+            };
+
+            led@1 {
+                reg = <1>;
+                default-brightness = <15>;
+            };
+        };
+    };
Signature · 1 line
2.44.0
#1 lore raw

PATCH v2 2/2 backlight: Add new lm3509 backlight driver

This is a general driver for LM3509 backlight chip of TI. LM3509 is High Efficiency Boost for White LEDs and/or OLED Displays with Dual Current Sinks. This driver supports OLED/White LED select, brightness control and sub/main control.
The datasheet can be found at http://www.ti.com/product/lm3509.

---
 drivers/video/backlight/Kconfig     |   7 +
 drivers/video/backlight/Makefile    |   1 +
 drivers/video/backlight/lm3509_bl.c | 340 ++++++++++++++++++++++++++++
 3 files changed, 348 insertions(+)
 create mode 100644 drivers/video/backlight/lm3509_bl.c
drivers/video/backlight/Kconfig +7 -0
index ea2d0d69bd8c..96ad5dc584b6 100644
@@ -366,6 +366,13 @@ config BACKLIGHT_AAT2870
 	  If you have a AnalogicTech AAT2870 say Y to enable the
 	  backlight driver.
 
+config BACKLIGHT_LM3509
+	tristate "Backlight Driver for LM3509"
+	depends on I2C
+	select REGMAP_I2C
+	help
+	  This supports TI LM3509 Backlight Driver
+
 config BACKLIGHT_LM3630A
 	tristate "Backlight Driver for LM3630A"
 	depends on I2C && PWM
drivers/video/backlight/Makefile +1 -0
index 06966cb20459..51a4ac5d0530 100644
@@ -35,6 +35,7 @@ obj-$(CONFIG_BACKLIGHT_HP700)		+= jornada720_bl.o
 obj-$(CONFIG_BACKLIGHT_IPAQ_MICRO)	+= ipaq_micro_bl.o
 obj-$(CONFIG_BACKLIGHT_KTD253)		+= ktd253-backlight.o
 obj-$(CONFIG_BACKLIGHT_KTZ8866)		+= ktz8866.o
+obj-$(CONFIG_BACKLIGHT_LM3509)		+= lm3509_bl.o
 obj-$(CONFIG_BACKLIGHT_LM3533)		+= lm3533_bl.o
 obj-$(CONFIG_BACKLIGHT_LM3630A)		+= lm3630a_bl.o
 obj-$(CONFIG_BACKLIGHT_LM3639)		+= lm3639_bl.o
drivers/video/backlight/lm3509_bl.c new file +340 -0

340 lines not on this page · raw message

Signature · 1 line
2.44.0
#2 lore raw
In reply to Patrick Gansterer
Quoted 4 lines · Patrick Gansterer

Add Device Tree bindings for Texas Instruments LM3509 - a High Efficiency Boost for White LED's and/or OLED Displays

Thank you for your patch. There is something to discuss/improve.

Quoted 14 lines
Documentation/devicetree/bindings/leds/backlight/ti,lm3509.yaml new file +14 -0
+  compatible:
+    const: ti,lm3509
+
+  reg:
+    maxItems: 1
+
+  "#address-cells":
+    const: 1
+
+  "#size-cells":
+    const: 0
+
+  reset-gpios:
+    maxItems: 1

Documentation/devicetree/bindings/leds/backlight/ti,lm3509.yaml line 40

Quoted 10 lines
Documentation/devicetree/bindings/leds/backlight/ti,lm3509.yaml new file +10 -0
+
+  ti,brightness-rate-of-change-us:
+    description: Brightness Rate of Change in microseconds.
+    enum: [51, 13000, 26000, 52000]
+
+  ti,oled-mode:
+    description: Enable OLED mode.
+    type: boolean
+
+required:

required: goes after all properties.

Documentation/devicetree/bindings/leds/backlight/ti,lm3509.yaml line 47

Quoted 7 lines
Documentation/devicetree/bindings/leds/backlight/ti,lm3509.yaml new file +7 -0
+  - compatible
+  - reg
+
+patternProperties:
+  "^led@[01]$":
+    type: object
+    description: Properties for a string of connected LEDs.

Are you sure this is a string of LEDs? How does a string/tape work with a backlight, I mean physically? How could it look like?

Quoted 7 lines
Documentation/devicetree/bindings/leds/backlight/ti,lm3509.yaml new file +7 -0
+
+    allOf:
+      - $ref: common.yaml#
+
+    properties:
+      reg:
+        description:

Documentation/devicetree/bindings/leds/backlight/ti,lm3509.yaml line 64

Quoted 10 lines
Documentation/devicetree/bindings/leds/backlight/ti,lm3509.yaml new file +10 -0
+          The control register that is used to program the two current sinks.
+          The LM3509 has two registers (BMAIN and BSUB) and are represented
+          as 0 or 1 in this property. The two current sinks can be controlled
+          independently with both registers, or register BMAIN can be
+          configured to control both sinks with the led-sources property.
+        minimum: 0
+        maximum: 1
+
+      label:
+        maxItems: 1

It's a string, not string-array, so maxItems are not needed, just ":true".

Documentation/devicetree/bindings/leds/backlight/ti,lm3509.yaml line 76

Quoted 12 lines
Documentation/devicetree/bindings/leds/backlight/ti,lm3509.yaml new file +12 -0
+
+      led-sources:
+        allOf:
+          - minItems: 1
+            maxItems: 2
+            items:
+              minimum: 0
+              maximum: 1
+
+      default-brightness:
+        minimum: 0
+        maximum: 31

Not a required property? Then "default:".

Documentation/devicetree/bindings/leds/backlight/ti,lm3509.yaml line 80

Quoted 4 lines
Documentation/devicetree/bindings/leds/backlight/ti,lm3509.yaml new file +4 -0
+
+      max-brightness:
+        minimum: 0
+        maximum: 31

Some of your examples miss it, so there is some kind of default. Add it.

Documentation/devicetree/bindings/leds/backlight/ti,lm3509.yaml line 87

Quoted 7 lines
Documentation/devicetree/bindings/leds/backlight/ti,lm3509.yaml new file +7 -0
+
+    required:
+      - reg
+
+    unevaluatedProperties: false
+
+unevaluatedProperties: false

You rewrote everything, so my previous comment obviously does not make sense in such case. This must be additionalProperties: false. Look at other bindings or example-schema how it is done (to repeat myself).

Quoted 10 lines
Documentation/devicetree/bindings/leds/backlight/ti,lm3509.yaml new file +10 -0
+
+examples:
+  - |
+    #include <dt-bindings/gpio/gpio.h>
+    i2c {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        backlight@36 {
+            compatible = "ti,lm3509";

Documentation/devicetree/bindings/leds/backlight/ti,lm3509.yaml line 107

Quoted 10 lines
Documentation/devicetree/bindings/leds/backlight/ti,lm3509.yaml new file +10 -0
+            reg = <0x36>;
+            reset-gpios = <&gpio2 5 GPIO_ACTIVE_LOW>;
+
+            ti,oled-mode;
+            ti,brightness-rate-of-change-us = <52000>;
+
+            #address-cells = <1>;
+            #size-cells = <0>;
+
+            led@0 {

Best regards,
Krzysztof

#3 lore raw
Quoted 10 lines · Krzysztof Kozlowski

Documentation/devicetree/bindings/leds/backlight/ti,lm3509.yaml line 47

Quoted 7 lines
Documentation/devicetree/bindings/leds/backlight/ti,lm3509.yaml new file +7 -0
+  - compatible
+  - reg
+
+patternProperties:
+  "^led@[01]$":
+    type: object
+    description: Properties for a string of connected LEDs.

Are you sure this is a string of LEDs? How does a string/tape work with a backlight, I mean physically? How could it look like?

I just took most of the descriptions/names from lm3630a-backlight.yaml. I understand it in this context as multiple serial connected LEDs (as shown in the circuit diagram in the datasheet), so that each of them gets the same current when connected to the output of the chip.

Maybe a more general question: Is there any easy accessible information about which code is the best used as example/reference? I tried to align my code very close to the LM3630, but you gave me a bunch of comments on that ;-). And would you like see patches cleaning up some of the code with bad/outdated style?

- Patrick

#4 lore raw
Quoted 12 lines · Patrick Gansterer
Quoted 10 lines · Krzysztof Kozlowski

Documentation/devicetree/bindings/leds/backlight/ti,lm3509.yaml line 47

Quoted 7 lines
Documentation/devicetree/bindings/leds/backlight/ti,lm3509.yaml new file +7 -0
+  - compatible
+  - reg
+
+patternProperties:
+  "^led@[01]$":
+    type: object
+    description: Properties for a string of connected LEDs.

Are you sure this is a string of LEDs? How does a string/tape work with a backlight, I mean physically? How could it look like?

Quoted 5 lines

I just took most of the descriptions/names from lm3630a-backlight.yaml. I understand it in this context as multiple serial connected LEDs (as shown in the circuit diagram in the datasheet), so that each of them gets the same current when connected to the output of the chip.

lm3630 might have copied it as well. LED strings are true in case of... well, LED strings, but I just wonder if such setup is applicable for backlight. Anyway, if you think it is, I don't mind.

Quoted 5 lines

Maybe a more general question: Is there any easy accessible information about which code is the best used as example/reference? I tried to align my code very close to the LM3630, but you gave me a bunch of comments on that ;-). And would you like see patches cleaning up some of the code with bad/outdated style?

There is no such reference, except example-schema. Usually newest bindings, which passed review, are the best source.

Best regards,
Krzysztof

#6 lore raw
Quoted 7 lines · Sebastian Reichel

Hi,

Quoted 3 lines · Krzysztof Kozlowski

LED strings are true in case of... well, LED strings, but I just wonder if such setup is applicable for backlight. Anyway, if you think it is, I don't mind.

Quoted 8 lines

LED strings are being used as backlight. Either from the edge, like shown here:

https://en.wikipedia.org/wiki/File:IPod_Touch_2G_Backlight.JPG

or like this:

https://de.wikipedia.org/wiki/Datei:DiodyTV.jpg

Indeed, thanks for sharing!

Best regards,
Krzysztof