* [PATCH 0/2] Input: snvs_pwrkey - add configurable force shutdown time
@ 2025-03-13 11:44 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-13 11:44 ` [PATCH 2/2] Input: snvs_pwrkey - add configurable force shutdown time Ian Ray
0 siblings, 2 replies; 6+ messages in thread
From: Ian Ray @ 2025-03-13 11:44 UTC (permalink / raw)
To: dmitry.torokhov, robh, krzk+dt, conor+dt
Cc: ian.ray, linux-input, devicetree, linux-kernel
PATCH 1 - add documentation for new option
PATCH 2 - add support to driver
Ian Ray (2):
dt-bindings: crypto: fsl,sec-v4.0-mon: add optional force shutdown
time property
Input: snvs_pwrkey - add configurable force shutdown time
.../bindings/crypto/fsl,sec-v4.0-mon.yaml | 8 +++++++
drivers/input/keyboard/snvs_pwrkey.c | 24 +++++++++++++++++++
2 files changed, 32 insertions(+)
--
2.39.5
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/2] dt-bindings: crypto: fsl,sec-v4.0-mon: add optional force shutdown time property
2025-03-13 11:44 [PATCH 0/2] Input: snvs_pwrkey - add configurable force shutdown time Ian Ray
@ 2025-03-13 11:44 ` Ian Ray
2025-03-14 8:44 ` Krzysztof Kozlowski
2025-03-13 11:44 ` [PATCH 2/2] Input: snvs_pwrkey - add configurable force shutdown time Ian Ray
1 sibling, 1 reply; 6+ messages in thread
From: Ian Ray @ 2025-03-13 11:44 UTC (permalink / raw)
To: dmitry.torokhov, robh, krzk+dt, conor+dt
Cc: ian.ray, linux-input, devicetree, linux-kernel
Add an optional property to configure the force shutdown time.
Signed-off-by: Ian Ray <ian.ray@gehealthcare.com>
---
.../devicetree/bindings/crypto/fsl,sec-v4.0-mon.yaml | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/Documentation/devicetree/bindings/crypto/fsl,sec-v4.0-mon.yaml b/Documentation/devicetree/bindings/crypto/fsl,sec-v4.0-mon.yaml
index e879bc0be8e2..ee282c352535 100644
--- a/Documentation/devicetree/bindings/crypto/fsl,sec-v4.0-mon.yaml
+++ b/Documentation/devicetree/bindings/crypto/fsl,sec-v4.0-mon.yaml
@@ -111,6 +111,14 @@ properties:
maxItems: 1
default: 116
+ force-shutdown-time:
+ description: |
+ Configure the long-press force shutdown time.
+ Setting this value to zero disables the long-press detection.
+ $ref: /schemas/types.yaml#/definitions/uint32
+ enum: [0, 5, 10, 15]
+ default: 5
+
required:
- compatible
- interrupts
--
2.39.5
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/2] Input: snvs_pwrkey - add configurable force shutdown time
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-13 11:44 ` Ian Ray
2025-03-13 12:22 ` Ian Ray
1 sibling, 1 reply; 6+ messages in thread
From: Ian Ray @ 2025-03-13 11:44 UTC (permalink / raw)
To: dmitry.torokhov, robh, krzk+dt, conor+dt
Cc: ian.ray, linux-input, devicetree, linux-kernel
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>;
+};
+
&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
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] Input: snvs_pwrkey - add configurable force shutdown time
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
0 siblings, 0 replies; 6+ messages in thread
From: Ian Ray @ 2025-03-13 12:22 UTC (permalink / raw)
To: dmitry.torokhov, robh, krzk+dt, conor+dt
Cc: linux-input, devicetree, linux-kernel, ian.ray
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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] dt-bindings: crypto: fsl,sec-v4.0-mon: add optional force shutdown time property
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
0 siblings, 1 reply; 6+ messages in thread
From: Krzysztof Kozlowski @ 2025-03-14 8:44 UTC (permalink / raw)
To: Ian Ray
Cc: dmitry.torokhov, robh, krzk+dt, conor+dt, linux-input, devicetree,
linux-kernel
On Thu, Mar 13, 2025 at 01:44:52PM +0200, Ian Ray wrote:
> Add an optional property to configure the force shutdown time.
And why is this hardware property? You described the desired Linux
feature or behavior, not the actual hardware. The bindings are about the
latter, so instead you need to rephrase the property and its description
to match actual hardware capabilities/features/configuration etc.
>
> Signed-off-by: Ian Ray <ian.ray@gehealthcare.com>
> ---
> .../devicetree/bindings/crypto/fsl,sec-v4.0-mon.yaml | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/crypto/fsl,sec-v4.0-mon.yaml b/Documentation/devicetree/bindings/crypto/fsl,sec-v4.0-mon.yaml
> index e879bc0be8e2..ee282c352535 100644
> --- a/Documentation/devicetree/bindings/crypto/fsl,sec-v4.0-mon.yaml
> +++ b/Documentation/devicetree/bindings/crypto/fsl,sec-v4.0-mon.yaml
> @@ -111,6 +111,14 @@ properties:
> maxItems: 1
> default: 116
>
> + force-shutdown-time:
Missing unit suffix
Missing vendor prefix
> + description: |
Do not need '|' unless you need to preserve formatting.
> + Configure the long-press force shutdown time.
> + Setting this value to zero disables the long-press detection.
> + $ref: /schemas/types.yaml#/definitions/uint32
> + enum: [0, 5, 10, 15]
> + default: 5
Why existing power-off-time-sec does not work? Isn't input schema
already referenced for this node? Looks like you are duplicating things
for no gain.
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] dt-bindings: crypto: fsl,sec-v4.0-mon: add optional force shutdown time property
2025-03-14 8:44 ` Krzysztof Kozlowski
@ 2025-03-14 8:48 ` Ian Ray
0 siblings, 0 replies; 6+ messages in thread
From: Ian Ray @ 2025-03-14 8:48 UTC (permalink / raw)
To: Krzysztof Kozlowski
Cc: dmitry.torokhov, robh, krzk+dt, conor+dt, linux-input, devicetree,
linux-kernel
On Fri, Mar 14, 2025 at 09:44:03AM +0100, Krzysztof Kozlowski wrote:
> On Thu, Mar 13, 2025 at 01:44:52PM +0200, Ian Ray wrote:
> > Add an optional property to configure the force shutdown time.
>
> And why is this hardware property? You described the desired Linux
> feature or behavior, not the actual hardware. The bindings are about the
> latter, so instead you need to rephrase the property and its description
> to match actual hardware capabilities/features/configuration etc.
>
>
> >
> > Signed-off-by: Ian Ray <ian.ray@gehealthcare.com>
> > ---
> > .../devicetree/bindings/crypto/fsl,sec-v4.0-mon.yaml | 8 ++++++++
> > 1 file changed, 8 insertions(+)
> >
> > diff --git a/Documentation/devicetree/bindings/crypto/fsl,sec-v4.0-mon.yaml b/Documentation/devicetree/bindings/crypto/fsl,sec-v4.0-mon.yaml
> > index e879bc0be8e2..ee282c352535 100644
> > --- a/Documentation/devicetree/bindings/crypto/fsl,sec-v4.0-mon.yaml
> > +++ b/Documentation/devicetree/bindings/crypto/fsl,sec-v4.0-mon.yaml
> > @@ -111,6 +111,14 @@ properties:
> > maxItems: 1
> > default: 116
> >
> > + force-shutdown-time:
>
> Missing unit suffix
>
> Missing vendor prefix
>
> > + description: |
>
> Do not need '|' unless you need to preserve formatting.
>
> > + Configure the long-press force shutdown time.
> > + Setting this value to zero disables the long-press detection.
> > + $ref: /schemas/types.yaml#/definitions/uint32
> > + enum: [0, 5, 10, 15]
> > + default: 5
>
> Why existing power-off-time-sec does not work? Isn't input schema
> already referenced for this node? Looks like you are duplicating things
> for no gain.
Thank you -- I somehow completely missed the existing property (which as
you note) is exactly what's needed.
I will send a V2 which uses the existing property.
>
> Best regards,
> Krzysztof
Thank you for the review,
Ian
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-03-14 8:48 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 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).