RE: [PATCH v3 1/2] dt-bindings: backlight: Add MPS MP3309C

2023-10-06 Thread Flavio Suligoi
HI Daniel,

...
> > ...
> > > ...
> > > > > > > +required:
> > > > > > > +  - compatible
> > > > > > > +  - reg
> > > > > > > +  - max-brightness
> > > > > >
> > > > > > Why is this mandatory?
> > > > > >
> > > > > > There's no point in setting max-brightness when running in I2C
> > > > > > mode
> > > > > > (max- brightness should default to 31 in that case).
> > > > > >
> > > > > >
> > > > > > > +  - default-brightness
> > > > > >
> > > > > > Again. I'm not clear why this needs to be mandatory.
> > > > > >
> > > > > >
> > > > >
> > > > > Ok, you are right, I'll remove max-brightness and
> > > > > default-brightness from required properties list. I think to
> > > > > change these properties, for the pwm dimming, into a clearer:
> > > > >
> > > > > - brightness-levels (uint32)
> > > > > - default-brightness-levels (uint32).
> > > > >
> > > > > For example:
> > > > >
> > > > >   brightness-levels:
> > > > > description:
> > > > >   Number of brightness levels. The actual brightness
> > > > >   level (PWM duty cycle) will be interpolated from 0 to this 
> > > > > value.
> > > > >   0 means a  0% duty cycle (darkest/off), while the
> > > > > brightness-levels
> > > > represents
> > > > >   a 100% duty cycle (brightest).
> > > > > $ref: /schemas/types.yaml#/definitions/uint32
> > > > >
> > > > >   default-brightness-level:
> > > > > description:
> > > > >   The default brightness level (from 0 to brightness-levels)
> > > > > $ref: /schemas/types.yaml#/definitions/uint32
> > > > >
> > > > > Example:
> > > > > brightness-levels = <10>;
> > > > > default-brightness-level = <6>;
> > > > >
> > > > > What do you think about this solution?
> > > >
> > > > If you want to introduce a brightness-levels property then I would
> > > > expect it to be defined with the same meaning as pwm-backlight
> > > > (it's not relevant to the bindings but ideally it would be
> > > > implemented by refactoring and reusing the code from pwm_bl.c).
> > >
> > > ok, I'll use the brightness-levels property as used in pwm-backlight
> > >
> > > >
> > > > Same with default-brightness-level although I'm not sure why one
> > > > wouldn't just use default-brightness for new bindings (doesn't
> > > > default-brightness-level simply do exactly the same thing as
> > > > default-
> > > brightness).
> > >
> > > ok for default-brightness instead of default-brightness-level
> >
> > Just a question: default-brightness-level is the index into the brightness-
> levels array.
> > But, if I use default-brightness instead of default-brightness-level,
> > should I consider default-brightness also as an index into brightness-levels
> array?
> 
> Yes.
> 
> 
> > Or, in this case, have the default-brightness to be equal to one of
> > the values inside the brightness-levels array?
> 
> When there is a brightness array (and there is no interpolation) then it is
> indexed by brightness. The values in the array are not brightness (e.g. the
> controlable value describing the output of the hardware). The values in the
> table are merely the PWM duty cycle...

ok

> 
> Main difference is, with a correct table the brightness can use an appropriate
> logarithmic power scale (which matches how humans perceive
> brightness) instead of the linear scale provided by the PWM duty cycle.
> 
> 
> Daniel.
> 
> 
> Brightness and "index into the brightness-levels array" should be one and the
> same thing

ok, I'll use default-brightness, thanks for the explanations!

> >
> > >
> > > >
> > > >
> > > > Daniel.
> > >
> > > Thanks an best regards,
> > > Flavio
> >
> > Thanks,
> >
> > Flavio

Flavio


Re: [PATCH v3 1/2] dt-bindings: backlight: Add MPS MP3309C

2023-10-05 Thread Daniel Thompson
On Wed, Oct 04, 2023 at 03:18:24PM +, Flavio Suligoi wrote:
> Hi Daniel,
> ...
> > ...
> > > > > > +required:
> > > > > > +  - compatible
> > > > > > +  - reg
> > > > > > +  - max-brightness
> > > > >
> > > > > Why is this mandatory?
> > > > >
> > > > > There's no point in setting max-brightness when running in I2C
> > > > > mode
> > > > > (max- brightness should default to 31 in that case).
> > > > >
> > > > >
> > > > > > +  - default-brightness
> > > > >
> > > > > Again. I'm not clear why this needs to be mandatory.
> > > > >
> > > > >
> > > >
> > > > Ok, you are right, I'll remove max-brightness and default-brightness
> > > > from required properties list. I think to change these properties,
> > > > for the pwm dimming, into a clearer:
> > > >
> > > > - brightness-levels (uint32)
> > > > - default-brightness-levels (uint32).
> > > >
> > > > For example:
> > > >
> > > >   brightness-levels:
> > > > description:
> > > >   Number of brightness levels. The actual brightness
> > > >   level (PWM duty cycle) will be interpolated from 0 to this value.
> > > >   0 means a  0% duty cycle (darkest/off), while the
> > > > brightness-levels
> > > represents
> > > >   a 100% duty cycle (brightest).
> > > > $ref: /schemas/types.yaml#/definitions/uint32
> > > >
> > > >   default-brightness-level:
> > > > description:
> > > >   The default brightness level (from 0 to brightness-levels)
> > > > $ref: /schemas/types.yaml#/definitions/uint32
> > > >
> > > > Example:
> > > > brightness-levels = <10>;
> > > > default-brightness-level = <6>;
> > > >
> > > > What do you think about this solution?
> > >
> > > If you want to introduce a brightness-levels property then I would
> > > expect it to be defined with the same meaning as pwm-backlight (it's
> > > not relevant to the bindings but ideally it would be implemented by
> > > refactoring and reusing the code from pwm_bl.c).
> >
> > ok, I'll use the brightness-levels property as used in pwm-backlight
> >
> > >
> > > Same with default-brightness-level although I'm not sure why one
> > > wouldn't just use default-brightness for new bindings (doesn't
> > > default-brightness-level simply do exactly the same thing as default-
> > brightness).
> >
> > ok for default-brightness instead of default-brightness-level
>
> Just a question: default-brightness-level is the index into the 
> brightness-levels array.
> But, if I use default-brightness instead of default-brightness-level,
> should I consider default-brightness also as an index into brightness-levels 
> array?

Yes.


> Or, in this case, have the default-brightness to be equal to one of the 
> values inside the
> brightness-levels array?

When there is a brightness array (and there is no interpolation) then
it is indexed by brightness. The values in the array are not
brightness (e.g. the controlable value describing the output of the
hardware). The values in the table are merely the PWM duty cycle...

Main difference is, with a correct table the brightness can use an
appropriate logarithmic power scale (which matches how humans perceive
brightness) instead of the linear scale provided by the PWM duty cycle.


Daniel.


Brightness and "index into the brightness-levels array" should be one
and the same thing
>
> >
> > >
> > >
> > > Daniel.
> >
> > Thanks an best regards,
> > Flavio
>
> Thanks,
>
> Flavio


RE: [PATCH v3 1/2] dt-bindings: backlight: Add MPS MP3309C

2023-10-04 Thread Flavio Suligoi
Hi Daniel,
...
> ...
> > > > > +required:
> > > > > +  - compatible
> > > > > +  - reg
> > > > > +  - max-brightness
> > > >
> > > > Why is this mandatory?
> > > >
> > > > There's no point in setting max-brightness when running in I2C
> > > > mode
> > > > (max- brightness should default to 31 in that case).
> > > >
> > > >
> > > > > +  - default-brightness
> > > >
> > > > Again. I'm not clear why this needs to be mandatory.
> > > >
> > > >
> > >
> > > Ok, you are right, I'll remove max-brightness and default-brightness
> > > from required properties list. I think to change these properties,
> > > for the pwm dimming, into a clearer:
> > >
> > > - brightness-levels (uint32)
> > > - default-brightness-levels (uint32).
> > >
> > > For example:
> > >
> > >   brightness-levels:
> > > description:
> > >   Number of brightness levels. The actual brightness
> > >   level (PWM duty cycle) will be interpolated from 0 to this value.
> > >   0 means a  0% duty cycle (darkest/off), while the
> > > brightness-levels
> > represents
> > >   a 100% duty cycle (brightest).
> > > $ref: /schemas/types.yaml#/definitions/uint32
> > >
> > >   default-brightness-level:
> > > description:
> > >   The default brightness level (from 0 to brightness-levels)
> > > $ref: /schemas/types.yaml#/definitions/uint32
> > >
> > > Example:
> > > brightness-levels = <10>;
> > > default-brightness-level = <6>;
> > >
> > > What do you think about this solution?
> >
> > If you want to introduce a brightness-levels property then I would
> > expect it to be defined with the same meaning as pwm-backlight (it's
> > not relevant to the bindings but ideally it would be implemented by
> > refactoring and reusing the code from pwm_bl.c).
> 
> ok, I'll use the brightness-levels property as used in pwm-backlight
> 
> >
> > Same with default-brightness-level although I'm not sure why one
> > wouldn't just use default-brightness for new bindings (doesn't
> > default-brightness-level simply do exactly the same thing as default-
> brightness).
> 
> ok for default-brightness instead of default-brightness-level

Just a question: default-brightness-level is the index into the 
brightness-levels array.
But, if I use default-brightness instead of default-brightness-level,  
should I consider default-brightness also as an index into brightness-levels 
array?
Or, in this case, have the default-brightness to be equal to one of the values 
inside the
brightness-levels array?

> 
> >
> >
> > Daniel.
> 
> Thanks an best regards,
> Flavio

Thanks,

Flavio


RE: [PATCH v3 1/2] dt-bindings: backlight: Add MPS MP3309C

2023-10-03 Thread Flavio Suligoi
Hi Daniel,

...
> > > > +required:
> > > > +  - compatible
> > > > +  - reg
> > > > +  - max-brightness
> > >
> > > Why is this mandatory?
> > >
> > > There's no point in setting max-brightness when running in I2C mode
> > > (max- brightness should default to 31 in that case).
> > >
> > >
> > > > +  - default-brightness
> > >
> > > Again. I'm not clear why this needs to be mandatory.
> > >
> > >
> >
> > Ok, you are right, I'll remove max-brightness and default-brightness
> > from required properties list. I think to change these properties, for
> > the pwm dimming, into a clearer:
> >
> > - brightness-levels (uint32)
> > - default-brightness-levels (uint32).
> >
> > For example:
> >
> >   brightness-levels:
> > description:
> >   Number of brightness levels. The actual brightness
> >   level (PWM duty cycle) will be interpolated from 0 to this value.
> >   0 means a  0% duty cycle (darkest/off), while the brightness-levels
> represents
> >   a 100% duty cycle (brightest).
> > $ref: /schemas/types.yaml#/definitions/uint32
> >
> >   default-brightness-level:
> > description:
> >   The default brightness level (from 0 to brightness-levels)
> > $ref: /schemas/types.yaml#/definitions/uint32
> >
> > Example:
> > brightness-levels = <10>;
> > default-brightness-level = <6>;
> >
> > What do you think about this solution?
> 
> If you want to introduce a brightness-levels property then I would expect it 
> to
> be defined with the same meaning as pwm-backlight (it's not relevant to the
> bindings but ideally it would be implemented by refactoring and reusing the
> code from pwm_bl.c).

ok, I'll use the brightness-levels property as used in pwm-backlight

> 
> Same with default-brightness-level although I'm not sure why one wouldn't
> just use default-brightness for new bindings (doesn't default-brightness-level
> simply do exactly the same thing as default-brightness).

ok for default-brightness instead of default-brightness-level

> 
> 
> Daniel.

Thanks an best regards,
Flavio


RE: [PATCH v3 1/2] dt-bindings: backlight: Add MPS MP3309C

2023-10-03 Thread Flavio Suligoi
Hi Daniel,

...

> > +required:
> > +  - compatible
> > +  - reg
> > +  - max-brightness
> 
> Why is this mandatory?
> 
> There's no point in setting max-brightness when running in I2C mode (max-
> brightness should default to 31 in that case).
> 
> 
> > +  - default-brightness
> 
> Again. I'm not clear why this needs to be mandatory.
> 
> 

Ok, you are right, I'll remove max-brightness and default-brightness from 
required properties list.
I think to change these properties, for the pwm dimming, into a clearer:

- brightness-levels (uint32) 
- default-brightness-levels (uint32).

For example:

  brightness-levels:
description:
  Number of brightness levels. The actual brightness
  level (PWM duty cycle) will be interpolated from 0 to this value.
  0 means a  0% duty cycle (darkest/off), while the brightness-levels 
represents
  a 100% duty cycle (brightest).
$ref: /schemas/types.yaml#/definitions/uint32

  default-brightness-level:
description:
  The default brightness level (from 0 to brightness-levels)
$ref: /schemas/types.yaml#/definitions/uint32

Example:
brightness-levels = <10>;
default-brightness-level = <6>;

What do you think about this solution?

> Daniel.

Thanks for your help,
Flavio


Re: [PATCH v3 1/2] dt-bindings: backlight: Add MPS MP3309C

2023-10-03 Thread Daniel Thompson
On Tue, Oct 03, 2023 at 09:43:15AM +, Flavio Suligoi wrote:
> Hi Daniel,
>
> ...
>
> > > +required:
> > > +  - compatible
> > > +  - reg
> > > +  - max-brightness
> >
> > Why is this mandatory?
> >
> > There's no point in setting max-brightness when running in I2C mode (max-
> > brightness should default to 31 in that case).
> >
> >
> > > +  - default-brightness
> >
> > Again. I'm not clear why this needs to be mandatory.
> >
> >
>
> Ok, you are right, I'll remove max-brightness and default-brightness
> from required properties list. I think to change these properties,
> for the pwm dimming, into a clearer:
>
> - brightness-levels (uint32)
> - default-brightness-levels (uint32).
>
> For example:
>
>   brightness-levels:
> description:
>   Number of brightness levels. The actual brightness
>   level (PWM duty cycle) will be interpolated from 0 to this value.
>   0 means a  0% duty cycle (darkest/off), while the brightness-levels 
> represents
>   a 100% duty cycle (brightest).
> $ref: /schemas/types.yaml#/definitions/uint32
>
>   default-brightness-level:
> description:
>   The default brightness level (from 0 to brightness-levels)
> $ref: /schemas/types.yaml#/definitions/uint32
>
> Example:
> brightness-levels = <10>;
> default-brightness-level = <6>;
>
> What do you think about this solution?

If you want to introduce a brightness-levels property then I would
expect it to be defined with the same meaning as pwm-backlight (it's not
relevant to the bindings but ideally it would be implemented by
refactoring and reusing the code from pwm_bl.c).

Same with default-brightness-level although I'm not sure why one
wouldn't just use default-brightness for new bindings (doesn't
default-brightness-level simply do exactly the same thing as
default-brightness).


Daniel.


Re: [PATCH v3 1/2] dt-bindings: backlight: Add MPS MP3309C

2023-09-26 Thread Daniel Thompson
On Mon, Sep 25, 2023 at 02:26:08PM +0200, Flavio Suligoi wrote:
> The Monolithic Power (MPS) MP3309C is a WLED step-up converter, featuring a
> programmable switching frequency to optimize efficiency.
> The brightness can be controlled either by I2C commands (called "analog"
> mode) or by a PWM input signal (PWM mode).
> This driver supports both modes.
>
> For device driver details, please refer to:
> - drivers/video/backlight/mp3309c_bl.c
>
> The datasheet is available at:
> - https://www.monolithicpower.com/en/mp3309c.html
>
> Signed-off-by: Flavio Suligoi 
> Reviewed-by: Rob Herring 
> ---
>
> v3:
>  - add default value for mps,overvoltage-protection-microvolt property
>  - fix the example, changing from "mps,mp3309c-backlight" to "mps,mp3309c" in
>compatible property
> v2:
>  - remove useless properties (dimming-mode, pinctrl-names, pinctrl-0,
>switch-on-delay-ms, switch-off-delay-ms, reset-gpios, reset-on-delay-ms,
>reset-on-length-ms)
>  - add common.yaml#
>  - remove already included properties (default-brightness, max-brightness)
>  - substitute three boolean properties, used for the overvoltage-protection
>values, with a single enum property
>  - remove some conditional definitions
>  - remove the 2nd example
> v1:
>  - first version
>
>  .../bindings/leds/backlight/mps,mp3309c.yaml  | 73 +++
>  1 file changed, 73 insertions(+)
>  create mode 100644 
> Documentation/devicetree/bindings/leds/backlight/mps,mp3309c.yaml
>
> diff --git 
> a/Documentation/devicetree/bindings/leds/backlight/mps,mp3309c.yaml 
> b/Documentation/devicetree/bindings/leds/backlight/mps,mp3309c.yaml
> new file mode 100644
> index ..4191e33626f5
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/leds/backlight/mps,mp3309c.yaml
> @@ -0,0 +1,73 @@
> +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/leds/backlight/mps,mp3309c.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: MPS MP3309C backlight
> +
> +maintainers:
> +  - Flavio Suligoi 
> +
> +description: |
> +  The Monolithic Power (MPS) MP3309C is a WLED step-up converter, featuring a
> +  programmable switching frequency to optimize efficiency.
> +  It supports two different dimming modes:
> +
> +  - analog mode, via I2C commands (default)
> +  - PWM controlled mode.
> +
> +  The datasheet is available at:
> +  https://www.monolithicpower.com/en/mp3309c.html
> +
> +allOf:
> +  - $ref: common.yaml#
> +
> +properties:
> +  compatible:
> +const: mps,mp3309c
> +
> +  reg:
> +maxItems: 1
> +
> +  pwms:
> +description: if present, the backlight is controlled in PWM mode.
> +maxItems: 1
> +
> +  enable-gpios:
> +description: GPIO used to enable the backlight in "analog-i2c" dimming 
> mode.
> +maxItems: 1
> +
> +  mps,overvoltage-protection-microvolt:
> +description: Overvoltage protection (13.5V, 24V or 35.5V).
> +enum: [ 1350, 2400, 3550 ]
> +default: 3550
> +
> +  mps,no-sync-mode:
> +description: disable synchronous rectification mode
> +type: boolean
> +
> +required:
> +  - compatible
> +  - reg
> +  - max-brightness

Why is this mandatory?

There's no point in setting max-brightness when running in I2C mode
(max-brightness should default to 31 in that case).


> +  - default-brightness

Again. I'm not clear why this needs to be mandatory.


Daniel.