aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/platform/x86/intel/int3472/discrete.c
diff options
context:
space:
mode:
authorHans de Goede <[email protected]>2023-01-27 20:37:27 +0000
committerHans de Goede <[email protected]>2023-02-03 09:22:35 +0000
commit5ae20a8050d08a51fef9769cd53237551f259dbe (patch)
tree7015b9464fda0c2828dd1ad01e3b825afef0c51f /drivers/platform/x86/intel/int3472/discrete.c
parentplatform/x86: int3472/discrete: Refactor GPIO to sensor mapping (diff)
downloadkernel-5ae20a8050d08a51fef9769cd53237551f259dbe.tar.gz
kernel-5ae20a8050d08a51fef9769cd53237551f259dbe.zip
platform/x86: int3472/discrete: Create a LED class device for the privacy LED
On some systems, e.g. the Lenovo ThinkPad X1 Yoga gen 7 and the ThinkPad X1 Nano gen 2 there is no clock-enable pin, triggering the: "No clk GPIO. The privacy LED won't work" warning and causing the privacy LED to not work. Fix this by modeling the privacy LED as a LED class device rather then integrating it with the registered clock. Note this relies on media subsys changes to actually turn the LED on/off when the sensor's v4l2_subdev's s_stream() operand gets called. Signed-off-by: Hans de Goede <[email protected]> Reviewed-by: Sakari Ailus <[email protected]> Link: https://lore.kernel.org/r/[email protected]
Diffstat (limited to 'drivers/platform/x86/intel/int3472/discrete.c')
-rw-r--r--drivers/platform/x86/intel/int3472/discrete.c58
1 files changed, 16 insertions, 42 deletions
diff --git a/drivers/platform/x86/intel/int3472/discrete.c b/drivers/platform/x86/intel/int3472/discrete.c
index 708d51f9b41d..38b1372e0745 100644
--- a/drivers/platform/x86/intel/int3472/discrete.c
+++ b/drivers/platform/x86/intel/int3472/discrete.c
@@ -155,37 +155,21 @@ static int skl_int3472_map_gpio_to_sensor(struct int3472_discrete_device *int347
}
static int skl_int3472_map_gpio_to_clk(struct int3472_discrete_device *int3472,
- struct acpi_resource_gpio *agpio, u8 type)
+ struct acpi_resource_gpio *agpio)
{
char *path = agpio->resource_source.string_ptr;
u16 pin = agpio->pin_table[0];
struct gpio_desc *gpio;
- switch (type) {
- case INT3472_GPIO_TYPE_CLK_ENABLE:
- gpio = acpi_get_and_request_gpiod(path, pin, "int3472,clk-enable");
- if (IS_ERR(gpio))
- return (PTR_ERR(gpio));
-
- int3472->clock.ena_gpio = gpio;
- /* Ensure the pin is in output mode and non-active state */
- gpiod_direction_output(int3472->clock.ena_gpio, 0);
- break;
- case INT3472_GPIO_TYPE_PRIVACY_LED:
- gpio = acpi_get_and_request_gpiod(path, pin, "int3472,privacy-led");
- if (IS_ERR(gpio))
- return (PTR_ERR(gpio));
+ gpio = acpi_get_and_request_gpiod(path, pin, "int3472,clk-enable");
+ if (IS_ERR(gpio))
+ return (PTR_ERR(gpio));
- int3472->clock.led_gpio = gpio;
- /* Ensure the pin is in output mode and non-active state */
- gpiod_direction_output(int3472->clock.led_gpio, 0);
- break;
- default:
- dev_err(int3472->dev, "Invalid GPIO type 0x%02x for clock\n", type);
- break;
- }
+ int3472->clock.ena_gpio = gpio;
+ /* Ensure the pin is in output mode and non-active state */
+ gpiod_direction_output(int3472->clock.ena_gpio, 0);
- return 0;
+ return skl_int3472_register_clock(int3472);
}
static void int3472_get_func_and_polarity(u8 type, const char **func, u32 *polarity)
@@ -293,12 +277,17 @@ static int skl_int3472_handle_gpio_resources(struct acpi_resource *ares,
break;
case INT3472_GPIO_TYPE_CLK_ENABLE:
- case INT3472_GPIO_TYPE_PRIVACY_LED:
- ret = skl_int3472_map_gpio_to_clk(int3472, agpio, type);
+ ret = skl_int3472_map_gpio_to_clk(int3472, agpio);
if (ret)
err_msg = "Failed to map GPIO to clock\n";
break;
+ case INT3472_GPIO_TYPE_PRIVACY_LED:
+ ret = skl_int3472_register_pled(int3472, agpio, polarity);
+ if (ret)
+ err_msg = "Failed to register LED\n";
+
+ break;
case INT3472_GPIO_TYPE_POWER_ENABLE:
ret = skl_int3472_register_regulator(int3472, agpio);
if (ret)
@@ -341,21 +330,6 @@ static int skl_int3472_parse_crs(struct int3472_discrete_device *int3472)
acpi_dev_free_resource_list(&resource_list);
- /*
- * If we find no clock enable GPIO pin then the privacy LED won't work.
- * We've never seen that situation, but it's possible. Warn the user so
- * it's clear what's happened.
- */
- if (int3472->clock.ena_gpio) {
- ret = skl_int3472_register_clock(int3472);
- if (ret)
- return ret;
- } else {
- if (int3472->clock.led_gpio)
- dev_warn(int3472->dev,
- "No clk GPIO. The privacy LED won't work\n");
- }
-
int3472->gpios.dev_id = int3472->sensor_name;
gpiod_add_lookup_table(&int3472->gpios);
@@ -372,8 +346,8 @@ static int skl_int3472_discrete_remove(struct platform_device *pdev)
skl_int3472_unregister_clock(int3472);
gpiod_put(int3472->clock.ena_gpio);
- gpiod_put(int3472->clock.led_gpio);
+ skl_int3472_unregister_pled(int3472);
skl_int3472_unregister_regulator(int3472);
return 0;