Received: by 10.223.185.116 with SMTP id b49csp7123129wrg; Wed, 28 Feb 2018 23:38:05 -0800 (PST) X-Google-Smtp-Source: AG47ELvhsV7d0E4DKuPDiZHE6pEODWt3ZdEA8ooX2Np4QskrygWqX9p4ymNunJCTqwQiLoJBPTWt X-Received: by 10.99.168.8 with SMTP id o8mr823966pgf.246.1519889885524; Wed, 28 Feb 2018 23:38:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519889885; cv=none; d=google.com; s=arc-20160816; b=OnnMbJFlAjPmQ3llP07vBQGsxJWiX0S8jxtBNDHVtY29IEUcXx/nhRQVlce2OfObtn aehoLVeDFvazUXGvGsujt3mnlcWUxUahP+A2gra0iPKUvPBq7ZsDoL1k6QgR2gh7Yq8y SLhv6hTc08F/LNpE+NUdm3fUgdoWV0KX7HOI82GiwAZQ4PMpnE2BTiZkGCAfjiT3RxBB yKqbG2lS3NMIZxEngDcoTT4rV7sglJ4OA+2VrtTG9KyMXanyCpsmKPZgNRlhj7aJ5HVh MINycxYD+Ofn9r7iV4xEVGnbf+8qoe/d2xR4vaYoXXNp5TsTgv3TSwUxD0/aAb6zmmVw TUbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=RHczmPeZ0O9jiFQJdqJWYz+CPCcuYOkftnF6zlVUHCI=; b=jmztOUz1LZ9M643o+KvbdTxr1Ab6ApLDRWzTheTwlWImmpFYOAqB/uyTYFqiMAP8tc cnJykZJ3W0bNwAX35Syo57r/9n4qQKmbwr4SK/EBiSTzD7dmA8amEmWEc0gO3G8jnlQT meazdaro3sJXVtpLtyb1QSXXb+dUPt5Mrjw4BvhlEvTFKSX94e7TQgSpiRXqCrk4WRhI WOwKniEUWcg6OBP/YhfKQRFLFPy8XCPssO1fZUyi3lc9KnfZ5Zq2DlaAhNbeIAO+0N30 Upo8XzA4GbttV3bQ/FxS02vbUK1jHjZo9I6kCQfy+OXHQ0d/TtvUR96/OuBCo1tSZQz6 RxWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XjjjKXEu; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b9si355532pff.169.2018.02.28.23.37.51; Wed, 28 Feb 2018 23:38:05 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XjjjKXEu; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935412AbeCAHhL (ORCPT + 99 others); Thu, 1 Mar 2018 02:37:11 -0500 Received: from mail-pl0-f67.google.com ([209.85.160.67]:35211 "EHLO mail-pl0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935008AbeCAHhJ (ORCPT ); Thu, 1 Mar 2018 02:37:09 -0500 Received: by mail-pl0-f67.google.com with SMTP id bb3-v6so3190007plb.2 for ; Wed, 28 Feb 2018 23:37:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=RHczmPeZ0O9jiFQJdqJWYz+CPCcuYOkftnF6zlVUHCI=; b=XjjjKXEuf1sV+n1Pbumg8ZBpnFvdpF6WBSIHoGowVRWS4Nc6v5OyE8Wnvyz5Tgb4HQ PqSy/k+yHo1yqLUQCPXyR9IHrTkKOjrXDY6Vz3e4q9qLUoYwUxug1izW5i/pdLeUj/sh eR7D6x18Y+tELrdCoNZlqUnytpPPzkGUHfJ/w= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=RHczmPeZ0O9jiFQJdqJWYz+CPCcuYOkftnF6zlVUHCI=; b=ngHz5GyyFVI/BeEV2eEYLLYYGe2DqILGnQNrWH1XfVhSbi8SzJyZqAtQD3vgjJm7V+ 7Zuz9YiYJWwV42PV3u/1OXhFYq5FKPaGX98u4dlsn98XnCPNaZ72gbcy0oiPz6EOmuTN 5Lgv4nr1WajHb0up7+lDm/bo7HSCqwV4hUApZuDXtmdSaZ6ndZ0VE/lJjImRBl6peMe8 Fw09QrOJsVOZnC6IujMbARWmr+Ga9xRu2/bpSGp+9pImeygHVDAIuCq+p2LwmFe3/Tuy WDpeADyw6aU7JRePRp88Pc5AjOzobo7EzOmI9CM2X7yvT8bCuxdYYK1Tu5h6YXKWwFjk klZA== X-Gm-Message-State: APf1xPBdo4Ln+2YnUUN7Pb7KGYjbTQxY6rvTSgOIr/34KeQG/fq3QrVl Jb4nsWYtUA3HkZd0Zei5rifQfQ== X-Received: by 2002:a17:902:a504:: with SMTP id s4-v6mr1068939plq.43.1519889828968; Wed, 28 Feb 2018 23:37:08 -0800 (PST) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.82]) by smtp.gmail.com with ESMTPSA id g5sm5818586pfh.6.2018.02.28.23.37.04 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 28 Feb 2018 23:37:08 -0800 (PST) From: Baolin Wang To: dmitry.torokhov@gmail.com, robh+dt@kernel.org, mark.rutland@arm.com Cc: gregkh@linuxfoundation.org, lumotuwe@gmail.com, arvind.yadav.cs@gmail.com, josephl@nvidia.com, kstewart@linuxfoundation.org, pombredanne@nexb.com, tglx@linutronix.de, linux-input@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, broonie@kernel.org, linus.walleij@linaro.org, arnd@arndb.de, baolin.wang@linaro.org Subject: [PATCH v4] Input: gpio_keys: Add level trigger support for GPIO keys Date: Thu, 1 Mar 2018 15:36:18 +0800 Message-Id: <9ea2faf9c1cf8439f3a8ad495c6a2b49dacad7bd.1519889208.git.baolin.wang@linaro.org> X-Mailer: git-send-email 1.7.9.5 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On some platforms (such as Spreadtrum platform), the GPIO keys can only be triggered by level type. So this patch introduces one trigger_type to indicate if the button's interrupt type is level trigger or edge trigger. Signed-off-by: Baolin Wang --- Changes since v3: - Remove the reserse level logic into gpio irqchip. - Add one trigger_type to indicate teh button's trigger type. Changes since v2: - Use 'interrupt' property to indicate the irq type. Changes since v1: - Diable the GPIO irq until reversing the GPIO level type. --- drivers/input/keyboard/gpio_keys.c | 12 ++++++++++-- include/linux/gpio_keys.h | 2 ++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c index 87e613d..614ee29 100644 --- a/drivers/input/keyboard/gpio_keys.c +++ b/drivers/input/keyboard/gpio_keys.c @@ -566,7 +566,10 @@ static int gpio_keys_setup_key(struct platform_device *pdev, INIT_DELAYED_WORK(&bdata->work, gpio_keys_gpio_work_func); isr = gpio_keys_gpio_isr; - irqflags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING; + if (button->trigger_type) + irqflags = button->trigger_type; + else + irqflags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING; } else { if (!button->irq) { @@ -696,10 +699,15 @@ static void gpio_keys_close(struct input_dev *input) device_property_read_string(dev, "label", &pdata->name); device_for_each_child_node(dev, child) { - if (is_of_node(child)) + if (is_of_node(child)) { button->irq = irq_of_parse_and_map(to_of_node(child), 0); + if (button->irq) + button->trigger_type = + irq_get_trigger_type(button->irq); + } + if (fwnode_property_read_u32(child, "linux,code", &button->code)) { dev_err(dev, "Button without keycode\n"); diff --git a/include/linux/gpio_keys.h b/include/linux/gpio_keys.h index d06bf77..eae87e2 100644 --- a/include/linux/gpio_keys.h +++ b/include/linux/gpio_keys.h @@ -18,6 +18,7 @@ * disable button via sysfs * @value: axis value for %EV_ABS * @irq: Irq number in case of interrupt keys + * @trigger_type: indicate the button's interrupt type */ struct gpio_keys_button { unsigned int code; @@ -30,6 +31,7 @@ struct gpio_keys_button { bool can_disable; int value; unsigned int irq; + unsigned int trigger_type; }; /** -- 1.7.9.5