From: Andrew Lunn <andrew@lunn.ch>
To: "Marek Behún" <kabel@kernel.org>
Cc: Rob Herring <robh+dt@kernel.org>, Pavel Machek <pavel@ucw.cz>,
Jacek Anaszewski <jacek.anaszewski@gmail.com>,
"linux-leds@vger.kernel.org" <linux-leds@vger.kernel.org>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
devicetree@vger.kernel.org
Subject: Re: lets settle the LED `function` property regarding the netdev trigger
Date: Mon, 4 Oct 2021 19:28:19 +0200 [thread overview]
Message-ID: <YVs5sxd/dEBwBShm@lunn.ch> (raw)
In-Reply-To: <20211004170847.3f92ef48@thinkpad>
> > There are two different ways this can be implemented. There can be two
> > independent LEDs within the same package. So you can generate three
> > colours. Or there can be two cross connected LEDs within the
> > package. Apply +ve you get one colour, apply -ve you get a different
> > colour. Since you cannot apply both -ve and +ve at the same time, you
> > cannot get both colours at once.
> >
> > If you have two independent LEDs, I would define two LEDs in DT.
>
> No, we have multicolor LED API which is meant for exactly this
> situation: a multicolor LED.
> (I am talking about something like the KJ2518D-262 from
> http://www.rego.com.tw/product_detail.php?prdt_id=258
> which has Green/Orange on left and Yellow on right side.
> The left Green/Orange LED has 3 pins, and so it can mix the colors into
> yellow.)
But here you are talking about the LED, not the controller in the
PHY. The controller might control it as two independent LEDs. It has
no idea it can get a third colour by enabling two LEDs at the same
time. Or maybe the controller does know it can combine colours.
So you need to know about both the controller and the LED. And the
same controller can be used either way. Plus you need to think about
the non DT case, when you have no idea about the LED connected to the
controller.
> I think the best solution here would be a subclass "enumcolor" (or
> different name), where you can choose between several pre-defined colors.
> In sysfs you could then do
> echo 1 >brightness
> echo green >color
> echo yellow >color
I'm not sure it is as simple as that. In the general case, you have no
idea what the colours actually are. You only know the colours if you
have DT and DT lists the colours. And you only know if LEDs are
combined if you have DT. You need a basic sysfs API based on knowing
the PHY can control X LEDs. You can then extend that API if you have
additional information via DT, like colour and if LEDs are combined,
that only LEDs numbered 2 and 3 are used, etc.
Andrew
next prev parent reply other threads:[~2021-10-04 17:28 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-01 12:36 lets settle the LED `function` property regarding the netdev trigger Marek Behún
2021-10-03 18:56 ` Andrew Lunn
2021-10-03 19:26 ` Marek Behún
2021-10-04 14:50 ` Andrew Lunn
2021-10-04 15:08 ` Marek Behún
2021-10-04 17:28 ` Andrew Lunn [this message]
2021-10-05 20:30 ` Marek Behún
2021-10-05 21:52 ` Andrew Lunn
2021-10-05 19:58 ` Jacek Anaszewski
2021-10-05 20:12 ` Andrew Lunn
2021-10-05 20:26 ` Marek Behún
2021-10-05 21:01 ` Andrew Lunn
2021-10-05 21:43 ` Marek Behún
2021-10-05 22:06 ` Andrew Lunn
2021-10-05 23:06 ` Marek Behún
2021-10-06 12:57 ` Andrew Lunn
2021-10-07 17:13 ` Marek Behún
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=YVs5sxd/dEBwBShm@lunn.ch \
--to=andrew@lunn.ch \
--cc=devicetree@vger.kernel.org \
--cc=jacek.anaszewski@gmail.com \
--cc=kabel@kernel.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