Received: by 10.223.185.116 with SMTP id b49csp4768685wrg; Wed, 7 Mar 2018 00:11:33 -0800 (PST) X-Google-Smtp-Source: AG47ELt41/CDqfj80fSEtbOkr5Ueq60SAR4bCgXl7B5o4C3XnFNc61hRatfExn26/gbPJQCedF1E X-Received: by 10.101.101.78 with SMTP id a14mr17276388pgw.368.1520410293288; Wed, 07 Mar 2018 00:11:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520410293; cv=none; d=google.com; s=arc-20160816; b=mUjyp5PPK1N7k/ctq1kRsR3ESifnxVKutg+RAsiyvHD1gNbyKgRX+mhTDYpftbhR/U gRgS5EjgREonGyD25vVf9Uxqlt1FloZ0P8Co8OdvIJc/If+uMj//8eI7jY5sDI4U4kVb NMojdrtMu0C3Ym2SUi8BI+gwfDNUPTsHFenfKqPTG5YGMpwt40GoMsJHM7idZ3epnaz0 pteBaxQOtSO3+12T+a7HxY8sbpIRbUAl9ifTXSovtKiInjIabDn8rprRSMvSEAMDDrlg f5nQs3IurloT4gU5SXtEXPPUz8mvEsMUgswNSBuy5l232VpmodtATSRKJA7iy1nStz04 18/w== 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=4Fcy11Z958FGCA2Hqr0ZNMjbRZiEBxmdkEGKQ6VvnS0=; b=EG82OBlMWzWLCLsHN8meoW5CtzuCqk0+WQf3NdI7bbxFTJYLQKzIG4kE+c2/t/iCH+ X5xsksrGugGm2JgfImVRORPmFjuslFqJ1JI1CKWFCZZ3xO488V9n5XUxKwbuqI+940qN c/sJHQI+Tw88PIXnqln6cglrZvn9rv/hL7ErpswpQkFAveuYhTEyDjN/TY6SxJJ13DyJ yz6zBACCiuADGPdv0v0hG0srLkldIAVi6YaP4i6nb63vJ/jBLVeZxQGZXbjMHrZZEHed hx0VlW34z6LTyberqX+BkRemXtBzd5VtRKWfY6vZE7CfHGu2R2eVx8tB8i+3sdH7nwJo l5nQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=IR7EJ9ij; dkim=pass header.i=@codeaurora.org header.s=default header.b=kY1afjC/; 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 u76si11060677pgc.218.2018.03.07.00.11.16; Wed, 07 Mar 2018 00:11:33 -0800 (PST) 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=IR7EJ9ij; dkim=pass header.i=@codeaurora.org header.s=default header.b=kY1afjC/; 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 S932687AbeCGIKU (ORCPT + 99 others); Wed, 7 Mar 2018 03:10:20 -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= 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 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-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 | 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", -- QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation