From patchwork Fri Feb 9 11:55:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeffy Chen X-Patchwork-Id: 10208853 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A663F60245 for ; Fri, 9 Feb 2018 11:56:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 94C692981C for ; Fri, 9 Feb 2018 11:56:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 89B9029828; Fri, 9 Feb 2018 11:56:15 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 023DD2981C for ; Fri, 9 Feb 2018 11:56:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751093AbeBILzd (ORCPT ); Fri, 9 Feb 2018 06:55:33 -0500 Received: from regular1.263xmail.com ([211.150.99.132]:40809 "EHLO regular1.263xmail.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751029AbeBILzb (ORCPT ); Fri, 9 Feb 2018 06:55:31 -0500 Received: from jeffy.chen?rock-chips.com (unknown [192.168.167.223]) by regular1.263xmail.com (Postfix) with ESMTP id 59E4E9450; Fri, 9 Feb 2018 19:55:25 +0800 (CST) X-263anti-spam: KSV:0; X-MAIL-GRAY: 0 X-MAIL-DELIVERY: 1 X-KSVirus-check: 0 X-ABS-CHECKED: 4 Received: from localhost (localhost [127.0.0.1]) by smtp.263.net (Postfix) with ESMTPA id ABD0E378; Fri, 9 Feb 2018 19:55:21 +0800 (CST) X-RL-SENDER: jeffy.chen@rock-chips.com X-FST-TO: linux-kernel@vger.kernel.org X-SENDER-IP: 103.29.142.67 X-LOGIN-NAME: jeffy.chen@rock-chips.com X-UNIQUE-TAG: X-ATTACHMENT-NUM: 0 X-SENDER: cjf@rock-chips.com X-DNS-TYPE: 0 Received: from localhost (unknown [103.29.142.67]) by smtp.263.net (Postfix) whith ESMTP id 26727HMXLMW; Fri, 09 Feb 2018 19:55:27 +0800 (CST) From: Jeffy Chen To: linux-kernel@vger.kernel.org Cc: briannorris@google.com, dtor@google.com, dianders@google.com, Jeffy Chen , Guenter Roeck , Thomas Gleixner , Joseph Lo , stephen lu , Dmitry Torokhov , Kate Stewart , linux-input@vger.kernel.org, Greg Kroah-Hartman , Philippe Ombredanne , Arvind Yadav Subject: [PATCH 1/3] Input: gpio-keys - add support for wakeup interrupt trigger type Date: Fri, 9 Feb 2018 19:55:08 +0800 Message-Id: <20180209115510.11868-2-jeffy.chen@rock-chips.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180209115510.11868-1-jeffy.chen@rock-chips.com> References: <20180209115510.11868-1-jeffy.chen@rock-chips.com> Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add support for specifying a different interrupt trigger type for wakeup when using the gpio-keys input device as a wakeup source. This would allow the device to configure when to wakeup the system. For example a gpio-keys input device for pen insert, may only want to wakeup the system when ejecting the pen. Suggested-by: Brian Norris Signed-off-by: Jeffy Chen --- drivers/input/keyboard/gpio_keys.c | 20 ++++++++++++++++++-- include/linux/gpio_keys.h | 2 ++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c index 87e613dc33b8..5e5c93b75a71 100644 --- a/drivers/input/keyboard/gpio_keys.c +++ b/drivers/input/keyboard/gpio_keys.c @@ -45,6 +45,7 @@ struct gpio_button_data { unsigned int software_debounce; /* in msecs, for GPIO-driven buttons */ unsigned int irq; + unsigned int irq_trigger_type; spinlock_t lock; bool disabled; bool key_pressed; @@ -618,6 +619,8 @@ static int gpio_keys_setup_key(struct platform_device *pdev, return error; } + bdata->irq_trigger_type = irq_get_trigger_type(bdata->irq); + return 0; } @@ -718,6 +721,9 @@ gpio_keys_get_devtree_pdata(struct device *dev) /* legacy name */ fwnode_property_read_bool(child, "gpio-key,wakeup"); + fwnode_property_read_u32(child, "wakeup-trigger-type", + &button->wakeup_trigger_type); + button->can_disable = fwnode_property_read_bool(child, "linux,can-disable"); @@ -854,7 +860,12 @@ static int __maybe_unused gpio_keys_suspend(struct device *dev) if (device_may_wakeup(dev)) { for (i = 0; i < ddata->pdata->nbuttons; i++) { struct gpio_button_data *bdata = &ddata->data[i]; - if (bdata->button->wakeup) + const struct gpio_keys_button *button = bdata->button; + + if (button->wakeup && button->wakeup_trigger_type) + irq_set_irq_type(bdata->irq, + button->wakeup_trigger_type); + if (button->wakeup) enable_irq_wake(bdata->irq); bdata->suspended = true; } @@ -878,7 +889,12 @@ static int __maybe_unused gpio_keys_resume(struct device *dev) if (device_may_wakeup(dev)) { for (i = 0; i < ddata->pdata->nbuttons; i++) { struct gpio_button_data *bdata = &ddata->data[i]; - if (bdata->button->wakeup) + const struct gpio_keys_button *button = bdata->button; + + if (button->wakeup && button->wakeup_trigger_type) + irq_set_irq_type(bdata->irq, + bdata->irq_trigger_type); + if (button->wakeup) disable_irq_wake(bdata->irq); bdata->suspended = false; } diff --git a/include/linux/gpio_keys.h b/include/linux/gpio_keys.h index d06bf77400f1..9b7e7137f768 100644 --- a/include/linux/gpio_keys.h +++ b/include/linux/gpio_keys.h @@ -13,6 +13,7 @@ struct device; * @desc: label that will be attached to button's gpio * @type: input event type (%EV_KEY, %EV_SW, %EV_ABS) * @wakeup: configure the button as a wake-up source + * @wakeup_trigger_type: wakeup interrupt trigger type * @debounce_interval: debounce ticks interval in msecs * @can_disable: %true indicates that userspace is allowed to * disable button via sysfs @@ -26,6 +27,7 @@ struct gpio_keys_button { const char *desc; unsigned int type; int wakeup; + int wakeup_trigger_type; int debounce_interval; bool can_disable; int value;