From patchwork Fri Mar 10 09:56:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kate Hsuan X-Patchwork-Id: 661957 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 451F2C64EC4 for ; Fri, 10 Mar 2023 09:57:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230304AbjCJJ5y (ORCPT ); Fri, 10 Mar 2023 04:57:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34914 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229598AbjCJJ5x (ORCPT ); Fri, 10 Mar 2023 04:57:53 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 73D05106A3A for ; Fri, 10 Mar 2023 01:57:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678442227; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mfMH4fZrJgKQsTUs6xU51M8btp6H5Xdte3Rx0tvuNm8=; b=fbfrsAxXaFhyc51uLJSoyEJNyh/4U5AdU48M6c2+kdFQGHlG5a47biRxm8PVSE/eJ76USA 77mkHYkmbuyM8UguoqdH9lD3mr+y3pCtC6UNh6bqNgKMEN8zOfP00XmhZkMYgifQCtjLO5 ++kWjTPf3+snmz5eozSERwzHgecYE1A= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-287-hm88C8yGNK6TUWIEyMMUfA-1; Fri, 10 Mar 2023 04:57:06 -0500 X-MC-Unique: hm88C8yGNK6TUWIEyMMUfA-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B8D7A857F49; Fri, 10 Mar 2023 09:57:05 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.67.24.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 356252166B2A; Fri, 10 Mar 2023 09:57:01 +0000 (UTC) From: Kate Hsuan To: Pavel Machek , Lee Jones , linux-leds@vger.kernel.org, platform-driver-x86@vger.kernel.org, Hans de Goede , Daniel Scally , Mark Gross Cc: Kate Hsuan Subject: [PATCH v2 1/4] platform: x86: int3472: Add MFD cell for tps68470 LED Date: Fri, 10 Mar 2023 17:56:32 +0800 Message-Id: <20230310095635.813262-2-hpa@redhat.com> In-Reply-To: <20230310095635.813262-1-hpa@redhat.com> References: <20230310095635.813262-1-hpa@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 Precedence: bulk List-ID: X-Mailing-List: linux-leds@vger.kernel.org Add MFD cell for tps68470-led. Signed-off-by: Kate Hsuan --- drivers/platform/x86/intel/int3472/tps68470.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/platform/x86/intel/int3472/tps68470.c b/drivers/platform/x86/intel/int3472/tps68470.c index 5b8d1a9620a5..82ef022f8916 100644 --- a/drivers/platform/x86/intel/int3472/tps68470.c +++ b/drivers/platform/x86/intel/int3472/tps68470.c @@ -17,7 +17,7 @@ #define DESIGNED_FOR_CHROMEOS 1 #define DESIGNED_FOR_WINDOWS 2 -#define TPS68470_WIN_MFD_CELL_COUNT 3 +#define TPS68470_WIN_MFD_CELL_COUNT 4 static const struct mfd_cell tps68470_cros[] = { { .name = "tps68470-gpio" }, @@ -193,7 +193,8 @@ static int skl_int3472_tps68470_probe(struct i2c_client *client) cells[1].name = "tps68470-regulator"; cells[1].platform_data = (void *)board_data->tps68470_regulator_pdata; cells[1].pdata_size = sizeof(struct tps68470_regulator_platform_data); - cells[2].name = "tps68470-gpio"; + cells[2].name = "tps68470-led"; + cells[3].name = "tps68470-gpio"; for (i = 0; i < board_data->n_gpiod_lookups; i++) gpiod_add_lookup_table(board_data->tps68470_gpio_lookup_tables[i]); From patchwork Fri Mar 10 09:56:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kate Hsuan X-Patchwork-Id: 661956 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 87EC9C6FD19 for ; Fri, 10 Mar 2023 09:58:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230488AbjCJJ6E (ORCPT ); Fri, 10 Mar 2023 04:58:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35012 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230397AbjCJJ6C (ORCPT ); Fri, 10 Mar 2023 04:58:02 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B01A3108206 for ; Fri, 10 Mar 2023 01:57:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678442237; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+Dc1/e5Gor5HQwQIQ+MzfYeXPuk8qO+tT4CO3SfZavc=; b=SbcsAOKV5A/qYN/U4aCq7zj39aVdiL2LFwyeiGFcXeC65kueQ+kFFYDFRh5MeDEKhQX8o5 61/DQr3GdNjBnQ4rQaZeutwzq106J+oxq6QVyoLdCnj+3osdu+TKSy7h9qeMR3E9wu9FDX 2TX+Dg8Hm3rMKgLlXHWSXzCG/HuWiTY= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-513-Z_CZ8T2XOgSvHsMQINogRg-1; Fri, 10 Mar 2023 04:57:12 -0500 X-MC-Unique: Z_CZ8T2XOgSvHsMQINogRg-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0EEC3858F0E; Fri, 10 Mar 2023 09:57:12 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.67.24.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3F1292166B26; Fri, 10 Mar 2023 09:57:07 +0000 (UTC) From: Kate Hsuan To: Pavel Machek , Lee Jones , linux-leds@vger.kernel.org, platform-driver-x86@vger.kernel.org, Hans de Goede , Daniel Scally , Mark Gross Cc: Kate Hsuan , Daniel Scally Subject: [PATCH v2 2/4] include: mfd: tps68470: Add masks for LEDA and LEDB Date: Fri, 10 Mar 2023 17:56:33 +0800 Message-Id: <20230310095635.813262-3-hpa@redhat.com> In-Reply-To: <20230310095635.813262-1-hpa@redhat.com> References: <20230310095635.813262-1-hpa@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 Precedence: bulk List-ID: X-Mailing-List: linux-leds@vger.kernel.org Add flags for both LEDA(TPS68470_ILEDCTL_ENA), LEDB (TPS68470_ILEDCTL_ENB), and current control mask for LEDB (TPS68470_ILEDCTL_CTRLB) Reviewed-by: Daniel Scally Reviewed-by: Hans de Goede Signed-off-by: Kate Hsuan --- include/linux/mfd/tps68470.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/linux/mfd/tps68470.h b/include/linux/mfd/tps68470.h index 7807fa329db0..2d2abb25b944 100644 --- a/include/linux/mfd/tps68470.h +++ b/include/linux/mfd/tps68470.h @@ -34,6 +34,7 @@ #define TPS68470_REG_SGPO 0x22 #define TPS68470_REG_GPDI 0x26 #define TPS68470_REG_GPDO 0x27 +#define TPS68470_REG_ILEDCTL 0x28 #define TPS68470_REG_VCMVAL 0x3C #define TPS68470_REG_VAUX1VAL 0x3D #define TPS68470_REG_VAUX2VAL 0x3E @@ -94,4 +95,8 @@ #define TPS68470_GPIO_MODE_OUT_CMOS 2 #define TPS68470_GPIO_MODE_OUT_ODRAIN 3 +#define TPS68470_ILEDCTL_ENA BIT(2) +#define TPS68470_ILEDCTL_ENB BIT(6) +#define TPS68470_ILEDCTL_CTRLB GENMASK(5, 4) + #endif /* __LINUX_MFD_TPS68470_H */ From patchwork Fri Mar 10 09:56:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kate Hsuan X-Patchwork-Id: 662875 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2AC90C64EC4 for ; Fri, 10 Mar 2023 09:58:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229846AbjCJJ6N (ORCPT ); Fri, 10 Mar 2023 04:58:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35064 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230387AbjCJJ6I (ORCPT ); Fri, 10 Mar 2023 04:58:08 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BC46A10868B for ; Fri, 10 Mar 2023 01:57:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678442243; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=iE9NYOXEg52ZpYxXc9MNojx9L7At2wdMLIDlFKCdzbg=; b=WsYJ1PTSyjTf4u5GXhTr5zHbjkNtbpEIgFxPy1zrtkN6gSUBEbDDkIUXC1h8htii7JPV57 2dxF6eXWba69eLc3Lo8AgT/5YVJ0lMXjDiWRXVw7mGiMASQwBlIKUutArcn4DG0xIoWBig J+jfmV3gI65VJOICiE+FUTBja0PZ+SQ= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-384-tZzt7KWNM9yLge9yrwFIkg-1; Fri, 10 Mar 2023 04:57:19 -0500 X-MC-Unique: tZzt7KWNM9yLge9yrwFIkg-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5105D800B23; Fri, 10 Mar 2023 09:57:19 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.67.24.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id A94292166B26; Fri, 10 Mar 2023 09:57:15 +0000 (UTC) From: Kate Hsuan To: Pavel Machek , Lee Jones , linux-leds@vger.kernel.org, platform-driver-x86@vger.kernel.org, Hans de Goede , Daniel Scally , Mark Gross Cc: Kate Hsuan Subject: [PATCH v2 3/4] leds: tps68470: Add LED control for tps68470 Date: Fri, 10 Mar 2023 17:56:34 +0800 Message-Id: <20230310095635.813262-4-hpa@redhat.com> In-Reply-To: <20230310095635.813262-1-hpa@redhat.com> References: <20230310095635.813262-1-hpa@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 Precedence: bulk List-ID: X-Mailing-List: linux-leds@vger.kernel.org There are two LED controllers, LEDA indicator LED and LEDB flash LED for tps68470. LEDA can be enabled by setting TPS68470_ILEDCTL_ENA. Moreover, tps68470 provides four levels of power status for LEDB. If the properties called "ti,ledb-current" can be found, the current will be set according to the property values. These two LEDs can be controlled through the LED class of sysfs (tps68470-leda and tps68470-ledb). Signed-off-by: Kate Hsuan --- drivers/leds/Kconfig | 12 +++ drivers/leds/Makefile | 1 + drivers/leds/leds-tps68470.c | 182 +++++++++++++++++++++++++++++++++++ 3 files changed, 195 insertions(+) create mode 100644 drivers/leds/leds-tps68470.c diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig index 9dbce09eabac..fd26036b3c61 100644 --- a/drivers/leds/Kconfig +++ b/drivers/leds/Kconfig @@ -827,6 +827,18 @@ config LEDS_TPS6105X It is a single boost converter primarily for white LEDs and audio amplifiers. +config LEDS_TPS68470 + tristate "LED support for TI TPS68470" + depends on LEDS_CLASS + depends on INTEL_SKL_INT3472 + help + This driver supports TPS68470 PMIC with LED chip. + It provide two LED controllers, including an indicator LED + and a flash LED. + + To compile this driver as a module, choose M and it will be + called leds-tps68470 + config LEDS_IP30 tristate "LED support for SGI Octane machines" depends on LEDS_CLASS diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile index d30395d11fd8..b284bc0daa98 100644 --- a/drivers/leds/Makefile +++ b/drivers/leds/Makefile @@ -84,6 +84,7 @@ obj-$(CONFIG_LEDS_TURRIS_OMNIA) += leds-turris-omnia.o obj-$(CONFIG_LEDS_WM831X_STATUS) += leds-wm831x-status.o obj-$(CONFIG_LEDS_WM8350) += leds-wm8350.o obj-$(CONFIG_LEDS_WRAP) += leds-wrap.o +obj-$(CONFIG_LEDS_TPS68470) += leds-tps68470.o # LED SPI Drivers obj-$(CONFIG_LEDS_CR0014114) += leds-cr0014114.o diff --git a/drivers/leds/leds-tps68470.c b/drivers/leds/leds-tps68470.c new file mode 100644 index 000000000000..98bb56153690 --- /dev/null +++ b/drivers/leds/leds-tps68470.c @@ -0,0 +1,182 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * LED driver for TPS68470 PMIC + * + * Copyright (C) 2023 Red Hat + * + * Authors: + * Kate Hsuan + */ + +#include +#include +#include +#include +#include +#include + +#define lcdev_to_led(led_cdev) \ + container_of(led_cdev, struct tps68470_led, lcdev) + +#define led_to_tps68470(led, index) \ + container_of(led, struct tps68470_device, leds[index]) + +enum tps68470_led_ids { + TPS68470_ILED_A, + TPS68470_ILED_B, + TPS68470_NUM_LEDS +}; + +static const char *tps68470_led_names[] = { + [TPS68470_ILED_A] = "tps68470-iled_a", + [TPS68470_ILED_B] = "tps68470-iled_b", +}; + +struct tps68470_led { + unsigned int led_id; + struct led_classdev lcdev; +}; + +struct tps68470_device { + struct device *dev; + struct regmap *regmap; + struct tps68470_led leds[TPS68470_NUM_LEDS]; +}; + +enum ctrlb_current { + CTRLB_2MA = 0, + CTRLB_4MA = 1, + CTRLB_8MA = 2, + CTRLB_16MA = 3, +}; + +static int tps68470_brightness_set(struct led_classdev *led_cdev, enum led_brightness brightness) +{ + struct tps68470_led *led = lcdev_to_led(led_cdev); + struct tps68470_device *tps68470 = led_to_tps68470(led, led->led_id); + struct regmap *regmap = tps68470->regmap; + + switch (led->led_id) { + case TPS68470_ILED_A: + return regmap_update_bits(regmap, TPS68470_REG_ILEDCTL, TPS68470_ILEDCTL_ENA, + brightness ? TPS68470_ILEDCTL_ENA : 0); + case TPS68470_ILED_B: + return regmap_update_bits(regmap, TPS68470_REG_ILEDCTL, TPS68470_ILEDCTL_ENB, + brightness ? TPS68470_ILEDCTL_ENB : 0); + } + return -EINVAL; +} + +static enum led_brightness tps68470_brightness_get(struct led_classdev *led_cdev) +{ + struct tps68470_led *led = lcdev_to_led(led_cdev); + struct tps68470_device *tps68470 = led_to_tps68470(led, led->led_id); + struct regmap *regmap = tps68470->regmap; + int ret = 0; + int value = 0; + + ret = regmap_read(regmap, TPS68470_REG_ILEDCTL, &value); + if (ret) + goto error; + + switch (led->led_id) { + case TPS68470_ILED_A: + value = value & TPS68470_ILEDCTL_ENA; + break; + case TPS68470_ILED_B: + value = value & TPS68470_ILEDCTL_ENB; + break; + } + + return value ? LED_ON : LED_OFF; + +error: + dev_err(led_cdev->dev, "Failed on reading register\n"); + return -EINVAL; +} + +static int tps68470_leds_probe(struct platform_device *pdev) +{ + int i = 0; + int ret = 0; + unsigned int curr; + struct tps68470_device *tps68470; + struct tps68470_led *led; + struct led_classdev *lcdev; + + tps68470 = devm_kzalloc(&pdev->dev, sizeof(struct tps68470_device), + GFP_KERNEL); + tps68470->dev = &pdev->dev; + tps68470->regmap = dev_get_drvdata(pdev->dev.parent); + + for (i = 0; i < TPS68470_NUM_LEDS; i++) { + led = &tps68470->leds[i]; + lcdev = &led->lcdev; + + led->led_id = i; + + lcdev->name = devm_kasprintf(tps68470->dev, GFP_KERNEL, "%s::%s", + tps68470_led_names[i], LED_FUNCTION_INDICATOR); + if (!lcdev->name) + return -ENOMEM; + + lcdev->max_brightness = 1; + lcdev->brightness = 0; + lcdev->brightness_set_blocking = tps68470_brightness_set; + lcdev->brightness_get = tps68470_brightness_get; + lcdev->dev = &pdev->dev; + + ret = devm_led_classdev_register(tps68470->dev, lcdev); + if (ret) { + dev_err_probe(tps68470->dev, ret, + "error registering led\n"); + goto err_exit; + } + } + + /* configure LEDB current if the properties can be got */ + if (!device_property_read_u32(&pdev->dev, "ti,ledb-current", &curr)) { + switch (curr) { + case 2: + curr = CTRLB_2MA; + break; + case 4: + curr = CTRLB_4MA; + break; + case 8: + curr = CTRLB_8MA; + break; + case 16: + curr = CTRLB_16MA; + break; + default: + dev_err(&pdev->dev, "Invalid LEDB curr value: %d\n", curr); + return -EINVAL; + } + ret = regmap_update_bits(tps68470->regmap, TPS68470_REG_ILEDCTL, + TPS68470_ILEDCTL_CTRLB, curr); + } + +err_exit: + if (ret) { + for (i = 0; i < TPS68470_NUM_LEDS; i++) { + if (tps68470->leds[i].lcdev.name) + devm_led_classdev_unregister(&pdev->dev, + &tps68470->leds[i].lcdev); + } + } + + return ret; +} +static struct platform_driver tps68470_led_driver = { + .driver = { + .name = "tps68470-led", + }, + .probe = tps68470_leds_probe, +}; + +module_platform_driver(tps68470_led_driver); + +MODULE_ALIAS("platform:tps68470-led"); +MODULE_DESCRIPTION("LED driver for TPS68470 PMIC"); +MODULE_LICENSE("GPL v2"); From patchwork Fri Mar 10 09:56:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kate Hsuan X-Patchwork-Id: 661955 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9A257C6FD1E for ; Fri, 10 Mar 2023 09:58:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230174AbjCJJ6U (ORCPT ); Fri, 10 Mar 2023 04:58:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35144 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230383AbjCJJ6T (ORCPT ); Fri, 10 Mar 2023 04:58:19 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E229D1086B7 for ; Fri, 10 Mar 2023 01:57:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678442251; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=CdvZdG0Wy23BadZemNj9PmvPi0/p33iaAuq+4IsShCI=; b=jNDRYDtpjwhkQlxGsHDpqD8udJd1U+xHIGXxm4cVh2BQXbsJ0En2DCId3UYlSemtyfymBo 7WfBcNAJJPneib85D5GYJ23qCVzdpYV/bzluCK/WLaxPvTMfJPpoP6pZrVVYoML6V83U8w fCTrv7RDOmt29uVUSaNOU6HzBKF2jQ0= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-653-zd5eytUKNYaE9CrFE2AP-Q-1; Fri, 10 Mar 2023 04:57:25 -0500 X-MC-Unique: zd5eytUKNYaE9CrFE2AP-Q-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 105BD85D063; Fri, 10 Mar 2023 09:57:25 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.67.24.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id D683F2166B26; Fri, 10 Mar 2023 09:57:21 +0000 (UTC) From: Kate Hsuan To: Pavel Machek , Lee Jones , linux-leds@vger.kernel.org, platform-driver-x86@vger.kernel.org, Hans de Goede , Daniel Scally , Mark Gross Subject: [PATCH v2 4/4] platform: x86: int3472: Register a LED lookup table entry for the privacy LED Date: Fri, 10 Mar 2023 17:56:35 +0800 Message-Id: <20230310095635.813262-5-hpa@redhat.com> In-Reply-To: <20230310095635.813262-1-hpa@redhat.com> References: <20230310095635.813262-1-hpa@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 Precedence: bulk List-ID: X-Mailing-List: linux-leds@vger.kernel.org From: Hans de Goede All currently known models using the tps68470 PMIC have a privacy LED for the back sensor (first ACPI consumer dev of the PMIC) connected to the ileda output of the PMIC. Add a LED lookup table entry for this, so that the v4l2-core code turns on the LED when streaming from the sensor. Signed-off-by: Hans de Goede --- drivers/platform/x86/intel/int3472/tps68470.c | 30 +++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/drivers/platform/x86/intel/int3472/tps68470.c b/drivers/platform/x86/intel/int3472/tps68470.c index 82ef022f8916..a53de9cd0540 100644 --- a/drivers/platform/x86/intel/int3472/tps68470.c +++ b/drivers/platform/x86/intel/int3472/tps68470.c @@ -140,11 +140,18 @@ skl_int3472_fill_clk_pdata(struct device *dev, struct tps68470_clk_platform_data return n_consumers; } +static void skl_int3472_tps68470_unregister_led_lookup(void *led_lookup) +{ + led_remove_lookup(led_lookup); +} + static int skl_int3472_tps68470_probe(struct i2c_client *client) { - struct acpi_device *adev = ACPI_COMPANION(&client->dev); + struct device *dev = &client->dev; + struct acpi_device *adev = ACPI_COMPANION(dev); const struct int3472_tps68470_board_data *board_data; struct tps68470_clk_platform_data *clk_pdata; + struct led_lookup_data *led_lookup; struct mfd_cell *cells; struct regmap *regmap; int n_consumers; @@ -177,6 +184,25 @@ static int skl_int3472_tps68470_probe(struct i2c_client *client) if (!board_data) return dev_err_probe(&client->dev, -ENODEV, "No board-data found for this model\n"); + /* Add a LED lookup table entry for the privacy LED */ + led_lookup = devm_kzalloc(&client->dev, sizeof(*led_lookup), GFP_KERNEL); + if (!led_lookup) + return -ENOMEM; + + ret = skl_int3472_get_sensor_adev_and_name(&client->dev, NULL, &led_lookup->dev_id); + if (ret) + return ret; + + led_lookup->provider = "tps68470-ileda"; + led_lookup->con_id = "privacy-led"; + led_add_lookup(led_lookup); + + ret = devm_add_action_or_reset(&client->dev, + skl_int3472_tps68470_unregister_led_lookup, + led_lookup); + if (ret) + return ret; + cells = kcalloc(TPS68470_WIN_MFD_CELL_COUNT, sizeof(*cells), GFP_KERNEL); if (!cells) return -ENOMEM; @@ -259,4 +285,4 @@ module_i2c_driver(int3472_tps68470); MODULE_DESCRIPTION("Intel SkyLake INT3472 ACPI TPS68470 Device Driver"); MODULE_AUTHOR("Daniel Scally "); MODULE_LICENSE("GPL v2"); -MODULE_SOFTDEP("pre: clk-tps68470 tps68470-regulator"); +MODULE_SOFTDEP("pre: clk-tps68470 tps68470-regulator leds-tps68470");