Received: by 10.213.65.68 with SMTP id h4csp209527imn; Tue, 13 Mar 2018 01:26:51 -0700 (PDT) X-Google-Smtp-Source: AG47ELueiYhCpgGV2+ARId+67oBFjcIIVXtK3PAz9Nn36wCcaB6CK/kNNXRgq8CAIuIjukaW1m/E X-Received: by 2002:a17:902:aa8e:: with SMTP id d14-v6mr10998702plr.318.1520929611578; Tue, 13 Mar 2018 01:26:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520929611; cv=none; d=google.com; s=arc-20160816; b=WFH4uaeyee9FF+ZDQ/gZYFPsbf38tdxVDAhFBO6RESGrr2Hy84ymFwfZwyKF0xPov3 ddmLEdRqQ8djobaVho24NFmEFr1ETKRR9YBVq4tKLHdWXf6oOyUaJX3znDmfglf8a835 94wHNGOigX+ORHwzBuA8yDarozKnYS74lv2TGQId8r+r/PmHmNZ8Nhalc9raZcIqg+JD zLTf30Wk4mSK8HxdefouYkfmrbdYZiXyAFsB74Eku8NmpnM8TxqU5lkSERL371XMoysq 4EACcz0DIU/CuJLmg6CTAtuevVHe/hRtsOLpzMpj9EABqhXNNOavnlEuYlHsbQsxQlM+ 8wNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dmarc-filter :dkim-signature:dkim-signature:arc-authentication-results; bh=3YFtXRJLNhKap+GpbP0D5mAKxQ9QxPECsyPH3fmMmvA=; b=pn+OSwnj3bTcV0INC1ymbEvjbbGTUJOT0e6hwuMt2KqdzAkWWUOygMfPyBits516Cq wGtvSewq8C1Bt6qDQ4IXMvGsCxcj18wUVg4JAgVv9B9/nb/3FDfDdYyLbgQ4VHk2ou90 lyWwD4heg8RgHar5Kf6Uh6khS77rTPJ532LKYRH5Gz4qok1LX5g+wDEyHcKpnpoJ6dTI gf4HlhOgQDDRIrwoXqu4LCBc4JaGPh/swBhpjL5Od+ih5X9hqFn0RnIx84y3PQwByWc1 /8NQYLGuztg6F4I6Dlc6r6Skp72ZIDfy7wX6QXSrIml3yItNbJllN4zBawFrchGydMkp ZhYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=GHBs4u6Y; dkim=pass header.i=@codeaurora.org header.s=default header.b=RWmWL0tg; 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 p14si6158163pgn.333.2018.03.13.01.26.36; Tue, 13 Mar 2018 01:26:51 -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=GHBs4u6Y; dkim=pass header.i=@codeaurora.org header.s=default header.b=RWmWL0tg; 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 S1752395AbeCMIZK (ORCPT + 99 others); Tue, 13 Mar 2018 04:25:10 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:49506 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752007AbeCMIZI (ORCPT ); Tue, 13 Mar 2018 04:25:08 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id BBEB060851; Tue, 13 Mar 2018 08:25:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1520929507; bh=eyfdnk+Sv9v4uNPxiYpSnZhkQKgElnRi6lc0TiE3UFA=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=GHBs4u6YkMOL+tBcy7SoOQv0ttxl0MabLIIkajtT05uOJ9t4W11TfJ2oUlbm3do97 7oNnV5K8VP9MH65cUBpc0RgBBNpKbbRoACSXBDmIQm8YYfYlau7UkxmrD/mChzwUvJ nNdh8n5QYdtITRFW9SaHTLzUp+NyrObH6UzYJYXo= 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 [10.206.28.83] (blr-c-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.19.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: tirupath@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id B5DFE60590; Tue, 13 Mar 2018 08:25:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1520929506; bh=eyfdnk+Sv9v4uNPxiYpSnZhkQKgElnRi6lc0TiE3UFA=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=RWmWL0tgkPyegqBHGkNZmoptNlIWr7isSzXz3eShqdixtRo7o+xIXupJ26SJ86Vti v/kUnOCdy0oOHcPb5Y2PcdEK8qY+DZisZ51zXZMwpFPg2xFrgQVrgjEbSIUe0LffKE WVdIz3lLCX18tIw8MS5V2XiqoI/OkYzaUbRGjhpE= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org B5DFE60590 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 Subject: Re: [PATCH V1] Input: pm8941-pwrkey: add resin key capabilities To: Dmitry Torokhov Cc: robh+dt@kernel.org, mark.rutland@arm.com, linux-input@vger.kernel.org, linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org References: <1520410173-2507-1-git-send-email-tirupath@codeaurora.org> <20180307202147.GB195580@dtor-ws> <20180310182714.GD260013@dtor-ws> From: Tirupathi Reddy T Message-ID: Date: Tue, 13 Mar 2018 13:55:02 +0530 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <20180310182714.GD260013@dtor-ws> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Dmitry, On 3/10/2018 11:57 PM, Dmitry Torokhov wrote: > On Wed, Mar 07, 2018 at 12:21:47PM -0800, Dmitry Torokhov wrote: >> Hi Tirupathi, >> >> On Wed, Mar 07, 2018 at 01:39:33PM +0530, Tirupathi Reddy wrote: >>> Add resin key support to handle different types of key events >>> defined in different platforms. > Also, when you say "resin" key, I do not suppose it refers to teh > material of the key, but rather have something to so with "reset in" > signal or similar when is not actually used for resetting the device? The resin is a "reset in" line to the "Power Management IC". Usually in a regular usecase this line is used for "volume down key" functionality and in other cases to reset the device on a long-press. >>> 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; >> It looks like you are reading the same register as the power on key. >> Won't you lose events if both are pressed at the same time? >> >> I think you need a unified interrupt handler... We are reading the real-time status register where both these bits would be set and the PMIC arb would dispatch 2 interrupts. >>> + >>> + 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"); >> You are breaking support for old DTS here I'm afraid. Correct. The other way to address it is keep old code and enforce kpdpwr interrupt should be the first one in interrupt list. Addressed in Patch V2. >>> 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) { >> This is not entirely correct. I'd say if you have -ENXIO you can >> conclude that the support for "resin" key is not enabled, but the rest >> of the errors you should report up the stack. Deferrals will be retried >> and other errors are fatal. Addressed in Patch V2. >>> + /* 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 >>> >> Thanks. >> >> -- >> Dmitry