Received: by 10.223.185.116 with SMTP id b49csp2203955wrg; Thu, 15 Feb 2018 08:04:07 -0800 (PST) X-Google-Smtp-Source: AH8x225WwGEFE8pVJPGkCb9blYq74FuxXq6OJ9zKC3z5dk0L/pfvtzAKFt7ql1xdConVyrOG7pY8 X-Received: by 10.98.197.68 with SMTP id j65mr3049462pfg.93.1518710646935; Thu, 15 Feb 2018 08:04:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518710646; cv=none; d=google.com; s=arc-20160816; b=SuW/gqcUBGg4E9qHV9mPdY60MQmJiaMaAzDPCiHErNYjxZhEoAQOm1YIsN/CoxQZ/e fZjVIjqFvdaXzIv+ahpsoRySpC7JPdXWZk0Z55kr5bmSNl2pNVNpUHgwD2JVmQFMNOz8 34oqycDjZfuBWYt74XzAjdwdZP0wo44iZDnQSG9nPBz841m7JoJz4gEh/ehlTQAo3B5E Uo9roGp871nnHeKyFXB65gecYlB9nmnFur493Tmb7DpaAzyKwcSQylop/byYx4vdeVNl taQ+B9RIowXkPCVP6YkRIzANgQfG777/A9vXqzeNS2wkYnI47WumgYW+eB7QxOY/zczf qJHQ== 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=Fdws4QecFU4x8BsM4OIMk31zMYtiGoQojj7SlkbZCas=; b=GnYGAeg+DugzzqQpHwCVAJUzxZwFJfbG6VqNG7oJtWs6W8WnwM3YdMERIV59E1xxm7 21qwADciWfgIx7/T585A2q7SfFZNZJdHIzRP46on6mA0Vp2PJdLks7uM9bO4Jlyqtuny gO4RRlz4RvjKtiOrqOEFF5FfnHCyEqaEAIVlJMWC0vd6rH0dR9E948TzuyPOqJkuIeO5 s+RXuZTyzgntutTh6T1EK4CxSGxGcY/f4WNbWhAppk50nMe4ec5XEGJQl+iYgyoFl/Ql TZ3q0aaVxpkMsavj9ZgQn44oyWCmhlQdX0vFsylVgikOn9Eb6aBfJ8fVzIXw+klQHuVi m0ng== 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 n7si2688615pgv.705.2018.02.15.08.03.51; Thu, 15 Feb 2018 08:04:06 -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 S1424716AbeBOPqn (ORCPT + 99 others); Thu, 15 Feb 2018 10:46:43 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:35878 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1424702AbeBOPqk (ORCPT ); Thu, 15 Feb 2018 10:46:40 -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 9DBE1FBE; Thu, 15 Feb 2018 15:46:39 +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.15 176/202] pinctrl: intel: Initialize GPIO properly when used through irqchip Date: Thu, 15 Feb 2018 16:17:56 +0100 Message-Id: <20180215151722.080763452@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180215151712.768794354@linuxfoundation.org> References: <20180215151712.768794354@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.15-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 @@ -425,6 +425,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) @@ -432,7 +444,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); @@ -442,13 +453,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);