Received: by 10.223.185.116 with SMTP id b49csp3879438wrg; Tue, 6 Mar 2018 06:33:05 -0800 (PST) X-Google-Smtp-Source: AG47ELu7qwQ7Ktw2Vjky3f2TSlxaYD/is+SqsQB1kIKVjGNmbqeRPgTZ7bDcP4fCiQYvhJY8Yg2F X-Received: by 2002:a17:902:7843:: with SMTP id e3-v6mr1372686pln.83.1520346785651; Tue, 06 Mar 2018 06:33:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520346785; cv=none; d=google.com; s=arc-20160816; b=aS8j7+FZGLNCimv4Xmmalj1O3Pu5PXwnJZL3xeiV9CLBBbnTYpkuSLuoYJ0HFdt6nq pT391oRS1QIySD1SoNPQPhRUYx61krxRlQn4jIKapyfMaHeyK7GY2/QkgBa7Ek8bkqub 40GD3o0DMmMwQU+aIqqgsT37gvrFeoWxPoLf/o91z4Zy/dMpKy7ao2M2J2huoVMLuHg/ icd4Oiyva3PyzzhcFFWw7q0KcMGQXJ3hqKUHP90BG+XNDREe/DTdAyt6Xquycb8VIuW+ 3oZmipiBSreiDFxP0OczvDnbcRudNPeIOxeNfCXwxEt7SpNHohTaz+MYS8sxHSS2igGL D9eg== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=L0qtdi22obdxzwsMmNbhcSLk+2Vmm9NVi32nSNpW4Rs=; b=PFq/1C5RGAUtL9RSFgV+9jkZ4zLI/aXfshKpOb2ob4l6VDIlJcc15g6wbDep2jTlgM 3fCTRynJJ1WOTjrEMLHqvcQ3HsKhDjKFzVUGTGVDc6c4OxYWyiWUl+aTjNi5MTKa5t2B 1Ff4qmmEr9SxR2P+a4sEi2ejLEUexZGGdwP8sJFz54fXnqYPWWvwe0dJ254Or//y2ia4 Rhe7k6ZqVlrFF3lF6sr3PXhbhX5DcuAl99pO6XdMcx07WYRgg5V8Xc2RwJvredaWA/Lv XN6rjKuS+gFOaMR3PtmJVd5ML68D2khYn9Zk5SlJ5MqR1gcTLZph8VWyg9H3zvWRSSej BmhQ== 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 b34-v6si11265542plc.439.2018.03.06.06.32.51; Tue, 06 Mar 2018 06:33:05 -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 S1753789AbeCFOb1 (ORCPT + 99 others); Tue, 6 Mar 2018 09:31:27 -0500 Received: from bert.emutex.com ([91.103.1.109]:48169 "EHLO bert.emutex.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753223AbeCFObZ (ORCPT ); Tue, 6 Mar 2018 09:31:25 -0500 Received: from [92.51.199.138] (helo=statler.emutex.com) by bert.emutex.com with esmtp (Exim 4.84) (envelope-from ) id 1etDdE-00011f-3A; Tue, 06 Mar 2018 14:31:56 +0000 Received: from [10.10.64.90] by statler.emutex.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84) (envelope-from ) id 1etDcg-00051I-Iu; Tue, 06 Mar 2018 14:31:23 +0000 Subject: Re: [PATCH] pinctrl: intel: Implement intel_gpio_get_direction callback To: Mika Westerberg Cc: Heikki Krogerus , Linus Walleij , Andy Shevchenko , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org References: <20180306134213.16898-1-javier@emutex.com> From: Javier Arteaga Message-ID: <3585081b-70af-5c31-08c0-84e96b6055bc@emutex.com> Date: Tue, 6 Mar 2018 14:31:20 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:59.0) Gecko/20100101 Thunderbird/59.0 MIME-Version: 1.0 In-Reply-To: <20180306134213.16898-1-javier@emutex.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Score: -1.0 (-) X-Spam-Report: Spam detection software, running on the system "statler.emutex.com", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: (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: > > > 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; > + > + 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, > [...] Content analysis details: (-1.0 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org (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: > > > 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; > + > + 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, >