* [PATCH 3/3] OMAP3: PM: Wakeup from TWL4030 keypad with OFF mode
@ 2010-02-04 16:07 Sanjeev Premi
2010-02-04 21:51 ` Kevin Hilman
0 siblings, 1 reply; 5+ messages in thread
From: Sanjeev Premi @ 2010-02-04 16:07 UTC (permalink / raw)
To: linux-omap; +Cc: Sanjeev Premi
This patch allows wakeup from TWL4030 keypad when
OFF mode is hit during suspend.
Tested on OMAP3EVM.
Signed-off-by: Sanjeev Premi <premi@ti.com>
---
arch/arm/mach-omap2/board-omap3evm.c | 86 ++++++++++++++++++++++++++++++++++
1 files changed, 86 insertions(+), 0 deletions(-)
diff --git a/arch/arm/mach-omap2/board-omap3evm.c b/arch/arm/mach-omap2/board-omap3evm.c
index 00bfe9b..b89fa29 100644
--- a/arch/arm/mach-omap2/board-omap3evm.c
+++ b/arch/arm/mach-omap2/board-omap3evm.c
@@ -40,12 +40,15 @@
#include <plat/board.h>
#include <plat/usb.h>
#include <plat/common.h>
+#include <plat/control.h>
#include <plat/mcspi.h>
#include "mux.h"
#include "sdram-micron-mt46h32m32lf-6.h"
#include "mmc-twl4030.h"
+#include "prm-regbits-34xx.h"
+
#define OMAP3_EVM_TS_GPIO 175
#define OMAP3_EVM_EHCI_VBUS 22
#define OMAP3_EVM_EHCI_SELECT 61
@@ -218,6 +221,84 @@ static struct platform_device leds_gpio = {
},
};
+#ifdef CONFIG_PM
+/*
+ * Save the state of keypad
+ *
+ * TODO: This definition should ideally be in a header file, but
+ * matrix_keypad.h is not the right one. Also, plat/keypad.h
+ * is no longer used.
+ */
+struct omap_keypad_pm_state {
+ void __iomem *wk_st;
+ void __iomem *wk_en;
+ u32 wk_mask;
+ u32 padconf;
+};
+
+/*
+ * Board specific hook for keypad suspend
+ */
+void omap3_evm_kp_suspend(void *ptr)
+{
+ struct omap_keypad_pm_state *pstate =
+ (struct omap_keypad_pm_state *)ptr;
+
+ if (pstate) {
+ /*
+ * Set wake-enable bit
+ */
+ if (pstate->wk_en && pstate->wk_mask) {
+ u32 v = __raw_readl(pstate->wk_en);
+ v |= pstate->wk_mask;
+ __raw_writel(v, pstate->wk_en);
+ }
+ /*
+ * Set corresponding IOPAD wakeup-enable
+ */
+ if (cpu_is_omap34xx() && pstate->padconf) {
+ u16 v = omap_ctrl_readw(pstate->padconf);
+ v |= OMAP3_PADCONF_WAKEUPENABLE0;
+ omap_ctrl_writew(v, pstate->padconf);
+ }
+ }
+}
+
+/*
+ * Board specific hook for keypad resume
+ */
+void omap3_evm_kp_resume(void *ptr)
+{
+ struct omap_keypad_pm_state *pstate =
+ (struct omap_keypad_pm_state *)ptr;
+
+ if (pstate) {
+ /*
+ * Clear wake-enable bit
+ */
+ if (pstate->wk_en && pstate->wk_mask) {
+ u32 v = __raw_readl(pstate->wk_en);
+ v &= ~pstate->wk_mask;
+ __raw_writel(v, pstate->wk_en);
+ }
+ /*
+ * Clear corresponding IOPAD wakeup-enable
+ */
+ if (cpu_is_omap34xx() && pstate->padconf) {
+ u16 v = omap_ctrl_readw(pstate->padconf);
+ v &= ~OMAP3_PADCONF_WAKEUPENABLE0;
+ omap_ctrl_writew(v, pstate->padconf);
+ }
+ }
+}
+
+static struct omap_keypad_pm_state omap3evm_kp_pm_state = {
+ .wk_st = OMAP34XX_PRM_REGADDR(WKUP_MOD, PM_WKEN1),
+ .wk_en = OMAP34XX_PRM_REGADDR(WKUP_MOD, PM_WKST1),
+ .wk_mask = OMAP3430_EN_GPIO1,
+ .padconf = 0x1e0,
+};
+#endif /* CONFIG_PM */
static int omap3evm_twl_gpio_setup(struct device *dev,
unsigned gpio, unsigned ngpio)
@@ -288,6 +369,11 @@ static struct twl4030_keypad_data omap3evm_kp_data = {
.rows = 4,
.cols = 4,
.rep = 1,
+#ifdef CONFIG_PM
+ .pm_state = (void *)&omap3evm_kp_pm_state,
+ .on_suspend = omap3_evm_kp_suspend,
+ .on_resume = omap3_evm_kp_resume,
+#endif /* CONFIG_PM */
};
static struct twl4030_madc_platform_data omap3evm_madc_data = {
--
1.6.2.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 3/3] OMAP3: PM: Wakeup from TWL4030 keypad with OFF mode
2010-02-04 16:07 [PATCH 3/3] OMAP3: PM: Wakeup from TWL4030 keypad with OFF mode Sanjeev Premi
@ 2010-02-04 21:51 ` Kevin Hilman
2010-02-05 8:06 ` Premi, Sanjeev
0 siblings, 1 reply; 5+ messages in thread
From: Kevin Hilman @ 2010-02-04 21:51 UTC (permalink / raw)
To: Sanjeev Premi; +Cc: linux-omap
Sanjeev Premi <premi@ti.com> writes:
> This patch allows wakeup from TWL4030 keypad when
> OFF mode is hit during suspend.
>
> Tested on OMAP3EVM.
>
> Signed-off-by: Sanjeev Premi <premi@ti.com>
The idea here looks good, but there is nothing realy EVM specific here
AFAICT, and this exact code could be used on any other board using
the T2 keypad, right? How about a common location?
Also, after looking at this patch, I think the 'void *pstate' member
of struct twl4030_keypad_data should be renamed to 'void *data' to
be more clear that it's just a pointer.
Kevin
> ---
> arch/arm/mach-omap2/board-omap3evm.c | 86 ++++++++++++++++++++++++++++++++++
> 1 files changed, 86 insertions(+), 0 deletions(-)
>
> diff --git a/arch/arm/mach-omap2/board-omap3evm.c b/arch/arm/mach-omap2/board-omap3evm.c
> index 00bfe9b..b89fa29 100644
> --- a/arch/arm/mach-omap2/board-omap3evm.c
> +++ b/arch/arm/mach-omap2/board-omap3evm.c
> @@ -40,12 +40,15 @@
> #include <plat/board.h>
> #include <plat/usb.h>
> #include <plat/common.h>
> +#include <plat/control.h>
> #include <plat/mcspi.h>
>
> #include "mux.h"
> #include "sdram-micron-mt46h32m32lf-6.h"
> #include "mmc-twl4030.h"
>
> +#include "prm-regbits-34xx.h"
> +
> #define OMAP3_EVM_TS_GPIO 175
> #define OMAP3_EVM_EHCI_VBUS 22
> #define OMAP3_EVM_EHCI_SELECT 61
> @@ -218,6 +221,84 @@ static struct platform_device leds_gpio = {
> },
> };
>
> +#ifdef CONFIG_PM
> +/*
> + * Save the state of keypad
> + *
> + * TODO: This definition should ideally be in a header file, but
> + * matrix_keypad.h is not the right one. Also, plat/keypad.h
> + * is no longer used.
> + */
> +struct omap_keypad_pm_state {
> + void __iomem *wk_st;
> + void __iomem *wk_en;
> + u32 wk_mask;
> + u32 padconf;
> +};
> +
> +/*
> + * Board specific hook for keypad suspend
> + */
> +void omap3_evm_kp_suspend(void *ptr)
> +{
> + struct omap_keypad_pm_state *pstate =
> + (struct omap_keypad_pm_state *)ptr;
> +
> + if (pstate) {
> + /*
> + * Set wake-enable bit
> + */
> + if (pstate->wk_en && pstate->wk_mask) {
> + u32 v = __raw_readl(pstate->wk_en);
> + v |= pstate->wk_mask;
> + __raw_writel(v, pstate->wk_en);
> + }
> + /*
> + * Set corresponding IOPAD wakeup-enable
> + */
> + if (cpu_is_omap34xx() && pstate->padconf) {
> + u16 v = omap_ctrl_readw(pstate->padconf);
> + v |= OMAP3_PADCONF_WAKEUPENABLE0;
> + omap_ctrl_writew(v, pstate->padconf);
> + }
> + }
> +}
> +
> +/*
> + * Board specific hook for keypad resume
> + */
> +void omap3_evm_kp_resume(void *ptr)
> +{
> + struct omap_keypad_pm_state *pstate =
> + (struct omap_keypad_pm_state *)ptr;
> +
> + if (pstate) {
> + /*
> + * Clear wake-enable bit
> + */
> + if (pstate->wk_en && pstate->wk_mask) {
> + u32 v = __raw_readl(pstate->wk_en);
> + v &= ~pstate->wk_mask;
> + __raw_writel(v, pstate->wk_en);
> + }
> + /*
> + * Clear corresponding IOPAD wakeup-enable
> + */
> + if (cpu_is_omap34xx() && pstate->padconf) {
> + u16 v = omap_ctrl_readw(pstate->padconf);
> + v &= ~OMAP3_PADCONF_WAKEUPENABLE0;
> + omap_ctrl_writew(v, pstate->padconf);
> + }
> + }
> +}
> +
> +static struct omap_keypad_pm_state omap3evm_kp_pm_state = {
> + .wk_st = OMAP34XX_PRM_REGADDR(WKUP_MOD, PM_WKEN1),
> + .wk_en = OMAP34XX_PRM_REGADDR(WKUP_MOD, PM_WKST1),
> + .wk_mask = OMAP3430_EN_GPIO1,
> + .padconf = 0x1e0,
> +};
> +#endif /* CONFIG_PM */
>
> static int omap3evm_twl_gpio_setup(struct device *dev,
> unsigned gpio, unsigned ngpio)
> @@ -288,6 +369,11 @@ static struct twl4030_keypad_data omap3evm_kp_data = {
> .rows = 4,
> .cols = 4,
> .rep = 1,
> +#ifdef CONFIG_PM
> + .pm_state = (void *)&omap3evm_kp_pm_state,
> + .on_suspend = omap3_evm_kp_suspend,
> + .on_resume = omap3_evm_kp_resume,
> +#endif /* CONFIG_PM */
> };
>
> static struct twl4030_madc_platform_data omap3evm_madc_data = {
> --
> 1.6.2.2
>
> --
> 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] 5+ messages in thread
* RE: [PATCH 3/3] OMAP3: PM: Wakeup from TWL4030 keypad with OFF mode
2010-02-04 21:51 ` Kevin Hilman
@ 2010-02-05 8:06 ` Premi, Sanjeev
2010-02-16 22:54 ` Kevin Hilman
0 siblings, 1 reply; 5+ messages in thread
From: Premi, Sanjeev @ 2010-02-05 8:06 UTC (permalink / raw)
To: Kevin Hilman; +Cc: linux-omap@vger.kernel.org
> -----Original Message-----
> From: Kevin Hilman [mailto:khilman@deeprootsystems.com]
> Sent: Friday, February 05, 2010 3:22 AM
> To: Premi, Sanjeev
> Cc: linux-omap@vger.kernel.org
> Subject: Re: [PATCH 3/3] OMAP3: PM: Wakeup from TWL4030
> keypad with OFF mode
>
> Sanjeev Premi <premi@ti.com> writes:
>
> > This patch allows wakeup from TWL4030 keypad when
> > OFF mode is hit during suspend.
> >
> > Tested on OMAP3EVM.
> >
> > Signed-off-by: Sanjeev Premi <premi@ti.com>
>
> The idea here looks good, but there is nothing realy EVM specific here
> AFAICT, and this exact code could be used on any other board using
> the T2 keypad, right? How about a common location?
[sp] The EVM uses SYS_NIRQ for hooking up with the T2 keypad. Not
sure of everyone would be doing so. Also, PADCONFs are more
applicable for OMAP3, but T2 can be used with other processors
as well...
I did initially inplement these functions in:
drivers/input/keyboard/twl4030_keypad.c
...but then moved to board specific file.
>
> Also, after looking at this patch, I think the 'void *pstate' member
> of struct twl4030_keypad_data should be renamed to 'void *data' to
> be more clear that it's just a pointer.
[sp] Will make the change. However, will wait for your response on the
earlier comment before re-submit.
~sanjeev
>
> Kevin
>
>
[snip]--[snip]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 3/3] OMAP3: PM: Wakeup from TWL4030 keypad with OFF mode
2010-02-05 8:06 ` Premi, Sanjeev
@ 2010-02-16 22:54 ` Kevin Hilman
2010-02-17 11:17 ` Premi, Sanjeev
0 siblings, 1 reply; 5+ messages in thread
From: Kevin Hilman @ 2010-02-16 22:54 UTC (permalink / raw)
To: Premi, Sanjeev; +Cc: linux-omap@vger.kernel.org
"Premi, Sanjeev" <premi@ti.com> writes:
>> -----Original Message-----
>> From: Kevin Hilman [mailto:khilman@deeprootsystems.com]
>> Sent: Friday, February 05, 2010 3:22 AM
>> To: Premi, Sanjeev
>> Cc: linux-omap@vger.kernel.org
>> Subject: Re: [PATCH 3/3] OMAP3: PM: Wakeup from TWL4030
>> keypad with OFF mode
>>
>> Sanjeev Premi <premi@ti.com> writes:
>>
>> > This patch allows wakeup from TWL4030 keypad when
>> > OFF mode is hit during suspend.
>> >
>> > Tested on OMAP3EVM.
>> >
>> > Signed-off-by: Sanjeev Premi <premi@ti.com>
>>
>> The idea here looks good, but there is nothing realy EVM specific here
>> AFAICT, and this exact code could be used on any other board using
>> the T2 keypad, right? How about a common location?
>
> [sp] The EVM uses SYS_NIRQ for hooking up with the T2 keypad. Not
> sure of everyone would be doing so. Also, PADCONFs are more
> applicable for OMAP3, but T2 can be used with other processors
> as well...
>
> I did initially inplement these functions in:
> drivers/input/keyboard/twl4030_keypad.c
>
> ...but then moved to board specific file.
I know at least SDP and EVM have these hooked up identically, so some common
way to set them up would be preferred. Maybe a mach-omap2/t2-keypad.c that
could be shared between various board files. The board files would still
configure the IRQ line and the padconfs used.
Kevin
>>
>> Also, after looking at this patch, I think the 'void *pstate' member
>> of struct twl4030_keypad_data should be renamed to 'void *data' to
>> be more clear that it's just a pointer.
>
> [sp] Will make the change. However, will wait for your response on the
> earlier comment before re-submit.
>
> ~sanjeev
>
>>
>> Kevin
>>
>>
>
> [snip]--[snip]
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: [PATCH 3/3] OMAP3: PM: Wakeup from TWL4030 keypad with OFF mode
2010-02-16 22:54 ` Kevin Hilman
@ 2010-02-17 11:17 ` Premi, Sanjeev
0 siblings, 0 replies; 5+ messages in thread
From: Premi, Sanjeev @ 2010-02-17 11:17 UTC (permalink / raw)
To: Kevin Hilman; +Cc: linux-omap@vger.kernel.org
> -----Original Message-----
> From: Kevin Hilman [mailto:khilman@deeprootsystems.com]
> Sent: Wednesday, February 17, 2010 4:24 AM
> To: Premi, Sanjeev
> Cc: linux-omap@vger.kernel.org
> Subject: Re: [PATCH 3/3] OMAP3: PM: Wakeup from TWL4030
> keypad with OFF mode
>
> "Premi, Sanjeev" <premi@ti.com> writes:
>
> >> -----Original Message-----
> >> From: Kevin Hilman [mailto:khilman@deeprootsystems.com]
> >> Sent: Friday, February 05, 2010 3:22 AM
> >> To: Premi, Sanjeev
> >> Cc: linux-omap@vger.kernel.org
> >> Subject: Re: [PATCH 3/3] OMAP3: PM: Wakeup from TWL4030
> >> keypad with OFF mode
> >>
> >> Sanjeev Premi <premi@ti.com> writes:
> >>
> >> > This patch allows wakeup from TWL4030 keypad when
> >> > OFF mode is hit during suspend.
> >> >
> >> > Tested on OMAP3EVM.
> >> >
> >> > Signed-off-by: Sanjeev Premi <premi@ti.com>
> >>
> >> The idea here looks good, but there is nothing realy EVM
> specific here
> >> AFAICT, and this exact code could be used on any other board using
> >> the T2 keypad, right? How about a common location?
> >
> > [sp] The EVM uses SYS_NIRQ for hooking up with the T2 keypad. Not
> > sure of everyone would be doing so. Also, PADCONFs are more
> > applicable for OMAP3, but T2 can be used with other processors
> > as well...
> >
> > I did initially inplement these functions in:
> > drivers/input/keyboard/twl4030_keypad.c
> >
> > ...but then moved to board specific file.
>
> I know at least SDP and EVM have these hooked up identically,
> so some common
> way to set them up would be preferred. Maybe a
> mach-omap2/t2-keypad.c that
> could be shared between various board files. The board files
> would still
> configure the IRQ line and the padconfs used.
[sp] Yes. This can be done.
Best regards,
Sanjeev
>
> Kevin
>
>
>
> >>
> >> Also, after looking at this patch, I think the 'void
> *pstate' member
> >> of struct twl4030_keypad_data should be renamed to 'void *data' to
> >> be more clear that it's just a pointer.
> >
> > [sp] Will make the change. However, will wait for your
> response on the
> > earlier comment before re-submit.
> >
> > ~sanjeev
> >
> >>
> >> Kevin
> >>
> >>
> >
> > [snip]--[snip]
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2010-02-17 11:18 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-04 16:07 [PATCH 3/3] OMAP3: PM: Wakeup from TWL4030 keypad with OFF mode Sanjeev Premi
2010-02-04 21:51 ` Kevin Hilman
2010-02-05 8:06 ` Premi, Sanjeev
2010-02-16 22:54 ` Kevin Hilman
2010-02-17 11:17 ` Premi, Sanjeev
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox