linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alexandre TORGUE <alexandre.torgue@st.com>
To: Linus Walleij <linus.walleij@linaro.org>,
	Maxime Coquelin <mcoquelin.stm32@gmail.com>,
	Patrice Chotard <patrice.chotard@st.com>,
	Paul Gortmaker <paul.gortmaker@windriver.com>,
	Rob Herring <robh+dt@kernel.org>
Cc: <linux-kernel@vger.kernel.org>, <linux-gpio@vger.kernel.org>,
	<linux-arm-kernel@lists.infradead.org>,
	<devicetree@vger.kernel.org>
Subject: [PATCH 1/4] pinctrl: stm32: set pin to gpio input when used as interrupt
Date: Fri, 7 Apr 2017 17:10:08 +0200	[thread overview]
Message-ID: <1491577811-26989-2-git-send-email-alexandre.torgue@st.com> (raw)
In-Reply-To: <1491577811-26989-1-git-send-email-alexandre.torgue@st.com>

This patch ensures that pin is correctly set as gpio input when it is used
as an interrupt.

Signed-off-by: Alexandre TORGUE <alexandre.torgue@st.com>

diff --git a/drivers/pinctrl/stm32/pinctrl-stm32.c b/drivers/pinctrl/stm32/pinctrl-stm32.c
index abc405b..c8825e5 100644
--- a/drivers/pinctrl/stm32/pinctrl-stm32.c
+++ b/drivers/pinctrl/stm32/pinctrl-stm32.c
@@ -207,12 +207,35 @@ static int stm32_gpio_to_irq(struct gpio_chip *chip, unsigned int offset)
 	.to_irq			= stm32_gpio_to_irq,
 };
 
+static int stm32_gpio_irq_request_resources(struct irq_data *irq_data)
+{
+	struct stm32_gpio_bank *bank = irq_data->domain->host_data;
+	u32 ret;
+
+	if (!gpiochip_is_requested(&bank->gpio_chip, irq_data->hwirq)) {
+		ret = stm32_gpio_request(&bank->gpio_chip, irq_data->hwirq);
+		if (ret)
+			return ret;
+	}
+
+	return stm32_gpio_direction_input(&bank->gpio_chip, irq_data->hwirq);
+}
+
+static void stm32_gpio_irq_release_resources(struct irq_data *irq_data)
+{
+	struct stm32_gpio_bank *bank = irq_data->domain->host_data;
+
+	stm32_gpio_free(&bank->gpio_chip, irq_data->hwirq);
+}
+
 static struct irq_chip stm32_gpio_irq_chip = {
 	.name           = "stm32gpio",
 	.irq_eoi	= irq_chip_eoi_parent,
 	.irq_mask       = irq_chip_mask_parent,
 	.irq_unmask     = irq_chip_unmask_parent,
 	.irq_set_type   = irq_chip_set_type_parent,
+	.irq_request_resources = stm32_gpio_irq_request_resources,
+	.irq_release_resources = stm32_gpio_irq_release_resources,
 };
 
 static int stm32_gpio_domain_translate(struct irq_domain *d,
-- 
1.9.1

  reply	other threads:[~2017-04-07 15:11 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-07 15:10 [PATCH 0/4] Add fixes to STM32 pintrl Alexandre TORGUE
2017-04-07 15:10 ` Alexandre TORGUE [this message]
2017-04-24 12:36   ` [PATCH 1/4] pinctrl: stm32: set pin to gpio input when used as interrupt Linus Walleij
2017-04-24 16:40     ` Alexandre Torgue
2017-04-07 15:10 ` [PATCH 2/4] pinctrl: stm32: replace device_initcall() with arch_initcall() Alexandre TORGUE
2017-04-24 12:22   ` Linus Walleij
2017-04-07 15:10 ` [PATCH 3/4] pinctrl: stm32: Implement .get_direction gpio_chip callback Alexandre TORGUE
2017-04-24 12:37   ` Linus Walleij
2017-04-24 16:07     ` Alexandre Torgue
2017-04-07 15:10 ` [PATCH 4/4] ARM: dts: stm32: Set gpio controller also as interrupt controller Alexandre TORGUE
2017-04-24 12:38   ` 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=1491577811-26989-2-git-send-email-alexandre.torgue@st.com \
    --to=alexandre.torgue@st.com \
    --cc=devicetree@vger.kernel.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mcoquelin.stm32@gmail.com \
    --cc=patrice.chotard@st.com \
    --cc=paul.gortmaker@windriver.com \
    --cc=robh+dt@kernel.org \
    /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).