Received: by 10.223.185.116 with SMTP id b49csp2557150wrg; Thu, 15 Feb 2018 13:35:46 -0800 (PST) X-Google-Smtp-Source: AH8x225CKKLRuSqyWMe0BUJuukBIH52EGOjYkwOp2IqJpQf1hZA8ANxXeullS8sjZHOIpURctf17 X-Received: by 10.101.81.4 with SMTP id f4mr3452247pgq.30.1518730546033; Thu, 15 Feb 2018 13:35:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518730545; cv=none; d=google.com; s=arc-20160816; b=0c2paq4Wpnj16WQ7FFo0luCaGg+am1n3jXkgnKtWsIVLSuv5HVE3NwZy+IdHEZB3mj mjobZc206WKgaWQ3out685lCe6Y9u73A1zZU/mb7I/CRaGNsZoJL8PUcEd0pRM5Srsfr NPMqc/WHgSyL9B9iItJcS6e498nJQbawHKt62aDw6bxc//8Tig/e5hUSQB0irExKqhI7 lWXvLKQ0wbQUrUfkHjHPKcy9v8KRUVW8zjfy1TWI919/nMa+1Sn6WvkdrOy4FcOoKtWK Ug0cnnNzAeTrGZmvlOW4EZRttLMoqXIDf0zwr67BhGgtE/cvomHDGMb1gKULWC4IWYnL w43Q== 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=9LbTazXK7tGdWO8CQKdFl9WeAXc8VNu2aQGxl9Cc3NY=; b=pSXcv1SyojWAKyDi+mlGaZFcUlavXZPR6Vjcggbf/xgot/gV3bkILfCLPxoEGCFtBC Ar0TdSoDB7gQfkmXSh5PzEsptHxYLYPep8jD8DV82dvpQuqFY00UUY94em5SIg6FEL1D 2/6wo6vnaLge2NMrpW1kRJPv3jAIvNyg8I1PD1sSEmasWmNUdOPyrU1Te5W5XGj57G3j juWP2wGLQ73a+jSnDkpAncFOe5BZjFxF6+cJYN9LvQangkKdQIg271L9Tc70HmXFEH5D V7MqdXZJi/1kgSaDzr24h+930nClCt/HMG9AHSw4rL7Lgye2Xu4uX6L9yG/iWVGcqCwF T4hQ== 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 u85si130988pfi.5.2018.02.15.13.35.31; Thu, 15 Feb 2018 13:35:45 -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 S1163940AbeBOP27 (ORCPT + 99 others); Thu, 15 Feb 2018 10:28:59 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:54220 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1163926AbeBOP24 (ORCPT ); Thu, 15 Feb 2018 10:28:56 -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 40D37BD1; Thu, 15 Feb 2018 15:28:55 +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.9 77/88] pinctrl: intel: Initialize GPIO properly when used through irqchip Date: Thu, 15 Feb 2018 16:17:44 +0100 Message-Id: <20180215151233.118734437@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180215151222.437136975@linuxfoundation.org> References: <20180215151222.437136975@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.9-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 @@ -368,6 +368,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) @@ -375,7 +387,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); @@ -385,13 +396,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); @@ -770,6 +775,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);