From patchwork Sun Jun 17 14:17:42 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 9368 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 02D6123E55 for ; Sun, 17 Jun 2012 14:18:20 +0000 (UTC) Received: from mail-yx0-f180.google.com (mail-yx0-f180.google.com [209.85.213.180]) by fiordland.canonical.com (Postfix) with ESMTP id B1C9CA18054 for ; Sun, 17 Jun 2012 14:18:19 +0000 (UTC) Received: by yenq6 with SMTP id q6so3571310yen.11 for ; Sun, 17 Jun 2012 07:18:19 -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=YjP1F1D2XDrbJuiH6z4MInc7YC5RgdEH5Ep5iagXTw4=; b=PiUlvXbsFomYs9x26W2sx6AbGBk3/jTWeXOrbtg4UHFJqPaUzSKuyvnVk6V7Ng4HaY AVF03UaLxtvyfwAKjrGqbpdePUdSftYsljkBbCOtYynxdhVhnrkqUvprMC6a1bRCOcm0 h2ZJojUrNtlvVtNEXjssejO6a9HL/USt1ud8b9hal+XCqmII2cdPSUwYJpJMfkUK4GJy jlFvRr4PxaJJalyDoaZdw/hL6uER3SuiRc8NuqYMet9SyQx0cyndAdIA7VIlzLqeJxOu gnU3oxcPkVjf1uOUlvvivIYbf8j0+DOlYPYuVXmxniSlTwE85GGwVkKACsM9TfFVftIf QsoA== Received: by 10.50.160.198 with SMTP id xm6mr6312490igb.0.1339942698964; Sun, 17 Jun 2012 07:18:18 -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 v20csp23821ibb; Sun, 17 Jun 2012 07:18:18 -0700 (PDT) Received: by 10.14.127.2 with SMTP id c2mr2010120eei.96.1339942697520; Sun, 17 Jun 2012 07:18:17 -0700 (PDT) Received: from eu1sys200aog117.obsmtp.com (eu1sys200aog117.obsmtp.com. [207.126.144.143]) by mx.google.com with SMTP id t47si7126696eeb.14.2012.06.17.07.18.15 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 17 Jun 2012 07:18:17 -0700 (PDT) Received-SPF: neutral (google.com: 207.126.144.143 is neither permitted nor denied by best guess record for domain of linus.walleij@stericsson.com) client-ip=207.126.144.143; Authentication-Results: mx.google.com; spf=neutral (google.com: 207.126.144.143 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 eu1sys200aob117.postini.com ([207.126.147.11]) with SMTP ID DSNKT93nJ7XyNMzIdAUBO+UmK3K4u8zJZ/QD@postini.com; Sun, 17 Jun 2012 14:18:17 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 6E3C48E; Sun, 17 Jun 2012 14:17:46 +0000 (GMT) Received: from relay1.stm.gmessaging.net (unknown [10.230.100.17]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 2DA0A2286; Sun, 17 Jun 2012 14:17:46 +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 465A424C07D; Sun, 17 Jun 2012 16:17:38 +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, 17 Jun 2012 16:17:45 +0200 From: Linus Walleij To: Dmitry Torokhov Cc: , Naveen Kumar Gaddipati , Linus Walleij Subject: [PATCH 1/4] input/nomadik-ske: add multi key press support Date: Sun, 17 Jun 2012 16:17:42 +0200 Message-ID: <1339942662-20085-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: ALoCoQnGVHG+WSGlwTQGwCR0hSYMPOs4dQ2SskYWxRAE8CAxdmFYwKutgJ0VX1fUwmfq1jNuYhan From: Naveen Kumar Gaddipati Added the multi key press support for SKE keypad by modifying the irq function for handling the two different keys on the same column and also pressing the two different keys of different columns on the same ASR register. Signed-off-by: Naveen Kumar Gaddipati Reviewed-by: Srinidhi Kasagar Signed-off-by: Linus Walleij --- drivers/input/keyboard/nomadik-ske-keypad.c | 65 ++++++++++++++++----------- 1 file changed, 40 insertions(+), 25 deletions(-) diff --git a/drivers/input/keyboard/nomadik-ske-keypad.c b/drivers/input/keyboard/nomadik-ske-keypad.c index 4ea4341..6857454 100644 --- a/drivers/input/keyboard/nomadik-ske-keypad.c +++ b/drivers/input/keyboard/nomadik-ske-keypad.c @@ -135,12 +135,37 @@ static int __init ske_keypad_chip_init(struct ske_keypad *keypad) return 0; } -static void ske_keypad_read_data(struct ske_keypad *keypad) +static void ske_keypad_report(struct ske_keypad *keypad, u8 status, int col) { + int row = 0, code, pos; struct input_dev *input = keypad->input; - u16 status; - int col = 0, row = 0, code; - int ske_asr, ske_ris, key_pressed, i; + u32 ske_ris; + int key_pressed; + int num_of_rows; + + /* find out the row */ + num_of_rows = hweight8(status); + do { + pos = __ffs(status); + row = pos; + status &= ~(1 << pos); + + code = MATRIX_SCAN_CODE(row, col, SKE_KEYPAD_ROW_SHIFT); + ske_ris = readl(keypad->reg_base + SKE_RIS); + key_pressed = ske_ris & SKE_KPRISA; + + input_event(input, EV_MSC, MSC_SCAN, code); + input_report_key(input, keypad->keymap[code], key_pressed); + input_sync(input); + num_of_rows--; + } while (num_of_rows); +} + +static void ske_keypad_read_data(struct ske_keypad *keypad) +{ + u8 status; + int col = 0; + int ske_asr, i; /* * Read the auto scan registers @@ -154,25 +179,17 @@ static void ske_keypad_read_data(struct ske_keypad *keypad) if (!ske_asr) continue; - /* now that ASRx is zero, find out the column x and row y*/ - if (ske_asr & 0xff) { + /* now that ASRx is zero, find out the coloumn x and row y */ + status = ske_asr & 0xff; + if (status) { col = i * 2; - status = ske_asr & 0xff; - } else { + ske_keypad_report(keypad, status, col); + } + status = (ske_asr & 0xff00) >> 8; + if (status) { col = (i * 2) + 1; - status = (ske_asr & 0xff00) >> 8; + ske_keypad_report(keypad, status, col); } - - /* find out the row */ - row = __ffs(status); - - code = MATRIX_SCAN_CODE(row, col, SKE_KEYPAD_ROW_SHIFT); - ske_ris = readl(keypad->reg_base + SKE_RIS); - key_pressed = ske_ris & SKE_KPRISA; - - input_event(input, EV_MSC, MSC_SCAN, code); - input_report_key(input, keypad->keymap[code], key_pressed); - input_sync(input); } } @@ -186,12 +203,10 @@ static irqreturn_t ske_keypad_irq(int irq, void *dev_id) ske_keypad_set_bits(keypad, SKE_ICR, 0x0, SKE_KPICA); while ((readl(keypad->reg_base + SKE_CR) & SKE_KPASON) && --retries) - msleep(5); + cpu_relax(); - if (retries) { - /* SKEx registers are stable and can be read */ - ske_keypad_read_data(keypad); - } + /* SKEx registers are stable and can be read */ + ske_keypad_read_data(keypad); /* enable auto scan interrupts */ ske_keypad_set_bits(keypad, SKE_IMSC, 0x0, SKE_KPIMA);