Received: by 10.223.185.116 with SMTP id b49csp3905864wrg; Tue, 6 Mar 2018 06:57:47 -0800 (PST) X-Google-Smtp-Source: AG47ELt+m4hRDgRMqMavYMcTZw/DpTGZVExZEogpztIQ0Cy5yvAo0zVX5op2g3pC8JEvPkq1z37E X-Received: by 2002:a17:902:7889:: with SMTP id q9-v6mr17377742pll.218.1520348266756; Tue, 06 Mar 2018 06:57:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520348266; cv=none; d=google.com; s=arc-20160816; b=oQyM6TMBU2r6OnotphxSTMTnl30ejNgsqG9/APW+nd0i2S/wsnbplQnJHaSMxiO5K3 uEchdldglGD4QmV9DkS1p++anNOcc2aS5KF19tQkyfh+38Y/e0UduOf1dHC2tb/LW3V8 s1ZKxH7Q2WnsV1HSyV7XTdSrOo7INpzV27l/+RZunmeUFfDjflP0LOxtEzql2Duwld25 7OBCwpocz94jQiS8O+pOWlGBiqb/fZPBQ4/M8hPrsc4An9IsP0oaNrSMgIt3yyNVk+C2 w8CqXLAoRagPpMUnTps3+ZjvjASc8PdKIOcIdTWje8qvGK9Ri2Adhkpwz1b4/AcKw1TJ ihsw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :organization:references:in-reply-to:date:cc:to:from:subject :message-id:arc-authentication-results; bh=T35nVONPScqtG2P7i8MSYyTA0hodZ9L2U6P8f6umJfw=; b=GCbgyCAZlYOIVALPPYhKRCcU15o05OB4f8OTXUdyKQzIy9SJUVaVJdxfqOgUuwnzix TMyegUZ+FMNzOIYuVTXJaO5R+nA6ZNTzTG6Lu85euCVj4BcTqickSkwmcMXHfZpomLit qb2VMdQGUydx/fI2Sp2TK1q4o9UFxJVgwbSIt/k2MD4FgW1Xs2AMYCjIU8us/BGsSPFD lbfOdRSBcXY9JbRUdTPT4SlpJOQ4Ur5fY+3PMOeH/kw9X1296nQpSCdWFBboxHLyCYZ4 QeJcbNb/FrLSv+F0OJjdmzicV+GDENI/3SxynFlGwUid479YzC05g8q+OBVZYzliU0w2 6fZw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y67si12156665pfd.195.2018.03.06.06.57.32; Tue, 06 Mar 2018 06:57:46 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932963AbeCFO4N (ORCPT + 99 others); Tue, 6 Mar 2018 09:56:13 -0500 Received: from mga09.intel.com ([134.134.136.24]:21347 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932448AbeCFO4J (ORCPT ); Tue, 6 Mar 2018 09:56:09 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 Mar 2018 06:56:08 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.47,431,1515484800"; d="scan'208";a="35033616" Received: from smile.fi.intel.com (HELO smile) ([10.237.72.86]) by fmsmga004.fm.intel.com with ESMTP; 06 Mar 2018 06:56:06 -0800 Message-ID: <1520348165.10722.438.camel@linux.intel.com> Subject: Re: [PATCH] pinctrl: intel: Implement intel_gpio_get_direction callback From: Andy Shevchenko To: Javier Arteaga , Mika Westerberg Cc: Heikki Krogerus , Linus Walleij , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org Date: Tue, 06 Mar 2018 16:56:05 +0200 In-Reply-To: <3585081b-70af-5c31-08c0-84e96b6055bc@emutex.com> References: <20180306134213.16898-1-javier@emutex.com> <3585081b-70af-5c31-08c0-84e96b6055bc@emutex.com> Organization: Intel Finland Oy Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.26.5-1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 2018-03-06 at 14:31 +0000, Javier Arteaga wrote: > (Fix Andy's Cc: - apologies) > > On 06/03/2018 13:42, Javier Arteaga wrote: > > Allows querying GPIO direction from the pad config register. > > If the pad is not in GPIO mode, return an error. > > > > Signed-off-by: Javier Arteaga > > --- > > This is needed by the drivers for the UP Squared board, an APL-based > > platform. (For now, these drivers are out-of-tree.) > > > > An earlier version of this patch was reviewed some time ago by Andy > > Shevchenko outside of the mailing lists: > > > > Yes, this one look good! Reviewed-by: Andy Shevchenko > > drivers/pinctrl/intel/pinctrl-intel.c | 19 +++++++++++++++++++ > > 1 file changed, 19 insertions(+) > > > > diff --git a/drivers/pinctrl/intel/pinctrl-intel.c > > b/drivers/pinctrl/intel/pinctrl-intel.c > > index 96e73e30204e..1e24a6b8a64e 100644 > > --- a/drivers/pinctrl/intel/pinctrl-intel.c > > +++ b/drivers/pinctrl/intel/pinctrl-intel.c > > @@ -788,6 +788,24 @@ static void intel_gpio_set(struct gpio_chip > > *chip, unsigned offset, int value) > > raw_spin_unlock_irqrestore(&pctrl->lock, flags); > > } > > > > +static int intel_gpio_get_direction(struct gpio_chip *chip, > > unsigned int offset) > > +{ > > + struct intel_pinctrl *pctrl = gpiochip_get_data(chip); > > + void __iomem *reg; > > + u32 padcfg0; > > + > > + reg = intel_get_padcfg(pctrl, offset, PADCFG0); > > + if (!reg) > > + return -EINVAL; > > + > > + padcfg0 = readl(reg); > > + > > + if (padcfg0 & PADCFG0_PMODE_MASK) > > + return -EINVAL; Actually we might return direction of GPIO function while pin is in some other mode, though it would probably make not much sense in practice. > > + > > + return !!(padcfg0 & PADCFG0_GPIOTXDIS); > > +} > > + > > static int intel_gpio_direction_input(struct gpio_chip *chip, > > unsigned offset) > > { > > return pinctrl_gpio_direction_input(chip->base + offset); > > @@ -804,6 +822,7 @@ static const struct gpio_chip intel_gpio_chip = > > { > > .owner = THIS_MODULE, > > .request = gpiochip_generic_request, > > .free = gpiochip_generic_free, > > + .get_direction = intel_gpio_get_direction, > > .direction_input = intel_gpio_direction_input, > > .direction_output = intel_gpio_direction_output, > > .get = intel_gpio_get, > > -- Andy Shevchenko Intel Finland Oy