diff mbox

[V2,1/2] dt-bindings: leds: document new led-triggers property

Message ID 20170120215605.15728-1-zajec5@gmail.com
State Superseded, archived
Headers show

Commit Message

Rafał Miłecki Jan. 20, 2017, 9:56 p.m. UTC
From: Rafał Miłecki <rafal@milecki.pl>

Some LEDs can be related to particular devices described in DT. This
property allows specifying such relations. E.g. USB LED should usually
be used to indicate some USB port(s) state.

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
---
V2: Replace "usb-ports" with "led-triggers" property which is more generic and
    allows specifying other devices as well.

When bindings patch is related to some followup implementation, they usually go
through the same tree.

Greg: this patch is based on top of e64b8cc72bf9 ("DT: leds: Improve examples by
adding some context") from kernel/git/j.anaszewski/linux-leds.git . Is there any
way to solve this dependency issue? Or should this patch wait until 3.11 is
released?
---
 Documentation/devicetree/bindings/leds/common.txt | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

Comments

Jacek Anaszewski Jan. 20, 2017, 10:35 p.m. UTC | #1
Hi Rafał,

On 01/20/2017 10:56 PM, Rafał Miłecki wrote:
> From: Rafał Miłecki <rafal@milecki.pl>
> 
> Some LEDs can be related to particular devices described in DT. This
> property allows specifying such relations. E.g. USB LED should usually
> be used to indicate some USB port(s) state.
> 
> Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
> ---
> V2: Replace "usb-ports" with "led-triggers" property which is more generic and
>     allows specifying other devices as well.
> 
> When bindings patch is related to some followup implementation, they usually go
> through the same tree.
> 
> Greg: this patch is based on top of e64b8cc72bf9 ("DT: leds: Improve examples by
> adding some context") from kernel/git/j.anaszewski/linux-leds.git . Is there any
> way to solve this dependency issue? Or should this patch wait until 3.11 is
> released?
> ---
>  Documentation/devicetree/bindings/leds/common.txt | 16 ++++++++++++++++
>  1 file changed, 16 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/leds/common.txt b/Documentation/devicetree/bindings/leds/common.txt
> index 24b656014089..17632a041196 100644
> --- a/Documentation/devicetree/bindings/leds/common.txt
> +++ b/Documentation/devicetree/bindings/leds/common.txt
> @@ -49,6 +49,17 @@ Optional properties for child nodes:
>  - panic-indicator : This property specifies that the LED should be used,
>  		    if at all possible, as a panic indicator.
>  
> +- led-triggers : List of devices that should trigger this LED activity. Some
> +		 LEDs can be related to a specific device and should somehow
> +		 indicate its state. E.g. USB 2.0 LED may react to device(s) in
> +		 a USB 2.0 port(s). Another common example is switch or router
> +		 with multiple Ethernet ports each of them having its own LED
> +		 assigned (assuminled-trigger-usbportg they are not hardwired).
> +		 In such cases this property should contain phandle(s) of
> +		 related device(s). In many cases LED can be related to more
> +		 than one device (e.g. one USB LED vs. multiple USB ports) so a
> +		 list of entries can be specified.
> +

This implies that it is possible to define multiple triggers for
a LED class device but it is not supported by LED Trigger core.
There is linux,default-trigger property which allows to define one
trigger that will be initially assigned.

I am aware that this is renamed usb-ports property from v1,
that attempts to address Rob's comment, but we can't do that this way.
Maybe usb-ports property could be documented in led-trigger-usbport's
specific bindings and a reference to it could be added next to the
related entry on the list of the available LED triggers (which is
actually missing) in Documentation/devicetree/bindings/leds/common.txt.

>  Required properties for flash LED child nodes:
>  - flash-max-microamp : Maximum flash LED supply current in microamperes.
>  - flash-max-timeout-us : Maximum timeout in microseconds after which the flash
> @@ -69,6 +80,11 @@ gpio-leds {
>  		linux,default-trigger = "heartbeat";
>  		gpios = <&gpio0 0 GPIO_ACTIVE_HIGH>;
>  	};
> +
> +	usb {
> +		gpios = <&gpio0 1 GPIO_ACTIVE_HIGH>;
> +		led-triggers = <&ohci_port1>, <&ehci_port1>;
> +	};
>  };
>  
>  max77693-led {
>
Rafał Miłecki Jan. 21, 2017, 4:24 p.m. UTC | #2
On 20 January 2017 at 23:35, Jacek Anaszewski
<jacek.anaszewski@gmail.com> wrote:
> On 01/20/2017 10:56 PM, Rafał Miłecki wrote:
>> From: Rafał Miłecki <rafal@milecki.pl>
>>
>> Some LEDs can be related to particular devices described in DT. This
>> property allows specifying such relations. E.g. USB LED should usually
>> be used to indicate some USB port(s) state.
>>
>> Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
>> ---
>> V2: Replace "usb-ports" with "led-triggers" property which is more generic and
>>     allows specifying other devices as well.
>>
>> When bindings patch is related to some followup implementation, they usually go
>> through the same tree.
>>
>> Greg: this patch is based on top of e64b8cc72bf9 ("DT: leds: Improve examples by
>> adding some context") from kernel/git/j.anaszewski/linux-leds.git . Is there any
>> way to solve this dependency issue? Or should this patch wait until 3.11 is
>> released?
>> ---
>>  Documentation/devicetree/bindings/leds/common.txt | 16 ++++++++++++++++
>>  1 file changed, 16 insertions(+)
>>
>> diff --git a/Documentation/devicetree/bindings/leds/common.txt b/Documentation/devicetree/bindings/leds/common.txt
>> index 24b656014089..17632a041196 100644
>> --- a/Documentation/devicetree/bindings/leds/common.txt
>> +++ b/Documentation/devicetree/bindings/leds/common.txt
>> @@ -49,6 +49,17 @@ Optional properties for child nodes:
>>  - panic-indicator : This property specifies that the LED should be used,
>>                   if at all possible, as a panic indicator.
>>
>> +- led-triggers : List of devices that should trigger this LED activity. Some
>> +              LEDs can be related to a specific device and should somehow
>> +              indicate its state. E.g. USB 2.0 LED may react to device(s) in
>> +              a USB 2.0 port(s). Another common example is switch or router
>> +              with multiple Ethernet ports each of them having its own LED
>> +              assigned (assuminled-trigger-usbportg they are not hardwired).
>> +              In such cases this property should contain phandle(s) of
>> +              related device(s). In many cases LED can be related to more
>> +              than one device (e.g. one USB LED vs. multiple USB ports) so a
>> +              list of entries can be specified.
>> +
>
> This implies that it is possible to define multiple triggers for
> a LED class device but it is not supported by LED Trigger core.
> There is linux,default-trigger property which allows to define one
> trigger that will be initially assigned.

I think we owe some extra explanation to people not closely familiar
with the triggers.

Linux has multiple trigger drivers each supporting some *type* of
events. Linux supports assigning only one trigger driver to LED at a
time.
This means you can use e.g.:
1) "usbport" trigger driver that supports USB events
XOR
2) "timer" trigger driver that uses timer to control LED
XOR
3) "cpu" trigger driver that supports CPU events
at once.

With proposed "led-triggers" property one could assign different
trigger *sources* to a LED. You could e.g. assign 2 USB ports, network
device & CPU to a single LED. For reason explained above Linux
couldn't support all of them at once.


> I am aware that this is renamed usb-ports property from v1,
> that attempts to address Rob's comment, but we can't do that this way.
> Maybe usb-ports property could be documented in led-trigger-usbport's
> specific bindings and a reference to it could be added next to the
> related entry on the list of the available LED triggers (which is
> actually missing) in Documentation/devicetree/bindings/leds/common.txt.

I'm wondering if we need to care about this Linux limitation and if it
should stop us from adding this flexible DT property. Maybe we could
live with Linux having limitation of supporting one trigger type at a
time? So e.g. if one assigns 2 USB ports + network device + CPU and
decides to use "usport" trigger driver he'll get LED indicating status
of USB ports only.

I think we could live with such limitation in Linux support for this
generic "led-triggers" property. I think it's also not very common to
have LED with different types of devices assigned. Personally I've
never seen devices with LED label "USB & CPU" or whatever.

What do you think about this? Maybe we could also document this
limitation in trigger docs.
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Jacek Anaszewski Jan. 21, 2017, 9:42 p.m. UTC | #3
On 01/21/2017 05:24 PM, Rafał Miłecki wrote:
> On 20 January 2017 at 23:35, Jacek Anaszewski
> <jacek.anaszewski@gmail.com> wrote:
>> On 01/20/2017 10:56 PM, Rafał Miłecki wrote:
>>> From: Rafał Miłecki <rafal@milecki.pl>
>>>
>>> Some LEDs can be related to particular devices described in DT. This
>>> property allows specifying such relations. E.g. USB LED should usually
>>> be used to indicate some USB port(s) state.
>>>
>>> Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
>>> ---
>>> V2: Replace "usb-ports" with "led-triggers" property which is more generic and
>>>     allows specifying other devices as well.
>>>
>>> When bindings patch is related to some followup implementation, they usually go
>>> through the same tree.
>>>
>>> Greg: this patch is based on top of e64b8cc72bf9 ("DT: leds: Improve examples by
>>> adding some context") from kernel/git/j.anaszewski/linux-leds.git . Is there any
>>> way to solve this dependency issue? Or should this patch wait until 3.11 is
>>> released?
>>> ---
>>>  Documentation/devicetree/bindings/leds/common.txt | 16 ++++++++++++++++
>>>  1 file changed, 16 insertions(+)
>>>
>>> diff --git a/Documentation/devicetree/bindings/leds/common.txt b/Documentation/devicetree/bindings/leds/common.txt
>>> index 24b656014089..17632a041196 100644
>>> --- a/Documentation/devicetree/bindings/leds/common.txt
>>> +++ b/Documentation/devicetree/bindings/leds/common.txt
>>> @@ -49,6 +49,17 @@ Optional properties for child nodes:
>>>  - panic-indicator : This property specifies that the LED should be used,
>>>                   if at all possible, as a panic indicator.
>>>
>>> +- led-triggers : List of devices that should trigger this LED activity. Some
>>> +              LEDs can be related to a specific device and should somehow
>>> +              indicate its state. E.g. USB 2.0 LED may react to device(s) in
>>> +              a USB 2.0 port(s). Another common example is switch or router
>>> +              with multiple Ethernet ports each of them having its own LED
>>> +              assigned (assuminled-trigger-usbportg they are not hardwired).
>>> +              In such cases this property should contain phandle(s) of
>>> +              related device(s). In many cases LED can be related to more
>>> +              than one device (e.g. one USB LED vs. multiple USB ports) so a
>>> +              list of entries can be specified.
>>> +
>>
>> This implies that it is possible to define multiple triggers for
>> a LED class device but it is not supported by LED Trigger core.
>> There is linux,default-trigger property which allows to define one
>> trigger that will be initially assigned.
> 
> I think we owe some extra explanation to people not closely familiar
> with the triggers.
> 
> Linux has multiple trigger drivers each supporting some *type* of
> events. Linux supports assigning only one trigger driver to LED at a
> time.
> This means you can use e.g.:
> 1) "usbport" trigger driver that supports USB events
> XOR
> 2) "timer" trigger driver that uses timer to control LED
> XOR
> 3) "cpu" trigger driver that supports CPU events
> at once.

Correct.

> With proposed "led-triggers" property one could assign different
> trigger *sources* to a LED. You could e.g. assign 2 USB ports, network
> device & CPU to a single LED. For reason explained above Linux
> couldn't support all of them at once.
> 
> 
>> I am aware that this is renamed usb-ports property from v1,
>> that attempts to address Rob's comment, but we can't do that this way.
>> Maybe usb-ports property could be documented in led-trigger-usbport's
>> specific bindings and a reference to it could be added next to the
>> related entry on the list of the available LED triggers (which is
>> actually missing) in Documentation/devicetree/bindings/leds/common.txt.
> 
> I'm wondering if we need to care about this Linux limitation and if it
> should stop us from adding this flexible DT property. Maybe we could
> live with Linux having limitation of supporting one trigger type at a
> time?

That's what I meant. Generally I have objections to the generic
property for defining list of allowed triggers. That's why I proposed
to stay by usb-ports property that would be specific to only one
trigger: led-trigger-usbport.

led-trigger-usbport in fact is an entirely new type of LED trigger.
LED triggers is a kernel based source of events. All existing triggers
react only to a single, well defined source of events, whereas
led-trigger-usbport allows to define the scope of events (usb ports)
to notify about. Activity on each port is treated similarly and the LED
class device that listens to the trigger notifications doesn't know
which exact port triggered the notification.

>From this POV led-trigger-usbport is kind of facade, which allows
for it to fit well into the LED Trigger design and API, and usb ports
are not identical with LED triggers, but sit rather one level below.
It is led-trigger-usbport which is visible to the LED subsystem, and
not every single usb port.

Therefore it isn't logically justified to rename usb-ports property
to led-triggers. The property should be specific to this trigger.

> So e.g. if one assigns 2 USB ports + network device + CPU and
> decides to use "usport" trigger driver he'll get LED indicating status
> of USB ports only.

How would it be different from the current state? Only in limiting
the scope of triggers available for a LED class device.

> I think we could live with such limitation in Linux support for this
> generic "led-triggers" property. I think it's also not very common to
> have LED with different types of devices assigned. Personally I've
> never seen devices with LED label "USB & CPU" or whatever.

I agree. Nonetheless led-triggers seems to support such a design.

> What do you think about this? Maybe we could also document this
> limitation in trigger docs.

I'm not entirely sure if I got your point. Your reasoning seems
self contradicting to me in few places.
Rob Herring Jan. 23, 2017, 4:45 p.m. UTC | #4
On Fri, Jan 20, 2017 at 11:35:20PM +0100, Jacek Anaszewski wrote:
> Hi Rafał,
> 
> On 01/20/2017 10:56 PM, Rafał Miłecki wrote:
> > From: Rafał Miłecki <rafal@milecki.pl>
> > 
> > Some LEDs can be related to particular devices described in DT. This
> > property allows specifying such relations. E.g. USB LED should usually
> > be used to indicate some USB port(s) state.
> > 
> > Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
> > ---
> > V2: Replace "usb-ports" with "led-triggers" property which is more generic and
> >     allows specifying other devices as well.
> > 
> > When bindings patch is related to some followup implementation, they usually go
> > through the same tree.
> > 
> > Greg: this patch is based on top of e64b8cc72bf9 ("DT: leds: Improve examples by
> > adding some context") from kernel/git/j.anaszewski/linux-leds.git . Is there any
> > way to solve this dependency issue? Or should this patch wait until 3.11 is
> > released?
> > ---
> >  Documentation/devicetree/bindings/leds/common.txt | 16 ++++++++++++++++
> >  1 file changed, 16 insertions(+)
> > 
> > diff --git a/Documentation/devicetree/bindings/leds/common.txt b/Documentation/devicetree/bindings/leds/common.txt
> > index 24b656014089..17632a041196 100644
> > --- a/Documentation/devicetree/bindings/leds/common.txt
> > +++ b/Documentation/devicetree/bindings/leds/common.txt
> > @@ -49,6 +49,17 @@ Optional properties for child nodes:
> >  - panic-indicator : This property specifies that the LED should be used,
> >  		    if at all possible, as a panic indicator.
> >  
> > +- led-triggers : List of devices that should trigger this LED activity. Some
> > +		 LEDs can be related to a specific device and should somehow
> > +		 indicate its state. E.g. USB 2.0 LED may react to device(s) in
> > +		 a USB 2.0 port(s). Another common example is switch or router
> > +		 with multiple Ethernet ports each of them having its own LED
> > +		 assigned (assuminled-trigger-usbportg they are not hardwired).
> > +		 In such cases this property should contain phandle(s) of
> > +		 related device(s). In many cases LED can be related to more
> > +		 than one device (e.g. one USB LED vs. multiple USB ports) so a
> > +		 list of entries can be specified.
> > +
> 
> This implies that it is possible to define multiple triggers for
> a LED class device but it is not supported by LED Trigger core.

Not really relevant for designing (and future proofing) a binding.

> There is linux,default-trigger property which allows to define one
> trigger that will be initially assigned.
> 
> I am aware that this is renamed usb-ports property from v1,
> that attempts to address Rob's comment, but we can't do that this way.
> Maybe usb-ports property could be documented in led-trigger-usbport's
> specific bindings and a reference to it could be added next to the
> related entry on the list of the available LED triggers (which is
> actually missing) in Documentation/devicetree/bindings/leds/common.txt.

I'm not going to accept something specific to USB. So the choice is make 
the existing property work for USB or design something more flexible and 
generic.

Rob
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Jacek Anaszewski Jan. 23, 2017, 8:51 p.m. UTC | #5
On 01/23/2017 05:45 PM, Rob Herring wrote:
> On Fri, Jan 20, 2017 at 11:35:20PM +0100, Jacek Anaszewski wrote:
>> Hi Rafał,
>>
>> On 01/20/2017 10:56 PM, Rafał Miłecki wrote:
>>> From: Rafał Miłecki <rafal@milecki.pl>
>>>
>>> Some LEDs can be related to particular devices described in DT. This
>>> property allows specifying such relations. E.g. USB LED should usually
>>> be used to indicate some USB port(s) state.
>>>
>>> Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
>>> ---
>>> V2: Replace "usb-ports" with "led-triggers" property which is more generic and
>>>     allows specifying other devices as well.
>>>
>>> When bindings patch is related to some followup implementation, they usually go
>>> through the same tree.
>>>
>>> Greg: this patch is based on top of e64b8cc72bf9 ("DT: leds: Improve examples by
>>> adding some context") from kernel/git/j.anaszewski/linux-leds.git . Is there any
>>> way to solve this dependency issue? Or should this patch wait until 3.11 is
>>> released?
>>> ---
>>>  Documentation/devicetree/bindings/leds/common.txt | 16 ++++++++++++++++
>>>  1 file changed, 16 insertions(+)
>>>
>>> diff --git a/Documentation/devicetree/bindings/leds/common.txt b/Documentation/devicetree/bindings/leds/common.txt
>>> index 24b656014089..17632a041196 100644
>>> --- a/Documentation/devicetree/bindings/leds/common.txt
>>> +++ b/Documentation/devicetree/bindings/leds/common.txt
>>> @@ -49,6 +49,17 @@ Optional properties for child nodes:
>>>  - panic-indicator : This property specifies that the LED should be used,
>>>  		    if at all possible, as a panic indicator.
>>>  
>>> +- led-triggers : List of devices that should trigger this LED activity. Some
>>> +		 LEDs can be related to a specific device and should somehow
>>> +		 indicate its state. E.g. USB 2.0 LED may react to device(s) in
>>> +		 a USB 2.0 port(s). Another common example is switch or router
>>> +		 with multiple Ethernet ports each of them having its own LED
>>> +		 assigned (assuminled-trigger-usbportg they are not hardwired).
>>> +		 In such cases this property should contain phandle(s) of
>>> +		 related device(s). In many cases LED can be related to more
>>> +		 than one device (e.g. one USB LED vs. multiple USB ports) so a
>>> +		 list of entries can be specified.
>>> +
>>
>> This implies that it is possible to define multiple triggers for
>> a LED class device but it is not supported by LED Trigger core.
> 
> Not really relevant for designing (and future proofing) a binding.

But relevant for LED Trigger ABI, which would have to be changed to
support the semantics in this form. I think that changing the property
name to linux,trigger-sources would make its purpose more clear.

Note that we have to also associate somehow this property with the
triggers that will make use of the information it provides. I can
imagine also other compound triggers that could benefit on it.

What follows, the trigger sources would trigger LED activity only
if the LED class device was assigned appropriate trigger. We need to
define somewhere which triggers support this property.

Trigger specific bindings?

>> There is linux,default-trigger property which allows to define one
>> trigger that will be initially assigned.
>>
>> I am aware that this is renamed usb-ports property from v1,
>> that attempts to address Rob's comment, but we can't do that this way.
>> Maybe usb-ports property could be documented in led-trigger-usbport's
>> specific bindings and a reference to it could be added next to the
>> related entry on the list of the available LED triggers (which is
>> actually missing) in Documentation/devicetree/bindings/leds/common.txt.
> 
> I'm not going to accept something specific to USB. So the choice is make 
> the existing property work for USB or design something more flexible and 
> generic.
Rafał Miłecki Jan. 25, 2017, 9:03 a.m. UTC | #6
On 21 January 2017 at 22:42, Jacek Anaszewski
<jacek.anaszewski@gmail.com> wrote:
> On 01/21/2017 05:24 PM, Rafał Miłecki wrote:
>> On 20 January 2017 at 23:35, Jacek Anaszewski
>> <jacek.anaszewski@gmail.com> wrote:
>>> On 01/20/2017 10:56 PM, Rafał Miłecki wrote:
>>>> From: Rafał Miłecki <rafal@milecki.pl>
>>>>
>>>> Some LEDs can be related to particular devices described in DT. This
>>>> property allows specifying such relations. E.g. USB LED should usually
>>>> be used to indicate some USB port(s) state.
>>>>
>>>> Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
>>>> ---
>>>> V2: Replace "usb-ports" with "led-triggers" property which is more generic and
>>>>     allows specifying other devices as well.
>>>>
>>>> When bindings patch is related to some followup implementation, they usually go
>>>> through the same tree.
>>>>
>>>> Greg: this patch is based on top of e64b8cc72bf9 ("DT: leds: Improve examples by
>>>> adding some context") from kernel/git/j.anaszewski/linux-leds.git . Is there any
>>>> way to solve this dependency issue? Or should this patch wait until 3.11 is
>>>> released?
>>>> ---
>>>>  Documentation/devicetree/bindings/leds/common.txt | 16 ++++++++++++++++
>>>>  1 file changed, 16 insertions(+)
>>>>
>>>> diff --git a/Documentation/devicetree/bindings/leds/common.txt b/Documentation/devicetree/bindings/leds/common.txt
>>>> index 24b656014089..17632a041196 100644
>>>> --- a/Documentation/devicetree/bindings/leds/common.txt
>>>> +++ b/Documentation/devicetree/bindings/leds/common.txt
>>>> @@ -49,6 +49,17 @@ Optional properties for child nodes:
>>>>  - panic-indicator : This property specifies that the LED should be used,
>>>>                   if at all possible, as a panic indicator.
>>>>
>>>> +- led-triggers : List of devices that should trigger this LED activity. Some
>>>> +              LEDs can be related to a specific device and should somehow
>>>> +              indicate its state. E.g. USB 2.0 LED may react to device(s) in
>>>> +              a USB 2.0 port(s). Another common example is switch or router
>>>> +              with multiple Ethernet ports each of them having its own LED
>>>> +              assigned (assuminled-trigger-usbportg they are not hardwired).
>>>> +              In such cases this property should contain phandle(s) of
>>>> +              related device(s). In many cases LED can be related to more
>>>> +              than one device (e.g. one USB LED vs. multiple USB ports) so a
>>>> +              list of entries can be specified.
>>>> +
>>>
>>> This implies that it is possible to define multiple triggers for
>>> a LED class device but it is not supported by LED Trigger core.
>>> There is linux,default-trigger property which allows to define one
>>> trigger that will be initially assigned.
>
>> With proposed "led-triggers" property one could assign different
>> trigger *sources* to a LED. You could e.g. assign 2 USB ports, network
>> device & CPU to a single LED. For reason explained above Linux
>> couldn't support all of them at once.
>>
>>
>>> I am aware that this is renamed usb-ports property from v1,
>>> that attempts to address Rob's comment, but we can't do that this way.
>>> Maybe usb-ports property could be documented in led-trigger-usbport's
>>> specific bindings and a reference to it could be added next to the
>>> related entry on the list of the available LED triggers (which is
>>> actually missing) in Documentation/devicetree/bindings/leds/common.txt.
>>
>> I'm wondering if we need to care about this Linux limitation and if it
>> should stop us from adding this flexible DT property. Maybe we could
>> live with Linux having limitation of supporting one trigger type at a
>> time?
>
> That's what I meant. Generally I have objections to the generic
> property for defining list of allowed triggers. That's why I proposed
> to stay by usb-ports property that would be specific to only one
> trigger: led-trigger-usbport.
>
> led-trigger-usbport in fact is an entirely new type of LED trigger.
> LED triggers is a kernel based source of events. All existing triggers
> react only to a single, well defined source of events, whereas
> led-trigger-usbport allows to define the scope of events (usb ports)
> to notify about. Activity on each port is treated similarly and the LED
> class device that listens to the trigger notifications doesn't know
> which exact port triggered the notification.
>
> From this POV led-trigger-usbport is kind of facade, which allows
> for it to fit well into the LED Trigger design and API, and usb ports
> are not identical with LED triggers, but sit rather one level below.
> It is led-trigger-usbport which is visible to the LED subsystem, and
> not every single usb port.

I of course agree with your nice usbport trigger driver summary.


> Therefore it isn't logically justified to rename usb-ports property
> to led-triggers. The property should be specific to this trigger.

Only if you mean to limit this property to the usbport trigger driver.
Rob wants to have this property cover other cases and I mean to work
on more trigger drivers using it as well. So I hope we can look at a
bigger picture focusing on a nice design that will allow reusing this
property in other places.

I'd like to work on netdev / netif / netiface trigger driver in the
future. I was going to use this DT property there as well.

Sorry, I should have make it clear from the beginning I mean to re-use
"led-triggers" in other trigger drivers as well.


>> So e.g. if one assigns 2 USB ports + network device + CPU and
>> decides to use "usport" trigger driver he'll get LED indicating status
>> of USB ports only.
>
> How would it be different from the current state? Only in limiting
> the scope of triggers available for a LED class device.

It won't differ from the current state. I just wanted to make it clear
Linux trigger drivers may respect only selected "led-triggers" values
(phandles). Like "usbport" respecting USB port phandles but ignoring
CPU ones, net ones, etc.


>> I think we could live with such limitation in Linux support for this
>> generic "led-triggers" property. I think it's also not very common to
>> have LED with different types of devices assigned. Personally I've
>> never seen devices with LED label "USB & CPU" or whatever.
>
> I agree. Nonetheless led-triggers seems to support such a design.

That's right. DT property "led-triggers" supports by design more than
Linux drivers can handle right now. That was my main point of this
e-mail.


>> What do you think about this? Maybe we could also document this
>> limitation in trigger docs.
>
> I'm not entirely sure if I got your point. Your reasoning seems
> self contradicting to me in few places.

I'm sorry, I obviously had to fail at some point explaining my idea.
Let's see if this e-mail made it clearer.
Rafał Miłecki Jan. 25, 2017, 9:08 a.m. UTC | #7
On 01/23/2017 05:45 PM, Rob Herring wrote:
> On Fri, Jan 20, 2017 at 11:35:20PM +0100, Jacek Anaszewski wrote:
>> Hi Rafał,
>>
>> On 01/20/2017 10:56 PM, Rafał Miłecki wrote:
>>> From: Rafał Miłecki <rafal@milecki.pl>
>>>
>>> Some LEDs can be related to particular devices described in DT. This
>>> property allows specifying such relations. E.g. USB LED should usually
>>> be used to indicate some USB port(s) state.
>>>
>>> Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
>>> ---
>>> V2: Replace "usb-ports" with "led-triggers" property which is more generic and
>>>     allows specifying other devices as well.
>>>
>>> When bindings patch is related to some followup implementation, they usually go
>>> through the same tree.
>>>
>>> Greg: this patch is based on top of e64b8cc72bf9 ("DT: leds: Improve examples by
>>> adding some context") from kernel/git/j.anaszewski/linux-leds.git . Is there any
>>> way to solve this dependency issue? Or should this patch wait until 3.11 is
>>> released?
>>> ---
>>>  Documentation/devicetree/bindings/leds/common.txt | 16 ++++++++++++++++
>>>  1 file changed, 16 insertions(+)
>>>
>>> diff --git a/Documentation/devicetree/bindings/leds/common.txt b/Documentation/devicetree/bindings/leds/common.txt
>>> index 24b656014089..17632a041196 100644
>>> --- a/Documentation/devicetree/bindings/leds/common.txt
>>> +++ b/Documentation/devicetree/bindings/leds/common.txt
>>> @@ -49,6 +49,17 @@ Optional properties for child nodes:
>>>  - panic-indicator : This property specifies that the LED should be used,
>>>  		    if at all possible, as a panic indicator.
>>>
>>> +- led-triggers : List of devices that should trigger this LED activity. Some
>>> +		 LEDs can be related to a specific device and should somehow
>>> +		 indicate its state. E.g. USB 2.0 LED may react to device(s) in
>>> +		 a USB 2.0 port(s). Another common example is switch or router
>>> +		 with multiple Ethernet ports each of them having its own LED
>>> +		 assigned (assuminled-trigger-usbportg they are not hardwired).
>>> +		 In such cases this property should contain phandle(s) of
>>> +		 related device(s). In many cases LED can be related to more
>>> +		 than one device (e.g. one USB LED vs. multiple USB ports) so a
>>> +		 list of entries can be specified.
>>> +
>>
>> This implies that it is possible to define multiple triggers for
>> a LED class device but it is not supported by LED Trigger core.
>
> Not really relevant for designing (and future proofing) a binding.

This is what I really like in this "led-triggers" property: it's future proof. I
will be able to reuse it in other trigger drivers and I won't be trying to sneak
properties like
* usb-port-triggers
* net-interface-triggers
* cpu-triggers
etc.

Saying that thanks Rob for rejecting my initial "usb-ports" property try :P
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Rafał Miłecki Jan. 25, 2017, 9:18 a.m. UTC | #8
On 01/23/2017 09:51 PM, Jacek Anaszewski wrote:
> On 01/23/2017 05:45 PM, Rob Herring wrote:
>> On Fri, Jan 20, 2017 at 11:35:20PM +0100, Jacek Anaszewski wrote:
>>> Hi Rafał,
>>>
>>> On 01/20/2017 10:56 PM, Rafał Miłecki wrote:
>>>> From: Rafał Miłecki <rafal@milecki.pl>
>>>>
>>>> Some LEDs can be related to particular devices described in DT. This
>>>> property allows specifying such relations. E.g. USB LED should usually
>>>> be used to indicate some USB port(s) state.
>>>>
>>>> Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
>>>> ---
>>>> V2: Replace "usb-ports" with "led-triggers" property which is more generic and
>>>>     allows specifying other devices as well.
>>>>
>>>> When bindings patch is related to some followup implementation, they usually go
>>>> through the same tree.
>>>>
>>>> Greg: this patch is based on top of e64b8cc72bf9 ("DT: leds: Improve examples by
>>>> adding some context") from kernel/git/j.anaszewski/linux-leds.git . Is there any
>>>> way to solve this dependency issue? Or should this patch wait until 3.11 is
>>>> released?
>>>> ---
>>>>  Documentation/devicetree/bindings/leds/common.txt | 16 ++++++++++++++++
>>>>  1 file changed, 16 insertions(+)
>>>>
>>>> diff --git a/Documentation/devicetree/bindings/leds/common.txt b/Documentation/devicetree/bindings/leds/common.txt
>>>> index 24b656014089..17632a041196 100644
>>>> --- a/Documentation/devicetree/bindings/leds/common.txt
>>>> +++ b/Documentation/devicetree/bindings/leds/common.txt
>>>> @@ -49,6 +49,17 @@ Optional properties for child nodes:
>>>>  - panic-indicator : This property specifies that the LED should be used,
>>>>  		    if at all possible, as a panic indicator.
>>>>
>>>> +- led-triggers : List of devices that should trigger this LED activity. Some
>>>> +		 LEDs can be related to a specific device and should somehow
>>>> +		 indicate its state. E.g. USB 2.0 LED may react to device(s) in
>>>> +		 a USB 2.0 port(s). Another common example is switch or router
>>>> +		 with multiple Ethernet ports each of them having its own LED
>>>> +		 assigned (assuminled-trigger-usbportg they are not hardwired).
>>>> +		 In such cases this property should contain phandle(s) of
>>>> +		 related device(s). In many cases LED can be related to more
>>>> +		 than one device (e.g. one USB LED vs. multiple USB ports) so a
>>>> +		 list of entries can be specified.
>>>> +
>>>
>>> This implies that it is possible to define multiple triggers for
>>> a LED class device but it is not supported by LED Trigger core.
>>
>> Not really relevant for designing (and future proofing) a binding.
>
> But relevant for LED Trigger ABI, which would have to be changed to
> support the semantics in this form. I think that changing the property
> name to linux,trigger-sources would make its purpose more clear.
>
> Note that we have to also associate somehow this property with the
> triggers that will make use of the information it provides. I can
> imagine also other compound triggers that could benefit on it.
>
> What follows, the trigger sources would trigger LED activity only
> if the LED class device was assigned appropriate trigger. We need to
> define somewhere which triggers support this property.
>
> Trigger specific bindings?

Maybe this is something I'm missing. Why adding this "led-triggers" property
would mean/require ABI breakage?

AFAIU adding support for "led-triggers" to the "usbport" trigger driver (see
patch 2/2) didn't break anything, I hope?
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Jacek Anaszewski Jan. 25, 2017, 9:04 p.m. UTC | #9
On 01/25/2017 10:03 AM, Rafał Miłecki wrote:
> On 21 January 2017 at 22:42, Jacek Anaszewski
> <jacek.anaszewski@gmail.com> wrote:
>> On 01/21/2017 05:24 PM, Rafał Miłecki wrote:
>>> On 20 January 2017 at 23:35, Jacek Anaszewski
>>> <jacek.anaszewski@gmail.com> wrote:
>>>> On 01/20/2017 10:56 PM, Rafał Miłecki wrote:
>>>>> From: Rafał Miłecki <rafal@milecki.pl>
>>>>>
>>>>> Some LEDs can be related to particular devices described in DT. This
>>>>> property allows specifying such relations. E.g. USB LED should usually
>>>>> be used to indicate some USB port(s) state.
>>>>>
>>>>> Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
>>>>> ---
>>>>> V2: Replace "usb-ports" with "led-triggers" property which is more generic and
>>>>>     allows specifying other devices as well.
>>>>>
>>>>> When bindings patch is related to some followup implementation, they usually go
>>>>> through the same tree.
>>>>>
>>>>> Greg: this patch is based on top of e64b8cc72bf9 ("DT: leds: Improve examples by
>>>>> adding some context") from kernel/git/j.anaszewski/linux-leds.git . Is there any
>>>>> way to solve this dependency issue? Or should this patch wait until 3.11 is
>>>>> released?
>>>>> ---
>>>>>  Documentation/devicetree/bindings/leds/common.txt | 16 ++++++++++++++++
>>>>>  1 file changed, 16 insertions(+)
>>>>>
>>>>> diff --git a/Documentation/devicetree/bindings/leds/common.txt b/Documentation/devicetree/bindings/leds/common.txt
>>>>> index 24b656014089..17632a041196 100644
>>>>> --- a/Documentation/devicetree/bindings/leds/common.txt
>>>>> +++ b/Documentation/devicetree/bindings/leds/common.txt
>>>>> @@ -49,6 +49,17 @@ Optional properties for child nodes:
>>>>>  - panic-indicator : This property specifies that the LED should be used,
>>>>>                   if at all possible, as a panic indicator.
>>>>>
>>>>> +- led-triggers : List of devices that should trigger this LED activity. Some
>>>>> +              LEDs can be related to a specific device and should somehow
>>>>> +              indicate its state. E.g. USB 2.0 LED may react to device(s) in
>>>>> +              a USB 2.0 port(s). Another common example is switch or router
>>>>> +              with multiple Ethernet ports each of them having its own LED
>>>>> +              assigned (assuminled-trigger-usbportg they are not hardwired).
>>>>> +              In such cases this property should contain phandle(s) of
>>>>> +              related device(s). In many cases LED can be related to more
>>>>> +              than one device (e.g. one USB LED vs. multiple USB ports) so a
>>>>> +              list of entries can be specified.
>>>>> +
>>>>
>>>> This implies that it is possible to define multiple triggers for
>>>> a LED class device but it is not supported by LED Trigger core.
>>>> There is linux,default-trigger property which allows to define one
>>>> trigger that will be initially assigned.
>>
>>> With proposed "led-triggers" property one could assign different
>>> trigger *sources* to a LED. You could e.g. assign 2 USB ports, network
>>> device & CPU to a single LED. For reason explained above Linux
>>> couldn't support all of them at once.
>>>
>>>
>>>> I am aware that this is renamed usb-ports property from v1,
>>>> that attempts to address Rob's comment, but we can't do that this way.
>>>> Maybe usb-ports property could be documented in led-trigger-usbport's
>>>> specific bindings and a reference to it could be added next to the
>>>> related entry on the list of the available LED triggers (which is
>>>> actually missing) in Documentation/devicetree/bindings/leds/common.txt.
>>>
>>> I'm wondering if we need to care about this Linux limitation and if it
>>> should stop us from adding this flexible DT property. Maybe we could
>>> live with Linux having limitation of supporting one trigger type at a
>>> time?
>>
>> That's what I meant. Generally I have objections to the generic
>> property for defining list of allowed triggers. That's why I proposed
>> to stay by usb-ports property that would be specific to only one
>> trigger: led-trigger-usbport.
>>
>> led-trigger-usbport in fact is an entirely new type of LED trigger.
>> LED triggers is a kernel based source of events. All existing triggers
>> react only to a single, well defined source of events, whereas
>> led-trigger-usbport allows to define the scope of events (usb ports)
>> to notify about. Activity on each port is treated similarly and the LED
>> class device that listens to the trigger notifications doesn't know
>> which exact port triggered the notification.
>>
>> From this POV led-trigger-usbport is kind of facade, which allows
>> for it to fit well into the LED Trigger design and API, and usb ports
>> are not identical with LED triggers, but sit rather one level below.
>> It is led-trigger-usbport which is visible to the LED subsystem, and
>> not every single usb port.
> 
> I of course agree with your nice usbport trigger driver summary.
> 
> 
>> Therefore it isn't logically justified to rename usb-ports property
>> to led-triggers. The property should be specific to this trigger.
> 
> Only if you mean to limit this property to the usbport trigger driver.
> Rob wants to have this property cover other cases and I mean to work
> on more trigger drivers using it as well. So I hope we can look at a
> bigger picture focusing on a nice design that will allow reusing this
> property in other places.
> 
> I'd like to work on netdev / netif / netiface trigger driver in the
> future. I was going to use this DT property there as well.
> 
> Sorry, I should have make it clear from the beginning I mean to re-use
> "led-triggers" in other trigger drivers as well.
> 
> 
>>> So e.g. if one assigns 2 USB ports + network device + CPU and
>>> decides to use "usport" trigger driver he'll get LED indicating status
>>> of USB ports only.
>>
>> How would it be different from the current state? Only in limiting
>> the scope of triggers available for a LED class device.
> 
> It won't differ from the current state. I just wanted to make it clear
> Linux trigger drivers may respect only selected "led-triggers" values
> (phandles). Like "usbport" respecting USB port phandles but ignoring
> CPU ones, net ones, etc.

This is the ambiguity I want to avoid. According to my analysis from
the previous message, physical usb port is one level below usbport LED
trigger, and it should be reflected in DT binding documentation. You
can't write usb1-port1 (using the convention from Documentation/leds/
ledtrig-usbport.txt) to the "triggers" sysfs file. You can only register
usbport trigger which can be configured to notify about activity on
usb1-port1.

That's why I proposed linux,trigger-sources name for that.
Let's not confuse LED triggers with events originating from physical
devices or other sources of kernel events, being in turn translated by
LED triggers to LED brightness changes.

This is a thing about naming. It is tempting to call sources of kernel
events "triggers", but they are not LED triggers on they own. LED
trigger is a driver that registers itself in LED Trigger core using
led_trigger_register() API.

>>> I think we could live with such limitation in Linux support for this
>>> generic "led-triggers" property. I think it's also not very common to
>>> have LED with different types of devices assigned. Personally I've
>>> never seen devices with LED label "USB & CPU" or whatever.
>>
>> I agree. Nonetheless led-triggers seems to support such a design.
> 
> That's right. DT property "led-triggers" supports by design more than
> Linux drivers can handle right now. That was my main point of this
> e-mail.

Having my above explanation, I see your led-triggers property as a means
for limiting the scope of LED Triggers available for a LED class
device. Physical usb port, not being a trigger on its own, wouldn't
fall into this category.

>>> What do you think about this? Maybe we could also document this
>>> limitation in trigger docs.
>>
>> I'm not entirely sure if I got your point. Your reasoning seems
>> self contradicting to me in few places.
> 
> I'm sorry, I obviously had to fail at some point explaining my idea.
> Let's see if this e-mail made it clearer.
>
Jacek Anaszewski Jan. 25, 2017, 9:04 p.m. UTC | #10
On 01/25/2017 10:08 AM, Rafał Miłecki wrote:
> On 01/23/2017 05:45 PM, Rob Herring wrote:
>> On Fri, Jan 20, 2017 at 11:35:20PM +0100, Jacek Anaszewski wrote:
>>> Hi Rafał,
>>>
>>> On 01/20/2017 10:56 PM, Rafał Miłecki wrote:
>>>> From: Rafał Miłecki <rafal@milecki.pl>
>>>>
>>>> Some LEDs can be related to particular devices described in DT. This
>>>> property allows specifying such relations. E.g. USB LED should usually
>>>> be used to indicate some USB port(s) state.
>>>>
>>>> Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
>>>> ---
>>>> V2: Replace "usb-ports" with "led-triggers" property which is more
>>>> generic and
>>>>     allows specifying other devices as well.
>>>>
>>>> When bindings patch is related to some followup implementation, they
>>>> usually go
>>>> through the same tree.
>>>>
>>>> Greg: this patch is based on top of e64b8cc72bf9 ("DT: leds: Improve
>>>> examples by
>>>> adding some context") from kernel/git/j.anaszewski/linux-leds.git .
>>>> Is there any
>>>> way to solve this dependency issue? Or should this patch wait until
>>>> 3.11 is
>>>> released?
>>>> ---
>>>>  Documentation/devicetree/bindings/leds/common.txt | 16
>>>> ++++++++++++++++
>>>>  1 file changed, 16 insertions(+)
>>>>
>>>> diff --git a/Documentation/devicetree/bindings/leds/common.txt
>>>> b/Documentation/devicetree/bindings/leds/common.txt
>>>> index 24b656014089..17632a041196 100644
>>>> --- a/Documentation/devicetree/bindings/leds/common.txt
>>>> +++ b/Documentation/devicetree/bindings/leds/common.txt
>>>> @@ -49,6 +49,17 @@ Optional properties for child nodes:
>>>>  - panic-indicator : This property specifies that the LED should be
>>>> used,
>>>>              if at all possible, as a panic indicator.
>>>>
>>>> +- led-triggers : List of devices that should trigger this LED
>>>> activity. Some
>>>> +         LEDs can be related to a specific device and should somehow
>>>> +         indicate its state. E.g. USB 2.0 LED may react to
>>>> device(s) in
>>>> +         a USB 2.0 port(s). Another common example is switch or router
>>>> +         with multiple Ethernet ports each of them having its own LED
>>>> +         assigned (assuminled-trigger-usbportg they are not
>>>> hardwired).
>>>> +         In such cases this property should contain phandle(s) of
>>>> +         related device(s). In many cases LED can be related to more
>>>> +         than one device (e.g. one USB LED vs. multiple USB ports)
>>>> so a
>>>> +         list of entries can be specified.
>>>> +
>>>
>>> This implies that it is possible to define multiple triggers for
>>> a LED class device but it is not supported by LED Trigger core.
>>
>> Not really relevant for designing (and future proofing) a binding.
> 
> This is what I really like in this "led-triggers" property: it's future
> proof. I
> will be able to reuse it in other trigger drivers and I won't be trying
> to sneak
> properties like
> * usb-port-triggers
> * net-interface-triggers
> * cpu-triggers
> etc.

Very well, but led-triggers in this approach are not LED trigger drivers
but sources of events. Therefore I proposed trigger-sources.

> Saying that thanks Rob for rejecting my initial "usb-ports" property try :P
> .
>
Jacek Anaszewski Jan. 25, 2017, 9:04 p.m. UTC | #11
On 01/25/2017 10:18 AM, Rafał Miłecki wrote:
> On 01/23/2017 09:51 PM, Jacek Anaszewski wrote:
>> On 01/23/2017 05:45 PM, Rob Herring wrote:
>>> On Fri, Jan 20, 2017 at 11:35:20PM +0100, Jacek Anaszewski wrote:
>>>> Hi Rafał,
>>>>
>>>> On 01/20/2017 10:56 PM, Rafał Miłecki wrote:
>>>>> From: Rafał Miłecki <rafal@milecki.pl>
>>>>>
>>>>> Some LEDs can be related to particular devices described in DT. This
>>>>> property allows specifying such relations. E.g. USB LED should usually
>>>>> be used to indicate some USB port(s) state.
>>>>>
>>>>> Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
>>>>> ---
>>>>> V2: Replace "usb-ports" with "led-triggers" property which is more
>>>>> generic and
>>>>>     allows specifying other devices as well.
>>>>>
>>>>> When bindings patch is related to some followup implementation,
>>>>> they usually go
>>>>> through the same tree.
>>>>>
>>>>> Greg: this patch is based on top of e64b8cc72bf9 ("DT: leds:
>>>>> Improve examples by
>>>>> adding some context") from kernel/git/j.anaszewski/linux-leds.git .
>>>>> Is there any
>>>>> way to solve this dependency issue? Or should this patch wait until
>>>>> 3.11 is
>>>>> released?
>>>>> ---
>>>>>  Documentation/devicetree/bindings/leds/common.txt | 16
>>>>> ++++++++++++++++
>>>>>  1 file changed, 16 insertions(+)
>>>>>
>>>>> diff --git a/Documentation/devicetree/bindings/leds/common.txt
>>>>> b/Documentation/devicetree/bindings/leds/common.txt
>>>>> index 24b656014089..17632a041196 100644
>>>>> --- a/Documentation/devicetree/bindings/leds/common.txt
>>>>> +++ b/Documentation/devicetree/bindings/leds/common.txt
>>>>> @@ -49,6 +49,17 @@ Optional properties for child nodes:
>>>>>  - panic-indicator : This property specifies that the LED should be
>>>>> used,
>>>>>              if at all possible, as a panic indicator.
>>>>>
>>>>> +- led-triggers : List of devices that should trigger this LED
>>>>> activity. Some
>>>>> +         LEDs can be related to a specific device and should somehow
>>>>> +         indicate its state. E.g. USB 2.0 LED may react to
>>>>> device(s) in
>>>>> +         a USB 2.0 port(s). Another common example is switch or
>>>>> router
>>>>> +         with multiple Ethernet ports each of them having its own LED
>>>>> +         assigned (assuminled-trigger-usbportg they are not
>>>>> hardwired).
>>>>> +         In such cases this property should contain phandle(s) of
>>>>> +         related device(s). In many cases LED can be related to more
>>>>> +         than one device (e.g. one USB LED vs. multiple USB ports)
>>>>> so a
>>>>> +         list of entries can be specified.
>>>>> +
>>>>
>>>> This implies that it is possible to define multiple triggers for
>>>> a LED class device but it is not supported by LED Trigger core.
>>>
>>> Not really relevant for designing (and future proofing) a binding.
>>
>> But relevant for LED Trigger ABI, which would have to be changed to
>> support the semantics in this form. I think that changing the property
>> name to linux,trigger-sources would make its purpose more clear.
>>
>> Note that we have to also associate somehow this property with the
>> triggers that will make use of the information it provides. I can
>> imagine also other compound triggers that could benefit on it.
>>
>> What follows, the trigger sources would trigger LED activity only
>> if the LED class device was assigned appropriate trigger. We need to
>> define somewhere which triggers support this property.
>>
>> Trigger specific bindings?
> 
> Maybe this is something I'm missing. Why adding this "led-triggers"
> property
> would mean/require ABI breakage?

As I explained in the other message, LED Triggers are drivers registered
in the LED Trigger core. LED subsystem allows for only one active
trigger at a time (triggers sysfs file reports selected trigger by
wrapping its name with square brackets on the space separated list
of all available LED Triggers).

The problem is in the property name, which can easily lead to wrong
conclusions for the reader not familiar with the LED Trigger core
design.

> AFAIU adding support for "led-triggers" to the "usbport" trigger driver
> (see
> patch 2/2) didn't break anything, I hope?
> 

No, it didn't, but ambiguity in the documentation can lead to
misunderstanding and hinder learning LED subsystem API.
Rafał Miłecki Jan. 31, 2017, 4:11 p.m. UTC | #12
On 01/25/2017 10:04 PM, Jacek Anaszewski wrote:
> On 01/25/2017 10:03 AM, Rafał Miłecki wrote:
>> On 21 January 2017 at 22:42, Jacek Anaszewski
>> <jacek.anaszewski@gmail.com> wrote:
>>> On 01/21/2017 05:24 PM, Rafał Miłecki wrote:
>>>> On 20 January 2017 at 23:35, Jacek Anaszewski
>>>> <jacek.anaszewski@gmail.com> wrote:
>>>>> On 01/20/2017 10:56 PM, Rafał Miłecki wrote:
>>>>>> From: Rafał Miłecki <rafal@milecki.pl>
>>>>>>
>>>>>> Some LEDs can be related to particular devices described in DT. This
>>>>>> property allows specifying such relations. E.g. USB LED should usually
>>>>>> be used to indicate some USB port(s) state.
>>>>>>
>>>>>> Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
>>>>>> ---
>>>>>> V2: Replace "usb-ports" with "led-triggers" property which is more generic and
>>>>>>     allows specifying other devices as well.
>>>>>>
>>>>>> When bindings patch is related to some followup implementation, they usually go
>>>>>> through the same tree.
>>>>>>
>>>>>> Greg: this patch is based on top of e64b8cc72bf9 ("DT: leds: Improve examples by
>>>>>> adding some context") from kernel/git/j.anaszewski/linux-leds.git . Is there any
>>>>>> way to solve this dependency issue? Or should this patch wait until 3.11 is
>>>>>> released?
>>>>>> ---
>>>>>>  Documentation/devicetree/bindings/leds/common.txt | 16 ++++++++++++++++
>>>>>>  1 file changed, 16 insertions(+)
>>>>>>
>>>>>> diff --git a/Documentation/devicetree/bindings/leds/common.txt b/Documentation/devicetree/bindings/leds/common.txt
>>>>>> index 24b656014089..17632a041196 100644
>>>>>> --- a/Documentation/devicetree/bindings/leds/common.txt
>>>>>> +++ b/Documentation/devicetree/bindings/leds/common.txt
>>>>>> @@ -49,6 +49,17 @@ Optional properties for child nodes:
>>>>>>  - panic-indicator : This property specifies that the LED should be used,
>>>>>>                   if at all possible, as a panic indicator.
>>>>>>
>>>>>> +- led-triggers : List of devices that should trigger this LED activity. Some
>>>>>> +              LEDs can be related to a specific device and should somehow
>>>>>> +              indicate its state. E.g. USB 2.0 LED may react to device(s) in
>>>>>> +              a USB 2.0 port(s). Another common example is switch or router
>>>>>> +              with multiple Ethernet ports each of them having its own LED
>>>>>> +              assigned (assuminled-trigger-usbportg they are not hardwired).
>>>>>> +              In such cases this property should contain phandle(s) of
>>>>>> +              related device(s). In many cases LED can be related to more
>>>>>> +              than one device (e.g. one USB LED vs. multiple USB ports) so a
>>>>>> +              list of entries can be specified.
>>>>>> +
>>>>>
>>>>> This implies that it is possible to define multiple triggers for
>>>>> a LED class device but it is not supported by LED Trigger core.
>>>>> There is linux,default-trigger property which allows to define one
>>>>> trigger that will be initially assigned.
>>>
>>>> With proposed "led-triggers" property one could assign different
>>>> trigger *sources* to a LED. You could e.g. assign 2 USB ports, network
>>>> device & CPU to a single LED. For reason explained above Linux
>>>> couldn't support all of them at once.
>>>>
>>>>
>>>>> I am aware that this is renamed usb-ports property from v1,
>>>>> that attempts to address Rob's comment, but we can't do that this way.
>>>>> Maybe usb-ports property could be documented in led-trigger-usbport's
>>>>> specific bindings and a reference to it could be added next to the
>>>>> related entry on the list of the available LED triggers (which is
>>>>> actually missing) in Documentation/devicetree/bindings/leds/common.txt.
>>>>
>>>> I'm wondering if we need to care about this Linux limitation and if it
>>>> should stop us from adding this flexible DT property. Maybe we could
>>>> live with Linux having limitation of supporting one trigger type at a
>>>> time?
>>>
>>> That's what I meant. Generally I have objections to the generic
>>> property for defining list of allowed triggers. That's why I proposed
>>> to stay by usb-ports property that would be specific to only one
>>> trigger: led-trigger-usbport.
>>>
>>> led-trigger-usbport in fact is an entirely new type of LED trigger.
>>> LED triggers is a kernel based source of events. All existing triggers
>>> react only to a single, well defined source of events, whereas
>>> led-trigger-usbport allows to define the scope of events (usb ports)
>>> to notify about. Activity on each port is treated similarly and the LED
>>> class device that listens to the trigger notifications doesn't know
>>> which exact port triggered the notification.
>>>
>>> From this POV led-trigger-usbport is kind of facade, which allows
>>> for it to fit well into the LED Trigger design and API, and usb ports
>>> are not identical with LED triggers, but sit rather one level below.
>>> It is led-trigger-usbport which is visible to the LED subsystem, and
>>> not every single usb port.
>>>
>>>> So e.g. if one assigns 2 USB ports + network device + CPU and
>>>> decides to use "usport" trigger driver he'll get LED indicating status
>>>> of USB ports only.
>>>
>>> How would it be different from the current state? Only in limiting
>>> the scope of triggers available for a LED class device.
>>
>> It won't differ from the current state. I just wanted to make it clear
>> Linux trigger drivers may respect only selected "led-triggers" values
>> (phandles). Like "usbport" respecting USB port phandles but ignoring
>> CPU ones, net ones, etc.
>
> This is the ambiguity I want to avoid. According to my analysis from
> the previous message, physical usb port is one level below usbport LED
> trigger, and it should be reflected in DT binding documentation. You
> can't write usb1-port1 (using the convention from Documentation/leds/
> ledtrig-usbport.txt) to the "triggers" sysfs file. You can only register
> usbport trigger which can be configured to notify about activity on
> usb1-port1.
>
> That's why I proposed linux,trigger-sources name for that.
> Let's not confuse LED triggers with events originating from physical
> devices or other sources of kernel events, being in turn translated by
> LED triggers to LED brightness changes.
>
> This is a thing about naming. It is tempting to call sources of kernel
> events "triggers", but they are not LED triggers on they own. LED
> trigger is a driver that registers itself in LED Trigger core using
> led_trigger_register() API.

Thanks a lot Jacek for this explanation (and sorry but I needed a bit of time to
think about this). I can finally see your point, I think we're on the same page
now.

I think that for all this time I was thinking from the pure DT perspective. If
you ignore fact that Linux has multiple LED trigger drivers, then "led-triggers"
may not sound that bad.

After reading your description however I can see this property can be misleading
as Linux people may think "drivers" when seeing "triggers".

I still think this is a useful property and I hope we can still find a way to
name it in a sane way: to be nice from DT PoV and march Linux LEDs subsystem.

I think we should still work on some generic property (without linux, prefix) as
this seems to be something generic, not really specific to Linux implementation.
Specifying relation between LED and devices is something than AFAICS can be
reused by other systems as well.

So my suggestion is to try some new name & leave linux,default-trigger to allow
specifying one single trigger driver as required by current Linux
implementation.

What do you think about this?

There are few suggestions to came to my mind:
"trigger-sources"
"trigger-devices"
"led-trigger-devices"
"led-related-devices"
"led-event-devices"
Do you think any of them would work? Or can you think of any better name?
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Jacek Anaszewski Jan. 31, 2017, 9:34 p.m. UTC | #13
Hi Rafał,

On 01/31/2017 05:11 PM, Rafał Miłecki wrote:
> On 01/25/2017 10:04 PM, Jacek Anaszewski wrote:
>> On 01/25/2017 10:03 AM, Rafał Miłecki wrote:
>>> On 21 January 2017 at 22:42, Jacek Anaszewski
>>> <jacek.anaszewski@gmail.com> wrote:
>>>> On 01/21/2017 05:24 PM, Rafał Miłecki wrote:
>>>>> On 20 January 2017 at 23:35, Jacek Anaszewski
>>>>> <jacek.anaszewski@gmail.com> wrote:
>>>>>> On 01/20/2017 10:56 PM, Rafał Miłecki wrote:
>>>>>>> From: Rafał Miłecki <rafal@milecki.pl>
>>>>>>>
>>>>>>> Some LEDs can be related to particular devices described in DT. This
>>>>>>> property allows specifying such relations. E.g. USB LED should
>>>>>>> usually
>>>>>>> be used to indicate some USB port(s) state.
>>>>>>>
>>>>>>> Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
>>>>>>> ---
>>>>>>> V2: Replace "usb-ports" with "led-triggers" property which is
>>>>>>> more generic and
>>>>>>>     allows specifying other devices as well.
>>>>>>>
>>>>>>> When bindings patch is related to some followup implementation,
>>>>>>> they usually go
>>>>>>> through the same tree.
>>>>>>>
>>>>>>> Greg: this patch is based on top of e64b8cc72bf9 ("DT: leds:
>>>>>>> Improve examples by
>>>>>>> adding some context") from kernel/git/j.anaszewski/linux-leds.git
>>>>>>> . Is there any
>>>>>>> way to solve this dependency issue? Or should this patch wait
>>>>>>> until 3.11 is
>>>>>>> released?
>>>>>>> ---
>>>>>>>  Documentation/devicetree/bindings/leds/common.txt | 16
>>>>>>> ++++++++++++++++
>>>>>>>  1 file changed, 16 insertions(+)
>>>>>>>
>>>>>>> diff --git a/Documentation/devicetree/bindings/leds/common.txt
>>>>>>> b/Documentation/devicetree/bindings/leds/common.txt
>>>>>>> index 24b656014089..17632a041196 100644
>>>>>>> --- a/Documentation/devicetree/bindings/leds/common.txt
>>>>>>> +++ b/Documentation/devicetree/bindings/leds/common.txt
>>>>>>> @@ -49,6 +49,17 @@ Optional properties for child nodes:
>>>>>>>  - panic-indicator : This property specifies that the LED should
>>>>>>> be used,
>>>>>>>                   if at all possible, as a panic indicator.
>>>>>>>
>>>>>>> +- led-triggers : List of devices that should trigger this LED
>>>>>>> activity. Some
>>>>>>> +              LEDs can be related to a specific device and
>>>>>>> should somehow
>>>>>>> +              indicate its state. E.g. USB 2.0 LED may react to
>>>>>>> device(s) in
>>>>>>> +              a USB 2.0 port(s). Another common example is
>>>>>>> switch or router
>>>>>>> +              with multiple Ethernet ports each of them having
>>>>>>> its own LED
>>>>>>> +              assigned (assuminled-trigger-usbportg they are not
>>>>>>> hardwired).
>>>>>>> +              In such cases this property should contain
>>>>>>> phandle(s) of
>>>>>>> +              related device(s). In many cases LED can be
>>>>>>> related to more
>>>>>>> +              than one device (e.g. one USB LED vs. multiple USB
>>>>>>> ports) so a
>>>>>>> +              list of entries can be specified.
>>>>>>> +
>>>>>>
>>>>>> This implies that it is possible to define multiple triggers for
>>>>>> a LED class device but it is not supported by LED Trigger core.
>>>>>> There is linux,default-trigger property which allows to define one
>>>>>> trigger that will be initially assigned.
>>>>
>>>>> With proposed "led-triggers" property one could assign different
>>>>> trigger *sources* to a LED. You could e.g. assign 2 USB ports, network
>>>>> device & CPU to a single LED. For reason explained above Linux
>>>>> couldn't support all of them at once.
>>>>>
>>>>>
>>>>>> I am aware that this is renamed usb-ports property from v1,
>>>>>> that attempts to address Rob's comment, but we can't do that this
>>>>>> way.
>>>>>> Maybe usb-ports property could be documented in led-trigger-usbport's
>>>>>> specific bindings and a reference to it could be added next to the
>>>>>> related entry on the list of the available LED triggers (which is
>>>>>> actually missing) in
>>>>>> Documentation/devicetree/bindings/leds/common.txt.
>>>>>
>>>>> I'm wondering if we need to care about this Linux limitation and if it
>>>>> should stop us from adding this flexible DT property. Maybe we could
>>>>> live with Linux having limitation of supporting one trigger type at a
>>>>> time?
>>>>
>>>> That's what I meant. Generally I have objections to the generic
>>>> property for defining list of allowed triggers. That's why I proposed
>>>> to stay by usb-ports property that would be specific to only one
>>>> trigger: led-trigger-usbport.
>>>>
>>>> led-trigger-usbport in fact is an entirely new type of LED trigger.
>>>> LED triggers is a kernel based source of events. All existing triggers
>>>> react only to a single, well defined source of events, whereas
>>>> led-trigger-usbport allows to define the scope of events (usb ports)
>>>> to notify about. Activity on each port is treated similarly and the LED
>>>> class device that listens to the trigger notifications doesn't know
>>>> which exact port triggered the notification.
>>>>
>>>> From this POV led-trigger-usbport is kind of facade, which allows
>>>> for it to fit well into the LED Trigger design and API, and usb ports
>>>> are not identical with LED triggers, but sit rather one level below.
>>>> It is led-trigger-usbport which is visible to the LED subsystem, and
>>>> not every single usb port.
>>>>
>>>>> So e.g. if one assigns 2 USB ports + network device + CPU and
>>>>> decides to use "usport" trigger driver he'll get LED indicating status
>>>>> of USB ports only.
>>>>
>>>> How would it be different from the current state? Only in limiting
>>>> the scope of triggers available for a LED class device.
>>>
>>> It won't differ from the current state. I just wanted to make it clear
>>> Linux trigger drivers may respect only selected "led-triggers" values
>>> (phandles). Like "usbport" respecting USB port phandles but ignoring
>>> CPU ones, net ones, etc.
>>
>> This is the ambiguity I want to avoid. According to my analysis from
>> the previous message, physical usb port is one level below usbport LED
>> trigger, and it should be reflected in DT binding documentation. You
>> can't write usb1-port1 (using the convention from Documentation/leds/
>> ledtrig-usbport.txt) to the "triggers" sysfs file. You can only register
>> usbport trigger which can be configured to notify about activity on
>> usb1-port1.
>>
>> That's why I proposed linux,trigger-sources name for that.
>> Let's not confuse LED triggers with events originating from physical
>> devices or other sources of kernel events, being in turn translated by
>> LED triggers to LED brightness changes.
>>
>> This is a thing about naming. It is tempting to call sources of kernel
>> events "triggers", but they are not LED triggers on they own. LED
>> trigger is a driver that registers itself in LED Trigger core using
>> led_trigger_register() API.
> 
> Thanks a lot Jacek for this explanation (and sorry but I needed a bit of
> time to
> think about this). I can finally see your point, I think we're on the
> same page
> now.
> 
> I think that for all this time I was thinking from the pure DT
> perspective. If
> you ignore fact that Linux has multiple LED trigger drivers, then
> "led-triggers"
> may not sound that bad.
> 
> After reading your description however I can see this property can be
> misleading
> as Linux people may think "drivers" when seeing "triggers".
> 
> I still think this is a useful property and I hope we can still find a
> way to
> name it in a sane way: to be nice from DT PoV and march Linux LEDs
> subsystem.

I also see the need for this property.

> I think we should still work on some generic property (without linux,
> prefix) as
> this seems to be something generic, not really specific to Linux
> implementation.
> Specifying relation between LED and devices is something than AFAICS can be
> reused by other systems as well.
> 
> So my suggestion is to try some new name & leave linux,default-trigger
> to allow
> specifying one single trigger driver as required by current Linux
> implementation.
> 
> What do you think about this?
> 
> There are few suggestions to came to my mind:
> "trigger-sources"
> "trigger-devices"
> "led-trigger-devices"
> "led-related-devices"
> "led-event-devices"

trigger-devices would work in this specific use case,
where we can give phandles to usb ports. Nonetheless, we
have also other kernel based events serving as trigger
sources - e.g. timer.

In this case I'd go for trigger-sources, but we'd need
to have some generic way of defining the source like timer.
Rafał Miłecki Feb. 1, 2017, 7:38 a.m. UTC | #14
On 01/31/2017 10:34 PM, Jacek Anaszewski wrote:
> On 01/31/2017 05:11 PM, Rafał Miłecki wrote:
>> On 01/25/2017 10:04 PM, Jacek Anaszewski wrote:
>>> On 01/25/2017 10:03 AM, Rafał Miłecki wrote:
>>>> On 21 January 2017 at 22:42, Jacek Anaszewski
>>>> <jacek.anaszewski@gmail.com> wrote:
>>>>> On 01/21/2017 05:24 PM, Rafał Miłecki wrote:
>>>>>> On 20 January 2017 at 23:35, Jacek Anaszewski
>>>>>> <jacek.anaszewski@gmail.com> wrote:
>>>>>>> On 01/20/2017 10:56 PM, Rafał Miłecki wrote:
>>>>>>>> From: Rafał Miłecki <rafal@milecki.pl>
>>>>>>>>
>>>>>>>> Some LEDs can be related to particular devices described in DT. This
>>>>>>>> property allows specifying such relations. E.g. USB LED should
>>>>>>>> usually
>>>>>>>> be used to indicate some USB port(s) state.
>>>>>>>>
>>>>>>>> Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
>>>>>>>> ---
>>>>>>>> V2: Replace "usb-ports" with "led-triggers" property which is
>>>>>>>> more generic and
>>>>>>>>     allows specifying other devices as well.
>>>>>>>>
>>>>>>>> When bindings patch is related to some followup implementation,
>>>>>>>> they usually go
>>>>>>>> through the same tree.
>>>>>>>>
>>>>>>>> Greg: this patch is based on top of e64b8cc72bf9 ("DT: leds:
>>>>>>>> Improve examples by
>>>>>>>> adding some context") from kernel/git/j.anaszewski/linux-leds.git
>>>>>>>> . Is there any
>>>>>>>> way to solve this dependency issue? Or should this patch wait
>>>>>>>> until 3.11 is
>>>>>>>> released?
>>>>>>>> ---
>>>>>>>>  Documentation/devicetree/bindings/leds/common.txt | 16
>>>>>>>> ++++++++++++++++
>>>>>>>>  1 file changed, 16 insertions(+)
>>>>>>>>
>>>>>>>> diff --git a/Documentation/devicetree/bindings/leds/common.txt
>>>>>>>> b/Documentation/devicetree/bindings/leds/common.txt
>>>>>>>> index 24b656014089..17632a041196 100644
>>>>>>>> --- a/Documentation/devicetree/bindings/leds/common.txt
>>>>>>>> +++ b/Documentation/devicetree/bindings/leds/common.txt
>>>>>>>> @@ -49,6 +49,17 @@ Optional properties for child nodes:
>>>>>>>>  - panic-indicator : This property specifies that the LED should
>>>>>>>> be used,
>>>>>>>>                   if at all possible, as a panic indicator.
>>>>>>>>
>>>>>>>> +- led-triggers : List of devices that should trigger this LED
>>>>>>>> activity. Some
>>>>>>>> +              LEDs can be related to a specific device and
>>>>>>>> should somehow
>>>>>>>> +              indicate its state. E.g. USB 2.0 LED may react to
>>>>>>>> device(s) in
>>>>>>>> +              a USB 2.0 port(s). Another common example is
>>>>>>>> switch or router
>>>>>>>> +              with multiple Ethernet ports each of them having
>>>>>>>> its own LED
>>>>>>>> +              assigned (assuminled-trigger-usbportg they are not
>>>>>>>> hardwired).
>>>>>>>> +              In such cases this property should contain
>>>>>>>> phandle(s) of
>>>>>>>> +              related device(s). In many cases LED can be
>>>>>>>> related to more
>>>>>>>> +              than one device (e.g. one USB LED vs. multiple USB
>>>>>>>> ports) so a
>>>>>>>> +              list of entries can be specified.
>>>>>>>> +
>>>>>>>
>>>>>>> This implies that it is possible to define multiple triggers for
>>>>>>> a LED class device but it is not supported by LED Trigger core.
>>>>>>> There is linux,default-trigger property which allows to define one
>>>>>>> trigger that will be initially assigned.
>>>>>
>>>>>> With proposed "led-triggers" property one could assign different
>>>>>> trigger *sources* to a LED. You could e.g. assign 2 USB ports, network
>>>>>> device & CPU to a single LED. For reason explained above Linux
>>>>>> couldn't support all of them at once.
>>>>>>
>>>>>>
>>>>>>> I am aware that this is renamed usb-ports property from v1,
>>>>>>> that attempts to address Rob's comment, but we can't do that this
>>>>>>> way.
>>>>>>> Maybe usb-ports property could be documented in led-trigger-usbport's
>>>>>>> specific bindings and a reference to it could be added next to the
>>>>>>> related entry on the list of the available LED triggers (which is
>>>>>>> actually missing) in
>>>>>>> Documentation/devicetree/bindings/leds/common.txt.
>>>>>>
>>>>>> I'm wondering if we need to care about this Linux limitation and if it
>>>>>> should stop us from adding this flexible DT property. Maybe we could
>>>>>> live with Linux having limitation of supporting one trigger type at a
>>>>>> time?
>>>>>
>>>>> That's what I meant. Generally I have objections to the generic
>>>>> property for defining list of allowed triggers. That's why I proposed
>>>>> to stay by usb-ports property that would be specific to only one
>>>>> trigger: led-trigger-usbport.
>>>>>
>>>>> led-trigger-usbport in fact is an entirely new type of LED trigger.
>>>>> LED triggers is a kernel based source of events. All existing triggers
>>>>> react only to a single, well defined source of events, whereas
>>>>> led-trigger-usbport allows to define the scope of events (usb ports)
>>>>> to notify about. Activity on each port is treated similarly and the LED
>>>>> class device that listens to the trigger notifications doesn't know
>>>>> which exact port triggered the notification.
>>>>>
>>>>> From this POV led-trigger-usbport is kind of facade, which allows
>>>>> for it to fit well into the LED Trigger design and API, and usb ports
>>>>> are not identical with LED triggers, but sit rather one level below.
>>>>> It is led-trigger-usbport which is visible to the LED subsystem, and
>>>>> not every single usb port.
>>>>>
>>>>>> So e.g. if one assigns 2 USB ports + network device + CPU and
>>>>>> decides to use "usport" trigger driver he'll get LED indicating status
>>>>>> of USB ports only.
>>>>>
>>>>> How would it be different from the current state? Only in limiting
>>>>> the scope of triggers available for a LED class device.
>>>>
>>>> It won't differ from the current state. I just wanted to make it clear
>>>> Linux trigger drivers may respect only selected "led-triggers" values
>>>> (phandles). Like "usbport" respecting USB port phandles but ignoring
>>>> CPU ones, net ones, etc.
>>>
>>> This is the ambiguity I want to avoid. According to my analysis from
>>> the previous message, physical usb port is one level below usbport LED
>>> trigger, and it should be reflected in DT binding documentation. You
>>> can't write usb1-port1 (using the convention from Documentation/leds/
>>> ledtrig-usbport.txt) to the "triggers" sysfs file. You can only register
>>> usbport trigger which can be configured to notify about activity on
>>> usb1-port1.
>>>
>>> That's why I proposed linux,trigger-sources name for that.
>>> Let's not confuse LED triggers with events originating from physical
>>> devices or other sources of kernel events, being in turn translated by
>>> LED triggers to LED brightness changes.
>>>
>>> This is a thing about naming. It is tempting to call sources of kernel
>>> events "triggers", but they are not LED triggers on they own. LED
>>> trigger is a driver that registers itself in LED Trigger core using
>>> led_trigger_register() API.
>>
>> Thanks a lot Jacek for this explanation (and sorry but I needed a bit of
>> time to
>> think about this). I can finally see your point, I think we're on the
>> same page
>> now.
>>
>> I think that for all this time I was thinking from the pure DT
>> perspective. If
>> you ignore fact that Linux has multiple LED trigger drivers, then
>> "led-triggers"
>> may not sound that bad.
>>
>> After reading your description however I can see this property can be
>> misleading
>> as Linux people may think "drivers" when seeing "triggers".
>>
>> I still think this is a useful property and I hope we can still find a
>> way to
>> name it in a sane way: to be nice from DT PoV and march Linux LEDs
>> subsystem.
>
> I also see the need for this property.
>
>> I think we should still work on some generic property (without linux,
>> prefix) as
>> this seems to be something generic, not really specific to Linux
>> implementation.
>> Specifying relation between LED and devices is something than AFAICS can be
>> reused by other systems as well.
>>
>> So my suggestion is to try some new name & leave linux,default-trigger
>> to allow
>> specifying one single trigger driver as required by current Linux
>> implementation.
>>
>> What do you think about this?
>>
>> There are few suggestions to came to my mind:
>> "trigger-sources"
>> "trigger-devices"
>> "led-trigger-devices"
>> "led-related-devices"
>> "led-event-devices"
>
> trigger-devices would work in this specific use case,
> where we can give phandles to usb ports. Nonetheless, we
> have also other kernel based events serving as trigger
> sources - e.g. timer.
>
> In this case I'd go for trigger-sources, but we'd need
> to have some generic way of defining the source like timer.

OK, let's try "trigger-sources" then!

I'll rename this property and send V3 with hopefully a better description.
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Rafał Miłecki Feb. 1, 2017, 3:56 p.m. UTC | #15
On 01/31/2017 10:34 PM, Jacek Anaszewski wrote:
> On 01/31/2017 05:11 PM, Rafał Miłecki wrote:
>> On 01/25/2017 10:04 PM, Jacek Anaszewski wrote:
>>> On 01/25/2017 10:03 AM, Rafał Miłecki wrote:
>>>> On 21 January 2017 at 22:42, Jacek Anaszewski
>>>> <jacek.anaszewski@gmail.com> wrote:
>>>>> On 01/21/2017 05:24 PM, Rafał Miłecki wrote:
>>>>>> On 20 January 2017 at 23:35, Jacek Anaszewski
>>>>>> <jacek.anaszewski@gmail.com> wrote:
>>>>>>> On 01/20/2017 10:56 PM, Rafał Miłecki wrote:
>>>>>>>> From: Rafał Miłecki <rafal@milecki.pl>
>>>>>>>>
>>>>>>>> Some LEDs can be related to particular devices described in DT. This
>>>>>>>> property allows specifying such relations. E.g. USB LED should
>>>>>>>> usually
>>>>>>>> be used to indicate some USB port(s) state.
>>>>>>>>
>>>>>>>> Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
>>>>>>>> ---
>>>>>>>> V2: Replace "usb-ports" with "led-triggers" property which is
>>>>>>>> more generic and
>>>>>>>>     allows specifying other devices as well.
>>>>>>>>
>>>>>>>> When bindings patch is related to some followup implementation,
>>>>>>>> they usually go
>>>>>>>> through the same tree.
>>>>>>>>
>>>>>>>> Greg: this patch is based on top of e64b8cc72bf9 ("DT: leds:
>>>>>>>> Improve examples by
>>>>>>>> adding some context") from kernel/git/j.anaszewski/linux-leds.git
>>>>>>>> . Is there any
>>>>>>>> way to solve this dependency issue? Or should this patch wait
>>>>>>>> until 3.11 is
>>>>>>>> released?
>>>>>>>> ---
>>>>>>>>  Documentation/devicetree/bindings/leds/common.txt | 16
>>>>>>>> ++++++++++++++++
>>>>>>>>  1 file changed, 16 insertions(+)
>>>>>>>>
>>>>>>>> diff --git a/Documentation/devicetree/bindings/leds/common.txt
>>>>>>>> b/Documentation/devicetree/bindings/leds/common.txt
>>>>>>>> index 24b656014089..17632a041196 100644
>>>>>>>> --- a/Documentation/devicetree/bindings/leds/common.txt
>>>>>>>> +++ b/Documentation/devicetree/bindings/leds/common.txt
>>>>>>>> @@ -49,6 +49,17 @@ Optional properties for child nodes:
>>>>>>>>  - panic-indicator : This property specifies that the LED should
>>>>>>>> be used,
>>>>>>>>                   if at all possible, as a panic indicator.
>>>>>>>>
>>>>>>>> +- led-triggers : List of devices that should trigger this LED
>>>>>>>> activity. Some
>>>>>>>> +              LEDs can be related to a specific device and
>>>>>>>> should somehow
>>>>>>>> +              indicate its state. E.g. USB 2.0 LED may react to
>>>>>>>> device(s) in
>>>>>>>> +              a USB 2.0 port(s). Another common example is
>>>>>>>> switch or router
>>>>>>>> +              with multiple Ethernet ports each of them having
>>>>>>>> its own LED
>>>>>>>> +              assigned (assuminled-trigger-usbportg they are not
>>>>>>>> hardwired).
>>>>>>>> +              In such cases this property should contain
>>>>>>>> phandle(s) of
>>>>>>>> +              related device(s). In many cases LED can be
>>>>>>>> related to more
>>>>>>>> +              than one device (e.g. one USB LED vs. multiple USB
>>>>>>>> ports) so a
>>>>>>>> +              list of entries can be specified.
>>>>>>>> +
>>>>>>>
>>>>>>> This implies that it is possible to define multiple triggers for
>>>>>>> a LED class device but it is not supported by LED Trigger core.
>>>>>>> There is linux,default-trigger property which allows to define one
>>>>>>> trigger that will be initially assigned.
>>>>>
>>>>>> With proposed "led-triggers" property one could assign different
>>>>>> trigger *sources* to a LED. You could e.g. assign 2 USB ports, network
>>>>>> device & CPU to a single LED. For reason explained above Linux
>>>>>> couldn't support all of them at once.
>>>>>>
>>>>>>
>>>>>>> I am aware that this is renamed usb-ports property from v1,
>>>>>>> that attempts to address Rob's comment, but we can't do that this
>>>>>>> way.
>>>>>>> Maybe usb-ports property could be documented in led-trigger-usbport's
>>>>>>> specific bindings and a reference to it could be added next to the
>>>>>>> related entry on the list of the available LED triggers (which is
>>>>>>> actually missing) in
>>>>>>> Documentation/devicetree/bindings/leds/common.txt.
>>>>>>
>>>>>> I'm wondering if we need to care about this Linux limitation and if it
>>>>>> should stop us from adding this flexible DT property. Maybe we could
>>>>>> live with Linux having limitation of supporting one trigger type at a
>>>>>> time?
>>>>>
>>>>> That's what I meant. Generally I have objections to the generic
>>>>> property for defining list of allowed triggers. That's why I proposed
>>>>> to stay by usb-ports property that would be specific to only one
>>>>> trigger: led-trigger-usbport.
>>>>>
>>>>> led-trigger-usbport in fact is an entirely new type of LED trigger.
>>>>> LED triggers is a kernel based source of events. All existing triggers
>>>>> react only to a single, well defined source of events, whereas
>>>>> led-trigger-usbport allows to define the scope of events (usb ports)
>>>>> to notify about. Activity on each port is treated similarly and the LED
>>>>> class device that listens to the trigger notifications doesn't know
>>>>> which exact port triggered the notification.
>>>>>
>>>>> From this POV led-trigger-usbport is kind of facade, which allows
>>>>> for it to fit well into the LED Trigger design and API, and usb ports
>>>>> are not identical with LED triggers, but sit rather one level below.
>>>>> It is led-trigger-usbport which is visible to the LED subsystem, and
>>>>> not every single usb port.
>>>>>
>>>>>> So e.g. if one assigns 2 USB ports + network device + CPU and
>>>>>> decides to use "usport" trigger driver he'll get LED indicating status
>>>>>> of USB ports only.
>>>>>
>>>>> How would it be different from the current state? Only in limiting
>>>>> the scope of triggers available for a LED class device.
>>>>
>>>> It won't differ from the current state. I just wanted to make it clear
>>>> Linux trigger drivers may respect only selected "led-triggers" values
>>>> (phandles). Like "usbport" respecting USB port phandles but ignoring
>>>> CPU ones, net ones, etc.
>>>
>>> This is the ambiguity I want to avoid. According to my analysis from
>>> the previous message, physical usb port is one level below usbport LED
>>> trigger, and it should be reflected in DT binding documentation. You
>>> can't write usb1-port1 (using the convention from Documentation/leds/
>>> ledtrig-usbport.txt) to the "triggers" sysfs file. You can only register
>>> usbport trigger which can be configured to notify about activity on
>>> usb1-port1.
>>>
>>> That's why I proposed linux,trigger-sources name for that.
>>> Let's not confuse LED triggers with events originating from physical
>>> devices or other sources of kernel events, being in turn translated by
>>> LED triggers to LED brightness changes.
>>>
>>> This is a thing about naming. It is tempting to call sources of kernel
>>> events "triggers", but they are not LED triggers on they own. LED
>>> trigger is a driver that registers itself in LED Trigger core using
>>> led_trigger_register() API.
>>
>> Thanks a lot Jacek for this explanation (and sorry but I needed a bit of
>> time to
>> think about this). I can finally see your point, I think we're on the
>> same page
>> now.
>>
>> I think that for all this time I was thinking from the pure DT
>> perspective. If
>> you ignore fact that Linux has multiple LED trigger drivers, then
>> "led-triggers"
>> may not sound that bad.
>>
>> After reading your description however I can see this property can be
>> misleading
>> as Linux people may think "drivers" when seeing "triggers".
>>
>> I still think this is a useful property and I hope we can still find a
>> way to
>> name it in a sane way: to be nice from DT PoV and march Linux LEDs
>> subsystem.
>
> I also see the need for this property.
>
>> I think we should still work on some generic property (without linux,
>> prefix) as
>> this seems to be something generic, not really specific to Linux
>> implementation.
>> Specifying relation between LED and devices is something than AFAICS can be
>> reused by other systems as well.
>>
>> So my suggestion is to try some new name & leave linux,default-trigger
>> to allow
>> specifying one single trigger driver as required by current Linux
>> implementation.
>>
>> What do you think about this?
>>
>> There are few suggestions to came to my mind:
>> "trigger-sources"
>> "trigger-devices"
>> "led-trigger-devices"
>> "led-related-devices"
>> "led-event-devices"
>
> trigger-devices would work in this specific use case,
> where we can give phandles to usb ports. Nonetheless, we
> have also other kernel based events serving as trigger
> sources - e.g. timer.
>
> In this case I'd go for trigger-sources, but we'd need
> to have some generic way of defining the source like timer.

I'd leave timer for later discussion but I'm glad you brought this problem.
Maybe we could discuss this on another example that is more supported like
GPIOs?

We know this property allows specifying USB ports and we want it to support
mixing various sources. So a very simple sample case seems to be using it for
specifying GPIO as trigger source.

Is this possible to mix various entries in a list assigned to single property?
Let's say:
trigger-sources =
	<&ohci_port1>,
	<&ehci_port1>,
	<&gpio 1 GPIO_ACTIVE_HIGH>;

Is this possible to support this? If so, which function I can use to detect
what is pointed by a phandle?
I'm not that familiar with DT and I'm not sure how to handle this.
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Jacek Anaszewski Feb. 1, 2017, 9:26 p.m. UTC | #16
On 02/01/2017 04:56 PM, Rafał Miłecki wrote:
> On 01/31/2017 10:34 PM, Jacek Anaszewski wrote:
>> On 01/31/2017 05:11 PM, Rafał Miłecki wrote:
>>> On 01/25/2017 10:04 PM, Jacek Anaszewski wrote:
>>>> On 01/25/2017 10:03 AM, Rafał Miłecki wrote:
>>>>> On 21 January 2017 at 22:42, Jacek Anaszewski
>>>>> <jacek.anaszewski@gmail.com> wrote:
>>>>>> On 01/21/2017 05:24 PM, Rafał Miłecki wrote:
>>>>>>> On 20 January 2017 at 23:35, Jacek Anaszewski
>>>>>>> <jacek.anaszewski@gmail.com> wrote:
>>>>>>>> On 01/20/2017 10:56 PM, Rafał Miłecki wrote:
>>>>>>>>> From: Rafał Miłecki <rafal@milecki.pl>
>>>>>>>>>
>>>>>>>>> Some LEDs can be related to particular devices described in DT.
>>>>>>>>> This
>>>>>>>>> property allows specifying such relations. E.g. USB LED should
>>>>>>>>> usually
>>>>>>>>> be used to indicate some USB port(s) state.
>>>>>>>>>
>>>>>>>>> Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
>>>>>>>>> ---
>>>>>>>>> V2: Replace "usb-ports" with "led-triggers" property which is
>>>>>>>>> more generic and
>>>>>>>>>     allows specifying other devices as well.
>>>>>>>>>
>>>>>>>>> When bindings patch is related to some followup implementation,
>>>>>>>>> they usually go
>>>>>>>>> through the same tree.
>>>>>>>>>
>>>>>>>>> Greg: this patch is based on top of e64b8cc72bf9 ("DT: leds:
>>>>>>>>> Improve examples by
>>>>>>>>> adding some context") from kernel/git/j.anaszewski/linux-leds.git
>>>>>>>>> . Is there any
>>>>>>>>> way to solve this dependency issue? Or should this patch wait
>>>>>>>>> until 3.11 is
>>>>>>>>> released?
>>>>>>>>> ---
>>>>>>>>>  Documentation/devicetree/bindings/leds/common.txt | 16
>>>>>>>>> ++++++++++++++++
>>>>>>>>>  1 file changed, 16 insertions(+)
>>>>>>>>>
>>>>>>>>> diff --git a/Documentation/devicetree/bindings/leds/common.txt
>>>>>>>>> b/Documentation/devicetree/bindings/leds/common.txt
>>>>>>>>> index 24b656014089..17632a041196 100644
>>>>>>>>> --- a/Documentation/devicetree/bindings/leds/common.txt
>>>>>>>>> +++ b/Documentation/devicetree/bindings/leds/common.txt
>>>>>>>>> @@ -49,6 +49,17 @@ Optional properties for child nodes:
>>>>>>>>>  - panic-indicator : This property specifies that the LED should
>>>>>>>>> be used,
>>>>>>>>>                   if at all possible, as a panic indicator.
>>>>>>>>>
>>>>>>>>> +- led-triggers : List of devices that should trigger this LED
>>>>>>>>> activity. Some
>>>>>>>>> +              LEDs can be related to a specific device and
>>>>>>>>> should somehow
>>>>>>>>> +              indicate its state. E.g. USB 2.0 LED may react to
>>>>>>>>> device(s) in
>>>>>>>>> +              a USB 2.0 port(s). Another common example is
>>>>>>>>> switch or router
>>>>>>>>> +              with multiple Ethernet ports each of them having
>>>>>>>>> its own LED
>>>>>>>>> +              assigned (assuminled-trigger-usbportg they are not
>>>>>>>>> hardwired).
>>>>>>>>> +              In such cases this property should contain
>>>>>>>>> phandle(s) of
>>>>>>>>> +              related device(s). In many cases LED can be
>>>>>>>>> related to more
>>>>>>>>> +              than one device (e.g. one USB LED vs. multiple USB
>>>>>>>>> ports) so a
>>>>>>>>> +              list of entries can be specified.
>>>>>>>>> +
>>>>>>>>
>>>>>>>> This implies that it is possible to define multiple triggers for
>>>>>>>> a LED class device but it is not supported by LED Trigger core.
>>>>>>>> There is linux,default-trigger property which allows to define one
>>>>>>>> trigger that will be initially assigned.
>>>>>>
>>>>>>> With proposed "led-triggers" property one could assign different
>>>>>>> trigger *sources* to a LED. You could e.g. assign 2 USB ports,
>>>>>>> network
>>>>>>> device & CPU to a single LED. For reason explained above Linux
>>>>>>> couldn't support all of them at once.
>>>>>>>
>>>>>>>
>>>>>>>> I am aware that this is renamed usb-ports property from v1,
>>>>>>>> that attempts to address Rob's comment, but we can't do that this
>>>>>>>> way.
>>>>>>>> Maybe usb-ports property could be documented in
>>>>>>>> led-trigger-usbport's
>>>>>>>> specific bindings and a reference to it could be added next to the
>>>>>>>> related entry on the list of the available LED triggers (which is
>>>>>>>> actually missing) in
>>>>>>>> Documentation/devicetree/bindings/leds/common.txt.
>>>>>>>
>>>>>>> I'm wondering if we need to care about this Linux limitation and
>>>>>>> if it
>>>>>>> should stop us from adding this flexible DT property. Maybe we could
>>>>>>> live with Linux having limitation of supporting one trigger type
>>>>>>> at a
>>>>>>> time?
>>>>>>
>>>>>> That's what I meant. Generally I have objections to the generic
>>>>>> property for defining list of allowed triggers. That's why I proposed
>>>>>> to stay by usb-ports property that would be specific to only one
>>>>>> trigger: led-trigger-usbport.
>>>>>>
>>>>>> led-trigger-usbport in fact is an entirely new type of LED trigger.
>>>>>> LED triggers is a kernel based source of events. All existing
>>>>>> triggers
>>>>>> react only to a single, well defined source of events, whereas
>>>>>> led-trigger-usbport allows to define the scope of events (usb ports)
>>>>>> to notify about. Activity on each port is treated similarly and
>>>>>> the LED
>>>>>> class device that listens to the trigger notifications doesn't know
>>>>>> which exact port triggered the notification.
>>>>>>
>>>>>> From this POV led-trigger-usbport is kind of facade, which allows
>>>>>> for it to fit well into the LED Trigger design and API, and usb ports
>>>>>> are not identical with LED triggers, but sit rather one level below.
>>>>>> It is led-trigger-usbport which is visible to the LED subsystem, and
>>>>>> not every single usb port.
>>>>>>
>>>>>>> So e.g. if one assigns 2 USB ports + network device + CPU and
>>>>>>> decides to use "usport" trigger driver he'll get LED indicating
>>>>>>> status
>>>>>>> of USB ports only.
>>>>>>
>>>>>> How would it be different from the current state? Only in limiting
>>>>>> the scope of triggers available for a LED class device.
>>>>>
>>>>> It won't differ from the current state. I just wanted to make it clear
>>>>> Linux trigger drivers may respect only selected "led-triggers" values
>>>>> (phandles). Like "usbport" respecting USB port phandles but ignoring
>>>>> CPU ones, net ones, etc.
>>>>
>>>> This is the ambiguity I want to avoid. According to my analysis from
>>>> the previous message, physical usb port is one level below usbport LED
>>>> trigger, and it should be reflected in DT binding documentation. You
>>>> can't write usb1-port1 (using the convention from Documentation/leds/
>>>> ledtrig-usbport.txt) to the "triggers" sysfs file. You can only
>>>> register
>>>> usbport trigger which can be configured to notify about activity on
>>>> usb1-port1.
>>>>
>>>> That's why I proposed linux,trigger-sources name for that.
>>>> Let's not confuse LED triggers with events originating from physical
>>>> devices or other sources of kernel events, being in turn translated by
>>>> LED triggers to LED brightness changes.
>>>>
>>>> This is a thing about naming. It is tempting to call sources of kernel
>>>> events "triggers", but they are not LED triggers on they own. LED
>>>> trigger is a driver that registers itself in LED Trigger core using
>>>> led_trigger_register() API.
>>>
>>> Thanks a lot Jacek for this explanation (and sorry but I needed a bit of
>>> time to
>>> think about this). I can finally see your point, I think we're on the
>>> same page
>>> now.
>>>
>>> I think that for all this time I was thinking from the pure DT
>>> perspective. If
>>> you ignore fact that Linux has multiple LED trigger drivers, then
>>> "led-triggers"
>>> may not sound that bad.
>>>
>>> After reading your description however I can see this property can be
>>> misleading
>>> as Linux people may think "drivers" when seeing "triggers".
>>>
>>> I still think this is a useful property and I hope we can still find a
>>> way to
>>> name it in a sane way: to be nice from DT PoV and march Linux LEDs
>>> subsystem.
>>
>> I also see the need for this property.
>>
>>> I think we should still work on some generic property (without linux,
>>> prefix) as
>>> this seems to be something generic, not really specific to Linux
>>> implementation.
>>> Specifying relation between LED and devices is something than AFAICS
>>> can be
>>> reused by other systems as well.
>>>
>>> So my suggestion is to try some new name & leave linux,default-trigger
>>> to allow
>>> specifying one single trigger driver as required by current Linux
>>> implementation.
>>>
>>> What do you think about this?
>>>
>>> There are few suggestions to came to my mind:
>>> "trigger-sources"
>>> "trigger-devices"
>>> "led-trigger-devices"
>>> "led-related-devices"
>>> "led-event-devices"
>>
>> trigger-devices would work in this specific use case,
>> where we can give phandles to usb ports. Nonetheless, we
>> have also other kernel based events serving as trigger
>> sources - e.g. timer.
>>
>> In this case I'd go for trigger-sources, but we'd need
>> to have some generic way of defining the source like timer.
> 
> I'd leave timer for later discussion but I'm glad you brought this problem.
> Maybe we could discuss this on another example that is more supported like
> GPIOs?
> 
> We know this property allows specifying USB ports and we want it to support
> mixing various sources. So a very simple sample case seems to be using
> it for
> specifying GPIO as trigger source.
> 
> Is this possible to mix various entries in a list assigned to single
> property?
> Let's say:
> trigger-sources =
>     <&ohci_port1>,
>     <&ehci_port1>,
>     <&gpio 1 GPIO_ACTIVE_HIGH>;

According to my knowledge all elements in the list are elements
of one array, no matter if they are comma separated or space separated
in "<>" brackets. DT maintainer would have to confirm that though.

> Is this possible to support this? If so, which function I can use to detect
> what is pointed by a phandle?
> I'm not that familiar with DT and I'm not sure how to handle this.

I wonder if this is correct way to go. Maybe we should think of
creating entirely new trigger mechanism that would allow for having
multiple active triggers at a time.

Of course trigger-sources would be still useful for defining
a list of devices of the same type like in case of usbport trigger.
Nonetheless, I have a problem with this property being a part of
LED class device DT bindings. Triggers are not tightly coupled with
LED class devices, but trigger-sources being a list of usb ports
would be applicable only to usbport trigger. What if there was
another combo trigger e.g. for reporting activity on mulitple GPIOs?

Should we have separate list of trigger sources per any possible
existing trigger type? Aren't we going to far from pure hardware
description the Device Tree was initially predestined to?
Rafał Miłecki Feb. 1, 2017, 9:55 p.m. UTC | #17
On 02/01/2017 10:26 PM, Jacek Anaszewski wrote:
> On 02/01/2017 04:56 PM, Rafał Miłecki wrote:
>> On 01/31/2017 10:34 PM, Jacek Anaszewski wrote:
>>> On 01/31/2017 05:11 PM, Rafał Miłecki wrote:
>>>> Thanks a lot Jacek for this explanation (and sorry but I needed a bit of
>>>> time to
>>>> think about this). I can finally see your point, I think we're on the
>>>> same page
>>>> now.
>>>>
>>>> I think that for all this time I was thinking from the pure DT
>>>> perspective. If
>>>> you ignore fact that Linux has multiple LED trigger drivers, then
>>>> "led-triggers"
>>>> may not sound that bad.
>>>>
>>>> After reading your description however I can see this property can be
>>>> misleading
>>>> as Linux people may think "drivers" when seeing "triggers".
>>>>
>>>> I still think this is a useful property and I hope we can still find a
>>>> way to
>>>> name it in a sane way: to be nice from DT PoV and march Linux LEDs
>>>> subsystem.
>>>
>>> I also see the need for this property.
>>>
>>>> I think we should still work on some generic property (without linux,
>>>> prefix) as
>>>> this seems to be something generic, not really specific to Linux
>>>> implementation.
>>>> Specifying relation between LED and devices is something than AFAICS
>>>> can be
>>>> reused by other systems as well.
>>>>
>>>> So my suggestion is to try some new name & leave linux,default-trigger
>>>> to allow
>>>> specifying one single trigger driver as required by current Linux
>>>> implementation.
>>>>
>>>> What do you think about this?
>>>>
>>>> There are few suggestions to came to my mind:
>>>> "trigger-sources"
>>>> "trigger-devices"
>>>> "led-trigger-devices"
>>>> "led-related-devices"
>>>> "led-event-devices"
>>>
>>> trigger-devices would work in this specific use case,
>>> where we can give phandles to usb ports. Nonetheless, we
>>> have also other kernel based events serving as trigger
>>> sources - e.g. timer.
>>>
>>> In this case I'd go for trigger-sources, but we'd need
>>> to have some generic way of defining the source like timer.
>>
>> I'd leave timer for later discussion but I'm glad you brought this problem.
>> Maybe we could discuss this on another example that is more supported like
>> GPIOs?
>>
>> We know this property allows specifying USB ports and we want it to support
>> mixing various sources. So a very simple sample case seems to be using
>> it for
>> specifying GPIO as trigger source.
>>
>> Is this possible to mix various entries in a list assigned to single
>> property?
>> Let's say:
>> trigger-sources =
>>     <&ohci_port1>,
>>     <&ehci_port1>,
>>     <&gpio 1 GPIO_ACTIVE_HIGH>;
>
> According to my knowledge all elements in the list are elements
> of one array, no matter if they are comma separated or space separated
> in "<>" brackets. DT maintainer would have to confirm that though.

This matches my knowledge as well.


>> Is this possible to support this? If so, which function I can use to detect
>> what is pointed by a phandle?
>> I'm not that familiar with DT and I'm not sure how to handle this.
>
> I wonder if this is correct way to go. Maybe we should think of
> creating entirely new trigger mechanism that would allow for having
> multiple active triggers at a time.

I'm OK with reworking Linux's triggers if it need be. I think we should agree
on binding(s) first though.


> Of course trigger-sources would be still useful for defining
> a list of devices of the same type like in case of usbport trigger.
> Nonetheless, I have a problem with this property being a part of
> LED class device DT bindings. Triggers are not tightly coupled with
> LED class devices, but trigger-sources being a list of usb ports
> would be applicable only to usbport trigger. What if there was
> another combo trigger e.g. for reporting activity on mulitple GPIOs?

That was exactly my point with above trigger-sources example including 2 USB
ports & GPIO.


> Should we have separate list of trigger sources per any possible
> existing trigger type? Aren't we going to far from pure hardware
> description the Device Tree was initially predestined to?

That would simplify things, but it gets us back to *multiple* properties like
led-usb-triggers (or led-usb-trigger-sources)
led-pci-triggers (or led-pci-trigger-sources)
led-gpio-triggers (or led-gpio-trigger-sources)
etc.

Last time Rob said he's not going to accept something like this, see:

On 23 January 2017 at 17:45, Rob Herring <robh@kernel.org> wrote:
 > I'm not going to accept something specific to USB. So the choice is make
 > the existing property work for USB or design something more flexible and
 > generic.

So I think the main question right now is if this is possible to support mixed
entries in a list like that
trigger-sources =
	<&ohci_port1>,
	<&ehci_port1>,
	<&gpio 1 GPIO_ACTIVE_HIGH>;

I posted as example.

I was also trying to find help on IRC #devicetree channel but didn't get any
response:
[09:15] <rmilecki> hi, i've a question about mixing various entries in a single list
[09:16] <rmilecki> is this possible to have different /syntax/ in every list element
[09:16] <rmilecki> and have driver detect what does it reference?
[09:16] <rmilecki> i'll post an example
[09:17] <rmilecki> trigger-sources = <&ohci_port1>, <&ehci_port1>, <&gpio 1 GPIO_ACTIVE_HIGH>;
[09:18] <rmilecki> this question is related to my work in [PATCH V2 1/2] dt-bindings: leds: document new led-triggers property
[09:18] <rmilecki> beware, there is a long discussion in that thread

Rob: do you still follow this thread? We'd like to use single property as you
suggested, but is it possible to work with something like trigger-sources
example posted above?
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Jacek Anaszewski Feb. 2, 2017, 8:44 p.m. UTC | #18
On 02/01/2017 10:55 PM, Rafał Miłecki wrote:
> On 02/01/2017 10:26 PM, Jacek Anaszewski wrote:
>> On 02/01/2017 04:56 PM, Rafał Miłecki wrote:
>>> On 01/31/2017 10:34 PM, Jacek Anaszewski wrote:
>>>> On 01/31/2017 05:11 PM, Rafał Miłecki wrote:
>>>>> Thanks a lot Jacek for this explanation (and sorry but I needed a
>>>>> bit of
>>>>> time to
>>>>> think about this). I can finally see your point, I think we're on the
>>>>> same page
>>>>> now.
>>>>>
>>>>> I think that for all this time I was thinking from the pure DT
>>>>> perspective. If
>>>>> you ignore fact that Linux has multiple LED trigger drivers, then
>>>>> "led-triggers"
>>>>> may not sound that bad.
>>>>>
>>>>> After reading your description however I can see this property can be
>>>>> misleading
>>>>> as Linux people may think "drivers" when seeing "triggers".
>>>>>
>>>>> I still think this is a useful property and I hope we can still find a
>>>>> way to
>>>>> name it in a sane way: to be nice from DT PoV and march Linux LEDs
>>>>> subsystem.
>>>>
>>>> I also see the need for this property.
>>>>
>>>>> I think we should still work on some generic property (without linux,
>>>>> prefix) as
>>>>> this seems to be something generic, not really specific to Linux
>>>>> implementation.
>>>>> Specifying relation between LED and devices is something than AFAICS
>>>>> can be
>>>>> reused by other systems as well.
>>>>>
>>>>> So my suggestion is to try some new name & leave linux,default-trigger
>>>>> to allow
>>>>> specifying one single trigger driver as required by current Linux
>>>>> implementation.
>>>>>
>>>>> What do you think about this?
>>>>>
>>>>> There are few suggestions to came to my mind:
>>>>> "trigger-sources"
>>>>> "trigger-devices"
>>>>> "led-trigger-devices"
>>>>> "led-related-devices"
>>>>> "led-event-devices"
>>>>
>>>> trigger-devices would work in this specific use case,
>>>> where we can give phandles to usb ports. Nonetheless, we
>>>> have also other kernel based events serving as trigger
>>>> sources - e.g. timer.
>>>>
>>>> In this case I'd go for trigger-sources, but we'd need
>>>> to have some generic way of defining the source like timer.
>>>
>>> I'd leave timer for later discussion but I'm glad you brought this
>>> problem.
>>> Maybe we could discuss this on another example that is more supported
>>> like
>>> GPIOs?
>>>
>>> We know this property allows specifying USB ports and we want it to
>>> support
>>> mixing various sources. So a very simple sample case seems to be using
>>> it for
>>> specifying GPIO as trigger source.
>>>
>>> Is this possible to mix various entries in a list assigned to single
>>> property?
>>> Let's say:
>>> trigger-sources =
>>>     <&ohci_port1>,
>>>     <&ehci_port1>,
>>>     <&gpio 1 GPIO_ACTIVE_HIGH>;
>>
>> According to my knowledge all elements in the list are elements
>> of one array, no matter if they are comma separated or space separated
>> in "<>" brackets. DT maintainer would have to confirm that though.
> 
> This matches my knowledge as well.

Having that, we would be limited to a list of fixed size
tuples IMHO.

> 
>>> Is this possible to support this? If so, which function I can use to
>>> detect
>>> what is pointed by a phandle?
>>> I'm not that familiar with DT and I'm not sure how to handle this.
>>
>> I wonder if this is correct way to go. Maybe we should think of
>> creating entirely new trigger mechanism that would allow for having
>> multiple active triggers at a time.
> 
> I'm OK with reworking Linux's triggers if it need be. I think we should
> agree
> on binding(s) first though.

I was thinking of creating entirely new mechanism (new sysfs file),
as we can't break existing users.


> 
>> Of course trigger-sources would be still useful for defining
>> a list of devices of the same type like in case of usbport trigger.
>> Nonetheless, I have a problem with this property being a part of
>> LED class device DT bindings. Triggers are not tightly coupled with
>> LED class devices, but trigger-sources being a list of usb ports
>> would be applicable only to usbport trigger. What if there was
>> another combo trigger e.g. for reporting activity on mulitple GPIOs?
> 
> That was exactly my point with above trigger-sources example including 2
> USB
> ports & GPIO.

How usbport trigger would make use use of information about GPIO?
Does it mean that in this approach triggers would arbitrarily choose
trigger-sources applicable for them?

> 
>> Should we have separate list of trigger sources per any possible
>> existing trigger type? Aren't we going to far from pure hardware
>> description the Device Tree was initially predestined to?
> 
> That would simplify things, but it gets us back to *multiple* properties
> like
> led-usb-triggers (or led-usb-trigger-sources)
> led-pci-triggers (or led-pci-trigger-sources)
> led-gpio-triggers (or led-gpio-trigger-sources)
> etc.

Right, I was rather skeptical in my question - I don't like this
solution too.

> Last time Rob said he's not going to accept something like this, see:
> 
> On 23 January 2017 at 17:45, Rob Herring <robh@kernel.org> wrote:
>> I'm not going to accept something specific to USB. So the choice is make
>> the existing property work for USB or design something more flexible and
>> generic.
> 
> So I think the main question right now is if this is possible to support
> mixed
> entries in a list like that
> trigger-sources =
>     <&ohci_port1>,
>     <&ehci_port1>,
>     <&gpio 1 GPIO_ACTIVE_HIGH>;
> 
> I posted as example.
> 
> I was also trying to find help on IRC #devicetree channel but didn't get
> any
> response:
> [09:15] <rmilecki> hi, i've a question about mixing various entries in a
> single list
> [09:16] <rmilecki> is this possible to have different /syntax/ in every
> list element
> [09:16] <rmilecki> and have driver detect what does it reference?
> [09:16] <rmilecki> i'll post an example
> [09:17] <rmilecki> trigger-sources = <&ohci_port1>, <&ehci_port1>,
> <&gpio 1 GPIO_ACTIVE_HIGH>;
> [09:18] <rmilecki> this question is related to my work in [PATCH V2 1/2]
> dt-bindings: leds: document new led-triggers property
> [09:18] <rmilecki> beware, there is a long discussion in that thread
> 
> Rob: do you still follow this thread? We'd like to use single property
> as you
> suggested, but is it possible to work with something like trigger-sources
> example posted above?
>
Rafał Miłecki Feb. 2, 2017, 11 p.m. UTC | #19
On 02/02/2017 09:44 PM, Jacek Anaszewski wrote:
> On 02/01/2017 10:55 PM, Rafał Miłecki wrote:
>> On 02/01/2017 10:26 PM, Jacek Anaszewski wrote:
>>> On 02/01/2017 04:56 PM, Rafał Miłecki wrote:
>>>> On 01/31/2017 10:34 PM, Jacek Anaszewski wrote:
>>>>> On 01/31/2017 05:11 PM, Rafał Miłecki wrote:
>>>>>> Thanks a lot Jacek for this explanation (and sorry but I needed a
>>>>>> bit of
>>>>>> time to
>>>>>> think about this). I can finally see your point, I think we're on the
>>>>>> same page
>>>>>> now.
>>>>>>
>>>>>> I think that for all this time I was thinking from the pure DT
>>>>>> perspective. If
>>>>>> you ignore fact that Linux has multiple LED trigger drivers, then
>>>>>> "led-triggers"
>>>>>> may not sound that bad.
>>>>>>
>>>>>> After reading your description however I can see this property can be
>>>>>> misleading
>>>>>> as Linux people may think "drivers" when seeing "triggers".
>>>>>>
>>>>>> I still think this is a useful property and I hope we can still find a
>>>>>> way to
>>>>>> name it in a sane way: to be nice from DT PoV and march Linux LEDs
>>>>>> subsystem.
>>>>>
>>>>> I also see the need for this property.
>>>>>
>>>>>> I think we should still work on some generic property (without linux,
>>>>>> prefix) as
>>>>>> this seems to be something generic, not really specific to Linux
>>>>>> implementation.
>>>>>> Specifying relation between LED and devices is something than AFAICS
>>>>>> can be
>>>>>> reused by other systems as well.
>>>>>>
>>>>>> So my suggestion is to try some new name & leave linux,default-trigger
>>>>>> to allow
>>>>>> specifying one single trigger driver as required by current Linux
>>>>>> implementation.
>>>>>>
>>>>>> What do you think about this?
>>>>>>
>>>>>> There are few suggestions to came to my mind:
>>>>>> "trigger-sources"
>>>>>> "trigger-devices"
>>>>>> "led-trigger-devices"
>>>>>> "led-related-devices"
>>>>>> "led-event-devices"
>>>>>
>>>>> trigger-devices would work in this specific use case,
>>>>> where we can give phandles to usb ports. Nonetheless, we
>>>>> have also other kernel based events serving as trigger
>>>>> sources - e.g. timer.
>>>>>
>>>>> In this case I'd go for trigger-sources, but we'd need
>>>>> to have some generic way of defining the source like timer.
>>>>
>>>> I'd leave timer for later discussion but I'm glad you brought this
>>>> problem.
>>>> Maybe we could discuss this on another example that is more supported
>>>> like
>>>> GPIOs?
>>>>
>>>> We know this property allows specifying USB ports and we want it to
>>>> support
>>>> mixing various sources. So a very simple sample case seems to be using
>>>> it for
>>>> specifying GPIO as trigger source.
>>>>
>>>> Is this possible to mix various entries in a list assigned to single
>>>> property?
>>>> Let's say:
>>>> trigger-sources =
>>>>     <&ohci_port1>,
>>>>     <&ehci_port1>,
>>>>     <&gpio 1 GPIO_ACTIVE_HIGH>;
>>>
>>> According to my knowledge all elements in the list are elements
>>> of one array, no matter if they are comma separated or space separated
>>> in "<>" brackets. DT maintainer would have to confirm that though.
>>
>> This matches my knowledge as well.
>
> Having that, we would be limited to a list of fixed size
> tuples IMHO.

That sounds OK. Now I spent some time thinking about this I think it can work.
First of all we may need something like #sources-cells to extend our property
in the future.
Secondly it should be possible to detect type of phandle node by trying things
one by one. We should be e.g. able to check is phandle is for GPIO by trying
of_find_gpiochip_by_xlate.


>>>> Is this possible to support this? If so, which function I can use to
>>>> detect
>>>> what is pointed by a phandle?
>>>> I'm not that familiar with DT and I'm not sure how to handle this.
>>>
>>> I wonder if this is correct way to go. Maybe we should think of
>>> creating entirely new trigger mechanism that would allow for having
>>> multiple active triggers at a time.
>>
>> I'm OK with reworking Linux's triggers if it need be. I think we should
>> agree
>> on binding(s) first though.
>
> I was thinking of creating entirely new mechanism (new sysfs file),
> as we can't break existing users.

Agree.


>>> Of course trigger-sources would be still useful for defining
>>> a list of devices of the same type like in case of usbport trigger.
>>> Nonetheless, I have a problem with this property being a part of
>>> LED class device DT bindings. Triggers are not tightly coupled with
>>> LED class devices, but trigger-sources being a list of usb ports
>>> would be applicable only to usbport trigger. What if there was
>>> another combo trigger e.g. for reporting activity on mulitple GPIOs?
>>
>> That was exactly my point with above trigger-sources example including 2
>> USB
>> ports & GPIO.
>
> How usbport trigger would make use use of information about GPIO?
> Does it mean that in this approach triggers would arbitrarily choose
> trigger-sources applicable for them?

It wouldn't. It would simply ignore it.

We could modify ledtrig-gpio.c however to support this new property
(ex-"led-triggers") and make use of specified GPIO(s). Of course ledtrig-gpio
would ignore specified USB ports. One type per LED trigger driver.


>>> Should we have separate list of trigger sources per any possible
>>> existing trigger type? Aren't we going to far from pure hardware
>>> description the Device Tree was initially predestined to?
>>
>> That would simplify things, but it gets us back to *multiple* properties
>> like
>> led-usb-triggers (or led-usb-trigger-sources)
>> led-pci-triggers (or led-pci-trigger-sources)
>> led-gpio-triggers (or led-gpio-trigger-sources)
>> etc.
>
> Right, I was rather skeptical in my question - I don't like this
> solution too.
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Pavel Machek Feb. 3, 2017, 11:05 a.m. UTC | #20
Hi!

> >>>>Is this possible to mix various entries in a list assigned to single
> >>>>property?
> >>>>Let's say:
> >>>>trigger-sources =
> >>>>    <&ohci_port1>,
> >>>>    <&ehci_port1>,
> >>>>    <&gpio 1 GPIO_ACTIVE_HIGH>;

Actually... I'm not sure I like the "multiple sources". It is somehow
justified for ohci/ehci_port, because they... represent single
physical port. Could we introduce something for the physical port into
the DTS, too?

> >>>According to my knowledge all elements in the list are elements
> >>>of one array, no matter if they are comma separated or space separated
> >>>in "<>" brackets. DT maintainer would have to confirm that though.
> >>
> >>This matches my knowledge as well.
> >
> >Having that, we would be limited to a list of fixed size
> >tuples IMHO.
> 
> That sounds OK. Now I spent some time thinking about this I think it can work.
> First of all we may need something like #sources-cells to extend our property
> in the future.
> Secondly it should be possible to detect type of phandle node by trying things
> one by one. We should be e.g. able to check is phandle is for GPIO by trying
> of_find_gpiochip_by_xlate.

I am not sure if variable-length parameters here is good idea. Would
be nice to keep it simple... Having the led representing voltage on
gpio line is somehow strange to me. I'd rather have dts explaining
what that voltage means ("it is battery charging signal") and than
have led connected to that...
									Pavel
Jacek Anaszewski Feb. 7, 2017, 9:41 p.m. UTC | #21
On 02/03/2017 12:00 AM, Rafał Miłecki wrote:
> On 02/02/2017 09:44 PM, Jacek Anaszewski wrote:
>> On 02/01/2017 10:55 PM, Rafał Miłecki wrote:
>>> On 02/01/2017 10:26 PM, Jacek Anaszewski wrote:
>>>> On 02/01/2017 04:56 PM, Rafał Miłecki wrote:
>>>>> On 01/31/2017 10:34 PM, Jacek Anaszewski wrote:
>>>>>> On 01/31/2017 05:11 PM, Rafał Miłecki wrote:
>>>>>>> Thanks a lot Jacek for this explanation (and sorry but I needed a
>>>>>>> bit of
>>>>>>> time to
>>>>>>> think about this). I can finally see your point, I think we're on
>>>>>>> the
>>>>>>> same page
>>>>>>> now.
>>>>>>>
>>>>>>> I think that for all this time I was thinking from the pure DT
>>>>>>> perspective. If
>>>>>>> you ignore fact that Linux has multiple LED trigger drivers, then
>>>>>>> "led-triggers"
>>>>>>> may not sound that bad.
>>>>>>>
>>>>>>> After reading your description however I can see this property
>>>>>>> can be
>>>>>>> misleading
>>>>>>> as Linux people may think "drivers" when seeing "triggers".
>>>>>>>
>>>>>>> I still think this is a useful property and I hope we can still
>>>>>>> find a
>>>>>>> way to
>>>>>>> name it in a sane way: to be nice from DT PoV and march Linux LEDs
>>>>>>> subsystem.
>>>>>>
>>>>>> I also see the need for this property.
>>>>>>
>>>>>>> I think we should still work on some generic property (without
>>>>>>> linux,
>>>>>>> prefix) as
>>>>>>> this seems to be something generic, not really specific to Linux
>>>>>>> implementation.
>>>>>>> Specifying relation between LED and devices is something than AFAICS
>>>>>>> can be
>>>>>>> reused by other systems as well.
>>>>>>>
>>>>>>> So my suggestion is to try some new name & leave
>>>>>>> linux,default-trigger
>>>>>>> to allow
>>>>>>> specifying one single trigger driver as required by current Linux
>>>>>>> implementation.
>>>>>>>
>>>>>>> What do you think about this?
>>>>>>>
>>>>>>> There are few suggestions to came to my mind:
>>>>>>> "trigger-sources"
>>>>>>> "trigger-devices"
>>>>>>> "led-trigger-devices"
>>>>>>> "led-related-devices"
>>>>>>> "led-event-devices"
>>>>>>
>>>>>> trigger-devices would work in this specific use case,
>>>>>> where we can give phandles to usb ports. Nonetheless, we
>>>>>> have also other kernel based events serving as trigger
>>>>>> sources - e.g. timer.
>>>>>>
>>>>>> In this case I'd go for trigger-sources, but we'd need
>>>>>> to have some generic way of defining the source like timer.
>>>>>
>>>>> I'd leave timer for later discussion but I'm glad you brought this
>>>>> problem.
>>>>> Maybe we could discuss this on another example that is more supported
>>>>> like
>>>>> GPIOs?
>>>>>
>>>>> We know this property allows specifying USB ports and we want it to
>>>>> support
>>>>> mixing various sources. So a very simple sample case seems to be using
>>>>> it for
>>>>> specifying GPIO as trigger source.
>>>>>
>>>>> Is this possible to mix various entries in a list assigned to single
>>>>> property?
>>>>> Let's say:
>>>>> trigger-sources =
>>>>>     <&ohci_port1>,
>>>>>     <&ehci_port1>,
>>>>>     <&gpio 1 GPIO_ACTIVE_HIGH>;
>>>>
>>>> According to my knowledge all elements in the list are elements
>>>> of one array, no matter if they are comma separated or space separated
>>>> in "<>" brackets. DT maintainer would have to confirm that though.
>>>
>>> This matches my knowledge as well.
>>
>> Having that, we would be limited to a list of fixed size
>> tuples IMHO.
> 
> That sounds OK. Now I spent some time thinking about this I think it can
> work.
> First of all we may need something like #sources-cells to extend our
> property
> in the future.
> Secondly it should be possible to detect type of phandle node by trying
> things
> one by one. We should be e.g. able to check is phandle is for GPIO by
> trying
> of_find_gpiochip_by_xlate.
> 
> 
>>>>> Is this possible to support this? If so, which function I can use to
>>>>> detect
>>>>> what is pointed by a phandle?
>>>>> I'm not that familiar with DT and I'm not sure how to handle this.
>>>>
>>>> I wonder if this is correct way to go. Maybe we should think of
>>>> creating entirely new trigger mechanism that would allow for having
>>>> multiple active triggers at a time.
>>>
>>> I'm OK with reworking Linux's triggers if it need be. I think we should
>>> agree
>>> on binding(s) first though.
>>
>> I was thinking of creating entirely new mechanism (new sysfs file),
>> as we can't break existing users.
> 
> Agree.
> 
> 
>>>> Of course trigger-sources would be still useful for defining
>>>> a list of devices of the same type like in case of usbport trigger.
>>>> Nonetheless, I have a problem with this property being a part of
>>>> LED class device DT bindings. Triggers are not tightly coupled with
>>>> LED class devices, but trigger-sources being a list of usb ports
>>>> would be applicable only to usbport trigger. What if there was
>>>> another combo trigger e.g. for reporting activity on mulitple GPIOs?
>>>
>>> That was exactly my point with above trigger-sources example including 2
>>> USB
>>> ports & GPIO.
>>
>> How usbport trigger would make use use of information about GPIO?
>> Does it mean that in this approach triggers would arbitrarily choose
>> trigger-sources applicable for them?
> 
> It wouldn't. It would simply ignore it.
> 
> We could modify ledtrig-gpio.c however to support this new property
> (ex-"led-triggers") and make use of specified GPIO(s). Of course
> ledtrig-gpio
> would ignore specified USB ports. One type per LED trigger driver.

Frankly speaking I don't like this too much. It would be hard
to infer from the bindings which trigger sources will be used by which
trigger.

I'd like to propose something different, i.e. trigger specific
trigger-sources property, but defined in a separate DT node
for each LED trigger:

led1-usbport-trig: usbport-trig {
	trigger-type = "usbport";
	trigger-sources = <&usb-port1>, <&usb-port2>, <usb-port3>;
	led-dev = <&led1>;
};

led1-compound-gpio-trig: compound-gpio-trig {
	trigger-type = "oneshot";
	trigger-sources = <&gpio1>, <&gpio2>, <&gpio3>;
	led-dev = <&led1>;
};

led1: led1 {
	compound-triggers = <&led1-usbport-trig>. <&led1-compound-gpio-trig>;
}

This way when applying usbport trigger to led1, we would know how
to configure it for this particular LED. If we had led2, we could
define different subset of usb ports to trigger it. In case of
hypothetical compound-gpio trigger, the driver would know
which gpios should generate LED events.

This is a freshly devised idea, just a subject for a discussion.

Best regards,
Jacek Anaszewski

>>>> Should we have separate list of trigger sources per any possible
>>>> existing trigger type? Aren't we going to far from pure hardware
>>>> description the Device Tree was initially predestined to?
>>>
>>> That would simplify things, but it gets us back to *multiple* properties
>>> like
>>> led-usb-triggers (or led-usb-trigger-sources)
>>> led-pci-triggers (or led-pci-trigger-sources)
>>> led-gpio-triggers (or led-gpio-trigger-sources)
>>> etc.
>>
>> Right, I was rather skeptical in my question - I don't like this
>> solution too.
> 


--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Rob Herring Feb. 7, 2017, 10:57 p.m. UTC | #22
On Wed, Feb 1, 2017 at 3:55 PM, Rafał Miłecki <zajec5@gmail.com> wrote:
> On 02/01/2017 10:26 PM, Jacek Anaszewski wrote:
>>
>> On 02/01/2017 04:56 PM, Rafał Miłecki wrote:
>>>
>>> On 01/31/2017 10:34 PM, Jacek Anaszewski wrote:
>>>>
>>>> On 01/31/2017 05:11 PM, Rafał Miłecki wrote:
>>>>>
>>>>> Thanks a lot Jacek for this explanation (and sorry but I needed a bit
>>>>> of
>>>>> time to
>>>>> think about this). I can finally see your point, I think we're on the
>>>>> same page
>>>>> now.
>>>>>
>>>>> I think that for all this time I was thinking from the pure DT
>>>>> perspective. If
>>>>> you ignore fact that Linux has multiple LED trigger drivers, then
>>>>> "led-triggers"
>>>>> may not sound that bad.
>>>>>
>>>>> After reading your description however I can see this property can be
>>>>> misleading
>>>>> as Linux people may think "drivers" when seeing "triggers".
>>>>>
>>>>> I still think this is a useful property and I hope we can still find a
>>>>> way to
>>>>> name it in a sane way: to be nice from DT PoV and march Linux LEDs
>>>>> subsystem.
>>>>
>>>>
>>>> I also see the need for this property.
>>>>
>>>>> I think we should still work on some generic property (without linux,
>>>>> prefix) as
>>>>> this seems to be something generic, not really specific to Linux
>>>>> implementation.
>>>>> Specifying relation between LED and devices is something than AFAICS
>>>>> can be
>>>>> reused by other systems as well.
>>>>>
>>>>> So my suggestion is to try some new name & leave linux,default-trigger
>>>>> to allow
>>>>> specifying one single trigger driver as required by current Linux
>>>>> implementation.
>>>>>
>>>>> What do you think about this?
>>>>>
>>>>> There are few suggestions to came to my mind:
>>>>> "trigger-sources"
>>>>> "trigger-devices"
>>>>> "led-trigger-devices"
>>>>> "led-related-devices"
>>>>> "led-event-devices"
>>>>
>>>>
>>>> trigger-devices would work in this specific use case,
>>>> where we can give phandles to usb ports. Nonetheless, we
>>>> have also other kernel based events serving as trigger
>>>> sources - e.g. timer.
>>>>
>>>> In this case I'd go for trigger-sources, but we'd need
>>>> to have some generic way of defining the source like timer.

+1 for the name.

>>>
>>>
>>> I'd leave timer for later discussion but I'm glad you brought this
>>> problem.
>>> Maybe we could discuss this on another example that is more supported
>>> like
>>> GPIOs?
>>>
>>> We know this property allows specifying USB ports and we want it to
>>> support
>>> mixing various sources. So a very simple sample case seems to be using
>>> it for
>>> specifying GPIO as trigger source.
>>>
>>> Is this possible to mix various entries in a list assigned to single
>>> property?
>>> Let's say:
>>> trigger-sources =
>>>     <&ohci_port1>,
>>>     <&ehci_port1>,
>>>     <&gpio 1 GPIO_ACTIVE_HIGH>;
>>
>>
>> According to my knowledge all elements in the list are elements
>> of one array, no matter if they are comma separated or space separated
>> in "<>" brackets. DT maintainer would have to confirm that though.
>
>
> This matches my knowledge as well.

It is a bit problematic, but this could work as long as you know the
possible arg types and a given node only has 1 match (nodes with
interrupt and gpio being likely). You look up the phandle, iterate
thru possible "#*-cells" properties for that phandle, then parse the
cells. You could define rules of what is the required cell type (e.g.
must use gpio cells if a phandle has both gpio and interrupt cells
defined.).

Another, simpler approach would be defining #trigger-cells in each
source. This is probably the better option as all the infrastructure
is there and could handle unforeseen cases.

>>> Is this possible to support this? If so, which function I can use to
>>> detect
>>> what is pointed by a phandle?
>>> I'm not that familiar with DT and I'm not sure how to handle this.
>>
>>
>> I wonder if this is correct way to go. Maybe we should think of
>> creating entirely new trigger mechanism that would allow for having
>> multiple active triggers at a time.
>
>
> I'm OK with reworking Linux's triggers if it need be. I think we should
> agree
> on binding(s) first though.

Yes, they are separate problems.

Rob
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/Documentation/devicetree/bindings/leds/common.txt b/Documentation/devicetree/bindings/leds/common.txt
index 24b656014089..17632a041196 100644
--- a/Documentation/devicetree/bindings/leds/common.txt
+++ b/Documentation/devicetree/bindings/leds/common.txt
@@ -49,6 +49,17 @@  Optional properties for child nodes:
 - panic-indicator : This property specifies that the LED should be used,
 		    if at all possible, as a panic indicator.
 
+- led-triggers : List of devices that should trigger this LED activity. Some
+		 LEDs can be related to a specific device and should somehow
+		 indicate its state. E.g. USB 2.0 LED may react to device(s) in
+		 a USB 2.0 port(s). Another common example is switch or router
+		 with multiple Ethernet ports each of them having its own LED
+		 assigned (assuming they are not hardwired).
+		 In such cases this property should contain phandle(s) of
+		 related device(s). In many cases LED can be related to more
+		 than one device (e.g. one USB LED vs. multiple USB ports) so a
+		 list of entries can be specified.
+
 Required properties for flash LED child nodes:
 - flash-max-microamp : Maximum flash LED supply current in microamperes.
 - flash-max-timeout-us : Maximum timeout in microseconds after which the flash
@@ -69,6 +80,11 @@  gpio-leds {
 		linux,default-trigger = "heartbeat";
 		gpios = <&gpio0 0 GPIO_ACTIVE_HIGH>;
 	};
+
+	usb {
+		gpios = <&gpio0 1 GPIO_ACTIVE_HIGH>;
+		led-triggers = <&ohci_port1>, <&ehci_port1>;
+	};
 };
 
 max77693-led {