linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/3] Input: omap-keypad: Wakeup capability and w/a for i689 errata.
@ 2013-07-26 17:09 Illia Smyrnov
  2013-07-26 17:09 ` [PATCH v2 1/3] Input: omap-keypad: Enable wakeup capability for keypad Illia Smyrnov
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Illia Smyrnov @ 2013-07-26 17:09 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: linux-input, linux-kernel, linux-omap

This patchset adds wake up capability for the keypad and
workaround for i689 errata.

Based on top of v3.11-rc2

Depends on:

Input: omap-keypad: Convert to threaded IRQ
https://patchwork.kernel.org/patch/2832920/

Input: omap-keypad: Cleanup - use bitfiled instead of hardcoded values
https://patchwork.kernel.org/patch/2832913/

Axel Haslam (2):
  Input: omap-keypad: errata i689: Correct debounce time
  Input: omap-keypad: Set irq to level instead of edge

Illia Smyrnov (1):
  Input: omap-keypad: Enable wakeup capability for keypad.

 drivers/input/keyboard/omap4-keypad.c |   55 +++++++++++++++++++++++++++++++--
 1 file changed, 52 insertions(+), 3 deletions(-)

-- 
1.7.9.5


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v2 1/3] Input: omap-keypad: Enable wakeup capability for keypad.
  2013-07-26 17:09 [PATCH v2 0/3] Input: omap-keypad: Wakeup capability and w/a for i689 errata Illia Smyrnov
@ 2013-07-26 17:09 ` Illia Smyrnov
  2013-07-26 17:09 ` [PATCH v2 2/3] Input: omap-keypad: errata i689: Correct debounce time Illia Smyrnov
  2013-07-26 17:09 ` [PATCH v2 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 17:09 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 |   43 +++++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)

diff --git a/drivers/input/keyboard/omap4-keypad.c b/drivers/input/keyboard/omap4-keypad.c
index 0244262..feab00f 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,50 @@ 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)
+{
+	struct platform_device *pdev = to_platform_device(dev);
+	struct omap4_keypad *keypad_data = platform_get_drvdata(pdev);
+	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)
+{
+	struct platform_device *pdev = to_platform_device(dev);
+	struct omap4_keypad *keypad_data = platform_get_drvdata(pdev);
+
+	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

* [PATCH v2 2/3] Input: omap-keypad: errata i689: Correct debounce time
  2013-07-26 17:09 [PATCH v2 0/3] Input: omap-keypad: Wakeup capability and w/a for i689 errata Illia Smyrnov
  2013-07-26 17:09 ` [PATCH v2 1/3] Input: omap-keypad: Enable wakeup capability for keypad Illia Smyrnov
@ 2013-07-26 17:09 ` Illia Smyrnov
  2013-07-26 17:09 ` [PATCH v2 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 17:09 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 feab00f..e8bdc76 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 v2 3/3] Input: omap-keypad: Set irq to level instead of edge
  2013-07-26 17:09 [PATCH v2 0/3] Input: omap-keypad: Wakeup capability and w/a for i689 errata Illia Smyrnov
  2013-07-26 17:09 ` [PATCH v2 1/3] Input: omap-keypad: Enable wakeup capability for keypad Illia Smyrnov
  2013-07-26 17:09 ` [PATCH v2 2/3] Input: omap-keypad: errata i689: Correct debounce time Illia Smyrnov
@ 2013-07-26 17:09 ` Illia Smyrnov
  2013-07-27 17:07   ` Felipe Balbi
  2 siblings, 1 reply; 5+ messages in thread
From: Illia Smyrnov @ 2013-07-26 17:09 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 e8bdc76..7adb53e 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

* Re: [PATCH v2 3/3] Input: omap-keypad: Set irq to level instead of edge
  2013-07-26 17:09 ` [PATCH v2 3/3] Input: omap-keypad: Set irq to level instead of edge Illia Smyrnov
@ 2013-07-27 17:07   ` Felipe Balbi
  0 siblings, 0 replies; 5+ messages in thread
From: Felipe Balbi @ 2013-07-27 17:07 UTC (permalink / raw)
  To: Illia Smyrnov; +Cc: Dmitry Torokhov, linux-input, linux-kernel, linux-omap

[-- Attachment #1: Type: text/plain, Size: 1424 bytes --]

Hi,

On Fri, Jul 26, 2013 at 08:09:06PM +0300, Illia Smyrnov wrote:
> 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 e8bdc76..7adb53e 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 is DT-only, why don't you pass zero here and expect DT to setup
IRQ type correctly for you ?

-- 
balbi

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-07-27 17:07 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-07-26 17:09 [PATCH v2 0/3] Input: omap-keypad: Wakeup capability and w/a for i689 errata Illia Smyrnov
2013-07-26 17:09 ` [PATCH v2 1/3] Input: omap-keypad: Enable wakeup capability for keypad Illia Smyrnov
2013-07-26 17:09 ` [PATCH v2 2/3] Input: omap-keypad: errata i689: Correct debounce time Illia Smyrnov
2013-07-26 17:09 ` [PATCH v2 3/3] Input: omap-keypad: Set irq to level instead of edge Illia Smyrnov
2013-07-27 17:07   ` Felipe Balbi

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).