* [PATCH 07/17] Input: omap-keypad: Remove dependencies to mach includes
[not found] <20120911052934.29637.9190.stgit@muffinssi.local>
@ 2012-09-11 5:30 ` Tony Lindgren
2012-09-11 5:57 ` Felipe Balbi
0 siblings, 1 reply; 7+ messages in thread
From: Tony Lindgren @ 2012-09-11 5:30 UTC (permalink / raw)
To: linux-arm-kernel; +Cc: linux-omap, Dmitry Torokhov, linux-input
We can't build CONFIG_ARCH_OMAP1 set with ARCH_OMAP2PLUS because
of different compiler flags needed, so we can define omap_kp_24xx()
instead of using cpu_is_omap24xx(). This way we can remove
depency to plat and mach headers which is needed for ARM common
zImage support.
Also remove INT_KEYBOARD by using omap_kp->irq.
Note that this patch depends on an earlier patch
"ARM: OMAP: Move gpio.h to include/linux/platform_data".
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: linux-input@vger.kernel.org
Signed-off-by: Tony Lindgren <tony@atomide.com>
---
drivers/input/keyboard/omap-keypad.c | 34 ++++++++++++++++++----------------
1 file changed, 18 insertions(+), 16 deletions(-)
diff --git a/drivers/input/keyboard/omap-keypad.c b/drivers/input/keyboard/omap-keypad.c
index a0222db..171d739 100644
--- a/drivers/input/keyboard/omap-keypad.c
+++ b/drivers/input/keyboard/omap-keypad.c
@@ -35,16 +35,19 @@
#include <linux/mutex.h>
#include <linux/errno.h>
#include <linux/slab.h>
-#include <asm/gpio.h>
+#include <linux/gpio.h>
+#include <linux/platform_data/gpio-omap.h>
#include <plat/keypad.h>
-#include <plat/menelaus.h>
-#include <asm/irq.h>
-#include <mach/hardware.h>
-#include <asm/io.h>
-#include <plat/mux.h>
#undef NEW_BOARD_LEARNING_MODE
+#ifdef CONFIG_ARCH_OMAP1
+#define omap_kp_24xx() 0
+#else
+#define omap_kp_24xx() 1
+#endif
+
+static struct omap_kp *omap_kp;
static void omap_kp_tasklet(unsigned long);
static void omap_kp_timer(unsigned long);
@@ -99,7 +102,7 @@ static irqreturn_t omap_kp_interrupt(int irq, void *dev_id)
struct omap_kp *omap_kp = dev_id;
/* disable keyboard interrupt and schedule for handling */
- if (cpu_is_omap24xx()) {
+ if (omap_kp_24xx()) {
int i;
for (i = 0; i < omap_kp->rows; i++) {
@@ -134,7 +137,7 @@ static void omap_kp_scan_keypad(struct omap_kp *omap_kp, unsigned char *state)
int col = 0;
/* read the keypad status */
- if (cpu_is_omap24xx()) {
+ if (omap_kp_24xx()) {
/* read the keypad status */
for (col = 0; col < omap_kp->cols; col++) {
set_col_gpio_val(omap_kp, ~(1 << col));
@@ -222,7 +225,7 @@ static void omap_kp_tasklet(unsigned long data)
mod_timer(&omap_kp_data->timer, jiffies + delay);
} else {
/* enable interrupts */
- if (cpu_is_omap24xx()) {
+ if (omap_kp_24xx()) {
int i;
for (i = 0; i < omap_kp_data->rows; i++)
enable_irq(gpio_to_irq(row_gpios[i]));
@@ -253,9 +256,9 @@ static ssize_t omap_kp_enable_store(struct device *dev, struct device_attribute
mutex_lock(&kp_enable_mutex);
if (state != kp_enable) {
if (state)
- enable_irq(INT_KEYBOARD);
+ enable_irq(omap_kp->irq);
else
- disable_irq(INT_KEYBOARD);
+ disable_irq(omap_kp->irq);
kp_enable = state;
}
mutex_unlock(&kp_enable_mutex);
@@ -286,7 +289,6 @@ static int omap_kp_resume(struct platform_device *dev)
static int __devinit omap_kp_probe(struct platform_device *pdev)
{
- struct omap_kp *omap_kp;
struct input_dev *input_dev;
struct omap_kp_platform_data *pdata = pdev->dev.platform_data;
int i, col_idx, row_idx, irq_idx, ret;
@@ -314,7 +316,7 @@ static int __devinit omap_kp_probe(struct platform_device *pdev)
omap_kp->input = input_dev;
/* Disable the interrupt for the MPUIO keyboard */
- if (!cpu_is_omap24xx())
+ if (!omap_kp_24xx())
omap_writew(1, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBD_MASKIT);
if (pdata->delay)
@@ -328,7 +330,7 @@ static int __devinit omap_kp_probe(struct platform_device *pdev)
omap_kp->rows = pdata->rows;
omap_kp->cols = pdata->cols;
- if (cpu_is_omap24xx()) {
+ if (omap_kp_24xx()) {
/* Cols: outputs */
for (col_idx = 0; col_idx < omap_kp->cols; col_idx++) {
if (gpio_request(col_gpios[col_idx], "omap_kp_col") < 0) {
@@ -394,7 +396,7 @@ static int __devinit omap_kp_probe(struct platform_device *pdev)
/* scan current status and enable interrupt */
omap_kp_scan_keypad(omap_kp, keypad_state);
- if (!cpu_is_omap24xx()) {
+ if (!omap_kp_24xx()) {
omap_kp->irq = platform_get_irq(pdev, 0);
if (omap_kp->irq >= 0) {
if (request_irq(omap_kp->irq, omap_kp_interrupt, 0,
@@ -439,7 +441,7 @@ static int __devexit omap_kp_remove(struct platform_device *pdev)
/* disable keypad interrupt handling */
tasklet_disable(&kp_tasklet);
- if (cpu_is_omap24xx()) {
+ if (omap_kp_24xx()) {
int i;
for (i = 0; i < omap_kp->cols; i++)
gpio_free(col_gpios[i]);
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 07/17] Input: omap-keypad: Remove dependencies to mach includes
2012-09-11 5:30 ` [PATCH 07/17] Input: omap-keypad: Remove dependencies to mach includes Tony Lindgren
@ 2012-09-11 5:57 ` Felipe Balbi
2012-09-11 6:16 ` Tony Lindgren
0 siblings, 1 reply; 7+ messages in thread
From: Felipe Balbi @ 2012-09-11 5:57 UTC (permalink / raw)
To: Tony Lindgren
Cc: linux-arm-kernel, linux-omap, Dmitry Torokhov, linux-input,
Sourav Poddar
[-- Attachment #1: Type: text/plain, Size: 5713 bytes --]
Hi,
On Mon, Sep 10, 2012 at 10:30:59PM -0700, Tony Lindgren wrote:
> We can't build CONFIG_ARCH_OMAP1 set with ARCH_OMAP2PLUS because
> of different compiler flags needed, so we can define omap_kp_24xx()
> instead of using cpu_is_omap24xx(). This way we can remove
> depency to plat and mach headers which is needed for ARM common
> zImage support.
>
> Also remove INT_KEYBOARD by using omap_kp->irq.
>
> Note that this patch depends on an earlier patch
> "ARM: OMAP: Move gpio.h to include/linux/platform_data".
>
> Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> Cc: linux-input@vger.kernel.org
> Signed-off-by: Tony Lindgren <tony@atomide.com>
> ---
> drivers/input/keyboard/omap-keypad.c | 34 ++++++++++++++++++----------------
> 1 file changed, 18 insertions(+), 16 deletions(-)
>
> diff --git a/drivers/input/keyboard/omap-keypad.c b/drivers/input/keyboard/omap-keypad.c
> index a0222db..171d739 100644
> --- a/drivers/input/keyboard/omap-keypad.c
> +++ b/drivers/input/keyboard/omap-keypad.c
> @@ -35,16 +35,19 @@
> #include <linux/mutex.h>
> #include <linux/errno.h>
> #include <linux/slab.h>
> -#include <asm/gpio.h>
> +#include <linux/gpio.h>
> +#include <linux/platform_data/gpio-omap.h>
> #include <plat/keypad.h>
> -#include <plat/menelaus.h>
> -#include <asm/irq.h>
> -#include <mach/hardware.h>
> -#include <asm/io.h>
> -#include <plat/mux.h>
>
> #undef NEW_BOARD_LEARNING_MODE
>
> +#ifdef CONFIG_ARCH_OMAP1
> +#define omap_kp_24xx() 0
> +#else
> +#define omap_kp_24xx() 1
> +#endif
I would rather use revision detection or different driver names (if
revision register is broken).
> +static struct omap_kp *omap_kp;
please don't. This will prevent multiple instances of this driver. Even
though I don't think we will ever have an omap with multiple keypad
instances, it's still not a good practice IMHO.
Also, this ends up being "hidden" (if you have a better work let me
know) in most functions since they either pass omap_kp as argument or
define a local omap_kp variable.
Sourav, is the revision register on this IP working fine across multiple
OMAPs ?
> static void omap_kp_tasklet(unsigned long);
> static void omap_kp_timer(unsigned long);
>
> @@ -99,7 +102,7 @@ static irqreturn_t omap_kp_interrupt(int irq, void *dev_id)
> struct omap_kp *omap_kp = dev_id;
>
> /* disable keyboard interrupt and schedule for handling */
> - if (cpu_is_omap24xx()) {
> + if (omap_kp_24xx()) {
> int i;
>
> for (i = 0; i < omap_kp->rows; i++) {
> @@ -134,7 +137,7 @@ static void omap_kp_scan_keypad(struct omap_kp *omap_kp, unsigned char *state)
> int col = 0;
>
> /* read the keypad status */
> - if (cpu_is_omap24xx()) {
> + if (omap_kp_24xx()) {
> /* read the keypad status */
> for (col = 0; col < omap_kp->cols; col++) {
> set_col_gpio_val(omap_kp, ~(1 << col));
> @@ -222,7 +225,7 @@ static void omap_kp_tasklet(unsigned long data)
> mod_timer(&omap_kp_data->timer, jiffies + delay);
> } else {
> /* enable interrupts */
> - if (cpu_is_omap24xx()) {
> + if (omap_kp_24xx()) {
> int i;
> for (i = 0; i < omap_kp_data->rows; i++)
> enable_irq(gpio_to_irq(row_gpios[i]));
> @@ -253,9 +256,9 @@ static ssize_t omap_kp_enable_store(struct device *dev, struct device_attribute
> mutex_lock(&kp_enable_mutex);
> if (state != kp_enable) {
> if (state)
> - enable_irq(INT_KEYBOARD);
> + enable_irq(omap_kp->irq);
> else
> - disable_irq(INT_KEYBOARD);
> + disable_irq(omap_kp->irq);
GREAT!! :-)
> kp_enable = state;
> }
> mutex_unlock(&kp_enable_mutex);
> @@ -286,7 +289,6 @@ static int omap_kp_resume(struct platform_device *dev)
>
> static int __devinit omap_kp_probe(struct platform_device *pdev)
> {
> - struct omap_kp *omap_kp;
???? I don't see the point for that global omap_kp, actually ...
> struct input_dev *input_dev;
> struct omap_kp_platform_data *pdata = pdev->dev.platform_data;
> int i, col_idx, row_idx, irq_idx, ret;
> @@ -314,7 +316,7 @@ static int __devinit omap_kp_probe(struct platform_device *pdev)
> omap_kp->input = input_dev;
>
> /* Disable the interrupt for the MPUIO keyboard */
> - if (!cpu_is_omap24xx())
> + if (!omap_kp_24xx())
> omap_writew(1, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBD_MASKIT);
>
> if (pdata->delay)
> @@ -328,7 +330,7 @@ static int __devinit omap_kp_probe(struct platform_device *pdev)
> omap_kp->rows = pdata->rows;
> omap_kp->cols = pdata->cols;
>
> - if (cpu_is_omap24xx()) {
> + if (omap_kp_24xx()) {
> /* Cols: outputs */
> for (col_idx = 0; col_idx < omap_kp->cols; col_idx++) {
> if (gpio_request(col_gpios[col_idx], "omap_kp_col") < 0) {
> @@ -394,7 +396,7 @@ static int __devinit omap_kp_probe(struct platform_device *pdev)
>
> /* scan current status and enable interrupt */
> omap_kp_scan_keypad(omap_kp, keypad_state);
> - if (!cpu_is_omap24xx()) {
> + if (!omap_kp_24xx()) {
> omap_kp->irq = platform_get_irq(pdev, 0);
> if (omap_kp->irq >= 0) {
> if (request_irq(omap_kp->irq, omap_kp_interrupt, 0,
> @@ -439,7 +441,7 @@ static int __devexit omap_kp_remove(struct platform_device *pdev)
>
> /* disable keypad interrupt handling */
> tasklet_disable(&kp_tasklet);
> - if (cpu_is_omap24xx()) {
> + if (omap_kp_24xx()) {
> int i;
> for (i = 0; i < omap_kp->cols; i++)
> gpio_free(col_gpios[i]);
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-omap" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
--
balbi
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 07/17] Input: omap-keypad: Remove dependencies to mach includes
2012-09-11 5:57 ` Felipe Balbi
@ 2012-09-11 6:16 ` Tony Lindgren
2012-09-11 17:56 ` Tony Lindgren
0 siblings, 1 reply; 7+ messages in thread
From: Tony Lindgren @ 2012-09-11 6:16 UTC (permalink / raw)
To: Felipe Balbi
Cc: linux-arm-kernel, linux-omap, Dmitry Torokhov, linux-input,
Sourav Poddar
* Felipe Balbi <balbi@ti.com> [120910 23:02]:
>
> >
> > +#ifdef CONFIG_ARCH_OMAP1
> > +#define omap_kp_24xx() 0
> > +#else
> > +#define omap_kp_24xx() 1
> > +#endif
>
> I would rather use revision detection or different driver names (if
> revision register is broken).
Hmm actually looks like we can actually remove all the omap2+
support as we no longer have any users for this one. I think I
already converted the last one to matrix-keypad a while back.
> > +static struct omap_kp *omap_kp;
>
> please don't. This will prevent multiple instances of this driver. Even
> though I don't think we will ever have an omap with multiple keypad
> instances, it's still not a good practice IMHO.
>
> Also, this ends up being "hidden" (if you have a better work let me
> know) in most functions since they either pass omap_kp as argument or
> define a local omap_kp variable.
Yeah good point, I'll update that and remove the omap2+ support
for this driver.
> Sourav, is the revision register on this IP working fine across multiple
> OMAPs ?
Sounds like no need for that, as we're no longer using this for
omap2+..
> > @@ -253,9 +256,9 @@ static ssize_t omap_kp_enable_store(struct device *dev, struct device_attribute
> > mutex_lock(&kp_enable_mutex);
> > if (state != kp_enable) {
> > if (state)
> > - enable_irq(INT_KEYBOARD);
> > + enable_irq(omap_kp->irq);
> > else
> > - disable_irq(INT_KEYBOARD);
> > + disable_irq(omap_kp->irq);
>
> GREAT!! :-)
Heh yeah that nice way to do it :)
> > static int __devinit omap_kp_probe(struct platform_device *pdev)
> > {
> > - struct omap_kp *omap_kp;
>
> ???? I don't see the point for that global omap_kp, actually ...
Yes you're right. Will send an updated one tomorrow.
Regards,
Tony
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 07/17] Input: omap-keypad: Remove dependencies to mach includes
2012-09-11 6:16 ` Tony Lindgren
@ 2012-09-11 17:56 ` Tony Lindgren
2012-09-11 18:27 ` Felipe Balbi
2012-09-12 6:39 ` Poddar, Sourav
0 siblings, 2 replies; 7+ messages in thread
From: Tony Lindgren @ 2012-09-11 17:56 UTC (permalink / raw)
To: Felipe Balbi
Cc: linux-arm-kernel, linux-omap, Dmitry Torokhov, linux-input,
Sourav Poddar
* Tony Lindgren <tony@atomide.com> [120910 23:17]:
> * Felipe Balbi <balbi@ti.com> [120910 23:02]:
>
> > > static int __devinit omap_kp_probe(struct platform_device *pdev)
> > > {
> > > - struct omap_kp *omap_kp;
> >
> > ???? I don't see the point for that global omap_kp, actually ...
>
> Yes you're right. Will send an updated one tomorrow.
Here's the updated patch that just removes all omap2+ code,
and does not use the global omap_kp.
Regards,
Tony
From: Tony Lindgren <tony@atomide.com>
Date: Fri, 7 Sep 2012 13:27:58 -0700
Subject: [PATCH] Input: omap-keypad: Remove dependencies to mach includes
Remove support for omap2+ as it's no longer needed since
it's using matrix-keypad. This way we can remove depency
to plat and mach headers which is needed for ARM common
zImage support.
Also remove INT_KEYBOARD by using omap_kp->irq.
Note that this patch depends on an earlier patch
"ARM: OMAP: Move gpio.h to include/linux/platform_data".
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: linux-input@vger.kernel.org
Signed-off-by: Tony Lindgren <tony@atomide.com>
--- a/drivers/input/keyboard/Kconfig
+++ b/drivers/input/keyboard/Kconfig
@@ -533,7 +533,7 @@ config KEYBOARD_DAVINCI
config KEYBOARD_OMAP
tristate "TI OMAP keypad support"
- depends on (ARCH_OMAP1 || ARCH_OMAP2)
+ depends on ARCH_OMAP1
select INPUT_MATRIXKMAP
help
Say Y here if you want to use the OMAP keypad.
diff --git a/drivers/input/keyboard/omap-keypad.c b/drivers/input/keyboard/omap-keypad.c
index a0222db..2bda5f0b 100644
--- a/drivers/input/keyboard/omap-keypad.c
+++ b/drivers/input/keyboard/omap-keypad.c
@@ -35,13 +35,9 @@
#include <linux/mutex.h>
#include <linux/errno.h>
#include <linux/slab.h>
-#include <asm/gpio.h>
+#include <linux/gpio.h>
+#include <linux/platform_data/gpio-omap.h>
#include <plat/keypad.h>
-#include <plat/menelaus.h>
-#include <asm/irq.h>
-#include <mach/hardware.h>
-#include <asm/io.h>
-#include <plat/mux.h>
#undef NEW_BOARD_LEARNING_MODE
@@ -96,28 +92,8 @@ static u8 get_row_gpio_val(struct omap_kp *omap_kp)
static irqreturn_t omap_kp_interrupt(int irq, void *dev_id)
{
- struct omap_kp *omap_kp = dev_id;
-
/* disable keyboard interrupt and schedule for handling */
- if (cpu_is_omap24xx()) {
- int i;
-
- for (i = 0; i < omap_kp->rows; i++) {
- int gpio_irq = gpio_to_irq(row_gpios[i]);
- /*
- * The interrupt which we're currently handling should
- * be disabled _nosync() to avoid deadlocks waiting
- * for this handler to complete. All others should
- * be disabled the regular way for SMP safety.
- */
- if (gpio_irq == irq)
- disable_irq_nosync(gpio_irq);
- else
- disable_irq(gpio_irq);
- }
- } else
- /* disable keyboard interrupt and schedule for handling */
- omap_writew(1, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBD_MASKIT);
+ omap_writew(1, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBD_MASKIT);
tasklet_schedule(&kp_tasklet);
@@ -133,33 +109,22 @@ static void omap_kp_scan_keypad(struct omap_kp *omap_kp, unsigned char *state)
{
int col = 0;
- /* read the keypad status */
- if (cpu_is_omap24xx()) {
- /* read the keypad status */
- for (col = 0; col < omap_kp->cols; col++) {
- set_col_gpio_val(omap_kp, ~(1 << col));
- state[col] = ~(get_row_gpio_val(omap_kp)) & 0xff;
- }
- set_col_gpio_val(omap_kp, 0);
-
- } else {
- /* disable keyboard interrupt and schedule for handling */
- omap_writew(1, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBD_MASKIT);
+ /* disable keyboard interrupt and schedule for handling */
+ omap_writew(1, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBD_MASKIT);
- /* read the keypad status */
- omap_writew(0xff, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBC);
- for (col = 0; col < omap_kp->cols; col++) {
- omap_writew(~(1 << col) & 0xff,
- OMAP1_MPUIO_BASE + OMAP_MPUIO_KBC);
+ /* read the keypad status */
+ omap_writew(0xff, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBC);
+ for (col = 0; col < omap_kp->cols; col++) {
+ omap_writew(~(1 << col) & 0xff,
+ OMAP1_MPUIO_BASE + OMAP_MPUIO_KBC);
- udelay(omap_kp->delay);
+ udelay(omap_kp->delay);
- state[col] = ~omap_readw(OMAP1_MPUIO_BASE +
- OMAP_MPUIO_KBR_LATCH) & 0xff;
- }
- omap_writew(0x00, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBC);
- udelay(2);
+ state[col] = ~omap_readw(OMAP1_MPUIO_BASE +
+ OMAP_MPUIO_KBR_LATCH) & 0xff;
}
+ omap_writew(0x00, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBC);
+ udelay(2);
}
static void omap_kp_tasklet(unsigned long data)
@@ -222,14 +187,8 @@ static void omap_kp_tasklet(unsigned long data)
mod_timer(&omap_kp_data->timer, jiffies + delay);
} else {
/* enable interrupts */
- if (cpu_is_omap24xx()) {
- int i;
- for (i = 0; i < omap_kp_data->rows; i++)
- enable_irq(gpio_to_irq(row_gpios[i]));
- } else {
- omap_writew(0, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBD_MASKIT);
- kp_cur_group = -1;
- }
+ omap_writew(0, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBD_MASKIT);
+ kp_cur_group = -1;
}
}
@@ -242,6 +201,7 @@ static ssize_t omap_kp_enable_show(struct device *dev,
static ssize_t omap_kp_enable_store(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{
+ struct omap_kp *omap_kp = dev_get_drvdata(dev);
int state;
if (sscanf(buf, "%u", &state) != 1)
@@ -253,9 +213,9 @@ static ssize_t omap_kp_enable_store(struct device *dev, struct device_attribute
mutex_lock(&kp_enable_mutex);
if (state != kp_enable) {
if (state)
- enable_irq(INT_KEYBOARD);
+ enable_irq(omap_kp->irq);
else
- disable_irq(INT_KEYBOARD);
+ disable_irq(omap_kp->irq);
kp_enable = state;
}
mutex_unlock(&kp_enable_mutex);
@@ -289,7 +249,7 @@ static int __devinit omap_kp_probe(struct platform_device *pdev)
struct omap_kp *omap_kp;
struct input_dev *input_dev;
struct omap_kp_platform_data *pdata = pdev->dev.platform_data;
- int i, col_idx, row_idx, irq_idx, ret;
+ int i, col_idx, row_idx, ret;
unsigned int row_shift, keycodemax;
if (!pdata->rows || !pdata->cols || !pdata->keymap_data) {
@@ -314,8 +274,7 @@ static int __devinit omap_kp_probe(struct platform_device *pdev)
omap_kp->input = input_dev;
/* Disable the interrupt for the MPUIO keyboard */
- if (!cpu_is_omap24xx())
- omap_writew(1, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBD_MASKIT);
+ omap_writew(1, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBD_MASKIT);
if (pdata->delay)
omap_kp->delay = pdata->delay;
@@ -328,31 +287,8 @@ static int __devinit omap_kp_probe(struct platform_device *pdev)
omap_kp->rows = pdata->rows;
omap_kp->cols = pdata->cols;
- if (cpu_is_omap24xx()) {
- /* Cols: outputs */
- for (col_idx = 0; col_idx < omap_kp->cols; col_idx++) {
- if (gpio_request(col_gpios[col_idx], "omap_kp_col") < 0) {
- printk(KERN_ERR "Failed to request"
- "GPIO%d for keypad\n",
- col_gpios[col_idx]);
- goto err1;
- }
- gpio_direction_output(col_gpios[col_idx], 0);
- }
- /* Rows: inputs */
- for (row_idx = 0; row_idx < omap_kp->rows; row_idx++) {
- if (gpio_request(row_gpios[row_idx], "omap_kp_row") < 0) {
- printk(KERN_ERR "Failed to request"
- "GPIO%d for keypad\n",
- row_gpios[row_idx]);
- goto err2;
- }
- gpio_direction_input(row_gpios[row_idx]);
- }
- } else {
- col_idx = 0;
- row_idx = 0;
- }
+ col_idx = 0;
+ row_idx = 0;
setup_timer(&omap_kp->timer, omap_kp_timer, (unsigned long)omap_kp);
@@ -394,27 +330,16 @@ static int __devinit omap_kp_probe(struct platform_device *pdev)
/* scan current status and enable interrupt */
omap_kp_scan_keypad(omap_kp, keypad_state);
- if (!cpu_is_omap24xx()) {
- omap_kp->irq = platform_get_irq(pdev, 0);
- if (omap_kp->irq >= 0) {
- if (request_irq(omap_kp->irq, omap_kp_interrupt, 0,
- "omap-keypad", omap_kp) < 0)
- goto err4;
- }
- omap_writew(0, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBD_MASKIT);
- } else {
- for (irq_idx = 0; irq_idx < omap_kp->rows; irq_idx++) {
- if (request_irq(gpio_to_irq(row_gpios[irq_idx]),
- omap_kp_interrupt,
- IRQF_TRIGGER_FALLING,
- "omap-keypad", omap_kp) < 0)
- goto err5;
- }
+ omap_kp->irq = platform_get_irq(pdev, 0);
+ if (omap_kp->irq >= 0) {
+ if (request_irq(omap_kp->irq, omap_kp_interrupt, 0,
+ "omap-keypad", omap_kp) < 0)
+ goto err4;
}
+ omap_writew(0, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBD_MASKIT);
+
return 0;
-err5:
- for (i = irq_idx - 1; i >=0; i--)
- free_irq(row_gpios[i], omap_kp);
+
err4:
input_unregister_device(omap_kp->input);
input_dev = NULL;
@@ -423,7 +348,6 @@ err3:
err2:
for (i = row_idx - 1; i >=0; i--)
gpio_free(row_gpios[i]);
-err1:
for (i = col_idx - 1; i >=0; i--)
gpio_free(col_gpios[i]);
@@ -439,18 +363,8 @@ static int __devexit omap_kp_remove(struct platform_device *pdev)
/* disable keypad interrupt handling */
tasklet_disable(&kp_tasklet);
- if (cpu_is_omap24xx()) {
- int i;
- for (i = 0; i < omap_kp->cols; i++)
- gpio_free(col_gpios[i]);
- for (i = 0; i < omap_kp->rows; i++) {
- gpio_free(row_gpios[i]);
- free_irq(gpio_to_irq(row_gpios[i]), omap_kp);
- }
- } else {
- omap_writew(1, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBD_MASKIT);
- free_irq(omap_kp->irq, omap_kp);
- }
+ omap_writew(1, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBD_MASKIT);
+ free_irq(omap_kp->irq, omap_kp);
del_timer_sync(&omap_kp->timer);
tasklet_kill(&kp_tasklet);
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 07/17] Input: omap-keypad: Remove dependencies to mach includes
2012-09-11 17:56 ` Tony Lindgren
@ 2012-09-11 18:27 ` Felipe Balbi
2012-09-12 4:39 ` Poddar, Sourav
2012-09-12 6:39 ` Poddar, Sourav
1 sibling, 1 reply; 7+ messages in thread
From: Felipe Balbi @ 2012-09-11 18:27 UTC (permalink / raw)
To: Tony Lindgren
Cc: Felipe Balbi, linux-arm-kernel, linux-omap, Dmitry Torokhov,
linux-input, Sourav Poddar
[-- Attachment #1: Type: text/plain, Size: 10383 bytes --]
Hi,
On Tue, Sep 11, 2012 at 10:56:34AM -0700, Tony Lindgren wrote:
> * Tony Lindgren <tony@atomide.com> [120910 23:17]:
> > * Felipe Balbi <balbi@ti.com> [120910 23:02]:
> >
> > > > static int __devinit omap_kp_probe(struct platform_device *pdev)
> > > > {
> > > > - struct omap_kp *omap_kp;
> > >
> > > ???? I don't see the point for that global omap_kp, actually ...
> >
> > Yes you're right. Will send an updated one tomorrow.
>
> Here's the updated patch that just removes all omap2+ code,
> and does not use the global omap_kp.
>
> Regards,
>
> Tony
>
>
> From: Tony Lindgren <tony@atomide.com>
> Date: Fri, 7 Sep 2012 13:27:58 -0700
> Subject: [PATCH] Input: omap-keypad: Remove dependencies to mach includes
>
> Remove support for omap2+ as it's no longer needed since
> it's using matrix-keypad. This way we can remove depency
> to plat and mach headers which is needed for ARM common
> zImage support.
>
> Also remove INT_KEYBOARD by using omap_kp->irq.
>
> Note that this patch depends on an earlier patch
> "ARM: OMAP: Move gpio.h to include/linux/platform_data".
>
> Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> Cc: linux-input@vger.kernel.org
> Signed-off-by: Tony Lindgren <tony@atomide.com>
This looks ok to me from a code standpoint. Sourav how does this look to
you ?
FWIW:
Reviewed-by: Felipe Balbi <balbi@ti.com>
>
> --- a/drivers/input/keyboard/Kconfig
> +++ b/drivers/input/keyboard/Kconfig
> @@ -533,7 +533,7 @@ config KEYBOARD_DAVINCI
>
> config KEYBOARD_OMAP
> tristate "TI OMAP keypad support"
> - depends on (ARCH_OMAP1 || ARCH_OMAP2)
> + depends on ARCH_OMAP1
> select INPUT_MATRIXKMAP
> help
> Say Y here if you want to use the OMAP keypad.
> diff --git a/drivers/input/keyboard/omap-keypad.c b/drivers/input/keyboard/omap-keypad.c
> index a0222db..2bda5f0b 100644
> --- a/drivers/input/keyboard/omap-keypad.c
> +++ b/drivers/input/keyboard/omap-keypad.c
> @@ -35,13 +35,9 @@
> #include <linux/mutex.h>
> #include <linux/errno.h>
> #include <linux/slab.h>
> -#include <asm/gpio.h>
> +#include <linux/gpio.h>
> +#include <linux/platform_data/gpio-omap.h>
> #include <plat/keypad.h>
> -#include <plat/menelaus.h>
> -#include <asm/irq.h>
> -#include <mach/hardware.h>
> -#include <asm/io.h>
> -#include <plat/mux.h>
>
> #undef NEW_BOARD_LEARNING_MODE
>
> @@ -96,28 +92,8 @@ static u8 get_row_gpio_val(struct omap_kp *omap_kp)
>
> static irqreturn_t omap_kp_interrupt(int irq, void *dev_id)
> {
> - struct omap_kp *omap_kp = dev_id;
> -
> /* disable keyboard interrupt and schedule for handling */
> - if (cpu_is_omap24xx()) {
> - int i;
> -
> - for (i = 0; i < omap_kp->rows; i++) {
> - int gpio_irq = gpio_to_irq(row_gpios[i]);
> - /*
> - * The interrupt which we're currently handling should
> - * be disabled _nosync() to avoid deadlocks waiting
> - * for this handler to complete. All others should
> - * be disabled the regular way for SMP safety.
> - */
> - if (gpio_irq == irq)
> - disable_irq_nosync(gpio_irq);
> - else
> - disable_irq(gpio_irq);
> - }
> - } else
> - /* disable keyboard interrupt and schedule for handling */
> - omap_writew(1, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBD_MASKIT);
> + omap_writew(1, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBD_MASKIT);
>
> tasklet_schedule(&kp_tasklet);
>
> @@ -133,33 +109,22 @@ static void omap_kp_scan_keypad(struct omap_kp *omap_kp, unsigned char *state)
> {
> int col = 0;
>
> - /* read the keypad status */
> - if (cpu_is_omap24xx()) {
> - /* read the keypad status */
> - for (col = 0; col < omap_kp->cols; col++) {
> - set_col_gpio_val(omap_kp, ~(1 << col));
> - state[col] = ~(get_row_gpio_val(omap_kp)) & 0xff;
> - }
> - set_col_gpio_val(omap_kp, 0);
> -
> - } else {
> - /* disable keyboard interrupt and schedule for handling */
> - omap_writew(1, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBD_MASKIT);
> + /* disable keyboard interrupt and schedule for handling */
> + omap_writew(1, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBD_MASKIT);
>
> - /* read the keypad status */
> - omap_writew(0xff, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBC);
> - for (col = 0; col < omap_kp->cols; col++) {
> - omap_writew(~(1 << col) & 0xff,
> - OMAP1_MPUIO_BASE + OMAP_MPUIO_KBC);
> + /* read the keypad status */
> + omap_writew(0xff, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBC);
> + for (col = 0; col < omap_kp->cols; col++) {
> + omap_writew(~(1 << col) & 0xff,
> + OMAP1_MPUIO_BASE + OMAP_MPUIO_KBC);
>
> - udelay(omap_kp->delay);
> + udelay(omap_kp->delay);
>
> - state[col] = ~omap_readw(OMAP1_MPUIO_BASE +
> - OMAP_MPUIO_KBR_LATCH) & 0xff;
> - }
> - omap_writew(0x00, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBC);
> - udelay(2);
> + state[col] = ~omap_readw(OMAP1_MPUIO_BASE +
> + OMAP_MPUIO_KBR_LATCH) & 0xff;
> }
> + omap_writew(0x00, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBC);
> + udelay(2);
> }
>
> static void omap_kp_tasklet(unsigned long data)
> @@ -222,14 +187,8 @@ static void omap_kp_tasklet(unsigned long data)
> mod_timer(&omap_kp_data->timer, jiffies + delay);
> } else {
> /* enable interrupts */
> - if (cpu_is_omap24xx()) {
> - int i;
> - for (i = 0; i < omap_kp_data->rows; i++)
> - enable_irq(gpio_to_irq(row_gpios[i]));
> - } else {
> - omap_writew(0, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBD_MASKIT);
> - kp_cur_group = -1;
> - }
> + omap_writew(0, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBD_MASKIT);
> + kp_cur_group = -1;
> }
> }
>
> @@ -242,6 +201,7 @@ static ssize_t omap_kp_enable_show(struct device *dev,
> static ssize_t omap_kp_enable_store(struct device *dev, struct device_attribute *attr,
> const char *buf, size_t count)
> {
> + struct omap_kp *omap_kp = dev_get_drvdata(dev);
> int state;
>
> if (sscanf(buf, "%u", &state) != 1)
> @@ -253,9 +213,9 @@ static ssize_t omap_kp_enable_store(struct device *dev, struct device_attribute
> mutex_lock(&kp_enable_mutex);
> if (state != kp_enable) {
> if (state)
> - enable_irq(INT_KEYBOARD);
> + enable_irq(omap_kp->irq);
> else
> - disable_irq(INT_KEYBOARD);
> + disable_irq(omap_kp->irq);
> kp_enable = state;
> }
> mutex_unlock(&kp_enable_mutex);
> @@ -289,7 +249,7 @@ static int __devinit omap_kp_probe(struct platform_device *pdev)
> struct omap_kp *omap_kp;
> struct input_dev *input_dev;
> struct omap_kp_platform_data *pdata = pdev->dev.platform_data;
> - int i, col_idx, row_idx, irq_idx, ret;
> + int i, col_idx, row_idx, ret;
> unsigned int row_shift, keycodemax;
>
> if (!pdata->rows || !pdata->cols || !pdata->keymap_data) {
> @@ -314,8 +274,7 @@ static int __devinit omap_kp_probe(struct platform_device *pdev)
> omap_kp->input = input_dev;
>
> /* Disable the interrupt for the MPUIO keyboard */
> - if (!cpu_is_omap24xx())
> - omap_writew(1, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBD_MASKIT);
> + omap_writew(1, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBD_MASKIT);
>
> if (pdata->delay)
> omap_kp->delay = pdata->delay;
> @@ -328,31 +287,8 @@ static int __devinit omap_kp_probe(struct platform_device *pdev)
> omap_kp->rows = pdata->rows;
> omap_kp->cols = pdata->cols;
>
> - if (cpu_is_omap24xx()) {
> - /* Cols: outputs */
> - for (col_idx = 0; col_idx < omap_kp->cols; col_idx++) {
> - if (gpio_request(col_gpios[col_idx], "omap_kp_col") < 0) {
> - printk(KERN_ERR "Failed to request"
> - "GPIO%d for keypad\n",
> - col_gpios[col_idx]);
> - goto err1;
> - }
> - gpio_direction_output(col_gpios[col_idx], 0);
> - }
> - /* Rows: inputs */
> - for (row_idx = 0; row_idx < omap_kp->rows; row_idx++) {
> - if (gpio_request(row_gpios[row_idx], "omap_kp_row") < 0) {
> - printk(KERN_ERR "Failed to request"
> - "GPIO%d for keypad\n",
> - row_gpios[row_idx]);
> - goto err2;
> - }
> - gpio_direction_input(row_gpios[row_idx]);
> - }
> - } else {
> - col_idx = 0;
> - row_idx = 0;
> - }
> + col_idx = 0;
> + row_idx = 0;
>
> setup_timer(&omap_kp->timer, omap_kp_timer, (unsigned long)omap_kp);
>
> @@ -394,27 +330,16 @@ static int __devinit omap_kp_probe(struct platform_device *pdev)
>
> /* scan current status and enable interrupt */
> omap_kp_scan_keypad(omap_kp, keypad_state);
> - if (!cpu_is_omap24xx()) {
> - omap_kp->irq = platform_get_irq(pdev, 0);
> - if (omap_kp->irq >= 0) {
> - if (request_irq(omap_kp->irq, omap_kp_interrupt, 0,
> - "omap-keypad", omap_kp) < 0)
> - goto err4;
> - }
> - omap_writew(0, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBD_MASKIT);
> - } else {
> - for (irq_idx = 0; irq_idx < omap_kp->rows; irq_idx++) {
> - if (request_irq(gpio_to_irq(row_gpios[irq_idx]),
> - omap_kp_interrupt,
> - IRQF_TRIGGER_FALLING,
> - "omap-keypad", omap_kp) < 0)
> - goto err5;
> - }
> + omap_kp->irq = platform_get_irq(pdev, 0);
> + if (omap_kp->irq >= 0) {
> + if (request_irq(omap_kp->irq, omap_kp_interrupt, 0,
> + "omap-keypad", omap_kp) < 0)
> + goto err4;
> }
> + omap_writew(0, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBD_MASKIT);
> +
> return 0;
> -err5:
> - for (i = irq_idx - 1; i >=0; i--)
> - free_irq(row_gpios[i], omap_kp);
> +
> err4:
> input_unregister_device(omap_kp->input);
> input_dev = NULL;
> @@ -423,7 +348,6 @@ err3:
> err2:
> for (i = row_idx - 1; i >=0; i--)
> gpio_free(row_gpios[i]);
> -err1:
> for (i = col_idx - 1; i >=0; i--)
> gpio_free(col_gpios[i]);
>
> @@ -439,18 +363,8 @@ static int __devexit omap_kp_remove(struct platform_device *pdev)
>
> /* disable keypad interrupt handling */
> tasklet_disable(&kp_tasklet);
> - if (cpu_is_omap24xx()) {
> - int i;
> - for (i = 0; i < omap_kp->cols; i++)
> - gpio_free(col_gpios[i]);
> - for (i = 0; i < omap_kp->rows; i++) {
> - gpio_free(row_gpios[i]);
> - free_irq(gpio_to_irq(row_gpios[i]), omap_kp);
> - }
> - } else {
> - omap_writew(1, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBD_MASKIT);
> - free_irq(omap_kp->irq, omap_kp);
> - }
> + omap_writew(1, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBD_MASKIT);
> + free_irq(omap_kp->irq, omap_kp);
>
> del_timer_sync(&omap_kp->timer);
> tasklet_kill(&kp_tasklet);
--
balbi
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 07/17] Input: omap-keypad: Remove dependencies to mach includes
2012-09-11 18:27 ` Felipe Balbi
@ 2012-09-12 4:39 ` Poddar, Sourav
0 siblings, 0 replies; 7+ messages in thread
From: Poddar, Sourav @ 2012-09-12 4:39 UTC (permalink / raw)
To: balbi
Cc: Tony Lindgren, linux-arm-kernel, linux-omap, Dmitry Torokhov,
linux-input
Hi,
On Tue, Sep 11, 2012 at 11:57 PM, Felipe Balbi <balbi@ti.com> wrote:
> Hi,
>
> On Tue, Sep 11, 2012 at 10:56:34AM -0700, Tony Lindgren wrote:
>> * Tony Lindgren <tony@atomide.com> [120910 23:17]:
>> > * Felipe Balbi <balbi@ti.com> [120910 23:02]:
>> >
>> > > > static int __devinit omap_kp_probe(struct platform_device *pdev)
>> > > > {
>> > > > - struct omap_kp *omap_kp;
>> > >
>> > > ???? I don't see the point for that global omap_kp, actually ...
>> >
>> > Yes you're right. Will send an updated one tomorrow.
>>
>> Here's the updated patch that just removes all omap2+ code,
>> and does not use the global omap_kp.
>>
>> Regards,
>>
>> Tony
>>
>>
>> From: Tony Lindgren <tony@atomide.com>
>> Date: Fri, 7 Sep 2012 13:27:58 -0700
>> Subject: [PATCH] Input: omap-keypad: Remove dependencies to mach includes
>>
>> Remove support for omap2+ as it's no longer needed since
>> it's using matrix-keypad. This way we can remove depency
>> to plat and mach headers which is needed for ARM common
>> zImage support.
>>
>> Also remove INT_KEYBOARD by using omap_kp->irq.
>>
>> Note that this patch depends on an earlier patch
>> "ARM: OMAP: Move gpio.h to include/linux/platform_data".
>>
>> Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
>> Cc: linux-input@vger.kernel.org
>> Signed-off-by: Tony Lindgren <tony@atomide.com>
>
> This looks ok to me from a code standpoint. Sourav how does this look to
> you ?
>
The patch looks good to me. Makes perfect sense to remove the omap2+
code from the driver.
> FWIW:
>
> Reviewed-by: Felipe Balbi <balbi@ti.com>
>
>>
>> --- a/drivers/input/keyboard/Kconfig
>> +++ b/drivers/input/keyboard/Kconfig
>> @@ -533,7 +533,7 @@ config KEYBOARD_DAVINCI
>>
>> config KEYBOARD_OMAP
>> tristate "TI OMAP keypad support"
>> - depends on (ARCH_OMAP1 || ARCH_OMAP2)
>> + depends on ARCH_OMAP1
>> select INPUT_MATRIXKMAP
>> help
>> Say Y here if you want to use the OMAP keypad.
>> diff --git a/drivers/input/keyboard/omap-keypad.c b/drivers/input/keyboard/omap-keypad.c
>> index a0222db..2bda5f0b 100644
>> --- a/drivers/input/keyboard/omap-keypad.c
>> +++ b/drivers/input/keyboard/omap-keypad.c
>> @@ -35,13 +35,9 @@
>> #include <linux/mutex.h>
>> #include <linux/errno.h>
>> #include <linux/slab.h>
>> -#include <asm/gpio.h>
>> +#include <linux/gpio.h>
>> +#include <linux/platform_data/gpio-omap.h>
>> #include <plat/keypad.h>
>> -#include <plat/menelaus.h>
>> -#include <asm/irq.h>
>> -#include <mach/hardware.h>
>> -#include <asm/io.h>
>> -#include <plat/mux.h>
>>
>> #undef NEW_BOARD_LEARNING_MODE
>>
>> @@ -96,28 +92,8 @@ static u8 get_row_gpio_val(struct omap_kp *omap_kp)
>>
>> static irqreturn_t omap_kp_interrupt(int irq, void *dev_id)
>> {
>> - struct omap_kp *omap_kp = dev_id;
>> -
>> /* disable keyboard interrupt and schedule for handling */
>> - if (cpu_is_omap24xx()) {
>> - int i;
>> -
>> - for (i = 0; i < omap_kp->rows; i++) {
>> - int gpio_irq = gpio_to_irq(row_gpios[i]);
>> - /*
>> - * The interrupt which we're currently handling should
>> - * be disabled _nosync() to avoid deadlocks waiting
>> - * for this handler to complete. All others should
>> - * be disabled the regular way for SMP safety.
>> - */
>> - if (gpio_irq == irq)
>> - disable_irq_nosync(gpio_irq);
>> - else
>> - disable_irq(gpio_irq);
>> - }
>> - } else
>> - /* disable keyboard interrupt and schedule for handling */
>> - omap_writew(1, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBD_MASKIT);
>> + omap_writew(1, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBD_MASKIT);
>>
>> tasklet_schedule(&kp_tasklet);
>>
>> @@ -133,33 +109,22 @@ static void omap_kp_scan_keypad(struct omap_kp *omap_kp, unsigned char *state)
>> {
>> int col = 0;
>>
>> - /* read the keypad status */
>> - if (cpu_is_omap24xx()) {
>> - /* read the keypad status */
>> - for (col = 0; col < omap_kp->cols; col++) {
>> - set_col_gpio_val(omap_kp, ~(1 << col));
>> - state[col] = ~(get_row_gpio_val(omap_kp)) & 0xff;
>> - }
>> - set_col_gpio_val(omap_kp, 0);
>> -
>> - } else {
>> - /* disable keyboard interrupt and schedule for handling */
>> - omap_writew(1, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBD_MASKIT);
>> + /* disable keyboard interrupt and schedule for handling */
>> + omap_writew(1, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBD_MASKIT);
>>
>> - /* read the keypad status */
>> - omap_writew(0xff, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBC);
>> - for (col = 0; col < omap_kp->cols; col++) {
>> - omap_writew(~(1 << col) & 0xff,
>> - OMAP1_MPUIO_BASE + OMAP_MPUIO_KBC);
>> + /* read the keypad status */
>> + omap_writew(0xff, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBC);
>> + for (col = 0; col < omap_kp->cols; col++) {
>> + omap_writew(~(1 << col) & 0xff,
>> + OMAP1_MPUIO_BASE + OMAP_MPUIO_KBC);
>>
>> - udelay(omap_kp->delay);
>> + udelay(omap_kp->delay);
>>
>> - state[col] = ~omap_readw(OMAP1_MPUIO_BASE +
>> - OMAP_MPUIO_KBR_LATCH) & 0xff;
>> - }
>> - omap_writew(0x00, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBC);
>> - udelay(2);
>> + state[col] = ~omap_readw(OMAP1_MPUIO_BASE +
>> + OMAP_MPUIO_KBR_LATCH) & 0xff;
>> }
>> + omap_writew(0x00, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBC);
>> + udelay(2);
>> }
>>
>> static void omap_kp_tasklet(unsigned long data)
>> @@ -222,14 +187,8 @@ static void omap_kp_tasklet(unsigned long data)
>> mod_timer(&omap_kp_data->timer, jiffies + delay);
>> } else {
>> /* enable interrupts */
>> - if (cpu_is_omap24xx()) {
>> - int i;
>> - for (i = 0; i < omap_kp_data->rows; i++)
>> - enable_irq(gpio_to_irq(row_gpios[i]));
>> - } else {
>> - omap_writew(0, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBD_MASKIT);
>> - kp_cur_group = -1;
>> - }
>> + omap_writew(0, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBD_MASKIT);
>> + kp_cur_group = -1;
>> }
>> }
>>
>> @@ -242,6 +201,7 @@ static ssize_t omap_kp_enable_show(struct device *dev,
>> static ssize_t omap_kp_enable_store(struct device *dev, struct device_attribute *attr,
>> const char *buf, size_t count)
>> {
>> + struct omap_kp *omap_kp = dev_get_drvdata(dev);
>> int state;
>>
>> if (sscanf(buf, "%u", &state) != 1)
>> @@ -253,9 +213,9 @@ static ssize_t omap_kp_enable_store(struct device *dev, struct device_attribute
>> mutex_lock(&kp_enable_mutex);
>> if (state != kp_enable) {
>> if (state)
>> - enable_irq(INT_KEYBOARD);
>> + enable_irq(omap_kp->irq);
>> else
>> - disable_irq(INT_KEYBOARD);
>> + disable_irq(omap_kp->irq);
>> kp_enable = state;
>> }
>> mutex_unlock(&kp_enable_mutex);
>> @@ -289,7 +249,7 @@ static int __devinit omap_kp_probe(struct platform_device *pdev)
>> struct omap_kp *omap_kp;
>> struct input_dev *input_dev;
>> struct omap_kp_platform_data *pdata = pdev->dev.platform_data;
>> - int i, col_idx, row_idx, irq_idx, ret;
>> + int i, col_idx, row_idx, ret;
>> unsigned int row_shift, keycodemax;
>>
>> if (!pdata->rows || !pdata->cols || !pdata->keymap_data) {
>> @@ -314,8 +274,7 @@ static int __devinit omap_kp_probe(struct platform_device *pdev)
>> omap_kp->input = input_dev;
>>
>> /* Disable the interrupt for the MPUIO keyboard */
>> - if (!cpu_is_omap24xx())
>> - omap_writew(1, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBD_MASKIT);
>> + omap_writew(1, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBD_MASKIT);
>>
>> if (pdata->delay)
>> omap_kp->delay = pdata->delay;
>> @@ -328,31 +287,8 @@ static int __devinit omap_kp_probe(struct platform_device *pdev)
>> omap_kp->rows = pdata->rows;
>> omap_kp->cols = pdata->cols;
>>
>> - if (cpu_is_omap24xx()) {
>> - /* Cols: outputs */
>> - for (col_idx = 0; col_idx < omap_kp->cols; col_idx++) {
>> - if (gpio_request(col_gpios[col_idx], "omap_kp_col") < 0) {
>> - printk(KERN_ERR "Failed to request"
>> - "GPIO%d for keypad\n",
>> - col_gpios[col_idx]);
>> - goto err1;
>> - }
>> - gpio_direction_output(col_gpios[col_idx], 0);
>> - }
>> - /* Rows: inputs */
>> - for (row_idx = 0; row_idx < omap_kp->rows; row_idx++) {
>> - if (gpio_request(row_gpios[row_idx], "omap_kp_row") < 0) {
>> - printk(KERN_ERR "Failed to request"
>> - "GPIO%d for keypad\n",
>> - row_gpios[row_idx]);
>> - goto err2;
>> - }
>> - gpio_direction_input(row_gpios[row_idx]);
>> - }
>> - } else {
>> - col_idx = 0;
>> - row_idx = 0;
>> - }
>> + col_idx = 0;
>> + row_idx = 0;
>>
>> setup_timer(&omap_kp->timer, omap_kp_timer, (unsigned long)omap_kp);
>>
>> @@ -394,27 +330,16 @@ static int __devinit omap_kp_probe(struct platform_device *pdev)
>>
>> /* scan current status and enable interrupt */
>> omap_kp_scan_keypad(omap_kp, keypad_state);
>> - if (!cpu_is_omap24xx()) {
>> - omap_kp->irq = platform_get_irq(pdev, 0);
>> - if (omap_kp->irq >= 0) {
>> - if (request_irq(omap_kp->irq, omap_kp_interrupt, 0,
>> - "omap-keypad", omap_kp) < 0)
>> - goto err4;
>> - }
>> - omap_writew(0, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBD_MASKIT);
>> - } else {
>> - for (irq_idx = 0; irq_idx < omap_kp->rows; irq_idx++) {
>> - if (request_irq(gpio_to_irq(row_gpios[irq_idx]),
>> - omap_kp_interrupt,
>> - IRQF_TRIGGER_FALLING,
>> - "omap-keypad", omap_kp) < 0)
>> - goto err5;
>> - }
>> + omap_kp->irq = platform_get_irq(pdev, 0);
>> + if (omap_kp->irq >= 0) {
>> + if (request_irq(omap_kp->irq, omap_kp_interrupt, 0,
>> + "omap-keypad", omap_kp) < 0)
>> + goto err4;
>> }
>> + omap_writew(0, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBD_MASKIT);
>> +
>> return 0;
>> -err5:
>> - for (i = irq_idx - 1; i >=0; i--)
>> - free_irq(row_gpios[i], omap_kp);
>> +
>> err4:
>> input_unregister_device(omap_kp->input);
>> input_dev = NULL;
>> @@ -423,7 +348,6 @@ err3:
>> err2:
>> for (i = row_idx - 1; i >=0; i--)
>> gpio_free(row_gpios[i]);
>> -err1:
>> for (i = col_idx - 1; i >=0; i--)
>> gpio_free(col_gpios[i]);
>>
>> @@ -439,18 +363,8 @@ static int __devexit omap_kp_remove(struct platform_device *pdev)
>>
>> /* disable keypad interrupt handling */
>> tasklet_disable(&kp_tasklet);
>> - if (cpu_is_omap24xx()) {
>> - int i;
>> - for (i = 0; i < omap_kp->cols; i++)
>> - gpio_free(col_gpios[i]);
>> - for (i = 0; i < omap_kp->rows; i++) {
>> - gpio_free(row_gpios[i]);
>> - free_irq(gpio_to_irq(row_gpios[i]), omap_kp);
>> - }
>> - } else {
>> - omap_writew(1, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBD_MASKIT);
>> - free_irq(omap_kp->irq, omap_kp);
>> - }
>> + omap_writew(1, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBD_MASKIT);
>> + free_irq(omap_kp->irq, omap_kp);
>>
>> del_timer_sync(&omap_kp->timer);
>> tasklet_kill(&kp_tasklet);
>
> --
> balbi
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 07/17] Input: omap-keypad: Remove dependencies to mach includes
2012-09-11 17:56 ` Tony Lindgren
2012-09-11 18:27 ` Felipe Balbi
@ 2012-09-12 6:39 ` Poddar, Sourav
1 sibling, 0 replies; 7+ messages in thread
From: Poddar, Sourav @ 2012-09-12 6:39 UTC (permalink / raw)
To: Tony Lindgren
Cc: Felipe Balbi, linux-arm-kernel, linux-omap, Dmitry Torokhov,
linux-input
Hi,
On Tue, Sep 11, 2012 at 11:26 PM, Tony Lindgren <tony@atomide.com> wrote:
> * Tony Lindgren <tony@atomide.com> [120910 23:17]:
>> * Felipe Balbi <balbi@ti.com> [120910 23:02]:
>>
>> > > static int __devinit omap_kp_probe(struct platform_device *pdev)
>> > > {
>> > > - struct omap_kp *omap_kp;
>> >
>> > ???? I don't see the point for that global omap_kp, actually ...
>>
>> Yes you're right. Will send an updated one tomorrow.
>
> Here's the updated patch that just removes all omap2+ code,
> and does not use the global omap_kp.
>
> Regards,
>
> Tony
>
>
> From: Tony Lindgren <tony@atomide.com>
> Date: Fri, 7 Sep 2012 13:27:58 -0700
> Subject: [PATCH] Input: omap-keypad: Remove dependencies to mach includes
>
> Remove support for omap2+ as it's no longer needed since
> it's using matrix-keypad. This way we can remove depency
> to plat and mach headers which is needed for ARM common
> zImage support.
>
> Also remove INT_KEYBOARD by using omap_kp->irq.
>
> Note that this patch depends on an earlier patch
> "ARM: OMAP: Move gpio.h to include/linux/platform_data".
>
> Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> Cc: linux-input@vger.kernel.org
> Signed-off-by: Tony Lindgren <tony@atomide.com>
>
> --- a/drivers/input/keyboard/Kconfig
> +++ b/drivers/input/keyboard/Kconfig
> @@ -533,7 +533,7 @@ config KEYBOARD_DAVINCI
>
> config KEYBOARD_OMAP
> tristate "TI OMAP keypad support"
> - depends on (ARCH_OMAP1 || ARCH_OMAP2)
> + depends on ARCH_OMAP1
> select INPUT_MATRIXKMAP
> help
> Say Y here if you want to use the OMAP keypad.
> diff --git a/drivers/input/keyboard/omap-keypad.c b/drivers/input/keyboard/omap-keypad.c
> index a0222db..2bda5f0b 100644
> --- a/drivers/input/keyboard/omap-keypad.c
> +++ b/drivers/input/keyboard/omap-keypad.c
> @@ -35,13 +35,9 @@
> #include <linux/mutex.h>
> #include <linux/errno.h>
> #include <linux/slab.h>
> -#include <asm/gpio.h>
> +#include <linux/gpio.h>
> +#include <linux/platform_data/gpio-omap.h>
> #include <plat/keypad.h>
> -#include <plat/menelaus.h>
> -#include <asm/irq.h>
> -#include <mach/hardware.h>
> -#include <asm/io.h>
> -#include <plat/mux.h>
>
> #undef NEW_BOARD_LEARNING_MODE
>
> @@ -96,28 +92,8 @@ static u8 get_row_gpio_val(struct omap_kp *omap_kp)
>
> static irqreturn_t omap_kp_interrupt(int irq, void *dev_id)
> {
> - struct omap_kp *omap_kp = dev_id;
> -
> /* disable keyboard interrupt and schedule for handling */
> - if (cpu_is_omap24xx()) {
> - int i;
> -
> - for (i = 0; i < omap_kp->rows; i++) {
> - int gpio_irq = gpio_to_irq(row_gpios[i]);
> - /*
> - * The interrupt which we're currently handling should
> - * be disabled _nosync() to avoid deadlocks waiting
> - * for this handler to complete. All others should
> - * be disabled the regular way for SMP safety.
> - */
> - if (gpio_irq == irq)
> - disable_irq_nosync(gpio_irq);
> - else
> - disable_irq(gpio_irq);
> - }
> - } else
> - /* disable keyboard interrupt and schedule for handling */
> - omap_writew(1, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBD_MASKIT);
> + omap_writew(1, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBD_MASKIT);
>
> tasklet_schedule(&kp_tasklet);
>
> @@ -133,33 +109,22 @@ static void omap_kp_scan_keypad(struct omap_kp *omap_kp, unsigned char *state)
> {
> int col = 0;
>
> - /* read the keypad status */
> - if (cpu_is_omap24xx()) {
> - /* read the keypad status */
> - for (col = 0; col < omap_kp->cols; col++) {
> - set_col_gpio_val(omap_kp, ~(1 << col));
> - state[col] = ~(get_row_gpio_val(omap_kp)) & 0xff;
> - }
> - set_col_gpio_val(omap_kp, 0);
> -
> - } else {
> - /* disable keyboard interrupt and schedule for handling */
> - omap_writew(1, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBD_MASKIT);
> + /* disable keyboard interrupt and schedule for handling */
> + omap_writew(1, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBD_MASKIT);
>
> - /* read the keypad status */
> - omap_writew(0xff, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBC);
> - for (col = 0; col < omap_kp->cols; col++) {
> - omap_writew(~(1 << col) & 0xff,
> - OMAP1_MPUIO_BASE + OMAP_MPUIO_KBC);
> + /* read the keypad status */
> + omap_writew(0xff, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBC);
> + for (col = 0; col < omap_kp->cols; col++) {
> + omap_writew(~(1 << col) & 0xff,
> + OMAP1_MPUIO_BASE + OMAP_MPUIO_KBC);
>
> - udelay(omap_kp->delay);
> + udelay(omap_kp->delay);
>
> - state[col] = ~omap_readw(OMAP1_MPUIO_BASE +
> - OMAP_MPUIO_KBR_LATCH) & 0xff;
> - }
> - omap_writew(0x00, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBC);
> - udelay(2);
> + state[col] = ~omap_readw(OMAP1_MPUIO_BASE +
> + OMAP_MPUIO_KBR_LATCH) & 0xff;
> }
> + omap_writew(0x00, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBC);
> + udelay(2);
> }
>
> static void omap_kp_tasklet(unsigned long data)
> @@ -222,14 +187,8 @@ static void omap_kp_tasklet(unsigned long data)
> mod_timer(&omap_kp_data->timer, jiffies + delay);
> } else {
> /* enable interrupts */
> - if (cpu_is_omap24xx()) {
> - int i;
> - for (i = 0; i < omap_kp_data->rows; i++)
> - enable_irq(gpio_to_irq(row_gpios[i]));
> - } else {
> - omap_writew(0, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBD_MASKIT);
> - kp_cur_group = -1;
> - }
> + omap_writew(0, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBD_MASKIT);
> + kp_cur_group = -1;
> }
> }
>
> @@ -242,6 +201,7 @@ static ssize_t omap_kp_enable_show(struct device *dev,
> static ssize_t omap_kp_enable_store(struct device *dev, struct device_attribute *attr,
> const char *buf, size_t count)
> {
> + struct omap_kp *omap_kp = dev_get_drvdata(dev);
> int state;
>
> if (sscanf(buf, "%u", &state) != 1)
> @@ -253,9 +213,9 @@ static ssize_t omap_kp_enable_store(struct device *dev, struct device_attribute
> mutex_lock(&kp_enable_mutex);
> if (state != kp_enable) {
> if (state)
> - enable_irq(INT_KEYBOARD);
> + enable_irq(omap_kp->irq);
> else
> - disable_irq(INT_KEYBOARD);
> + disable_irq(omap_kp->irq);
> kp_enable = state;
> }
> mutex_unlock(&kp_enable_mutex);
> @@ -289,7 +249,7 @@ static int __devinit omap_kp_probe(struct platform_device *pdev)
> struct omap_kp *omap_kp;
> struct input_dev *input_dev;
> struct omap_kp_platform_data *pdata = pdev->dev.platform_data;
> - int i, col_idx, row_idx, irq_idx, ret;
> + int i, col_idx, row_idx, ret;
> unsigned int row_shift, keycodemax;
>
> if (!pdata->rows || !pdata->cols || !pdata->keymap_data) {
> @@ -314,8 +274,7 @@ static int __devinit omap_kp_probe(struct platform_device *pdev)
> omap_kp->input = input_dev;
>
> /* Disable the interrupt for the MPUIO keyboard */
> - if (!cpu_is_omap24xx())
> - omap_writew(1, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBD_MASKIT);
> + omap_writew(1, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBD_MASKIT);
>
> if (pdata->delay)
> omap_kp->delay = pdata->delay;
> @@ -328,31 +287,8 @@ static int __devinit omap_kp_probe(struct platform_device *pdev)
> omap_kp->rows = pdata->rows;
> omap_kp->cols = pdata->cols;
>
> - if (cpu_is_omap24xx()) {
> - /* Cols: outputs */
> - for (col_idx = 0; col_idx < omap_kp->cols; col_idx++) {
> - if (gpio_request(col_gpios[col_idx], "omap_kp_col") < 0) {
> - printk(KERN_ERR "Failed to request"
> - "GPIO%d for keypad\n",
> - col_gpios[col_idx]);
> - goto err1;
> - }
> - gpio_direction_output(col_gpios[col_idx], 0);
> - }
> - /* Rows: inputs */
> - for (row_idx = 0; row_idx < omap_kp->rows; row_idx++) {
> - if (gpio_request(row_gpios[row_idx], "omap_kp_row") < 0) {
> - printk(KERN_ERR "Failed to request"
> - "GPIO%d for keypad\n",
> - row_gpios[row_idx]);
> - goto err2;
> - }
> - gpio_direction_input(row_gpios[row_idx]);
> - }
> - } else {
> - col_idx = 0;
> - row_idx = 0;
> - }
> + col_idx = 0;
> + row_idx = 0;
>
> setup_timer(&omap_kp->timer, omap_kp_timer, (unsigned long)omap_kp);
>
> @@ -394,27 +330,16 @@ static int __devinit omap_kp_probe(struct platform_device *pdev)
>
> /* scan current status and enable interrupt */
> omap_kp_scan_keypad(omap_kp, keypad_state);
> - if (!cpu_is_omap24xx()) {
> - omap_kp->irq = platform_get_irq(pdev, 0);
> - if (omap_kp->irq >= 0) {
> - if (request_irq(omap_kp->irq, omap_kp_interrupt, 0,
> - "omap-keypad", omap_kp) < 0)
> - goto err4;
> - }
> - omap_writew(0, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBD_MASKIT);
> - } else {
> - for (irq_idx = 0; irq_idx < omap_kp->rows; irq_idx++) {
> - if (request_irq(gpio_to_irq(row_gpios[irq_idx]),
> - omap_kp_interrupt,
> - IRQF_TRIGGER_FALLING,
> - "omap-keypad", omap_kp) < 0)
> - goto err5;
> - }
> + omap_kp->irq = platform_get_irq(pdev, 0);
> + if (omap_kp->irq >= 0) {
> + if (request_irq(omap_kp->irq, omap_kp_interrupt, 0,
> + "omap-keypad", omap_kp) < 0)
> + goto err4;
> }
> + omap_writew(0, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBD_MASKIT);
> +
> return 0;
> -err5:
> - for (i = irq_idx - 1; i >=0; i--)
> - free_irq(row_gpios[i], omap_kp);
> +
> err4:
> input_unregister_device(omap_kp->input);
> input_dev = NULL;
> @@ -423,7 +348,6 @@ err3:
> err2:
> for (i = row_idx - 1; i >=0; i--)
> gpio_free(row_gpios[i]);
> -err1:
> for (i = col_idx - 1; i >=0; i--)
> gpio_free(col_gpios[i]);
>
> @@ -439,18 +363,8 @@ static int __devexit omap_kp_remove(struct platform_device *pdev)
>
> /* disable keypad interrupt handling */
> tasklet_disable(&kp_tasklet);
> - if (cpu_is_omap24xx()) {
> - int i;
> - for (i = 0; i < omap_kp->cols; i++)
> - gpio_free(col_gpios[i]);
> - for (i = 0; i < omap_kp->rows; i++) {
> - gpio_free(row_gpios[i]);
> - free_irq(gpio_to_irq(row_gpios[i]), omap_kp);
> - }
> - } else {
> - omap_writew(1, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBD_MASKIT);
> - free_irq(omap_kp->irq, omap_kp);
> - }
> + omap_writew(1, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBD_MASKIT);
> + free_irq(omap_kp->irq, omap_kp);
>
FWIW,
Acked-by: Sourav Poddar <sourav.poddar@ti.com>
> del_timer_sync(&omap_kp->timer);
> tasklet_kill(&kp_tasklet);
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2012-09-12 6:39 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20120911052934.29637.9190.stgit@muffinssi.local>
2012-09-11 5:30 ` [PATCH 07/17] Input: omap-keypad: Remove dependencies to mach includes Tony Lindgren
2012-09-11 5:57 ` Felipe Balbi
2012-09-11 6:16 ` Tony Lindgren
2012-09-11 17:56 ` Tony Lindgren
2012-09-11 18:27 ` Felipe Balbi
2012-09-12 4:39 ` Poddar, Sourav
2012-09-12 6:39 ` Poddar, Sourav
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).