mbox series

[v1,0/2] leds: add aw20xx driver

Message ID 20221124204807.1593241-1-mmkurbanov@sberdevices.ru
Headers show
Series leds: add aw20xx driver | expand

Message

Martin Kurbanov Nov. 24, 2022, 8:48 p.m. UTC
This patch series adds support for AWINIC AW20036/AW20054/AW20072 LED
driver programmed via an I2C interface.

This driver supports following AW200XX features:
  - 3 pattern controllers for auto breathing or group dimming control
  - Individual 64-level DIM currents
  - Interrupt output, low active

Datasheet:
  aw20036 - https://www.awinic.com/Public/Uploads/uploadfile/files/20200509/20200509151532_5eb65894d205a.pdf
  aw20054 - https://www.awinic.com/Public/Uploads/uploadfile/files/20200509/20200509151602_5eb658b2b77cb.pdf
  aw20072 - https://www.awinic.com/Public/Uploads/uploadfile/files/20200509/20200509151754_5eb659227a145.pdf

Add YAML dt-binding schema for AW200XX.

Martin Kurbanov (2):
  dt-bindings: leds: add binding for aw200xx
  leds: add aw20xx driver

 .../bindings/leds/leds-aw200xx.yaml           |  110 ++
 Documentation/leds/leds-aw200xx.rst           |  274 ++++
 drivers/leds/Kconfig                          |   10 +
 drivers/leds/Makefile                         |    1 +
 drivers/leds/leds-aw200xx.c                   | 1113 +++++++++++++++++
 include/dt-bindings/leds/leds-aw200xx.h       |   48 +
 6 files changed, 1556 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/leds/leds-aw200xx.yaml
 create mode 100644 Documentation/leds/leds-aw200xx.rst
 create mode 100644 drivers/leds/leds-aw200xx.c
 create mode 100644 include/dt-bindings/leds/leds-aw200xx.h

--
2.38.1

Comments

Martin Kurbanov Nov. 28, 2022, 5:43 p.m. UTC | #1
Hi. Thank you for quick reply. 

On 25.11.2022 11:29, Krzysztof Kozlowski wrote:
>> +
>> +  imax:
>> +    maxItems: 1
>> +    description:
>> +      Maximum supply current, see dt-bindings/leds/leds-aw200xx.h
> 
> No. Use existing properties from common.yaml. This looks like
> led-max-microamp and it is per LED, not per entire device.

The AW200XX LED chip does not support imax setup per led.
Imax is the global parameter over the all leds. I suppose, it's better
to add vendor prefix or take minimum from all subnodes?
How do you think?


>> +/* Global max current (IMAX) */
>> +#define AW200XX_IMAX_3_3MA  8
>> +#define AW200XX_IMAX_6_7MA  9
> 
> No. Bindings are not for storing register constants. Feel free to store
> here IDs (ID start from 0 or 1 and is incremented by 1)... but how the
> IMAX even matches any need for "ID"?

IMAX can be chosen from the predefined values in the
datasheet (10mA, 20mA, etc). Do you mean the IMAX should be round down
to nearest supported value in the driver?
Krzysztof Kozlowski Dec. 2, 2022, 4:41 p.m. UTC | #2
On 28/11/2022 18:43, Martin Kurbanov wrote:
> Hi. Thank you for quick reply. 
> 
> On 25.11.2022 11:29, Krzysztof Kozlowski wrote:
>>> +
>>> +  imax:
>>> +    maxItems: 1
>>> +    description:
>>> +      Maximum supply current, see dt-bindings/leds/leds-aw200xx.h
>>
>> No. Use existing properties from common.yaml. This looks like
>> led-max-microamp and it is per LED, not per entire device.
> 
> The AW200XX LED chip does not support imax setup per led.
> Imax is the global parameter over the all leds. I suppose, it's better
> to add vendor prefix or take minimum from all subnodes?
> How do you think?

Have in mind that led-max-microamp is a required property in some cases,
so skipping it and using per-device properties does not solve the
problem of adjusting proper currents. What if each LED you set for
something which in total gives more than your imax?

> 
> 
>>> +/* Global max current (IMAX) */
>>> +#define AW200XX_IMAX_3_3MA  8
>>> +#define AW200XX_IMAX_6_7MA  9
>>
>> No. Bindings are not for storing register constants. Feel free to store
>> here IDs (ID start from 0 or 1 and is incremented by 1)... but how the
>> IMAX even matches any need for "ID"?
> 
> IMAX can be chosen from the predefined values in the
> datasheet (10mA, 20mA, etc). Do you mean the IMAX should be round down
> to nearest supported value in the driver?

What Linux driver support does not matter here. Bindings should reflect
hardware and the same time not store register constants but logical
values (for current this is in uA).

Best regards,
Krzysztof
Dmitry Rokosov Dec. 2, 2022, 6:53 p.m. UTC | #3
Hello Krzysztof,

On Fri, Dec 02, 2022 at 05:41:37PM +0100, Krzysztof Kozlowski wrote:
> On 28/11/2022 18:43, Martin Kurbanov wrote:
> > Hi. Thank you for quick reply. 
> > 
> > On 25.11.2022 11:29, Krzysztof Kozlowski wrote:
> >>> +
> >>> +  imax:
> >>> +    maxItems: 1
> >>> +    description:
> >>> +      Maximum supply current, see dt-bindings/leds/leds-aw200xx.h
> >>
> >> No. Use existing properties from common.yaml. This looks like
> >> led-max-microamp and it is per LED, not per entire device.
> > 
> > The AW200XX LED chip does not support imax setup per led.
> > Imax is the global parameter over the all leds. I suppose, it's better
> > to add vendor prefix or take minimum from all subnodes?
> > How do you think?
> 
> Have in mind that led-max-microamp is a required property in some cases,
> so skipping it and using per-device properties does not solve the
> problem of adjusting proper currents. What if each LED you set for
> something which in total gives more than your imax?
> 

You are right. From my point of view too, we must build our solutions from
HW capabilities. In the current situation, AW200XX chips support global
Imax value, so it's acceptable decision to use vendor prefix for global
imax parameter, why not?

...
Krzysztof Kozlowski Dec. 3, 2022, 10:44 a.m. UTC | #4
On 02/12/2022 19:53, Dmitry Rokosov wrote:
> Hello Krzysztof,
> 
> On Fri, Dec 02, 2022 at 05:41:37PM +0100, Krzysztof Kozlowski wrote:
>> On 28/11/2022 18:43, Martin Kurbanov wrote:
>>> Hi. Thank you for quick reply. 
>>>
>>> On 25.11.2022 11:29, Krzysztof Kozlowski wrote:
>>>>> +
>>>>> +  imax:
>>>>> +    maxItems: 1
>>>>> +    description:
>>>>> +      Maximum supply current, see dt-bindings/leds/leds-aw200xx.h
>>>>
>>>> No. Use existing properties from common.yaml. This looks like
>>>> led-max-microamp and it is per LED, not per entire device.
>>>
>>> The AW200XX LED chip does not support imax setup per led.
>>> Imax is the global parameter over the all leds. I suppose, it's better
>>> to add vendor prefix or take minimum from all subnodes?
>>> How do you think?
>>
>> Have in mind that led-max-microamp is a required property in some cases,
>> so skipping it and using per-device properties does not solve the
>> problem of adjusting proper currents. What if each LED you set for
>> something which in total gives more than your imax?
>>
> 
> You are right. From my point of view too, we must build our solutions from
> HW capabilities. 

And there was no proposal to go around HW capabilities. We talk only
about representation.

> In the current situation, AW200XX chips support global
> Imax value, so it's acceptable decision to use vendor prefix for global
> imax parameter, why not?

Jacek made his statement some time ago quite clear:

https://lore.kernel.org/all/5785F17D.3010108@samsung.com/

"If you question the idea of having different maximum brightness per
sub-LEDs controlled by the same device, then it means that you have
objections to the entire idea of LED subsystem max_brightness property,
whereas it has been broadly accepted and successfully used for years."

Best regards,
Krzysztof