From patchwork Thu Mar 1 16:55:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Smirnov X-Patchwork-Id: 10252021 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 ACD10602B5 for ; Thu, 1 Mar 2018 16:56:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9C926285CB for ; Thu, 1 Mar 2018 16:56:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 90711285E4; Thu, 1 Mar 2018 16:56:18 +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.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham 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 D315E285CB for ; Thu, 1 Mar 2018 16:56:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1033098AbeCAQ4Q (ORCPT ); Thu, 1 Mar 2018 11:56:16 -0500 Received: from mail-pg0-f65.google.com ([74.125.83.65]:32805 "EHLO mail-pg0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1033021AbeCAQ4P (ORCPT ); Thu, 1 Mar 2018 11:56:15 -0500 Received: by mail-pg0-f65.google.com with SMTP id g12so2546285pgs.0; Thu, 01 Mar 2018 08:56:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=Svpsj39b3HYAbbD6MYji3Iojo4qMwa82jU0cfDCHGpM=; b=L3YtrhA/7lP2vmqWB+87cBNFAdCg8RXxzumhJpjpL/VZrBOYGG36syeQZFPdU5eLPG lXAiot5Ab8CugJzUzQHpm4+oQ8qnN7siRt4UD4Nf7y+mmF88bMCzPBWYXOdg4Dh+TMAv ICoAxDPqC4UHenqwNztIbMiaWyQ/8imTIy/f5Tck0HttmORUYga4gaTaaIAMyqJDpWfK 904Po7aRUknSSXXlNEqnOWydpxYbqAqP01n/b+7xSKAXMaYdMI1NLyfTtUo/NAv3R8Oh 8BLKlpx/uDmiyQj4zty303eIyv28oRfNBIyIShqu3irDKaLgsX0qA6ZQgO8fC6EQNTfY i2Bg== 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=Svpsj39b3HYAbbD6MYji3Iojo4qMwa82jU0cfDCHGpM=; b=UP2r6u+KOUAIizPil9/4nq31YOcmBxXA5BkBff0NcnX9y4PBLIZ+6E+3q5O9X+Nk7R HebKyMUwxVE3TJnRy/8mhwPW4vV5Vi/mj4guBe4m0mN6lzdNu1ZXuKKR+/KizZ6BtB/W 8KtHsnedL2dI18yX3YJZoFKVf5GswJoySopfQBWHxdGAqcmEIiKxr0ARtpRh1NQTx1Kf z0hS5FknIfaZBtvXnKrSQHvUWQp+tFzRo2Cm7f3x9d6aT8pHDa7OhSCrHVhT5NnhwI/l SZIZLNF+1C7IWygfyIan2bmaG3o7let4ldibp09roy9t55tQafURHcSPjaLsumea+A/n 73bg== X-Gm-Message-State: APf1xPDYIIqnM2AfS+KrAeN5r8M1OFU+DuJKwoXFK01xrMY1+T8DwbWt 4fnk8QkXJ8F4sXwNdk7AfsA= X-Google-Smtp-Source: AG47ELuZ+znZNbyay812IFbfiukqVhrdIF1C0MXxu6EkcU9E7rmUQ3wGoEt5UIN3mVvsDbF37CixxQ== X-Received: by 10.99.167.2 with SMTP id d2mr2053918pgf.408.1519923374224; Thu, 01 Mar 2018 08:56:14 -0800 (PST) Received: from squirtle.lan (c-24-22-235-96.hsd1.wa.comcast.net. [24.22.235.96]) by smtp.gmail.com with ESMTPSA id b8sm9500331pff.31.2018.03.01.08.56.12 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 01 Mar 2018 08:56:13 -0800 (PST) From: Andrey Smirnov To: Dmitry Torokhov Cc: Andrey Smirnov , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, Rob Herring , Mark Rutland , devicetree@vger.kernel.org, Guenter Roeck , Chris Healy , Lucas Stach Subject: [PATCH v2 1/2] input: Add RAVE SP Powerbutton driver Date: Thu, 1 Mar 2018 08:55:26 -0800 Message-Id: <20180301165527.22274-1-andrew.smirnov@gmail.com> X-Mailer: git-send-email 2.14.3 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 driver that properly handles input event emitted by RAVE SP devices. Cc: Dmitry Torokhov Cc: linux-input@vger.kernel.org Cc: linux-kernel@vger.kernel.org Cc: Rob Herring Cc: Mark Rutland Cc: devicetree@vger.kernel.org Cc: Guenter Roeck Cc: Chris Healy Cc: Lucas Stach Signed-off-by: Andrey Smirnov Reviewed-by: Lucas Stach --- Changes since [v1]: - Removed redundant dev.parent assignment - Various cosmetic changes [v1] lkml.kernel.org/r/20180226154130.25774-1-andrew.smirnov@gmail.com drivers/input/misc/Kconfig | 9 ++++ drivers/input/misc/Makefile | 1 + drivers/input/misc/rave-sp-pwrbutton.c | 94 ++++++++++++++++++++++++++++++++++ 3 files changed, 104 insertions(+) create mode 100644 drivers/input/misc/rave-sp-pwrbutton.c diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig index 62a1312a7387..6a3c753b093b 100644 --- a/drivers/input/misc/Kconfig +++ b/drivers/input/misc/Kconfig @@ -841,4 +841,13 @@ config INPUT_HISI_POWERKEY To compile this driver as a module, choose M here: the module will be called hisi_powerkey. +config INPUT_RAVE_SP_PWRBUTTON + tristate "RAVE SP Power button Driver" + depends on RAVE_SP_CORE + help + Say Y here if you want to enable power key reporting from RAVE SP + + To compile this driver as a module, choose M here: the + module will be called rave-sp-pwrbutton. + endif diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile index a8f61af865aa..8cc58f362bb8 100644 --- a/drivers/input/misc/Makefile +++ b/drivers/input/misc/Makefile @@ -60,6 +60,7 @@ obj-$(CONFIG_INPUT_PMIC8XXX_PWRKEY) += pmic8xxx-pwrkey.o obj-$(CONFIG_INPUT_POWERMATE) += powermate.o obj-$(CONFIG_INPUT_PWM_BEEPER) += pwm-beeper.o obj-$(CONFIG_INPUT_PWM_VIBRA) += pwm-vibra.o +obj-$(CONFIG_INPUT_RAVE_SP_PWRBUTTON) += rave-sp-pwrbutton.o obj-$(CONFIG_INPUT_RB532_BUTTON) += rb532_button.o obj-$(CONFIG_INPUT_REGULATOR_HAPTIC) += regulator-haptic.o obj-$(CONFIG_INPUT_RETU_PWRBUTTON) += retu-pwrbutton.o diff --git a/drivers/input/misc/rave-sp-pwrbutton.c b/drivers/input/misc/rave-sp-pwrbutton.c new file mode 100644 index 000000000000..bcab3cdb7ebd --- /dev/null +++ b/drivers/input/misc/rave-sp-pwrbutton.c @@ -0,0 +1,94 @@ +// SPDX-License-Identifier: GPL-2.0+ +// +// Power Button driver for RAVE SP +// +// Copyright (C) 2017 Zodiac Inflight Innovations +// +// + +#include +#include +#include +#include +#include + +#define RAVE_SP_EVNT_BUTTON_PRESS (RAVE_SP_EVNT_BASE + 0x00) + +struct rave_sp_power_button { + struct input_dev *idev; + struct notifier_block nb; +}; + +static int rave_sp_power_button_event(struct notifier_block *nb, + unsigned long action, void *data) +{ + struct rave_sp_power_button *pb = + container_of(nb, struct rave_sp_power_button, nb); + const u8 event = rave_sp_action_unpack_event(action); + const u8 value = rave_sp_action_unpack_value(action); + struct input_dev *idev = pb->idev; + + if (event == RAVE_SP_EVNT_BUTTON_PRESS) { + input_report_key(idev, KEY_POWER, value); + input_sync(idev); + + return NOTIFY_STOP; + } + + return NOTIFY_DONE; +} + +static int rave_sp_pwrbutton_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct rave_sp_power_button *pb; + struct input_dev *idev; + int error; + + pb = devm_kzalloc(dev, sizeof(*pb), GFP_KERNEL); + if (!pb) + return -ENOMEM; + + idev = devm_input_allocate_device(dev); + if (!idev) + return -ENOMEM; + + idev->name = pdev->name; + + input_set_capability(idev, EV_KEY, KEY_POWER); + + error = input_register_device(idev); + if (error) + return error; + + pb->idev = idev; + pb->nb.notifier_call = rave_sp_power_button_event; + pb->nb.priority = 128; + + error = devm_rave_sp_register_event_notifier(dev, &pb->nb); + if (error) + return error; + + return 0; +} + +static const struct of_device_id rave_sp_pwrbutton_of_match[] = { + { .compatible = "zii,rave-sp-pwrbutton" }, + {} +}; + +static struct platform_driver rave_sp_pwrbutton_driver = { + .probe = rave_sp_pwrbutton_probe, + .driver = { + .name = KBUILD_MODNAME, + .of_match_table = rave_sp_pwrbutton_of_match, + }, +}; +module_platform_driver(rave_sp_pwrbutton_driver); + +MODULE_DEVICE_TABLE(of, rave_sp_pwrbutton_of_match); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("Andrey Vostrikov "); +MODULE_AUTHOR("Nikita Yushchenko "); +MODULE_AUTHOR("Andrey Smirnov "); +MODULE_DESCRIPTION("RAVE SP Power Button driver");