summaryrefslogtreecommitdiffstats
path: root/drivers/platform
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2023-04-30 18:57:57 +0200
committerHans de Goede <hdegoede@redhat.com>2023-05-09 12:29:51 +0200
commit76d6778fb21ee5e86b1de102d12b6480fa4fad9e (patch)
tree6cfd6ed49bd8399101881f1ba5e810fd8dc765ad /drivers/platform
parenta6673cfc6b56a2dc41de416f5ea397943297b79a (diff)
downloadlinux-stable-76d6778fb21ee5e86b1de102d12b6480fa4fad9e.tar.gz
linux-stable-76d6778fb21ee5e86b1de102d12b6480fa4fad9e.tar.bz2
linux-stable-76d6778fb21ee5e86b1de102d12b6480fa4fad9e.zip
platform/x86: lenovo-yogabook: Use PMIC LED driver for pen icon LED control
Use the (new) PMIC LED driver for pen icon LED control instead of using custom WMI calls for this. This will also work on the Android version of the Lenovo Yoga Book 1, where there is no WMI interface for this. The dev_id of the lookup is set using dev_name() so that it will also work for both the Windows YB1 WMI-device as well as the Android YB1 platform-device. While at it also move the gpio_lookup to using dev_name() for the dev_id. Note this also removes the need to turn of the LED during suspend since the PMIC LED driver now already does that. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Link: https://lore.kernel.org/r/20230430165807.472798-10-hdegoede@redhat.com
Diffstat (limited to 'drivers/platform')
-rw-r--r--drivers/platform/x86/lenovo-yogabook-wmi.c63
1 files changed, 21 insertions, 42 deletions
diff --git a/drivers/platform/x86/lenovo-yogabook-wmi.c b/drivers/platform/x86/lenovo-yogabook-wmi.c
index 4f2624eba210..68057150f465 100644
--- a/drivers/platform/x86/lenovo-yogabook-wmi.c
+++ b/drivers/platform/x86/lenovo-yogabook-wmi.c
@@ -11,11 +11,6 @@
#include <linux/workqueue.h>
#define YB_MBTN_EVENT_GUID "243FEC1D-1963-41C1-8100-06A9D82A94B4"
-#define YB_MBTN_METHOD_GUID "742B0CA1-0B20-404B-9CAA-AEFCABF30CE0"
-
-#define YB_PAD_ENABLE 1
-#define YB_PAD_DISABLE 2
-#define YB_LIGHTUP_BTN 3
#define YB_KBD_BL_DEFAULT 128
@@ -34,6 +29,7 @@ struct yogabook_wmi {
struct acpi_device *dig_adev;
struct device *kbd_dev;
struct device *dig_dev;
+ struct led_classdev *pen_led;
struct gpio_desc *backside_hall_gpio;
int backside_hall_irq;
struct work_struct work;
@@ -42,31 +38,6 @@ struct yogabook_wmi {
uint8_t brightness;
};
-static int yogabook_wmi_do_action(struct yogabook_wmi *data, int action)
-{
- struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL };
- struct acpi_buffer input;
- acpi_status status;
- u32 dummy_arg = 0;
-
- dev_dbg(data->dev, "Do action: %d\n", action);
-
- input.pointer = &dummy_arg;
- input.length = sizeof(dummy_arg);
-
- status = wmi_evaluate_method(YB_MBTN_METHOD_GUID, 0, action, &input,
- &output);
- if (ACPI_FAILURE(status)) {
- dev_err(data->dev, "Calling WMI method failure: 0x%x\n",
- status);
- return status;
- }
-
- kfree(output.pointer);
-
- return 0;
-}
-
/*
* To control keyboard backlight, call the method KBLC() of the TCS1 ACPI
* device (Goodix touchpad acts as virtual sensor keyboard).
@@ -134,7 +105,7 @@ static void yogabook_wmi_work(struct work_struct *work)
}
if (!digitizer_on && test_bit(YB_DIGITIZER_IS_ON, &data->flags)) {
- yogabook_wmi_do_action(data, YB_PAD_DISABLE);
+ led_set_brightness(data->pen_led, LED_OFF);
device_release_driver(data->dig_dev);
clear_bit(YB_DIGITIZER_IS_ON, &data->flags);
}
@@ -153,7 +124,7 @@ static void yogabook_wmi_work(struct work_struct *work)
if (r)
dev_warn(data->dev, "Reprobe of digitizer failed: %d\n", r);
- yogabook_wmi_do_action(data, YB_PAD_ENABLE);
+ led_set_brightness(data->pen_led, LED_FULL);
set_bit(YB_DIGITIZER_IS_ON, &data->flags);
}
}
@@ -217,13 +188,17 @@ static int kbd_brightness_set(struct led_classdev *cdev,
}
static struct gpiod_lookup_table yogabook_wmi_gpios = {
- .dev_id = "243FEC1D-1963-41C1-8100-06A9D82A94B4",
- .table = {
+ .table = {
GPIO_LOOKUP("INT33FF:02", 18, "backside_hall_sw", GPIO_ACTIVE_LOW),
{}
},
};
+static struct led_lookup_data yogabook_pen_led = {
+ .provider = "platform::indicator",
+ .con_id = "pen-icon-led",
+};
+
static int yogabook_wmi_probe(struct wmi_device *wdev, const void *context)
{
struct device *dev = &wdev->dev;
@@ -265,6 +240,18 @@ static int yogabook_wmi_probe(struct wmi_device *wdev, const void *context)
goto error_put_devs;
}
+ yogabook_pen_led.dev_id = dev_name(dev);
+ led_add_lookup(&yogabook_pen_led);
+ data->pen_led = devm_led_get(dev, "pen-icon-led");
+ led_remove_lookup(&yogabook_pen_led);
+
+ if (IS_ERR(data->pen_led)) {
+ r = PTR_ERR(data->pen_led);
+ dev_err_probe(dev, r, "Getting pen icon LED\n");
+ goto error_put_devs;
+ }
+
+ yogabook_wmi_gpios.dev_id = dev_name(dev);
gpiod_add_lookup_table(&yogabook_wmi_gpios);
data->backside_hall_gpio = devm_gpiod_get(dev, "backside_hall_sw", GPIOD_IN);
gpiod_remove_lookup_table(&yogabook_wmi_gpios);
@@ -350,11 +337,6 @@ static int yogabook_suspend(struct device *dev)
set_bit(YB_SUSPENDED, &data->flags);
flush_work(&data->work);
-
- /* Turn off the pen button at sleep */
- if (test_bit(YB_DIGITIZER_IS_ON, &data->flags))
- yogabook_wmi_do_action(data, YB_PAD_DISABLE);
-
return 0;
}
@@ -368,9 +350,6 @@ static int yogabook_resume(struct device *dev)
yogabook_wmi_set_kbd_backlight(data, data->brightness);
}
- if (test_bit(YB_DIGITIZER_IS_ON, &data->flags))
- yogabook_wmi_do_action(data, YB_PAD_ENABLE);
-
clear_bit(YB_SUSPENDED, &data->flags);
/* Check for YB_TABLET_MODE changes made during suspend */