Received: by 10.213.65.68 with SMTP id h4csp213627imn; Tue, 13 Mar 2018 01:37:37 -0700 (PDT) X-Google-Smtp-Source: AG47ELsYnNkty39f22+Q/gIb84ecL0pwoImCpEMTEamgjCmz5y7Dbc+3gYRFLNr0SlCCYj5ywQAI X-Received: by 2002:a17:902:4643:: with SMTP id o61-v6mr11212965pld.103.1520930257193; Tue, 13 Mar 2018 01:37:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520930257; cv=none; d=google.com; s=arc-20160816; b=LgV7K8r+S0Gb0blQqRVanww+H31plMMcGGq0UYQHV+BcmGbYgqdA/fA+Pm2CKMsmqA +3aIhaXzMcFrwObFn2YDTLEx9R5xgdwPYElPv/W8KmiHV+Q2MPP75Qh/7z1wqm9ZPyLa YKbPdwCMXy93PvIVVatoGCLGo9Hv0WBg1KZakXZy4U590aEPT4Y+v/2dW8Ags7SLi8/F FyuRCpA1aG3n38i0kKxqWyeO8C+JPej7lQ82nczPtLZJmLlsVg5/y4d6VfVcCNSh/aR6 4mB5p55hUya30M9RTdNI3eRUXR0ijpQnnO3ST4Ez0/7KxBCTLDjxk+u768+vqDzN1ONM oqPA== 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 :dmarc-filter:dkim-signature:dkim-signature :arc-authentication-results; bh=RVuAMHLfrXYXJw1psZt+GVCb8D4+Sy/oHQNb2KXuh84=; b=MJw/imNFHfBl6bvw8r5qUWHZekjhUm858qHelPaKiMV0aDtfAZWvkx/VKWVfCGeGpT wc1wsqWi7f27+fP5d31TOrcgRgh6dS4kSE5UXWNqk6vDbkJPXCFUNUG5wnuhK/QH1FWy QdEJPS/YAa4FSo04fi/+1aP2Ho/pAXi9j6aUJ0bXiU2Sc3IxDGPd/JU8e8y4JWNP4kiq hInWmCXFVxdcq5GrLPIptLK9Uk/ztYziv3a7i8xKxNAysHBMeq2dEJt/lQSosBfefh6Y LK+OBn4PSGH2naoeRTN+S30utNVUk9dMebtOnea4HxairTSguIqu5hSvlb32kLnhopZ/ 31dg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=FnhZnf9F; dkim=pass header.i=@codeaurora.org header.s=default header.b=cwgrLRrO; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z124si6214913pgb.811.2018.03.13.01.37.23; Tue, 13 Mar 2018 01:37:37 -0700 (PDT) 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=@codeaurora.org header.s=default header.b=FnhZnf9F; dkim=pass header.i=@codeaurora.org header.s=default header.b=cwgrLRrO; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752341AbeCMIgY (ORCPT + 99 others); Tue, 13 Mar 2018 04:36:24 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:54674 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752209AbeCMIgW (ORCPT ); Tue, 13 Mar 2018 04:36:22 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 89AB46016D; Tue, 13 Mar 2018 08:36:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1520930181; bh=QW1TIqx46UxIlTD/04QI4kK7Dr/kHQ3jKyemfGrNTnw=; h=From:To:Cc:Subject:Date:From; b=FnhZnf9Fvg6YwFYM6Q5VrAjKBNcTHTduuO6JXbV2Zdno6DXRCpM4HUvh+o9sNwsp7 EW1EgHe+6OFixqAus6bn0XG6Vf8a7fPijDi6tVwbHAOPdiVcfJmTQTxRZOd449hwwj CMSlWzHvV6J9JvtL82Rkgbk/u4tOCJAdqT2Q/cH4= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.0 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 22BFB60592; Tue, 13 Mar 2018 08:36:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1520930180; bh=QW1TIqx46UxIlTD/04QI4kK7Dr/kHQ3jKyemfGrNTnw=; h=From:To:Cc:Subject:Date:From; b=cwgrLRrOtiR0setBaFJ1DuUs3nnzKQ2heTmZNf8Aw7aeg0pXxBYcRxea925RB/Kur cgXPTkuRHem5DtapPh2Ii6e7veJlq807sz8bGOBufCD5SjGpb1uAY0g02SpZ3OfCTb M5i7TKHcDMrdjRYVy03EZVrbXmBqZLh7Al+RHN+U= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 22BFB60592 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 V2] Input: pm8941-pwrkey: add resin key capabilities Date: Tue, 13 Mar 2018 14:05:58 +0530 Message-Id: <1520930158-5854-1-git-send-email-tirupath@codeaurora.org> X-Mailer: git-send-email 1.9.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 | 65 +++++++++++++++++++++- 2 files changed, 83 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..f499cf8 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 and should be the first entry of the list. + "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..2fffc7c 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,7 @@ struct pm8941_pwrkey { struct device *dev; int irq; + u32 resin_key_code; u32 baseaddr; struct regmap *regmap; struct input_dev *input; @@ -130,6 +132,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,12 +173,40 @@ 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 irq) +{ + 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, 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; bool pull_up; u32 req_delay; - int error; + int error, resin_irq; if (of_property_read_u32(pdev->dev.of_node, "debounce", &req_delay)) req_delay = 15625; @@ -241,6 +289,21 @@ static int pm8941_pwrkey_probe(struct platform_device *pdev) return error; } + resin_irq = platform_get_irq_byname(pdev, "resin"); + if (resin_irq < 0 && resin_irq != -ENXIO) { + if (resin_irq != -EPROBE_DEFER) + dev_err(&pdev->dev, "failed to get resin irq\n"); + return resin_irq; + } else if (resin_irq >= 0) { + /* resin key capabilities are defined in device node */ + error = pm8941_resin_key_init(pwrkey, resin_irq); + 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", -- QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation