Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp5558066rwb; Mon, 14 Nov 2022 06:25:49 -0800 (PST) X-Google-Smtp-Source: AA0mqf4pqpmigbHowW1gjVgJhW1CWxdOpPVkayuUx8s+0tGl//vggKwxicI6B6WFq0TE0iSJhVJl X-Received: by 2002:a62:442:0:b0:562:86a3:12fc with SMTP id 63-20020a620442000000b0056286a312fcmr14351335pfe.8.1668435949677; Mon, 14 Nov 2022 06:25:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668435949; cv=none; d=google.com; s=arc-20160816; b=kUJW9OBwkBFZrKhCqkBwX4qBzvxA3VeNkdFq6xzPA0mNO3IzR/84XU/iwP4c02zg7N lOdzl214hVrX8TFJB9O2+m+6cWhaTS1IuAn6HloJyH0P/OW5wwo4FCB1LGXQLw66x9Tc oZr8r0Gzaf5OurTjzLEEJP1q13J2tBLer+5/aVykjwpzqj57Z9lIZbV501ci8oFHWSeh IhDgK+C1BvQcttgW2Y1EF2isRxvttCxi1chCY1YLxk9vBcPame9VEGiBsSy/4xO8smVr lRIYfbVcU5ZK/D/h3RJkRIW9rILVOl4hM07Opev1GnELOPwg5yYJyOSVzXnZDhJ/IdW1 Yg5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:cc:to:from; bh=uHnUVwNOfE80l4ngN9j5+S0ceSpBYpUcTlBGn52DeVo=; b=bmuFhL+/Zr1UhwGRBK4ZlI1RQjDYSEixTL7dsWA/1NV9CZjS7iOPMGkdRB+MUq6gwO WH7G/0Xa1KQaeC9Jr9MMw33fMzt37+hRz1NVb5dmggjfwplklIaPdBYYsNuzIlZUvZIA xT2oRkz7eBC/sw0kMTm8UtqNU9UUOTVyjEIKeabeGNCGhN/Dz1XwxWSz+YSHW6iBbYMK LTS3xyUX1Yu4GNRxczgJ+t3ZPcbMD3+0A6HXUCAfuC77BTkO5lhEVVV2OzjqruaYZy7u vJP7sz9JpVyR+rCkLVRv7IiBb89SuvHiCDD8fPnWCemXL2bnUpFCMrDBNGLHU4UvgruE 0Ytg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=analog.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p2-20020a170902e74200b00178431e112asi10821134plf.449.2022.11.14.06.25.37; Mon, 14 Nov 2022 06:25:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=analog.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236389AbiKNNwr convert rfc822-to-8bit (ORCPT + 88 others); Mon, 14 Nov 2022 08:52:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39744 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235984AbiKNNwq (ORCPT ); Mon, 14 Nov 2022 08:52:46 -0500 Received: from mx0a-00128a01.pphosted.com (mx0a-00128a01.pphosted.com [148.163.135.77]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 409DF22BE0; Mon, 14 Nov 2022 05:52:45 -0800 (PST) Received: from pps.filterd (m0167089.ppops.net [127.0.0.1]) by mx0a-00128a01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2AECVxM9008761; Mon, 14 Nov 2022 08:52:29 -0500 Received: from nwd2mta3.analog.com ([137.71.173.56]) by mx0a-00128a01.pphosted.com (PPS) with ESMTPS id 3ku76yn5j1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 14 Nov 2022 08:52:29 -0500 Received: from ASHBMBX8.ad.analog.com (ASHBMBX8.ad.analog.com [10.64.17.5]) by nwd2mta3.analog.com (8.14.7/8.14.7) with ESMTP id 2AEDqSPE025093 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 14 Nov 2022 08:52:28 -0500 Received: from ASHBMBX9.ad.analog.com (10.64.17.10) by ASHBMBX8.ad.analog.com (10.64.17.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.14; Mon, 14 Nov 2022 08:52:27 -0500 Received: from ASHBMBX9.ad.analog.com ([fe80::c1f2:f121:22ef:29db]) by ASHBMBX9.ad.analog.com ([fe80::c1f2:f121:22ef:29db%20]) with mapi id 15.02.0986.014; Mon, 14 Nov 2022 08:52:27 -0500 From: "Tanislav, Cosmin" To: Jonathan Cameron , Rasmus Villemoes CC: Lars-Peter Clausen , "Hennerich, Michael" , "devicetree@vger.kernel.org" , Rob Herring , "linux-iio@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: RE: [PATCH 5/5] iio: addac: ad74413r: add support for reset-gpio Thread-Topic: [PATCH 5/5] iio: addac: ad74413r: add support for reset-gpio Thread-Index: AQHY9reALFIOJ45fGkOdEYqpsVzwNK4+cXWA Date: Mon, 14 Nov 2022 13:52:26 +0000 Message-ID: <095a454b55cf497392a621649f24e067@analog.com> References: <20221111143921.742194-1-linux@rasmusvillemoes.dk> <20221111143921.742194-6-linux@rasmusvillemoes.dk> <20221112170705.7efe1673@jic23-huawei> In-Reply-To: <20221112170705.7efe1673@jic23-huawei> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: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QUFBQUFBQUFB?= =?us-ascii?Q?QUVBQUFBQUFBQUFBZ0FBQUFBQW5nQUFBR0VBWkFCcEFGOEFjd0JsQUdNQWRR?= =?us-ascii?Q?QnlBR1VBWHdCd0FISUFid0JxQUdVQVl3QjBBSE1BWHdCMEFHa0FaUUJ5QURF?= =?us-ascii?Q?QUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFB?= =?us-ascii?Q?QUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFB?= =?us-ascii?Q?QUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFRQUFBQUFBQUFBQ0FB?= =?us-ascii?Q?QUFBQUNlQUFBQVlRQmtBR2tBWHdCekFHVUFZd0IxQUhJQVpRQmZBSEFBY2dC?= =?us-ascii?Q?dkFHb0FaUUJqQUhRQWN3QmZBSFFBYVFCbEFISUFNZ0FBQUFBQUFBQUFBQUFB?= =?us-ascii?Q?QUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFB?= =?us-ascii?Q?QUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFB?= =?us-ascii?Q?QUFBQUFBQUFBQUFBQUFBQUFCQUFBQUFBQUFBQUlBQUFBQUFBPT0iLz48L21l?= =?us-ascii?Q?dGE+?= x-dg-rorf: true x-originating-ip: [10.32.224.42] x-adiruleop-newscl: Rule Triggered Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-Proofpoint-GUID: qir8QAEG-MWFkEc3ZemqDaFniSX2X3dx X-Proofpoint-ORIG-GUID: qir8QAEG-MWFkEc3ZemqDaFniSX2X3dx X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-11-14_12,2022-11-11_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 clxscore=1011 phishscore=0 bulkscore=0 lowpriorityscore=0 mlxlogscore=999 suspectscore=0 mlxscore=0 spamscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2211140098 X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > -----Original Message----- > From: Jonathan Cameron > Sent: Saturday, November 12, 2022 7:07 PM > To: Rasmus Villemoes > Cc: Tanislav, Cosmin ; Lars-Peter Clausen > ; Hennerich, Michael ; > devicetree@vger.kernel.org; Rob Herring ; linux- > iio@vger.kernel.org; linux-kernel@vger.kernel.org > Subject: Re: [PATCH 5/5] iio: addac: ad74413r: add support for reset-gpio > > [External] > > On Fri, 11 Nov 2022 15:39:21 +0100 > Rasmus Villemoes wrote: > > > We have a board where the reset pin of the ad74412 is connected to a > > gpio, but also pulled low by default. Hence to get the chip out of > > reset, the driver needs to know about that gpio and set it high before > > attempting to communicate with it. > > I'm a little confused on polarity here. The pin is a !reset so > we need to drive it low briefly to trigger a reset. > I'm guessing for your board the pin is set to active low? (an example > in the dt would have made that clearer) Hence the pulse > in here to 1 is actually briefly driving it low before restoring to high? > > For a pin documented as !reset that seems backwards though you have > called it reset so that is fine, but this description doesn't make that > celar. My opinion is that the driver shouldn't exactly know the polarity of the reset, and just assume that setting the reset GPIO to 1 means putting it in reset, and setting it to 0 means bringing out of reset. > > Perhaps just add some more description here to make it clear the GPIO > is active low, and then refer to setting it to true and false to avoid > the confusing high / low terminology which are inverted... > > > > > When a reset-gpio is given in device tree, use that instead of the > > software reset. According to the data sheet, the two methods are > > functionally equivalent. > > > > Signed-off-by: Rasmus Villemoes > > --- > > drivers/iio/addac/ad74413r.c | 12 ++++++++++++ > > 1 file changed, 12 insertions(+) > > > > diff --git a/drivers/iio/addac/ad74413r.c b/drivers/iio/addac/ad74413r.c > > index 9f77d2f514de..af09d43f921c 100644 > > --- a/drivers/iio/addac/ad74413r.c > > +++ b/drivers/iio/addac/ad74413r.c > > @@ -71,6 +71,7 @@ struct ad74413r_state { > > struct regmap *regmap; > > struct device *dev; > > struct iio_trigger *trig; > > + struct gpio_desc *reset_gpio; > > > > size_t adc_active_channels; > > struct spi_message adc_samples_msg; > > @@ -393,6 +394,13 @@ static int ad74413r_reset(struct ad74413r_state > *st) > > { > > int ret; > > > > + if (st->reset_gpio) { > > + gpiod_set_value_cansleep(st->reset_gpio, 1); > > + fsleep(50); > > + gpiod_set_value_cansleep(st->reset_gpio, 0); > > + return 0; > > + } > > + > > ret = regmap_write(st->regmap, AD74413R_REG_CMD_KEY, > > AD74413R_CMD_KEY_RESET1); > > if (ret) > > @@ -1316,6 +1324,10 @@ static int ad74413r_probe(struct spi_device *spi) > > if (IS_ERR(st->regmap)) > > return PTR_ERR(st->regmap); > > > > + st->reset_gpio = devm_gpiod_get_optional(st->dev, "reset", > GPIOD_OUT_LOW); > > + if (IS_ERR(st->reset_gpio)) > > + return PTR_ERR(st->reset_gpio); > > + > > st->refin_reg = devm_regulator_get_optional(st->dev, "refin"); > > if (IS_ERR(st->refin_reg)) { > > ret = PTR_ERR(st->refin_reg);