linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Marek Behún" <kabel@kernel.org>
To: Alexander Dahl <ada@thorsis.com>
Cc: Pavel Machek <pavel@ucw.cz>,
	devicetree@vger.kernel.org, linux-leds@vger.kernel.org,
	Andrew Lunn <andrew@lunn.ch>,
	robh+dt@kernel.org, Jacek Anaszewski <jacek.anaszewski@gmail.com>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	Linus Walleij <linus.walleij@linaro.org>
Subject: Re: [PATCH 2/3] dt-bindings: leds: Add `excludes` property
Date: Thu, 14 Oct 2021 13:58:44 +0200	[thread overview]
Message-ID: <20211014135844.440e4e19@dellmb> (raw)
In-Reply-To: <YWgU37NQfnIOtlsn@ada.ifak-system.com>

On Thu, 14 Oct 2021 13:30:39 +0200
Alexander Dahl <ada@thorsis.com> wrote:

> Hei hei,
> 
> Am Thu, Oct 14, 2021 at 12:43:09PM +0200 schrieb Marek Behún:
> > On Thu, 14 Oct 2021 12:29:18 +0200
> > Pavel Machek <pavel@ucw.cz> wrote:
> >   
> > > Hi!
> > >   
> > > > Some RJ-45 connectors have LEDs wired in the following way:
> > > > 
> > > >          LED1
> > > >       +--|>|--+
> > > >       |       |
> > > >   A---+--|<|--+---B
> > > >          LED2
> > > > 
> > > > With + on A and - on B, LED1 is ON and LED2 is OFF. Inverting
> > > > the polarity turns LED1 OFF and LED2 ON.
> > > > 
> > > > So these LEDs exclude each other.
> > > > 
> > > > Add new `excludes` property to the LED binding. The property is
> > > > a phandle-array to all the other LEDs that are excluded by this
> > > > LED.    
> > > 
> > > I don't think this belongs to the LED binding.
> > > 
> > > This is controller limitation, and the driver handling the
> > > controller needs to know about it... so it does not need to learn
> > > that from the LED binding.  
> > 
> > It's not necessarily a controller limitation, rather a limitation of
> > the board (or ethernet connector, in the case of LEDs on an ethernet
> > connector).  
> 
> Such LEDs are not limited to PHYs or ethernet connectors.  There is
> hardware with such dual color LEDs connected to GPIO pins (either
> directly to the SoC or through some GPIO expander like an 74hc595
> shift register).  That mail points to such hardware:
> 
> https://www.spinics.net/lists/linux-leds/msg11847.html
> 
> I asked about how this can be modelled back in 2019 and it was also
> discussed last year:
> 
> https://www.spinics.net/lists/linux-leds/msg11665.html
> https://lore.kernel.org/linux-leds/2315048.uTtSMl1LR1@ada/
> 
> The "solution" back when I first asked was treating them as ordinary
> GPIO-LEDs and ignore the "exclusion topic" which means in practice the
> LED goes OFF if both pins are ON (high) at the same time, which works
> well enough in practice.
> 
> > But I guess we could instead document this property in the ethernet
> > PHY controller binding for a given PHY.  
> 
> Because such LEDs are not restricted to ethernet PHYs, but can also be
> used with GPIOs from the hardware point of view, I would not put it
> there.
> 
> Furthermore I would not view this as a restriction of the gpio-leds
> controller, but it's a property of the LEDs itself or the way they are
> wired to the board.
> 
> This could (or should as Pavel suggested back in 2019) be put to a new
> driver, at least for the GPIO case, but it would need some kind of new
> binding anyways.  With that in mind I consider the proposed binding to
> be well comprehensible for a human reader/writer.
> 
> I'm sorry, I did not have leisure time to implement such a driver yet.
> Breadboard hardware for that still waiting in the drawer. :-/

That's why I think we need the `excludes` property.

On the sw side, it should work like this:
$ cd /sys/class/leds
$ echo 1 >LED1/brightness
$ cat LED1/brightness LED2/brightness
1
0
$ echo 1 >LED2/brightness
$ cat LED1/brightness LED2/brightness
0
1

The drivers could also implement brightness_hw_changed for these LEDs.

Marek

  reply	other threads:[~2021-10-14 11:58 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-13 20:44 [PATCH 1/3] dt-bindings: leds: Deprecate `linux,default-trigger` property Marek Behún
2021-10-13 20:44 ` [PATCH 2/3] dt-bindings: leds: Add `excludes` property Marek Behún
2021-10-13 22:20   ` Rob Herring
2021-10-14 10:29   ` Pavel Machek
2021-10-14 10:43     ` Marek Behún
2021-10-14 11:30       ` Alexander Dahl
2021-10-14 11:58         ` Marek Behún [this message]
2021-10-13 20:44 ` [PATCH 3/3] dt-bindings: leds: Allow for multiple colors in the `color` property Marek Behún
2021-10-26 20:44   ` Rob Herring
2021-10-26 20:39 ` [PATCH 1/3] dt-bindings: leds: Deprecate `linux,default-trigger` property Rob Herring

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211014135844.440e4e19@dellmb \
    --to=kabel@kernel.org \
    --cc=ada@thorsis.com \
    --cc=andrew@lunn.ch \
    --cc=devicetree@vger.kernel.org \
    --cc=jacek.anaszewski@gmail.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-leds@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pavel@ucw.cz \
    --cc=robh+dt@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).