* [PATCH v4 2/4] OMAP4: Keyboard device registration
@ 2010-06-16 16:09 Abraham Arce
2010-06-17 6:07 ` Varadarajan, Charulatha
0 siblings, 1 reply; 4+ messages in thread
From: Abraham Arce @ 2010-06-16 16:09 UTC (permalink / raw)
To: linux-input, linux-omap; +Cc: Abraham Arce
Register keyboard device with hwmod framework
Signed-off-by: Abraham Arce <x0066660@ti.com>
---
arch/arm/mach-omap2/devices.c | 50 +++++++++++++++++++++++++++++++++++++++++
1 files changed, 50 insertions(+), 0 deletions(-)
diff --git a/arch/arm/mach-omap2/devices.c b/arch/arm/mach-omap2/devices.c
index 03e6c9e..d229901 100644
--- a/arch/arm/mach-omap2/devices.c
+++ b/arch/arm/mach-omap2/devices.c
@@ -15,6 +15,7 @@
#include <linux/platform_device.h>
#include <linux/io.h>
#include <linux/clk.h>
+#include <linux/slab.h>
#include <mach/hardware.h>
#include <mach/irqs.h>
@@ -29,6 +30,9 @@
#include <mach/gpio.h>
#include <plat/mmc.h>
#include <plat/dma.h>
+#include <plat/omap_hwmod.h>
+#include <plat/omap_device.h>
+#include <plat/omap4-keypad.h>
#include "mux.h"
@@ -139,6 +143,52 @@ static inline void omap_init_camera(void)
}
#endif
+#ifdef CONFIG_ARCH_OMAP4
+
+struct omap_device_pm_latency omap_keyboard_latency[] = {
+ {
+ .deactivate_func = omap_device_idle_hwmods,
+ .activate_func = omap_device_enable_hwmods,
+ .flags = OMAP_DEVICE_LATENCY_AUTO_ADJUST,
+ },
+};
+
+int omap4_init_kp(struct omap4_keypad_platform_data *kp)
+{
+ struct omap_hwmod *oh;
+ struct omap_device *od;
+ struct omap4_keypad_platform_data *pdata;
+
+ unsigned int id = 0;
+ char *name = "omap4-keypad";
+ char *oh_name = "kbd";
+
+ if (!cpu_is_omap44xx())
+ return -ENODEV;
+
+ oh = omap_hwmod_lookup(oh_name);
+ if (!oh) {
+ pr_err("Could not look up %s\n", oh_name);
+ return -EIO;
+ }
+
+ pdata = kp;
+
+ pdata->base = oh->_rt_va;
+ pdata->irq = oh->mpu_irqs[0].irq;
+
+ od = omap_device_build(name, id, oh, pdata,
+ sizeof(struct matrix_keypad_platform_data),
+ omap_keyboard_latency,
+ ARRAY_SIZE(omap_keyboard_latency), 1);
+ WARN(IS_ERR(od), "Could not build omap_device for %s %s\n",
+ name, oh_name);
+
+ return 0;
+}
+
+#endif
+
#if defined(CONFIG_OMAP_MBOX_FWK) || defined(CONFIG_OMAP_MBOX_FWK_MODULE)
#define MBOX_REG_SIZE 0x120
--
1.6.3.3
^ permalink raw reply related [flat|nested] 4+ messages in thread
* RE: [PATCH v4 2/4] OMAP4: Keyboard device registration
2010-06-16 16:09 [PATCH v4 2/4] OMAP4: Keyboard device registration Abraham Arce
@ 2010-06-17 6:07 ` Varadarajan, Charulatha
2010-06-17 21:08 ` Kevin Hilman
0 siblings, 1 reply; 4+ messages in thread
From: Varadarajan, Charulatha @ 2010-06-17 6:07 UTC (permalink / raw)
To: linux-input@vger.kernel.org, linux-omap@vger.kernel.org; +Cc: Arce, Abraham
> -----Original Message-----
> From: linux-omap-owner@vger.kernel.org [mailto:linux-omap-owner@vger.kernel.org]
> On Behalf Of Abraham Arce
> Sent: Wednesday, June 16, 2010 9:39 PM
> To: linux-input@vger.kernel.org; linux-omap@vger.kernel.org
> Cc: Arce, Abraham
> Subject: [PATCH v4 2/4] OMAP4: Keyboard device registration
>
> Register keyboard device with hwmod framework
>
> Signed-off-by: Abraham Arce <x0066660@ti.com>
> ---
> arch/arm/mach-omap2/devices.c | 50 +++++++++++++++++++++++++++++++++++++++++
> 1 files changed, 50 insertions(+), 0 deletions(-)
>
> diff --git a/arch/arm/mach-omap2/devices.c b/arch/arm/mach-omap2/devices.c
> index 03e6c9e..d229901 100644
> --- a/arch/arm/mach-omap2/devices.c
> +++ b/arch/arm/mach-omap2/devices.c
> @@ -15,6 +15,7 @@
> #include <linux/platform_device.h>
> #include <linux/io.h>
> #include <linux/clk.h>
> +#include <linux/slab.h>
>
> #include <mach/hardware.h>
> #include <mach/irqs.h>
> @@ -29,6 +30,9 @@
> #include <mach/gpio.h>
> #include <plat/mmc.h>
> #include <plat/dma.h>
> +#include <plat/omap_hwmod.h>
> +#include <plat/omap_device.h>
> +#include <plat/omap4-keypad.h>
>
> #include "mux.h"
>
> @@ -139,6 +143,52 @@ static inline void omap_init_camera(void)
> }
> #endif
>
> +#ifdef CONFIG_ARCH_OMAP4
> +
> +struct omap_device_pm_latency omap_keyboard_latency[] = {
> + {
> + .deactivate_func = omap_device_idle_hwmods,
> + .activate_func = omap_device_enable_hwmods,
> + .flags = OMAP_DEVICE_LATENCY_AUTO_ADJUST,
> + },
> +};
> +
> +int omap4_init_kp(struct omap4_keypad_platform_data *kp)
> +{
> + struct omap_hwmod *oh;
> + struct omap_device *od;
> + struct omap4_keypad_platform_data *pdata;
> +
> + unsigned int id = 0;
> + char *name = "omap4-keypad";
> + char *oh_name = "kbd";
> +
> + if (!cpu_is_omap44xx())
> + return -ENODEV;
> +
> + oh = omap_hwmod_lookup(oh_name);
Use omap_hwmod_for_each_by_class() instead of lookup by name.
> + if (!oh) {
> + pr_err("Could not look up %s\n", oh_name);
> + return -EIO;
> + }
> +
> + pdata = kp;
> +
> + pdata->base = oh->_rt_va;
> + pdata->irq = oh->mpu_irqs[0].irq;
Use platform_get_() APIs to get base addr & irq instead of passing
it as pdata
> +
> + od = omap_device_build(name, id, oh, pdata,
> + sizeof(struct matrix_keypad_platform_data),
> + omap_keyboard_latency,
> + ARRAY_SIZE(omap_keyboard_latency), 1);
> + WARN(IS_ERR(od), "Could not build omap_device for %s %s\n",
> + name, oh_name);
> +
> + return 0;
> +}
> +
> +#endif
> +
> #if defined(CONFIG_OMAP_MBOX_FWK) || defined(CONFIG_OMAP_MBOX_FWK_MODULE)
>
> #define MBOX_REG_SIZE 0x120
> --
> 1.6.3.3
>
> --
> 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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v4 2/4] OMAP4: Keyboard device registration
2010-06-17 6:07 ` Varadarajan, Charulatha
@ 2010-06-17 21:08 ` Kevin Hilman
2010-06-22 22:36 ` Abraham Arce
0 siblings, 1 reply; 4+ messages in thread
From: Kevin Hilman @ 2010-06-17 21:08 UTC (permalink / raw)
To: Varadarajan, Charulatha
Cc: Arce, Abraham, linux-input@vger.kernel.org,
linux-omap@vger.kernel.org
"Varadarajan, Charulatha" <charu@ti.com> writes:
[...]
>> +
>> +int omap4_init_kp(struct omap4_keypad_platform_data *kp)
>> +{
>> + struct omap_hwmod *oh;
>> + struct omap_device *od;
>> + struct omap4_keypad_platform_data *pdata;
>> +
>> + unsigned int id = 0;
>> + char *name = "omap4-keypad";
>> + char *oh_name = "kbd";
>> +
>> + if (!cpu_is_omap44xx())
>> + return -ENODEV;
>> +
>> + oh = omap_hwmod_lookup(oh_name);
>
> Use omap_hwmod_for_each_by_class() instead of lookup by name.
Yes.
>> + if (!oh) {
>> + pr_err("Could not look up %s\n", oh_name);
>> + return -EIO;
>> + }
>> +
>> + pdata = kp;
>> +
>> + pdata->base = oh->_rt_va;
>> + pdata->irq = oh->mpu_irqs[0].irq;
>
> Use platform_get_() APIs to get base addr & irq instead of passing
> it as pdata
Yes.
Thanks Charu!
For all those working on OMAP hwmod conversions, please take some time
to read the reviews of the other hwmod conversions that have already
been posted and reviewed (some of them multiple times) so we don't
keep duplicating the same mistakes and wasting review time.
Thanks,
Kevin
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v4 2/4] OMAP4: Keyboard device registration
2010-06-17 21:08 ` Kevin Hilman
@ 2010-06-22 22:36 ` Abraham Arce
0 siblings, 0 replies; 4+ messages in thread
From: Abraham Arce @ 2010-06-22 22:36 UTC (permalink / raw)
To: Kevin Hilman, Varadarajan, Charulatha
Cc: Arce, Abraham, linux-input@vger.kernel.org,
linux-omap@vger.kernel.org
Charu, Kevin,
On Thu, Jun 17, 2010 at 4:08 PM, Kevin Hilman
<khilman@deeprootsystems.com> wrote:
> "Varadarajan, Charulatha" <charu@ti.com> writes:
[...]
>>> +
>>> + oh = omap_hwmod_lookup(oh_name);
>>
>> Use omap_hwmod_for_each_by_class() instead of lookup by name.
>
> Yes.
how about handling all keypad data in devices.c and add
omap_init_keypad() under omap2_init_devices()?
diff --git a/arch/arm/mach-omap2/devices.c b/arch/arm/mach-omap2/devices.c
+#ifdef CONFIG_ARCH_OMAP4
+static int sdp4430_keymap[] = {
+ KEY(0, 0, KEY_E),
+ KEY(0, 1, KEY_R),
[...]
+ KEY(7, 6, KEY_OK),
+ KEY(7, 7, KEY_DOWN),
+};
+
+static struct matrix_keymap_data sdp4430_keymap_data = {
+ .keymap = sdp4430_keymap,
+ .keymap_size = ARRAY_SIZE(sdp4430_keymap),
+};
+
+static struct omap4_keypad_platform_data sdp4430_keypad_data = {
+ .keymap_data = &sdp4430_keymap_data,
+ .rows = 8,
+ .cols = 8,
+};
+
+struct omap_device_pm_latency omap_keyboard_latency[] = {
+ {
+ .deactivate_func = omap_device_idle_hwmods,
+ .activate_func = omap_device_enable_hwmods,
+ .flags = OMAP_DEVICE_LATENCY_AUTO_ADJUST,
+ },
+};
+
+static int omap4_init_keypad(struct omap_hwmod *oh, void *user)
+{
+ struct omap_device *od;
+ unsigned int id = -1;
+ char *name = "omap4-keypad";
+
+ if (!oh)
+ pr_err("Could not look up omap4 kbd\n");
+
+ od = omap_device_build(name, id, oh, &sdp4430_keypad_data,
+ sizeof(struct omap4_keypad_platform_data),
+ omap_keyboard_latency,
+ ARRAY_SIZE(omap_keyboard_latency), 0);
+ WARN(IS_ERR(od), "Could not build omap_device for %s %s\n",
+ name, oh->name);
+
+ return 0;
+}
+
+static int omap_init_keypad(void)
+{
+ if (!cpu_is_omap44xx())
+ return -ENODEV;
+
+ return omap_hwmod_for_each_by_class("kbd", omap4_init_keypad, NULL);
+}
+#endif /* KEYBOARD CONFIG_ARCH_OMAP4 */
+
#if defined(CONFIG_OMAP_MBOX_FWK) || defined(CONFIG_OMAP_MBOX_FWK_MODULE)
#define MBOX_REG_SIZE 0x120
@@ -807,6 +931,7 @@ static int __init omap2_init_devices(void)
*/
omap_hsmmc_reset();
omap_init_camera();
+ omap_init_keypad();
omap_init_mbox();
omap_init_mcspi();
omap_hdq_init();
>>> + pdata->base = oh->_rt_va;
>>> + pdata->irq = oh->mpu_irqs[0].irq;
>>
>> Use platform_get_() APIs to get base addr & irq instead of passing
>> it as pdata
>
> Yes.
>
> Thanks Charu!
>
> For all those working on OMAP hwmod conversions, please take some time
> to read the reviews of the other hwmod conversions that have already
> been posted and reviewed (some of them multiple times) so we don't
> keep duplicating the same mistakes and wasting review time.
>
These will be the changes....
diff --git a/drivers/input/keyboard/omap4-keypad.c
b/drivers/input/keyboard/omap4-keypad.c
index 975f8bb..c606e36 100644
--- a/drivers/input/keyboard/omap4-keypad.c
+++ b/drivers/input/keyboard/omap4-keypad.c
@@ -158,12 +213,14 @@ static int __devinit omap4_keypad_probe(struct
platform_device *pdev)
return -EINVAL;
}
- if (!pdata->base) {
+ res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ if (!res) {
dev_err(&pdev->dev, "no base address specified\n");
return -EINVAL;
}
- if (!pdata->irq) {
+ irq = platform_get_irq(pdev, 0);
+ if (!irq) {
dev_err(&pdev->dev, "no keyboard irq assigned\n");
return -EINVAL;
}
@@ -184,9 +240,22 @@ static int __devinit omap4_keypad_probe(struct
platform_device *pdev)
return -ENOMEM;
}
- keypad_data->base = pdata->base;
- keypad_data->irq = pdata->irq;
+ mem = request_mem_region(res->start,
+ resource_size(res), pdev->name);
+ if (!mem) {
+ dev_err(&pdev->dev, "no mem region available\n");
+ return -ENOMEM;
+ goto err_free_keypad;
+ }
+
+ keypad_data->base = ioremap(res->start, resource_size(res));
+ if (!keypad_data->base) {
+ dev_err(&pdev->dev, "can't ioremap mem resource.\n");
+ error = -ENOMEM;
+ goto err_free_memreg;
+ }
+ keypad_data->irq = irq;
Best Regards
Abraham
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-06-22 22:36 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-06-16 16:09 [PATCH v4 2/4] OMAP4: Keyboard device registration Abraham Arce
2010-06-17 6:07 ` Varadarajan, Charulatha
2010-06-17 21:08 ` Kevin Hilman
2010-06-22 22:36 ` Abraham Arce
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).