[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230415000533.534ea99b@aktux>
Date: Sat, 15 Apr 2023 00:05:33 +0200
From: Andreas Kemnade <andreas@...nade.info>
To: Pavel Machek <pavel@....cz>
Cc: lee@...nel.org, robh+dt@...nel.org,
krzysztof.kozlowski+dt@...aro.org, linux-leds@...r.kernel.org,
devicetree@...r.kernel.org, linux-kernel@...r.kernel.org,
Matti Vaittinen <mazziesaccount@...il.com>
Subject: Re: [PATCH v4 2/2] leds: bd2606mvv: Driver for the Rohm 6 Channel
i2c LED driver
Hi Pavel,
On Fri, 14 Apr 2023 14:18:56 +0200
Pavel Machek <pavel@....cz> wrote:
> Hi!
>
> > The device provides 6 channels which can be individually
> > turned off and on but groups of two channels share a common brightness
> > register.
>
> Yeah, well.. Turn it into 3-channel controller with brightness or
> 6-channel on/off one... You can't really share brightness.
>
No, I cannot change the hardware, so it is a 6-channel with limitations.
And the devicetree has to describe the hardware and not the driver.
What is discussable is just how the driver should deal with that:
I see 5 possibilities.
a) ignore the shared brightness problem (status quo)
b) never set a brightness other than full on/off
c) ignore one led of each pair (not register it at all{
d) couple also the on/off of the pairs, so present to
userspace only max. 3 leds.
e) allow full brightness control where independently possible,
if LEDs are defined where that leads to conflicts,
register them with max_brightness=1 and use them
in on/off mode.
My preference were a) or e), the most possible usages.
e) has a cleaner interface to the userspace.
I would not upstream b)
Regards,
Andreas
> > +++ b/drivers/leds/Kconfig
> > @@ -551,6 +551,17 @@ config LEDS_REGULATOR
> > help
> > This option enables support for regulator driven LEDs.
> >
> > +config LEDS_BD2606MVV
> > + tristate "LED driver for BD2606MVV"
> > + depends on LEDS_CLASS
> > + depends on I2C
> > + select REGMAP_I2C
> > + help
> > + This option enables support for BD2606MVV LED driver chips
> > + accessed via the I2C bus. It supports setting brightness, with
> > + the limitiation that there are groups of two channels sharing
> > + a brightness setting, but not the on/off setting.
> > +
>
> This driver can be used as a module...
>
>
> > +static int
> > +bd2606mvv_brightness_set(struct led_classdev *led_cdev,
> > + enum led_brightness brightness)
> > +{
> > + struct bd2606mvv_led *led = ldev_to_led(led_cdev);
> > + struct bd2606mvv_priv *priv = led->priv;
> > + int err;
> > +
> > + if (brightness == 0)
> > + return regmap_update_bits(priv->regmap,
> > + BD2606_REG_PWRCNT,
> > + 1 << led->led_no,
> > + 0);
> > +
> > + /* shared brightness register */
> > + err = regmap_write(priv->regmap, led->led_no / 2,
> > + brightness);
> > + if (err)
> > + return err;
>
> Yeah. No.
>
> Best regards,
> Pavel
Powered by blists - more mailing lists