From: Janusz Krzysztofik <jmkrzyszt@gmail.com>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>,
Tony Lindgren <tony@atomide.com>,
Aaro Koskinen <aaro.koskinen@iki.fi>
Cc: "David S . Miller" <davem@davemloft.net>,
Mauro Carvalho Chehab <mchehab+samsung@kernel.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Andrew Morton <akpm@linux-foundation.org>,
Randy Dunlap <rdunlap@infradead.org>,
Liam Girdwood <lgirdwood@gmail.com>,
Mark Brown <broonie@kernel.org>,
Linus Walleij <linus.walleij@linaro.org>,
linux-arm-kernel@lists.infradead.org,
linux-input@vger.kernel.org, linux-omap@vger.kernel.org,
linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org,
Janusz Krzysztofik <jmkrzyszt@gmail.com>
Subject: [PATCH 07/10] ARM: OMAP1: ams-delta FIQ: Keep serio input GPIOs requested
Date: Sat, 9 Jun 2018 16:02:21 +0200 [thread overview]
Message-ID: <20180609140224.32606-7-jmkrzyszt@gmail.com> (raw)
In-Reply-To: <20180609140224.32606-1-jmkrzyszt@gmail.com>
>From the very beginning, input GPIO pins of ams-delta serio port have
been used by FIQ handler, not serio driver.
Don't request those pins from the ams-delta-serio driver any longer,
instead keep them requested and initialized by the FIQ initialization
routine which already requests them and releases while identifying GPIO
IRQs.
Signed-off-by: Janusz Krzysztofik <jmkrzyszt@gmail.com>
---
arch/arm/mach-omap1/ams-delta-fiq.c | 42 ++++++++++++++++++++++++++++++-----
drivers/input/serio/ams_delta_serio.c | 30 ++-----------------------
2 files changed, 39 insertions(+), 33 deletions(-)
diff --git a/arch/arm/mach-omap1/ams-delta-fiq.c b/arch/arm/mach-omap1/ams-delta-fiq.c
index 1d54a6177f14..5a6c59ac9b5f 100644
--- a/arch/arm/mach-omap1/ams-delta-fiq.c
+++ b/arch/arm/mach-omap1/ams-delta-fiq.c
@@ -45,6 +45,11 @@ static struct irq_chip *irq_chip;
static struct irq_data *irq_data[16];
static unsigned int irq_counter[16];
+static const char *pin_name[16] __initconst = {
+ [AMS_DELTA_GPIO_PIN_KEYBRD_DATA] = "keybrd_data",
+ [AMS_DELTA_GPIO_PIN_KEYBRD_CLK] = "keybrd_clk",
+};
+
static irqreturn_t deferred_fiq(int irq, void *dev_id)
{
struct irq_data *d;
@@ -80,7 +85,7 @@ static irqreturn_t deferred_fiq(int irq, void *dev_id)
void __init ams_delta_init_fiq(struct gpio_chip *chip)
{
- struct gpio_desc *gpiod;
+ struct gpio_desc *gpiod, *data = NULL, *clk = NULL;
void *fiqhandler_start;
unsigned int fiqhandler_length;
struct pt_regs FIQ_regs;
@@ -96,7 +101,7 @@ void __init ams_delta_init_fiq(struct gpio_chip *chip)
}
for (i = 0; i < ARRAY_SIZE(irq_data); i++) {
- gpiod = gpiochip_request_own_desc(chip, i, NULL);
+ gpiod = gpiochip_request_own_desc(chip, i, pin_name[i]);
if (IS_ERR(gpiod)) {
pr_err("%s: failed to get GPIO pin %d (%ld)\n",
__func__, i, PTR_ERR(gpiod));
@@ -105,8 +110,27 @@ void __init ams_delta_init_fiq(struct gpio_chip *chip)
/* Store irq_data location for IRQ handler use */
irq_data[i] = irq_get_irq_data(gpiod_to_irq(gpiod));
- gpiochip_free_own_desc(gpiod);
+ /*
+ * FIQ handler takes full control over serio data and clk GPIO
+ * pins. Initiaize them and keep requested so nobody can
+ * interfere. Fail if any of those two couldn't be requested.
+ */
+ switch (i) {
+ case AMS_DELTA_GPIO_PIN_KEYBRD_DATA:
+ data = gpiod;
+ gpiod_direction_input(data);
+ break;
+ case AMS_DELTA_GPIO_PIN_KEYBRD_CLK:
+ clk = gpiod;
+ gpiod_direction_input(clk);
+ break;
+ default:
+ gpiochip_free_own_desc(gpiod);
+ break;
+ }
}
+ if (!data || !clk)
+ goto out_gpio;
fiqhandler_start = &qwerty_fiqin_start;
fiqhandler_length = &qwerty_fiqin_end - &qwerty_fiqin_start;
@@ -117,7 +141,7 @@ void __init ams_delta_init_fiq(struct gpio_chip *chip)
if (retval) {
pr_err("ams_delta_init_fiq(): couldn't claim FIQ, ret=%d\n",
retval);
- return;
+ goto out_gpio;
}
retval = request_irq(INT_DEFERRED_FIQ, deferred_fiq,
@@ -125,7 +149,7 @@ void __init ams_delta_init_fiq(struct gpio_chip *chip)
if (retval < 0) {
pr_err("Failed to get deferred_fiq IRQ, ret=%d\n", retval);
release_fiq(&fh);
- return;
+ goto out_gpio;
}
/*
* Since no set_type() method is provided by OMAP irq chip,
@@ -175,4 +199,12 @@ void __init ams_delta_init_fiq(struct gpio_chip *chip)
offset = IRQ_ILR0_REG_OFFSET + (INT_GPIO_BANK1 - NR_IRQS_LEGACY) * 0x4;
val = omap_readl(OMAP_IH1_BASE + offset) | 1;
omap_writel(val, OMAP_IH1_BASE + offset);
+
+ return;
+
+out_gpio:
+ if (data)
+ gpiochip_free_own_desc(data);
+ if (clk)
+ gpiochip_free_own_desc(clk);
}
diff --git a/drivers/input/serio/ams_delta_serio.c b/drivers/input/serio/ams_delta_serio.c
index 0b4d5a952ecb..a83d8b3cd838 100644
--- a/drivers/input/serio/ams_delta_serio.c
+++ b/drivers/input/serio/ams_delta_serio.c
@@ -110,19 +110,6 @@ static void ams_delta_serio_close(struct serio *serio)
regulator_disable(priv->vcc);
}
-static const struct gpio ams_delta_gpios[] __initconst_or_module = {
- {
- .gpio = AMS_DELTA_GPIO_PIN_KEYBRD_DATA,
- .flags = GPIOF_DIR_IN,
- .label = "serio-data",
- },
- {
- .gpio = AMS_DELTA_GPIO_PIN_KEYBRD_CLK,
- .flags = GPIOF_DIR_IN,
- .label = "serio-clock",
- },
-};
-
static int ams_delta_serio_init(struct platform_device *pdev)
{
struct ams_delta_serio *priv;
@@ -133,13 +120,6 @@ static int ams_delta_serio_init(struct platform_device *pdev)
if (!priv)
return -ENOMEM;
- err = gpio_request_array(ams_delta_gpios,
- ARRAY_SIZE(ams_delta_gpios));
- if (err) {
- dev_err(&pdev->dev, "Couldn't request gpio pins\n");
- goto serio;
- }
-
priv->vcc = devm_regulator_get(&pdev->dev, "vcc");
if (IS_ERR(priv->vcc)) {
err = PTR_ERR(priv->vcc);
@@ -147,7 +127,7 @@ static int ams_delta_serio_init(struct platform_device *pdev)
/* Fail softly if the regulator is not available yet */
if (err == -ENODEV)
err = -EPROBE_DEFER;
- goto gpio;
+ return err;
}
err = request_irq(gpio_to_irq(AMS_DELTA_GPIO_PIN_KEYBRD_CLK),
@@ -155,7 +135,7 @@ static int ams_delta_serio_init(struct platform_device *pdev)
DRIVER_NAME, priv);
if (err < 0) {
dev_err(&pdev->dev, "IRQ request failed (%d)\n", err);
- goto gpio;
+ return err;
}
/*
* Since GPIO register handling for keyboard clock pin is performed
@@ -191,10 +171,6 @@ static int ams_delta_serio_init(struct platform_device *pdev)
irq:
free_irq(gpio_to_irq(AMS_DELTA_GPIO_PIN_KEYBRD_CLK), priv);
-gpio:
- gpio_free_array(ams_delta_gpios,
- ARRAY_SIZE(ams_delta_gpios));
-serio:
return err;
}
@@ -204,8 +180,6 @@ static int ams_delta_serio_exit(struct platform_device *pdev)
serio_unregister_port(priv->serio);
free_irq(gpio_to_irq(AMS_DELTA_GPIO_PIN_KEYBRD_CLK), 0);
- gpio_free_array(ams_delta_gpios,
- ARRAY_SIZE(ams_delta_gpios));
return 0;
}
--
2.16.1
next prev parent reply other threads:[~2018-06-09 14:03 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-09 14:02 [PATCH 01/10] ARM: OMAP1: ams-delta: drop GPIO lookup table for serio device Janusz Krzysztofik
2018-06-09 14:02 ` [PATCH 02/10] Input: ams_delta_serio: convert to platform driver Janusz Krzysztofik
2018-06-09 14:02 ` [PATCH 03/10] Input: ams_delta_serio: use private structure Janusz Krzysztofik
2018-06-09 14:02 ` [PATCH 04/10] Input: ams_delta_serio: Replace power GPIO with regulator Janusz Krzysztofik
2018-06-12 22:17 ` Dmitry Torokhov
2018-06-13 1:01 ` Janusz Krzysztofik
2018-06-13 20:51 ` Dmitry Torokhov
2018-06-14 22:16 ` [PATCH 4/10 v2] " Janusz Krzysztofik
2018-06-09 14:02 ` [PATCH 05/10] ARM: OMAP1: ams-delta: Hog "keybrd_dataout" GPIO pin Janusz Krzysztofik
2018-06-09 14:02 ` [PATCH 06/10] ARM: OMAP1: ams-delta FIQ: don't use static GPIO numbers Janusz Krzysztofik
2018-06-14 8:45 ` Linus Walleij
2018-06-09 14:02 ` Janusz Krzysztofik [this message]
2018-06-09 14:02 ` [PATCH 08/10] ARM: OMAP1: Get rid of <mach/ams-delta-fiq.h> Janusz Krzysztofik
2018-06-09 14:02 ` [PATCH 09/10] Input: ams_delta_serio: use IRQ resource Janusz Krzysztofik
2018-06-12 22:21 ` Dmitry Torokhov
2018-06-13 1:10 ` Janusz Krzysztofik
2018-06-09 14:02 ` [PATCH 10/10] Input: ams_delta_serio: Get FIQ buffer from platform_data Janusz Krzysztofik
2018-06-12 22:23 ` [PATCH 01/10] ARM: OMAP1: ams-delta: drop GPIO lookup table for serio device Dmitry Torokhov
2018-06-13 1:16 ` Janusz Krzysztofik
2018-06-13 4:41 ` Tony Lindgren
2018-06-19 6:50 ` Tony Lindgren
2018-06-21 22:41 ` [PATCH v2 " Janusz Krzysztofik
2018-06-21 22:41 ` [PATCH v2 02/10] Input: ams_delta_serio: convert to platform driver Janusz Krzysztofik
2018-06-22 0:05 ` Dmitry Torokhov
2018-06-21 22:41 ` [PATCH v2 03/10] Input: ams_delta_serio: use private structure Janusz Krzysztofik
2018-06-22 0:07 ` Dmitry Torokhov
2018-06-21 22:41 ` [PATCH v2 04/10] Input: ams_delta_serio: Replace power GPIO with regulator Janusz Krzysztofik
2018-06-22 0:09 ` Dmitry Torokhov
2018-06-21 22:41 ` [PATCH v2 05/10] ARM: OMAP1: ams-delta: Hog "keybrd_dataout" GPIO pin Janusz Krzysztofik
2018-06-21 22:41 ` [PATCH v2 06/10] ARM: OMAP1: ams-delta FIQ: don't use static GPIO numbers Janusz Krzysztofik
2018-07-02 12:56 ` Tony Lindgren
2018-06-21 22:41 ` [PATCH v2 07/10] ARM: OMAP1: ams-delta FIQ: Keep serio input GPIOs requested Janusz Krzysztofik
2018-06-22 0:10 ` Dmitry Torokhov
2018-06-21 22:41 ` [PATCH v2 08/10] ARM: OMAP1: Get rid of <mach/ams-delta-fiq.h> Janusz Krzysztofik
2018-06-22 0:10 ` Dmitry Torokhov
2018-06-21 22:41 ` [PATCH v2 09/10] Input: ams_delta_serio: use IRQ resource Janusz Krzysztofik
2018-06-22 0:11 ` Dmitry Torokhov
2018-06-21 22:41 ` [PATCH v2 10/10] Input: ams_delta_serio: Get FIQ buffer from platform_data Janusz Krzysztofik
2018-06-22 0:11 ` Dmitry Torokhov
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=20180609140224.32606-7-jmkrzyszt@gmail.com \
--to=jmkrzyszt@gmail.com \
--cc=aaro.koskinen@iki.fi \
--cc=akpm@linux-foundation.org \
--cc=broonie@kernel.org \
--cc=davem@davemloft.net \
--cc=dmitry.torokhov@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=lgirdwood@gmail.com \
--cc=linus.walleij@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-omap@vger.kernel.org \
--cc=mchehab+samsung@kernel.org \
--cc=rdunlap@infradead.org \
--cc=tony@atomide.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
all inboxes | Powered by JetHome®