Received: by 10.223.185.116 with SMTP id b49csp2175081wrg; Thu, 15 Feb 2018 07:38:48 -0800 (PST) X-Google-Smtp-Source: AH8x2257fdtDh6BCDs/nIWGxK8lgFJRn+N0ksTsYaUcrarSWZyTQIjsWlsyPsU4gn9ctMizENBYZ X-Received: by 10.98.78.148 with SMTP id c142mr2978637pfb.153.1518709128031; Thu, 15 Feb 2018 07:38:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518709127; cv=none; d=google.com; s=arc-20160816; b=FUHQEaPaGKGdD0JFBedaTPHukiu3ThWjo9gZrnPWyWQ88ZDYpdg2SWaSsg/WP1Qoqf roGLAAoq7xKwgL2Cs+Q6nrZjyYx4SCtzWEvCRKtKTXPrxl8iGd6Zl0OY0VJehSUk9aae 2zKyvGGrsj1bfLGl5Z6Ne8ng33nkZtMF5EcS46yMPWribweCMbjGXesGTKJAoFJH6MJo mdT9eI7l9iebTOjhrvtMbWPOi5j4G6TQ3aKlzVBq6u/SEMpPS4GwdWLALAFjy2EpiWyn SkWqrUmZlLTmYJ02O9k238/a8arEu7xKeqmXlhDRDeeaAyQjHJ/bW0v6XRZfdcnwt6jH jqZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=pvQkkWCzCXcrFjdcxq947znp9n9+4zxZ+7327LtJQLk=; b=MT5SSW8JympDwVhExZrsysvBPqM7DVPetUCgESW+FmES/omqmnMGnCOoUb6D8fV9Jg bLuylCioblwN1xKM+yXIf9UaM8eqolC4Z4dXSAGUMgdF5js0v4lYLP7IuqbVvFP7mUd8 t+o0QG7wMPnVBJqRXYkqRx0P44Sf+w7aUtWLM9Q44nlrvvwRuQKmIXTZyp6C3ToF9zXU M7s+MfAQFxxo4hsiDXGG0zn3M2dFdkGKpKkOJ90RtuA+DQAF8V1BnlSRNcvRj7NJA2ZN 1zPjKRvB0dhw5iqLiHE/tMjBtvPwIiNzqWYpvzXZ3xLjQLn0LYR5k8Ig+IIQoTrwF6sr I0KA== 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 e6-v6si1791726plt.123.2018.02.15.07.38.33; Thu, 15 Feb 2018 07:38:47 -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 S1423106AbeBOPhY (ORCPT + 99 others); Thu, 15 Feb 2018 10:37:24 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:58950 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1422694AbeBOPhV (ORCPT ); Thu, 15 Feb 2018 10:37:21 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 0EB60104C; Thu, 15 Feb 2018 15:37:20 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Daniel Drake , Mika Westerberg , Linus Walleij Subject: [PATCH 4.14 171/195] pinctrl: intel: Initialize GPIO properly when used through irqchip Date: Thu, 15 Feb 2018 16:17:42 +0100 Message-Id: <20180215151714.605266810@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180215151705.738773577@linuxfoundation.org> References: <20180215151705.738773577@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Mika Westerberg commit f5a26acf0162477af6ee4c11b4fb9cffe5d3e257 upstream. When a GPIO is requested using gpiod_get_* APIs the intel pinctrl driver switches the pin to GPIO mode and makes sure interrupts are routed to the GPIO hardware instead of IOAPIC. However, if the GPIO is used directly through irqchip, as is the case with many I2C-HID devices where I2C core automatically configures interrupt for the device, the pin is not initialized as GPIO. Instead we rely that the BIOS configures the pin accordingly which seems not to be the case at least in Asus X540NA SKU3 with Focaltech touchpad. When the pin is not properly configured it might result weird behaviour like interrupts suddenly stop firing completely and the touchpad stops responding to user input. Fix this by properly initializing the pin to GPIO mode also when it is used directly through irqchip. Fixes: 7981c0015af2 ("pinctrl: intel: Add Intel Sunrisepoint pin controller and GPIO support") Reported-by: Daniel Drake Reported-and-tested-by: Chris Chiu Signed-off-by: Mika Westerberg Signed-off-by: Linus Walleij Signed-off-by: Greg Kroah-Hartman --- drivers/pinctrl/intel/pinctrl-intel.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) --- a/drivers/pinctrl/intel/pinctrl-intel.c +++ b/drivers/pinctrl/intel/pinctrl-intel.c @@ -427,6 +427,18 @@ static void __intel_gpio_set_direction(v writel(value, padcfg0); } +static void intel_gpio_set_gpio_mode(void __iomem *padcfg0) +{ + u32 value; + + /* Put the pad into GPIO mode */ + value = readl(padcfg0) & ~PADCFG0_PMODE_MASK; + /* Disable SCI/SMI/NMI generation */ + value &= ~(PADCFG0_GPIROUTIOXAPIC | PADCFG0_GPIROUTSCI); + value &= ~(PADCFG0_GPIROUTSMI | PADCFG0_GPIROUTNMI); + writel(value, padcfg0); +} + static int intel_gpio_request_enable(struct pinctrl_dev *pctldev, struct pinctrl_gpio_range *range, unsigned pin) @@ -434,7 +446,6 @@ static int intel_gpio_request_enable(str struct intel_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev); void __iomem *padcfg0; unsigned long flags; - u32 value; raw_spin_lock_irqsave(&pctrl->lock, flags); @@ -444,13 +455,7 @@ static int intel_gpio_request_enable(str } padcfg0 = intel_get_padcfg(pctrl, pin, PADCFG0); - /* Put the pad into GPIO mode */ - value = readl(padcfg0) & ~PADCFG0_PMODE_MASK; - /* Disable SCI/SMI/NMI generation */ - value &= ~(PADCFG0_GPIROUTIOXAPIC | PADCFG0_GPIROUTSCI); - value &= ~(PADCFG0_GPIROUTSMI | PADCFG0_GPIROUTNMI); - writel(value, padcfg0); - + intel_gpio_set_gpio_mode(padcfg0); /* Disable TX buffer and enable RX (this will be input) */ __intel_gpio_set_direction(padcfg0, true); @@ -935,6 +940,8 @@ static int intel_gpio_irq_type(struct ir raw_spin_lock_irqsave(&pctrl->lock, flags); + intel_gpio_set_gpio_mode(reg); + value = readl(reg); value &= ~(PADCFG0_RXEVCFG_MASK | PADCFG0_RXINV);