Skip to contentSkip to conversation

leds: Add Intel Cherry Trail Whiskey Cove PMIC LED driver

PATCH Applied Hans de Goede 3 participants 14 messages Apr 30, 2023 – May 15, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

v3 cover leds: Add Intel Cherry Trail Whiskey Cove PMIC LED driver

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
Signature · 1 line
2.39.2
#1 lore raw

PATCH v3 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)).

---
Changes in v3:
- Some comment tweaks and s/LED_OFF/0/
- 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:
- Update comment about YB1 kernel source usage for register info
- Replace "cht-wc::" LED name prefix with "platform::"
- Add leds-cht-wcove to list of drivers using "platform::charging" in Documentation/leds/well-known-leds.txt
- Bail from cht_wc_leds_brightness_set() on first error
- Make default blink 1Hz, like sw-blink default blink

---
 Documentation/leds/well-known-leds.txt |   2 +-
 drivers/leds/Kconfig                   |  11 +
 drivers/leds/Makefile                  |   1 +
 drivers/leds/leds-cht-wcove.c          | 380 +++++++++++++++++++++++++
 4 files changed, 393 insertions(+), 1 deletion(-)
 create mode 100644 drivers/leds/leds-cht-wcove.c
Documentation/leds/well-known-leds.txt +1 -1
index 2160382c86be..7640debee6c0 100644
@@ -65,7 +65,7 @@ Phones usually have multi-color status LED.
 
 * Power management
 
-Good: "platform:*:charging" (allwinner sun50i)
+Good: "platform:*:charging" (allwinner sun50i, leds-cht-wcove)
 
 * Screen
 
drivers/leds/Kconfig +11 -0
index 9dbce09eabac..90835716f14a 100644
@@ -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
index d30395d11fd8..78b5b69f9c54 100644
@@ -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 +380 -0

380 lines not on this page · raw message

Signature · 1 line
2.39.2
maintainer Applied
#2 lore raw
Quoted 35 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.

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)).

---
Changes in v3:
- Some comment tweaks and s/LED_OFF/0/
- 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:
- Update comment about YB1 kernel source usage for register info
- Replace "cht-wc::" LED name prefix with "platform::"
- Add leds-cht-wcove to list of drivers using "platform::charging" in Documentation/leds/well-known-leds.txt
- Bail from cht_wc_leds_brightness_set() on first error
- Make default blink 1Hz, like sw-blink default blink

Quoted 7 lines
---
 Documentation/leds/well-known-leds.txt |   2 +-
 drivers/leds/Kconfig                   |  11 +
 drivers/leds/Makefile                  |   1 +
 drivers/leds/leds-cht-wcove.c          | 380 +++++++++++++++++++++++++
 4 files changed, 393 insertions(+), 1 deletion(-)
 create mode 100644 drivers/leds/leds-cht-wcove.c

Applied, thanks

Signature · 1 line
Lee Jones [李琼斯]
#3 lore raw

PATCH v3 2/5 leds: cht-wcove: Add suspend/resume handling

In reply to Hans de Goede

When 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
index 9fe76a0c62c8..166b140e132a 100644
@@ -17,6 +17,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 {
@@ -364,12 +366,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 saved 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.2
maintainer Applied
#4 lore raw

Re: [PATCH v3 2/5] leds: cht-wcove: Add suspend/resume handling

Quoted 9 lines · Hans de Goede

When 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.

Quoted 8 lines

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(+)

Applied, thanks

Signature · 1 line
Lee Jones [李琼斯]
#5 lore raw

PATCH v3 3/5 leds: cht-wcove: Add support for breathing mode use hw_pattern sysfs API

In reply to 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_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.

---
Changes in v3
- s/LED_OFF/0/ and s/LED_ON/1/

Changes in v2
- Improve/extend Documentation/leds/leds-cht-wcove.rst a bit

---
 Documentation/leds/index.rst          |  1 +
 Documentation/leds/leds-cht-wcove.rst | 38 ++++++++++++++++++++++++
 drivers/leds/leds-cht-wcove.c         | 42 ++++++++++++++++++++++++---
 3 files changed, 77 insertions(+), 4 deletions(-)
 create mode 100644 Documentation/leds/leds-cht-wcove.rst
Documentation/leds/index.rst +1 -0
index b9ca081fac71..c92612271e25 100644
@@ -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 +38 -0
new file mode 100644
index 000000000000..5ec7cb60c4aa
@@ -0,0 +1,38 @@
+.. 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.
+
+The set 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.
drivers/leds/leds-cht-wcove.c +38 -4

66 lines not on this page · raw message

Signature · 1 line
2.39.2
maintainer Applied
#6 lore raw

Re: [PATCH v3 3/5] leds: cht-wcove: Add support for breathing mode use hw_pattern sysfs API

Quoted 24 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_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.

---
Changes in v3
- s/LED_OFF/0/ and s/LED_ON/1/

Quoted 8 lines

Changes in v2
- Improve/extend Documentation/leds/leds-cht-wcove.rst a bit

---
 Documentation/leds/index.rst          |  1 +
 Documentation/leds/leds-cht-wcove.rst | 38 ++++++++++++++++++++++++
 drivers/leds/leds-cht-wcove.c         | 42 ++++++++++++++++++++++++---
 3 files changed, 77 insertions(+), 4 deletions(-)
 create mode 100644 Documentation/leds/leds-cht-wcove.rst

Applied, thanks

Signature · 1 line
Lee Jones [李琼斯]
#7 lore raw

PATCH v3 4/5 leds: cht-wcove: Set default trigger for charging LED

In reply to Hans de Goede

Set 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 | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
drivers/leds/leds-cht-wcove.c +16 -0
index 36fb4c2c3c13..ee9fb4bee018 100644
@@ -351,6 +351,22 @@ 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;
+	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.2
maintainer Applied
#8 lore raw

Re: [PATCH v3 4/5] leds: cht-wcove: Set default trigger for charging LED

Quoted 7 lines · Hans de Goede

Set 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 | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

Applied, thanks

Signature · 1 line
Lee Jones [李琼斯]
#9 lore raw

PATCH v3 5/5 leds: cht-wcove: Use breathing when LED_INIT_DEFAULT_TRIGGER is set

In reply to Hans de Goede

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.

---
Changes in v3:
- Also set on/off delay to 1000 so that we get a slow breathing effect, this counter-acts the v2 cht_wc_leds_set_effect() change changing the default delays from 1000 to 500

---
 drivers/leds/leds-cht-wcove.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)
drivers/leds/leds-cht-wcove.c +15 -1
index ee9fb4bee018..0cfebee98910 100644
@@ -270,7 +270,21 @@ 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 slow breathing
+	 * when the default "charging-blink-full-solid" trigger is used to
+	 * achieve the desired default behavior.
+	 */
+	if (cdev->flags & LED_INIT_DEFAULT_TRIGGER) {
+		*delay_on = *delay_off = 1000;
+		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.2
maintainer Applied
#10 lore raw

Re: [PATCH v3 5/5] leds: cht-wcove: Use breathing when LED_INIT_DEFAULT_TRIGGER is set

Quoted 7 lines · Hans de Goede

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.

Quoted 8 lines

---
Changes in v3:
- Also set on/off delay to 1000 so that we get a slow breathing effect, this counter-acts the v2 cht_wc_leds_set_effect() change changing the default delays from 1000 to 500

---
 drivers/leds/leds-cht-wcove.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

Applied, thanks

Signature · 1 line
Lee Jones [李琼斯]
Tested-by on the v3 series
#11 lore raw
In reply to Hans de Goede
Quoted 31 lines · Hans de Goede

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.

Quoted 3 lines

Regards,

Hans

Works at my Lenovo Yoga Book YB1-X91L.

Signature · 1 line
Yauhen Kharuzhy
#12 lore raw

Hi Yauhen,

Quoted 32 lines · Yauhen Kharuzhy
Quoted 31 lines · Hans de Goede

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.

Quoted 7 lines
Quoted 3 lines

Regards,

Hans

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/[email protected]/

If yes, can you reply with your Tested-by: Yauhen Kharuzhy <[email protected]> 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 ?

#13 lore raw

чт, 4 мая 2023 г. в 11:56, Hans de Goede <[email protected]>:

Quoted 46 lines

Hi Yauhen,

Quoted 32 lines · Yauhen Kharuzhy
Quoted 31 lines · Hans de Goede

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.

Quoted 7 lines
Quoted 3 lines

Regards,

Hans

Works at my Lenovo Yoga Book YB1-X91L.

Thank you!

Quoted 7 lines

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/[email protected]/

If yes, can you reply with your Tested-by: Yauhen Kharuzhy <[email protected]> to that series too please ?

Yes, sure, I will reply there too.

Quoted 11 lines

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

Quoted 6 lines

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

Signature · 1 line
Yauhen Kharuzhy