Re: How are dual color LEDs best modelled in Linux

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Alexander,

On 4/2/19 12:23 PM, Alexander Dahl wrote:
Hello everyone,

on my desk lies a piece of hardware with some dual color LEDs connected to
some IO ports. The LEDs shine green or red depending on polarity and are
connected in between two data output lines or GPIO ports like this:

     ------.
           |    LED
        P1 |---->|-------.
           |    ___      |
        P2 |---|___|-----'
           |
     ------'

The logic table is this one:

P1 | P2 | LED
-- + -- + -----
  0 |  0 | off
  0 |  1 | green
  1 |  0 | red
  1 |  1 | off

So there are three states: red, green and off, red and green are mutual
exclusive, both colors can not be switched on independently at the same time.

I guess this is a quite common setup in embedded electronics, but how would
one model that with Linux? How would I describe it in device tree and how
would the sysfs interface for trigger etc. look like?

You would have to extend leds-gpio bindings by some property defining
forbidden states for given LED child node, i.e. which sub-LED cannot
be turned on in the same time. If the forbidden state is going to be
set, then just return -EBUSY from the brightness_set callback.
leds-gpio driver would have to be altered for that too, to understand
the new DT property.

--
Best regards,
Jacek Anaszewski



[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux