linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mika Westerberg <mika.westerberg@linux.intel.com>
To: Linus Walleij <linus.walleij@linaro.org>
Cc: Marc Zyngier <marc.zyngier@arm.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Phidias Chiang <phidias.chiang@canonical.com>,
	Anisse Astier <anisse@astier.eu>,
	Heikki Krogerus <heikki.krogerus@linux.intel.com>,
	Yu C Chen <yu.c.chen@intel.com>,
	Mika Westerberg <mika.westerberg@linux.intel.com>,
	linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 2/2] pinctrl: cherryview: Do not add all southwest and north GPIOs to IRQ domain
Date: Thu, 15 Sep 2016 18:52:10 +0300	[thread overview]
Message-ID: <20160915155210.94413-2-mika.westerberg@linux.intel.com> (raw)
In-Reply-To: <20160915155210.94413-1-mika.westerberg@linux.intel.com>

It turns out that for north and southwest communities, they can only
generate GPIO interrupts for lower 8 interrupts (IntSel value). The upper
part (8-15) can only generate GPEs (General Purpose Events).

Now the reason why EC events such as pressing hotkeys does not work if we
mask all the interrupts is that in order to generate either interrupts or
GPEs the INTMASK register must have that particular interrupt unmasked. In
case of GPEs the CPU does not trigger normal interrupt (and thus the GPIO
driver does not see it) but instead it causes SCI (System Control
Interrupt) to be triggered with the GPE in question set.

To make this all work as expected we only add those GPIOs to the IRQ domain
that can actually generate interrupts (IntSel value 0-7) and skip others.

Reported-by: Phidias Chiang <phidias.chiang@canonical.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
---
Hi Phidias and Anisse,

Can you try this series out? It should finally fix the EC event issue(s)
you have reported.

 drivers/pinctrl/intel/pinctrl-cherryview.c | 31 ++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/drivers/pinctrl/intel/pinctrl-cherryview.c b/drivers/pinctrl/intel/pinctrl-cherryview.c
index 0fe8fad25e4d..717ef1b00adb 100644
--- a/drivers/pinctrl/intel/pinctrl-cherryview.c
+++ b/drivers/pinctrl/intel/pinctrl-cherryview.c
@@ -134,6 +134,7 @@ struct chv_gpio_pinrange {
  * @gpio_ranges: An array of GPIO ranges in this community
  * @ngpio_ranges: Number of GPIO ranges
  * @ngpios: Total number of GPIOs in this community
+ * @nirqs: Total number of IRQs this community can generate
  */
 struct chv_community {
 	const char *uid;
@@ -146,6 +147,7 @@ struct chv_community {
 	const struct chv_gpio_pinrange *gpio_ranges;
 	size_t ngpio_ranges;
 	size_t ngpios;
+	size_t nirqs;
 };
 
 struct chv_pin_context {
@@ -396,6 +398,12 @@ static const struct chv_community southwest_community = {
 	.gpio_ranges = southwest_gpio_ranges,
 	.ngpio_ranges = ARRAY_SIZE(southwest_gpio_ranges),
 	.ngpios = ARRAY_SIZE(southwest_pins),
+	/*
+	 * Southwest community can benerate GPIO interrupts only for the
+	 * first 8 interrupts. The upper half (8-15) can only be used to
+	 * trigger GPEs.
+	 */
+	.nirqs = 8,
 };
 
 static const struct pinctrl_pin_desc north_pins[] = {
@@ -479,6 +487,12 @@ static const struct chv_community north_community = {
 	.gpio_ranges = north_gpio_ranges,
 	.ngpio_ranges = ARRAY_SIZE(north_gpio_ranges),
 	.ngpios = ARRAY_SIZE(north_pins),
+	/*
+	 * North community can benerate GPIO interrupts only for the first
+	 * 8 interrupts. The upper half (8-15) can only be used to trigger
+	 * GPEs.
+	 */
+	.nirqs = 8,
 };
 
 static const struct pinctrl_pin_desc east_pins[] = {
@@ -521,6 +535,7 @@ static const struct chv_community east_community = {
 	.gpio_ranges = east_gpio_ranges,
 	.ngpio_ranges = ARRAY_SIZE(east_gpio_ranges),
 	.ngpios = ARRAY_SIZE(east_pins),
+	.nirqs = 16,
 };
 
 static const struct pinctrl_pin_desc southeast_pins[] = {
@@ -646,6 +661,7 @@ static const struct chv_community southeast_community = {
 	.gpio_ranges = southeast_gpio_ranges,
 	.ngpio_ranges = ARRAY_SIZE(southeast_gpio_ranges),
 	.ngpios = ARRAY_SIZE(southeast_pins),
+	.nirqs = 16,
 };
 
 static const struct chv_community *chv_communities[] = {
@@ -1539,6 +1555,21 @@ static int chv_gpio_probe(struct chv_pinctrl *pctrl, int irq)
 		offset += range->npins;
 	}
 
+	/* Do not add GPIOs that can only generate GPEs to the IRQ domain */
+	for (i = 0; i < pctrl->community->npins; i++) {
+		const struct pinctrl_pin_desc *desc;
+		u32 intsel;
+
+		desc = &pctrl->community->pins[i];
+
+		intsel = readl(chv_padreg(pctrl, desc->number, CHV_PADCTRL0));
+		intsel &= CHV_PADCTRL0_INTSEL_MASK;
+		intsel >>= CHV_PADCTRL0_INTSEL_SHIFT;
+
+		if (intsel >= pctrl->community->nirqs)
+			clear_bit(i, chip->valid_mask);
+	}
+
 	/* Clear all interrupts */
 	chv_writel(0xffff, pctrl->regs + CHV_INTSTAT);
 
-- 
2.9.3


  reply	other threads:[~2016-09-15 15:52 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-22  7:56 [PATCH] pinctrl: cherryview: Do not mask all interrupts on probe Mika Westerberg
2015-06-01  9:23 ` Mika Westerberg
2015-06-02 13:53   ` Linus Walleij
2015-06-02 14:15     ` Mika Westerberg
2015-07-29  8:51       ` João Paulo Rechi Vita
2016-08-16 16:12       ` Anisse Astier
2016-08-17  8:13         ` Mika Westerberg
2016-08-17 13:42           ` Anisse Astier
2016-08-18 12:13             ` Mika Westerberg
2016-08-18 13:52               ` Anisse Astier
2016-08-18 13:58                 ` Mika Westerberg
2016-09-08 10:13                   ` Phidias Chiang
2016-09-08 10:24                     ` Mika Westerberg
2016-09-08 16:28                       ` Phidias Chiang
2016-09-09  6:18                         ` Mika Westerberg
2016-09-09  8:23                           ` Phidias Chiang
2016-09-09  8:58                             ` Mika Westerberg
2016-09-11  8:05                               ` Mika Westerberg
2016-09-12  6:56                                 ` Phidias Chiang
2016-09-12  9:04                                   ` Mika Westerberg
2016-09-12 13:04                                     ` Phidias Chiang
2016-09-12 13:11                                       ` Mika Westerberg
2016-09-13  9:18                                         ` Linus Walleij
2016-09-13  9:33                                           ` Mika Westerberg
2016-09-13 12:22                                             ` Linus Walleij
2016-09-13 12:52                                               ` Mika Westerberg
2016-09-13 20:57                                                 ` Linus Walleij
2016-09-14  8:26                                                   ` Mika Westerberg
2016-09-14 12:46                                                     ` Linus Walleij
2016-09-14 15:12                                                       ` Mika Westerberg
2016-09-15 12:39                                                         ` Linus Walleij
2016-09-15 15:42                                                           ` Mika Westerberg
2016-09-15 15:52                                                           ` [PATCH 1/2] gpiolib: Add possibility to mask which GPIOs are added to IRQ domain Mika Westerberg
2016-09-15 15:52                                                             ` Mika Westerberg [this message]
2016-09-15 16:07                                                             ` Marc Zyngier
2016-09-15 18:12                                                               ` Mika Westerberg
2016-09-15 18:50                                                                 ` Thomas Gleixner
2016-09-18 11:16                                                             ` Linus Walleij

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160915155210.94413-2-mika.westerberg@linux.intel.com \
    --to=mika.westerberg@linux.intel.com \
    --cc=anisse@astier.eu \
    --cc=heikki.krogerus@linux.intel.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marc.zyngier@arm.com \
    --cc=phidias.chiang@canonical.com \
    --cc=tglx@linutronix.de \
    --cc=yu.c.chen@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).