* [PATCH 1/3] Input: omap-keypad: Enable wakeup capability for keypad.
2013-07-26 16:29 [PATCH 0/3] Input: omap-keypad: Wakeup capability and w/a for i689 errata Illia Smyrnov
@ 2013-07-26 16:29 ` Illia Smyrnov
2013-07-26 16:58 ` Illia Smyrnov
2013-07-26 16:30 ` [PATCH 2/3] Input: omap-keypad: errata i689: Correct debounce time Illia Smyrnov
2013-07-26 16:30 ` [PATCH 3/3] Input: omap-keypad: Set irq to level instead of edge Illia Smyrnov
2 siblings, 1 reply; 5+ messages in thread
From: Illia Smyrnov @ 2013-07-26 16:29 UTC (permalink / raw)
To: Dmitry Torokhov; +Cc: linux-input, linux-kernel, linux-omap
Enable/disable IRQ wake in suspend/resume handlers
to make the keypad wakeup capable.
Signed-off-by: Illia Smyrnov <illia.smyrnov@ti.com>
---
drivers/input/keyboard/omap4-keypad.c | 38 +++++++++++++++++++++++++++++++++
1 file changed, 38 insertions(+)
diff --git a/drivers/input/keyboard/omap4-keypad.c b/drivers/input/keyboard/omap4-keypad.c
index 0244262..5f0a2c7 100644
--- a/drivers/input/keyboard/omap4-keypad.c
+++ b/drivers/input/keyboard/omap4-keypad.c
@@ -74,6 +74,7 @@ struct omap4_keypad {
struct input_dev *input;
void __iomem *base;
+ bool irq_wake_enabled;
unsigned int irq;
unsigned int rows;
@@ -380,6 +381,7 @@ static int omap4_keypad_probe(struct platform_device *pdev)
goto err_free_input;
}
+ device_init_wakeup(&pdev->dev, true);
pm_runtime_put_sync(&pdev->dev);
error = input_register_device(keypad_data->input);
@@ -393,6 +395,7 @@ static int omap4_keypad_probe(struct platform_device *pdev)
err_pm_disable:
pm_runtime_disable(&pdev->dev);
+ device_init_wakeup(&pdev->dev, false);
free_irq(keypad_data->irq, keypad_data);
err_free_keymap:
kfree(keypad_data->keymap);
@@ -418,6 +421,8 @@ static int omap4_keypad_remove(struct platform_device *pdev)
pm_runtime_disable(&pdev->dev);
+ device_init_wakeup(&pdev->dev, false);
+
input_unregister_device(keypad_data->input);
iounmap(keypad_data->base);
@@ -439,12 +444,45 @@ static const struct of_device_id omap_keypad_dt_match[] = {
MODULE_DEVICE_TABLE(of, omap_keypad_dt_match);
#endif
+#ifdef CONFIG_PM_SLEEP
+static int omap4_keypad_suspend(struct device *dev)
+{
+ int error;
+
+ if (device_may_wakeup(&pdev->dev)) {
+ error = enable_irq_wake(keypad_data->irq);
+ if (!error)
+ keypad_data->irq_wake_enabled = true;
+ }
+
+ return 0;
+}
+
+static int omap4_keypad_resume(struct device *dev)
+{
+ if (device_may_wakeup(&pdev->dev) && keypad_data->irq_wake_enabled) {
+ disable_irq_wake(keypad_data->irq);
+ keypad_data->irq_wake_enabled = false;
+ }
+
+ return 0;
+}
+
+static SIMPLE_DEV_PM_OPS(omap4_keypad_pm_ops, omap4_keypad_suspend,
+ omap4_keypad_resume);
+
+#define OMAP4_KEYPAD_PM_OPS (&omap4_keypad_pm_ops)
+#else
+#define OMAP4_KEYPAD_PM_OPS NULL
+#endif
+
static struct platform_driver omap4_keypad_driver = {
.probe = omap4_keypad_probe,
.remove = omap4_keypad_remove,
.driver = {
.name = "omap4-keypad",
.owner = THIS_MODULE,
+ .pm = OMAP4_KEYPAD_PM_OPS,
.of_match_table = of_match_ptr(omap_keypad_dt_match),
},
};
--
1.7.9.5
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 1/3] Input: omap-keypad: Enable wakeup capability for keypad.
2013-07-26 16:29 ` [PATCH 1/3] Input: omap-keypad: Enable wakeup capability for keypad Illia Smyrnov
@ 2013-07-26 16:58 ` Illia Smyrnov
0 siblings, 0 replies; 5+ messages in thread
From: Illia Smyrnov @ 2013-07-26 16:58 UTC (permalink / raw)
To: Illia Smyrnov; +Cc: Dmitry Torokhov, linux-input, linux-kernel, linux-omap
Sorry,
this patch is incomplete and was sent by mistake.
I will sent v2
On 07/26/2013 07:29 PM, Illia Smyrnov wrote:
> Enable/disable IRQ wake in suspend/resume handlers
> to make the keypad wakeup capable.
>
> Signed-off-by: Illia Smyrnov <illia.smyrnov@ti.com>
> ---
> drivers/input/keyboard/omap4-keypad.c | 38 +++++++++++++++++++++++++++++++++
> 1 file changed, 38 insertions(+)
>
> diff --git a/drivers/input/keyboard/omap4-keypad.c b/drivers/input/keyboard/omap4-keypad.c
> index 0244262..5f0a2c7 100644
> --- a/drivers/input/keyboard/omap4-keypad.c
> +++ b/drivers/input/keyboard/omap4-keypad.c
> @@ -74,6 +74,7 @@ struct omap4_keypad {
> struct input_dev *input;
>
> void __iomem *base;
> + bool irq_wake_enabled;
> unsigned int irq;
>
> unsigned int rows;
> @@ -380,6 +381,7 @@ static int omap4_keypad_probe(struct platform_device *pdev)
> goto err_free_input;
> }
>
> + device_init_wakeup(&pdev->dev, true);
> pm_runtime_put_sync(&pdev->dev);
>
> error = input_register_device(keypad_data->input);
> @@ -393,6 +395,7 @@ static int omap4_keypad_probe(struct platform_device *pdev)
>
> err_pm_disable:
> pm_runtime_disable(&pdev->dev);
> + device_init_wakeup(&pdev->dev, false);
> free_irq(keypad_data->irq, keypad_data);
> err_free_keymap:
> kfree(keypad_data->keymap);
> @@ -418,6 +421,8 @@ static int omap4_keypad_remove(struct platform_device *pdev)
>
> pm_runtime_disable(&pdev->dev);
>
> + device_init_wakeup(&pdev->dev, false);
> +
> input_unregister_device(keypad_data->input);
>
> iounmap(keypad_data->base);
> @@ -439,12 +444,45 @@ static const struct of_device_id omap_keypad_dt_match[] = {
> MODULE_DEVICE_TABLE(of, omap_keypad_dt_match);
> #endif
>
> +#ifdef CONFIG_PM_SLEEP
> +static int omap4_keypad_suspend(struct device *dev)
> +{
> + int error;
> +
> + if (device_may_wakeup(&pdev->dev)) {
> + error = enable_irq_wake(keypad_data->irq);
> + if (!error)
> + keypad_data->irq_wake_enabled = true;
> + }
> +
> + return 0;
> +}
> +
> +static int omap4_keypad_resume(struct device *dev)
> +{
> + if (device_may_wakeup(&pdev->dev) && keypad_data->irq_wake_enabled) {
> + disable_irq_wake(keypad_data->irq);
> + keypad_data->irq_wake_enabled = false;
> + }
> +
> + return 0;
> +}
> +
> +static SIMPLE_DEV_PM_OPS(omap4_keypad_pm_ops, omap4_keypad_suspend,
> + omap4_keypad_resume);
> +
> +#define OMAP4_KEYPAD_PM_OPS (&omap4_keypad_pm_ops)
> +#else
> +#define OMAP4_KEYPAD_PM_OPS NULL
> +#endif
> +
> static struct platform_driver omap4_keypad_driver = {
> .probe = omap4_keypad_probe,
> .remove = omap4_keypad_remove,
> .driver = {
> .name = "omap4-keypad",
> .owner = THIS_MODULE,
> + .pm = OMAP4_KEYPAD_PM_OPS,
> .of_match_table = of_match_ptr(omap_keypad_dt_match),
> },
> };
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 2/3] Input: omap-keypad: errata i689: Correct debounce time
2013-07-26 16:29 [PATCH 0/3] Input: omap-keypad: Wakeup capability and w/a for i689 errata Illia Smyrnov
2013-07-26 16:29 ` [PATCH 1/3] Input: omap-keypad: Enable wakeup capability for keypad Illia Smyrnov
@ 2013-07-26 16:30 ` Illia Smyrnov
2013-07-26 16:30 ` [PATCH 3/3] Input: omap-keypad: Set irq to level instead of edge Illia Smyrnov
2 siblings, 0 replies; 5+ messages in thread
From: Illia Smyrnov @ 2013-07-26 16:30 UTC (permalink / raw)
To: Dmitry Torokhov; +Cc: linux-input, linux-kernel, linux-omap
From: Axel Haslam <axelhaslam@ti.com>
Set debounce time value to 12ms to workaround the errata.
ERRATA DESCRIPTION:
When a key is released for a time shorter than the debounce time,
in-between 2 key press (KP1 and KP2), the keyboard state machine will go to
idle mode and will never detect the key release (after KP1,and also after KP2),
and thus will never generate a new IRQ indicating the key release.
>From the operating system standpoint, only a key press as been detected,
and the key will keep on being printed on the screen until another or
the same key is pressed again.When the failing state has been reached,
the KBD_STATEMACHINE register will show "idle state" and the KBD_FULLCODE
register won't be empty, this is the signature of the bug.There is no impact
on the power consumption of the system as the state machine goes to IDLE state.
WORKAROUND:
First thing is to program the debounce time correctly:
If X (us) is the maximum time of bounces when a key is pressed or released,
and Y (us) is the minimum time of a key release that is expected to be detected,
then the debounce time should be set to a value inbetween X and Y.
In case it is still possible to get shorter than debounce time key-release
events, then the only solution is to implement a software workaround:
Before printing a second character on the screen, the software must check if
the keyboard has hit the failing condition (cf signature of the bug above)
or if the key is still really pressed and then take the appropriate actions.
Silicon revisions impacted: OMAP4430 ES 1.0,2.0,2.1,2.2,2.3
OMAP4460 ES 1.0,1.1
OMAP5430 ES 1.0
Signed-off-by: Axel Haslam <axelhaslam@ti.com>
Signed-off-by: Illia Smyrnov <illia.smyrnov@ti.com>
---
Based on top of v3.11-rc2
Depends on:
Input: omap-keypad: Cleanup - use bitfiled instead of hardcoded values
https://patchwork.kernel.org/patch/2832913/
drivers/input/keyboard/omap4-keypad.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/input/keyboard/omap4-keypad.c b/drivers/input/keyboard/omap4-keypad.c
index 5f0a2c7..b13589e 100644
--- a/drivers/input/keyboard/omap4-keypad.c
+++ b/drivers/input/keyboard/omap4-keypad.c
@@ -62,8 +62,10 @@
/* OMAP4 values */
#define OMAP4_VAL_IRQDISABLE 0x0
-#define OMAP4_VAL_DEBOUNCINGTIME 0x7
-#define OMAP4_VAL_PVT 0x7
+
+/* Errata i689: set debounce time value to 12ms */
+#define OMAP4_VAL_DEBOUNCINGTIME 0x2
+#define OMAP4_VAL_PVT 0x6
enum {
KBD_REVISION_OMAP4 = 0,
--
1.7.9.5
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 3/3] Input: omap-keypad: Set irq to level instead of edge
2013-07-26 16:29 [PATCH 0/3] Input: omap-keypad: Wakeup capability and w/a for i689 errata Illia Smyrnov
2013-07-26 16:29 ` [PATCH 1/3] Input: omap-keypad: Enable wakeup capability for keypad Illia Smyrnov
2013-07-26 16:30 ` [PATCH 2/3] Input: omap-keypad: errata i689: Correct debounce time Illia Smyrnov
@ 2013-07-26 16:30 ` Illia Smyrnov
2 siblings, 0 replies; 5+ messages in thread
From: Illia Smyrnov @ 2013-07-26 16:30 UTC (permalink / raw)
To: Dmitry Torokhov; +Cc: linux-input, linux-kernel, linux-omap
From: Axel Haslam <axelhaslam@ti.com>
Set mpu irq to level instead of edge, since if mpu is in low power
an edge detection may be lost if the event is a wkup event.
Signed-off-by: Axel Haslam <axelhaslam@ti.com>
Signed-off-by: Illia Smyrnov <illia.smyrnov@ti.com>
---
Based on top of v3.11-rc2
Depends on:
Input: omap-keypad: Convert to threaded IRQ
https://patchwork.kernel.org/patch/2832920/
drivers/input/keyboard/omap4-keypad.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/input/keyboard/omap4-keypad.c b/drivers/input/keyboard/omap4-keypad.c
index b13589e..66a41d6 100644
--- a/drivers/input/keyboard/omap4-keypad.c
+++ b/drivers/input/keyboard/omap4-keypad.c
@@ -374,9 +374,13 @@ static int omap4_keypad_probe(struct platform_device *pdev)
goto err_free_keymap;
}
+ /*
+ * Set irq level detection for mpu. Edge event are missed in gic
+ * if the mpu is in low power and keypad event is a wakeup
+ */
error = request_threaded_irq(keypad_data->irq, omap4_keypad_irq_handler,
omap4_keypad_irq_thread_fn,
- IRQF_TRIGGER_RISING,
+ IRQF_TRIGGER_HIGH,
"omap4-keypad", keypad_data);
if (error) {
dev_err(&pdev->dev, "failed to register interrupt\n");
--
1.7.9.5
^ permalink raw reply related [flat|nested] 5+ messages in thread