Re: [PATCH v7 05/26] gpio/omap: handle save/restore context in GPIO driver

2011-09-26 Thread Kevin Hilman
Tarun Kanti DebBarma tarun.ka...@ti.com writes:

 From: Charulatha V ch...@ti.com

 Modify omap_gpio_prepare_for_idle()  omap_gpio_resume_after_idle() functions
 to handle save context  restore context respectively in the OMAP GPIO driver
 itself instead of calling these functions from pm specific files.
 For this, in gpio_prepare_for_idle(), call *_get_context_loss_count() and in
 gpio_resume_after_idle() call it again. If the count is different, do restore
 context. The workaround_enabled flag is no more required and is removed.

 Signed-off-by: Charulatha V ch...@ti.com
 Signed-off-by: Tarun Kanti DebBarma tarun.ka...@ti.com
 Reviewed-by: Santosh Shilimkar santosh.shilim...@ti.com

[...]

 diff --git a/arch/arm/mach-omap2/gpio.c b/arch/arm/mach-omap2/gpio.c
 index 9f3a007..6c6b1a7 100644
 --- a/arch/arm/mach-omap2/gpio.c
 +++ b/arch/arm/mach-omap2/gpio.c
 @@ -23,6 +23,7 @@
  
  #include plat/omap_hwmod.h
  #include plat/omap_device.h
 +#include plat/omap-pm.h
  
  #include powerdomain.h
  
 @@ -63,7 +64,9 @@ static int omap2_gpio_dev_init(struct omap_hwmod *oh, void 
 *unused)
   pdata-bank_width = dev_attr-bank_width;
   pdata-dbck_flag = dev_attr-dbck_flag;
   pdata-virtual_irq_start = IH_GPIO_BASE + 32 * (id - 1);
 -
 +#ifdef CONFIG_PM
 + pdata-get_context_loss_count = omap_pm_get_dev_context_loss_count;
 +#endif

no #ifdef please (c.f. #ifdefs are ugly in
Documentation/SubmittingPatches)

In this case, the existence of this API isn't dependent on CONFIG_PM, so
the #ifdef isn't right.

Kevin
--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v7 05/26] gpio/omap: handle save/restore context in GPIO driver

2011-09-21 Thread Tony Lindgren
* Tarun Kanti DebBarma tarun.ka...@ti.com [110913 05:29]:
 From: Charulatha V ch...@ti.com
 
 Modify omap_gpio_prepare_for_idle()  omap_gpio_resume_after_idle() functions
 to handle save context  restore context respectively in the OMAP GPIO driver
 itself instead of calling these functions from pm specific files.
 For this, in gpio_prepare_for_idle(), call *_get_context_loss_count() and in
 gpio_resume_after_idle() call it again. If the count is different, do restore
 context. The workaround_enabled flag is no more required and is removed.
 
 Signed-off-by: Charulatha V ch...@ti.com
 Signed-off-by: Tarun Kanti DebBarma tarun.ka...@ti.com
 Reviewed-by: Santosh Shilimkar santosh.shilim...@ti.com

This to should be also acked by Kevin, looks OK to me:

Acked-by: Tony Lindgren t...@atomide.com
--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v7 05/26] gpio/omap: handle save/restore context in GPIO driver

2011-09-13 Thread Tarun Kanti DebBarma
From: Charulatha V ch...@ti.com

Modify omap_gpio_prepare_for_idle()  omap_gpio_resume_after_idle() functions
to handle save context  restore context respectively in the OMAP GPIO driver
itself instead of calling these functions from pm specific files.
For this, in gpio_prepare_for_idle(), call *_get_context_loss_count() and in
gpio_resume_after_idle() call it again. If the count is different, do restore
context. The workaround_enabled flag is no more required and is removed.

Signed-off-by: Charulatha V ch...@ti.com
Signed-off-by: Tarun Kanti DebBarma tarun.ka...@ti.com
Reviewed-by: Santosh Shilimkar santosh.shilim...@ti.com
---
 arch/arm/mach-omap2/gpio.c |5 +-
 arch/arm/mach-omap2/pm34xx.c   |   14 
 arch/arm/plat-omap/include/plat/gpio.h |5 +-
 drivers/gpio/gpio-omap.c   |  131 ++--
 4 files changed, 65 insertions(+), 90 deletions(-)

diff --git a/arch/arm/mach-omap2/gpio.c b/arch/arm/mach-omap2/gpio.c
index 9f3a007..6c6b1a7 100644
--- a/arch/arm/mach-omap2/gpio.c
+++ b/arch/arm/mach-omap2/gpio.c
@@ -23,6 +23,7 @@
 
 #include plat/omap_hwmod.h
 #include plat/omap_device.h
+#include plat/omap-pm.h
 
 #include powerdomain.h
 
@@ -63,7 +64,9 @@ static int omap2_gpio_dev_init(struct omap_hwmod *oh, void 
*unused)
pdata-bank_width = dev_attr-bank_width;
pdata-dbck_flag = dev_attr-dbck_flag;
pdata-virtual_irq_start = IH_GPIO_BASE + 32 * (id - 1);
-
+#ifdef CONFIG_PM
+   pdata-get_context_loss_count = omap_pm_get_dev_context_loss_count;
+#endif
pdata-regs = kzalloc(sizeof(struct omap_gpio_reg_offs), GFP_KERNEL);
if (!pdata) {
pr_err(gpio%d: Memory allocation failed\n, id);
diff --git a/arch/arm/mach-omap2/pm34xx.c b/arch/arm/mach-omap2/pm34xx.c
index 1915050..b33cf3d 100644
--- a/arch/arm/mach-omap2/pm34xx.c
+++ b/arch/arm/mach-omap2/pm34xx.c
@@ -85,16 +85,6 @@ static struct powerdomain *mpu_pwrdm, *neon_pwrdm;
 static struct powerdomain *core_pwrdm, *per_pwrdm;
 static struct powerdomain *cam_pwrdm;
 
-static inline void omap3_per_save_context(void)
-{
-   omap_gpio_save_context();
-}
-
-static inline void omap3_per_restore_context(void)
-{
-   omap_gpio_restore_context();
-}
-
 static void omap3_enable_io_chain(void)
 {
int timeout = 0;
@@ -393,8 +383,6 @@ void omap_sram_idle(void)
omap_uart_prepare_idle(2);
omap_uart_prepare_idle(3);
omap2_gpio_prepare_for_idle(per_going_off);
-   if (per_next_state == PWRDM_POWER_OFF)
-   omap3_per_save_context();
}
 
/* CORE */
@@ -462,8 +450,6 @@ void omap_sram_idle(void)
if (per_next_state  PWRDM_POWER_ON) {
per_prev_state = pwrdm_read_prev_pwrst(per_pwrdm);
omap2_gpio_resume_after_idle();
-   if (per_prev_state == PWRDM_POWER_OFF)
-   omap3_per_restore_context();
omap_uart_resume_idle(2);
omap_uart_resume_idle(3);
}
diff --git a/arch/arm/plat-omap/include/plat/gpio.h 
b/arch/arm/plat-omap/include/plat/gpio.h
index 58d0bf2..2c06e43 100644
--- a/arch/arm/plat-omap/include/plat/gpio.h
+++ b/arch/arm/plat-omap/include/plat/gpio.h
@@ -201,14 +201,15 @@ struct omap_gpio_platform_data {
bool loses_context; /* whether the bank would ever lose context */
 
struct omap_gpio_reg_offs *regs;
+
+   /* Return context loss count due to PM states changing */
+   u32 (*get_context_loss_count)(struct device *dev);
 };
 
 extern void omap2_gpio_prepare_for_idle(int off_mode);
 extern void omap2_gpio_resume_after_idle(void);
 extern void omap_set_gpio_debounce(int gpio, int enable);
 extern void omap_set_gpio_debounce_time(int gpio, int enable);
-extern void omap_gpio_save_context(void);
-extern void omap_gpio_restore_context(void);
 /*-*/
 
 /* Wrappers for new style GPIO calls, using the new infrastructure
diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
index 62d2213..c3cf01f 100644
--- a/drivers/gpio/gpio-omap.c
+++ b/drivers/gpio/gpio-omap.c
@@ -72,9 +72,11 @@ struct gpio_bank {
bool loses_context;
int stride;
u32 width;
+   u32 context_loss_count;
u16 id;
 
void (*set_dataout)(struct gpio_bank *bank, int gpio, int enable);
+   u32 (*get_context_loss_count)(struct device *dev);
 
struct omap_gpio_reg_offs *regs;
 };
@@ -1179,6 +1181,7 @@ static int __devinit omap_gpio_probe(struct 
platform_device *pdev)
bank-stride = pdata-bank_stride;
bank-width = pdata-bank_width;
bank-loses_context = pdata-loses_context;
+   bank-get_context_loss_count = pdata-get_context_loss_count;
bank-regs = pdata-regs;
 
if (bank-regs-set_dataout  bank-regs-clr_dataout)
@@ -1323,11 +1326,11 @@ static struct syscore_ops