From patchwork Mon Nov 28 21:44:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 629101 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 0E103C4321E for ; Mon, 28 Nov 2022 21:45:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233214AbiK1VpN (ORCPT ); Mon, 28 Nov 2022 16:45:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38912 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232801AbiK1VpM (ORCPT ); Mon, 28 Nov 2022 16:45:12 -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 A77411DF25 for ; Mon, 28 Nov 2022 13:44:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1669671858; 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=HYgpL2606mVfO+98npo7eaosHXY5I8deinLTWhiViEE=; b=SozgTE4t+V2EvkMHIkAe+Nu6s/pDrW+MJ5WoSWW4GQOACsmp8PX4tQZzufBOeSKAmwVsSX lmS9rmXYJ6gP6L3gsAJTu5upA1BqCSREw60krIBSFQq5ZeqPV/k60JCVCYMaFKQV11BRFa fsg3gXgGGPc3CAVZwMTUeI/G+F+U0ak= 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-197-XIfB4YCLNIye0mUOA4KgEA-1; Mon, 28 Nov 2022 16:44:15 -0500 X-MC-Unique: XIfB4YCLNIye0mUOA4KgEA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id AD33286C177; Mon, 28 Nov 2022 21:44:14 +0000 (UTC) Received: from shalem.redhat.com (unknown [10.39.192.115]) by smtp.corp.redhat.com (Postfix) with ESMTP id 23AFD40C6EC2; Mon, 28 Nov 2022 21:44:13 +0000 (UTC) From: Hans de Goede To: Mark Gross , Andy Shevchenko , Bartosz Golaszewski , Linus Walleij , Daniel Scally , Laurent Pinchart Cc: Hans de Goede , platform-driver-x86@vger.kernel.org, linux-gpio@vger.kernel.org, Sakari Ailus , Kate Hsuan , linux-media@vger.kernel.org Subject: [PATCH 1/5] gpio: tps68470: Fix tps68470_gpio_get() reading from the wrong register Date: Mon, 28 Nov 2022 22:44:04 +0100 Message-Id: <20221128214408.165726-2-hdegoede@redhat.com> In-Reply-To: <20221128214408.165726-1-hdegoede@redhat.com> References: <20221128214408.165726-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org For the regular GPIO pins the value should be read from TPS68470_REG_GPDI, so that the actual value of the pin is read, rather then the value the pin would output when put in output mode. Signed-off-by: Hans de Goede Reviewed-by: Daniel Scally --- drivers/gpio/gpio-tps68470.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpio/gpio-tps68470.c b/drivers/gpio/gpio-tps68470.c index aaddcabe9b35..778a72cf800c 100644 --- a/drivers/gpio/gpio-tps68470.c +++ b/drivers/gpio/gpio-tps68470.c @@ -30,7 +30,7 @@ static int tps68470_gpio_get(struct gpio_chip *gc, unsigned int offset) { struct tps68470_gpio_data *tps68470_gpio = gpiochip_get_data(gc); struct regmap *regmap = tps68470_gpio->tps68470_regmap; - unsigned int reg = TPS68470_REG_GPDO; + unsigned int reg = TPS68470_REG_GPDI; int val, ret; if (offset >= TPS68470_N_REGULAR_GPIO) { From patchwork Mon Nov 28 21:44:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 629100 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 41C0FC46467 for ; Mon, 28 Nov 2022 21:46:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234170AbiK1VqG (ORCPT ); Mon, 28 Nov 2022 16:46:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38996 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232966AbiK1VqF (ORCPT ); Mon, 28 Nov 2022 16:46:05 -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 9D0602F396 for ; Mon, 28 Nov 2022 13:44:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1669671862; 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=lDSk/YotiMAVVVz5IFNCek4sXkrxUKeZgip3PiiCKEk=; b=SGEPVM0/oZKJ2ToW0Y9bMne/gJ6ebRkgLYB0D5I85p7nTaKS0o+Qvc4stJbIr/AABurOj0 DPAsZG9VYWg5M3UMESt2Sx9kL2hi8yWwZ2QsrVNIP1ykLI8f69Ze5yta90GYVLppM554fR z1qjjMwUyQ4Lk1y6eGUEmKb+YhAmHYU= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-169-THRlshcIPleqsWkBH0l2Vg-1; Mon, 28 Nov 2022 16:44:17 -0500 X-MC-Unique: THRlshcIPleqsWkBH0l2Vg-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7943429DD989; Mon, 28 Nov 2022 21:44:16 +0000 (UTC) Received: from shalem.redhat.com (unknown [10.39.192.115]) by smtp.corp.redhat.com (Postfix) with ESMTP id E162B40C6EC2; Mon, 28 Nov 2022 21:44:14 +0000 (UTC) From: Hans de Goede To: Mark Gross , Andy Shevchenko , Bartosz Golaszewski , Linus Walleij , Daniel Scally , Laurent Pinchart Cc: Hans de Goede , platform-driver-x86@vger.kernel.org, linux-gpio@vger.kernel.org, Sakari Ailus , Kate Hsuan , linux-media@vger.kernel.org Subject: [PATCH 2/5] gpio: tps68470: Make tps68470_gpio_output() always set the initial value Date: Mon, 28 Nov 2022 22:44:05 +0100 Message-Id: <20221128214408.165726-3-hdegoede@redhat.com> In-Reply-To: <20221128214408.165726-1-hdegoede@redhat.com> References: <20221128214408.165726-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Make tps68470_gpio_output() call tps68470_gpio_set() for output-only pins too, so that the initial value passed to gpiod_direction_output() is honored for these pins too. Signed-off-by: Hans de Goede Reviewed-by: Andy Shevchenko Reviewed-by: Daniel Scally Tested-by: Daniel Scally --- drivers/gpio/gpio-tps68470.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/gpio/gpio-tps68470.c b/drivers/gpio/gpio-tps68470.c index 778a72cf800c..2ca86fbe1d84 100644 --- a/drivers/gpio/gpio-tps68470.c +++ b/drivers/gpio/gpio-tps68470.c @@ -91,13 +91,13 @@ static int tps68470_gpio_output(struct gpio_chip *gc, unsigned int offset, struct tps68470_gpio_data *tps68470_gpio = gpiochip_get_data(gc); struct regmap *regmap = tps68470_gpio->tps68470_regmap; + /* Set the initial value */ + tps68470_gpio_set(gc, offset, value); + /* rest are always outputs */ if (offset >= TPS68470_N_REGULAR_GPIO) return 0; - /* Set the initial value */ - tps68470_gpio_set(gc, offset, value); - return regmap_update_bits(regmap, TPS68470_GPIO_CTL_REG_A(offset), TPS68470_GPIO_MODE_MASK, TPS68470_GPIO_MODE_OUT_CMOS); From patchwork Mon Nov 28 21:44:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 629099 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 11498C47088 for ; Mon, 28 Nov 2022 21:46:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233721AbiK1VqI (ORCPT ); Mon, 28 Nov 2022 16:46:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38990 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233440AbiK1VqG (ORCPT ); Mon, 28 Nov 2022 16:46:06 -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 17BE82ED5D for ; Mon, 28 Nov 2022 13:44:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1669671860; 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=JMnrRho9OQOGXDAMjv1JNg9wZ8w7tYaVKUwPtg4BbDc=; b=eTviN+rHIPqDCyqdlS5RCEYKpKviWKrEzqcc46aUOD/1xNp4tZnaD6BsSTPGATGURrhV+7 BB9N7XBUE23Caj+zXAcyswG9zvDBeYZgPgFei7qbce2EUVp25myjiXR4Z61SNgyEPTEB0v fWvwZYdyETy7CeiCbv6cO5Cy26XzkpU= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-120-nT4qwJbyOy-dhu4ed9nbAA-1; Mon, 28 Nov 2022 16:44:18 -0500 X-MC-Unique: nT4qwJbyOy-dhu4ed9nbAA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 44D8C1C0512C; Mon, 28 Nov 2022 21:44:18 +0000 (UTC) Received: from shalem.redhat.com (unknown [10.39.192.115]) by smtp.corp.redhat.com (Postfix) with ESMTP id AF8B340C6EC2; Mon, 28 Nov 2022 21:44:16 +0000 (UTC) From: Hans de Goede To: Mark Gross , Andy Shevchenko , Bartosz Golaszewski , Linus Walleij , Daniel Scally , Laurent Pinchart Cc: Hans de Goede , platform-driver-x86@vger.kernel.org, linux-gpio@vger.kernel.org, Sakari Ailus , Kate Hsuan , linux-media@vger.kernel.org Subject: [PATCH 3/5] gpio: tps68470: Add support for the indicator LED outputs Date: Mon, 28 Nov 2022 22:44:06 +0100 Message-Id: <20221128214408.165726-4-hdegoede@redhat.com> In-Reply-To: <20221128214408.165726-1-hdegoede@redhat.com> References: <20221128214408.165726-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The tps68470 has support for 2 indicator LED outputs called ileda and iledb, at support for these as GPIO pins 10 + 11. Signed-off-by: Hans de Goede --- drivers/gpio/gpio-tps68470.c | 46 +++++++++++++++++++++++++----------- include/linux/mfd/tps68470.h | 4 ++++ 2 files changed, 36 insertions(+), 14 deletions(-) diff --git a/drivers/gpio/gpio-tps68470.c b/drivers/gpio/gpio-tps68470.c index 2ca86fbe1d84..33febd96c001 100644 --- a/drivers/gpio/gpio-tps68470.c +++ b/drivers/gpio/gpio-tps68470.c @@ -19,24 +19,43 @@ #define TPS68470_N_LOGIC_OUTPUT 3 #define TPS68470_N_REGULAR_GPIO 7 -#define TPS68470_N_GPIO (TPS68470_N_LOGIC_OUTPUT + TPS68470_N_REGULAR_GPIO) +#define TPS68470_N_ILEDS 2 +#define TPS68470_N_GPIO (TPS68470_N_LOGIC_OUTPUT + TPS68470_N_REGULAR_GPIO + TPS68470_N_ILEDS) struct tps68470_gpio_data { struct regmap *tps68470_regmap; struct gpio_chip gc; }; +static void tps68470_gpio_get_reg_and_mask(bool get, unsigned int offset, + unsigned int *reg, int *mask) +{ + if (offset < TPS68470_N_REGULAR_GPIO) { + if (get) + *reg = TPS68470_REG_GPDI; + else + *reg = TPS68470_REG_GPDO; + *mask = BIT(offset); + } else if (offset < (TPS68470_N_REGULAR_GPIO + TPS68470_N_LOGIC_OUTPUT)) { + *reg = TPS68470_REG_SGPO; + *mask = BIT(offset - TPS68470_N_REGULAR_GPIO); + } else { + *reg = TPS68470_REG_ILEDCTL; + if (offset == (TPS68470_N_REGULAR_GPIO + TPS68470_N_LOGIC_OUTPUT)) + *mask = TPS68470_ILEDCTL_ENA; + else + *mask = TPS68470_ILEDCTL_ENB; + } +} + static int tps68470_gpio_get(struct gpio_chip *gc, unsigned int offset) { struct tps68470_gpio_data *tps68470_gpio = gpiochip_get_data(gc); struct regmap *regmap = tps68470_gpio->tps68470_regmap; - unsigned int reg = TPS68470_REG_GPDI; - int val, ret; + int val, mask, ret; + unsigned int reg; - if (offset >= TPS68470_N_REGULAR_GPIO) { - offset -= TPS68470_N_REGULAR_GPIO; - reg = TPS68470_REG_SGPO; - } + tps68470_gpio_get_reg_and_mask(true, offset, ®, &mask); ret = regmap_read(regmap, reg, &val); if (ret) { @@ -44,7 +63,7 @@ static int tps68470_gpio_get(struct gpio_chip *gc, unsigned int offset) TPS68470_REG_SGPO); return ret; } - return !!(val & BIT(offset)); + return !!(val & mask); } static int tps68470_gpio_get_direction(struct gpio_chip *gc, @@ -75,14 +94,12 @@ static void tps68470_gpio_set(struct gpio_chip *gc, unsigned int offset, { struct tps68470_gpio_data *tps68470_gpio = gpiochip_get_data(gc); struct regmap *regmap = tps68470_gpio->tps68470_regmap; - unsigned int reg = TPS68470_REG_GPDO; + unsigned int reg; + int mask; - if (offset >= TPS68470_N_REGULAR_GPIO) { - reg = TPS68470_REG_SGPO; - offset -= TPS68470_N_REGULAR_GPIO; - } + tps68470_gpio_get_reg_and_mask(false, offset, ®, &mask); - regmap_update_bits(regmap, reg, BIT(offset), value ? BIT(offset) : 0); + regmap_update_bits(regmap, reg, mask, value ? mask : 0); } static int tps68470_gpio_output(struct gpio_chip *gc, unsigned int offset, @@ -120,6 +137,7 @@ static const char *tps68470_names[TPS68470_N_GPIO] = { "gpio.0", "gpio.1", "gpio.2", "gpio.3", "gpio.4", "gpio.5", "gpio.6", "s_enable", "s_idle", "s_resetn", + "ileda", "iledb", }; static int tps68470_gpio_probe(struct platform_device *pdev) diff --git a/include/linux/mfd/tps68470.h b/include/linux/mfd/tps68470.h index 7807fa329db0..2a1b6de65540 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,7 @@ #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) + #endif /* __LINUX_MFD_TPS68470_H */ From patchwork Mon Nov 28 21:44:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 630093 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 98A6CC4708A for ; Mon, 28 Nov 2022 21:46:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233396AbiK1VqH (ORCPT ); Mon, 28 Nov 2022 16:46:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39004 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233349AbiK1VqF (ORCPT ); Mon, 28 Nov 2022 16:46:05 -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 CD1CC2FFDC for ; Mon, 28 Nov 2022 13:44:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1669671864; 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=ijZvrHfxzqLtf9v5WhrCliu1xtsXettjChSs9tCIBZo=; b=WA/nlWQMcFZsZ/dz/rIdSaC1JE6I21HhinKlTV1T0VcVai+iTtfSOqsV4p7qUg/NU7d8uC mOP52Ik6Dwtl22WScggzmQiue7uKTwZKNu1IYWpQ5y/3E4tV9QxCUhzB02kvEvaxEwgdNY I1jRrq1NfPfFDo7tqt/mnNLCYLHNavo= 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-108-wfWKXQ0gMViXqONqWAwVAA-1; Mon, 28 Nov 2022 16:44:20 -0500 X-MC-Unique: wfWKXQ0gMViXqONqWAwVAA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 142E3886463; Mon, 28 Nov 2022 21:44:20 +0000 (UTC) Received: from shalem.redhat.com (unknown [10.39.192.115]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7911F40C6EC2; Mon, 28 Nov 2022 21:44:18 +0000 (UTC) From: Hans de Goede To: Mark Gross , Andy Shevchenko , Bartosz Golaszewski , Linus Walleij , Daniel Scally , Laurent Pinchart Cc: Hans de Goede , platform-driver-x86@vger.kernel.org, linux-gpio@vger.kernel.org, Sakari Ailus , Kate Hsuan , linux-media@vger.kernel.org Subject: [PATCH 4/5] media: ov8865: Add support for a privacy-led GPIO Date: Mon, 28 Nov 2022 22:44:07 +0100 Message-Id: <20221128214408.165726-5-hdegoede@redhat.com> In-Reply-To: <20221128214408.165726-1-hdegoede@redhat.com> References: <20221128214408.165726-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Add support for a privacy-led GPIO. Making the privacy LED to controlable from userspace, as using the LED class subsystem would do, would make it too easy for spy-ware to disable the LED. To avoid this have the sensor driver directly control the LED. Signed-off-by: Hans de Goede --- Note an additional advantage of directly controlling the GPIO is that GPIOs are tied directly to consumer devices. Where as with a LED class device, there would need to be some mechanism to tie the right LED (e.g front or back) to the right sensor. --- drivers/media/i2c/ov8865.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/media/i2c/ov8865.c b/drivers/media/i2c/ov8865.c index cae1866134a0..fe86b166b28b 100644 --- a/drivers/media/i2c/ov8865.c +++ b/drivers/media/i2c/ov8865.c @@ -688,6 +688,7 @@ struct ov8865_sensor { struct i2c_client *i2c_client; struct gpio_desc *reset; struct gpio_desc *powerdown; + struct gpio_desc *privacy_led; struct regulator *avdd; struct regulator *dvdd; struct regulator *dovdd; @@ -2432,10 +2433,12 @@ static int ov8865_sensor_power(struct ov8865_sensor *sensor, bool on) gpiod_set_value_cansleep(sensor->reset, 0); gpiod_set_value_cansleep(sensor->powerdown, 0); + gpiod_set_value_cansleep(sensor->privacy_led, 1); /* Time to enter streaming mode according to power timings. */ usleep_range(10000, 12000); } else { + gpiod_set_value_cansleep(sensor->privacy_led, 0); gpiod_set_value_cansleep(sensor->powerdown, 1); gpiod_set_value_cansleep(sensor->reset, 1); @@ -3009,6 +3012,12 @@ static int ov8865_probe(struct i2c_client *client) goto error_endpoint; } + sensor->privacy_led = devm_gpiod_get_optional(dev, "privacy-led", GPIOD_OUT_LOW); + if (IS_ERR(sensor->privacy_led)) { + ret = PTR_ERR(sensor->privacy_led); + goto error_endpoint; + } + /* External Clock */ sensor->extclk = devm_clk_get(dev, NULL); From patchwork Mon Nov 28 21:44:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 630092 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 9EAABC46467 for ; Mon, 28 Nov 2022 21:46:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233836AbiK1VqL (ORCPT ); Mon, 28 Nov 2022 16:46:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39006 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232860AbiK1VqK (ORCPT ); Mon, 28 Nov 2022 16:46:10 -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 9A68B2FFE2 for ; Mon, 28 Nov 2022 13:44:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1669671865; 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=w6RkPyT4Az4Oqk+MW9n0yAQ0aGyPFE38zf6k639wdOg=; b=IGdgvidQ2rP815DJ7pwmUFRrY4U+UbQDL+6SrjIa245/0W7eIiFmSTUjj42TzqHug1mY9n 4bfAYL7mJ4vPp/+VV2H4S2ECv8Mq562BgAMMNYlUvAQN94hLCOwSwzaEzKc0C+AeiMvuC6 QWihDcthKx95+5vuPyFX5XdxirewhAo= 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-650-_v_EHgyHOMiDWvbifqOSjQ-1; Mon, 28 Nov 2022 16:44:22 -0500 X-MC-Unique: _v_EHgyHOMiDWvbifqOSjQ-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D4803101245C; Mon, 28 Nov 2022 21:44:21 +0000 (UTC) Received: from shalem.redhat.com (unknown [10.39.192.115]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4865340C6EC2; Mon, 28 Nov 2022 21:44:20 +0000 (UTC) From: Hans de Goede To: Mark Gross , Andy Shevchenko , Bartosz Golaszewski , Linus Walleij , Daniel Scally , Laurent Pinchart Cc: Hans de Goede , platform-driver-x86@vger.kernel.org, linux-gpio@vger.kernel.org, Sakari Ailus , Kate Hsuan , linux-media@vger.kernel.org Subject: [PATCH 5/5] platform/x86: int3472: Add support for the back privacy LED on Surface Go models Date: Mon, 28 Nov 2022 22:44:08 +0100 Message-Id: <20221128214408.165726-6-hdegoede@redhat.com> In-Reply-To: <20221128214408.165726-1-hdegoede@redhat.com> References: <20221128214408.165726-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The back camera on the Surface Go series has a privacy LED too, this is connected to the indicator-LED-A output of the tps68470 PMIC. Add a GPIO mapping for this. Together with the patches to add support for the indicator-LED outputs to the gpio-tps68470 driver + the patch to add privacy LED support to the ov8865 drivers this fixes the back privacy LED on the Surface Go models not turning on when the back camera is active. Signed-off-by: Hans de Goede --- drivers/platform/x86/intel/int3472/tps68470_board_data.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/platform/x86/intel/int3472/tps68470_board_data.c b/drivers/platform/x86/intel/int3472/tps68470_board_data.c index 309eab9c0558..ac40fdc13876 100644 --- a/drivers/platform/x86/intel/int3472/tps68470_board_data.c +++ b/drivers/platform/x86/intel/int3472/tps68470_board_data.c @@ -134,6 +134,7 @@ static struct gpiod_lookup_table surface_go_int347a_gpios = { .table = { GPIO_LOOKUP("tps68470-gpio", 9, "reset", GPIO_ACTIVE_LOW), GPIO_LOOKUP("tps68470-gpio", 7, "powerdown", GPIO_ACTIVE_LOW), + GPIO_LOOKUP("tps68470-gpio", 10, "privacy-led", GPIO_ACTIVE_HIGH), { } } };