Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3107453pxb; Mon, 1 Nov 2021 08:01:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx5eXmRXWk1l0RceYcDNM41HtBo9sBbn2dKzEYEnRsGVgLX/NLAJFDt/EmJKd5S6IuNa8cB X-Received: by 2002:a05:6e02:198e:: with SMTP id g14mr21059837ilf.204.1635778889864; Mon, 01 Nov 2021 08:01:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635778889; cv=none; d=google.com; s=arc-20160816; b=agv675OCW+qkCx3XWf2+NBrgSWLYQiNpwMKXaM79uVBPQJL1OXjaO20OaNSY5x2Rzr 2SufscdpBtwaJLG2Xqqzfw3a7YbIe73wRzEF5wwmsL7hYT99suhLY2f4Ic7xHoVsIEzf RqBBHlI7in8YRomBeJjZnrVZoBE9glGHMFGvUBSb2ZCdH/77YYqniuXQ+RyGNyIun9TI b6i2lxjoXgRCxQptMe6rZSIjKV48kFRf22TWUEMC4VWjZ+ZtmDctEknKAwX+IXyp/9ox V6bMznweknBZQMmveoYsCFiwSx1NSel2Jdk90b4OmZ/6YkP4osa9dmpuqlN9/sD6zWLS 1IJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id; bh=AKXHDFP3SrsdQF9J9RHV3bFdL8VuKYkw8XncgestaQw=; b=x1ESt5aBGy6v6P4vpePi04o7j4GY8vfBm3dpzRVePv4gH+Kn1fCpgNbMV5xfb6LDta ky41vPQ8z3cx/SBxRXfT2EJ2UovAFSdznqkOyAT2yJXxpVG8DUsSvOS7MFtIrECrQyNe 8Dzz6tvgB6VOBSw6muRplTzzc13PPe0WZh3qwE6KHVpmjZAG5qagR0z+p4qPZ0VYWSGV t7bmP01bqqYey/bnHwHTkWwlFbmiDzoq+cu+58rlu7mVIGtrKB3PUQJ8M4Kj6I1dUNp5 ooJx67HWh1BXx9xhm7VIYcfN4CZb1otQbQDZI5+DgXdV8AU3qsqoT8PekBfLzBft6lut mF9g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l6si23746015ilh.136.2021.11.01.08.01.12; Mon, 01 Nov 2021 08:01:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231741AbhKAPBU (ORCPT + 99 others); Mon, 1 Nov 2021 11:01:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35126 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231304AbhKAPBS (ORCPT ); Mon, 1 Nov 2021 11:01:18 -0400 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E704C061714 for ; Mon, 1 Nov 2021 07:58:45 -0700 (PDT) Received: from gallifrey.ext.pengutronix.de ([2001:67c:670:201:5054:ff:fe8d:eefb] helo=[IPv6:::1]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mhYle-0005LQ-1T; Mon, 01 Nov 2021 15:58:34 +0100 Message-ID: <557e68ad15634ddb65c98ebf80cd7ef962ac2608.camel@pengutronix.de> Subject: Re: [PATCH v2 RESEND] PCI: imx6: Replace legacy gpio interface for gpiod interface From: Lucas Stach To: =?ISO-8859-1?Q?Ma=EDra?= Canal Cc: hongxing.zhu@nxp.com, lorenzo.pieralisi@arm.com, robh@kernel.org, Bjorn Helgaas , Bjorn Helgaas , shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, linux-imx@nxp.com, linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Date: Mon, 01 Nov 2021 15:58:31 +0100 In-Reply-To: References: <4f1b60bab451b219c7139e2204eb5b9f462ee4e0.camel@pengutronix.de> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.40.4 (3.40.4-1.fc34) MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 2001:67c:670:201:5054:ff:fe8d:eefb X-SA-Exim-Mail-From: l.stach@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Am Montag, dem 01.11.2021 um 11:44 -0300 schrieb MaĆ­ra Canal: > ? > > > /* Some boards don't have PCIe reset GPIO. */ > > > - if (gpio_is_valid(imx6_pcie->reset_gpio)) { > > > - gpio_set_value_cansleep(imx6_pcie->reset_gpio, > > > + if (imx6_pcie->reset_gpio) { > > > + gpiod_set_value_cansleep(imx6_pcie->reset_gpio, > > > imx6_pcie->gpio_active_high); > > > msleep(100); > > > - gpio_set_value_cansleep(imx6_pcie->reset_gpio, > > > + gpiod_set_value_cansleep(imx6_pcie->reset_gpio, > > > !imx6_pcie->gpio_active_high); > > > > I don't think this is correct. gpiod_set_value sets the logical line > > state, so if the GPIO is specified as active-low in the DT, the real > > line state will be negated. The only reason why the reset-gpio-active- > > high property even exists is that old DTs might specify the wrong GPIO > > polarity in the reset-gpio DT description. I think you need to use to > > gpiod_set_raw_value API here to get the expected real line state even > > with a broken DT description. > > > > Regards, > > Lucas > > > > I'm a beginner in kernel development, so I'm sorry for the question. > If I change gpiod_set_value_cansleep for gpiod_set_raw_value, wouldn't > I change the behavior of the driver? I replaced > gpio_set_value_cansleep for gpiod_set_value_cansleep because they have > the same behavior and I didn't change the logic states. Thank you for > the feedback! Yes, you need to use the _cansleep variant of the API to keep the context information. The point I was trying to make was that you probably (please double check, that's just an assumption on my side) need to use the _raw variant of the gpiod API to keep the current behavior of the driver, as we are setting the physical line state purely depending on the reset-gpio-active-high property presence, not the logical line state, which would take into account the polarity specified in the DT gpio descriptor. I guess the right API call here would be gpiod_set_raw_value_cansleep(). Regards, Lucas