mbox series

[v3,0/5] leds: Add Intel Cherry Trail Whiskey Cove PMIC LED driver

Message ID 20230430195952.862527-1-hdegoede@redhat.com
Headers show
Series leds: Add Intel Cherry Trail Whiskey Cove PMIC LED driver | expand

Message

Hans de Goede April 30, 2023, 7:59 p.m. UTC
Hi All,

Here is v3 of the patch series to add support for the LED controller
on Intel Cherry Trail Whiskey Cove PMICs.

Changes in v3:
- Some comment tweaks and s/LED_OFF/0/ and s/LED_ON/1/
- Refuse to load on the Yoga Tab 3 as it turns out the LED1 driver output
  is connected to a haptic feedback motor there (and LED2 is unused)

Changes in v2 (of my version of this):
- Address Pavel's small remarks on patch 1/5,
  see patch 1/5's commit message for details
- Improve/extend pattern docs in Documentation/leds/leds-cht-wcove.rst

This is based on the original patch for this from Yauhen Kharuzhy,
with additional work on top by me.

This addresses the review remarks on the v2 posting from Yauhen:
- Since the PMIC is connected to the battery any changes we make to
  the LED settings are permanent, even surviving reboot / poweroff.
  Save LED1 register settings on probe() and if auto-/hw-control was
  enabled on probe() restore the settings on remove() and shutdown().
- Add support for the pattern trigger to select breathing mode

This makes the charging LED on devices with these PMICs properly
reflect the charging status (this relies on sw control on most
devices) and this also allows control of the LED behind the pen
(digitizer on) symbol on the keyboard half of the Lenovo Yoga Book
1 models.

Regards,

Hans


Hans de Goede (4):
  leds: cht-wcove: Add suspend/resume handling
  leds: cht-wcove: Add support for breathing mode use hw_pattern sysfs
    API
  leds: cht-wcove: Set default trigger for charging LED
  leds: cht-wcove: Use breathing when LED_INIT_DEFAULT_TRIGGER is set

Yauhen Kharuzhy (1):
  leds: Add Intel Cherry Trail Whiskey Cove PMIC LED driver

 Documentation/leds/index.rst           |   1 +
 Documentation/leds/leds-cht-wcove.rst  |  38 ++
 Documentation/leds/well-known-leds.txt |   2 +-
 drivers/leds/Kconfig                   |  11 +
 drivers/leds/Makefile                  |   1 +
 drivers/leds/leds-cht-wcove.c          | 477 +++++++++++++++++++++++++
 6 files changed, 529 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/leds/leds-cht-wcove.rst
 create mode 100644 drivers/leds/leds-cht-wcove.c

Comments

Yauhen Kharuzhy May 4, 2023, 8:05 a.m. UTC | #1
On Sun, Apr 30, 2023 at 09:59:47PM +0200, Hans de Goede wrote:
> Hi All,
> 
> Here is v3 of the patch series to add support for the LED controller
> on Intel Cherry Trail Whiskey Cove PMICs.
> 
> Changes in v3:
> - Some comment tweaks and s/LED_OFF/0/ and s/LED_ON/1/
> - Refuse to load on the Yoga Tab 3 as it turns out the LED1 driver output
>   is connected to a haptic feedback motor there (and LED2 is unused)
> 
> Changes in v2 (of my version of this):
> - Address Pavel's small remarks on patch 1/5,
>   see patch 1/5's commit message for details
> - Improve/extend pattern docs in Documentation/leds/leds-cht-wcove.rst
> 
> This is based on the original patch for this from Yauhen Kharuzhy,
> with additional work on top by me.
> 
> This addresses the review remarks on the v2 posting from Yauhen:
> - Since the PMIC is connected to the battery any changes we make to
>   the LED settings are permanent, even surviving reboot / poweroff.
>   Save LED1 register settings on probe() and if auto-/hw-control was
>   enabled on probe() restore the settings on remove() and shutdown().
> - Add support for the pattern trigger to select breathing mode
> 
> This makes the charging LED on devices with these PMICs properly
> reflect the charging status (this relies on sw control on most
> devices) and this also allows control of the LED behind the pen
> (digitizer on) symbol on the keyboard half of the Lenovo Yoga Book
> 1 models.
> 
> Regards,
> 
> Hans

Tested-by: Yauhen Kharuzhy <jekhor@gmail.com>

Works at my Lenovo Yoga Book YB1-X91L.
Hans de Goede May 4, 2023, 8:56 a.m. UTC | #2
Hi Yauhen,

On 5/4/23 10:05, Yauhen Kharuzhy wrote:
> On Sun, Apr 30, 2023 at 09:59:47PM +0200, Hans de Goede wrote:
>> Hi All,
>>
>> Here is v3 of the patch series to add support for the LED controller
>> on Intel Cherry Trail Whiskey Cove PMICs.
>>
>> Changes in v3:
>> - Some comment tweaks and s/LED_OFF/0/ and s/LED_ON/1/
>> - Refuse to load on the Yoga Tab 3 as it turns out the LED1 driver output
>>   is connected to a haptic feedback motor there (and LED2 is unused)
>>
>> Changes in v2 (of my version of this):
>> - Address Pavel's small remarks on patch 1/5,
>>   see patch 1/5's commit message for details
>> - Improve/extend pattern docs in Documentation/leds/leds-cht-wcove.rst
>>
>> This is based on the original patch for this from Yauhen Kharuzhy,
>> with additional work on top by me.
>>
>> This addresses the review remarks on the v2 posting from Yauhen:
>> - Since the PMIC is connected to the battery any changes we make to
>>   the LED settings are permanent, even surviving reboot / poweroff.
>>   Save LED1 register settings on probe() and if auto-/hw-control was
>>   enabled on probe() restore the settings on remove() and shutdown().
>> - Add support for the pattern trigger to select breathing mode
>>
>> This makes the charging LED on devices with these PMICs properly
>> reflect the charging status (this relies on sw control on most
>> devices) and this also allows control of the LED behind the pen
>> (digitizer on) symbol on the keyboard half of the Lenovo Yoga Book
>> 1 models.
>>
>> Regards,
>>
>> Hans
> 
> Tested-by: Yauhen Kharuzhy <jekhor@gmail.com>
> 
> Works at my Lenovo Yoga Book YB1-X91L.

Thank you!

I assume you have tested with my LED class/core series which avoids
the oops/WARN() you were seeing before:

https://lore.kernel.org/linux-leds/20230412215855.593541-1-hdegoede@redhat.com/

If yes, can you reply with your Tested-by: Yauhen Kharuzhy <jekhor@gmail.com>
to that series too please ?

Regards,

Hans


p.s.

I think on an earlier version of this series you mentioned that you
are still carrying some patches locally for the yogabook ?

If I remember that correctly can you share those patches with me/us ?

Then if I can find some time I can see if I can submit them upstream
(or find another way to achieve their goal and post that upstream).

Also while on the subject of the yogabook have you looked into
getting sound to work ?
Yauhen Kharuzhy May 4, 2023, 11:29 a.m. UTC | #3
чт, 4 мая 2023 г. в 11:56, Hans de Goede <hdegoede@redhat.com>:
>
> Hi Yauhen,
>
> On 5/4/23 10:05, Yauhen Kharuzhy wrote:
> > On Sun, Apr 30, 2023 at 09:59:47PM +0200, Hans de Goede wrote:
> >> Hi All,
> >>
> >> Here is v3 of the patch series to add support for the LED controller
> >> on Intel Cherry Trail Whiskey Cove PMICs.
> >>
> >> Changes in v3:
> >> - Some comment tweaks and s/LED_OFF/0/ and s/LED_ON/1/
> >> - Refuse to load on the Yoga Tab 3 as it turns out the LED1 driver output
> >>   is connected to a haptic feedback motor there (and LED2 is unused)
> >>
> >> Changes in v2 (of my version of this):
> >> - Address Pavel's small remarks on patch 1/5,
> >>   see patch 1/5's commit message for details
> >> - Improve/extend pattern docs in Documentation/leds/leds-cht-wcove.rst
> >>
> >> This is based on the original patch for this from Yauhen Kharuzhy,
> >> with additional work on top by me.
> >>
> >> This addresses the review remarks on the v2 posting from Yauhen:
> >> - Since the PMIC is connected to the battery any changes we make to
> >>   the LED settings are permanent, even surviving reboot / poweroff.
> >>   Save LED1 register settings on probe() and if auto-/hw-control was
> >>   enabled on probe() restore the settings on remove() and shutdown().
> >> - Add support for the pattern trigger to select breathing mode
> >>
> >> This makes the charging LED on devices with these PMICs properly
> >> reflect the charging status (this relies on sw control on most
> >> devices) and this also allows control of the LED behind the pen
> >> (digitizer on) symbol on the keyboard half of the Lenovo Yoga Book
> >> 1 models.
> >>
> >> Regards,
> >>
> >> Hans
> >
> > Tested-by: Yauhen Kharuzhy <jekhor@gmail.com>
> >
> > Works at my Lenovo Yoga Book YB1-X91L.
>
> Thank you!
>
> I assume you have tested with my LED class/core series which avoids
> the oops/WARN() you were seeing before:
>
> https://lore.kernel.org/linux-leds/20230412215855.593541-1-hdegoede@redhat.com/
>
> If yes, can you reply with your Tested-by: Yauhen Kharuzhy <jekhor@gmail.com>
> to that series too please ?

Yes, sure, I will reply there too.

> Regards,
>
> Hans
>
>
> p.s.
>
> I think on an earlier version of this series you mentioned that you
> are still carrying some patches locally for the yogabook ?
>
> If I remember that correctly can you share those patches with me/us ?

Of course, all my patches are in my github:
https://github.com/jekhor/yogabook-linux-kernel/commits/master

>
> Then if I can find some time I can see if I can submit them upstream
> (or find another way to achieve their goal and post that upstream).
>
> Also while on the subject of the yogabook have you looked into
> getting sound to work ?

Sound works for me with my kernel, speakers and DMIC. UCM configs are
needed to get it working:
https://github.com/jekhor/alsa-ucm-conf-yogabook/tree/main