From patchwork Sun May 13 12:43:54 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 8572 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 031F123EAB for ; Sun, 13 May 2012 12:44:03 +0000 (UTC) Received: from mail-yw0-f52.google.com (mail-yw0-f52.google.com [209.85.213.52]) by fiordland.canonical.com (Postfix) with ESMTP id B1430A187E7 for ; Sun, 13 May 2012 12:44:02 +0000 (UTC) Received: by yhpp61 with SMTP id p61so4613135yhp.11 for ; Sun, 13 May 2012 05:44:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:mime-version:content-type :x-gm-message-state; bh=lrXPN5FRuxT0+Tw4wzJlZ+YzBxrUjSceqSUZGPNpujo=; b=EE093Kyt8fK59uE49jEbHbHeEYVSU0+RkIlhWt+IyfoxGL5xa1FiYe1P5i2SAGWMjg I4t45c6PbMwQTaA6HH/yIKJZFIX6QKgtkw2wnqb1/LVsT5YM/Gr8PLNvna+TP5mri7Xi D4rVijCkezpFPbNzi++R/thFZqlC4A3eAnNlrCyBf7G0zSKQmzjHTIjykr95pKs2/X97 GsE24pcpEWQe7LcJbXUI48CNgbzkBSZg9k9rdevz2vjYrL5Qqp/YL5VNzoeJVTMGXj+Z 9j9fsrxZRL6yMPxEaS7VCWYUTbDY0CY9XwDuzHujTseoHdYprucF93H/RxqtnB7+xaAZ wm6A== Received: by 10.42.142.71 with SMTP id r7mr2089674icu.7.1336913041635; Sun, 13 May 2012 05:44:01 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.231.73.147 with SMTP id q19csp286721ibj; Sun, 13 May 2012 05:44:00 -0700 (PDT) Received: by 10.213.145.67 with SMTP id c3mr754941ebv.144.1336913040163; Sun, 13 May 2012 05:44:00 -0700 (PDT) Received: from eu1sys200aog107.obsmtp.com (eu1sys200aog107.obsmtp.com. [207.126.144.123]) by mx.google.com with SMTP id o16si4585541eeb.86.2012.05.13.05.43.58 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 13 May 2012 05:44:00 -0700 (PDT) Received-SPF: neutral (google.com: 207.126.144.123 is neither permitted nor denied by best guess record for domain of linus.walleij@stericsson.com) client-ip=207.126.144.123; Authentication-Results: mx.google.com; spf=neutral (google.com: 207.126.144.123 is neither permitted nor denied by best guess record for domain of linus.walleij@stericsson.com) smtp.mail=linus.walleij@stericsson.com Received: from beta.dmz-eu.st.com ([164.129.1.35]) (using TLSv1) by eu1sys200aob107.postini.com ([207.126.147.11]) with SMTP ID DSNKT6+sjo+G+7i6GFjonPZgdFRyabcyR3J2@postini.com; Sun, 13 May 2012 12:44:00 UTC Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 8F6916C; Sun, 13 May 2012 12:43:57 +0000 (GMT) Received: from relay1.stm.gmessaging.net (unknown [10.230.100.17]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 2A39F2072; Sun, 13 May 2012 12:43:57 +0000 (GMT) Received: from exdcvycastm003.EQ1STM.local (alteon-source-exch [10.230.100.61]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (Client CN "exdcvycastm003", Issuer "exdcvycastm003" (not verified)) by relay1.stm.gmessaging.net (Postfix) with ESMTPS id 2BE3024C2F1; Sun, 13 May 2012 14:43:50 +0200 (CEST) Received: from steludxu4075.lud.stericsson.com (10.230.100.153) by smtp.stericsson.com (10.230.100.1) with Microsoft SMTP Server (TLS) id 8.3.83.0; Sun, 13 May 2012 14:43:56 +0200 From: Linus Walleij To: Dmitry Torokhov Cc: , Naveen Kumar Gaddipati , Linus Walleij Subject: [PATCH 3/7] input/nomadik-ske: get rid of multiple interrupts Date: Sun, 13 May 2012 14:43:54 +0200 Message-ID: <1336913034-10082-1-git-send-email-linus.walleij@stericsson.com> X-Mailer: git-send-email 1.7.9.2 MIME-Version: 1.0 X-Gm-Message-State: ALoCoQl3WL9nFhq4a+wsdZ86/GxOcOcQj4o1U1keo80b5LVdZR1Bj7EahMrkLxUOosBDv3Rc33ek From: Naveen Kumar Gaddipati The keypad could cause multiple interrupts to be fired in succession since we weren't waiting for the IRQs to clear properly in the interrupt handler. We ait for a number of bus iterations (the readl():s from the peripheral bus will stall, so these are quite long) before giving up on getting keys ready to read, then we sleep until the IRQ is deasserted (this is OK since the interrupt is threaded). Also use the debounce platform data for another hardcoded wait loop. Signed-off-by: Naveen Kumar Gaddipati Reviewed-by: Rikard Olsson Reviewed-by: Srinidhi Kasagar Signed-off-by: Linus Walleij --- drivers/input/keyboard/nomadik-ske-keypad.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/input/keyboard/nomadik-ske-keypad.c b/drivers/input/keyboard/nomadik-ske-keypad.c index 0df47e5..83b0424 100644 --- a/drivers/input/keyboard/nomadik-ske-keypad.c +++ b/drivers/input/keyboard/nomadik-ske-keypad.c @@ -48,6 +48,7 @@ #define SKE_ASR3 0x2C #define SKE_NUM_ASRX_REGISTERS (4) +#define KEY_PRESSED_DELAY 10 /** * struct ske_keypad - data structure used by keypad driver @@ -91,7 +92,7 @@ static void ske_keypad_set_bits(struct ske_keypad *keypad, u16 addr, static int __init ske_keypad_chip_init(struct ske_keypad *keypad) { u32 value; - int timeout = 50; + int timeout = keypad->board->debounce_ms; /* check SKE_RIS to be 0 */ while ((readl(keypad->reg_base + SKE_RIS) != 0x00000000) && timeout--) @@ -195,18 +196,22 @@ static void ske_keypad_read_data(struct ske_keypad *keypad) static irqreturn_t ske_keypad_irq(int irq, void *dev_id) { struct ske_keypad *keypad = dev_id; - int retries = 20; + int timeout = keypad->board->debounce_ms; /* disable auto scan interrupt; mask the interrupt generated */ ske_keypad_set_bits(keypad, SKE_IMSC, ~SKE_KPIMA, 0x0); ske_keypad_set_bits(keypad, SKE_ICR, 0x0, SKE_KPICA); - while ((readl(keypad->reg_base + SKE_CR) & SKE_KPASON) && --retries) + while ((readl(keypad->reg_base + SKE_CR) & SKE_KPASON) && --timeout) cpu_relax(); /* SKEx registers are stable and can be read */ ske_keypad_read_data(keypad); + /* wait until raw interrupt is clear */ + while ((readl(keypad->reg_base + SKE_RIS)) && --timeout) + msleep(KEY_PRESSED_DELAY); + /* enable auto scan interrupts */ ske_keypad_set_bits(keypad, SKE_IMSC, 0x0, SKE_KPIMA);