From patchwork Wed Mar 7 08:09:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tirupathi Reddy X-Patchwork-Id: 10263549 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 4F48F60211 for ; Wed, 7 Mar 2018 08:10:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3C42E28434 for ; Wed, 7 Mar 2018 08:10:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3A53129458; Wed, 7 Mar 2018 08:10:34 +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_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 CB8972946B for ; Wed, 7 Mar 2018 08:10:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751207AbeCGIKS (ORCPT ); Wed, 7 Mar 2018 03:10:18 -0500 Received: from smtp.codeaurora.org ([198.145.29.96]:53048 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751083AbeCGIKJ (ORCPT ); Wed, 7 Mar 2018 03:10:09 -0500 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id A598560398; Wed, 7 Mar 2018 08:10:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1520410208; bh=B2E8tmbw2yZrfVTDfavM9BoZZoIX31GLvPr8SCMgYIQ=; h=From:To:Cc:Subject:Date:From; b=IR7EJ9ij4yjjEDu3CsBcr9lz/TLpczxMXdCceNJkqLZZdKJVyNaFobIA8ngJ5oKwa hPEIgD4UX8JvLEaROdnk6NcXmtyoH0sK7JGEK8QBAVJ5wjJpffUDb6yMUEnJhKTgin mf4h5QsM7qtsaukH3lI37+XPr8/SeVeOknRFnLYQ= Received: from tirupath-linux.qualcomm.com (blr-c-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.19.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: tirupath@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id E34D7602A0; Wed, 7 Mar 2018 08:10:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1520410207; bh=B2E8tmbw2yZrfVTDfavM9BoZZoIX31GLvPr8SCMgYIQ=; h=From:To:Cc:Subject:Date:From; b=kY1afjC/2FDYfvBhqxVTWESmHPVj8PGHnKq0rAqWbzCBDe4nFrfgT58gRjLbsNSmH MLk42BsuUhq+EZQhH3BUrAfL2Y+rX/sD9fMrEE0ecUbU0NIhwD7T6lsewMvfxv11Lw ff9e4HMp8GofJlWwtSU1hvZ/IA4eP7H/ZwHoYsDo= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org E34D7602A0 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=tirupath@codeaurora.org From: Tirupathi Reddy To: dmitry.torokhov@gmail.com, robh+dt@kernel.org, mark.rutland@arm.com Cc: tirupath@codeaurora.org, linux-input@vger.kernel.org, linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH V1] Input: pm8941-pwrkey: add resin key capabilities Date: Wed, 7 Mar 2018 13:39:33 +0530 Message-Id: <1520410173-2507-1-git-send-email-tirupath@codeaurora.org> X-Mailer: git-send-email 1.9.1 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 resin key support to handle different types of key events defined in different platforms. Signed-off-by: Tirupathi Reddy --- .../bindings/input/qcom,pm8941-pwrkey.txt | 20 ++++++- drivers/input/misc/pm8941-pwrkey.c | 63 +++++++++++++++++++++- 2 files changed, 81 insertions(+), 2 deletions(-) diff --git a/Documentation/devicetree/bindings/input/qcom,pm8941-pwrkey.txt b/Documentation/devicetree/bindings/input/qcom,pm8941-pwrkey.txt index 07bf55f..1c437e9 100644 --- a/Documentation/devicetree/bindings/input/qcom,pm8941-pwrkey.txt +++ b/Documentation/devicetree/bindings/input/qcom,pm8941-pwrkey.txt @@ -20,6 +20,14 @@ PROPERTIES defined by the binding document describing the node's interrupt parent. +- interrupt-names: + Usage: required + Value type: + Definition: Interrupt names. This list must match up 1-to-1 with the + interrupts specified in the 'interrupts' property. "kpdpwr" + must be specified. "resin" may be specified for some + platforms. + - debounce: Usage: optional Value type: @@ -32,12 +40,22 @@ PROPERTIES Definition: presence of this property indicates that the KPDPWR_N pin should be configured for pull up. +- linux,code: + Usage: required for "resin" key + Value type: + Definition: The input key-code associated with the resin key. + Use the linux event codes defined in + include/dt-bindings/input/linux-event-codes.h + EXAMPLE pwrkey@800 { compatible = "qcom,pm8941-pwrkey"; reg = <0x800>; - interrupts = <0x0 0x8 0 IRQ_TYPE_EDGE_BOTH>; + interrupts = <0x0 0x8 0 IRQ_TYPE_EDGE_BOTH>, + <0x0 0x8 1 IRQ_TYPE_EDGE_BOTH>; + interrupt-names = "kpdpwr", "resin"; debounce = <15625>; bias-pull-up; + linux,code = ; }; diff --git a/drivers/input/misc/pm8941-pwrkey.c b/drivers/input/misc/pm8941-pwrkey.c index 18ad956..3f801cf 100644 --- a/drivers/input/misc/pm8941-pwrkey.c +++ b/drivers/input/misc/pm8941-pwrkey.c @@ -28,6 +28,7 @@ #define PON_RT_STS 0x10 #define PON_KPDPWR_N_SET BIT(0) +#define PON_RESIN_N_SET BIT(1) #define PON_PS_HOLD_RST_CTL 0x5a #define PON_PS_HOLD_RST_CTL2 0x5b @@ -46,6 +47,8 @@ struct pm8941_pwrkey { struct device *dev; int irq; + int resin_irq; + u32 resin_key_code; u32 baseaddr; struct regmap *regmap; struct input_dev *input; @@ -130,6 +133,24 @@ static irqreturn_t pm8941_pwrkey_irq(int irq, void *_data) return IRQ_HANDLED; } +static irqreturn_t pm8941_resinkey_irq(int irq, void *_data) +{ + struct pm8941_pwrkey *pwrkey = _data; + unsigned int sts; + int error; + + error = regmap_read(pwrkey->regmap, + pwrkey->baseaddr + PON_RT_STS, &sts); + if (error) + return IRQ_HANDLED; + + input_report_key(pwrkey->input, pwrkey->resin_key_code, + !!(sts & PON_RESIN_N_SET)); + input_sync(pwrkey->input); + + return IRQ_HANDLED; +} + static int __maybe_unused pm8941_pwrkey_suspend(struct device *dev) { struct pm8941_pwrkey *pwrkey = dev_get_drvdata(dev); @@ -153,6 +174,35 @@ static int __maybe_unused pm8941_pwrkey_resume(struct device *dev) static SIMPLE_DEV_PM_OPS(pm8941_pwr_key_pm_ops, pm8941_pwrkey_suspend, pm8941_pwrkey_resume); +static int pm8941_resin_key_init(struct pm8941_pwrkey *pwrkey) +{ + int error; + + /* + * Get the standard-key parameters. This might not be + * specified if there is no key mapping on the reset line. + */ + error = of_property_read_u32(pwrkey->dev->of_node, "linux,code", + &pwrkey->resin_key_code); + if (error) { + dev_err(pwrkey->dev, "failed to read key-code for resin key\n"); + return error; + } + + /* Register key configuration */ + input_set_capability(pwrkey->input, EV_KEY, pwrkey->resin_key_code); + + error = devm_request_threaded_irq(pwrkey->dev, pwrkey->resin_irq, + NULL, pm8941_resinkey_irq, + IRQF_ONESHOT, + "pm8941_resinkey", pwrkey); + if (error) + dev_err(pwrkey->dev, "failed requesting resin key IRQ: %d\n", + error); + + return error; +} + static int pm8941_pwrkey_probe(struct platform_device *pdev) { struct pm8941_pwrkey *pwrkey; @@ -182,7 +232,7 @@ static int pm8941_pwrkey_probe(struct platform_device *pdev) return -ENODEV; } - pwrkey->irq = platform_get_irq(pdev, 0); + pwrkey->irq = platform_get_irq_byname(pdev, "kpdpwr"); if (pwrkey->irq < 0) { dev_err(&pdev->dev, "failed to get irq\n"); return pwrkey->irq; @@ -241,6 +291,17 @@ static int pm8941_pwrkey_probe(struct platform_device *pdev) return error; } + pwrkey->resin_irq = platform_get_irq_byname(pdev, "resin"); + if (pwrkey->resin_irq >= 0) { + /* resin key capabilities are defined in device node */ + error = pm8941_resin_key_init(pwrkey); + if (error) { + dev_err(&pdev->dev, "failed resin key initialization: %d\n", + error); + return error; + } + } + error = input_register_device(pwrkey->input); if (error) { dev_err(&pdev->dev, "failed to register input device: %d\n",