From: Robin van der Gracht <robin@protonic.nl> Date: 2019-08-27 12:31:51
The first generation i.MX6 processors does not send an interrupt when the
power key is pressed. It sends a power down request interrupt if the key is
released before a hard shutdown (5 second press). This should allow
software to bring down the SoC safely.
For this driver to work as a regular power key with the older SoCs, we need
to send a keypress AND release when we get the power down request irq.
Signed-off-by: Robin van der Gracht <robin@protonic.nl>
---
.../devicetree/bindings/crypto/fsl-sec4.txt | 16 ++++--
drivers/input/keyboard/Kconfig | 2 +-
drivers/input/keyboard/snvs_pwrkey.c | 52 ++++++++++++++++---
3 files changed, 57 insertions(+), 13 deletions(-)
@@ -420,14 +420,22 @@ EXAMPLE ===================================================================== System ON/OFF key driver- The snvs-pwrkey is designed to enable POWER key function which controlled- by SNVS ONOFF, the driver can report the status of POWER key and wakeup- system if pressed after system suspend.+ The snvs-pwrkey is designed to enable POWER key function which is controlled+ by SNVS ONOFF. It can wakeup the system if pressed after system suspend.++ There are two generations of SVNS pwrkey hardware. The first generation is+ included in i.MX6 Solo, DualLite and Quad processors. The second generation+ is included in i.MX6 SoloX and newer SoCs.++ Second generation SNVS can detect and report the status of POWER key, but the+ first generation can only detect a key release and so emits an instantaneous+ press and release event when the key is released. - compatible: Usage: required Value type: <string>- Definition: Mush include "fsl,sec-v4.0-pwrkey".+ Definition: Must include "fsl,sec-v4.0-pwrkey" for i.MX6 SoloX and newer+ or "fsl,imx6qdl-snvs-pwrkey" for older SoCs. - interrupts: Usage: required
@@ -93,6 +129,7 @@ static int imx_snvs_pwrkey_probe(struct platform_device *pdev)structpwrkey_drv_data*pdata=NULL;structinput_dev*input=NULL;structdevice_node*np;+conststructof_device_id*match;interror;/* Get SNVS register Page */
@@ -100,6 +137,10 @@ static int imx_snvs_pwrkey_probe(struct platform_device *pdev)if(!np)return-ENODEV;+match=of_match_node(imx_snvs_pwrkey_ids,np);+if(!match)+return-ENODEV;+pdata=devm_kzalloc(&pdev->dev,sizeof(*pdata),GFP_KERNEL);if(!pdata)return-ENOMEM;
@@ -115,6 +156,7 @@ static int imx_snvs_pwrkey_probe(struct platform_device *pdev)dev_warn(&pdev->dev,"KEY_POWER without setting in dts\n");}+pdata->hwtype=(enumimx_snvs_hwtype)match->data;pdata->wakeup=of_property_read_bool(np,"wakeup-source");pdata->irq=platform_get_irq(pdev,0);
From: Robin van der Gracht <robin@protonic.nl> Date: 2019-08-27 12:31:55
The older imx6 SoCs do not send a power key press interrupt, instead it
sends a power down request interrupt when the key is released between
750ms and 5 seconds. The driver uses a different compatible string to ID
the older SoCs.
Signed-off-by: Robin van der Gracht <robin@protonic.nl>
---
arch/arm/boot/dts/imx6qdl.dtsi | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
From: Marco Felsch <hidden> Date: 2019-08-28 09:16:03
Hi Robin,
thanks for the patch.
On 19-08-27 14:32, Robin van der Gracht wrote:
The first generation i.MX6 processors does not send an interrupt when the
power key is pressed. It sends a power down request interrupt if the key is
released before a hard shutdown (5 second press). This should allow
software to bring down the SoC safely.
For this driver to work as a regular power key with the older SoCs, we need
to send a keypress AND release when we get the power down request irq.
Signed-off-by: Robin van der Gracht <robin@protonic.nl>
---
.../devicetree/bindings/crypto/fsl-sec4.txt | 16 ++++--
drivers/input/keyboard/Kconfig | 2 +-
drivers/input/keyboard/snvs_pwrkey.c | 52 ++++++++++++++++---
Can we split this so the dt-bindings are a standalone patch? IMHO this
is the usual way because the maintainer can squash them on there needs.
Also it would be cool to document the changes. A common place for
changes is after the '---' or on the cover-letter.
@@ -420,14 +420,22 @@ EXAMPLE ===================================================================== System ON/OFF key driver- The snvs-pwrkey is designed to enable POWER key function which controlled- by SNVS ONOFF, the driver can report the status of POWER key and wakeup- system if pressed after system suspend.+ The snvs-pwrkey is designed to enable POWER key function which is controlled+ by SNVS ONOFF. It can wakeup the system if pressed after system suspend.++ There are two generations of SVNS pwrkey hardware. The first generation is+ included in i.MX6 Solo, DualLite and Quad processors. The second generation+ is included in i.MX6 SoloX and newer SoCs.++ Second generation SNVS can detect and report the status of POWER key, but the+ first generation can only detect a key release and so emits an instantaneous+ press and release event when the key is released. - compatible: Usage: required Value type: <string>- Definition: Mush include "fsl,sec-v4.0-pwrkey".+ Definition: Must include "fsl,sec-v4.0-pwrkey" for i.MX6 SoloX and newer+ or "fsl,imx6qdl-snvs-pwrkey" for older SoCs. - interrupts: Usage: required
@@ -100,6 +137,10 @@ static int imx_snvs_pwrkey_probe(struct platform_device *pdev) if (!np) return -ENODEV;+ match = of_match_node(imx_snvs_pwrkey_ids, np);+ if (!match)+ return -ENODEV;
... of_device_get_match_data() here. While reading the rm it seems that
the snvs block has a dedicated version register. IMHO this could be a
better way to apply the change also to existing devices with old
firmware.
Regards,
Marco
quoted hunk
+
pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
if (!pdata)
return -ENOMEM;
@@ -115,6 +156,7 @@ static int imx_snvs_pwrkey_probe(struct platform_device *pdev) dev_warn(&pdev->dev, "KEY_POWER without setting in dts\n"); }+ pdata->hwtype = (enum imx_snvs_hwtype)match->data; pdata->wakeup = of_property_read_bool(np, "wakeup-source"); pdata->irq = platform_get_irq(pdev, 0);
From: robin <robin@protonic.nl> Date: 2019-08-29 07:24:15
Hi Marco,
On 2019-08-28 11:15, Marco Felsch wrote:
Hi Robin,
thanks for the patch.
On 19-08-27 14:32, Robin van der Gracht wrote:
quoted
The first generation i.MX6 processors does not send an interrupt when
the
power key is pressed. It sends a power down request interrupt if the
key is
released before a hard shutdown (5 second press). This should allow
software to bring down the SoC safely.
For this driver to work as a regular power key with the older SoCs, we
need
to send a keypress AND release when we get the power down request irq.
Signed-off-by: Robin van der Gracht <robin@protonic.nl>
---
.../devicetree/bindings/crypto/fsl-sec4.txt | 16 ++++--
drivers/input/keyboard/Kconfig | 2 +-
drivers/input/keyboard/snvs_pwrkey.c | 52
++++++++++++++++---
Can we split this so the dt-bindings are a standalone patch? IMHO this
is the usual way because the maintainer can squash them on there needs.
Not sure what you mean, do you want me to make a separate patch for the
devicetree binding documentation here?
Also it would be cool to document the changes. A common place for
changes is after the '---' or on the cover-letter.
Agreed!
v1 -> v2:
- Nolonger altering the existing compatible string, just add a second
one.
- Moved the event emiting work out of the irq handler to the timer
handler.
- Assign hwtype directly to of_device_id->data instead of a struct
platform_device_id entry which has it's .driver_data set to hwtype.
- Document the new device tree binding.
- Update commit message to make more clear why we want to make this
change.
@@ -420,14 +420,22 @@ EXAMPLE ===================================================================== System ON/OFF key driver- The snvs-pwrkey is designed to enable POWER key function which
controlled
- by SNVS ONOFF, the driver can report the status of POWER key and
wakeup
- system if pressed after system suspend.
+ The snvs-pwrkey is designed to enable POWER key function which is
controlled
+ by SNVS ONOFF. It can wakeup the system if pressed after system
suspend.
+
+ There are two generations of SVNS pwrkey hardware. The first
generation is
+ included in i.MX6 Solo, DualLite and Quad processors. The second
generation
+ is included in i.MX6 SoloX and newer SoCs.
+
+ Second generation SNVS can detect and report the status of POWER
key, but the
+ first generation can only detect a key release and so emits an
instantaneous
+ press and release event when the key is released.
- compatible:
Usage: required
Value type: <string>
- Definition: Mush include "fsl,sec-v4.0-pwrkey".
+ Definition: Must include "fsl,sec-v4.0-pwrkey" for i.MX6 SoloX
and newer
+ or "fsl,imx6qdl-snvs-pwrkey" for older SoCs.
- interrupts:
Usage: required
diff --git a/drivers/input/keyboard/Kconfig
b/drivers/input/keyboard/Kconfig
index 7c4f19dab34f..937e58da5ce1 100644
application
- processors that are newer than i.MX6 SX.
+ processors.
To compile this driver as a module, choose M here; the
module will be called snvs_pwrkey.
diff --git a/drivers/input/keyboard/snvs_pwrkey.c
b/drivers/input/keyboard/snvs_pwrkey.c
index 5342d8d45f81..d71c44733103 100644
Is this desired because the timer gets triggered earlier.
Yes, since the first generation has debounce implemented in hardware,
we dont need to add another one.
Now looking at it, maybe I should change the conditional to:
if (pdata->hwtype != IMX6QDL_SNVS)
expire += msecs_to_jiffies(DEBOUNCE_TIME);
to make this more clear.
quoted
+ }
/* clear SPO status */
regmap_write(pdata->snvs, SNVS_LPSR_REG, SNVS_LPSR_SPO);
@@ -93,6 +129,7 @@ static int imx_snvs_pwrkey_probe(struct
@@ -100,6 +137,10 @@ static int imx_snvs_pwrkey_probe(struct
platform_device *pdev)
if (!np)
return -ENODEV;
+ match = of_match_node(imx_snvs_pwrkey_ids, np);
+ if (!match)
+ return -ENODEV;
... of_device_get_match_data() here.
of_device_get_match_data() returns NULL on error. In this case, because
I
assigned integer values to the .data pointers, casting NULL back to an
integer will result in a valid hwtype.
I could declare a special struct with a 'quirks' field like they did in
the
flexcan diver: 'drivers/net/can/flexcan.c'.
Use of_device_get_match_data() to get it, and define a quirk like:
SNVS_QUIRK_NO_BTN_PRESS_IRQ. This might also improve readability.
While reading the rm it seems that
the snvs block has a dedicated version register. IMHO this could be a
better way to apply the change also to existing devices with old
firmware.
I thought the same thing, and fully agree with you. However I do not
have
a way to determine which versions are out there. Since I couldn't find
any
documentation on this, and I only have i.MX6 S/DL, D/Q and UL laying
around.
Regards,
Robin van der Gracht
From: Marco Felsch <hidden> Date: 2019-08-29 08:17:21
Hi Robin,
On 19-08-29 09:24, robin wrote:
Hi Marco,
On 2019-08-28 11:15, Marco Felsch wrote:
quoted
Hi Robin,
thanks for the patch.
On 19-08-27 14:32, Robin van der Gracht wrote:
quoted
The first generation i.MX6 processors does not send an interrupt
when the
power key is pressed. It sends a power down request interrupt if the
key is
released before a hard shutdown (5 second press). This should allow
software to bring down the SoC safely.
For this driver to work as a regular power key with the older SoCs,
we need
to send a keypress AND release when we get the power down request irq.
Signed-off-by: Robin van der Gracht <robin@protonic.nl>
---
.../devicetree/bindings/crypto/fsl-sec4.txt | 16 ++++--
drivers/input/keyboard/Kconfig | 2 +-
drivers/input/keyboard/snvs_pwrkey.c | 52
++++++++++++++++---
Can we split this so the dt-bindings are a standalone patch? IMHO this
is the usual way because the maintainer can squash them on there needs.
Not sure what you mean, do you want me to make a separate patch for the
devicetree binding documentation here?
Yes.
quoted
Also it would be cool to document the changes. A common place for
changes is after the '---' or on the cover-letter.
Agreed!
v1 -> v2:
- Nolonger altering the existing compatible string, just add a second one.
- Moved the event emiting work out of the irq handler to the timer handler.
- Assign hwtype directly to of_device_id->data instead of a struct
platform_device_id entry which has it's .driver_data set to hwtype.
- Document the new device tree binding.
- Update commit message to make more clear why we want to make this change.
@@ -420,14 +420,22 @@ EXAMPLE ===================================================================== System ON/OFF key driver- The snvs-pwrkey is designed to enable POWER key function which
controlled
- by SNVS ONOFF, the driver can report the status of POWER key and
wakeup
- system if pressed after system suspend.
+ The snvs-pwrkey is designed to enable POWER key function which is
controlled
+ by SNVS ONOFF. It can wakeup the system if pressed after system
suspend.
+
+ There are two generations of SVNS pwrkey hardware. The first
generation is
+ included in i.MX6 Solo, DualLite and Quad processors. The second
generation
+ is included in i.MX6 SoloX and newer SoCs.
+
+ Second generation SNVS can detect and report the status of POWER
key, but the
+ first generation can only detect a key release and so emits an
instantaneous
+ press and release event when the key is released.
- compatible:
Usage: required
Value type: <string>
- Definition: Mush include "fsl,sec-v4.0-pwrkey".
+ Definition: Must include "fsl,sec-v4.0-pwrkey" for i.MX6
SoloX and newer
+ or "fsl,imx6qdl-snvs-pwrkey" for older SoCs.
- interrupts:
Usage: required
diff --git a/drivers/input/keyboard/Kconfig
b/drivers/input/keyboard/Kconfig
index 7c4f19dab34f..937e58da5ce1 100644
application
- processors that are newer than i.MX6 SX.
+ processors.
To compile this driver as a module, choose M here; the
module will be called snvs_pwrkey.
diff --git a/drivers/input/keyboard/snvs_pwrkey.c
b/drivers/input/keyboard/snvs_pwrkey.c
index 5342d8d45f81..d71c44733103 100644
Is this desired because the timer gets triggered earlier.
Yes, since the first generation has debounce implemented in hardware,
we dont need to add another one.
Now looking at it, maybe I should change the conditional to:
if (pdata->hwtype != IMX6QDL_SNVS)
expire += msecs_to_jiffies(DEBOUNCE_TIME);
to make this more clear.
Maybe we should add:
if (pdata->hwtype != IMX6QDL_SNVS)
expire = jiffies + msecs_to_jiffies(DEBOUNCE_TIME);
So we can ensure the correct DEBOUNCE time for the other SoC's.
quoted
quoted
+ }
/* clear SPO status */
regmap_write(pdata->snvs, SNVS_LPSR_REG, SNVS_LPSR_SPO);
@@ -93,6 +129,7 @@ static int imx_snvs_pwrkey_probe(struct
@@ -100,6 +137,10 @@ static int imx_snvs_pwrkey_probe(struct
platform_device *pdev)
if (!np)
return -ENODEV;
+ match = of_match_node(imx_snvs_pwrkey_ids, np);
+ if (!match)
+ return -ENODEV;
... of_device_get_match_data() here.
of_device_get_match_data() returns NULL on error. In this case, because I
assigned integer values to the .data pointers, casting NULL back to an
integer will result in a valid hwtype.
I could declare a special struct with a 'quirks' field like they did in the
flexcan diver: 'drivers/net/can/flexcan.c'.
Use of_device_get_match_data() to get it, and define a quirk like:
SNVS_QUIRK_NO_BTN_PRESS_IRQ. This might also improve readability.
IMHO we don't need that check because of:
8<-----------------------------
...
np = pdev->dev.of_node
if (!np)
return -ENODEV;
...
8<-----------------------------
So we can asign it directly.
quoted
While reading the rm it seems that
the snvs block has a dedicated version register. IMHO this could be a
better way to apply the change also to existing devices with old
firmware.
I thought the same thing, and fully agree with you. However I do not have
a way to determine which versions are out there. Since I couldn't find any
documentation on this, and I only have i.MX6 S/DL, D/Q and UL laying around.
@NXP Kernel Team
Can we get some more information here?
Regards,
Marco
Regards,
Robin van der Gracht
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
From: Robin Gong <hidden> Date: 2019-08-29 09:11:46
On 2019-08-29 16:17, Marco Felsch wrote:
quoted
quoted
While reading the rm it seems that
the snvs block has a dedicated version register. IMHO this could be
a better way to apply the change also to existing devices with old
firmware.
I thought the same thing, and fully agree with you. However I do not
have a way to determine which versions are out there. Since I couldn't
find any documentation on this, and I only have i.MX6 S/DL, D/Q and UL
laying around.
@NXP Kernel Team
Can we get some more information here?
Go ahead, please. That snvs version register SNVS_HPVIDR1 should work as expect.
MINOR_REV checking is enough, none-zero means for soc after i.mx6sx, but
Zero means i.mx6q/dl/sl elder soc.
From: Marco Felsch <hidden> Date: 2019-08-29 11:51:03
On 19-08-29 09:11, Robin Gong wrote:
On 2019-08-29 16:17, Marco Felsch wrote:
quoted
quoted
quoted
While reading the rm it seems that
the snvs block has a dedicated version register. IMHO this could be
a better way to apply the change also to existing devices with old
firmware.
I thought the same thing, and fully agree with you. However I do not
have a way to determine which versions are out there. Since I couldn't
find any documentation on this, and I only have i.MX6 S/DL, D/Q and UL
laying around.
@NXP Kernel Team
Can we get some more information here?
Go ahead, please. That snvs version register SNVS_HPVIDR1 should work as expect.
MINOR_REV checking is enough, none-zero means for soc after i.mx6sx, but
Zero means i.mx6q/dl/sl elder soc.
Thanks. Robin can you integrate that so we can drop the different
dt-handling?
Regards,
Marco
From: robin <robin@protonic.nl> Date: 2019-08-29 14:32:25
On 2019-08-29 13:50, Marco Felsch wrote:
On 19-08-29 09:11, Robin Gong wrote:
quoted
On 2019-08-29 16:17, Marco Felsch wrote:
quoted
quoted
quoted
While reading the rm it seems that
the snvs block has a dedicated version register. IMHO this could be
a better way to apply the change also to existing devices with old
firmware.
I thought the same thing, and fully agree with you. However I do not
have a way to determine which versions are out there. Since I couldn't
find any documentation on this, and I only have i.MX6 S/DL, D/Q and UL
laying around.
@NXP Kernel Team
Can we get some more information here?
Go ahead, please. That snvs version register SNVS_HPVIDR1 should work
as expect.
MINOR_REV checking is enough, none-zero means for soc after i.mx6sx,
but
Zero means i.mx6q/dl/sl elder soc.
Thanks. Robin can you integrate that so we can drop the different
dt-handling?