From patchwork Wed Jul 31 07:02:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 13748220 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DE362C3DA64 for ; Wed, 31 Jul 2024 07:04:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=1en2UDhCmjTGFGjP/TgFY9CbGILQ1ytXSVromO9IkT0=; b=MqAz1qQKmxkg4xe9iHauENdfUN Dz0x4qSUgmscDgJkQe6Tr5n7q5b7lg+sISP1/bBGReBHClA6pylmH+VeHx/ubCFXtw8xkBjte6dXU U1eKOrASnvS6zVUlO25eKfcLaoSfBluZqtF4h+k6Q0OX7n87RIdjhZ0vthO4hiXLRVKuPE/f2Cuq0 7gX0GoU+lKSzrr5NSd+1KaNi3gFPzoTXvaa3cuBY4nvFv8BBFuQapMWAWoxN9Fhpfvge0CGF8y1tN a4kOGzZvQhv7eWsFtcgdPy4+UwvtF54V9fLhiqVY9SxY61PA9NR3XMYgvLgQZCR9FVunPta1H0XfJ mH8Ka6Uw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sZ3Nn-000000002t1-2uHL; Wed, 31 Jul 2024 07:04:23 +0000 Received: from perceval.ideasonboard.com ([213.167.242.64]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sZ3MW-000000002Uh-2OBG for linux-arm-kernel@lists.infradead.org; Wed, 31 Jul 2024 07:03:06 +0000 Received: from [192.168.29.25] (unknown [IPv6:2405:201:2015:f873:55f8:639e:8e9f:12ec]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id C6EE3F85; Wed, 31 Jul 2024 09:02:11 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1722409334; bh=cBiZJlXkx8Xmxiz4nT0B6k8ktBei6F1rsFujvTYFtUU=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=tyo9h4neSWXbeQzktPZ0x+tEEfATrVrlSM3ErEzLvZdaFAdkHnfAH+uyzjjkQPxOl yLrxdcNIKjWlELaY86S4i0P6OleV3TfYKNFSGnsCsUopB2G2tADEXdH8ZMl/3SUVPn xdTkDK5bou+RoEJaSdg89vXLT9VBCAbpy3Uy5q8Q= From: Umang Jain Date: Wed, 31 Jul 2024 12:32:41 +0530 Subject: [PATCH v3 1/2] dt-bindings: media: imx335: Add reset-gpios to the DT example MIME-Version: 1.0 Message-Id: <20240731-imx335-gpio-v3-1-443bfa6ce864@ideasonboard.com> References: <20240731-imx335-gpio-v3-0-443bfa6ce864@ideasonboard.com> In-Reply-To: <20240731-imx335-gpio-v3-0-443bfa6ce864@ideasonboard.com> To: Mauro Carvalho Chehab , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , "Paul J. Murphy" , Daniele Alessandrelli , Sakari Ailus , Martina Krasteva Cc: linux-media@vger.kernel.org, devicetree@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Mauro Carvalho Chehab , Kieran Bingham , Sakari Ailus , Laurent Pinchart , Umang Jain X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1722409375; l=1423; i=umang.jain@ideasonboard.com; s=20240731; h=from:subject:message-id; bh=cBiZJlXkx8Xmxiz4nT0B6k8ktBei6F1rsFujvTYFtUU=; b=sPqZV88nyfYCPAOxBPZSR18zsVZf7Rdt51WTlArhr3UPStdyjtjvp3x6lr+wQlovbLwb3gqWj 2Sfr+y9M9L+BtucN6Z/bmaZGOJxnxxzYQx5Q3clvoRPWlman1QZ0eHL X-Developer-Key: i=umang.jain@ideasonboard.com; a=ed25519; pk=7pvnIBNsDpFUMiph0Vlhrr01+rAn5fSIn/QtDeLeXL0= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240731_000304_788497_359BB30A X-CRM114-Status: GOOD ( 11.94 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org It's easy to get the polarity of GPIOs in the device tree wrong, as shown by a recently fixed bug in the imx335 driver. To lower the chance of future mistakes, especially in new bindings that would take the imx335 binding as a starting point, add the reset-gpios property to the DT example. This showcases the correct polarity of the XCLR signal for Sony sensors in the most common case of the signal not being inverted on the board. Signed-off-by: Umang Jain Acked-by: Krzysztof Kozlowski --- Documentation/devicetree/bindings/media/i2c/sony,imx335.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Documentation/devicetree/bindings/media/i2c/sony,imx335.yaml b/Documentation/devicetree/bindings/media/i2c/sony,imx335.yaml index 106c36ee966d..77bf3a4ee89d 100644 --- a/Documentation/devicetree/bindings/media/i2c/sony,imx335.yaml +++ b/Documentation/devicetree/bindings/media/i2c/sony,imx335.yaml @@ -75,6 +75,8 @@ additionalProperties: false examples: - | + #include + i2c { #address-cells = <1>; #size-cells = <0>; @@ -92,6 +94,8 @@ examples: ovdd-supply = <&camera_vddo_1v8>; dvdd-supply = <&camera_vddd_1v2>; + reset-gpios = <&gpio 50 GPIO_ACTIVE_LOW>; + port { imx335: endpoint { remote-endpoint = <&cam>; From patchwork Wed Jul 31 07:02:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 13748221 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C4619C3DA7F for ; Wed, 31 Jul 2024 07:05:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=bXkbyqA3O8LFzbO73jt+gAxLKAd+1a+TyKM90xETpAc=; b=0WXwxZ3oCIJTiYKR9m54VHK4GS GBqaV/rIAPi3j8Nztm3c7IDDvzTelHNf19X/qIL6ygSQ+C8JxMU9WqVfdEcw7wArDaUmrMCX5leCN 6dfF/KvSd6PJ/4TDhj0wZTEhwQiMrDGzG/50ORBXjlPSfD/HccIEujd6n68Vkt1UCL8bC3tb2l+rZ ck1FyfryPbaB3z/0oylGFjwRHBTBRVAW+8gCmkj2M/51oItNFOjHp91f5lWZkgpguJPR24bxCmQhO YL68vDPOux0TsT70d2kW4/GORMlQB/KknsXY5+Ebk8PSp18dZQSZ8p5m3xN4G9MSy/JIeuDhZXOEX 2KfzD5cQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sZ3OG-0000000033w-3K8j; Wed, 31 Jul 2024 07:04:52 +0000 Received: from perceval.ideasonboard.com ([213.167.242.64]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sZ3MY-000000002VE-3dsV for linux-arm-kernel@lists.infradead.org; Wed, 31 Jul 2024 07:03:08 +0000 Received: from [192.168.29.25] (unknown [IPv6:2405:201:2015:f873:55f8:639e:8e9f:12ec]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 27D75144C; Wed, 31 Jul 2024 09:02:15 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1722409338; bh=dkOkY+B0/cyoFmPI2OdnhUFer6WrrHex+z/Q5THTpcg=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=g128npLwemLjujaENCfvYbZAzH0yaq505ZO47BvznBeJuY8ByKKgpQjun9DvJAH+X vRsgOijAyIuACJgzSTglgunqAoinEoAOiPwwkYL23vBdztC2kUd0VJmHgcQ/NXNJiO g56i0aDRPF5Vm+DijExQ3ZMg1bAUwbychKQhvy3Q= From: Umang Jain Date: Wed, 31 Jul 2024 12:32:42 +0530 Subject: [PATCH v3 2/2] media: imx335: Fix reset-gpio handling MIME-Version: 1.0 Message-Id: <20240731-imx335-gpio-v3-2-443bfa6ce864@ideasonboard.com> References: <20240731-imx335-gpio-v3-0-443bfa6ce864@ideasonboard.com> In-Reply-To: <20240731-imx335-gpio-v3-0-443bfa6ce864@ideasonboard.com> To: Mauro Carvalho Chehab , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , "Paul J. Murphy" , Daniele Alessandrelli , Sakari Ailus , Martina Krasteva Cc: linux-media@vger.kernel.org, devicetree@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Mauro Carvalho Chehab , Kieran Bingham , Sakari Ailus , Laurent Pinchart , Umang Jain , stable@vger.kernel.org X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1722409375; l=2193; i=umang.jain@ideasonboard.com; s=20240731; h=from:subject:message-id; bh=dkOkY+B0/cyoFmPI2OdnhUFer6WrrHex+z/Q5THTpcg=; b=aHtk6nfQ3/4g+Uszq64ruRfgME2MRH39/fIvSRh1R2OI7mMpDTXr1wj+1g1Ij1Ps/Nip+4iH0 aS/nPto3/NQCEbI6EgL2sS41b8imnpNFN7wOq4hc4zDHN9rWKclibHr X-Developer-Key: i=umang.jain@ideasonboard.com; a=ed25519; pk=7pvnIBNsDpFUMiph0Vlhrr01+rAn5fSIn/QtDeLeXL0= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240731_000307_083841_57845A84 X-CRM114-Status: GOOD ( 11.83 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Rectify the logical value of reset-gpio so that it is set to 0 (disabled) during power-on and to 1 (enabled) during power-off. Meanwhile at it, set the reset-gpio to GPIO_OUT_HIGH at initialization time to make sure it starts off in reset. Also drop the "Set XCLR" comment which is not-so-informative. Cc: stable@vger.kernel.org Fixes: 45d19b5fb9ae ("media: i2c: Add imx335 camera sensor driver") Reviewed-by: Laurent Pinchart Signed-off-by: Umang Jain --- drivers/media/i2c/imx335.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/media/i2c/imx335.c b/drivers/media/i2c/imx335.c index cd150606a8a9..79b6d60bf6af 100644 --- a/drivers/media/i2c/imx335.c +++ b/drivers/media/i2c/imx335.c @@ -1057,7 +1057,7 @@ static int imx335_parse_hw_config(struct imx335 *imx335) /* Request optional reset pin */ imx335->reset_gpio = devm_gpiod_get_optional(imx335->dev, "reset", - GPIOD_OUT_LOW); + GPIOD_OUT_HIGH); if (IS_ERR(imx335->reset_gpio)) { dev_err(imx335->dev, "failed to get reset gpio %ld\n", PTR_ERR(imx335->reset_gpio)); @@ -1170,8 +1170,7 @@ static int imx335_power_on(struct device *dev) usleep_range(500, 550); /* Tlow */ - /* Set XCLR */ - gpiod_set_value_cansleep(imx335->reset_gpio, 1); + gpiod_set_value_cansleep(imx335->reset_gpio, 0); ret = clk_prepare_enable(imx335->inclk); if (ret) { @@ -1184,7 +1183,7 @@ static int imx335_power_on(struct device *dev) return 0; error_reset: - gpiod_set_value_cansleep(imx335->reset_gpio, 0); + gpiod_set_value_cansleep(imx335->reset_gpio, 1); regulator_bulk_disable(ARRAY_SIZE(imx335_supply_name), imx335->supplies); return ret; @@ -1201,7 +1200,7 @@ static int imx335_power_off(struct device *dev) struct v4l2_subdev *sd = dev_get_drvdata(dev); struct imx335 *imx335 = to_imx335(sd); - gpiod_set_value_cansleep(imx335->reset_gpio, 0); + gpiod_set_value_cansleep(imx335->reset_gpio, 1); clk_disable_unprepare(imx335->inclk); regulator_bulk_disable(ARRAY_SIZE(imx335_supply_name), imx335->supplies);