input: keyboard: snvs_pwrkey: Send key events for i.MX6 S, DL and Q
Subsystems (2)
PATCH v3 1/1 input: keyboard: snvs_pwrkey: Send key events for i.MX6 S, DL and Q
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.
---
Changes v2 -> v3:
- Drop alt compatible string for identifying first revision snvs hardware, read minor revision from register instead.
- Drop imx6qdl.dtsi modification and device-tree binding documentation.
- Add an additional input_sync() to create 2 seperate input reports for press and release.
drivers/input/keyboard/Kconfig | 2 +- drivers/input/keyboard/snvs_pwrkey.c | 28 ++++++++++++++++++++++++++-- 2 files changed, 27 insertions(+), 3 deletions(-)
drivers/input/keyboard/Kconfig +1 -1
@@ -436,7 +436,7 @@ config KEYBOARD_SNVS_PWRKEY depends on OF help This is the snvs powerkey driver for the Freescale i.MX 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.
drivers/input/keyboard/snvs_pwrkey.c +26 -2
@@ -19,6 +19,7 @@#include <linux/mfd/syscon.h> #include <linux/regmap.h> +#define SNVS_HPVIDR1_REG 0xF8#define SNVS_LPSR_REG 0x4C/* LP Status Register */ #define SNVS_LPCR_REG 0x38/* LP Control Register */ #define SNVS_HPSR_REG 0x14
@@ -37,6 +38,7 @@ struct pwrkey_drv_data {int wakeup;struct timer_list check_timer;struct input_dev *input; +u8 minor_rev; };static void imx_imx_snvs_check_for_events (struct timer_list *t)
@@ -45,6 +47,20 @@ static void imx_imx_snvs_check_for_events(struct timer_list *t)struct input_dev *input = pdata->input;u32 state; +if (pdata->minor_rev ==0 ) { +/* +* The first generation i.MX6 SoCs only sends an interrupt on +* button release. To mimic power-key usage, we'll prepend a +* press event. +*/ +input_report_key (input, pdata->keycode,1 ); +input_sync (input); +input_report_key (input, pdata->keycode,0 ); +input_sync (input); +pm_relax (input->dev.parent); +return ; + } +regmap_read (pdata->snvs,SNVS_HPSR_REG , &state); state = state &SNVS_HPSR_BTN ?1 :0 ;
@@ -67,13 +83,17 @@ static irqreturn_t imx_snvs_pwrkey_interrupt(int irq, void *dev_id) {struct platform_device *pdev = dev_id;struct pwrkey_drv_data *pdata =platform_get_drvdata (pdev); +unsigned long expire = jiffies;u32 lp_status;pm_wakeup_event (pdata->input->dev.parent,0 );regmap_read (pdata->snvs,SNVS_LPSR_REG , &lp_status); -if (lp_status &SNVS_LPSR_SPO ) -mod_timer (&pdata->check_timer, jiffies +msecs_to_jiffies (DEBOUNCE_TIME )); +if (lp_status &SNVS_LPSR_SPO ) { +if (pdata->minor_rev >0 ) + expire = jiffies +msecs_to_jiffies (DEBOUNCE_TIME ); +mod_timer (&pdata->check_timer, expire); + }/* clear SPO status */ regmap_write (pdata->snvs,SNVS_LPSR_REG ,SNVS_LPSR_SPO );
@@ -94,6 +114,7 @@ static int imx_snvs_pwrkey_probe(struct platform_device *pdev)struct input_dev *input =NULL ;struct device_node *np;int error; +u32 vid;/* Get SNVS register Page */ np = pdev->dev.of_node;
@@ -123,6 +144,9 @@ static int imx_snvs_pwrkey_probe(struct platform_device *pdev)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 );/* clear the unexpected interrupt before driver ready */
Signature · 1 line
2.20.1
Hi Robin,
thanks for the patch it looks quite good, just two minor nitpicks.
Quoted 56 lines · Robin van der Gracht
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 <[email protected]>---
Changes v2 -> v3:
- Drop alt compatible string for identifying first revision snvs hardware, read minor revision from register instead.
- Dropimx6qdl.dtsimodification and device-tree binding documentation.
- Add an additionalinput_sync()to create 2 seperate input reports for press and release.drivers/input/keyboard/Kconfig | 2 +- drivers/input/keyboard/snvs_pwrkey.c | 28 ++++++++++++++++++++++++++-- 2 files changed, 27 insertions(+), 3 deletions(-)drivers/input/keyboard/Kconfig +1
-1@@ -436,7 +436,7 @@ config KEYBOARD_SNVS_PWRKEY depends on OF help This is the snvs powerkey driver for the Freescale i.MX 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.drivers/input/keyboard/snvs_pwrkey.c +2
-0@@ -19,6 +19,7 @@#include <linux/mfd/syscon.h> #include <linux/regmap.h> +#define SNVS_HPVIDR1_REG 0xF8#define SNVS_LPSR_REG 0x4C/* LP Status Register */ #define SNVS_LPCR_REG 0x38/* LP Control Register */ #define SNVS_HPSR_REG 0x14@@ -37,6 +38,7 @@ struct pwrkey_drv_data {int wakeup;struct timer_list check_timer;struct input_dev *input; +u8 minor_rev; };static void imx_imx_snvs_check_for_events (struct timer_list *t)
drivers/input/keyboard/snvs_pwrkey.c static void imx_imx_snvs_check_for_events(struct timer_list *t) · line 50
Quoted 4 lines
drivers/input/keyboard/snvs_pwrkey.c +1
-0@@ -45,6 +47,20 @@ static void imx_imx_snvs_check_for_events(struct timer_list *t)struct input_dev *input = pdata->input;u32 state; +if (pdata->minor_rev ==0 ) {
Should we use a define here and ..
Quoted 20 lines
drivers/input/keyboard/snvs_pwrkey.c +13
-0+/* +* The first generation i.MX6 SoCs only sends an interrupt on +* button release. To mimic power-key usage, we'll prepend a +* press event. +*/ +input_report_key (input, pdata->keycode,1 ); +input_sync (input); +input_report_key (input, pdata->keycode,0 ); +input_sync (input); +pm_relax (input->dev.parent); +return ; + } +regmap_read (pdata->snvs,SNVS_HPSR_REG , &state); state = state &SNVS_HPSR_BTN ?1 :0 ;@@ -67,13 +83,17 @@ static irqreturn_t imx_snvs_pwrkey_interrupt(int irq, void *dev_id) {struct platform_device *pdev = dev_id;struct pwrkey_drv_data *pdata =platform_get_drvdata (pdev);
drivers/input/keyboard/snvs_pwrkey.c static irqreturn_t imx_snvs_pwrkey_interrupt(int irq, void *dev_id) · line 93
Quoted 10 lines
drivers/input/keyboard/snvs_pwrkey.c +3
-2+unsigned long expire = jiffies;u32 lp_status;pm_wakeup_event (pdata->input->dev.parent,0 );regmap_read (pdata->snvs,SNVS_LPSR_REG , &lp_status); -if (lp_status &SNVS_LPSR_SPO ) -mod_timer (&pdata->check_timer, jiffies +msecs_to_jiffies (DEBOUNCE_TIME )); +if (lp_status &SNVS_LPSR_SPO ) { +if (pdata->minor_rev >0 )
here? Just a nitpick, feel free to add/drop it.
Quoted 15 lines
drivers/input/keyboard/snvs_pwrkey.c +4
-0+ expire = jiffies +msecs_to_jiffies (DEBOUNCE_TIME ); +mod_timer (&pdata->check_timer, expire); + }/* clear SPO status */ regmap_write (pdata->snvs,SNVS_LPSR_REG ,SNVS_LPSR_SPO );@@ -94,6 +114,7 @@ static int imx_snvs_pwrkey_probe(struct platform_device *pdev)struct input_dev *input =NULL ;struct device_node *np;int error; +u32 vid;/* Get SNVS register Page */ np = pdev->dev.of_node;
drivers/input/keyboard/snvs_pwrkey.c static int imx_snvs_pwrkey_probe(struct platform_device *pdev) · line 147
Quoted 4 lines
drivers/input/keyboard/snvs_pwrkey.c +1
-0@@ -123,6 +144,9 @@ static int imx_snvs_pwrkey_probe(struct platform_device *pdev)return -EINVAL ; } +regmap_read (pdata->snvs,SNVS_HPVIDR1_REG , &vid);
Should we check the return val here?
Regards,
Marco
Quoted 9 lines
drivers/input/keyboard/snvs_pwrkey.c +2
-0+ pdata->minor_rev = vid &0xff ; +regmap_update_bits (pdata->snvs,SNVS_LPCR_REG ,SNVS_LPCR_DEP_EN ,SNVS_LPCR_DEP_EN );/* clear the unexpected interrupt before driver ready */ Signature · 1 line
2.20.1
Signature · 4 lines
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 |
Quoted 100 lines · Marco Felsch
Hi Robin,
thanks for the patch it looks quite good, just two minor nitpicks.
Quoted 61 lines · Robin van der Gracht
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 <[email protected]>---
Changes v2 -> v3:
- Drop alt compatible string for identifying first revision snvs
hardware,
read minor revision from register instead.
- Dropimx6qdl.dtsimodification and device-tree binding
documentation.
- Add an additionalinput_sync()to create 2 seperate input reports
for press
and release.drivers/input/keyboard/Kconfig | 2 +- drivers/input/keyboard/snvs_pwrkey.c | 28 ++++++++++++++++++++++++++-- 2 files changed, 27 insertions(+), 3 deletions(-)drivers/input/keyboard/Kconfig +0
-0@@ -436,7 +436,7 @@ config KEYBOARD_SNVS_PWRKEY depends on OF help This is the snvs powerkey driver for the Freescale i.MXapplication
drivers/input/keyboard/Kconfig +1
-1- 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.drivers/input/keyboard/snvs_pwrkey.c +2
-0@@ -19,6 +19,7 @@#include <linux/mfd/syscon.h> #include <linux/regmap.h> +#define SNVS_HPVIDR1_REG 0xF8#define SNVS_LPSR_REG 0x4C/* LP Status Register */ #define SNVS_LPCR_REG 0x38/* LP Control Register */ #define SNVS_HPSR_REG 0x14@@ -37,6 +38,7 @@ struct pwrkey_drv_data {int wakeup;struct timer_list check_timer;struct input_dev *input; +u8 minor_rev; };static void imx_imx_snvs_check_for_events (struct timer_list *t)drivers/input/keyboard/snvs_pwrkey.c static void imx_imx_snvs_check_for_events(struct · line 51
Quoted 5 lines
drivers/input/keyboard/snvs_pwrkey.c +1
-0@@ -45,6 +47,20 @@ static void imx_imx_snvs_check_for_events(struct timer_list *t)struct input_dev *input = pdata->input;u32 state; +if (pdata->minor_rev ==0 ) {Should we use a define here and ..
Quoted 26 lines
drivers/input/keyboard/snvs_pwrkey.c +14
-0+/* +* The first generation i.MX6 SoCs only sends an interrupt on +* button release. To mimic power-key usage, we'll prepend a +* press event. +*/ +input_report_key (input, pdata->keycode,1 ); +input_sync (input); +input_report_key (input, pdata->keycode,0 ); +input_sync (input); +pm_relax (input->dev.parent); +return ; + } +regmap_read (pdata->snvs,SNVS_HPSR_REG , &state); state = state &SNVS_HPSR_BTN ?1 :0 ;@@ -67,13 +83,17 @@ static irqreturn_t imx_snvs_pwrkey_interrupt(int irq, void *dev_id) {struct platform_device *pdev = dev_id;struct pwrkey_drv_data *pdata =platform_get_drvdata (pdev); +unsigned long expire = jiffies;u32 lp_status;pm_wakeup_event (pdata->input->dev.parent,0 );
Quoted 8 lines
drivers/input/keyboard/snvs_pwrkey.c static irqreturn_t imx_snvs_pwrkey_interrupt(int irq, void *dev_id) · line 93
Quoted 6 lines
drivers/input/keyboard/snvs_pwrkey.c +2
-2regmap_read (pdata->snvs,SNVS_LPSR_REG , &lp_status); -if (lp_status &SNVS_LPSR_SPO ) -mod_timer (&pdata->check_timer, jiffies + msecs_to_jiffies(DEBOUNCE_TIME)); +if (lp_status &SNVS_LPSR_SPO ) { +if (pdata->minor_rev >0 )here? Just a nitpick, feel free to add/drop it.
Like a Macro?
#define FIRST_HW_REV(pdata) (pdata->minor_rev == 0)
if (FIRST_HW_REV(pdata) {
...
}or just a define to identify the minor rev used for the first hw revision
#define FIRST_HW_MINOR_REV 0
if (pdata->minor_rev == FIRST_HW_MINOR_REV) {
...
}Regards,
Robin van der Gracht
Dmitry Torokhov
maintainerHi Robin,
Quoted 82 lines · Robin van der Gracht
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 <[email protected]>---
Changes v2 -> v3:
- Drop alt compatible string for identifying first revision snvs hardware, read minor revision from register instead.
- Dropimx6qdl.dtsimodification and device-tree binding documentation.
- Add an additionalinput_sync()to create 2 seperate input reports for press and release.drivers/input/keyboard/Kconfig | 2 +- drivers/input/keyboard/snvs_pwrkey.c | 28 ++++++++++++++++++++++++++-- 2 files changed, 27 insertions(+), 3 deletions(-)drivers/input/keyboard/Kconfig +1
-1@@ -436,7 +436,7 @@ config KEYBOARD_SNVS_PWRKEY depends on OF help This is the snvs powerkey driver for the Freescale i.MX 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.drivers/input/keyboard/snvs_pwrkey.c +17
-0@@ -19,6 +19,7 @@#include <linux/mfd/syscon.h> #include <linux/regmap.h> +#define SNVS_HPVIDR1_REG 0xF8#define SNVS_LPSR_REG 0x4C/* LP Status Register */ #define SNVS_LPCR_REG 0x38/* LP Control Register */ #define SNVS_HPSR_REG 0x14@@ -37,6 +38,7 @@ struct pwrkey_drv_data {int wakeup;struct timer_list check_timer;struct input_dev *input; +u8 minor_rev; };static void imx_imx_snvs_check_for_events (struct timer_list *t)@@ -45,6 +47,20 @@ static void imx_imx_snvs_check_for_events(struct timer_list *t)struct input_dev *input = pdata->input;u32 state; +if (pdata->minor_rev ==0 ) { +/* +* The first generation i.MX6 SoCs only sends an interrupt on +* button release. To mimic power-key usage, we'll prepend a +* press event. +*/ +input_report_key (input, pdata->keycode,1 ); +input_sync (input); +input_report_key (input, pdata->keycode,0 ); +input_sync (input); +pm_relax (input->dev.parent); +return ; + } +regmap_read (pdata->snvs,SNVS_HPSR_REG , &state); state = state &SNVS_HPSR_BTN ?1 :0 ;@@ -67,13 +83,17 @@ static irqreturn_t imx_snvs_pwrkey_interrupt(int irq, void *dev_id) {struct platform_device *pdev = dev_id;struct pwrkey_drv_data *pdata =platform_get_drvdata (pdev); +unsigned long expire = jiffies;u32 lp_status;
drivers/input/keyboard/snvs_pwrkey.c static irqreturn_t imx_snvs_pwrkey_interrupt(int irq, void *dev_id) · line 95
Quoted 10 lines
drivers/input/keyboard/snvs_pwrkey.c +4
-2pm_wakeup_event (pdata->input->dev.parent,0 );regmap_read (pdata->snvs,SNVS_LPSR_REG , &lp_status); -if (lp_status &SNVS_LPSR_SPO ) -mod_timer (&pdata->check_timer, jiffies +msecs_to_jiffies (DEBOUNCE_TIME )); +if (lp_status &SNVS_LPSR_SPO ) { +if (pdata->minor_rev >0 ) + expire = jiffies +msecs_to_jiffies (DEBOUNCE_TIME ); +mod_timer (&pdata->check_timer, expire);
Why do we even need to fire the timer in case of the first generation hardware? Just send press and release events directly from the ISR.
Thanks.
Signature · 1 line
Dmitry
Hi Dmitry,
Quoted 95 lines · Dmitry Torokhov
Hi Robin,
Quoted 92 lines · Robin van der Gracht
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 <[email protected]>---
Changes v2 -> v3:
- Drop alt compatible string for identifying first revision snvs
hardware,
read minor revision from register instead.
- Dropimx6qdl.dtsimodification and device-tree binding
documentation.
- Add an additionalinput_sync()to create 2 seperate input reports
for press
and release.drivers/input/keyboard/Kconfig | 2 +- drivers/input/keyboard/snvs_pwrkey.c | 28 ++++++++++++++++++++++++++-- 2 files changed, 27 insertions(+), 3 deletions(-)drivers/input/keyboard/Kconfig +0
-0@@ -436,7 +436,7 @@ config KEYBOARD_SNVS_PWRKEY depends on OF help This is the snvs powerkey driver for the Freescale i.MXapplication
drivers/input/keyboard/Kconfig +1
-1- 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.drivers/input/keyboard/snvs_pwrkey.c +17
-0@@ -19,6 +19,7 @@#include <linux/mfd/syscon.h> #include <linux/regmap.h> +#define SNVS_HPVIDR1_REG 0xF8#define SNVS_LPSR_REG 0x4C/* LP Status Register */ #define SNVS_LPCR_REG 0x38/* LP Control Register */ #define SNVS_HPSR_REG 0x14@@ -37,6 +38,7 @@ struct pwrkey_drv_data {int wakeup;struct timer_list check_timer;struct input_dev *input; +u8 minor_rev; };static void imx_imx_snvs_check_for_events (struct timer_list *t)@@ -45,6 +47,20 @@ static void imx_imx_snvs_check_for_events(struct timer_list *t)struct input_dev *input = pdata->input;u32 state; +if (pdata->minor_rev ==0 ) { +/* +* The first generation i.MX6 SoCs only sends an interrupt on +* button release. To mimic power-key usage, we'll prepend a +* press event. +*/ +input_report_key (input, pdata->keycode,1 ); +input_sync (input); +input_report_key (input, pdata->keycode,0 ); +input_sync (input); +pm_relax (input->dev.parent); +return ; + } +regmap_read (pdata->snvs,SNVS_HPSR_REG , &state); state = state &SNVS_HPSR_BTN ?1 :0 ;@@ -67,13 +83,17 @@ static irqreturn_t imx_snvs_pwrkey_interrupt(int irq, void *dev_id) {struct platform_device *pdev = dev_id;struct pwrkey_drv_data *pdata =platform_get_drvdata (pdev); +unsigned long expire = jiffies;u32 lp_status;pm_wakeup_event (pdata->input->dev.parent,0 );
Quoted 11 lines
drivers/input/keyboard/snvs_pwrkey.c static irqreturn_t imx_snvs_pwrkey_interrupt(int irq, void *dev_id) · line 95
Quoted 8 lines
drivers/input/keyboard/snvs_pwrkey.c +4
-2regmap_read (pdata->snvs,SNVS_LPSR_REG , &lp_status); -if (lp_status &SNVS_LPSR_SPO ) -mod_timer (&pdata->check_timer, jiffies + msecs_to_jiffies(DEBOUNCE_TIME)); +if (lp_status &SNVS_LPSR_SPO ) { +if (pdata->minor_rev >0 ) + expire = jiffies +msecs_to_jiffies (DEBOUNCE_TIME ); +mod_timer (&pdata->check_timer, expire);Why do we even need to fire the timer in case of the first generation hardware? Just send press and release events directly from the ISR.
Robin Gong proposed to move the code to imx_imx_snvs_check_for_events() to improve readability and unload the ISR.
But since I, eventually, couldn't use the existing handling in imx_imx_snvs_check_for_events(), I do see why you're asking.
I'll move the code to the ISR and submit a new patch.
Robin van der Gracht
On 2019/9/13 15:31 robin <[email protected]> wrote:>
Quoted 37 lines
Hi Dmitry,
Quoted 34 lines · Dmitry Torokhov
Hi Robin,
Quoted 18 lines · Robin van der Gracht
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 <[email protected]>---
drivers/input/keyboard/snvs_pwrkey.c +1
-0@@ -67,13 +83,17 @@ static irqreturn_t imx_snvs_pwrkey_interrupt(int irq, void *dev_id) {struct platform_device *pdev = dev_id;struct pwrkey_drv_data *pdata =platform_get_drvdata (pdev); +unsigned long expire = jiffies;u32 lp_status;drivers/input/keyboard/snvs_pwrkey.c static irqreturn_t imx_snvs_pwrkey_interrupt(int · line 96
Quoted 10 lines
drivers/input/keyboard/snvs_pwrkey.c +4
-2pm_wakeup_event (pdata->input->dev.parent,0 );regmap_read (pdata->snvs,SNVS_LPSR_REG , &lp_status); -if (lp_status &SNVS_LPSR_SPO ) -mod_timer (&pdata->check_timer, jiffies + msecs_to_jiffies(DEBOUNCE_TIME)); +if (lp_status &SNVS_LPSR_SPO ) { +if (pdata->minor_rev >0 ) + expire = jiffies +msecs_to_jiffies (DEBOUNCE_TIME ); +mod_timer (&pdata->check_timer, expire);Why do we even need to fire the timer in case of the first generation hardware? Just send press and release events directly from the ISR.
That timer looks like a software debounce to prevent unexpected and meaningless interrupt/event caused by quick press/release.
Quoted 10 lines
Robin Gong proposed to move the code to
imx_imx_snvs_check_for_events()to improve readability and unload the ISR.But since I, eventually, couldn't use the existing handling in
imx_imx_snvs_check_for_events(), I do see why you're asking.I'll move the code to the ISR and submit a new patch.
Robin van der Gracht
Dmitry Torokhov
maintainerQuoted 38 lines · Robin Gong
On 2019/9/13 15:31 robin <[email protected]> wrote:>
Quoted 37 lines
Hi Dmitry,
Quoted 34 lines · Dmitry Torokhov
Hi Robin,
Quoted 18 lines · Robin van der Gracht
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 <[email protected]>---
drivers/input/keyboard/snvs_pwrkey.c +1
-0@@ -67,13 +83,17 @@ static irqreturn_t imx_snvs_pwrkey_interrupt(int irq, void *dev_id) {struct platform_device *pdev = dev_id;struct pwrkey_drv_data *pdata =platform_get_drvdata (pdev); +unsigned long expire = jiffies;u32 lp_status;drivers/input/keyboard/snvs_pwrkey.c static irqreturn_t imx_snvs_pwrkey_interrupt(int · line 96
Quoted 10 lines
drivers/input/keyboard/snvs_pwrkey.c +4
-2pm_wakeup_event (pdata->input->dev.parent,0 );regmap_read (pdata->snvs,SNVS_LPSR_REG , &lp_status); -if (lp_status &SNVS_LPSR_SPO ) -mod_timer (&pdata->check_timer, jiffies + msecs_to_jiffies(DEBOUNCE_TIME)); +if (lp_status &SNVS_LPSR_SPO ) { +if (pdata->minor_rev >0 ) + expire = jiffies +msecs_to_jiffies (DEBOUNCE_TIME ); +mod_timer (&pdata->check_timer, expire);Why do we even need to fire the timer in case of the first generation hardware? Just send press and release events directly from the ISR.
Quoted 2 lines
That timer looks like a software debounce to prevent unexpected and meaningless interrupt/event caused by quick press/release.
Right, but in case of the first generation hardware we schedule the timer immediately (expire == 0) and do not check state of the hardware in the timer handler, but rather simply emit down/up events, so we do not really get any benefit from the timer (again, I am talking about first generation hardware only).
Thanks.
Signature · 1 line
Dmitry
Hi Robin,
Quoted 39 lines · Dmitry Torokhov
Quoted 38 lines · Robin Gong
On 2019/9/13 15:31 robin <[email protected]> wrote:>
Quoted 37 lines
Hi Dmitry,
Quoted 34 lines · Dmitry Torokhov
Hi Robin,
Quoted 18 lines · Robin van der Gracht
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 <[email protected]>---
drivers/input/keyboard/snvs_pwrkey.c +1
-0@@ -67,13 +83,17 @@ static irqreturn_t imx_snvs_pwrkey_interrupt(int irq, void *dev_id) {struct platform_device *pdev = dev_id;struct pwrkey_drv_data *pdata =platform_get_drvdata (pdev); +unsigned long expire = jiffies;u32 lp_status;drivers/input/keyboard/snvs_pwrkey.c static irqreturn_t imx_snvs_pwrkey_interrupt(int · line 96
Quoted 10 lines
drivers/input/keyboard/snvs_pwrkey.c +4
-2pm_wakeup_event (pdata->input->dev.parent,0 );regmap_read (pdata->snvs,SNVS_LPSR_REG , &lp_status); -if (lp_status &SNVS_LPSR_SPO ) -mod_timer (&pdata->check_timer, jiffies + msecs_to_jiffies(DEBOUNCE_TIME)); +if (lp_status &SNVS_LPSR_SPO ) { +if (pdata->minor_rev >0 ) + expire = jiffies +msecs_to_jiffies (DEBOUNCE_TIME ); +mod_timer (&pdata->check_timer, expire);Why do we even need to fire the timer in case of the first generation hardware? Just send press and release events directly from the ISR.
Quoted 8 lines
Quoted 2 lines
That timer looks like a software debounce to prevent unexpected and meaningless interrupt/event caused by quick press/release.
Right, but in case of the first generation hardware we schedule the timer immediately (expire == 0) and do not check state of the hardware in the timer handler, but rather simply emit down/up events, so we do not really get any benefit from the timer (again, I am talking about first generation hardware only).
Did you prepared a v4? Just ask to avoid a duplicated work :)
Regards,
Marco
Quoted 5 lines
Thanks.
Signature · 1 line
Dmitry
Quoted 45 lines · Marco Felsch
Hi Robin,
Quoted 42 lines · Dmitry Torokhov
Quoted 40 lines · Robin Gong
On 2019/9/13 15:31 robin <[email protected]> wrote:>
Quoted 37 lines
Hi Dmitry,
Quoted 34 lines · Dmitry Torokhov
Hi Robin,
Quoted 18 lines · Robin van der Gracht
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 <[email protected]>---
drivers/input/keyboard/snvs_pwrkey.c +1
-0@@ -67,13 +83,17 @@ static irqreturn_t imx_snvs_pwrkey_interrupt(int irq, void *dev_id) {struct platform_device *pdev = dev_id;struct pwrkey_drv_data *pdata =platform_get_drvdata (pdev); +unsigned long expire = jiffies;u32 lp_status;drivers/input/keyboard/snvs_pwrkey.c static irqreturn_t imx_snvs_pwrkey_interrupt(int · line 96
Quoted 10 lines
drivers/input/keyboard/snvs_pwrkey.c +4
-2pm_wakeup_event (pdata->input->dev.parent,0 );regmap_read (pdata->snvs,SNVS_LPSR_REG , &lp_status); -if (lp_status &SNVS_LPSR_SPO ) -mod_timer (&pdata->check_timer, jiffies + msecs_to_jiffies(DEBOUNCE_TIME)); +if (lp_status &SNVS_LPSR_SPO ) { +if (pdata->minor_rev >0 ) + expire = jiffies +msecs_to_jiffies (DEBOUNCE_TIME ); +mod_timer (&pdata->check_timer, expire);Why do we even need to fire the timer in case of the first generation hardware? Just send press and release events directly from the ISR.
That timer looks like a software debounce to prevent unexpected and meaningless interrupt/event caused by quick press/release.
Quoted 7 lines
Quoted 5 lines
Right, but in case of the first generation hardware we schedule the timer immediately (expire == 0) and do not check state of the hardware in the timer handler, but rather simply emit down/up events, so we do not really get any benefit from the timer (again, I am talking about first generation hardware only).
Did you prepared a v4? Just ask to avoid a duplicated work :)
No I haven't. Not sure what the public wants. Use timer, don't use timer..
v3 has had long term testing though ;)
Regards,
Robin van der Gracht
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Quoted 55 lines · robin
Quoted 11 lines · Marco Felsch
Hi Robin,
Quoted 8 lines · Dmitry Torokhov
Quoted 7 lines · Robin Gong
On 2019/9/13 15:31 robin <[email protected]> wrote:>
Quoted 6 lines
Hi Dmitry,
Quoted 3 lines · Dmitry Torokhov
Hi Robin,
On Wed, Sep 04, 2019 at 06:23:29AM +0000, Robin van der Gracht
Quoted 4 lines · wrote:
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
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.
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
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 <[email protected]>---
(quoted diff) +1
-0@@ -67,13 +83,17 @@ static irqreturn_t imx_snvs_pwrkey_interrupt(int irq, void *dev_id) { struct platform_device *pdev = dev_id; struct pwrkey_drv_data *pdata = platform_get_drvdata(pdev); + unsigned long expire = jiffies; u32 lp_status; pm_wakeup_event(pdata->input->dev.parent, 0);Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Review static irqreturn_t · line 96
Quoted 8 lines
(quoted diff) +4
-2regmap_read(pdata->snvs, SNVS_LPSR_REG, &lp_status); - if (lp_status & SNVS_LPSR_SPO) - mod_timer(&pdata->check_timer, jiffies + msecs_to_jiffies(DEBOUNCE_TIME)); + if (lp_status & SNVS_LPSR_SPO) { + if (pdata->minor_rev > 0) + expire = jiffies + msecs_to_jiffies(DEBOUNCE_TIME); + mod_timer(&pdata->check_timer, expire);Why do we even need to fire the timer in case of the first generation hardware? Just send press and release events directly from
the ISR.
Quoted 9 lines
Quoted 8 lines
Quoted 2 lines
That timer looks like a software debounce to prevent unexpected and meaningless interrupt/event caused by quick press/release.
Right, but in case of the first generation hardware we schedule the timer immediately (expire == 0) and do not check state of the hardware in the timer handler, but rather simply emit down/up events, so we do not really get any benefit from the timer (again, I am talking about first generation hardware only).
Quoted 5 lines
Quoted 1 line
Did you prepared a v4? Just ask to avoid a duplicated work :)
No I haven't. Not sure what the public wants. Use timer, don't use timer..
v3 has had long term testing though ;)
Sorry for that I miss the mail.
Understood a little bit confusion about immediate timer for the first press, just stand on the view of clean code shape. But I'm okay if you prefer to remove timer in the first interrupt generation.
Quoted 3 lines
Regards,
Robin van der Gracht
Dmitry Torokhov
maintainerQuoted 59 lines · Robin Gong
Quoted 57 lines · robin
Quoted 11 lines · Marco Felsch
Hi Robin,
Quoted 8 lines · Dmitry Torokhov
Quoted 7 lines · Robin Gong
On 2019/9/13 15:31 robin <[email protected]> wrote:>
Quoted 6 lines
Hi Dmitry,
Quoted 3 lines · Dmitry Torokhov
Hi Robin,
On Wed, Sep 04, 2019 at 06:23:29AM +0000, Robin van der Gracht
Quoted 4 lines · wrote:
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
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.
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
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 <[email protected]>---
(quoted diff) +1
-0@@ -67,13 +83,17 @@ static irqreturn_t imx_snvs_pwrkey_interrupt(int irq, void *dev_id) { struct platform_device *pdev = dev_id; struct pwrkey_drv_data *pdata = platform_get_drvdata(pdev); + unsigned long expire = jiffies; u32 lp_status; pm_wakeup_event(pdata->input->dev.parent, 0);Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Review static irqreturn_t · line 96
Quoted 8 lines
(quoted diff) +4
-2regmap_read(pdata->snvs, SNVS_LPSR_REG, &lp_status); - if (lp_status & SNVS_LPSR_SPO) - mod_timer(&pdata->check_timer, jiffies + msecs_to_jiffies(DEBOUNCE_TIME)); + if (lp_status & SNVS_LPSR_SPO) { + if (pdata->minor_rev > 0) + expire = jiffies + msecs_to_jiffies(DEBOUNCE_TIME); + mod_timer(&pdata->check_timer, expire);Why do we even need to fire the timer in case of the first generation hardware? Just send press and release events directly from
the ISR.
Quoted 10 lines
Quoted 8 lines
Quoted 2 lines
That timer looks like a software debounce to prevent unexpected and meaningless interrupt/event caused by quick press/release.
Right, but in case of the first generation hardware we schedule the timer immediately (expire == 0) and do not check state of the hardware in the timer handler, but rather simply emit down/up events, so we do not really get any benefit from the timer (again, I am talking about first generation hardware only).
Did you prepared a v4? Just ask to avoid a duplicated work :)
Quoted 8 lines
Quoted 3 lines
No I haven't. Not sure what the public wants. Use timer, don't use timer..
v3 has had long term testing though ;)
Sorry for that I miss the mail.
Understood a little bit confusion about immediate timer for the first press, just stand on the view of clean code shape. But I'm okay if you prefer to remove timer in the first interrupt generation.
Yes, please prepare v4 without the timer for the first generation of the hardware.
Thanks.
Signature · 1 line
Dmitry