devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3 v2] dt-bindings: backlight: Add some common backlight properties
@ 2020-08-12  8:58 Linus Walleij
  2020-08-12  8:58 ` [PATCH 2/3 v2] dt-bindings: backlight: Add Kinetic KTD253 bindings Linus Walleij
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Linus Walleij @ 2020-08-12  8:58 UTC (permalink / raw)
  To: Lee Jones, Daniel Thompson, Jingoo Han, dri-devel
  Cc: Linus Walleij, devicetree, Sam Ravnborg

Let's use a common.yaml include for the backlight like we do with
the LEDs. The LEDs are inherently incompatible so their bindings
cannot be reused for backlight.

Cc: devicetree@vger.kernel.org
Suggested-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
ChangeLog v1->v2:
- New patch as suggested by Sam.
---
 .../bindings/leds/backlight/common.yaml       | 42 +++++++++++++++++++
 1 file changed, 42 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/leds/backlight/common.yaml

diff --git a/Documentation/devicetree/bindings/leds/backlight/common.yaml b/Documentation/devicetree/bindings/leds/backlight/common.yaml
new file mode 100644
index 000000000000..8ae7e3818b0d
--- /dev/null
+++ b/Documentation/devicetree/bindings/leds/backlight/common.yaml
@@ -0,0 +1,42 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/leds/backlight/common.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Common backlight properties
+
+maintainers:
+  - Lee Jones <lee.jones@linaro.org>
+  - Daniel Thompson <daniel.thompson@linaro.org>
+  - Jingoo Han <jingoohan1@gmail.com>
+
+description: |
+  Backlight devices provide backlight for different types of graphical
+  displays. They are typically but not necessarilt implemented using a white
+  LED powered by a boost converter.
+
+properties:
+  default-on:
+    description:
+      The initial state of the backlight can be set to be on with this
+      property. This is a state applied by the operating system so that the
+      backlight is always turned on at boot.
+
+  default-brightness:
+    description:
+      The default brightness that should be applied to the LED by the operating
+      system on start-up. The brightness should not exceed the brightness the
+      LED can provide.
+    $ref: /schemas/types.yaml#definitions/uint32
+    minimum: 0
+
+  max-brightness:
+    description:
+      Normally the maximum brightness is determined by the hardware and this
+      property is not required. This property is used to put a software limit
+      on the brightness apart from what the driver says, as it could happen
+      that a LED can be made so bright that it gets damaged or causes damage
+      due to restrictions in a specific system, such as mounting conditions.
+    $ref: /schemas/types.yaml#definitions/uint32
+    minimum: 0
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/3 v2] dt-bindings: backlight: Add Kinetic KTD253 bindings
  2020-08-12  8:58 [PATCH 1/3 v2] dt-bindings: backlight: Add some common backlight properties Linus Walleij
@ 2020-08-12  8:58 ` Linus Walleij
  2020-08-13 10:48   ` Daniel Thompson
  2020-08-12 15:46 ` [PATCH 1/3 v2] dt-bindings: backlight: Add some common backlight properties Rob Herring
  2020-08-13 11:04 ` Daniel Thompson
  2 siblings, 1 reply; 6+ messages in thread
From: Linus Walleij @ 2020-08-12  8:58 UTC (permalink / raw)
  To: Lee Jones, Daniel Thompson, Jingoo Han, dri-devel
  Cc: Linus Walleij, devicetree, Sam Ravnborg

This adds device tree bindings for the Kinetic KTD253
white LED backlight driver.

Cc: devicetree@vger.kernel.org
Cc: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
ChangeLog v1->v2:
- Create common.yaml for backlight as suggested by Sam and
  use that.
- Rename the GPIO line "enable-gpios"
---
 .../leds/backlight/kinetic,ktd253.yaml        | 48 +++++++++++++++++++
 1 file changed, 48 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/leds/backlight/kinetic,ktd253.yaml

diff --git a/Documentation/devicetree/bindings/leds/backlight/kinetic,ktd253.yaml b/Documentation/devicetree/bindings/leds/backlight/kinetic,ktd253.yaml
new file mode 100644
index 000000000000..e17f45a2a6bf
--- /dev/null
+++ b/Documentation/devicetree/bindings/leds/backlight/kinetic,ktd253.yaml
@@ -0,0 +1,48 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/leds/backlight/kinetic,ktd253.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Kinetic Technologies KTD253 one-wire backlight
+
+maintainers:
+  - Linus Walleij <linus.walleij@linaro.org>
+
+description: |
+  The Kinetic Technologies KTD253 is a white LED backlight that is
+  controlled by a single GPIO line. If you just turn on the backlight
+  it goes to maximum backlight then you can set the level of backlight
+  using pulses on the enable wire. This is sometimes referred to as
+  "expresswire".
+
+allOf:
+  - $ref: common.yaml#
+
+properties:
+  compatible:
+    const: kinetic,ktd253
+
+  enable-gpios:
+    description: GPIO to use to enable/disable and dim the backlight.
+    maxItems: 1
+
+  default-on: true
+  default-brightness: true
+  max-brightness: true
+
+required:
+  - compatible
+  - enable-gpios
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/gpio/gpio.h>
+    backlight {
+        compatible = "kinetic,ktd253";
+        enable-gpios = <&gpio2 5 GPIO_ACTIVE_HIGH>;
+        default-on;
+        default-brightness = <160>;
+    };
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/3 v2] dt-bindings: backlight: Add some common backlight properties
  2020-08-12  8:58 [PATCH 1/3 v2] dt-bindings: backlight: Add some common backlight properties Linus Walleij
  2020-08-12  8:58 ` [PATCH 2/3 v2] dt-bindings: backlight: Add Kinetic KTD253 bindings Linus Walleij
@ 2020-08-12 15:46 ` Rob Herring
  2020-08-19 20:46   ` Linus Walleij
  2020-08-13 11:04 ` Daniel Thompson
  2 siblings, 1 reply; 6+ messages in thread
From: Rob Herring @ 2020-08-12 15:46 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Lee Jones, Daniel Thompson, Jingoo Han, dri-devel, devicetree,
	Sam Ravnborg

On Wed, Aug 12, 2020 at 2:58 AM Linus Walleij <linus.walleij@linaro.org> wrote:
>
> Let's use a common.yaml include for the backlight like we do with
> the LEDs. The LEDs are inherently incompatible so their bindings
> cannot be reused for backlight.
>
> Cc: devicetree@vger.kernel.org
> Suggested-by: Sam Ravnborg <sam@ravnborg.org>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> ---
> ChangeLog v1->v2:
> - New patch as suggested by Sam.
> ---
>  .../bindings/leds/backlight/common.yaml       | 42 +++++++++++++++++++
>  1 file changed, 42 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/leds/backlight/common.yaml

I'd expect some refactoring here with existing backlight schemas
including the ones I just added for 5.9.

Ideally, we shouldn't have any property have a type definition more
than once. (We don't have any way to detect that though it wouldn't be
hard to write a program to do so).

> diff --git a/Documentation/devicetree/bindings/leds/backlight/common.yaml b/Documentation/devicetree/bindings/leds/backlight/common.yaml
> new file mode 100644
> index 000000000000..8ae7e3818b0d
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/leds/backlight/common.yaml
> @@ -0,0 +1,42 @@
> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/leds/backlight/common.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Common backlight properties
> +
> +maintainers:
> +  - Lee Jones <lee.jones@linaro.org>
> +  - Daniel Thompson <daniel.thompson@linaro.org>
> +  - Jingoo Han <jingoohan1@gmail.com>
> +
> +description: |

You don't need '|' if there's no formatting to preserve.

> +  Backlight devices provide backlight for different types of graphical
> +  displays. They are typically but not necessarilt implemented using a white

typo

> +  LED powered by a boost converter.
> +
> +properties:
> +  default-on:
> +    description:
> +      The initial state of the backlight can be set to be on with this
> +      property. This is a state applied by the operating system so that the
> +      backlight is always turned on at boot.

Needs a type.

> +
> +  default-brightness:
> +    description:
> +      The default brightness that should be applied to the LED by the operating
> +      system on start-up. The brightness should not exceed the brightness the
> +      LED can provide.
> +    $ref: /schemas/types.yaml#definitions/uint32
> +    minimum: 0

It's an unsigned int, so the min is already 0.

> +
> +  max-brightness:
> +    description:
> +      Normally the maximum brightness is determined by the hardware and this
> +      property is not required. This property is used to put a software limit
> +      on the brightness apart from what the driver says, as it could happen
> +      that a LED can be made so bright that it gets damaged or causes damage
> +      due to restrictions in a specific system, such as mounting conditions.
> +    $ref: /schemas/types.yaml#definitions/uint32
> +    minimum: 0

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/3 v2] dt-bindings: backlight: Add Kinetic KTD253 bindings
  2020-08-12  8:58 ` [PATCH 2/3 v2] dt-bindings: backlight: Add Kinetic KTD253 bindings Linus Walleij
@ 2020-08-13 10:48   ` Daniel Thompson
  0 siblings, 0 replies; 6+ messages in thread
From: Daniel Thompson @ 2020-08-13 10:48 UTC (permalink / raw)
  To: Linus Walleij; +Cc: Lee Jones, Jingoo Han, dri-devel, devicetree, Sam Ravnborg

On Wed, Aug 12, 2020 at 10:58:49AM +0200, Linus Walleij wrote:
> This adds device tree bindings for the Kinetic KTD253
> white LED backlight driver.
> 
> Cc: devicetree@vger.kernel.org
> Cc: Sam Ravnborg <sam@ravnborg.org>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> ---
> ChangeLog v1->v2:
> - Create common.yaml for backlight as suggested by Sam and
>   use that.
> - Rename the GPIO line "enable-gpios"
> ---
>  .../leds/backlight/kinetic,ktd253.yaml        | 48 +++++++++++++++++++
>  1 file changed, 48 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/leds/backlight/kinetic,ktd253.yaml
> 
> diff --git a/Documentation/devicetree/bindings/leds/backlight/kinetic,ktd253.yaml b/Documentation/devicetree/bindings/leds/backlight/kinetic,ktd253.yaml
> new file mode 100644
> index 000000000000..e17f45a2a6bf
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/leds/backlight/kinetic,ktd253.yaml
> @@ -0,0 +1,48 @@
> +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/leds/backlight/kinetic,ktd253.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Kinetic Technologies KTD253 one-wire backlight
> +
> +maintainers:
> +  - Linus Walleij <linus.walleij@linaro.org>
> +
> +description: |
> +  The Kinetic Technologies KTD253 is a white LED backlight that is
> +  controlled by a single GPIO line. If you just turn on the backlight
> +  it goes to maximum backlight then you can set the level of backlight
> +  using pulses on the enable wire. This is sometimes referred to as
> +  "expresswire".
> +
> +allOf:
> +  - $ref: common.yaml#
> +
> +properties:
> +  compatible:
> +    const: kinetic,ktd253
> +
> +  enable-gpios:
> +    description: GPIO to use to enable/disable and dim the backlight.
> +    maxItems: 1
> +
> +  default-on: true

What use is default-on here?

I'm guessing not much because there is no code in the driver to consume
it!

If there is a need to arrange a flicker-free backlight handover then
we should only use DT to handle that if the approach taken by other
drivers is not feasible (this is best demonstrated by
pwm_backlight_initial_power_state() ).

In short the approach is if not DT or no phandle link then turn the
backlight on (because noone else will) otherwise look at the current state
of the hardware and use that to inherit the power state (that is power
state, not brightness level).

To be honest flicker-free handover looks pretty hard for this driver.
It looks like we would have to flicker at some point so that we can
know exactly what brightness the hardware currently is.


Daniel.


> +  default-brightness: true
> +  max-brightness: true
> +
> +required:
> +  - compatible
> +  - enable-gpios
> +
> +additionalProperties: false
> +
> +examples:
> +  - |
> +    #include <dt-bindings/gpio/gpio.h>
> +    backlight {
> +        compatible = "kinetic,ktd253";
> +        enable-gpios = <&gpio2 5 GPIO_ACTIVE_HIGH>;
> +        default-on;
> +        default-brightness = <160>;

160 is out of range...


Daniel.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/3 v2] dt-bindings: backlight: Add some common backlight properties
  2020-08-12  8:58 [PATCH 1/3 v2] dt-bindings: backlight: Add some common backlight properties Linus Walleij
  2020-08-12  8:58 ` [PATCH 2/3 v2] dt-bindings: backlight: Add Kinetic KTD253 bindings Linus Walleij
  2020-08-12 15:46 ` [PATCH 1/3 v2] dt-bindings: backlight: Add some common backlight properties Rob Herring
@ 2020-08-13 11:04 ` Daniel Thompson
  2 siblings, 0 replies; 6+ messages in thread
From: Daniel Thompson @ 2020-08-13 11:04 UTC (permalink / raw)
  To: Linus Walleij; +Cc: Lee Jones, Jingoo Han, dri-devel, devicetree, Sam Ravnborg

On Wed, Aug 12, 2020 at 10:58:48AM +0200, Linus Walleij wrote:
> Let's use a common.yaml include for the backlight like we do with
> the LEDs. The LEDs are inherently incompatible so their bindings
> cannot be reused for backlight.
> 
> Cc: devicetree@vger.kernel.org
> Suggested-by: Sam Ravnborg <sam@ravnborg.org>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> ---
> ChangeLog v1->v2:
> - New patch as suggested by Sam.
> ---
>  .../bindings/leds/backlight/common.yaml       | 42 +++++++++++++++++++
>  1 file changed, 42 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/leds/backlight/common.yaml
> 
> diff --git a/Documentation/devicetree/bindings/leds/backlight/common.yaml b/Documentation/devicetree/bindings/leds/backlight/common.yaml
> new file mode 100644
> index 000000000000..8ae7e3818b0d
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/leds/backlight/common.yaml
> @@ -0,0 +1,42 @@
> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/leds/backlight/common.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Common backlight properties
> +
> +maintainers:
> +  - Lee Jones <lee.jones@linaro.org>
> +  - Daniel Thompson <daniel.thompson@linaro.org>
> +  - Jingoo Han <jingoohan1@gmail.com>
> +
> +description: |
> +  Backlight devices provide backlight for different types of graphical
> +  displays. They are typically but not necessarilt implemented using a white
> +  LED powered by a boost converter.
> +
> +properties:
> +  default-on:
> +    description:
> +      The initial state of the backlight can be set to be on with this
> +      property. This is a state applied by the operating system so that the
> +      backlight is always turned on at boot.

Is default-on really a common property? I would describe it as legacy
that emerged when we added the gpio bindings and didn't spell
default-brightness correctly!

Currently I think this is only implemented for GPIO and it is simply
not needed for most hardware. More specifically, for hardware that is
capable of flicker-free handover (bootloader -> kernel) by examining
the hardware state at handover then we don't want a DT property. It is
duplicative and can only result in bad handovers.


Daniel.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/3 v2] dt-bindings: backlight: Add some common backlight properties
  2020-08-12 15:46 ` [PATCH 1/3 v2] dt-bindings: backlight: Add some common backlight properties Rob Herring
@ 2020-08-19 20:46   ` Linus Walleij
  0 siblings, 0 replies; 6+ messages in thread
From: Linus Walleij @ 2020-08-19 20:46 UTC (permalink / raw)
  To: Rob Herring
  Cc: Lee Jones, Daniel Thompson, Jingoo Han, dri-devel,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	Sam Ravnborg

On Wed, Aug 12, 2020 at 5:46 PM Rob Herring <robh@kernel.org> wrote:
> On Wed, Aug 12, 2020 at 2:58 AM Linus Walleij <linus.walleij@linaro.org> wrote:
> >
> > Let's use a common.yaml include for the backlight like we do with
> > the LEDs. The LEDs are inherently incompatible so their bindings
> > cannot be reused for backlight.
> >
> > Cc: devicetree@vger.kernel.org
> > Suggested-by: Sam Ravnborg <sam@ravnborg.org>
> > Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> > ---
> > ChangeLog v1->v2:
> > - New patch as suggested by Sam.
> > ---
> >  .../bindings/leds/backlight/common.yaml       | 42 +++++++++++++++++++
> >  1 file changed, 42 insertions(+)
> >  create mode 100644 Documentation/devicetree/bindings/leds/backlight/common.yaml
>
> I'd expect some refactoring here with existing backlight schemas
> including the ones I just added for 5.9.

Yeah if it takes off I can certainly make a slew of refactorings,
I would like to do that once this is applied.

> > +  LED powered by a boost converter.
> > +
> > +properties:
> > +  default-on:
> > +    description:
> > +      The initial state of the backlight can be set to be on with this
> > +      property. This is a state applied by the operating system so that the
> > +      backlight is always turned on at boot.
>
> Needs a type.

Dropping this property because the subsystem maintainer
doubts this is needed.

Fixed the rest!

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-08-19 20:46 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-12  8:58 [PATCH 1/3 v2] dt-bindings: backlight: Add some common backlight properties Linus Walleij
2020-08-12  8:58 ` [PATCH 2/3 v2] dt-bindings: backlight: Add Kinetic KTD253 bindings Linus Walleij
2020-08-13 10:48   ` Daniel Thompson
2020-08-12 15:46 ` [PATCH 1/3 v2] dt-bindings: backlight: Add some common backlight properties Rob Herring
2020-08-19 20:46   ` Linus Walleij
2020-08-13 11:04 ` Daniel Thompson

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).