leds: Add Intel Cherry Trail Whiskey Cove PMIC LED driver
Subsystems (2)
cover leds: Add Intel Cherry Trail Whiskey Cove PMIC LED driver
Hi All,
Here is a patch series to add support for the LED controller on Intel Cherry Trail Whiskey Cove PMICs.
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 | 29 ++ drivers/leds/Kconfig | 11 + drivers/leds/Makefile | 1 + drivers/leds/leds-cht-wcove.c | 466 ++++++++++++++++++++++++++ 5 files changed, 508 insertions(+) create mode 100644 Documentation/leds/leds-cht-wcove.rst create mode 100644 drivers/leds/leds-cht-wcove.c
Signature · 1 line
2.39.1
PATCH 1/5 leds: Add Intel Cherry Trail Whiskey Cove PMIC LED driver
From: Yauhen Kharuzhy <[email protected]>
Add support for LEDs connected to the Intel Cherry Trail Whiskey Cove PMIC. Charger and general-purpose leds are supported. Hardware blinking is implemented, breathing is not.
This driver was tested with Lenovo Yoga Book notebook.
Changes by Hans de Goede (in response to review of v2):
- 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().
- Delay switching LED1 to software control mode to first brightness write.
- Use dynamically allocated drvdata instead of a global drvdata variable.
- Ensure the LED is on when activating blinking.
- Fix CHT_WC_LED_EFF_BREATHING val ((3 << 1) rather then BIT(3)).
--- drivers/leds/Kconfig | 11 + drivers/leds/Makefile | 1 + drivers/leds/leds-cht-wcove.c | 368 ++++++++++++++++++++++++++++++++++ 3 files changed, 380 insertions(+) create mode 100644 drivers/leds/leds-cht-wcove.c
drivers/leds/Kconfig +11 -0
@@ -122,6 +122,17 @@ config LEDS_BCM6358 This option enables support for LEDs connected to the BCM6358 LED HW controller accessed via MMIO registers. +config LEDS_CHT_WCOVE + tristate "LED support for Intel Cherry Trail Whiskey Cove PMIC" + depends on LEDS_CLASS + depends on INTEL_SOC_PMIC_CHTWC + help + This option enables support for charger and general purpose LEDs + connected to the Intel Cherrytrail Whiskey Cove PMIC. + + To compile this driver as a module, choose M here: the module + will be called leds-cht-wcove. + config LEDS_CPCAP tristate "LED Support for Motorola CPCAP" depends on LEDS_CLASS
drivers/leds/Makefile +1 -0
@@ -19,6 +19,7 @@ obj-$(CONFIG_LEDS_BCM6328) += leds-bcm6328.o obj-$(CONFIG_LEDS_BCM6358) += leds-bcm6358.o obj-$(CONFIG_LEDS_BD2802) += leds-bd2802.o obj-$(CONFIG_LEDS_BLINKM) += leds-blinkm.o +obj-$(CONFIG_LEDS_CHT_WCOVE) += leds-cht-wcove.o obj-$(CONFIG_LEDS_CLEVO_MAIL) += leds-clevo-mail.o obj-$(CONFIG_LEDS_COBALT_QUBE) += leds-cobalt-qube.o obj-$(CONFIG_LEDS_COBALT_RAQ) += leds-cobalt-raq.o
drivers/leds/leds-cht-wcove.c new file +368 -0
368 lines not on this page · raw message
Signature · 1 line
2.39.1
Quoted 5 lines · Hans de Goede
From: Yauhen Kharuzhy <[email protected]>
Add support for LEDs connected to the Intel Cherry Trail Whiskey Cove PMIC. Charger and general-purpose leds are supported. Hardware blinking is implemented, breathing is not.
leds->LEDs.
Quoted 6 lines
drivers/leds/leds-cht-wcove.c new file +0
-0
drivers/leds/leds-cht-wcove.c line 9
Quoted 9 lines
drivers/leds/leds-cht-wcove.c new file +9
-0@@ -0,0 +1,368 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Driver for LEDs connected to the Intel Cherry Trail Whiskey Cove PMIC +* +* Copyright 2019 Yauhen Kharuzhy <[email protected]> +* Copyright 2023 Hans de Goede <[email protected]> +* +* Based on Lenovo Yoga Book Android kernel sources +*/
"sources." Should copyrights from Android be copied here?
drivers/leds/leds-cht-wcove.c line 102
Quoted 4 lines
drivers/leds/leds-cht-wcove.c new file +4
-0+static const char *const cht_wc_leds_names[CHT_WC_LED_COUNT ] = { +"cht-wc::" LED_FUNCTION_CHARGING , +"cht-wc::" LED_FUNCTION_INDICATOR , +};
No need for "cht-wc". Mention color. At least charging LED is going to be common - document in Documentation/leds/well-known-leds.txt.
Quoted 9 lines
drivers/leds/leds-cht-wcove.c new file +9
-0+static int cht_wc_leds_brightness_set (struct led_classdev *cdev, +enum led_brightness value) +{ + struct cht_wc_led *led = container_of(cdev, struct cht_wc_led, cdev); +int ret; + +mutex_lock (&led->mutex); + +if (!value) {
drivers/leds/leds-cht-wcove.c line 122
Quoted 10 lines
drivers/leds/leds-cht-wcove.c new file +10
-0+ ret =regmap_update_bits (led->regmap, led->regs->ctrl, + led->regs->on_off_mask, led->regs->off_val); +if (ret) +dev_err (cdev->dev,"Failed to turn off: %d\n" , ret); + +/* Disable HW blinking */ + ret =regmap_update_bits (led->regmap, led->regs->fsm, +CHT_WC_LED_EFF_MASK ,CHT_WC_LED_EFF_ON ); +if (ret <0 ) +dev_err (cdev->dev,"Failed to update LED FSM reg: %d\n" , ret);
This overwrites previous error. Not sure if it is big deal.
drivers/leds/leds-cht-wcove.c line 226
Quoted 12 lines
drivers/leds/leds-cht-wcove.c new file +12
-0+static int cht_wc_leds_blink_set (struct led_classdev *cdev, +unsigned long *delay_on, +unsigned long *delay_off) +{ + struct cht_wc_led *led = container_of(cdev, struct cht_wc_led, cdev); +unsigned int ctrl; +int ret; + +mutex_lock (&led->mutex); + +if (!*delay_on && !*delay_off) + *delay_on = *delay_off =1000 ;
That's really slow blink; I'd do something faster by default.
drivers/leds/leds-cht-wcove.c line 301
Quoted 5 lines
drivers/leds/leds-cht-wcove.c new file +5
-0+/* +* LED1 might be in hw-controlled mode when this driver gets loaded; and +* since the PMIC is always powered by the battery any changes made are +* permanent. Save LED1 regs to restore them on remove() or shutdown(). +*/
Fun :-).
Thank you.
Best regards,
Pavel
Signature · 1 line
People of Russia, stop Putin before his war on Ukraine escalates.
Hi Pavel,
Thank you for reviewing this.
Quoted 27 lines · Pavel Machek
Quoted 5 lines · Hans de Goede
From: Yauhen Kharuzhy <[email protected]>
Add support for LEDs connected to the Intel Cherry Trail Whiskey Cove PMIC. Charger and general-purpose leds are supported. Hardware blinking is implemented, breathing is not.
leds->LEDs.Quoted 6 lines
drivers/leds/leds-cht-wcove.c new file +0
-0drivers/leds/leds-cht-wcove.c line 9
Quoted 9 lines
drivers/leds/leds-cht-wcove.c new file +9
-0@@ -0,0 +1,368 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Driver for LEDs connected to the Intel Cherry Trail Whiskey Cove PMIC +* +* Copyright 2019 Yauhen Kharuzhy <[email protected]> +* Copyright 2023 Hans de Goede <[email protected]> +* +* Based on Lenovo Yoga Book Android kernel sources +*/ "sources." Should copyrights from Android be copied here?
Quoted 6 lines
drivers/leds/leds-cht-wcove.c line 102
Quoted 4 lines
drivers/leds/leds-cht-wcove.c new file +4
-0+static const char *const cht_wc_leds_names[CHT_WC_LED_COUNT ] = { +"cht-wc::" LED_FUNCTION_CHARGING , +"cht-wc::" LED_FUNCTION_INDICATOR , +};No need for "cht-wc".
I should put something there right, iow not just "::" LED_FUNCTION_CHARGING" if it should not be cht-wc should I put "platform::" there then, or maybe "pmic::" ?
Quoted 1 line
Mention color.
This PMIC is used in multiple designs at least both white and red LEDs are used in 2 designs I know about. AFAIK the norm is to leave out the color if it is different per design?
Quoted 2 lines
At least charging LED is
going to be common - document inDocumentation/leds/well-known-leds.txt.
That already has:
* Power management
Good: "platform:*:charging" (allwinner sun50i)
So you want me to extend the (allwinner sun50i) bit with ", cht-wc" ?
Ack to all the other comments, will fix for v2.
Regards,
Hans
Quoted 50 lines
Quoted 10 lines
drivers/leds/leds-cht-wcove.c new file +9
-0+static int cht_wc_leds_brightness_set (struct led_classdev *cdev, +enum led_brightness value) +{ + struct cht_wc_led *led = container_of(cdev, struct cht_wc_led, cdev); +int ret; + +mutex_lock (&led->mutex); + +if (!value) {drivers/leds/leds-cht-wcove.c line 122
Quoted 10 lines
drivers/leds/leds-cht-wcove.c new file +10
-0+ ret =regmap_update_bits (led->regmap, led->regs->ctrl, + led->regs->on_off_mask, led->regs->off_val); +if (ret) +dev_err (cdev->dev,"Failed to turn off: %d\n" , ret); + +/* Disable HW blinking */ + ret =regmap_update_bits (led->regmap, led->regs->fsm, +CHT_WC_LED_EFF_MASK ,CHT_WC_LED_EFF_ON ); +if (ret <0 ) +dev_err (cdev->dev,"Failed to update LED FSM reg: %d\n" , ret);This overwrites previous error. Not sure if it is big deal.
drivers/leds/leds-cht-wcove.c line 226
Quoted 12 lines
drivers/leds/leds-cht-wcove.c new file +12
-0+static int cht_wc_leds_blink_set (struct led_classdev *cdev, +unsigned long *delay_on, +unsigned long *delay_off) +{ + struct cht_wc_led *led = container_of(cdev, struct cht_wc_led, cdev); +unsigned int ctrl; +int ret; + +mutex_lock (&led->mutex); + +if (!*delay_on && !*delay_off) + *delay_on = *delay_off =1000 ;That's really slow blink; I'd do something faster by default.
drivers/leds/leds-cht-wcove.c line 301
Quoted 5 lines
drivers/leds/leds-cht-wcove.c new file +5
-0+/* +* LED1 might be in hw-controlled mode when this driver gets loaded; and +* since the PMIC is always powered by the battery any changes made are +* permanent. Save LED1 regs to restore them on remove() or shutdown(). +*/ Fun :-).
Thank you.
Best regards,
Pavel
Hi,
Quoted 18 lines · Pavel Machek
Quoted 5 lines · Hans de Goede
From: Yauhen Kharuzhy <[email protected]>
Add support for LEDs connected to the Intel Cherry Trail Whiskey Cove PMIC. Charger and general-purpose leds are supported. Hardware blinking is implemented, breathing is not.
leds->LEDs.Quoted 9 lines
drivers/leds/leds-cht-wcove.c new file +3
-0@@ -0,0 +1,368 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Driver for LEDs connected to the Intel Cherry Trail Whiskey Cove PMIC
Quoted 8 lines
drivers/leds/leds-cht-wcove.c line 9
Quoted 6 lines
drivers/leds/leds-cht-wcove.c new file +6
-0+* +* Copyright 2019 Yauhen Kharuzhy <[email protected]> +* Copyright 2023 Hans de Goede <[email protected]> +* +* Based on Lenovo Yoga Book Android kernel sources +*/ "sources." Should copyrights from Android be copied here?
Quick follow up on this, the original file has no copyright statements, so there is nothing to copy. Also it uses a custom sysfs API, so this new LED driver was pretty much done from scratch. The only thing which comes from the Android source is hw-interface info like register addresses and what various bits in the registers mean.
For v2 I've updated this comment to:
* Register info comes from the Lenovo Yoga Book Android kernel sources:
* YB1_source_code/kernel/cht/drivers/misc/charger_gp_led.c.
Regards,
Hans
PATCH 2/5 leds: cht-wcove: Add suspend/resume handling
In reply to Hans de GoedeWhen LED1 is showing the tablet is charging and then the device gets suspended followed by unplugging the charger, then it will incorrectly still show it is charging.
To avoid this turn both LEDs off on suspend, just like the PMIC always turns them off when the tablet is powered off (even if the tablet is charging). If hw-control is supported for LED1, then restore the initial hw-control settings to let the hw control LED1 while suspended.
To restore the state the LEDs had before suspending, save it before turning the LEDs off and restore it on resume.
--- drivers/leds/leds-cht-wcove.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+)
drivers/leds/leds-cht-wcove.c +33 -0
@@ -15,6 +15,7 @@#include <linux/mod_devicetable.h> #include <linux/platform_device.h> #include <linux/regmap.h> +#include <linux/suspend.h> #define CHT_WC_LED1_CTRL 0x5e1f#define CHT_WC_LED1_FSM 0x5e20
@@ -69,6 +70,7 @@ struct cht_wc_led {const struct cht_wc_led_regs *regs;struct regmap *regmap;struct mutex mutex; +struct cht_wc_led_saved_regs saved_regs; };struct cht_wc_leds {
@@ -352,12 +354,43 @@ static void cht_wc_leds_disable(struct platform_device *pdev)cht_wc_led_restore_regs (&leds->leds[0 ], &leds->led1_initial_regs); } +/* On suspend save current settings and turn LEDs off */ +static int cht_wc_leds_suspend (struct device *dev) +{ +struct cht_wc_leds *leds =dev_get_drvdata (dev); +int i, ret; + +for (i =0 ; i <CHT_WC_LED_COUNT ; i++) { + ret =cht_wc_led_save_regs (&leds->leds[i], &leds->leds[i].saved_regs); +if (ret <0 ) +return ret; + } + +cht_wc_leds_disable (to_platform_device (dev)); +return 0 ; +} + +/* On resume restore the saveds settings */ +static int cht_wc_leds_resume (struct device *dev) +{ +struct cht_wc_leds *leds =dev_get_drvdata (dev); +int i; + +for (i =0 ; i <CHT_WC_LED_COUNT ; i++) +cht_wc_led_restore_regs (&leds->leds[i], &leds->leds[i].saved_regs); + +return 0 ; +} + +static DEFINE_SIMPLE_DEV_PM_OPS(cht_wc_leds_pm, cht_wc_leds_suspend, cht_wc_leds_resume); +static struct platform_driver cht_wc_leds_driver = { .probe = cht_wc_leds_probe, .remove_new = cht_wc_leds_remove, .shutdown = cht_wc_leds_disable, .driver = { .name ="cht_wcove_leds" , + .pm =pm_sleep_ptr (&cht_wc_leds_pm), }, };module_platform_driver (cht_wc_leds_driver);
Signature · 1 line
2.39.1
Re: [PATCH 2/5] leds: cht-wcove: Add suspend/resume handling
Hi!
Review
Quoted 2 lines
(quoted diff) +2
-0+ +/* On resume restore the saveds settings */
-> saved.
Signature · 1 line
People of Russia, stop Putin before his war on Ukraine escalates.
PATCH 3/5 leds: cht-wcove: Add support for breathing mode use hw_pattern sysfs API
In reply to Hans de GoedeThe hw-blinking of the LED controller in the Whiskey Cove PMIC can also be used for a hw-breathing effect.
As discussed during review of v2 of the submission of the new leds-cht-wcove driver, the LED subsystem already supports breathing mode on several other LED controllers using the hw_pattern interface.
Implement a pattern_set callback to implement breathing mode modelled after the breathing mode supported by the SC27xx breathing light and Crane EL15203000 LED drivers. The Whiskey Cove PMIC's breathing mode is closer to the EL15203000 one then to the SC27xx one since it does not support staying high / low for a specific time, it only supports rise and fall times.
As such the supported hw_pattern and the documentation for this is almost a 1:1 copy of the pattern/docs for the EL15203000 breathing mode.
--- Documentation/leds/index.rst | 1 + Documentation/leds/leds-cht-wcove.rst | 29 ++++++++++++++++++ drivers/leds/leds-cht-wcove.c | 42 ++++++++++++++++++++++++--- 3 files changed, 68 insertions(+), 4 deletions(-) create mode 100644 Documentation/leds/leds-cht-wcove.rst
Documentation/leds/index.rst +1 -0
@@ -17,6 +17,7 @@ LEDs uleds leds-blinkm + leds-cht-wcove leds-el15203000 leds-lm3556 leds-lp3944
Documentation/leds/leds-cht-wcove.rst new file +29 -0
@@ -0,0 +1,29 @@ +.. SPDX-License-Identifier: GPL-2.0 + +=========================================================== +Kernel driver for Intel Cherry Trail Whiskey Cove PMIC LEDs +=========================================================== + +/sys/class/leds/<led>/hw_pattern +-------------------------------- + +Specify a hardware pattern for the Whiskey Cove PMIC LEDs. + +The only supported pattern is hardware breathing mode:: + + "0 2000 1 2000" + + ^ + | + Max-| --- + | / \ + | / \ + | / \ / + | / \ / + Min-|- --- + | + 0------2------4--> time (sec) + +The rise and fall times must be the same value. +Supported values are 2000, 1000, 500 and 250 for +breathing frequencies of 1/4, 1/2, 1 and 2 Hz.
drivers/leds/leds-cht-wcove.c +38 -4
66 lines not on this page · raw message
Signature · 1 line
2.39.1
Re: [PATCH 3/5] leds: cht-wcove: Add support for breathing mode use hw_pattern sysfs API
Hi Hans,
Thanks for the patch.
Quoted 49 lines · Hans de Goede
The hw-blinking of the LED controller in the Whiskey Cove PMIC can also be used for a hw-breathing effect.
As discussed during review of v2 of the submission of the new leds-cht-wcove driver, the LED subsystem already supports breathing mode on several other LED controllers using the
hw_patterninterface.Implement a
pattern_setcallback to implement breathing mode modelled after the breathing mode supported by the SC27xx breathing light and Crane EL15203000 LED drivers. The Whiskey Cove PMIC's breathing mode is closer to the EL15203000 one then to the SC27xx one since it does not support staying high / low for a specific time, it only supports rise and fall times.As such the supported
hw_patternand the documentation for this is almost a 1:1 copy of the pattern/docs for the EL15203000 breathing mode.Suggested-by Jacek Anaszewski <[email protected]>Signed-off-by Hans de Goede <[email protected]>--- Documentation/leds/index.rst | 1 + Documentation/leds/leds-cht-wcove.rst | 29 ++++++++++++++++++ drivers/leds/leds-cht-wcove.c | 42 ++++++++++++++++++++++++--- 3 files changed, 68 insertions(+), 4 deletions(-)create mode 100644
Documentation/leds/leds-cht-wcove.rstDocumentation/leds/index.rst +1
-0@@ -17,6 +17,7 @@ LEDs uleds leds-blinkm + leds-cht-wcove leds-el15203000 leds-lm3556 leds-lp3944Documentation/leds/leds-cht-wcove.rst new file +4
-0@@ -0,0 +1,29 @@ +.. SPDX-License-Identifier: GPL-2.0 + +=========================================================== +Kernel driver for Intel Cherry Trail Whiskey Cove PMIC LEDs
Documentation/leds/leds-cht-wcove.rst line 14
Quoted 10 lines
Documentation/leds/leds-cht-wcove.rst new file +10
-0+=========================================================== + +/sys/class/leds/<led>/hw_pattern +-------------------------------- + +Specify a hardware pattern for the Whiskey Cove PMIC LEDs. + +The only supported pattern is hardware breathing mode:: + + "0 2000 1 2000"
Why 1? What is the peek brightness in this mode?
Documentation/leds/leds-cht-wcove.rst line 25
Quoted 11 lines
Documentation/leds/leds-cht-wcove.rst new file +11
-0+ + ^ + | + Max-| --- + | / \ + | / \ + | / \ / + | / \ / + Min-|- --- + | + 0------2------4--> time (sec)
v);
Signature · 2 lines
Best regards, Jacek Anaszewski
Re: [PATCH 3/5] leds: cht-wcove: Add support for breathing mode use hw_pattern sysfs API
Hi Jacek,
Quoted 57 lines · Jacek Anaszewski
Hi Hans,
Thanks for the patch.
Quoted 52 lines · Hans de Goede
The hw-blinking of the LED controller in the Whiskey Cove PMIC can also be used for a hw-breathing effect.
As discussed during review of v2 of the submission of the new leds-cht-wcove driver, the LED subsystem already supports breathing mode on several other LED controllers using the
hw_patterninterface.Implement a
pattern_setcallback to implement breathing mode modelled after the breathing mode supported by the SC27xx breathing light and Crane EL15203000 LED drivers. The Whiskey Cove PMIC's breathing mode is closer to the EL15203000 one then to the SC27xx one since it does not support staying high / low for a specific time, it only supports rise and fall times.As such the supported
hw_patternand the documentation for this is almost a 1:1 copy of the pattern/docs for the EL15203000 breathing mode.Suggested-by Jacek Anaszewski <[email protected]>Signed-off-by Hans de Goede <[email protected]>---
Documentation/leds/index.rst | 1 +Documentation/leds/leds-cht-wcove.rst| 29 ++++++++++++++++++ drivers/leds/leds-cht-wcove.c | 42 ++++++++++++++++++++++++---3 files changed, 68 insertions(+), 4 deletions(-)create mode 100644
Documentation/leds/leds-cht-wcove.rstDocumentation/leds/index.rst +0
-0@@ -17,6 +17,7 @@ LEDsuleds
leds-blinkm
+ leds-cht-wcove
leds-el15203000
leds-lm3556
leds-lp3944Documentation/leds/leds-cht-wcove.rst new file +8
-0@@ -0,0 +1,29 @@ +.. SPDX-License-Identifier: GPL-2.0 + +=========================================================== +Kernel driver for Intel Cherry Trail Whiskey Cove PMIC LEDs +=========================================================== + +/sys/class/leds/<led>/hw_pattern +--------------------------------
Quoted 8 lines
Documentation/leds/leds-cht-wcove.rst line 14
Quoted 6 lines
Documentation/leds/leds-cht-wcove.rst new file +6
-0+ +Specify a hardware pattern for the Whiskey Cove PMIC LEDs. + +The only supported pattern is hardware breathing mode:: + + "0 2000 1 2000"Why 1? What is the peek brightness in this mode?
255, but the pattern only controls the timing. For max brightness the last set brightness is used and the max brightness can be changed while breathing by writing the brightness attribute.
This is just like how blinking works in the LED subsystem, for both sw and hw blinking the brightness can also be changed while blinking. Breathing on this hw really is just a variant mode of blinking.
Regards,
Hans
Quoted 14 lines
Documentation/leds/leds-cht-wcove.rst line 25
Quoted 12 lines
Documentation/leds/leds-cht-wcove.rst new file +11
-0+ + ^ + | + Max-| --- + | / \ + | / \ + | / \ / + | / \ / + Min-|- --- + | + 0------2------4--> time (sec)v);
Re: [PATCH 3/5] leds: cht-wcove: Add support for breathing mode use hw_pattern sysfs API
Hi Hans,
Quoted 5 lines · Hans de Goede
Hi Jacek,
Quoted 2 lines · Jacek Anaszewski
Hi Hans,
[...]
Quoted 15 lines
Quoted 6 lines
Quoted 6 lines
+===========================================================
Documentation/leds/leds-cht-wcove.rst new file +5
-0+Kernel driver for Intel Cherry Trail Whiskey Cove PMIC LEDs +=========================================================== + +/sys/class/leds/<led>/hw_pattern +--------------------------------Quoted 8 lines
Documentation/leds/leds-cht-wcove.rst line 14
Quoted 6 lines
Documentation/leds/leds-cht-wcove.rst new file +6
-0+ +Specify a hardware pattern for the Whiskey Cove PMIC LEDs. + +The only supported pattern is hardware breathing mode:: + + "0 2000 1 2000"Why 1? What is the peek brightness in this mode?
Quoted 8 lines
255, but the pattern only controls the timing. For max brightness the last set brightness is used and the max brightness can be changed while breathing by writing the brightness attribute.
This is just like how blinking works in the LED subsystem, for both sw and hw blinking the brightness can also be changed while blinking. Breathing on this hw really is just a variant mode of blinking.
Thanks for the explanation. So it would be nice to have it also mentioned explicitly here.
Signature · 2 lines
Best regards, Jacek Anaszewski
Re: [PATCH 3/5] leds: cht-wcove: Add support for breathing mode use hw_pattern sysfs API
Hi,
Quoted 28 lines · Jacek Anaszewski
Hi Hans,
Quoted 5 lines · Hans de Goede
Hi Jacek,
Quoted 2 lines · Jacek Anaszewski
Hi Hans,
[...]
Quoted 19 lines
Quoted 6 lines
Quoted 6 lines
+===========================================================
Documentation/leds/leds-cht-wcove.rst new file +5
-0+Kernel driver for Intel Cherry Trail Whiskey Cove PMIC LEDs +=========================================================== + +/sys/class/leds/<led>/hw_pattern +--------------------------------Quoted 8 lines
Documentation/leds/leds-cht-wcove.rst line 14
Quoted 6 lines
Documentation/leds/leds-cht-wcove.rst new file +6
-0+ +Specify a hardware pattern for the Whiskey Cove PMIC LEDs. + +The only supported pattern is hardware breathing mode:: + + "0 2000 1 2000"Why 1? What is the peek brightness in this mode?
255, but the pattern only controls the timing. For max brightness the last set brightness is used and the max brightness can be changed while breathing by writing the brightness attribute.
Quoted 7 lines
Quoted 4 lines
This is just like how blinking works in the LED subsystem, for both sw and hw blinking the brightness can also be changed while blinking. Breathing on this hw really is just a variant mode of blinking.
Thanks for the explanation. So it would be nice to have it also mentioned explicitly here.
Ack, I'll add something like the above explanation to the docs for v2.
Regards,
Hans
PATCH 4/5 leds: cht-wcove: Set default trigger for charging LED
In reply to Hans de GoedeSet a default trigger for the charging LED based on the machine-model as set by the PMIC MFD driver.
--- drivers/leds/leds-cht-wcove.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
drivers/leds/leds-cht-wcove.c +19 -0
@@ -339,6 +339,25 @@ static int cht_wc_leds_probe(struct platform_device *pdev)if (ret <0 )return ret; +/* Set LED1 default trigger based on machine model */ +switch (pmic->cht_wc_model) { +case INTEL_CHT_WC_GPD_WIN_POCKET : + leds->leds[0 ].cdev.default_trigger ="max170xx_battery-charging-blink-full-solid" ; +break ; +case INTEL_CHT_WC_XIAOMI_MIPAD2 : + leds->leds[0 ].cdev.default_trigger ="bq27520-0-charging-blink-full-solid" ; +break ; +case INTEL_CHT_WC_LENOVO_YOGABOOK1 : + leds->leds[0 ].cdev.default_trigger ="bq27542-0-charging-blink-full-solid" ; +break ; +case INTEL_CHT_WC_LENOVO_YT3_X90 : + leds->leds[0 ].cdev.default_trigger ="bq27500-1-charging-blink-full-solid" ; +break ; +default : +dev_warn (&pdev->dev,"Unknown model, no default charging trigger\n" ); +break ; + } +for (i =0 ; i <CHT_WC_LED_COUNT ; i++) {struct cht_wc_led *led = &leds->leds[i];
Signature · 1 line
2.39.1
PATCH 5/5 leds: cht-wcove: Use breathing when LED_INIT_DEFAULT_TRIGGER is set
In reply to Hans de GoedeThe desired default behavior of LED1 / the charge LED is breathing while charging and on/solid when full. Since triggers cannot select breathing, blink_set() gets called when charging. Use breathing when the default "charging-blink-full-solid" trigger is used to achieve the desired default behavior.
--- drivers/leds/leds-cht-wcove.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
drivers/leds/leds-cht-wcove.c +13 -1
@@ -266,7 +266,19 @@ static int cht_wc_leds_blink_set(struct led_classdev *cdev,unsigned long *delay_on, unsigned long *delay_off) { - return cht_wc_leds_set_effect(cdev, delay_on, delay_off, CHT_WC_LED_EFF_BLINKING); + u8 effect = CHT_WC_LED_EFF_BLINKING; + +/* +* The desired default behavior of LED1 / the charge LED is breathing +* while charging and on/solid when full. Since triggers cannot select +* breathing, blink_set() gets called when charging. Use breathing +* when the default "charging-blink-full-solid" trigger is used to +* achieve the desired default behavior. +*/ +if (cdev->flags &LED_INIT_DEFAULT_TRIGGER ) + effect =CHT_WC_LED_EFF_BREATHING ; + +return cht_wc_leds_set_effect (cdev, delay_on, delay_off, effect); } static int cht_wc_leds_pattern_set(struct led_classdev *cdev,
Signature · 1 line
2.39.1
Quoted 36 lines · Hans de Goede
Hi All,
Here is a patch series to add support for the LED controller on Intel Cherry Trail Whiskey Cove PMICs.
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 onprobe()and if auto-/hw-control was enabled onprobe()restore the settings onremove()andshutdown().
- Add support for the pattern trigger to select breathing modeThis 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 usehw_patternsysfs
API
leds: cht-wcove: Set default trigger for charging LED
leds: cht-wcove: Use breathing whenLED_INIT_DEFAULT_TRIGGERis setYauhen Kharuzhy (1):
leds: Add Intel Cherry Trail Whiskey Cove PMIC LED driver
Quoted 8 lines
Documentation/leds/index.rst | 1 + Documentation/leds/leds-cht-wcove.rst | 29 ++ drivers/leds/Kconfig | 11 + drivers/leds/Makefile | 1 + drivers/leds/leds-cht-wcove.c | 466 ++++++++++++++++++++++++++ 5 files changed, 508 insertions(+) create mode 100644 Documentation/leds/leds-cht-wcove.rst create mode 100644 drivers/leds/leds-cht-wcove.c
Hi Hans,
Thanks for reviving this patch!
I haven't tested it on linux-next yet but on v6.2.11 (with few patches for Yoabook) I catched following trace. I will investigate it later but maybe you can take a look also?
[ 192.585809] bq25890-charger i2c-bq25892: S:CHG/PG/VSYS=2/1/0, F:CHG/BOOST/BAT/NTC=0/0/0/0 [ 196.753095] bq25890-charger i2c-bq25892: Start to request input voltage increasing [ 196.770555] bq25890-charger i2c-bq25892: input voltage = 4000000 uV [ 200.473777] bq25890-charger i2c-bq25892: input voltage = 5900000 uV [ 204.187438] bq25890-charger i2c-bq25892: input voltage = 7900000 uV [ 207.864890] bq25890-charger i2c-bq25892: input voltage = 11000000 uV [ 211.573333] bq25890-charger i2c-bq25892: input voltage = 10900000 uV [ 215.222692] bq25890-charger i2c-bq25892: input voltage = 11000000 uV [ 218.937871] bq25890-charger i2c-bq25892: Hi-voltage charging requested, input voltage is 11000000 mV [ 242.786148] systemd-journald[270]: Data hash table of /var/log/journal/39241a358af746c292cb608baea5be4c/system.journal has a fill level at 75.0 (8533 of 11377 items, 6553600 file size, 768 bytes per hash table item), suggesting rotation. [ 242.786185] systemd-journald[270]: /var/log/journal/39241a358af746c292cb608baea5be4c/system.journal: Journal header limits reached or header out-of-date, rotating. [ 257.790169] ------------[ cut here ]------------ [ 257.790223] Voluntary context switch within RCU read-side critical section! [ 257.790256] WARNING: CPU: 3 PID: 69 at kernel/rcu/tree_plugin.h:318 rcu_note_context_switch+0x4e3/0x6c0 [ 257.790337] Modules linked in: rfcomm(E) snd_seq_dummy(E) snd_hrtimer(E) snd_seq(E) snd_seq_device(E) cmac(E) algif_hash(E) algif_skcipher(E) af_alg(E) bnep(E) uinput(E) binfmt_misc(E) intel_powerclamp(E) coretemp(E) kvm_intel(E) snd_soc_sst_cht_yogabook(E) snd_soc_ts3a227e(E) kvm(E) irqbypass(E) crct10dif_pclmul(E) ghash_clmulni_intel(E) snd_sof_acpi_intel_byt(E) snd_sof_acpi(E) sha512_ssse3(E) snd_sof_intel_atom(E) snd_sof(E) snd_sof_utils(E) snd_sof_xtensa_dsp(E) aesni_intel(E) snd_intel_sst_acpi(E) crypto_simd(E) snd_intel_sst_core(E) cryptd(E) gpio_keys(E) intel_rapl_msr(E) brcmfmac_wcc(E) intel_cstate(E) lenovo_yogabook_wmi(E) wmi_bmof(E) pcspkr(E) hci_uart(E) btqca(E) snd_soc_sst_atom_hifi2_platform(E) btbcm(E) snd_soc_rt5677(E) bq25890_charger(E) btintel(E) snd_soc_rt5677_spi(E) snd_soc_acpi_intel_match(E) joydev(E) leds_cht_wcove(E) extcon_intel_cht_wc(E) hid_multitouch(E) brcmfmac(E) snd_soc_acpi(E) snd_soc_rl6231(E) bluetooth(E) brcmutil(E) bq27xxx_battery_i2c(E) nls_ascii(E) [ 257.790879] bq27xxx_battery(E) nls_cp437(E) hid_sensor_accel_3d(E) hid_sensor_custom_intel_hinge(E) hid_sensor_als(E) spi_nor(E) snd_soc_core(E) iTCO_wdt(E) hid_sensor_trigger(E) vfat(E) snd_compress(E) cfg80211(E) mtd(E) iTCO_vendor_support(E) hid_sensor_iio_common(E) snd_hdmi_lpe_audio(E) fat(E) snd_intel_dspcfg(E) jitterentropy_rng(E) sx9310(E) snd_pcm(E) sx_common(E) tpm_crb(E) snd_timer(E) industrialio_triggered_buffer(E) goodix_ts(E) drbg(E) kfifo_buf(E) intel_hid(E) sparse_keymap(E) snd(E) rfkill_gpio(E) soundcore(E) tpm_tis(E) industrialio(E) ansi_cprng(E) tpm_tis_core(E) ecdh_generic(E) rfkill(E) ecc(E) tpm(E) processor_thermal_device_pci_legacy(E) processor_thermal_device(E) processor_thermal_rfim(E) rng_core(E) processor_thermal_mbox(E) processor_thermal_rapl(E) intel_rapl_common(E) int3400_thermal(E) int3406_thermal(E) int3403_thermal(E) soc_button_array(E) acpi_thermal_rel(E) int340x_thermal_zone(E) intel_int0002_vgpio(E) evdev(E) intel_soc_dts_iosf(E) acpi_pad(E) [ 257.791393] squashfs(E) loop(E) ramoops(E) reed_solomon(E) intel_pstore_pram(E) msr(E) parport_pc(E) ppdev(E) lp(E) parport(E) fuse(E) efi_pstore(E) configfs(E) efivarfs(E) ip_tables(E) x_tables(E) autofs4(E) ext4(E) crc32c_generic(E) crc16(E) mbcache(E) jbd2(E) hid_sensor_custom(E) hid_sensor_hub(E) intel_ishtp_hid(E) wacom(E) dwc3(E) usbhid(E) ulpi(E) hid_generic(E) udc_core(E) i915(E) xhci_pci(E) spi_intel_platform(E) i2c_algo_bit(E) spi_intel(E) mmc_block(E) xhci_hcd(E) drm_buddy(E) drm_display_helper(E) cec(E) ttm(E) usbcore(E) video(E) drm_kms_helper(E) intel_ish_ipc(E) crc32_pclmul(E) spi_pxa2xx_platform(E) crc32c_intel(E) i2c_cht_wc(E) i2c_hid_acpi(E) lpc_ich(E) dwc3_pci(E) usb_common(E) drm(E) intel_ishtp(E) thermal(E) i2c_hid(E) hid(E) wmi(E) sdhci_acpi(E) dw_dmac(E) sdhci(E) pwm_lpss_platform(E) pwm_lpss(E) dw_dmac_core(E) mmc_core(E) button(E) [ 257.792047] CPU: 3 PID: 69 Comm: kworker/3:2 Tainted: G E 6.2.11-yogabook1 #57 [ 257.792084] Hardware name: LENOVO Lenovo YB1-X91L/INVALID, BIOS 04WT18WW 08/26/2016 [ 257.792110] Workqueue: events power_supply_changed_work [ 257.792163] RIP: 0010:rcu_note_context_switch+0x4e3/0x6c0 [ 257.792206] Code: 49 89 3e 49 83 bc 24 98 00 00 00 00 0f 85 6c fe ff ff e9 5e fe ff ff 48 c7 c7 f0 5e d0 be c6 05 e7 bb 45 01 01 e8 ed 66 f6 ff <0f> 0b e9 7c fb ff ff a9 ff ff ff 7f 0f 84 38 fc ff ff 65 48 8b 3c [ 257.792240] RSP: 0018:ffffb357003ef830 EFLAGS: 00010046 [ 257.792275] RAX: 0000000000000000 RBX: ffff95dd3abae280 RCX: 0000000000000000 [ 257.792302] RDX: 0000000000000003 RSI: ffffffffbed4bfb7 RDI: 00000000ffffffff [ 257.792327] RBP: 0000000000000000 R08: 0000000000000000 R09: ffffb357003ef6e0 [ 257.792352] R10: 0000000000000003 R11: ffff95dd3fbfefe8 R12: 000000000002d400 [ 257.792376] R13: ffff95dcca22cc40 R14: 0000000000000000 R15: ffff95dcca22cc40 [ 257.792403] FS: 0000000000000000(0000) GS:ffff95dd3ab80000(0000) knlGS:0000000000000000 [ 257.792431] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 257.792456] CR2: 000055cdc7a88670 CR3: 0000000155c0a000 CR4: 00000000001006e0 [ 257.792485] Call Trace: [ 257.792511] <TASK> [ 257.792535] ? _raw_spin_lock_irqsave+0x23/0x50 [ 257.792579] ? preempt_count_add+0x62/0xa0 [ 257.792625] __schedule+0xac/0x9d0 [ 257.792663] ? _raw_spin_unlock_irqrestore+0x23/0x40 [ 257.792700] ? __mod_timer+0x28a/0x3c0 [ 257.792743] schedule+0x5d/0xe0 [ 257.792775] schedule_timeout+0x8a/0x160 [ 257.792812] ? __bpf_trace_tick_stop+0x10/0x10 [ 257.792849] msleep+0x29/0x40 [ 257.792885] acpi_lpss_resume+0x6e/0x160 [ 257.792924] ? acpi_lpss_resume+0x160/0x160 [ 257.792958] acpi_lpss_runtime_resume+0xe/0x20 [ 257.792993] __rpm_callback+0x44/0x170 [ 257.793029] ? acpi_lpss_resume+0x160/0x160 [ 257.793065] rpm_callback+0x59/0x70 [ 257.793100] ? acpi_lpss_resume+0x160/0x160 [ 257.793135] rpm_resume+0x5f8/0x850 [ 257.793168] ? acpi_ut_update_ref_count.part.0+0x7a/0x8f0 [ 257.793215] __pm_runtime_resume+0x3c/0x60 [ 257.793251] i2c_dw_xfer+0x47/0x490 [ 257.793291] __i2c_transfer+0x16e/0x6c0 [ 257.793335] i2c_smbus_xfer_emulated+0x26f/0x9c0 [ 257.793375] ? __switch_to+0x7e/0x420 [ 257.793410] ? update_load_avg+0x80/0x790 [ 257.793447] __i2c_smbus_xfer+0xab/0x410 [ 257.793477] ? enqueue_entity+0x19a/0x4f0 [ 257.793514] i2c_smbus_xfer+0x6a/0xe0 [ 257.793547] i2c_smbus_read_byte_data+0x45/0x70 [ 257.793578] ? _raw_spin_unlock_irqrestore+0x23/0x40 [ 257.793615] ? try_to_wake_up+0x95/0x590 [ 257.793653] cht_wc_byte_reg_read+0x2e/0x60 [ 257.793701] _regmap_read+0x5a/0x110 [ 257.793737] _regmap_update_bits+0xb4/0xf0 [ 257.793775] regmap_update_bits_base+0x59/0x80 [ 257.793816] cht_wc_leds_set_effect+0xcb/0x1b0 [leds_cht_wcove] [ 257.793875] led_blink_setup+0x25/0x100 [ 257.793912] led_trigger_blink+0x45/0x70 [ 257.793947] power_supply_update_leds+0x1d6/0x1e0 [ 257.793991] power_supply_changed_work+0x6f/0xf0 [ 257.794029] process_one_work+0x1c7/0x3c0 [ 257.794065] worker_thread+0x4e/0x3a0 [ 257.794095] ? _raw_spin_lock_irqsave+0x23/0x50 [ 257.794133] ? rescuer_thread+0x3b0/0x3b0 [ 257.794161] kthread+0xe9/0x110 [ 257.794195] ? kthread_complete_and_exit+0x20/0x20 [ 257.794233] ret_from_fork+0x1f/0x30 [ 257.794280] </TASK> [ 257.794298] ---[ end trace 0000000000000000 ]--- [ 257.854563] bq25890-charger i2c-bq25892: S:CHG/PG/VSYS=2/1/0, F:CHG/BOOST/BAT/NTC=0/0/0/0
Signature · 1 line
Yauhen Kharuzhy
Hi Yauhen,
Quoted 46 lines · Yauhen Kharuzhy
Quoted 36 lines · Hans de Goede
Hi All,
Here is a patch series to add support for the LED controller on Intel Cherry Trail Whiskey Cove PMICs.
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 onprobe()and if auto-/hw-control was enabled onprobe()restore the settings onremove()andshutdown().
- Add support for the pattern trigger to select breathing modeThis 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 usehw_patternsysfs
API
leds: cht-wcove: Set default trigger for charging LED
leds: cht-wcove: Use breathing whenLED_INIT_DEFAULT_TRIGGERis setYauhen Kharuzhy (1):
leds: Add Intel Cherry Trail Whiskey Cove PMIC LED driverQuoted 8 lines
Documentation/leds/index.rst | 1 + Documentation/leds/leds-cht-wcove.rst | 29 ++ drivers/leds/Kconfig | 11 + drivers/leds/Makefile | 1 + drivers/leds/leds-cht-wcove.c | 466 ++++++++++++++++++++++++++ 5 files changed, 508 insertions(+) create mode 100644 Documentation/leds/leds-cht-wcove.rst create mode 100644 drivers/leds/leds-cht-wcove.c
Quoted 3 lines
Hi Hans,
Thanks for reviving this patch!
You're welcome.
Quoted 3 lines
I haven't tested it on linux-next yet but on v6.2.11 (with few patches for Yoabook) I catched following trace. I will investigate it later but maybe you can take a look also?
Right, this is an unrelated pre-existing kernel bug when using led_trigger_blink().
I already hit that myself and I have a fix for it, see this series:
https://lore.kernel.org/linux-leds/[email protected]/
And for the blinking -> solid transition to work when the battery goes from charging to full you also need:
https://lore.kernel.org/linux-pm/[email protected]/
I guess I should have mentioned both in the cover-letter, sorry about that.
And related to this there are also these 2 power-supply patch series which are also relevant for the yogabook:
https://lore.kernel.org/linux-pm/[email protected]/
https://lore.kernel.org/linux-pm/[email protected]/
Regards,
Hans
Quoted 83 lines
[ 192.585809] bq25890-charger i2c-bq25892: S:CHG/PG/VSYS=2/1/0, F:CHG/BOOST/BAT/NTC=0/0/0/0 [ 196.753095] bq25890-charger i2c-bq25892: Start to request input voltage increasing [ 196.770555] bq25890-charger i2c-bq25892: input voltage = 4000000 uV [ 200.473777] bq25890-charger i2c-bq25892: input voltage = 5900000 uV [ 204.187438] bq25890-charger i2c-bq25892: input voltage = 7900000 uV [ 207.864890] bq25890-charger i2c-bq25892: input voltage = 11000000 uV [ 211.573333] bq25890-charger i2c-bq25892: input voltage = 10900000 uV [ 215.222692] bq25890-charger i2c-bq25892: input voltage = 11000000 uV [ 218.937871] bq25890-charger i2c-bq25892: Hi-voltage charging requested, input voltage is 11000000 mV [ 242.786148] systemd-journald[270]: Data hash table of /var/log/journal/39241a358af746c292cb608baea5be4c/system.journal has a fill level at 75.0 (8533 of 11377 items, 6553600 file size, 768 bytes per hash table item), suggesting rotation. [ 242.786185] systemd-journald[270]: /var/log/journal/39241a358af746c292cb608baea5be4c/system.journal: Journal header limits reached or header out-of-date, rotating. [ 257.790169] ------------[ cut here ]------------ [ 257.790223] Voluntary context switch within RCU read-side critical section! [ 257.790256] WARNING: CPU: 3 PID: 69 at kernel/rcu/tree_plugin.h:318 rcu_note_context_switch+0x4e3/0x6c0 [ 257.790337] Modules linked in: rfcomm(E) snd_seq_dummy(E) snd_hrtimer(E) snd_seq(E) snd_seq_device(E) cmac(E) algif_hash(E) algif_skcipher(E) af_alg(E) bnep(E) uinput(E) binfmt_misc(E) intel_powerclamp(E) coretemp(E) kvm_intel(E) snd_soc_sst_cht_yogabook(E) snd_soc_ts3a227e(E) kvm(E) irqbypass(E) crct10dif_pclmul(E) ghash_clmulni_intel(E) snd_sof_acpi_intel_byt(E) snd_sof_acpi(E) sha512_ssse3(E) snd_sof_intel_atom(E) snd_sof(E) snd_sof_utils(E) snd_sof_xtensa_dsp(E) aesni_intel(E) snd_intel_sst_acpi(E) crypto_simd(E) snd_intel_sst_core(E) cryptd(E) gpio_keys(E) intel_rapl_msr(E) brcmfmac_wcc(E) intel_cstate(E) lenovo_yogabook_wmi(E) wmi_bmof(E) pcspkr(E) hci_uart(E) btqca(E) snd_soc_sst_atom_hifi2_platform(E) btbcm(E) snd_soc_rt5677(E) bq25890_charger(E) btintel(E) snd_soc_rt5677_spi(E) snd_soc_acpi_intel_match(E) joydev(E) leds_cht_wcove(E) extcon_intel_cht_wc(E) hid_multitouch(E) brcmfmac(E) snd_soc_acpi(E) snd_soc_rl6231(E) bluetooth(E) brcmutil(E) bq27xxx_battery_i2c(E) nls_ascii(E) [ 257.790879] bq27xxx_battery(E) nls_cp437(E) hid_sensor_accel_3d(E) hid_sensor_custom_intel_hinge(E) hid_sensor_als(E) spi_nor(E) snd_soc_core(E) iTCO_wdt(E) hid_sensor_trigger(E) vfat(E) snd_compress(E) cfg80211(E) mtd(E) iTCO_vendor_support(E) hid_sensor_iio_common(E) snd_hdmi_lpe_audio(E) fat(E) snd_intel_dspcfg(E) jitterentropy_rng(E) sx9310(E) snd_pcm(E) sx_common(E) tpm_crb(E) snd_timer(E) industrialio_triggered_buffer(E) goodix_ts(E) drbg(E) kfifo_buf(E) intel_hid(E) sparse_keymap(E) snd(E) rfkill_gpio(E) soundcore(E) tpm_tis(E) industrialio(E) ansi_cprng(E) tpm_tis_core(E) ecdh_generic(E) rfkill(E) ecc(E) tpm(E) processor_thermal_device_pci_legacy(E) processor_thermal_device(E) processor_thermal_rfim(E) rng_core(E) processor_thermal_mbox(E) processor_thermal_rapl(E) intel_rapl_common(E) int3400_thermal(E) int3406_thermal(E) int3403_thermal(E) soc_button_array(E) acpi_thermal_rel(E) int340x_thermal_zone(E) intel_int0002_vgpio(E) evdev(E) intel_soc_dts_iosf(E) acpi_pad(E) [ 257.791393] squashfs(E) loop(E) ramoops(E) reed_solomon(E) intel_pstore_pram(E) msr(E) parport_pc(E) ppdev(E) lp(E) parport(E) fuse(E) efi_pstore(E) configfs(E) efivarfs(E) ip_tables(E) x_tables(E) autofs4(E) ext4(E) crc32c_generic(E) crc16(E) mbcache(E) jbd2(E) hid_sensor_custom(E) hid_sensor_hub(E) intel_ishtp_hid(E) wacom(E) dwc3(E) usbhid(E) ulpi(E) hid_generic(E) udc_core(E) i915(E) xhci_pci(E) spi_intel_platform(E) i2c_algo_bit(E) spi_intel(E) mmc_block(E) xhci_hcd(E) drm_buddy(E) drm_display_helper(E) cec(E) ttm(E) usbcore(E) video(E) drm_kms_helper(E) intel_ish_ipc(E) crc32_pclmul(E) spi_pxa2xx_platform(E) crc32c_intel(E) i2c_cht_wc(E) i2c_hid_acpi(E) lpc_ich(E) dwc3_pci(E) usb_common(E) drm(E) intel_ishtp(E) thermal(E) i2c_hid(E) hid(E) wmi(E) sdhci_acpi(E) dw_dmac(E) sdhci(E) pwm_lpss_platform(E) pwm_lpss(E) dw_dmac_core(E) mmc_core(E) button(E) [ 257.792047] CPU: 3 PID: 69 Comm: kworker/3:2 Tainted: G E 6.2.11-yogabook1 #57 [ 257.792084] Hardware name: LENOVO Lenovo YB1-X91L/INVALID, BIOS 04WT18WW 08/26/2016 [ 257.792110] Workqueue: events power_supply_changed_work [ 257.792163] RIP: 0010:rcu_note_context_switch+0x4e3/0x6c0 [ 257.792206] Code: 49 89 3e 49 83 bc 24 98 00 00 00 00 0f 85 6c fe ff ff e9 5e fe ff ff 48 c7 c7 f0 5e d0 be c6 05 e7 bb 45 01 01 e8 ed 66 f6 ff <0f> 0b e9 7c fb ff ff a9 ff ff ff 7f 0f 84 38 fc ff ff 65 48 8b 3c [ 257.792240] RSP: 0018:ffffb357003ef830 EFLAGS: 00010046 [ 257.792275] RAX: 0000000000000000 RBX: ffff95dd3abae280 RCX: 0000000000000000 [ 257.792302] RDX: 0000000000000003 RSI: ffffffffbed4bfb7 RDI: 00000000ffffffff [ 257.792327] RBP: 0000000000000000 R08: 0000000000000000 R09: ffffb357003ef6e0 [ 257.792352] R10: 0000000000000003 R11: ffff95dd3fbfefe8 R12: 000000000002d400 [ 257.792376] R13: ffff95dcca22cc40 R14: 0000000000000000 R15: ffff95dcca22cc40 [ 257.792403] FS: 0000000000000000(0000) GS:ffff95dd3ab80000(0000) knlGS:0000000000000000 [ 257.792431] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 257.792456] CR2: 000055cdc7a88670 CR3: 0000000155c0a000 CR4: 00000000001006e0 [ 257.792485] Call Trace: [ 257.792511] <TASK> [ 257.792535] ? _raw_spin_lock_irqsave+0x23/0x50 [ 257.792579] ? preempt_count_add+0x62/0xa0 [ 257.792625] __schedule+0xac/0x9d0 [ 257.792663] ? _raw_spin_unlock_irqrestore+0x23/0x40 [ 257.792700] ? __mod_timer+0x28a/0x3c0 [ 257.792743] schedule+0x5d/0xe0 [ 257.792775] schedule_timeout+0x8a/0x160 [ 257.792812] ? __bpf_trace_tick_stop+0x10/0x10 [ 257.792849] msleep+0x29/0x40 [ 257.792885] acpi_lpss_resume+0x6e/0x160 [ 257.792924] ? acpi_lpss_resume+0x160/0x160 [ 257.792958] acpi_lpss_runtime_resume+0xe/0x20 [ 257.792993] __rpm_callback+0x44/0x170 [ 257.793029] ? acpi_lpss_resume+0x160/0x160 [ 257.793065] rpm_callback+0x59/0x70 [ 257.793100] ? acpi_lpss_resume+0x160/0x160 [ 257.793135] rpm_resume+0x5f8/0x850 [ 257.793168] ? acpi_ut_update_ref_count.part.0+0x7a/0x8f0 [ 257.793215] __pm_runtime_resume+0x3c/0x60 [ 257.793251] i2c_dw_xfer+0x47/0x490 [ 257.793291] __i2c_transfer+0x16e/0x6c0 [ 257.793335] i2c_smbus_xfer_emulated+0x26f/0x9c0 [ 257.793375] ? __switch_to+0x7e/0x420 [ 257.793410] ? update_load_avg+0x80/0x790 [ 257.793447] __i2c_smbus_xfer+0xab/0x410 [ 257.793477] ? enqueue_entity+0x19a/0x4f0 [ 257.793514] i2c_smbus_xfer+0x6a/0xe0 [ 257.793547] i2c_smbus_read_byte_data+0x45/0x70 [ 257.793578] ? _raw_spin_unlock_irqrestore+0x23/0x40 [ 257.793615] ? try_to_wake_up+0x95/0x590 [ 257.793653] cht_wc_byte_reg_read+0x2e/0x60 [ 257.793701] _regmap_read+0x5a/0x110 [ 257.793737] _regmap_update_bits+0xb4/0xf0 [ 257.793775] regmap_update_bits_base+0x59/0x80 [ 257.793816] cht_wc_leds_set_effect+0xcb/0x1b0 [leds_cht_wcove] [ 257.793875] led_blink_setup+0x25/0x100 [ 257.793912] led_trigger_blink+0x45/0x70 [ 257.793947] power_supply_update_leds+0x1d6/0x1e0 [ 257.793991] power_supply_changed_work+0x6f/0xf0 [ 257.794029] process_one_work+0x1c7/0x3c0 [ 257.794065] worker_thread+0x4e/0x3a0 [ 257.794095] ? _raw_spin_lock_irqsave+0x23/0x50 [ 257.794133] ? rescuer_thread+0x3b0/0x3b0 [ 257.794161] kthread+0xe9/0x110 [ 257.794195] ? kthread_complete_and_exit+0x20/0x20 [ 257.794233] ret_from_fork+0x1f/0x30 [ 257.794280] </TASK> [ 257.794298] ---[ end trace 0000000000000000 ]--- [ 257.854563] bq25890-charger i2c-bq25892: S:CHG/PG/VSYS=2/1/0, F:CHG/BOOST/BAT/NTC=0/0/0/0
Hi Yauhen,
Quoted 59 lines · Hans de Goede
Hi Yauhen,
Quoted 46 lines · Yauhen Kharuzhy
Quoted 36 lines · Hans de Goede
Hi All,
Here is a patch series to add support for the LED controller on Intel Cherry Trail Whiskey Cove PMICs.
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 onprobe()and if auto-/hw-control was enabled onprobe()restore the settings onremove()andshutdown().
- Add support for the pattern trigger to select breathing modeThis 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 usehw_patternsysfs
API
leds: cht-wcove: Set default trigger for charging LED
leds: cht-wcove: Use breathing whenLED_INIT_DEFAULT_TRIGGERis setYauhen Kharuzhy (1):
leds: Add Intel Cherry Trail Whiskey Cove PMIC LED driverQuoted 8 lines
Documentation/leds/index.rst | 1 + Documentation/leds/leds-cht-wcove.rst | 29 ++ drivers/leds/Kconfig | 11 + drivers/leds/Makefile | 1 + drivers/leds/leds-cht-wcove.c | 466 ++++++++++++++++++++++++++ 5 files changed, 508 insertions(+) create mode 100644 Documentation/leds/leds-cht-wcove.rst create mode 100644 drivers/leds/leds-cht-wcove.cQuoted 3 lines
Hi Hans,
Thanks for reviving this patch!
You're welcome.
Quoted 3 lines
I haven't tested it on linux-next yet but on v6.2.11 (with few patches for Yoabook) I catched following trace. I will investigate it later but maybe you can take a look also?
Quoted 5 lines
Right, this is an unrelated pre-existing kernel bug when using
led_trigger_blink().I already hit that myself and I have a fix for it, see this series:
https://lore.kernel.org/linux-leds/[email protected]/
Lee is asking for testers of this series, if you have time it would be good if you can give this series a try in combination with this new leds-cht-wcove driver.
Assuming the other series fixed the oops/backtrace for you can you please reply with your Tested-by to that series:
https://lore.kernel.org/linux-leds/[email protected]/
(or even better give your Tested-by for both series)
Regards,
Hans
Hi,
OK, I will test the latest version near the weekend and will reply with Tested-by if all will be fine.
вт, 25 апр. 2023 г. в 16:37, Hans de Goede <[email protected]>:
Quoted 84 lines
Hi Yauhen,
Quoted 59 lines · Hans de Goede
Hi Yauhen,
Quoted 46 lines · Yauhen Kharuzhy
Quoted 36 lines · Hans de Goede
Hi All,
Here is a patch series to add support for the LED controller on Intel Cherry Trail Whiskey Cove PMICs.
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 onprobe()and if auto-/hw-control was enabled onprobe()restore the settings onremove()andshutdown().
- Add support for the pattern trigger to select breathing modeThis 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 usehw_patternsysfs
API
leds: cht-wcove: Set default trigger for charging LED
leds: cht-wcove: Use breathing whenLED_INIT_DEFAULT_TRIGGERis setYauhen Kharuzhy (1):
leds: Add Intel Cherry Trail Whiskey Cove PMIC LED driverQuoted 8 lines
Documentation/leds/index.rst | 1 + Documentation/leds/leds-cht-wcove.rst | 29 ++ drivers/leds/Kconfig | 11 + drivers/leds/Makefile | 1 + drivers/leds/leds-cht-wcove.c | 466 ++++++++++++++++++++++++++ 5 files changed, 508 insertions(+) create mode 100644 Documentation/leds/leds-cht-wcove.rst create mode 100644 drivers/leds/leds-cht-wcove.cQuoted 3 lines
Hi Hans,
Thanks for reviving this patch!
You're welcome.
Quoted 3 lines
I haven't tested it on linux-next yet but on v6.2.11 (with few patches for Yoabook) I catched following trace. I will investigate it later but maybe you can take a look also?
Quoted 5 lines
Right, this is an unrelated pre-existing kernel bug when using
led_trigger_blink().I already hit that myself and I have a fix for it, see this series:
https://lore.kernel.org/linux-leds/[email protected]/Lee is asking for testers of this series, if you have time it would be good if you can give this series a try in combination with this new leds-cht-wcove driver.
Assuming the other series fixed the oops/backtrace for you can you please reply with your Tested-by to that series:
https://lore.kernel.org/linux-leds/[email protected]/
(or even better give your Tested-by for both series)
Regards,
Hans
Signature · 1 line
Yauhen Kharuzhy