From patchwork Thu Mar 1 07:36:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "\(Exiting\) Baolin Wang" X-Patchwork-Id: 130129 Delivered-To: patch@linaro.org Received: by 10.80.172.228 with SMTP id x91csp2483152edc; Wed, 28 Feb 2018 23:37:12 -0800 (PST) X-Google-Smtp-Source: AG47ELsn5wHZxBiehjr+l4jvkeFWe679N+SOAT3LA/trVFCd35SHSFbfrQG0RPr4/CsP8KldxaNf X-Received: by 2002:a17:902:d81:: with SMTP id 1-v6mr1063869plv.324.1519889832131; Wed, 28 Feb 2018 23:37:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519889832; cv=none; d=google.com; s=arc-20160816; b=eBaWn2hjH+svqSKs8WpHL3LU83Xrx0C5F7rALzSaKoZnyYdAB5RD+tlRqEbbfXueZI rRKXSlhSx8ZeNGRoHqKrlSOk+gqhK9tijnEN2dLdTGhZYz9Nf9YqgpYph3b7DcK6s1fi LjFNUXTyjUoxcGJJ8Rte/uV+V2f2XHY+RckRjSGPgUfrwydrNdlCil62guGo7K1/ADXi sKxDtBGeEdf/ySZGQkllrstOLpIeuSUCV2+TuTaFY4UvcBG6DEBMIwK95hDZROuG1+cz QUAhzTn+XdFfDe1D8erf/YFQNH8R5Z/HVjqZ/KOd4f/lLZcwFuFxA8ztrdSA1Nz3Pwm8 AJhQ== 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=4gwX9kbJqcaf179bSVgCzLFU2jSSGeeqWSpAL5AZvz4=; b=bGaKFw01cvgoQXwTCkhOrhtMX0Jf9x1YCOC5vkZs/U6dJZx+DYhJUPDjP81wyitejF Ehg/qMXCYr5VAJWs9dwi0kuIvGDKN1WToSS8d3CB6U8oPc5si02JUW5sd9H4vevW9Wi0 URn4/LxYiM5UnXK3pDIPzJm9ddYIQF58o/0r90h3jMVM5ReoZE0qqMZy+9Po7DG4ccTe RyJyehiXNV+xBFAPLd4yb4JzpAum9wxEiZLwVbPLyvRMlU5Z6mjiPz2GlNvEtZ9+Qpe7 BU6utB4bnhyBGMzNenwA4vfr2rXc67FOxpKGpow8vZqbl++ki5UteNoEEQKdFYo65UTw VIsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=XjjjKXEu; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=fail (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 o5-v6si2644974plh.135.2018.02.28.23.37.11; Wed, 28 Feb 2018 23:37:12 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=XjjjKXEu; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935251AbeCAHhL (ORCPT + 6 others); Thu, 1 Mar 2018 02:37:11 -0500 Received: from mail-pl0-f65.google.com ([209.85.160.65]:41337 "EHLO mail-pl0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935175AbeCAHhJ (ORCPT ); Thu, 1 Mar 2018 02:37:09 -0500 Received: by mail-pl0-f65.google.com with SMTP id k8-v6so3174226pli.8 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=I64mrBj3CX2MoCaTzLMkvuELBD+FwT3EQZ4RDQmTnEueUis15yqeDs7RvAJ/s6NAOb AC6uSNBlBMFwHax+mcv9sd0TDfkYjuh8Kwy+QkA3OKClnJ31NzTUUL9ZGmgFdflzVY4c OXTjOVIf+Fl4qUslW+M6/baTRsAJt3X7t152zyGBhO342quxM/BbYbM9YDEH+6UBy+1d tyWaq8FtietkQozHJp3GY+SCKkRJZS7xx/nb5t8gv4HiexR90H3WD0XhqAp0LHmUAttu ElWtZ1ejuuWKNCc+8RL+7FQgOc7/yGv/NvawfznYazKuZXyCR5uYUzzddbd23t9g62i2 Zsuw== X-Gm-Message-State: APf1xPAdnecMcQSTc+aghmoMeB/L2r3fAwh98F/CSvs5dsGnfwFKiKDT 9WS3N1jewnQCTgKc50xX5I2rOw== 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: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@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(-) -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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; }; /**