From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from wnew3-smtp.messagingengine.com (wnew3-smtp.messagingengine.com [64.147.123.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7EDEF3FD0 for ; Tue, 14 Sep 2021 07:28:33 +0000 (UTC) Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailnew.west.internal (Postfix) with ESMTP id 93C8D2B01223; Tue, 14 Sep 2021 03:28:31 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Tue, 14 Sep 2021 03:28:32 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h= date:from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=fm3; bh=hvVjVrfSs4NfbZwUvsxZ1AIAjiN Kf/AxOnqlfzcIO3w=; b=BNjOx/AihmBs1wdMnZUt41zDND5dmoq3ZZKrl4HnHY2 n4O9g5pag6oJ5V5QTKYLEopFcFit8H4TZpnDTVDpL6VCgV4U7+oH2Pu31fZx8rkL H7O0p086NO9gxYhsy5J980A8m8Tmc0skb3jPLDf5qgpfd7vS4mT3NxTZ/f5KlcDj pomU3VcA+wl/EPKshVIA9geMP8YSY+dSL+VVBMO5Kpnkht1EhyymvYP4mV008bL7 VK10llKYavsHEi2yfYrQO4E06d8mvcr2m9WHeHPUKVDfb6cnnwfxT1eIjS/hzWiz zbEhlhpGpuC4U85fOFt8M60mcKl5BkEJnSvlM2VKQGQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=hvVjVr fSs4NfbZwUvsxZ1AIAjiNKf/AxOnqlfzcIO3w=; b=ZC1956DSICswdAdl2s0Ol1 cA7e+CBNDk1Pe+3u0UpevfVh8x4SC7ROXTDG1g+0eEdpaWnR0oDrxx9YkFNhmISp fO9taT451Y4czoXjFCK/47IbIFNaqe4LaruKbhcIR5yGsQ5QoJensUbi+iZjDyMV xV07pzZYHUNz1d26YDYTj17ylP+yJGksyaWVcUdjhT4zPrqlzrt8STXlyzvSBtJM ZJbEnF7PEO/8yI6I9GiBN073gSJN4YXheFSrM1xb1UgCykV+fKzWiv90XbT5j+ld SS228t1xyl/HHB96yVTUXYvHZlxjQhq1+3vCyzf2dvZDwCU5ZAbrl2jF1mCgZW9Q == X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrudegkedguddujecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpeffhffvuffkfhggtggujgesghdtreertddtvdenucfhrhhomhepofgrgihi mhgvucftihhprghrugcuoehmrgigihhmvgestggvrhhnohdrthgvtghhqeenucggtffrrg htthgvrhhnpeelkeeghefhuddtleejgfeljeffheffgfeijefhgfeufefhtdevteegheei heegudenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpe hmrgigihhmvgestggvrhhnohdrthgvtghh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 14 Sep 2021 03:28:29 -0400 (EDT) Date: Tue, 14 Sep 2021 09:28:27 +0200 From: Maxime Ripard To: Samuel Holland Cc: Dmitry Torokhov , Hans de Goede , Rob Herring , Chen-Yu Tsai , Jernej Skrabec , Philipp Zabel , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-input@vger.kernel.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/3] Input: sun4i-lradc-keys: Add optional clock/reset support Message-ID: <20210914072827.jgv6piny47veacig@gilmour> References: <20210908034016.24119-1-samuel@sholland.org> <20210908034016.24119-3-samuel@sholland.org> Precedence: bulk X-Mailing-List: linux-sunxi@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="rzmx22vvpwfmbzkv" Content-Disposition: inline In-Reply-To: <20210908034016.24119-3-samuel@sholland.org> --rzmx22vvpwfmbzkv Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi Samuel, On Tue, Sep 07, 2021 at 10:40:15PM -0500, Samuel Holland wrote: > Until the R329, the LRADC hardware was always active. Now it requires > enabling a clock gate and deasserting a reset line. Do this if the clock > and reset are provided in the device tree, but keep them optional to > maintain support for the existing binding. >=20 > Signed-off-by: Samuel Holland > --- > drivers/input/keyboard/sun4i-lradc-keys.c | 29 +++++++++++++++++++++++ > 1 file changed, 29 insertions(+) >=20 > diff --git a/drivers/input/keyboard/sun4i-lradc-keys.c b/drivers/input/ke= yboard/sun4i-lradc-keys.c > index 4a796bed48ac..50fc18052829 100644 > --- a/drivers/input/keyboard/sun4i-lradc-keys.c > +++ b/drivers/input/keyboard/sun4i-lradc-keys.c > @@ -14,6 +14,7 @@ > * there are no boards known to use channel 1. > */ > =20 > +#include > #include > #include > #include > @@ -23,6 +24,7 @@ > #include > #include > #include > +#include > #include > =20 > #define LRADC_CTRL 0x00 > @@ -83,6 +85,8 @@ struct sun4i_lradc_data { > struct device *dev; > struct input_dev *input; > void __iomem *base; > + struct clk *clk; > + struct reset_control *reset; > struct regulator *vref_supply; > struct sun4i_lradc_keymap *chan0_map; > const struct lradc_variant *variant; > @@ -140,6 +144,14 @@ static int sun4i_lradc_open(struct input_dev *dev) > if (error) > return error; > =20 > + error =3D reset_control_deassert(lradc->reset); > + if (error) > + goto err_disable_reg; > + > + error =3D clk_prepare_enable(lradc->clk); > + if (error) > + goto err_assert_reset; > + > lradc->vref =3D regulator_get_voltage(lradc->vref_supply) * > lradc->variant->divisor_numerator / > lradc->variant->divisor_denominator; > @@ -153,6 +165,13 @@ static int sun4i_lradc_open(struct input_dev *dev) > writel(CHAN0_KEYUP_IRQ | CHAN0_KEYDOWN_IRQ, lradc->base + LRADC_INTC); > =20 > return 0; > + > +err_assert_reset: > + reset_control_assert(lradc->reset); > +err_disable_reg: > + regulator_disable(lradc->vref_supply); > + > + return error; > } > =20 > static void sun4i_lradc_close(struct input_dev *dev) > @@ -164,6 +183,8 @@ static void sun4i_lradc_close(struct input_dev *dev) > SAMPLE_RATE(2), lradc->base + LRADC_CTRL); > writel(0, lradc->base + LRADC_INTC); > =20 > + clk_disable_unprepare(lradc->clk); > + reset_control_assert(lradc->reset); > regulator_disable(lradc->vref_supply); > } > =20 > @@ -243,6 +264,14 @@ static int sun4i_lradc_probe(struct platform_device = *pdev) > return -EINVAL; > } > =20 > + lradc->clk =3D devm_clk_get_optional(dev, NULL); > + if (IS_ERR(lradc->clk)) > + return PTR_ERR(lradc->clk); > + > + lradc->reset =3D devm_reset_control_get_optional_exclusive(dev, NULL); > + if (IS_ERR(lradc->reset)) > + return PTR_ERR(lradc->reset); > + This wouldn't report an error if the clocks are missing on the R329 (and D1), even though they are required. The way we usually deal with this is through a flag in the variant structure (at least to guard clk_get / reset_control_get) Maxime --rzmx22vvpwfmbzkv Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYIAB0WIQRcEzekXsqa64kGDp7j7w1vZxhRxQUCYUBPGwAKCRDj7w1vZxhR xQPqAP9LGRvPenYpVtWJ7qukgVZrUVeqfttxeSmMC5gIPT+hLwEA+33NIDCBUsS5 hzuRkA1uLpYHY1fKdfQpdP+Kvb8XhQM= =KI02 -----END PGP SIGNATURE----- --rzmx22vvpwfmbzkv-- From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4C2EFC433F5 for ; Tue, 14 Sep 2021 07:30:25 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id B860A60E74 for ; Tue, 14 Sep 2021 07:30:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org B860A60E74 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=cerno.tech Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type: List-Subscribe:List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: In-Reply-To:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Reply-To:Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date :Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=bIj3P1I/DAS3JaG82R1Gwm0cGl2VIVrs/H1/G1QxrYQ=; b=dxd1tY5D4Dtbuau/Im9tMj7kXV ISJHzonU1TtDKzEeQyRobGcG9rIhy2aTnYSKbJpmkXd0jTrqhMr7XsSXG5Bh2+IKsetOh6ri0uy2B dzNxTZrH0zYHZsHVCFgftg5RFBs8FgrTY/reGzHdK72n0oksvyW5aBJAu5vW2D/FO62g8WZ8C6EG/ 9d7ihjSbUjViQD9ZlKOpeLbWWAeOOmWGYAAo+GN0AlgvvsozMS4M7fRO2gloFWqv1H3Q2v5e0uN/7 Y5fmyQCVantgMKyM9I897fgy+oSptNSs6Y6NeeVPJ54E3pxHfxQ//6OxrPC0YiOXd25z9lDrvi8dR txzQAOZQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mQ2rs-004Tdf-RG; Tue, 14 Sep 2021 07:28:37 +0000 Received: from wnew3-smtp.messagingengine.com ([64.147.123.17]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mQ2rp-004TcZ-6I for linux-arm-kernel@lists.infradead.org; Tue, 14 Sep 2021 07:28:34 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailnew.west.internal (Postfix) with ESMTP id 93C8D2B01223; Tue, 14 Sep 2021 03:28:31 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Tue, 14 Sep 2021 03:28:32 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h= date:from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=fm3; bh=hvVjVrfSs4NfbZwUvsxZ1AIAjiN Kf/AxOnqlfzcIO3w=; b=BNjOx/AihmBs1wdMnZUt41zDND5dmoq3ZZKrl4HnHY2 n4O9g5pag6oJ5V5QTKYLEopFcFit8H4TZpnDTVDpL6VCgV4U7+oH2Pu31fZx8rkL H7O0p086NO9gxYhsy5J980A8m8Tmc0skb3jPLDf5qgpfd7vS4mT3NxTZ/f5KlcDj pomU3VcA+wl/EPKshVIA9geMP8YSY+dSL+VVBMO5Kpnkht1EhyymvYP4mV008bL7 VK10llKYavsHEi2yfYrQO4E06d8mvcr2m9WHeHPUKVDfb6cnnwfxT1eIjS/hzWiz zbEhlhpGpuC4U85fOFt8M60mcKl5BkEJnSvlM2VKQGQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=hvVjVr fSs4NfbZwUvsxZ1AIAjiNKf/AxOnqlfzcIO3w=; b=ZC1956DSICswdAdl2s0Ol1 cA7e+CBNDk1Pe+3u0UpevfVh8x4SC7ROXTDG1g+0eEdpaWnR0oDrxx9YkFNhmISp fO9taT451Y4czoXjFCK/47IbIFNaqe4LaruKbhcIR5yGsQ5QoJensUbi+iZjDyMV xV07pzZYHUNz1d26YDYTj17ylP+yJGksyaWVcUdjhT4zPrqlzrt8STXlyzvSBtJM ZJbEnF7PEO/8yI6I9GiBN073gSJN4YXheFSrM1xb1UgCykV+fKzWiv90XbT5j+ld SS228t1xyl/HHB96yVTUXYvHZlxjQhq1+3vCyzf2dvZDwCU5ZAbrl2jF1mCgZW9Q == X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrudegkedguddujecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpeffhffvuffkfhggtggujgesghdtreertddtvdenucfhrhhomhepofgrgihi mhgvucftihhprghrugcuoehmrgigihhmvgestggvrhhnohdrthgvtghhqeenucggtffrrg htthgvrhhnpeelkeeghefhuddtleejgfeljeffheffgfeijefhgfeufefhtdevteegheei heegudenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpe hmrgigihhmvgestggvrhhnohdrthgvtghh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 14 Sep 2021 03:28:29 -0400 (EDT) Date: Tue, 14 Sep 2021 09:28:27 +0200 From: Maxime Ripard To: Samuel Holland Cc: Dmitry Torokhov , Hans de Goede , Rob Herring , Chen-Yu Tsai , Jernej Skrabec , Philipp Zabel , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-input@vger.kernel.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/3] Input: sun4i-lradc-keys: Add optional clock/reset support Message-ID: <20210914072827.jgv6piny47veacig@gilmour> References: <20210908034016.24119-1-samuel@sholland.org> <20210908034016.24119-3-samuel@sholland.org> MIME-Version: 1.0 In-Reply-To: <20210908034016.24119-3-samuel@sholland.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210914_002833_308831_CAB2AB91 X-CRM114-Status: GOOD ( 23.97 ) 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: , Content-Type: multipart/mixed; boundary="===============5735162301499842668==" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org --===============5735162301499842668== Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="rzmx22vvpwfmbzkv" Content-Disposition: inline --rzmx22vvpwfmbzkv Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi Samuel, On Tue, Sep 07, 2021 at 10:40:15PM -0500, Samuel Holland wrote: > Until the R329, the LRADC hardware was always active. Now it requires > enabling a clock gate and deasserting a reset line. Do this if the clock > and reset are provided in the device tree, but keep them optional to > maintain support for the existing binding. >=20 > Signed-off-by: Samuel Holland > --- > drivers/input/keyboard/sun4i-lradc-keys.c | 29 +++++++++++++++++++++++ > 1 file changed, 29 insertions(+) >=20 > diff --git a/drivers/input/keyboard/sun4i-lradc-keys.c b/drivers/input/ke= yboard/sun4i-lradc-keys.c > index 4a796bed48ac..50fc18052829 100644 > --- a/drivers/input/keyboard/sun4i-lradc-keys.c > +++ b/drivers/input/keyboard/sun4i-lradc-keys.c > @@ -14,6 +14,7 @@ > * there are no boards known to use channel 1. > */ > =20 > +#include > #include > #include > #include > @@ -23,6 +24,7 @@ > #include > #include > #include > +#include > #include > =20 > #define LRADC_CTRL 0x00 > @@ -83,6 +85,8 @@ struct sun4i_lradc_data { > struct device *dev; > struct input_dev *input; > void __iomem *base; > + struct clk *clk; > + struct reset_control *reset; > struct regulator *vref_supply; > struct sun4i_lradc_keymap *chan0_map; > const struct lradc_variant *variant; > @@ -140,6 +144,14 @@ static int sun4i_lradc_open(struct input_dev *dev) > if (error) > return error; > =20 > + error =3D reset_control_deassert(lradc->reset); > + if (error) > + goto err_disable_reg; > + > + error =3D clk_prepare_enable(lradc->clk); > + if (error) > + goto err_assert_reset; > + > lradc->vref =3D regulator_get_voltage(lradc->vref_supply) * > lradc->variant->divisor_numerator / > lradc->variant->divisor_denominator; > @@ -153,6 +165,13 @@ static int sun4i_lradc_open(struct input_dev *dev) > writel(CHAN0_KEYUP_IRQ | CHAN0_KEYDOWN_IRQ, lradc->base + LRADC_INTC); > =20 > return 0; > + > +err_assert_reset: > + reset_control_assert(lradc->reset); > +err_disable_reg: > + regulator_disable(lradc->vref_supply); > + > + return error; > } > =20 > static void sun4i_lradc_close(struct input_dev *dev) > @@ -164,6 +183,8 @@ static void sun4i_lradc_close(struct input_dev *dev) > SAMPLE_RATE(2), lradc->base + LRADC_CTRL); > writel(0, lradc->base + LRADC_INTC); > =20 > + clk_disable_unprepare(lradc->clk); > + reset_control_assert(lradc->reset); > regulator_disable(lradc->vref_supply); > } > =20 > @@ -243,6 +264,14 @@ static int sun4i_lradc_probe(struct platform_device = *pdev) > return -EINVAL; > } > =20 > + lradc->clk =3D devm_clk_get_optional(dev, NULL); > + if (IS_ERR(lradc->clk)) > + return PTR_ERR(lradc->clk); > + > + lradc->reset =3D devm_reset_control_get_optional_exclusive(dev, NULL); > + if (IS_ERR(lradc->reset)) > + return PTR_ERR(lradc->reset); > + This wouldn't report an error if the clocks are missing on the R329 (and D1), even though they are required. The way we usually deal with this is through a flag in the variant structure (at least to guard clk_get / reset_control_get) Maxime --rzmx22vvpwfmbzkv Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYIAB0WIQRcEzekXsqa64kGDp7j7w1vZxhRxQUCYUBPGwAKCRDj7w1vZxhR xQPqAP9LGRvPenYpVtWJ7qukgVZrUVeqfttxeSmMC5gIPT+hLwEA+33NIDCBUsS5 hzuRkA1uLpYHY1fKdfQpdP+Kvb8XhQM= =KI02 -----END PGP SIGNATURE----- --rzmx22vvpwfmbzkv-- --===============5735162301499842668== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel --===============5735162301499842668==--