linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/3] Input: omap-keypad: Convert to threaded IRQ and cleanup
@ 2013-07-24 15:54 Illia Smyrnov
  2013-07-24 15:54 ` [PATCH v3 1/3] Input: omap-keypad: Cleanup - use bitfiled instead of hardcoded values Illia Smyrnov
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Illia Smyrnov @ 2013-07-24 15:54 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: Felipe Balbi, linux-input, linux-kernel, linux-omap

Replace unclear hardcoded values with bit field, convert to threaded IRQ and
clear interrupts when open the keypad.

Based on top of v3.11-rc2.

Tested on OMAP4 SDP.

Illia Smyrnov (3):
  Input: omap-keypad: Cleanup - use bitfiled instead of hardcoded
    values
  Input: omap-keypad: Convert to threaded IRQ
  Input: omap-keypad: Clear interrupts on open

 drivers/input/keyboard/omap4-keypad.c |   57 +++++++++++++++++++--------------
 1 files changed, 33 insertions(+), 24 deletions(-)

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

* [PATCH v3 1/3] Input: omap-keypad: Cleanup - use bitfiled instead of hardcoded values
  2013-07-24 15:54 [PATCH v3 0/3] Input: omap-keypad: Convert to threaded IRQ and cleanup Illia Smyrnov
@ 2013-07-24 15:54 ` Illia Smyrnov
  2013-07-24 15:54 ` [PATCH v3 2/3] Input: omap-keypad: Convert to threaded IRQ Illia Smyrnov
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Illia Smyrnov @ 2013-07-24 15:54 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: Felipe Balbi, linux-input, linux-kernel, linux-omap

Use bitfiled instead of hardcoded values to set KBD_CTRL, use BIT macro,
remove unused defines.

Signed-off-by: Illia Smyrnov <illia.smyrnov@ti.com>
Reviewed-by: Felipe Balbi <balbi@ti.com>
---
 drivers/input/keyboard/omap4-keypad.c |   25 +++++++++++--------------
 1 files changed, 11 insertions(+), 14 deletions(-)

diff --git a/drivers/input/keyboard/omap4-keypad.c b/drivers/input/keyboard/omap4-keypad.c
index f4aa53a..c727548 100644
--- a/drivers/input/keyboard/omap4-keypad.c
+++ b/drivers/input/keyboard/omap4-keypad.c
@@ -53,21 +53,17 @@
 #define OMAP4_KBD_FULLCODE63_32		0x48
 
 /* OMAP4 bit definitions */
-#define OMAP4_DEF_IRQENABLE_EVENTEN	(1 << 0)
-#define OMAP4_DEF_IRQENABLE_LONGKEY	(1 << 1)
-#define OMAP4_DEF_IRQENABLE_TIMEOUTEN	(1 << 2)
-#define OMAP4_DEF_WUP_EVENT_ENA		(1 << 0)
-#define OMAP4_DEF_WUP_LONG_KEY_ENA	(1 << 1)
-#define OMAP4_DEF_CTRL_NOSOFTMODE	(1 << 1)
-#define OMAP4_DEF_CTRLPTVVALUE		(1 << 2)
-#define OMAP4_DEF_CTRLPTV		(1 << 1)
+#define OMAP4_DEF_IRQENABLE_EVENTEN	BIT(0)
+#define OMAP4_DEF_IRQENABLE_LONGKEY	BIT(1)
+#define OMAP4_DEF_WUP_EVENT_ENA		BIT(0)
+#define OMAP4_DEF_WUP_LONG_KEY_ENA	BIT(1)
+#define OMAP4_DEF_CTRL_NOSOFTMODE	BIT(1)
+#define OMAP4_DEF_CTRL_PTV_SHIFT	2
 
 /* OMAP4 values */
-#define OMAP4_VAL_IRQDISABLE		0x00
-#define OMAP4_VAL_DEBOUNCINGTIME	0x07
-#define OMAP4_VAL_FUNCTIONALCFG		0x1E
-
-#define OMAP4_MASK_IRQSTATUSDISABLE	0xFFFF
+#define OMAP4_VAL_IRQDISABLE		0x0
+#define OMAP4_VAL_DEBOUNCINGTIME	0x7
+#define OMAP4_VAL_PVT			0x7
 
 enum {
 	KBD_REVISION_OMAP4 = 0,
@@ -175,7 +171,8 @@ static int omap4_keypad_open(struct input_dev *input)
 	disable_irq(keypad_data->irq);
 
 	kbd_writel(keypad_data, OMAP4_KBD_CTRL,
-			OMAP4_VAL_FUNCTIONALCFG);
+			OMAP4_DEF_CTRL_NOSOFTMODE |
+			(OMAP4_VAL_PVT << OMAP4_DEF_CTRL_PTV_SHIFT));
 	kbd_writel(keypad_data, OMAP4_KBD_DEBOUNCINGTIME,
 			OMAP4_VAL_DEBOUNCINGTIME);
 	kbd_write_irqreg(keypad_data, OMAP4_KBD_IRQSTATUS,
-- 
1.7.0.4


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

* [PATCH v3 2/3] Input: omap-keypad: Convert to threaded IRQ
  2013-07-24 15:54 [PATCH v3 0/3] Input: omap-keypad: Convert to threaded IRQ and cleanup Illia Smyrnov
  2013-07-24 15:54 ` [PATCH v3 1/3] Input: omap-keypad: Cleanup - use bitfiled instead of hardcoded values Illia Smyrnov
@ 2013-07-24 15:54 ` Illia Smyrnov
  2013-07-24 15:54 ` [PATCH v3 3/3] Input: omap-keypad: Clear interrupts on open Illia Smyrnov
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Illia Smyrnov @ 2013-07-24 15:54 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: Felipe Balbi, linux-input, linux-kernel, linux-omap

Convert to use threaded IRQ.

Cc: Felipe Balbi <balbi@ti.com>
Signed-off-by: Illia Smyrnov <illia.smyrnov@ti.com>
Reviewed-by: Felipe Balbi <balbi@ti.com>
---
 drivers/input/keyboard/omap4-keypad.c |   29 ++++++++++++++++++++---------
 1 files changed, 20 insertions(+), 9 deletions(-)

diff --git a/drivers/input/keyboard/omap4-keypad.c b/drivers/input/keyboard/omap4-keypad.c
index c727548..b876a0d 100644
--- a/drivers/input/keyboard/omap4-keypad.c
+++ b/drivers/input/keyboard/omap4-keypad.c
@@ -112,8 +112,22 @@ static void kbd_write_irqreg(struct omap4_keypad *keypad_data,
 }
 
 
-/* Interrupt handler */
-static irqreturn_t omap4_keypad_interrupt(int irq, void *dev_id)
+/* Interrupt handlers */
+static irqreturn_t omap4_keypad_irq_handler(int irq, void *dev_id)
+{
+	struct omap4_keypad *keypad_data = dev_id;
+
+	if (kbd_read_irqreg(keypad_data, OMAP4_KBD_IRQSTATUS)) {
+		/* Disable interrupts */
+		kbd_write_irqreg(keypad_data, OMAP4_KBD_IRQENABLE,
+				 OMAP4_VAL_IRQDISABLE);
+		return IRQ_WAKE_THREAD;
+	}
+
+	return IRQ_NONE;
+}
+
+static irqreturn_t omap4_keypad_irq_thread_fn(int irq, void *dev_id)
 {
 	struct omap4_keypad *keypad_data = dev_id;
 	struct input_dev *input_dev = keypad_data->input;
@@ -121,10 +135,6 @@ static irqreturn_t omap4_keypad_interrupt(int irq, void *dev_id)
 	unsigned int col, row, code, changed;
 	u32 *new_state = (u32 *) key_state;
 
-	/* Disable interrupts */
-	kbd_write_irqreg(keypad_data, OMAP4_KBD_IRQENABLE,
-			 OMAP4_VAL_IRQDISABLE);
-
 	*new_state = kbd_readl(keypad_data, OMAP4_KBD_FULLCODE31_0);
 	*(new_state + 1) = kbd_readl(keypad_data, OMAP4_KBD_FULLCODE63_32);
 
@@ -360,9 +370,10 @@ static int omap4_keypad_probe(struct platform_device *pdev)
 		goto err_free_keymap;
 	}
 
-	error = request_irq(keypad_data->irq, omap4_keypad_interrupt,
-			     IRQF_TRIGGER_RISING,
-			     "omap4-keypad", keypad_data);
+	error = request_threaded_irq(keypad_data->irq, omap4_keypad_irq_handler,
+				     omap4_keypad_irq_thread_fn,
+				     IRQF_TRIGGER_RISING,
+				     "omap4-keypad", keypad_data);
 	if (error) {
 		dev_err(&pdev->dev, "failed to register interrupt\n");
 		goto err_free_input;
-- 
1.7.0.4

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

* [PATCH v3 3/3] Input: omap-keypad: Clear interrupts on open
  2013-07-24 15:54 [PATCH v3 0/3] Input: omap-keypad: Convert to threaded IRQ and cleanup Illia Smyrnov
  2013-07-24 15:54 ` [PATCH v3 1/3] Input: omap-keypad: Cleanup - use bitfiled instead of hardcoded values Illia Smyrnov
  2013-07-24 15:54 ` [PATCH v3 2/3] Input: omap-keypad: Convert to threaded IRQ Illia Smyrnov
@ 2013-07-24 15:54 ` Illia Smyrnov
  2013-07-24 16:06   ` Felipe Balbi
  2013-08-22 11:34 ` [PATCH v3 0/3] Input: omap-keypad: Convert to threaded IRQ and cleanup Smyrnov, Illia
  2013-08-26  6:27 ` Dmitry Torokhov
  4 siblings, 1 reply; 7+ messages in thread
From: Illia Smyrnov @ 2013-07-24 15:54 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: Felipe Balbi, linux-input, linux-kernel, linux-omap

Clear interrupts when open keypad.

According to TRM, the recommended way for keyboard controller
initialization is clear the interrupt-status register, then set up
certain keyboard events for generating an interrupt request and
set up expected source of wake-up event that generates a wake-up
request.

Signed-off-by: Illia Smyrnov <illia.smyrnov@ti.com>
---
 drivers/input/keyboard/omap4-keypad.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/drivers/input/keyboard/omap4-keypad.c b/drivers/input/keyboard/omap4-keypad.c
index b876a0d..0244262 100644
--- a/drivers/input/keyboard/omap4-keypad.c
+++ b/drivers/input/keyboard/omap4-keypad.c
@@ -185,8 +185,9 @@ static int omap4_keypad_open(struct input_dev *input)
 			(OMAP4_VAL_PVT << OMAP4_DEF_CTRL_PTV_SHIFT));
 	kbd_writel(keypad_data, OMAP4_KBD_DEBOUNCINGTIME,
 			OMAP4_VAL_DEBOUNCINGTIME);
+	/* clear pending interrupts */
 	kbd_write_irqreg(keypad_data, OMAP4_KBD_IRQSTATUS,
-			OMAP4_VAL_IRQDISABLE);
+			 kbd_read_irqreg(keypad_data, OMAP4_KBD_IRQSTATUS));
 	kbd_write_irqreg(keypad_data, OMAP4_KBD_IRQENABLE,
 			OMAP4_DEF_IRQENABLE_EVENTEN |
 				OMAP4_DEF_IRQENABLE_LONGKEY);
-- 
1.7.0.4

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

* Re: [PATCH v3 3/3] Input: omap-keypad: Clear interrupts on open
  2013-07-24 15:54 ` [PATCH v3 3/3] Input: omap-keypad: Clear interrupts on open Illia Smyrnov
@ 2013-07-24 16:06   ` Felipe Balbi
  0 siblings, 0 replies; 7+ messages in thread
From: Felipe Balbi @ 2013-07-24 16:06 UTC (permalink / raw)
  To: Illia Smyrnov
  Cc: Dmitry Torokhov, Felipe Balbi, linux-input, linux-kernel,
	linux-omap

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

Hi,

On Wed, Jul 24, 2013 at 06:54:53PM +0300, Illia Smyrnov wrote:
> Clear interrupts when open keypad.
> 
> According to TRM, the recommended way for keyboard controller
> initialization is clear the interrupt-status register, then set up
> certain keyboard events for generating an interrupt request and
> set up expected source of wake-up event that generates a wake-up
> request.
> 
> Signed-off-by: Illia Smyrnov <illia.smyrnov@ti.com>
> ---
>  drivers/input/keyboard/omap4-keypad.c |    3 ++-
>  1 files changed, 2 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/input/keyboard/omap4-keypad.c b/drivers/input/keyboard/omap4-keypad.c
> index b876a0d..0244262 100644
> --- a/drivers/input/keyboard/omap4-keypad.c
> +++ b/drivers/input/keyboard/omap4-keypad.c
> @@ -185,8 +185,9 @@ static int omap4_keypad_open(struct input_dev *input)
>  			(OMAP4_VAL_PVT << OMAP4_DEF_CTRL_PTV_SHIFT));
>  	kbd_writel(keypad_data, OMAP4_KBD_DEBOUNCINGTIME,
>  			OMAP4_VAL_DEBOUNCINGTIME);
> +	/* clear pending interrupts */
>  	kbd_write_irqreg(keypad_data, OMAP4_KBD_IRQSTATUS,
> -			OMAP4_VAL_IRQDISABLE);
> +			 kbd_read_irqreg(keypad_data, OMAP4_KBD_IRQSTATUS));
>  	kbd_write_irqreg(keypad_data, OMAP4_KBD_IRQENABLE,
>  			OMAP4_DEF_IRQENABLE_EVENTEN |
>  				OMAP4_DEF_IRQENABLE_LONGKEY);

Reviewed-by: Felipe Balbi <balbi@ti.com>

-- 
balbi

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

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

* RE: [PATCH v3 0/3] Input: omap-keypad: Convert to threaded IRQ and cleanup
  2013-07-24 15:54 [PATCH v3 0/3] Input: omap-keypad: Convert to threaded IRQ and cleanup Illia Smyrnov
                   ` (2 preceding siblings ...)
  2013-07-24 15:54 ` [PATCH v3 3/3] Input: omap-keypad: Clear interrupts on open Illia Smyrnov
@ 2013-08-22 11:34 ` Smyrnov, Illia
  2013-08-26  6:27 ` Dmitry Torokhov
  4 siblings, 0 replies; 7+ messages in thread
From: Smyrnov, Illia @ 2013-08-22 11:34 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Balbi, Felipe, linux-input@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org

Dmitry,

should I take any additional action regarding these patches?

Best regards,
Illia Smyrnov


________________________________________
From: linux-kernel-owner@vger.kernel.org [linux-kernel-owner@vger.kernel.org] on behalf of Smyrnov, Illia
Sent: Wednesday, July 24, 2013 6:54 PM
To: Dmitry Torokhov
Cc: Balbi, Felipe; linux-input@vger.kernel.org; linux-kernel@vger.kernel.org; linux-omap@vger.kernel.org
Subject: [PATCH v3 0/3] Input: omap-keypad: Convert to threaded IRQ and cleanup

Replace unclear hardcoded values with bit field, convert to threaded IRQ and
clear interrupts when open the keypad.

Based on top of v3.11-rc2.

Tested on OMAP4 SDP.

Illia Smyrnov (3):
  Input: omap-keypad: Cleanup - use bitfiled instead of hardcoded
    values
  Input: omap-keypad: Convert to threaded IRQ
  Input: omap-keypad: Clear interrupts on open

 drivers/input/keyboard/omap4-keypad.c |   57 +++++++++++++++++++--------------
 1 files changed, 33 insertions(+), 24 deletions(-)


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

* Re: [PATCH v3 0/3] Input: omap-keypad: Convert to threaded IRQ and cleanup
  2013-07-24 15:54 [PATCH v3 0/3] Input: omap-keypad: Convert to threaded IRQ and cleanup Illia Smyrnov
                   ` (3 preceding siblings ...)
  2013-08-22 11:34 ` [PATCH v3 0/3] Input: omap-keypad: Convert to threaded IRQ and cleanup Smyrnov, Illia
@ 2013-08-26  6:27 ` Dmitry Torokhov
  4 siblings, 0 replies; 7+ messages in thread
From: Dmitry Torokhov @ 2013-08-26  6:27 UTC (permalink / raw)
  To: Illia Smyrnov; +Cc: Felipe Balbi, linux-input, linux-kernel, linux-omap

On Wed, Jul 24, 2013 at 06:54:50PM +0300, Illia Smyrnov wrote:
> Replace unclear hardcoded values with bit field, convert to threaded IRQ and
> clear interrupts when open the keypad.
> 
> Based on top of v3.11-rc2.
> 
> Tested on OMAP4 SDP.
> 
> Illia Smyrnov (3):
>   Input: omap-keypad: Cleanup - use bitfiled instead of hardcoded
>     values
>   Input: omap-keypad: Convert to threaded IRQ
>   Input: omap-keypad: Clear interrupts on open
> 
>  drivers/input/keyboard/omap4-keypad.c |   57 +++++++++++++++++++--------------
>  1 files changed, 33 insertions(+), 24 deletions(-)
> 

Applied, thank you.

-- 
Dmitry

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

end of thread, other threads:[~2013-08-26  6:36 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-07-24 15:54 [PATCH v3 0/3] Input: omap-keypad: Convert to threaded IRQ and cleanup Illia Smyrnov
2013-07-24 15:54 ` [PATCH v3 1/3] Input: omap-keypad: Cleanup - use bitfiled instead of hardcoded values Illia Smyrnov
2013-07-24 15:54 ` [PATCH v3 2/3] Input: omap-keypad: Convert to threaded IRQ Illia Smyrnov
2013-07-24 15:54 ` [PATCH v3 3/3] Input: omap-keypad: Clear interrupts on open Illia Smyrnov
2013-07-24 16:06   ` Felipe Balbi
2013-08-22 11:34 ` [PATCH v3 0/3] Input: omap-keypad: Convert to threaded IRQ and cleanup Smyrnov, Illia
2013-08-26  6:27 ` Dmitry Torokhov

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