linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: eric.y.miao@gmail.com (Eric Miao)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 2/7] [ARM] locomo: avoid the unnecessary cascade of keyboard IRQ
Date: Mon, 28 Dec 2009 13:18:03 +0800	[thread overview]
Message-ID: <1261977488-18271-3-git-send-email-eric.y.miao@gmail.com> (raw)
In-Reply-To: <1261977488-18271-1-git-send-email-eric.y.miao@gmail.com>

It is not necessary and over-complicated that IRQ_LOCOMO_KEY is a cascaded
IRQ of IRQ_LOCOMO_KEY_BASE. Removed and introduced locomokbd_{open,close}
for masking/unmasking of the keyboard IRQ.

Signed-off-by: Eric Miao <eric.y.miao@gmail.com>
---
 arch/arm/common/locomo.c           |    5 +++--
 drivers/input/keyboard/locomokbd.c |   32 +++++++++++++++++++++++++++++++-
 2 files changed, 34 insertions(+), 3 deletions(-)

diff --git a/arch/arm/common/locomo.c b/arch/arm/common/locomo.c
index bd36c77..43cdb5a 100644
--- a/arch/arm/common/locomo.c
+++ b/arch/arm/common/locomo.c
@@ -82,7 +82,7 @@ static struct locomo_dev_info locomo_devices[] = {
 	{
 		.devid 		= LOCOMO_DEVID_KEYBOARD,
 		.irq = {
-			IRQ_LOCOMO_KEY,
+			IRQ_LOCOMO_KEY_BASE,
 		},
 		.name		= "locomo-keyboard",
 		.offset		= LOCOMO_KEYBOARD,
@@ -470,7 +470,8 @@ static void locomo_setup_irq(struct locomo *lchip)
 	/* Install handlers for IRQ_LOCOMO_*_BASE */
 	set_irq_chip(IRQ_LOCOMO_KEY_BASE, &locomo_chip);
 	set_irq_chip_data(IRQ_LOCOMO_KEY_BASE, irqbase);
-	set_irq_chained_handler(IRQ_LOCOMO_KEY_BASE, locomo_key_handler);
+	set_irq_handler(IRQ_LOCOMO_KEY_BASE, handle_level_irq);
+	set_irq_flags(IRQ_LOCOMO_KEY_BASE, IRQF_VALID | IRQF_PROBE);
 
 	set_irq_chip(IRQ_LOCOMO_GPIO_BASE, &locomo_chip);
 	set_irq_chip_data(IRQ_LOCOMO_GPIO_BASE, irqbase);
diff --git a/drivers/input/keyboard/locomokbd.c b/drivers/input/keyboard/locomokbd.c
index 9caed30..b1ab298 100644
--- a/drivers/input/keyboard/locomokbd.c
+++ b/drivers/input/keyboard/locomokbd.c
@@ -192,11 +192,18 @@ static void locomokbd_scankeyboard(struct locomokbd *locomokbd)
 static irqreturn_t locomokbd_interrupt(int irq, void *dev_id)
 {
 	struct locomokbd *locomokbd = dev_id;
+	u16 r;
+
+	r = locomo_readl(locomokbd->base + LOCOMO_KIC);
+	if ((r & 0x0001) == 0)
+		return IRQ_HANDLED;
+
+	locomo_writel(r & ~0x0100, locomokbd->base + LOCOMO_KIC); /* Ack */
+
 	/** wait chattering delay **/
 	udelay(100);
 
 	locomokbd_scankeyboard(locomokbd);
-
 	return IRQ_HANDLED;
 }
 
@@ -210,6 +217,25 @@ static void locomokbd_timer_callback(unsigned long data)
 	locomokbd_scankeyboard(locomokbd);
 }
 
+static int locomokbd_open(struct input_dev *dev)
+{
+	struct locomokbd *locomokbd = input_get_drvdata(dev);
+	u16 r;
+	
+	r = locomo_readl(locomokbd->base + LOCOMO_KIC) | 0x0010;
+	locomo_writel(r, locomokbd->base + LOCOMO_KIC);
+	return 0;
+}
+
+static void locomokbd_close(struct input_dev *dev)
+{
+	struct locomokbd *locomokbd = input_get_drvdata(dev);
+	u16 r;
+	
+	r = locomo_readl(locomokbd->base + LOCOMO_KIC) & ~0x0010;
+	locomo_writel(r, locomokbd->base + LOCOMO_KIC);
+}
+
 static int __devinit locomokbd_probe(struct locomo_dev *dev)
 {
 	struct locomokbd *locomokbd;
@@ -253,6 +279,8 @@ static int __devinit locomokbd_probe(struct locomo_dev *dev)
 	input_dev->id.vendor = 0x0001;
 	input_dev->id.product = 0x0001;
 	input_dev->id.version = 0x0100;
+	input_dev->open = locomokbd_open;
+	input_dev->close = locomokbd_close;
 	input_dev->dev.parent = &dev->dev;
 
 	input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP) |
@@ -261,6 +289,8 @@ static int __devinit locomokbd_probe(struct locomo_dev *dev)
 	input_dev->keycodesize = sizeof(locomokbd_keycode[0]);
 	input_dev->keycodemax = ARRAY_SIZE(locomokbd_keycode);
 
+	input_set_drvdata(input_dev, locomokbd);
+
 	memcpy(locomokbd->keycode, locomokbd_keycode, sizeof(locomokbd->keycode));
 	for (i = 0; i < LOCOMOKBD_NUMKEYS; i++)
 		set_bit(locomokbd->keycode[i], input_dev->keybit);
-- 
1.6.3.3

  parent reply	other threads:[~2009-12-28  5:18 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-28  5:18 [PATCH 0/7] pxa/sa1100: irqs.h cleanup Eric Miao
2009-12-28  5:18 ` [PATCH 1/7] [ARM] sa1100: remove unreferenced IRQ definitions Eric Miao
2009-12-31 13:23   ` Thomas Kunze
2010-01-10 17:04     ` Marek Vasut
2010-01-21 18:01       ` Thomas Kunze
2009-12-28  5:18 ` Eric Miao [this message]
2009-12-31 13:47   ` [PATCH 2/7] [ARM] locomo: avoid the unnecessary cascade of keyboard IRQ Thomas Kunze
2010-01-01  3:35     ` Eric Miao
2010-01-02 11:43   ` Russell King - ARM Linux
2010-01-03  8:07     ` Eric Miao
2009-12-28  5:18 ` [PATCH 3/7] [ARM] locomo: remove unused IRQs and avoid unnecessary cascade Eric Miao
2009-12-31 13:42   ` Thomas Kunze
2010-01-01  2:59     ` Eric Miao
2010-01-10 14:31       ` Thomas Kunze
2010-01-02 11:45   ` Russell King - ARM Linux
2009-12-28  5:18 ` [PATCH 4/7] [ARM] locomo: allow cascaded IRQ base to be specified by platforms Eric Miao
2009-12-28 21:14   ` Pavel Machek
2009-12-29  1:07     ` Eric Miao
2009-12-28  5:18 ` [PATCH 5/7] [ARM] sa1111: avoid using hardcoded IRQ numbers for PCMCIA driver Eric Miao
2009-12-28  5:18 ` [PATCH 6/7] [ARM] sa1111: allow cascaded IRQs to be used by platforms Eric Miao
2009-12-28  5:18 ` [PATCH 7/7] [ARM] pxa: move board board IRQ definitions out of irqs.h Eric Miao

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=1261977488-18271-3-git-send-email-eric.y.miao@gmail.com \
    --to=eric.y.miao@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.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).