Received: by 10.223.185.116 with SMTP id b49csp3861673wrg; Tue, 6 Mar 2018 06:17:00 -0800 (PST) X-Google-Smtp-Source: AG47ELvtoKd7+KyGJAIemX3zLoZHiuxxHo+WHjQ1NOMrYxDmd9hb87KMpEB/z7dhBxHVf2RbZshC X-Received: by 10.101.97.207 with SMTP id j15mr15029485pgv.266.1520345820172; Tue, 06 Mar 2018 06:17:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520345820; cv=none; d=google.com; s=arc-20160816; b=alYdNv0TrHChY7bA3Hsy/UnzV7mdTM9eEB3q9XnHCzKDe8fHODiLXwjpxdrP60hkTs L/GqJw3DD0J+Pmhw7yqv3UL97rhH4xG62Xv1PITtZRR0Xg5XADZ2NNDLxC3uVDfIDBqo 14NXCEqJ1bJLsxmR7YrTugIdqruJJMLEkI9IKaBeAXPX/S9j1QpWJC//OQiU3GYs3etm IHWELXJJwHw9/2cYMV+8R7xCgrLbKFgM+lEFN3A0hHd8rM1qBbQhrrynH42G6G1ppoD5 kIONtc+22yjsYivR7ueHHr0EHrAYPsv1/1HDB+JsyecnnVpwREZ+qNzQAY1SNAdnWkhR f8TA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=7iVDcLLiP7qtbpyJ+Tg9MlUU716aOqkg/i4wCH19+8Y=; b=a7Xm68jlDT1qYSEX9S4KJczRQF5uSeMgVLS5dKJ3/12RQLMYNxoYwYxe3KU3u8aZjn G19UM+LwcNBxQwn/XyvmkhKlTkwrdwUM4T/RLVA7kCI6sHLzxCBrLAQmNsnt5DF0VLS0 H2aZ6JomUSWnSNliOHmwzuYkaC3FxDg0m4FPBcppcs2Czb/8KPgHYeJ8VYFbBo1A51hH 8elsW31lIwKG3GmTLIdiAP5eQkgaK5CGqqdv52QmYPG0ERhNDuKKTN4gwX527B9Bsvu4 1NAY9GHmemmrxo/1VjV1lijhtMss6N9EQroEV1Pmp9qCukqIgYycKc4cVzHPhFFC//nO LLGw== 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 31-v6si11182486plj.86.2018.03.06.06.16.45; Tue, 06 Mar 2018 06:17:00 -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 S1753512AbeCFOPp (ORCPT + 99 others); Tue, 6 Mar 2018 09:15:45 -0500 Received: from bert.emutex.com ([91.103.1.109]:48165 "EHLO bert.emutex.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750817AbeCFOPn (ORCPT ); Tue, 6 Mar 2018 09:15:43 -0500 X-Greylist: delayed 1969 seconds by postgrey-1.27 at vger.kernel.org; Tue, 06 Mar 2018 09:15:43 EST Received: from [92.51.199.138] (helo=statler.emutex.com) by bert.emutex.com with esmtp (Exim 4.84) (envelope-from ) id 1etCsH-0000zf-Py; Tue, 06 Mar 2018 13:43:25 +0000 Received: from [10.10.64.90] (helo=localhost) by statler.emutex.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84) (envelope-from ) id 1etCrj-0004tJ-KY; Tue, 06 Mar 2018 13:42:52 +0000 From: Javier Arteaga To: Mika Westerberg Cc: Heikki Krogerus , Linus Walleij , Andy Shevchenko , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Javier Arteaga Subject: [PATCH] pinctrl: intel: Implement intel_gpio_get_direction callback Date: Tue, 6 Mar 2018 13:42:13 +0000 Message-Id: <20180306134213.16898-1-javier@emutex.com> X-Mailer: git-send-email 2.16.2 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: 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.) [...] 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 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, -- 2.16.2