linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ian Ray <ian.ray@gehealthcare.com>
To: dmitry.torokhov@gmail.com, robh@kernel.org, krzk+dt@kernel.org,
	conor+dt@kernel.org
Cc: linux-input@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org, ian.ray@gehealthcare.com
Subject: Re: [PATCH 2/2] Input: snvs_pwrkey - add configurable force shutdown time
Date: Thu, 13 Mar 2025 14:22:03 +0200	[thread overview]
Message-ID: <Z9LN63R1IhMDieP7@782be41d2a0d> (raw)
In-Reply-To: <20250313114453.702-3-ian.ray@gehealthcare.com>

On Thu, Mar 13, 2025 at 01:44:53PM +0200, Ian Ray wrote:
> Support configurable shutdown period using a new, optional, device tree
> property.
> 
> The force shutdown time is configured in LPCR[17:16] BTN_PRESS_TIME:
> 
>  * b00:  5 seconds (SoC default)
>  * b01: 10 seconds
>  * b10: 15 seconds
>  * b11: PMIC is not disabled
> 
> Signed-off-by: Ian Ray <ian.ray@gehealthcare.com>
> ---
>  .../arm64/boot/dts/freescale/imx8mp-ppdv2.dts |  4 ++++
>  drivers/input/keyboard/snvs_pwrkey.c          | 24 +++++++++++++++++++
>  2 files changed, 28 insertions(+)
> 
> diff --git a/arch/arm64/boot/dts/freescale/imx8mp-ppdv2.dts b/arch/arm64/boot/dts/freescale/imx8mp-ppdv2.dts
> index 7cc427f23e59..921eda35154a 100644
> --- a/arch/arm64/boot/dts/freescale/imx8mp-ppdv2.dts
> +++ b/arch/arm64/boot/dts/freescale/imx8mp-ppdv2.dts
> @@ -699,6 +699,10 @@ &pinctrl_usdhc2_200mhz {
>  		<MX8MP_IOMUXC_GPIO1_IO04__GPIO1_IO04		0x106>;
>  };
>  
> +&snvs_pwrkey {
> +	force-shutdown-time = <0>;
> +};
> +

Sorry, please disregard this hunk which was accidentally included.
(Should I send a V2?)


>  &usdhc2 {
>  	/delete-property/ cd-gpios;
>  	/delete-property/ wp-gpios;
> diff --git a/drivers/input/keyboard/snvs_pwrkey.c b/drivers/input/keyboard/snvs_pwrkey.c
> index f7b5f1e25c80..2ba848df061c 100644
> --- a/drivers/input/keyboard/snvs_pwrkey.c
> +++ b/drivers/input/keyboard/snvs_pwrkey.c
> @@ -27,7 +27,10 @@
>  #define SNVS_HPSR_BTN		BIT(6)
>  #define SNVS_LPSR_SPO		BIT(18)
>  #define SNVS_LPCR_DEP_EN	BIT(5)
> +#define SNVS_LPCR_BPT_SHIFT	16
> +#define SNVS_LPCR_BPT_MASK	(3 << SNVS_LPCR_BPT_SHIFT)
>  
> +#define FORCE_SHUTDOWN_TIME	5	/* LPCR 17:16 default */
>  #define DEBOUNCE_TIME		30
>  #define REPEAT_INTERVAL		60
>  
> @@ -114,6 +117,8 @@ static int imx_snvs_pwrkey_probe(struct platform_device *pdev)
>  	struct device_node *np;
>  	struct clk *clk;
>  	int error;
> +	int force_shutdown_time;
> +	int bpt;
>  	u32 vid;
>  
>  	/* Get SNVS register Page */
> @@ -148,11 +153,30 @@ static int imx_snvs_pwrkey_probe(struct platform_device *pdev)
>  	if (pdata->irq < 0)
>  		return -EINVAL;
>  
> +	force_shutdown_time = FORCE_SHUTDOWN_TIME;
> +	of_property_read_u32(np, "force-shutdown-time", &force_shutdown_time);
> +	switch (force_shutdown_time) {
> +		case 0:
> +			/* Disable long-press detection. */
> +			bpt = 0x3;
> +			break;
> +		case 5:
> +		case 10:
> +		case 15:
> +			bpt = (force_shutdown_time / 5) - 1;
> +			break;
> +		default:
> +			dev_err(&pdev->dev, "Invalid force-shutdown-time %d\n", force_shutdown_time);
> +			return -EINVAL;
> +	}
> +
>  	regmap_read(pdata->snvs, SNVS_HPVIDR1_REG, &vid);
>  	pdata->minor_rev = vid & 0xff;
>  
>  	regmap_update_bits(pdata->snvs, SNVS_LPCR_REG, SNVS_LPCR_DEP_EN, SNVS_LPCR_DEP_EN);
>  
> +	regmap_update_bits(pdata->snvs, SNVS_LPCR_REG, SNVS_LPCR_BPT_MASK, bpt << SNVS_LPCR_BPT_SHIFT);
> +
>  	/* clear the unexpected interrupt before driver ready */
>  	regmap_write(pdata->snvs, SNVS_LPSR_REG, SNVS_LPSR_SPO);
>  
> -- 
> 2.39.5

      reply	other threads:[~2025-03-13 12:22 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-13 11:44 [PATCH 0/2] Input: snvs_pwrkey - add configurable force shutdown time Ian Ray
2025-03-13 11:44 ` [PATCH 1/2] dt-bindings: crypto: fsl,sec-v4.0-mon: add optional force shutdown time property Ian Ray
2025-03-14  8:44   ` Krzysztof Kozlowski
2025-03-14  8:48     ` Ian Ray
2025-03-13 11:44 ` [PATCH 2/2] Input: snvs_pwrkey - add configurable force shutdown time Ian Ray
2025-03-13 12:22   ` Ian Ray [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Z9LN63R1IhMDieP7@782be41d2a0d \
    --to=ian.ray@gehealthcare.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=krzk+dt@kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robh@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).