From patchwork Sun Jun 17 14:17:58 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 9369 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 97C6423E55 for ; Sun, 17 Jun 2012 14:18:22 +0000 (UTC) Received: from mail-ob0-f180.google.com (mail-ob0-f180.google.com [209.85.214.180]) by fiordland.canonical.com (Postfix) with ESMTP id 5E3B1A18054 for ; Sun, 17 Jun 2012 14:18:22 +0000 (UTC) Received: by mail-ob0-f180.google.com with SMTP id un3so7892186obb.11 for ; Sun, 17 Jun 2012 07:18:22 -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=WzpkAlueN/KijHS75x11t1xgigYh7J/w8HHIaGGbemY=; b=C4JOgzAhnx1S1qzqxH7e7FHOieFyVS6UlUy+RRBlI2bnrdgJR9PWG7raYO7zmZfSKL 1HKTJ9KHcFeTXjLLm8VZFWGAWinqV/+bW3SPcOPNfRuHVMtiIO4Rp5RrradFCVm4xSRf 7Zngouuuc7sBqsJNEYWRemYfyCNXYQU71o5ubZS0jfY0LSm7vEGYt/yz6Doy87nHSlTi 5xezTQPaeotNzI0Y00Ckl1+S0IwlUULw2UHGbE8avvBwpgntX+uFeuBP+asV9g2qb1iM NtjsL7M+k0ar5UqQeyLJZ9V7x7g8XSeX1ySYXD16iHzcQNn9H2F/DAp332EuI3lrbXXV 75Ww== Received: by 10.50.40.193 with SMTP id z1mr3052805igk.0.1339942702005; Sun, 17 Jun 2012 07:18:22 -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.24.148 with SMTP id v20csp23825ibb; Sun, 17 Jun 2012 07:18:21 -0700 (PDT) Received: by 10.14.37.206 with SMTP id y54mr2914602eea.218.1339942700729; Sun, 17 Jun 2012 07:18:20 -0700 (PDT) Received: from eu1sys200aog102.obsmtp.com (eu1sys200aog102.obsmtp.com. [207.126.144.113]) by mx.google.com with SMTP id z6si7118443eem.54.2012.06.17.07.18.17 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 17 Jun 2012 07:18:20 -0700 (PDT) Received-SPF: neutral (google.com: 207.126.144.113 is neither permitted nor denied by best guess record for domain of linus.walleij@stericsson.com) client-ip=207.126.144.113; Authentication-Results: mx.google.com; spf=neutral (google.com: 207.126.144.113 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-ap.st.com ([138.198.100.35]) (using TLSv1) by eu1sys200aob102.postini.com ([207.126.147.11]) with SMTP ID DSNKT93nHLpaaWNrFsU+YLf8MK4Dqk6jKCYe@postini.com; Sun, 17 Jun 2012 14:18:20 UTC Received: from zeta.dmz-ap.st.com (ns6.st.com [138.198.234.13]) by beta.dmz-ap.st.com (STMicroelectronics) with ESMTP id 7B9BFA2; Sun, 17 Jun 2012 14:09:42 +0000 (GMT) Received: from relay1.stm.gmessaging.net (unknown [10.230.100.17]) by zeta.dmz-ap.st.com (STMicroelectronics) with ESMTP id CDD1B12A4; Sun, 17 Jun 2012 14:18:01 +0000 (GMT) Received: from exdcvycastm022.EQ1STM.local (alteon-source-exch [10.230.100.61]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (Client CN "exdcvycastm022", Issuer "exdcvycastm022" (not verified)) by relay1.stm.gmessaging.net (Postfix) with ESMTPS id 62D9624C07D; Sun, 17 Jun 2012 16:17:53 +0200 (CEST) Received: from steludxu4075.lud.stericsson.com (10.230.100.153) by smtp.stericsson.com (10.230.100.30) with Microsoft SMTP Server (TLS) id 8.3.83.0; Sun, 17 Jun 2012 16:18:01 +0200 From: Linus Walleij To: Dmitry Torokhov Cc: , Naveen Kumar Gaddipati , Linus Walleij Subject: [PATCH 3/4] input/nomadik-ske: get rid of multiple interrupts Date: Sun, 17 Jun 2012 16:17:58 +0200 Message-ID: <1339942678-20156-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: ALoCoQk3AdlCBwg1CppvA34pQ7y7i3020/8gZbojjO9lVd3hmX8fiWm1ubIfsqpimhRdUVSSshR1 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 68c36a7..ca802fe 100644 --- a/drivers/input/keyboard/nomadik-ske-keypad.c +++ b/drivers/input/keyboard/nomadik-ske-keypad.c @@ -49,6 +49,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 @@ -92,7 +93,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--) @@ -196,18 +197,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);