[PATCH v2] gpio/omap: add *remove* callback in platform_driver

2012-08-08 Thread Tarun Kanti DebBarma
Add *remove* callback so that necessary cleanup operations are
performed when device is unregistered. The device is deleted
from the list and associated clock handle is released by
calling clk_put() and irq descriptor is released using the
irq_free_desc() api.

Signed-off-by: Tarun Kanti DebBarma tarun.ka...@ti.com
Reported-by: Paul Walmsley p...@pwsan.com
Reviewed-by: Jon Hunter jon-hun...@ti.com
Cc: Kevin Hilman khil...@ti.com
Cc: Rajendra Nayak rna...@ti.com
Cc: Santosh Shilimkar santosh.shilim...@ti.com
Cc: Cousson, Benoit b-cous...@ti.com
Cc: Paul Walmsley p...@pwsan.com
---
v2:
Baseline: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git
Commit: 0d7614f09c1ebdbaa1599a5aba7593f147bf96ee (Linux 3.6-rc1)

(1) Use irq_free_descs() instead of irq_free_desc().
Besides, irq_free_desc() was using wrong parameter,
irq_base, instead of bank-irq.
(2) irq_free_descs() moved outside spin_lock/unlock_*()
in order to avoid exception warnings.

(3) pm_runtime_disable() added so that bind can happen successfully

Test Detail:
Step 1: Unbind gpio.5 device in order to invoke the *remove* callback.
#echo omap_gpio.5  sys/bus/platform/drivers/omap_gpio/unbind

Step 2: Bind gpio.5 device and confirm probe() for the device succeeds.
#echo omap_gpio.5  sys/bus/platform/drivers/omap_gpio/bind

Step 3: Execute read/write GPIO test case.

 drivers/gpio/gpio-omap.c |   35 +++
 1 files changed, 35 insertions(+), 0 deletions(-)

diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
index e6efd77..50de875 100644
--- a/drivers/gpio/gpio-omap.c
+++ b/drivers/gpio/gpio-omap.c
@@ -1152,6 +1152,40 @@ static int __devinit omap_gpio_probe(struct 
platform_device *pdev)
return ret;
 }
 
+/**
+ * omap_gpio_remove - cleanup a registered gpio device
+ * @pdev:   pointer to current gpio platform device
+ *
+ * Called by driver framework whenever a gpio device is unregistered.
+ * GPIO is deleted from the list and associated clock handle freed.
+ */
+static int __devexit omap_gpio_remove(struct platform_device *pdev)
+{
+   struct device *dev = pdev-dev;
+   struct gpio_bank *bank;
+   unsigned long flags;
+   int ret = -EINVAL;
+
+   list_for_each_entry(bank, omap_gpio_list, node) {
+   spin_lock_irqsave(bank-lock, flags);
+   if (bank-dev == dev) {
+   clk_put(bank-dbck);
+   list_del(bank-node);
+   ret = 0;
+   spin_unlock_irqrestore(bank-lock, flags);
+   break;
+   }
+   spin_unlock_irqrestore(bank-lock, flags);
+   }
+
+   if (!ret) {
+   pm_runtime_disable(bank-dev);
+   irq_free_descs(bank-irq_base, bank-width);
+   }
+
+   return ret;
+}
+
 #ifdef CONFIG_ARCH_OMAP2PLUS
 
 #if defined(CONFIG_PM_RUNTIME)
@@ -1478,6 +1512,7 @@ MODULE_DEVICE_TABLE(of, omap_gpio_match);
 
 static struct platform_driver omap_gpio_driver = {
.probe  = omap_gpio_probe,
+   .remove = __devexit_p(omap_gpio_remove),
.driver = {
.name   = omap_gpio,
.pm = gpio_pm_ops,
-- 
1.7.0.4

--
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 1/2] gpio/omap: move bank-dbck initialization to omap_gpio_mod_init()

2012-07-11 Thread Tarun Kanti DebBarma
Since the bank-dbck initialization in a one time operation there
is no need to keep this within gpio_debounce(). Therefore, moving
clk_get(bank-dbck) to omap_gpio_mod_init(). Since the value of
bank-dbck would be NULL at the beginning, this check has been
removed.

Signed-off-by: Tarun Kanti DebBarma tarun.ka...@ti.com
Reported-by: Paul Walmsley p...@pwsan.com
Reviewed-by: Jon Hunter jon-hun...@ti.com
Cc: Kevin Hilman khil...@ti.com
Cc: Rajendra Nayak rna...@ti.com
Cc: Santosh Shilimkar santosh.shilim...@ti.com
Cc: Cousson, Benoit b-cous...@ti.com
Cc: Paul Walmsley p...@pwsan.com
---
 drivers/gpio/gpio-omap.c |   10 --
 1 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
index c4ed172..afecdcc 100644
--- a/drivers/gpio/gpio-omap.c
+++ b/drivers/gpio/gpio-omap.c
@@ -889,12 +889,6 @@ static int gpio_debounce(struct gpio_chip *chip, unsigned 
offset,
 
bank = container_of(chip, struct gpio_bank, chip);
 
-   if (!bank-dbck) {
-   bank-dbck = clk_get(bank-dev, dbclk);
-   if (IS_ERR(bank-dbck))
-   dev_err(bank-dev, Could not get gpio dbck\n);
-   }
-
spin_lock_irqsave(bank-lock, flags);
_set_gpio_debounce(bank, offset, debounce);
spin_unlock_irqrestore(bank-lock, flags);
@@ -966,6 +960,10 @@ static void omap_gpio_mod_init(struct gpio_bank *bank)
 /* Initialize interface clk ungated, module enabled */
if (bank-regs-ctrl)
__raw_writel(0, base + bank-regs-ctrl);
+
+   bank-dbck = clk_get(bank-dev, dbclk);
+   if (IS_ERR(bank-dbck))
+   dev_err(bank-dev, Could not get gpio dbck\n);
 }
 
 static __devinit void
-- 
1.7.0.4

--
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 2/2] gpio/omap: add *remove* callback in platform_driver

2012-07-11 Thread Tarun Kanti DebBarma
Add *remove* callback so that necessary cleanup operations are
performed when device is unregistered. The device is deleted
from the list and associated clock handle is released by
calling clk_put() and irq descriptor is released using the
irq_free_desc() api.

Signed-off-by: Tarun Kanti DebBarma tarun.ka...@ti.com
Reported-by: Paul Walmsley p...@pwsan.com
Reviewed-by: Jon Hunter jon-hun...@ti.com
Cc: Kevin Hilman khil...@ti.com
Cc: Rajendra Nayak rna...@ti.com
Cc: Santosh Shilimkar santosh.shilim...@ti.com
Cc: Cousson, Benoit b-cous...@ti.com
Cc: Paul Walmsley p...@pwsan.com
---
 drivers/gpio/gpio-omap.c |   30 ++
 1 files changed, 30 insertions(+), 0 deletions(-)

diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
index afecdcc..08929d5 100644
--- a/drivers/gpio/gpio-omap.c
+++ b/drivers/gpio/gpio-omap.c
@@ -1140,6 +1140,35 @@ static int __devinit omap_gpio_probe(struct 
platform_device *pdev)
return ret;
 }
 
+/**
+ * omap_gpio_remove - cleanup a registered gpio device
+ * @pdev:   pointer to current gpio platform device
+ *
+ * Called by driver framework whenever a gpio device is unregistered.
+ * GPIO is deleted from the list and associated clock handle freed.
+ */
+static int __devexit omap_gpio_remove(struct platform_device *pdev)
+{
+   struct device *dev = pdev-dev;
+   struct gpio_bank *bank;
+   unsigned long flags;
+   int ret = -EINVAL;
+
+   list_for_each_entry(bank, omap_gpio_list, node) {
+   spin_lock_irqsave(bank-lock, flags);
+   if (bank-dev == dev) {
+   list_del(bank-node);
+   clk_put(bank-dbck);
+   irq_free_desc(bank-irq_base);
+   ret = 0;
+   spin_unlock_irqrestore(bank-lock, flags);
+   break;
+   }
+   spin_unlock_irqrestore(bank-lock, flags);
+   }
+   return ret;
+}
+
 #ifdef CONFIG_ARCH_OMAP2PLUS
 
 #if defined(CONFIG_PM_RUNTIME)
@@ -1466,6 +1495,7 @@ MODULE_DEVICE_TABLE(of, omap_gpio_match);
 
 static struct platform_driver omap_gpio_driver = {
.probe  = omap_gpio_probe,
+   .remove = __devexit_p(omap_gpio_remove),
.driver = {
.name   = omap_gpio,
.pm = gpio_pm_ops,
-- 
1.7.0.4

--
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 v2 REPOST 4/4] ARM: OMAP2+: dmtimer: cleanup fclk usage

2012-07-05 Thread Tarun Kanti DebBarma
With omap_hwmod_get_main_clk() now available, this can be passed to
clk_get() to extract the fclk and thus avoid construction of fclk name.
Corrected the timer fck name mis-match between clock44xx_data.c and
omap_hwmod_44xx_data.c. For other platforms this is already taken care.

Cc: Cousson, Benoit b-cous...@ti.com
Cc: Paul Walmsley p...@pwsan.com
Cc: Tony Lindgren t...@atomide.com
Cc: Kevin Hilman khil...@ti.com
Cc: Rajendra Nayak rna...@ti.com
Cc: Santosh Shilimkar santosh.shilim...@ti.com

Signed-off-by: Tarun Kanti DebBarma tarun.ka...@ti.com
---
Reference:
git://git.kernel.org/pub/scm/linux/kernel/git/tmlind/linux-omap.git
Branch: cleanup-part2

Tested on ZOOM3, BLAZE, PANDA.

 arch/arm/mach-omap2/clock44xx_data.c |   22 +++---
 arch/arm/mach-omap2/timer.c  |3 +--
 2 files changed, 12 insertions(+), 13 deletions(-)

diff --git a/arch/arm/mach-omap2/clock44xx_data.c 
b/arch/arm/mach-omap2/clock44xx_data.c
index ba6f9a0..f9d4f58 100644
--- a/arch/arm/mach-omap2/clock44xx_data.c
+++ b/arch/arm/mach-omap2/clock44xx_data.c
@@ -3299,17 +3299,17 @@ static struct omap_clk omap44xx_clks[] = {
CLK(NULL,   smartreflex_core_fck, smartreflex_core_fck,  
CK_443X),
CLK(NULL,   smartreflex_iva_fck,  smartreflex_iva_fck,   
CK_443X),
CLK(NULL,   smartreflex_mpu_fck,  smartreflex_mpu_fck,   
CK_443X),
-   CLK(NULL,   gpt1_fck, timer1_fck,
CK_443X),
-   CLK(NULL,   gpt10_fck,timer10_fck,   
CK_443X),
-   CLK(NULL,   gpt11_fck,timer11_fck,   
CK_443X),
-   CLK(NULL,   gpt2_fck, timer2_fck,
CK_443X),
-   CLK(NULL,   gpt3_fck, timer3_fck,
CK_443X),
-   CLK(NULL,   gpt4_fck, timer4_fck,
CK_443X),
-   CLK(NULL,   gpt5_fck, timer5_fck,
CK_443X),
-   CLK(NULL,   gpt6_fck, timer6_fck,
CK_443X),
-   CLK(NULL,   gpt7_fck, timer7_fck,
CK_443X),
-   CLK(NULL,   gpt8_fck, timer8_fck,
CK_443X),
-   CLK(NULL,   gpt9_fck, timer9_fck,
CK_443X),
+   CLK(NULL,   timer1_fck,   timer1_fck,
CK_443X),
+   CLK(NULL,   timer10_fck,  timer10_fck,   
CK_443X),
+   CLK(NULL,   timer11_fck,  timer11_fck,   
CK_443X),
+   CLK(NULL,   timer2_fck,   timer2_fck,
CK_443X),
+   CLK(NULL,   timer3_fck,   timer3_fck,
CK_443X),
+   CLK(NULL,   timer4_fck,   timer4_fck,
CK_443X),
+   CLK(NULL,   timer5_fck,   timer5_fck,
CK_443X),
+   CLK(NULL,   timer6_fck,   timer6_fck,
CK_443X),
+   CLK(NULL,   timer7_fck,   timer7_fck,
CK_443X),
+   CLK(NULL,   timer8_fck,   timer8_fck,
CK_443X),
+   CLK(NULL,   timer9_fck,   timer9_fck,
CK_443X),
CLK(NULL,   uart1_fck,uart1_fck, 
CK_443X),
CLK(NULL,   uart2_fck,uart2_fck, 
CK_443X),
CLK(NULL,   uart3_fck,uart3_fck, 
CK_443X),
diff --git a/arch/arm/mach-omap2/timer.c b/arch/arm/mach-omap2/timer.c
index 840929b..4c9ef35 100644
--- a/arch/arm/mach-omap2/timer.c
+++ b/arch/arm/mach-omap2/timer.c
@@ -173,8 +173,7 @@ static int __init omap_dm_timer_init_one(struct 
omap_dm_timer *timer,
return -ENXIO;
 
/* After the dmtimer is using hwmod these clocks won't be needed */
-   sprintf(name, gpt%d_fck, gptimer_id);
-   timer-fclk = clk_get(NULL, name);
+   timer-fclk = clk_get(NULL, omap_hwmod_get_main_clk(oh));
if (IS_ERR(timer-fclk))
return -ENODEV;
 
-- 
1.7.0.4

--
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] ARM: OMAP4: PM: Keep static dep between MPUSS and ABE clockdomain

2012-05-15 Thread Tarun Kanti DebBarma
Commit 68523f4233de5f233478dde0a63047b4efb710b8 (ARM: OMAP4:
Workaround the OCP synchronisation issue with 32K synctimer)
does not include GP Timers in ABE domain. Since synchronization
issue is applicable to all GPTIMER[1-12], we also need to set
static dependency of MPUSS with abe_clkdm and l4_per_clkdm.
Dependency with l4_per_clkdm timers is already set in commit
12f27826bdaf56b01cbdfc8bdeb577ebc106dee3 (ARM: OMAP4: PM: Keep
static dep between MPUSS-EMIF and MPUSS-L3/L4 and DUCATI-L3).
Therefore, set static dependency of MPUSS with abe_clkdm.

Cc: Kevin Hilman khil...@ti.com
Cc: Tony Lindgren t...@atomide.com
Cc: Russell King li...@arm.linux.org.uk
Signed-off-by: Tarun Kanti DebBarma tarun.ka...@ti.com
---
 arch/arm/mach-omap2/pm44xx.c |6 +-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/arch/arm/mach-omap2/pm44xx.c b/arch/arm/mach-omap2/pm44xx.c
index 8856253..f788e98 100644
--- a/arch/arm/mach-omap2/pm44xx.c
+++ b/arch/arm/mach-omap2/pm44xx.c
@@ -146,6 +146,7 @@ static int __init omap4_pm_init(void)
int ret;
struct clockdomain *emif_clkdm, *mpuss_clkdm, *l3_1_clkdm, *l4wkup;
struct clockdomain *ducati_clkdm, *l3_2_clkdm, *l4_per_clkdm;
+   struct clockdomain *abe_clkdm;
 
if (!cpu_is_omap44xx())
return -ENODEV;
@@ -180,8 +181,10 @@ static int __init omap4_pm_init(void)
l4_per_clkdm = clkdm_lookup(l4_per_clkdm);
l4wkup = clkdm_lookup(l4_wkup_clkdm);
ducati_clkdm = clkdm_lookup(ducati_clkdm);
+   abe_clkdm = clkdm_lookup(abe_clkdm);
if ((!mpuss_clkdm) || (!emif_clkdm) || (!l3_1_clkdm) || (!l4wkup) ||
-   (!l3_2_clkdm) || (!ducati_clkdm) || (!l4_per_clkdm))
+   (!l3_2_clkdm) || (!ducati_clkdm) || (!l4_per_clkdm) ||
+   (!abe_clkdm))
goto err2;
 
ret = clkdm_add_wkdep(mpuss_clkdm, emif_clkdm);
@@ -191,6 +194,7 @@ static int __init omap4_pm_init(void)
ret |= clkdm_add_wkdep(mpuss_clkdm, l4wkup);
ret |= clkdm_add_wkdep(ducati_clkdm, l3_1_clkdm);
ret |= clkdm_add_wkdep(ducati_clkdm, l3_2_clkdm);
+   ret |= clkdm_add_wkdep(mpuss_clkdm, abe_clkdm);
if (ret) {
pr_err(Failed to add MPUSS - L3/EMIF/L4PER, DUCATI - L3 
wakeup dependency\n);
-- 
1.7.0.4

--
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 0/2] ARM: omap: dmtimer: fix incorrect TCRR value in posted mode

2012-05-11 Thread Tarun Kanti DebBarma
Timers in PER domain periodically report old time from TCRR in posted mode
unless ICLK = 4 * FCLK. The problem is addressed in the following manner:

Patch 1: Adds ick alias in the clkdev table so that dmtimer code can
extract the iclk rate using clk_get_rate().

Patch 2: The final logic added in omap_dm_timer_prepare() where timer is
set to non-posted mode if iclk  4*fclk.

Rajendra Nayak (1):
  ARM: omap: hwmod: Add an 'ick' clkdev alias

Tarun Kanti DebBarma (1):
  ARM: omap: dmtimer: set non-posted mode if iclk less than 4*fck

 arch/arm/plat-omap/dmtimer.c |   12 
 arch/arm/plat-omap/omap_device.c |3 +++
 2 files changed, 15 insertions(+), 0 deletions(-)

--
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 1/2] ARM: omap: hwmod: Add an 'ick' clkdev alias

2012-05-11 Thread Tarun Kanti DebBarma
From: Rajendra Nayak rna...@ti.com

For all hwmods' with just one slave interface, use the
slave-clk to add an 'ick' clkdev alias in the table.
This is useful for drivers of such devices to get
the interface clock using 'clk_get(dev, ick)'

Signed-off-by: Rajendra Nayak rna...@ti.com
---
 arch/arm/plat-omap/omap_device.c |3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/arch/arm/plat-omap/omap_device.c b/arch/arm/plat-omap/omap_device.c
index d50cbc6..c8bc005 100644
--- a/arch/arm/plat-omap/omap_device.c
+++ b/arch/arm/plat-omap/omap_device.c
@@ -311,6 +311,9 @@ static void _add_hwmod_clocks_clkdev(struct omap_device *od,
 
for (i = 0; i  oh-opt_clks_cnt; i++)
_add_clkdev(od, oh-opt_clks[i].role, oh-opt_clks[i].clk);
+
+   if (oh-slaves_cnt == 1)
+   _add_clkdev(od, ick, oh-slaves[0]-clk);
 }
 
 
-- 
1.7.0.4

--
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 2/2] ARM: omap: dmtimer: set non-posted mode if iclk less than 4*fck

2012-05-11 Thread Tarun Kanti DebBarma
Timers in PER domain periodically report old time from TCRR in
posted mode if ick  4*fck. Therefore, set timer to non-posted
whenever ick  4*fck for all timers.

Signed-off-by: Tarun Kanti DebBarma tarun.ka...@ti.com
---
 arch/arm/plat-omap/dmtimer.c |   12 
 1 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/arch/arm/plat-omap/dmtimer.c b/arch/arm/plat-omap/dmtimer.c
index 15e7882..a81b85e 100644
--- a/arch/arm/plat-omap/dmtimer.c
+++ b/arch/arm/plat-omap/dmtimer.c
@@ -378,6 +378,7 @@ int omap_dm_timer_set_source(struct omap_dm_timer *timer, 
int source)
 {
int ret;
struct dmtimer_platform_data *pdata;
+   struct clk *iclk;
 
if (unlikely(!timer))
return -EINVAL;
@@ -388,6 +389,17 @@ int omap_dm_timer_set_source(struct omap_dm_timer *timer, 
int source)
return -EINVAL;
 
ret = pdata-set_timer_src(timer-pdev, source);
+   /*
+* Timers in PER domain periodically report old time
+* from TCRR in posted mode if ick  4*fck. Hence,
+* when this condition is satisfied setting the timer
+* to non-posted mode, instead.
+*/
+   if (!IS_ERR(ret)) {
+   iclk = clk_get(timer-pdev-dev, ick);
+   if (clk_get_rate(iclk)  (4 * clk_get_rate(timer-fclk)))
+   timer-posted = 0;
+   }
 
return ret;
 }
-- 
1.7.0.4

--
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 v2] gpio/omap: fix incorrect initialization of omap_gpio_mod_init

2012-04-30 Thread Tarun Kanti DebBarma
Initialization of irqenable, irqstatus registers is the common
operation done in this function for all OMAP platforms, viz. OMAP1,
OMAP2+. The latter _gpio_rmw()'s which supposedly got introduced
wrongly to take care of OMAP2+ platforms were overwriting initially
programmed OMAP1 value breaking functionality on OMAP1.
Somehow incorrect assumption was made that each _gpio_rmw()'s were
mutually exclusive. On close observation it is found that the first
_gpio_rmw() which is supposedly done to take care of OMAP1 platform
is generic enough and takes care of OMAP2+ platform as well.
Therefore remove the latter _gpio_rmw() to irqenable as they are
redundant now.

Writing to ctrl and debounce_en registers for OMAP2+ platforms are
modified to match the original(pre-cleanup) code where the registers
are initialized with 0. In the cleanup series since we are using
_gpio_rmw(reg, 0, 1), instead of __raw_writel(), we are just reading
and writing the same values to ctrl and debounce_en. This is not an
issue for debounce_en register because it has 0x0 as the default value.
But in the case of ctrl register the default value is 0x2 (GATINGRATIO
 = 0x1) so that we end up writing 0x2 instead of intended 0 value.
Therefore changing back to __raw_writel() as this is sufficient for
this case besides simpler to understand.

Also, change irqstatus initalization logic that avoids comparison
with bool, besides making it fit in a single line.

Cc: sta...@vger.kernel.org
Cc: Tony Lindgren t...@atomide.com
Cc: Kevin Hilman khil...@ti.com
Cc: Santosh Shilimkar santosh.shilim...@ti.com
Cc: Grant Likely grant.lik...@secretlab.ca
Reported-by: Janusz Krzysztofik jkrzy...@tis.icnet.pl
Signed-off-by: Tarun Kanti DebBarma tarun.ka...@ti.com
---
v2:
Avoid irqstatus initialization sequence change.
Use __raw_writel() to update debounce_en and ctrl registers.
Update changelog to elaborate how redundant _gpio_rmw() got added.

 drivers/gpio/gpio-omap.c |9 +++--
 1 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
index 59a4af1..9b71f04 100644
--- a/drivers/gpio/gpio-omap.c
+++ b/drivers/gpio/gpio-omap.c
@@ -957,18 +957,15 @@ static void omap_gpio_mod_init(struct gpio_bank *bank)
}
 
_gpio_rmw(base, bank-regs-irqenable, l, bank-regs-irqenable_inv);
-   _gpio_rmw(base, bank-regs-irqstatus, l,
-   bank-regs-irqenable_inv == false);
-   _gpio_rmw(base, bank-regs-irqenable, l, bank-regs-debounce_en != 0);
-   _gpio_rmw(base, bank-regs-irqenable, l, bank-regs-ctrl != 0);
+   _gpio_rmw(base, bank-regs-irqstatus, l, !bank-regs-irqenable_inv);
if (bank-regs-debounce_en)
-   _gpio_rmw(base, bank-regs-debounce_en, 0, 1);
+   __raw_writel(0, base + bank-regs-debounce_en);
 
/* Save OE default value (0x) in the context */
bank-context.oe = __raw_readl(bank-base + bank-regs-direction);
 /* Initialize interface clk ungated, module enabled */
if (bank-regs-ctrl)
-   _gpio_rmw(base, bank-regs-ctrl, 0, 1);
+   __raw_writel(0, base + bank-regs-ctrl);
 }
 
 static __devinit void
-- 
1.7.0.4

--
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] gpio/omap: fix incorrect initialization of omap_gpio_mod_init

2012-04-27 Thread Tarun Kanti DebBarma
Breaking commit: ab985f0f7c2c0ef90b7c832f0c04f470dda0593d

Initialization of irqenable, irqstatus registers is the common
operation done in this function for all OMAP platforms, viz.
OMAP1, OMAP2+. The latter _gpio_rmw()'s to irqenable register
was overwriting the correctly programmed OMAP1 value at the
beginning. As a result, even though it worked on OMAP2+
platforms it was breaking OMAP1 functionality. On close
observation it is found that the first _gpio_rmw() which is
supposedly done to take care of OMAP1 platform is generic enough
and takes care of OMAP2+ platform as well. Therefore remove the
latter _gpio_rmw() to irqenable as they are redundant now.

Writing to ctrl and debounce_en registers for OMAP2+ platforms
are modified to match the original(pre-cleanup) code where the
registers are initialized with 0. In the cleanup series since
we are using _gpio_rmw(reg, 0, 1), instead of __raw_writel(),
we are just reading and writing the same values to ctrl and
debounce_en. This is not an issue for debounce_en register
because it has 0x0 as the default value. But in the case of
ctrl register the default value is 0x2 (GATINGRATIO = 0x1)
so that we end up writing 0x2 instead of intended 0 value.
Therefore correcting it to _gpio_rmw(reg, l, 0), where
l = 0x so that registers are initialized to 0.

Also, changing the sequence and logic of initializing the irqstatus.

Cc: sta...@vger.kernel.org
Cc: Tony Lindgren t...@atomide.com
Cc: Kevin Hilman khil...@ti.com
Cc: Santosh Shilimkar santosh.shilim...@ti.com
Cc: Grant Likely grant.lik...@secretlab.ca
Reported-by: Janusz Krzysztofik jkrzy...@tis.icnet.pl
Signed-off-by: Tarun Kanti DebBarma tarun.ka...@ti.com
---
Tested on OMAP2+ platforms and bootup test on OMAP1710.
Janusz,
Please help me in validating the patch on OMAP1 platform.

 drivers/gpio/gpio-omap.c |9 +++--
 1 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
index 1adc2ec..910fd14 100644
--- a/drivers/gpio/gpio-omap.c
+++ b/drivers/gpio/gpio-omap.c
@@ -964,19 +964,16 @@ static void omap_gpio_mod_init(struct gpio_bank *bank)
return;
}
 
+   _gpio_rmw(base, bank-regs-irqstatus, l, !bank-regs-irqenable_inv);
_gpio_rmw(base, bank-regs-irqenable, l, bank-regs-irqenable_inv);
-   _gpio_rmw(base, bank-regs-irqstatus, l,
-   bank-regs-irqenable_inv == false);
-   _gpio_rmw(base, bank-regs-irqenable, l, bank-regs-debounce_en != 0);
-   _gpio_rmw(base, bank-regs-irqenable, l, bank-regs-ctrl != 0);
if (bank-regs-debounce_en)
-   _gpio_rmw(base, bank-regs-debounce_en, 0, 1);
+   _gpio_rmw(base, bank-regs-debounce_en, l, 0);
 
/* Save OE default value (0x) in the context */
bank-context.oe = __raw_readl(bank-base + bank-regs-direction);
 /* Initialize interface clk ungated, module enabled */
if (bank-regs-ctrl)
-   _gpio_rmw(base, bank-regs-ctrl, 0, 1);
+   _gpio_rmw(base, bank-regs-ctrl, l, 0);
 }
 
 static __devinit void
-- 
1.7.0.4

--
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 0/8] gpio/omap: remaining cleanups and fix

2012-04-27 Thread Tarun Kanti DebBarma
Here are the remaining cleanup patches. There are broadly
two categories of cleanups.

Cat-1: Those missed while introducing new feature like SPARSE_IRQ
   handling and DT support; use edge/level handlers from
   generic IRQ framework.

Cat-2: Removal of redundant fields from struct gpio_bank{} as a
   result of they being already covered by members within
   context field of struct gpio_bank{}.

Reference: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git
Commit: 66f75a5d028beaf67c931435fdc3e7823125730c (Linux 3.4-rc4)

Series is available for reference here:
git://gitorious.org/~tarunkanti/omap-sw-develoment/tarunkantis-linux-omap-dev.git
 for_3.5/gpio_more_cleanup_fixes

Test info:
OMAP2+ platforms: OMAP2430SDP, OMAP3430SDP, OMAP4430SDP
OMAP1: Bootup test on OMAP1710SDP.

Cc: Kevin Hilman khil...@ti.com
Cc: Tony Lindgren t...@atomide.com
Cc: Santosh Shilimkar santosh.shilim...@ti.com
Cc: Cousson, Benoit b-cous...@ti.com
Cc: Grant Likely grant.lik...@secretlab.ca
Tarun Kanti DebBarma (8):
  gpio/omap: remove virtual_irq_start variable
  gpio/omap: remove saved_fallingdetect, saved_risingdetect
  gpio/omap: remove suspend_wakeup field from struct gpio_bank
  gpio/omap: remove saved_wakeup field from struct gpio_bank
  gpio/omap: remove retrigger variable in gpio_irq_handler
  gpio/omap: remove suspend/resume callbacks
  gpio/omap: remove cpu_is_omap() checks from *_runtime_resume()
  gpio/omap: fix missing check in *_runtime_suspend()

 arch/arm/mach-omap1/gpio15xx.c |2 -
 arch/arm/mach-omap1/gpio16xx.c |5 --
 arch/arm/mach-omap1/gpio7xx.c  |7 --
 arch/arm/mach-omap2/gpio.c |3 +-
 arch/arm/plat-omap/include/plat/gpio.h |3 +-
 drivers/gpio/gpio-omap.c   |  103 +++-
 6 files changed, 27 insertions(+), 96 deletions(-)

--
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 8/8] gpio/omap: fix missing check in *_runtime_suspend()

2012-04-27 Thread Tarun Kanti DebBarma
We do checking for bank-enabled_non_wakeup_gpios in order
to skip redundant operations. Somehow, the check got missed
while doing the cleanup series.

Just to make sure that we do context restore correctly in
*_runtime_resume(), the bank-workaround_enabled check is
moved after context restore. Otherwise, it would prevent
context restore when bank-enabled_non_wakeup_gpios is 0.

Cc: Kevin Hilman khil...@ti.com
Cc: Tony Lindgren t...@atomide.com
Cc: Santosh Shilimkar santosh.shilim...@ti.com
Cc: Cousson, Benoit b-cous...@ti.com
Cc: Grant Likely grant.lik...@secretlab.ca
Signed-off-by: Tarun Kanti DebBarma tarun.ka...@ti.com
---
 drivers/gpio/gpio-omap.c |   13 -
 1 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
index d238f84..59a4af1 100644
--- a/drivers/gpio/gpio-omap.c
+++ b/drivers/gpio/gpio-omap.c
@@ -1160,6 +1160,9 @@ static int omap_gpio_runtime_suspend(struct device *dev)
 
spin_lock_irqsave(bank-lock, flags);
 
+   if (!bank-enabled_non_wakeup_gpios)
+   goto update_gpio_context_count;
+
/*
 * Only edges can generate a wakeup event to the PRCM.
 *
@@ -1235,11 +1238,6 @@ static int omap_gpio_runtime_resume(struct device *dev)
__raw_writel(bank-context.risingdetect,
 bank-base + bank-regs-risingdetect);
 
-   if (!bank-workaround_enabled) {
-   spin_unlock_irqrestore(bank-lock, flags);
-   return 0;
-   }
-
if (bank-get_context_loss_count) {
context_lost_cnt_after =
bank-get_context_loss_count(bank-dev);
@@ -1252,6 +1250,11 @@ static int omap_gpio_runtime_resume(struct device *dev)
}
}
 
+   if (!bank-workaround_enabled) {
+   spin_unlock_irqrestore(bank-lock, flags);
+   return 0;
+   }
+
__raw_writel(bank-context.fallingdetect,
bank-base + bank-regs-fallingdetect);
__raw_writel(bank-context.risingdetect,
-- 
1.7.0.4

--
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 7/8] gpio/omap: remove cpu_is_omapxxxx() checks from *_runtime_resume()

2012-04-27 Thread Tarun Kanti DebBarma
Add register offsets for GPIO_IRQSTATUS_RAW_0, GPIO_IRQSTATUS_RAW_0
which are present on OMAP4+ processors. Now we can distinguish
conditions applicable to OMAP4,5 and those specific to OMAP24xx
and OMAP3xxx.

Cc: Kevin Hilman khil...@ti.com
Cc: Tony Lindgren t...@atomide.com
Cc: Santosh Shilimkar santosh.shilim...@ti.com
Cc: Cousson, Benoit b-cous...@ti.com
Cc: Grant Likely grant.lik...@secretlab.ca
Signed-off-by: Tarun Kanti DebBarma tarun.ka...@ti.com
---
 arch/arm/mach-omap2/gpio.c |2 ++
 arch/arm/plat-omap/include/plat/gpio.h |2 ++
 drivers/gpio/gpio-omap.c   |4 ++--
 3 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-omap2/gpio.c b/arch/arm/mach-omap2/gpio.c
index 86f91a6..a144e22 100644
--- a/arch/arm/mach-omap2/gpio.c
+++ b/arch/arm/mach-omap2/gpio.c
@@ -101,6 +101,8 @@ static int __init omap2_gpio_dev_init(struct omap_hwmod 
*oh, void *unused)
pdata-regs-dataout = OMAP4_GPIO_DATAOUT;
pdata-regs-set_dataout = OMAP4_GPIO_SETDATAOUT;
pdata-regs-clr_dataout = OMAP4_GPIO_CLEARDATAOUT;
+   pdata-regs-irqstatus_raw0 = OMAP4_GPIO_IRQSTATUSRAW0;
+   pdata-regs-irqstatus_raw1 = OMAP4_GPIO_IRQSTATUSRAW1;
pdata-regs-irqstatus = OMAP4_GPIO_IRQSTATUS0;
pdata-regs-irqstatus2 = OMAP4_GPIO_IRQSTATUS1;
pdata-regs-irqenable = OMAP4_GPIO_IRQSTATUSSET0;
diff --git a/arch/arm/plat-omap/include/plat/gpio.h 
b/arch/arm/plat-omap/include/plat/gpio.h
index d903e7d..50fb7cc 100644
--- a/arch/arm/plat-omap/include/plat/gpio.h
+++ b/arch/arm/plat-omap/include/plat/gpio.h
@@ -172,6 +172,8 @@ struct omap_gpio_reg_offs {
u16 clr_dataout;
u16 irqstatus;
u16 irqstatus2;
+   u16 irqstatus_raw0;
+   u16 irqstatus_raw1;
u16 irqenable;
u16 irqenable2;
u16 set_irqenable;
diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
index ae62c62..d238f84 100644
--- a/drivers/gpio/gpio-omap.c
+++ b/drivers/gpio/gpio-omap.c
@@ -1289,14 +1289,14 @@ static int omap_gpio_runtime_resume(struct device *dev)
old0 = __raw_readl(bank-base + bank-regs-leveldetect0);
old1 = __raw_readl(bank-base + bank-regs-leveldetect1);
 
-   if (cpu_is_omap24xx() || cpu_is_omap34xx()) {
+   if (!bank-regs-irqstatus_raw0) {
__raw_writel(old0 | gen, bank-base +
bank-regs-leveldetect0);
__raw_writel(old1 | gen, bank-base +
bank-regs-leveldetect1);
}
 
-   if (cpu_is_omap44xx()) {
+   if (bank-regs-irqstatus_raw0) {
__raw_writel(old0 | l, bank-base +
bank-regs-leveldetect0);
__raw_writel(old1 | l, bank-base +
-- 
1.7.0.4

--
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 6/8] gpio/omap: remove suspend/resume callbacks

2012-04-27 Thread Tarun Kanti DebBarma
Both omap_gpio_suspend() and omap_gpio_resume() does programming
of wakeup_en register.
_gpio_rmw(base, bank-regs-wkup_en, 0x, 0);
_gpio_rmw(base, bank-regs-wkup_en, bank-context.wake_en, 1);

This is redundant in omap_gpio_suspend() because wakeup_en
register automatically gets initialized in _set_gpio_wakeup()
and set_gpio_trigger() while being called either from
chip.irq_set_wake() or chip.irq_set_type().

This is also redundant in omap_gpio_resume() because wakeup_en
register is programmed in omap_gpio_restore_context() called
which is called from runtime resume callback.

Cc: Kevin Hilman khil...@ti.com
Cc: Tony Lindgren t...@atomide.com
Cc: Santosh Shilimkar santosh.shilim...@ti.com
Cc: Cousson, Benoit b-cous...@ti.com
Cc: Grant Likely grant.lik...@secretlab.ca
Signed-off-by: Tarun Kanti DebBarma tarun.ka...@ti.com
Reviewed-by: Santosh Shilimkar santosh.shilim...@ti.com
---
 drivers/gpio/gpio-omap.c |   47 --
 1 files changed, 0 insertions(+), 47 deletions(-)

diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
index 7533564..ae62c62 100644
--- a/drivers/gpio/gpio-omap.c
+++ b/drivers/gpio/gpio-omap.c
@@ -1147,50 +1147,6 @@ static int __devinit omap_gpio_probe(struct 
platform_device *pdev)
 
 #ifdef CONFIG_ARCH_OMAP2PLUS
 
-#if defined(CONFIG_PM_SLEEP)
-static int omap_gpio_suspend(struct device *dev)
-{
-   struct platform_device *pdev = to_platform_device(dev);
-   struct gpio_bank *bank = platform_get_drvdata(pdev);
-   void __iomem *base = bank-base;
-   unsigned long flags;
-
-   if (!bank-mod_usage || !bank-loses_context)
-   return 0;
-
-   if (!bank-regs-wkup_en || !bank-context.wake_en)
-   return 0;
-
-   spin_lock_irqsave(bank-lock, flags);
-   _gpio_rmw(base, bank-regs-wkup_en, 0x, 0);
-   _gpio_rmw(base, bank-regs-wkup_en, bank-context.wake_en, 1);
-   spin_unlock_irqrestore(bank-lock, flags);
-
-   return 0;
-}
-
-static int omap_gpio_resume(struct device *dev)
-{
-   struct platform_device *pdev = to_platform_device(dev);
-   struct gpio_bank *bank = platform_get_drvdata(pdev);
-   void __iomem *base = bank-base;
-   unsigned long flags;
-
-   if (!bank-mod_usage || !bank-loses_context)
-   return 0;
-
-   if (!bank-regs-wkup_en || !bank-context.wake_en)
-   return 0;
-
-   spin_lock_irqsave(bank-lock, flags);
-   _gpio_rmw(base, bank-regs-wkup_en, 0x, 0);
-   _gpio_rmw(base, bank-regs-wkup_en, bank-context.wake_en, 1);
-   spin_unlock_irqrestore(bank-lock, flags);
-
-   return 0;
-}
-#endif /* CONFIG_PM_SLEEP */
-
 #if defined(CONFIG_PM_RUNTIME)
 static void omap_gpio_restore_context(struct gpio_bank *bank);
 
@@ -1419,14 +1375,11 @@ static void omap_gpio_restore_context(struct gpio_bank 
*bank)
 }
 #endif /* CONFIG_PM_RUNTIME */
 #else
-#define omap_gpio_suspend NULL
-#define omap_gpio_resume NULL
 #define omap_gpio_runtime_suspend NULL
 #define omap_gpio_runtime_resume NULL
 #endif
 
 static const struct dev_pm_ops gpio_pm_ops = {
-   SET_SYSTEM_SLEEP_PM_OPS(omap_gpio_suspend, omap_gpio_resume)
SET_RUNTIME_PM_OPS(omap_gpio_runtime_suspend, omap_gpio_runtime_resume,
NULL)
 };
-- 
1.7.0.4

--
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 3/8] gpio/omap: remove suspend_wakeup field from struct gpio_bank

2012-04-27 Thread Tarun Kanti DebBarma
Since we already have bank-context.wake_en to keep track
of gpios which are wakeup enabled, there is no need to have
this field any more.

Cc: Kevin Hilman khil...@ti.com
Cc: Tony Lindgren t...@atomide.com
Cc: Santosh Shilimkar santosh.shilim...@ti.com
Cc: Cousson, Benoit b-cous...@ti.com
Cc: Grant Likely grant.lik...@secretlab.ca
Signed-off-by: Tarun Kanti DebBarma tarun.ka...@ti.com
Reviewed-by: Santosh Shilimkar santosh.shilim...@ti.com
Acked-by: Felipe Balbi ba...@ti.com
---
 drivers/gpio/gpio-omap.c |   13 ++---
 1 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
index 1751f89..7b00256 100644
--- a/drivers/gpio/gpio-omap.c
+++ b/drivers/gpio/gpio-omap.c
@@ -57,7 +57,6 @@ struct gpio_bank {
u16 irq;
int irq_base;
struct irq_domain *domain;
-   u32 suspend_wakeup;
u32 saved_wakeup;
u32 non_wakeup_gpios;
u32 enabled_non_wakeup_gpios;
@@ -514,11 +513,11 @@ static int _set_gpio_wakeup(struct gpio_bank *bank, int 
gpio, int enable)
 
spin_lock_irqsave(bank-lock, flags);
if (enable)
-   bank-suspend_wakeup |= gpio_bit;
+   bank-context.wake_en |= gpio_bit;
else
-   bank-suspend_wakeup = ~gpio_bit;
+   bank-context.wake_en = ~gpio_bit;
 
-   __raw_writel(bank-suspend_wakeup, bank-base + bank-regs-wkup_en);
+   __raw_writel(bank-context.wake_en, bank-base + bank-regs-wkup_en);
spin_unlock_irqrestore(bank-lock, flags);
 
return 0;
@@ -788,7 +787,7 @@ static int omap_mpuio_suspend_noirq(struct device *dev)
 
spin_lock_irqsave(bank-lock, flags);
bank-saved_wakeup = __raw_readl(mask_reg);
-   __raw_writel(0x  ~bank-suspend_wakeup, mask_reg);
+   __raw_writel(0x  ~bank-context.wake_en, mask_reg);
spin_unlock_irqrestore(bank-lock, flags);
 
return 0;
@@ -1165,7 +1164,7 @@ static int omap_gpio_suspend(struct device *dev)
if (!bank-mod_usage || !bank-loses_context)
return 0;
 
-   if (!bank-regs-wkup_en || !bank-suspend_wakeup)
+   if (!bank-regs-wkup_en || !bank-context.wake_en)
return 0;
 
wakeup_enable = bank-base + bank-regs-wkup_en;
@@ -1173,7 +1172,7 @@ static int omap_gpio_suspend(struct device *dev)
spin_lock_irqsave(bank-lock, flags);
bank-saved_wakeup = __raw_readl(wakeup_enable);
_gpio_rmw(base, bank-regs-wkup_en, 0x, 0);
-   _gpio_rmw(base, bank-regs-wkup_en, bank-suspend_wakeup, 1);
+   _gpio_rmw(base, bank-regs-wkup_en, bank-context.wake_en, 1);
spin_unlock_irqrestore(bank-lock, flags);
 
return 0;
-- 
1.7.0.4

--
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 5/8] gpio/omap: remove retrigger variable in gpio_irq_handler

2012-04-27 Thread Tarun Kanti DebBarma
commit 672e302e3c (ARM: OMAP: use edge/level handlers from generic IRQ
framework) removed retrigger support in favor of using generic IRQ
framework.  This patch cleans up some unused remnants of that removal.

Cc: Kevin Hilman khil...@ti.com
Cc: Tony Lindgren t...@atomide.com
Cc: Santosh Shilimkar santosh.shilim...@ti.com
Cc: Cousson, Benoit b-cous...@ti.com
Cc: Grant Likely grant.lik...@secretlab.ca
Signed-off-by: Tarun Kanti DebBarma tarun.ka...@ti.com
Reviewed-by: Santosh Shilimkar santosh.shilim...@ti.com
Acked-by: Felipe Balbi ba...@ti.com
---
 drivers/gpio/gpio-omap.c |3 ---
 1 files changed, 0 insertions(+), 3 deletions(-)

diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
index cb9f6d9..7533564 100644
--- a/drivers/gpio/gpio-omap.c
+++ b/drivers/gpio/gpio-omap.c
@@ -636,7 +636,6 @@ static void gpio_irq_handler(unsigned int irq, struct 
irq_desc *desc)
u32 isr;
unsigned int gpio_irq, gpio_index;
struct gpio_bank *bank;
-   u32 retrigger = 0;
int unmasked = 0;
struct irq_chip *chip = irq_desc_get_chip(desc);
 
@@ -673,8 +672,6 @@ static void gpio_irq_handler(unsigned int irq, struct 
irq_desc *desc)
chained_irq_exit(chip, desc);
}
 
-   isr |= retrigger;
-   retrigger = 0;
if (!isr)
break;
 
-- 
1.7.0.4

--
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 1/8] gpio/omap: remove virtual_irq_start variable

2012-04-27 Thread Tarun Kanti DebBarma
This cleanup got missed while implementing following:
25db711 gpio/omap: Fix IRQ handling for SPARSE_IRQ
384ebe1 gpio/omap: Add DT support to GPIO driver

Cc: Kevin Hilman khil...@ti.com
Cc: Tony Lindgren t...@atomide.com
Cc: Santosh Shilimkar santosh.shilim...@ti.com
Cc: Cousson, Benoit b-cous...@ti.com
Cc: Grant Likely grant.lik...@secretlab.ca
Signed-off-by: Tarun Kanti DebBarma tarun.ka...@ti.com
---
 arch/arm/mach-omap1/gpio15xx.c |2 --
 arch/arm/mach-omap1/gpio16xx.c |5 -
 arch/arm/mach-omap1/gpio7xx.c  |7 ---
 arch/arm/mach-omap2/gpio.c |1 -
 arch/arm/plat-omap/include/plat/gpio.h |1 -
 5 files changed, 0 insertions(+), 16 deletions(-)

diff --git a/arch/arm/mach-omap1/gpio15xx.c b/arch/arm/mach-omap1/gpio15xx.c
index 634903e..ebef15e 100644
--- a/arch/arm/mach-omap1/gpio15xx.c
+++ b/arch/arm/mach-omap1/gpio15xx.c
@@ -46,7 +46,6 @@ static struct omap_gpio_reg_offs omap15xx_mpuio_regs = {
 };
 
 static struct __initdata omap_gpio_platform_data omap15xx_mpu_gpio_config = {
-   .virtual_irq_start  = IH_MPUIO_BASE,
.is_mpuio   = true,
.bank_width = 16,
.bank_stride= 1,
@@ -89,7 +88,6 @@ static struct omap_gpio_reg_offs omap15xx_gpio_regs = {
 };
 
 static struct __initdata omap_gpio_platform_data omap15xx_gpio_config = {
-   .virtual_irq_start  = IH_GPIO_BASE,
.bank_width = 16,
.regs   = omap15xx_gpio_regs,
 };
diff --git a/arch/arm/mach-omap1/gpio16xx.c b/arch/arm/mach-omap1/gpio16xx.c
index 1fb3b9a..2a48cd2 100644
--- a/arch/arm/mach-omap1/gpio16xx.c
+++ b/arch/arm/mach-omap1/gpio16xx.c
@@ -52,7 +52,6 @@ static struct omap_gpio_reg_offs omap16xx_mpuio_regs = {
 };
 
 static struct __initdata omap_gpio_platform_data omap16xx_mpu_gpio_config = {
-   .virtual_irq_start  = IH_MPUIO_BASE,
.is_mpuio   = true,
.bank_width = 16,
.bank_stride= 1,
@@ -99,7 +98,6 @@ static struct omap_gpio_reg_offs omap16xx_gpio_regs = {
 };
 
 static struct __initdata omap_gpio_platform_data omap16xx_gpio1_config = {
-   .virtual_irq_start  = IH_GPIO_BASE,
.bank_width = 16,
.regs   = omap16xx_gpio_regs,
 };
@@ -128,7 +126,6 @@ static struct __initdata resource 
omap16xx_gpio2_resources[] = {
 };
 
 static struct __initdata omap_gpio_platform_data omap16xx_gpio2_config = {
-   .virtual_irq_start  = IH_GPIO_BASE + 16,
.bank_width = 16,
.regs   = omap16xx_gpio_regs,
 };
@@ -157,7 +154,6 @@ static struct __initdata resource 
omap16xx_gpio3_resources[] = {
 };
 
 static struct __initdata omap_gpio_platform_data omap16xx_gpio3_config = {
-   .virtual_irq_start  = IH_GPIO_BASE + 32,
.bank_width = 16,
.regs   = omap16xx_gpio_regs,
 };
@@ -186,7 +182,6 @@ static struct __initdata resource 
omap16xx_gpio4_resources[] = {
 };
 
 static struct __initdata omap_gpio_platform_data omap16xx_gpio4_config = {
-   .virtual_irq_start  = IH_GPIO_BASE + 48,
.bank_width = 16,
.regs   = omap16xx_gpio_regs,
 };
diff --git a/arch/arm/mach-omap1/gpio7xx.c b/arch/arm/mach-omap1/gpio7xx.c
index 4771d6b..acf12b7 100644
--- a/arch/arm/mach-omap1/gpio7xx.c
+++ b/arch/arm/mach-omap1/gpio7xx.c
@@ -51,7 +51,6 @@ static struct omap_gpio_reg_offs omap7xx_mpuio_regs = {
 };
 
 static struct __initdata omap_gpio_platform_data omap7xx_mpu_gpio_config = {
-   .virtual_irq_start  = IH_MPUIO_BASE,
.is_mpuio   = true,
.bank_width = 16,
.bank_stride= 2,
@@ -93,7 +92,6 @@ static struct omap_gpio_reg_offs omap7xx_gpio_regs = {
 };
 
 static struct __initdata omap_gpio_platform_data omap7xx_gpio1_config = {
-   .virtual_irq_start  = IH_GPIO_BASE,
.bank_width = 32,
.regs   = omap7xx_gpio_regs,
 };
@@ -122,7 +120,6 @@ static struct __initdata resource omap7xx_gpio2_resources[] 
= {
 };
 
 static struct __initdata omap_gpio_platform_data omap7xx_gpio2_config = {
-   .virtual_irq_start  = IH_GPIO_BASE + 32,
.bank_width = 32,
.regs   = omap7xx_gpio_regs,
 };
@@ -151,7 +148,6 @@ static struct __initdata resource omap7xx_gpio3_resources[] 
= {
 };
 
 static struct __initdata omap_gpio_platform_data omap7xx_gpio3_config = {
-   .virtual_irq_start  = IH_GPIO_BASE + 64,
.bank_width = 32,
.regs   = omap7xx_gpio_regs,
 };
@@ -180,7 +176,6 @@ static struct __initdata resource omap7xx_gpio4_resources[] 
= {
 };
 
 static struct __initdata omap_gpio_platform_data omap7xx_gpio4_config = {
-   .virtual_irq_start  = IH_GPIO_BASE + 96,
.bank_width = 32,
.regs

[PATCH 4/8] gpio/omap: remove saved_wakeup field from struct gpio_bank

2012-04-27 Thread Tarun Kanti DebBarma
There is no more need to have saved_wakeup because bank-context.wake_en
already holds that value. So getting rid of read/write operation associated
with this field.

Cc: Kevin Hilman khil...@ti.com
Cc: Tony Lindgren t...@atomide.com
Cc: Santosh Shilimkar santosh.shilim...@ti.com
Cc: Cousson, Benoit b-cous...@ti.com
Cc: Grant Likely grant.lik...@secretlab.ca
Signed-off-by: Tarun Kanti DebBarma tarun.ka...@ti.com
Reviewed-by: Santosh Shilimkar santosh.shilim...@ti.com
Acked-by: Felipe Balbi ba...@ti.com
---
 drivers/gpio/gpio-omap.c |   12 +++-
 1 files changed, 3 insertions(+), 9 deletions(-)

diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
index 7b00256..cb9f6d9 100644
--- a/drivers/gpio/gpio-omap.c
+++ b/drivers/gpio/gpio-omap.c
@@ -57,7 +57,6 @@ struct gpio_bank {
u16 irq;
int irq_base;
struct irq_domain *domain;
-   u32 saved_wakeup;
u32 non_wakeup_gpios;
u32 enabled_non_wakeup_gpios;
struct gpio_regs context;
@@ -786,7 +785,6 @@ static int omap_mpuio_suspend_noirq(struct device *dev)
unsigned long   flags;
 
spin_lock_irqsave(bank-lock, flags);
-   bank-saved_wakeup = __raw_readl(mask_reg);
__raw_writel(0x  ~bank-context.wake_en, mask_reg);
spin_unlock_irqrestore(bank-lock, flags);
 
@@ -802,7 +800,7 @@ static int omap_mpuio_resume_noirq(struct device *dev)
unsigned long   flags;
 
spin_lock_irqsave(bank-lock, flags);
-   __raw_writel(bank-saved_wakeup, mask_reg);
+   __raw_writel(bank-context.wake_en, mask_reg);
spin_unlock_irqrestore(bank-lock, flags);
 
return 0;
@@ -1158,7 +1156,6 @@ static int omap_gpio_suspend(struct device *dev)
struct platform_device *pdev = to_platform_device(dev);
struct gpio_bank *bank = platform_get_drvdata(pdev);
void __iomem *base = bank-base;
-   void __iomem *wakeup_enable;
unsigned long flags;
 
if (!bank-mod_usage || !bank-loses_context)
@@ -1167,10 +1164,7 @@ static int omap_gpio_suspend(struct device *dev)
if (!bank-regs-wkup_en || !bank-context.wake_en)
return 0;
 
-   wakeup_enable = bank-base + bank-regs-wkup_en;
-
spin_lock_irqsave(bank-lock, flags);
-   bank-saved_wakeup = __raw_readl(wakeup_enable);
_gpio_rmw(base, bank-regs-wkup_en, 0x, 0);
_gpio_rmw(base, bank-regs-wkup_en, bank-context.wake_en, 1);
spin_unlock_irqrestore(bank-lock, flags);
@@ -1188,12 +1182,12 @@ static int omap_gpio_resume(struct device *dev)
if (!bank-mod_usage || !bank-loses_context)
return 0;
 
-   if (!bank-regs-wkup_en || !bank-saved_wakeup)
+   if (!bank-regs-wkup_en || !bank-context.wake_en)
return 0;
 
spin_lock_irqsave(bank-lock, flags);
_gpio_rmw(base, bank-regs-wkup_en, 0x, 0);
-   _gpio_rmw(base, bank-regs-wkup_en, bank-saved_wakeup, 1);
+   _gpio_rmw(base, bank-regs-wkup_en, bank-context.wake_en, 1);
spin_unlock_irqrestore(bank-lock, flags);
 
return 0;
-- 
1.7.0.4

--
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 2/8] gpio/omap: remove saved_fallingdetect, saved_risingdetect

2012-04-27 Thread Tarun Kanti DebBarma
Since we already have context.fallingdetect and context.risingdetect
there is no more need to have these additional fields. Also, getting
rid of extra reads associated with them.

Cc: Kevin Hilman khil...@ti.com
Cc: Tony Lindgren t...@atomide.com
Cc: Santosh Shilimkar santosh.shilim...@ti.com
Cc: Cousson, Benoit b-cous...@ti.com
Cc: Grant Likely grant.lik...@secretlab.ca
Signed-off-by: Tarun Kanti DebBarma tarun.ka...@ti.com
Reviewed-by: Santosh Shilimkar santosh.shilim...@ti.com
Acked-by: Felipe Balbi ba...@ti.com
---
 drivers/gpio/gpio-omap.c |   19 ---
 1 files changed, 8 insertions(+), 11 deletions(-)

diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
index 1adc2ec..1751f89 100644
--- a/drivers/gpio/gpio-omap.c
+++ b/drivers/gpio/gpio-omap.c
@@ -63,8 +63,6 @@ struct gpio_bank {
u32 enabled_non_wakeup_gpios;
struct gpio_regs context;
u32 saved_datain;
-   u32 saved_fallingdetect;
-   u32 saved_risingdetect;
u32 level_mask;
u32 toggle_mask;
spinlock_t lock;
@@ -1247,11 +1245,9 @@ static int omap_gpio_runtime_suspend(struct device *dev)
 */
bank-saved_datain = __raw_readl(bank-base +
bank-regs-datain);
-   l1 = __raw_readl(bank-base + bank-regs-fallingdetect);
-   l2 = __raw_readl(bank-base + bank-regs-risingdetect);
+   l1 = bank-context.fallingdetect;
+   l2 = bank-context.risingdetect;
 
-   bank-saved_fallingdetect = l1;
-   bank-saved_risingdetect = l2;
l1 = ~bank-enabled_non_wakeup_gpios;
l2 = ~bank-enabled_non_wakeup_gpios;
 
@@ -1310,9 +1306,9 @@ static int omap_gpio_runtime_resume(struct device *dev)
}
}
 
-   __raw_writel(bank-saved_fallingdetect,
+   __raw_writel(bank-context.fallingdetect,
bank-base + bank-regs-fallingdetect);
-   __raw_writel(bank-saved_risingdetect,
+   __raw_writel(bank-context.risingdetect,
bank-base + bank-regs-risingdetect);
l = __raw_readl(bank-base + bank-regs-datain);
 
@@ -1329,14 +1325,15 @@ static int omap_gpio_runtime_resume(struct device *dev)
 * No need to generate IRQs for the rising edge for gpio IRQs
 * configured with falling edge only; and vice versa.
 */
-   gen0 = l  bank-saved_fallingdetect;
+   gen0 = l  bank-context.fallingdetect;
gen0 = bank-saved_datain;
 
-   gen1 = l  bank-saved_risingdetect;
+   gen1 = l  bank-context.risingdetect;
gen1 = ~(bank-saved_datain);
 
/* FIXME: Consider GPIO IRQs with level detections properly! */
-   gen = l  (~(bank-saved_fallingdetect)  ~(bank-saved_risingdetect));
+   gen = l  (~(bank-context.fallingdetect) 
+~(bank-context.risingdetect));
/* Consider all GPIO IRQs needed to be updated */
gen |= gen0 | gen1;
 
-- 
1.7.0.4

--
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 v2 3/4] ARM: OMAP2+: dmtimer: cleanup iclk usage

2012-04-20 Thread Tarun Kanti DebBarma
We do not use iclk anywhere in the dmtimer driver and so removing it.
Hence removing the timer iclk entries from OMAP4 clkdev table as well.

Cc: Cousson, Benoit b-cous...@ti.com
Cc: Paul Walmsley p...@pwsan.com
Cc: Tony Lindgren t...@atomide.com
Cc: Kevin Hilman khil...@ti.com
Cc: Rajendra Nayak rna...@ti.com
Cc: Santosh Shilimkar santosh.shilim...@ti.com

Signed-off-by: Tarun Kanti DebBarma tarun.ka...@ti.com
---
 arch/arm/mach-omap2/clock44xx_data.c  |   11 ---
 arch/arm/mach-omap2/timer.c   |7 ---
 arch/arm/plat-omap/include/plat/dmtimer.h |2 +-
 3 files changed, 1 insertions(+), 19 deletions(-)

diff --git a/arch/arm/mach-omap2/clock44xx_data.c 
b/arch/arm/mach-omap2/clock44xx_data.c
index fa6ea65..2172f66 100644
--- a/arch/arm/mach-omap2/clock44xx_data.c
+++ b/arch/arm/mach-omap2/clock44xx_data.c
@@ -3355,17 +3355,6 @@ static struct omap_clk omap44xx_clks[] = {
CLK(NULL,   auxclk5_ck,   auxclk5_ck,
CK_443X),
CLK(NULL,   auxclkreq5_ck,auxclkreq5_ck, 
CK_443X),
CLK(NULL,   gpmc_ck,  dummy_ck,  
CK_443X),
-   CLK(NULL,   gpt1_ick, dummy_ck,  
CK_443X),
-   CLK(NULL,   gpt2_ick, dummy_ck,  
CK_443X),
-   CLK(NULL,   gpt3_ick, dummy_ck,  
CK_443X),
-   CLK(NULL,   gpt4_ick, dummy_ck,  
CK_443X),
-   CLK(NULL,   gpt5_ick, dummy_ck,  
CK_443X),
-   CLK(NULL,   gpt6_ick, dummy_ck,  
CK_443X),
-   CLK(NULL,   gpt7_ick, dummy_ck,  
CK_443X),
-   CLK(NULL,   gpt8_ick, dummy_ck,  
CK_443X),
-   CLK(NULL,   gpt9_ick, dummy_ck,  
CK_443X),
-   CLK(NULL,   gpt10_ick,dummy_ck,  
CK_443X),
-   CLK(NULL,   gpt11_ick,dummy_ck,  
CK_443X),
CLK(omap_i2c.1,   ick,  dummy_ck,  
CK_443X),
CLK(omap_i2c.2,   ick,  dummy_ck,  
CK_443X),
CLK(omap_i2c.3,   ick,  dummy_ck,  
CK_443X),
diff --git a/arch/arm/mach-omap2/timer.c b/arch/arm/mach-omap2/timer.c
index c512bac..5d7a0ee 100644
--- a/arch/arm/mach-omap2/timer.c
+++ b/arch/arm/mach-omap2/timer.c
@@ -169,13 +169,6 @@ static int __init omap_dm_timer_init_one(struct 
omap_dm_timer *timer,
if (IS_ERR(timer-fclk))
return -ENODEV;
 
-   sprintf(name, gpt%d_ick, gptimer_id);
-   timer-iclk = clk_get(NULL, name);
-   if (IS_ERR(timer-iclk)) {
-   clk_put(timer-fclk);
-   return -ENODEV;
-   }
-
omap_hwmod_enable(oh);
 
sys_timer_reserved |= (1  (gptimer_id - 1));
diff --git a/arch/arm/plat-omap/include/plat/dmtimer.h 
b/arch/arm/plat-omap/include/plat/dmtimer.h
index 9418f00..be2b8c4 100644
--- a/arch/arm/plat-omap/include/plat/dmtimer.h
+++ b/arch/arm/plat-omap/include/plat/dmtimer.h
@@ -259,7 +259,7 @@ struct omap_dm_timer {
unsigned long phys_base;
int id;
int irq;
-   struct clk *iclk, *fclk;
+   struct clk *fclk;
 
void __iomem*io_base;
void __iomem*sys_stat;  /* TISTAT timer status */
-- 
1.7.0.4

--
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 v2 4/4] ARM: OMAP2+: dmtimer: cleanup fclk usage

2012-04-20 Thread Tarun Kanti DebBarma
With omap_hwmod_get_main_clk() now available, this can be passed to
clk_get() to extract the fclk and thus avoid construction of fclk name.
Corrected the timer fck name mis-match between clock44xx_data.c and
omap_hwmod_44xx_data.c. For other platforms this is already taken care.

Cc: Cousson, Benoit b-cous...@ti.com
Cc: Paul Walmsley p...@pwsan.com
Cc: Tony Lindgren t...@atomide.com
Cc: Kevin Hilman khil...@ti.com
Cc: Rajendra Nayak rna...@ti.com
Cc: Santosh Shilimkar santosh.shilim...@ti.com

Signed-off-by: Tarun Kanti DebBarma tarun.ka...@ti.com
---
 arch/arm/mach-omap2/clock44xx_data.c |   22 +++---
 arch/arm/mach-omap2/timer.c  |3 +--
 2 files changed, 12 insertions(+), 13 deletions(-)

diff --git a/arch/arm/mach-omap2/clock44xx_data.c 
b/arch/arm/mach-omap2/clock44xx_data.c
index 2172f66..17f3bcd 100644
--- a/arch/arm/mach-omap2/clock44xx_data.c
+++ b/arch/arm/mach-omap2/clock44xx_data.c
@@ -3294,17 +3294,17 @@ static struct omap_clk omap44xx_clks[] = {
CLK(NULL,   smartreflex_core_fck, smartreflex_core_fck,  
CK_443X),
CLK(NULL,   smartreflex_iva_fck,  smartreflex_iva_fck,   
CK_443X),
CLK(NULL,   smartreflex_mpu_fck,  smartreflex_mpu_fck,   
CK_443X),
-   CLK(NULL,   gpt1_fck, timer1_fck,
CK_443X),
-   CLK(NULL,   gpt10_fck,timer10_fck,   
CK_443X),
-   CLK(NULL,   gpt11_fck,timer11_fck,   
CK_443X),
-   CLK(NULL,   gpt2_fck, timer2_fck,
CK_443X),
-   CLK(NULL,   gpt3_fck, timer3_fck,
CK_443X),
-   CLK(NULL,   gpt4_fck, timer4_fck,
CK_443X),
-   CLK(NULL,   gpt5_fck, timer5_fck,
CK_443X),
-   CLK(NULL,   gpt6_fck, timer6_fck,
CK_443X),
-   CLK(NULL,   gpt7_fck, timer7_fck,
CK_443X),
-   CLK(NULL,   gpt8_fck, timer8_fck,
CK_443X),
-   CLK(NULL,   gpt9_fck, timer9_fck,
CK_443X),
+   CLK(NULL,   timer1_fck,   timer1_fck,
CK_443X),
+   CLK(NULL,   timer10_fck,  timer10_fck,   
CK_443X),
+   CLK(NULL,   timer11_fck,  timer11_fck,   
CK_443X),
+   CLK(NULL,   timer2_fck,   timer2_fck,
CK_443X),
+   CLK(NULL,   timer3_fck,   timer3_fck,
CK_443X),
+   CLK(NULL,   timer4_fck,   timer4_fck,
CK_443X),
+   CLK(NULL,   timer5_fck,   timer5_fck,
CK_443X),
+   CLK(NULL,   timer6_fck,   timer6_fck,
CK_443X),
+   CLK(NULL,   timer7_fck,   timer7_fck,
CK_443X),
+   CLK(NULL,   timer8_fck,   timer8_fck,
CK_443X),
+   CLK(NULL,   timer9_fck,   timer9_fck,
CK_443X),
CLK(NULL,   uart1_fck,uart1_fck, 
CK_443X),
CLK(NULL,   uart2_fck,uart2_fck, 
CK_443X),
CLK(NULL,   uart3_fck,uart3_fck, 
CK_443X),
diff --git a/arch/arm/mach-omap2/timer.c b/arch/arm/mach-omap2/timer.c
index 5d7a0ee..80c9667 100644
--- a/arch/arm/mach-omap2/timer.c
+++ b/arch/arm/mach-omap2/timer.c
@@ -164,8 +164,7 @@ static int __init omap_dm_timer_init_one(struct 
omap_dm_timer *timer,
return -ENXIO;
 
/* After the dmtimer is using hwmod these clocks won't be needed */
-   sprintf(name, gpt%d_fck, gptimer_id);
-   timer-fclk = clk_get(NULL, name);
+   timer-fclk = clk_get(NULL, omap_hwmod_get_main_clk(oh));
if (IS_ERR(timer-fclk))
return -ENODEV;
 
-- 
1.7.0.4

--
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 v2 0/4] ARM: OMAP2+: dmtimer: cleanup related to devm API and clk usage

2012-04-20 Thread Tarun Kanti DebBarma
The devm API usage in probe() simplifies error handling operation.
Since iclk is not used in the driver it is removed from wherever
not needed.
Corrected the timer fck name mis-match between clock44xx_data.c and
omap_hwmod_44xx_data.c.
Added omap_hwmod_get_main_clk() API. There is no more need to construct
clock names using sprintf() to be used in clk_get() during initialization.

Reference:
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git
Commit: e816b57a337ea3b755de72bec38c10c864f23015 (Linux 3.4-rc3)

Series is available here for reference:
git://gitorious.org/~tarunkanti/omap-sw-develoment/tarunkantis-linux-omap-dev 
dmtimer_cleanup_for_3.5

Tested on following platforms:
OMAP5, OMAP4430SDP, OMAP3430SDP, OMAP2430SDP.
Could not test on OMAP2420 due to unavailability of board.

v2:
- Use devm_request_and_ioremap() instead of request_mem_region() and ioremap()
- Add omap_hwmod_get_main_clk() API
- Reverted changes of clock names from OMAP2 and OMAP3 platforms  

Cc: Cousson, Benoit b-cous...@ti.com
Cc: Paul Walmsley p...@pwsan.com
Cc: Tony Lindgren t...@atomide.com
Cc: Kevin Hilman khil...@ti.com
Cc: Rajendra Nayak rna...@ti.com
Cc: Santosh Shilimkar santosh.shilim...@ti.com

Tarun Kanti DebBarma (4):
  ARM: OMAP: dmtimer: use devm_ API and do some cleanup in probe()
  ARM: OMAP2+: hwmod: add omap_hwmod_get_main_clk() API
  ARM: OMAP2+: dmtimer: cleanup iclk usage
  ARM: OMAP2+: dmtimer: cleanup fclk usage

 arch/arm/mach-omap2/clock44xx_data.c |   33 ++---
 arch/arm/mach-omap2/omap_hwmod.c |   15 
 arch/arm/mach-omap2/timer.c  |   10 +-
 arch/arm/plat-omap/dmtimer.c |   51 --
 arch/arm/plat-omap/include/plat/dmtimer.h|2 +-
 arch/arm/plat-omap/include/plat/omap_hwmod.h |2 +
 6 files changed, 46 insertions(+), 67 deletions(-)

--
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 v2 1/4] ARM: OMAP: dmtimer: use devm_ API and do some cleanup in probe()

2012-04-20 Thread Tarun Kanti DebBarma
Replace the regular kzalloc and ioremap with the devm_ equivalent
to simplify error handling. We don't need kree() any more in
omap_dm_timer_remove().

Also added *dev* pointer to reference pdev-dev which makes the
usage shorter in code.

Cc: Cousson, Benoit b-cous...@ti.com
Cc: Paul Walmsley p...@pwsan.com
Cc: Tony Lindgren t...@atomide.com
Cc: Kevin Hilman khil...@ti.com
Cc: Rajendra Nayak rna...@ti.com
Cc: Santosh Shilimkar santosh.shilim...@ti.com

Signed-off-by: Tarun Kanti DebBarma tarun.ka...@ti.com
---
 arch/arm/plat-omap/dmtimer.c |   51 +
 1 files changed, 16 insertions(+), 35 deletions(-)

diff --git a/arch/arm/plat-omap/dmtimer.c b/arch/arm/plat-omap/dmtimer.c
index 652139c..8a8768b 100644
--- a/arch/arm/plat-omap/dmtimer.c
+++ b/arch/arm/plat-omap/dmtimer.c
@@ -37,7 +37,7 @@
 
 #include linux/module.h
 #include linux/io.h
-#include linux/slab.h
+#include linux/device.h
 #include linux/err.h
 #include linux/pm_runtime.h
 
@@ -628,49 +628,39 @@ EXPORT_SYMBOL_GPL(omap_dm_timers_active);
  */
 static int __devinit omap_dm_timer_probe(struct platform_device *pdev)
 {
-   int ret;
unsigned long flags;
struct omap_dm_timer *timer;
-   struct resource *mem, *irq, *ioarea;
+   struct resource *mem, *irq;
+   struct device *dev = pdev-dev;
struct dmtimer_platform_data *pdata = pdev-dev.platform_data;
 
if (!pdata) {
-   dev_err(pdev-dev, %s: no platform data.\n, __func__);
+   dev_err(dev, %s: no platform data.\n, __func__);
return -ENODEV;
}
 
irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
if (unlikely(!irq)) {
-   dev_err(pdev-dev, %s: no IRQ resource.\n, __func__);
+   dev_err(dev, %s: no IRQ resource.\n, __func__);
return -ENODEV;
}
 
mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (unlikely(!mem)) {
-   dev_err(pdev-dev, %s: no memory resource.\n, __func__);
+   dev_err(dev, %s: no memory resource.\n, __func__);
return -ENODEV;
}
 
-   ioarea = request_mem_region(mem-start, resource_size(mem),
-   pdev-name);
-   if (!ioarea) {
-   dev_err(pdev-dev, %s: region already claimed.\n, __func__);
-   return -EBUSY;
-   }
-
-   timer = kzalloc(sizeof(struct omap_dm_timer), GFP_KERNEL);
+   timer = devm_kzalloc(dev, sizeof(struct omap_dm_timer), GFP_KERNEL);
if (!timer) {
-   dev_err(pdev-dev, %s: no memory for omap_dm_timer.\n,
-   __func__);
-   ret = -ENOMEM;
-   goto err_free_ioregion;
+   dev_err(dev, %s: memory alloc failed!\n, __func__);
+   return  -ENOMEM;
}
 
-   timer-io_base = ioremap(mem-start, resource_size(mem));
+   timer-io_base = devm_request_and_ioremap(dev, mem);
if (!timer-io_base) {
-   dev_err(pdev-dev, %s: ioremap failed.\n, __func__);
-   ret = -ENOMEM;
-   goto err_free_mem;
+   dev_err(dev, %s: region already claimed.\n, __func__);
+   return -ENOMEM;
}
 
timer-id = pdev-id;
@@ -682,12 +672,12 @@ static int __devinit omap_dm_timer_probe(struct 
platform_device *pdev)
 
/* Skip pm_runtime_enable for OMAP1 */
if (!pdata-needs_manual_reset) {
-   pm_runtime_enable(pdev-dev);
-   pm_runtime_irq_safe(pdev-dev);
+   pm_runtime_enable(dev);
+   pm_runtime_irq_safe(dev);
}
 
if (!timer-reserved) {
-   pm_runtime_get_sync(pdev-dev);
+   pm_runtime_get_sync(dev);
__omap_dm_timer_init_regs(timer);
pm_runtime_put(pdev-dev);
}
@@ -697,17 +687,9 @@ static int __devinit omap_dm_timer_probe(struct 
platform_device *pdev)
list_add_tail(timer-node, omap_timer_list);
spin_unlock_irqrestore(dm_timer_lock, flags);
 
-   dev_dbg(pdev-dev, Device Probed.\n);
+   dev_dbg(dev, Device Probed.\n);
 
return 0;
-
-err_free_mem:
-   kfree(timer);
-
-err_free_ioregion:
-   release_mem_region(mem-start, resource_size(mem));
-
-   return ret;
 }
 
 /**
@@ -728,7 +710,6 @@ static int __devexit omap_dm_timer_remove(struct 
platform_device *pdev)
list_for_each_entry(timer, omap_timer_list, node)
if (timer-pdev-id == pdev-id) {
list_del(timer-node);
-   kfree(timer);
ret = 0;
break;
}
-- 
1.7.0.4

--
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 v2 2/4] ARM: OMAP2+: hwmod: add omap_hwmod_get_main_clk() API

2012-04-20 Thread Tarun Kanti DebBarma
Add an API to get main clock name associated with a given @oh.
This will avoid the need to construct fclk names during early
initialization in order to get fclk handle using clk_get().

Cc: Cousson, Benoit b-cous...@ti.com
Cc: Paul Walmsley p...@pwsan.com
Cc: Tony Lindgren t...@atomide.com
Cc: Kevin Hilman khil...@ti.com
Cc: Rajendra Nayak rna...@ti.com
Cc: Santosh Shilimkar santosh.shilim...@ti.com

Signed-off-by: Tarun Kanti DebBarma tarun.ka...@ti.com
---
 arch/arm/mach-omap2/omap_hwmod.c |   15 +++
 arch/arm/plat-omap/include/plat/omap_hwmod.h |2 ++
 2 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
index 2c27fdb..2c6214d 100644
--- a/arch/arm/mach-omap2/omap_hwmod.c
+++ b/arch/arm/mach-omap2/omap_hwmod.c
@@ -2775,3 +2775,18 @@ int omap_hwmod_pad_route_irq(struct omap_hwmod *oh, int 
pad_idx, int irq_idx)
 
return 0;
 }
+
+/**
+ * omap_hwmod_get_main_clk - get pointer to main clock name
+ * @oh: struct omap_hwmod *
+ *
+ * Returns the main clock name assocated with @oh upon success,
+ * or NULL if @oh is NULL.
+ */
+const char *omap_hwmod_get_main_clk(struct omap_hwmod *oh)
+{
+   if (!oh)
+   return NULL;
+
+   return oh-main_clk;
+}
diff --git a/arch/arm/plat-omap/include/plat/omap_hwmod.h 
b/arch/arm/plat-omap/include/plat/omap_hwmod.h
index 8070145..f3c0697 100644
--- a/arch/arm/plat-omap/include/plat/omap_hwmod.h
+++ b/arch/arm/plat-omap/include/plat/omap_hwmod.h
@@ -608,6 +608,8 @@ int omap_hwmod_no_setup_reset(struct omap_hwmod *oh);
 
 int omap_hwmod_pad_route_irq(struct omap_hwmod *oh, int pad_idx, int irq_idx);
 
+const char *omap_hwmod_get_main_clk(struct omap_hwmod *oh);
+
 /*
  * Chip variant-specific hwmod init routines - XXX should be converted
  * to use initcalls once the initial boot ordering is straightened out
-- 
1.7.0.4

--
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 3/3] ARM: OMAP2+: dmtimer: cleanup fclk usage

2012-04-16 Thread Tarun Kanti DebBarma
Timer clock nodes have been re-named as timer1_fck, timer2_fck, ...
in place of gpt1_fck, gpt2_fck, ... This is in line with the names
present in OMAP4 gptimer hwmod database assigned to oh-main_clk.
Now we can get the fck name directly from oh-main_clk and pass the
same to clk_get() to extract the fclk and thus avoid construction
of fclk clock name.

Signed-off-by: Tarun Kanti DebBarma tarun.ka...@ti.com
---
 arch/arm/mach-omap2/clock2420_data.c   |   72 ++--
 arch/arm/mach-omap2/clock2430_data.c   |   72 ++--
 arch/arm/mach-omap2/clock3xxx_data.c   |   72 ++--
 arch/arm/mach-omap2/clock44xx_data.c   |   22 
 arch/arm/mach-omap2/omap_hwmod_2420_data.c |   24 +-
 arch/arm/mach-omap2/omap_hwmod_2430_data.c |   24 +-
 arch/arm/mach-omap2/omap_hwmod_3xxx_data.c |   24 +-
 arch/arm/mach-omap2/timer.c|3 +-
 8 files changed, 156 insertions(+), 157 deletions(-)

diff --git a/arch/arm/mach-omap2/clock2420_data.c 
b/arch/arm/mach-omap2/clock2420_data.c
index bace930..8d12e8e 100644
--- a/arch/arm/mach-omap2/clock2420_data.c
+++ b/arch/arm/mach-omap2/clock2420_data.c
@@ -847,8 +847,8 @@ static struct clk gpt1_ick = {
.recalc = followparent_recalc,
 };
 
-static struct clk gpt1_fck = {
-   .name   = gpt1_fck,
+static struct clk timer1_fck = {
+   .name   = timer1_fck,
.ops= clkops_omap2_dflt_wait,
.parent = func_32k_ck,
.clkdm_name = core_l4_clkdm,
@@ -873,8 +873,8 @@ static struct clk gpt2_ick = {
.recalc = followparent_recalc,
 };
 
-static struct clk gpt2_fck = {
-   .name   = gpt2_fck,
+static struct clk timer2_fck = {
+   .name   = timer2_fck,
.ops= clkops_omap2_dflt_wait,
.parent = func_32k_ck,
.clkdm_name = core_l4_clkdm,
@@ -897,8 +897,8 @@ static struct clk gpt3_ick = {
.recalc = followparent_recalc,
 };
 
-static struct clk gpt3_fck = {
-   .name   = gpt3_fck,
+static struct clk timer3_fck = {
+   .name   = timer3_fck,
.ops= clkops_omap2_dflt_wait,
.parent = func_32k_ck,
.clkdm_name = core_l4_clkdm,
@@ -921,8 +921,8 @@ static struct clk gpt4_ick = {
.recalc = followparent_recalc,
 };
 
-static struct clk gpt4_fck = {
-   .name   = gpt4_fck,
+static struct clk timer4_fck = {
+   .name   = timer4_fck,
.ops= clkops_omap2_dflt_wait,
.parent = func_32k_ck,
.clkdm_name = core_l4_clkdm,
@@ -945,8 +945,8 @@ static struct clk gpt5_ick = {
.recalc = followparent_recalc,
 };
 
-static struct clk gpt5_fck = {
-   .name   = gpt5_fck,
+static struct clk timer5_fck = {
+   .name   = timer5_fck,
.ops= clkops_omap2_dflt_wait,
.parent = func_32k_ck,
.clkdm_name = core_l4_clkdm,
@@ -969,8 +969,8 @@ static struct clk gpt6_ick = {
.recalc = followparent_recalc,
 };
 
-static struct clk gpt6_fck = {
-   .name   = gpt6_fck,
+static struct clk timer6_fck = {
+   .name   = timer6_fck,
.ops= clkops_omap2_dflt_wait,
.parent = func_32k_ck,
.clkdm_name = core_l4_clkdm,
@@ -993,8 +993,8 @@ static struct clk gpt7_ick = {
.recalc = followparent_recalc,
 };
 
-static struct clk gpt7_fck = {
-   .name   = gpt7_fck,
+static struct clk timer7_fck = {
+   .name   = timer7_fck,
.ops= clkops_omap2_dflt_wait,
.parent = func_32k_ck,
.clkdm_name = core_l4_clkdm,
@@ -1017,8 +1017,8 @@ static struct clk gpt8_ick = {
.recalc = followparent_recalc,
 };
 
-static struct clk gpt8_fck = {
-   .name   = gpt8_fck,
+static struct clk timer8_fck = {
+   .name   = timer8_fck,
.ops= clkops_omap2_dflt_wait,
.parent = func_32k_ck,
.clkdm_name = core_l4_clkdm,
@@ -1041,8 +1041,8 @@ static struct clk gpt9_ick = {
.recalc = followparent_recalc,
 };
 
-static struct clk gpt9_fck = {
-   .name   = gpt9_fck,
+static struct clk timer9_fck = {
+   .name   = timer9_fck,
.ops= clkops_omap2_dflt_wait,
.parent = func_32k_ck,
.clkdm_name = core_l4_clkdm,
@@ -1065,8 +1065,8 @@ static struct clk gpt10_ick = {
.recalc = followparent_recalc,
 };
 
-static struct clk gpt10_fck = {
-   .name   = gpt10_fck,
+static struct clk timer10_fck = {
+   .name   = timer10_fck,
.ops= clkops_omap2_dflt_wait,
.parent = func_32k_ck,
.clkdm_name = core_l4_clkdm,
@@ -1089,8 +1089,8 @@ static

[PATCH 2/3] ARM: OMAP2+: dmtimer: cleanup iclk usage

2012-04-16 Thread Tarun Kanti DebBarma
We do not use iclk anywhere in the dmtimer driver and so removing it.
Hence removing the timer iclk entries from OMAP4 clkdev table as well.

Signed-off-by: Tarun Kanti DebBarma tarun.ka...@ti.com
---
 arch/arm/mach-omap2/clock44xx_data.c  |   11 ---
 arch/arm/mach-omap2/timer.c   |7 ---
 arch/arm/plat-omap/include/plat/dmtimer.h |2 +-
 3 files changed, 1 insertions(+), 19 deletions(-)

diff --git a/arch/arm/mach-omap2/clock44xx_data.c 
b/arch/arm/mach-omap2/clock44xx_data.c
index fa6ea65..2172f66 100644
--- a/arch/arm/mach-omap2/clock44xx_data.c
+++ b/arch/arm/mach-omap2/clock44xx_data.c
@@ -3355,17 +3355,6 @@ static struct omap_clk omap44xx_clks[] = {
CLK(NULL,   auxclk5_ck,   auxclk5_ck,
CK_443X),
CLK(NULL,   auxclkreq5_ck,auxclkreq5_ck, 
CK_443X),
CLK(NULL,   gpmc_ck,  dummy_ck,  
CK_443X),
-   CLK(NULL,   gpt1_ick, dummy_ck,  
CK_443X),
-   CLK(NULL,   gpt2_ick, dummy_ck,  
CK_443X),
-   CLK(NULL,   gpt3_ick, dummy_ck,  
CK_443X),
-   CLK(NULL,   gpt4_ick, dummy_ck,  
CK_443X),
-   CLK(NULL,   gpt5_ick, dummy_ck,  
CK_443X),
-   CLK(NULL,   gpt6_ick, dummy_ck,  
CK_443X),
-   CLK(NULL,   gpt7_ick, dummy_ck,  
CK_443X),
-   CLK(NULL,   gpt8_ick, dummy_ck,  
CK_443X),
-   CLK(NULL,   gpt9_ick, dummy_ck,  
CK_443X),
-   CLK(NULL,   gpt10_ick,dummy_ck,  
CK_443X),
-   CLK(NULL,   gpt11_ick,dummy_ck,  
CK_443X),
CLK(omap_i2c.1,   ick,  dummy_ck,  
CK_443X),
CLK(omap_i2c.2,   ick,  dummy_ck,  
CK_443X),
CLK(omap_i2c.3,   ick,  dummy_ck,  
CK_443X),
diff --git a/arch/arm/mach-omap2/timer.c b/arch/arm/mach-omap2/timer.c
index c512bac..5d7a0ee 100644
--- a/arch/arm/mach-omap2/timer.c
+++ b/arch/arm/mach-omap2/timer.c
@@ -169,13 +169,6 @@ static int __init omap_dm_timer_init_one(struct 
omap_dm_timer *timer,
if (IS_ERR(timer-fclk))
return -ENODEV;
 
-   sprintf(name, gpt%d_ick, gptimer_id);
-   timer-iclk = clk_get(NULL, name);
-   if (IS_ERR(timer-iclk)) {
-   clk_put(timer-fclk);
-   return -ENODEV;
-   }
-
omap_hwmod_enable(oh);
 
sys_timer_reserved |= (1  (gptimer_id - 1));
diff --git a/arch/arm/plat-omap/include/plat/dmtimer.h 
b/arch/arm/plat-omap/include/plat/dmtimer.h
index 9418f00..be2b8c4 100644
--- a/arch/arm/plat-omap/include/plat/dmtimer.h
+++ b/arch/arm/plat-omap/include/plat/dmtimer.h
@@ -259,7 +259,7 @@ struct omap_dm_timer {
unsigned long phys_base;
int id;
int irq;
-   struct clk *iclk, *fclk;
+   struct clk *fclk;
 
void __iomem*io_base;
void __iomem*sys_stat;  /* TISTAT timer status */
-- 
1.7.0.4

--
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 0/3] ARM: OMAP2+: dmtimer: cleanup related to devm API and clk usage

2012-04-16 Thread Tarun Kanti DebBarma
The devm API usage in probe() simplifies error handling operation.
Since iclk is not used in the driver it is removed from wherever
not needed. The fclk naming is made uniform as per OMAP4 platform,
viz. timer1_fck, timer2_fck, ... in all relevant places which
include hwmod database. With this change there is no more need to
construct clock names using sprintf() to be used in clk_get()
during initialization. Instead we can use oh-main_clk directly.

Reference:
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git
Commit: e816b57a337ea3b755de72bec38c10c864f23015 (Linux 3.4-rc3)

Series is available here for reference:
git://gitorious.org/~tarunkanti/omap-sw-develoment/tarunkantis-linux-omap-dev 
dmtimer_cleanup_for_3.5

Tested on following platforms:
OMAP4430SDP, OMAP3430SDP, OMAP2430SDP.
Could not test on OMAP2420 due to unavailability of board.

Tarun Kanti DebBarma (3):
  ARM: OMAP: dmtimer: Use devm_ API and do some cleanup in probe()
  ARM: OMAP2+: dmtimer: cleanup iclk usage
  ARM: OMAP2+: dmtimer: cleanup fclk usage

 arch/arm/mach-omap2/clock2420_data.c   |   72 ++--
 arch/arm/mach-omap2/clock2430_data.c   |   72 ++--
 arch/arm/mach-omap2/clock3xxx_data.c   |   72 ++--
 arch/arm/mach-omap2/clock44xx_data.c   |   33 
 arch/arm/mach-omap2/omap_hwmod_2420_data.c |   24 +-
 arch/arm/mach-omap2/omap_hwmod_2430_data.c |   24 +-
 arch/arm/mach-omap2/omap_hwmod_3xxx_data.c |   24 +-
 arch/arm/mach-omap2/timer.c|   10 +
 arch/arm/plat-omap/dmtimer.c   |   51 +++
 arch/arm/plat-omap/include/plat/dmtimer.h  |2 +-
 10 files changed, 176 insertions(+), 208 deletions(-)

--
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 1/3] ARM: OMAP: dmtimer: Use devm_ API and do some cleanup in probe()

2012-04-16 Thread Tarun Kanti DebBarma
Replace the regular kzalloc and ioremap with the devm_ equivalent
to simplify error handling. We don't need kree() anymore in
omap_dm_timer_remove().

Also added *dev* pointer to reference pdev-dev which makes the
usage shorter in code.

Signed-off-by: Tarun Kanti DebBarma tarun.ka...@ti.com
---
 arch/arm/plat-omap/dmtimer.c |   51 +++--
 1 files changed, 19 insertions(+), 32 deletions(-)

diff --git a/arch/arm/plat-omap/dmtimer.c b/arch/arm/plat-omap/dmtimer.c
index 652139c..549a811 100644
--- a/arch/arm/plat-omap/dmtimer.c
+++ b/arch/arm/plat-omap/dmtimer.c
@@ -37,7 +37,7 @@
 
 #include linux/module.h
 #include linux/io.h
-#include linux/slab.h
+#include linux/device.h
 #include linux/err.h
 #include linux/pm_runtime.h
 
@@ -628,49 +628,45 @@ EXPORT_SYMBOL_GPL(omap_dm_timers_active);
  */
 static int __devinit omap_dm_timer_probe(struct platform_device *pdev)
 {
-   int ret;
unsigned long flags;
struct omap_dm_timer *timer;
-   struct resource *mem, *irq, *ioarea;
+   struct resource *mem, *irq;
+   struct device *dev = pdev-dev;
struct dmtimer_platform_data *pdata = pdev-dev.platform_data;
 
if (!pdata) {
-   dev_err(pdev-dev, %s: no platform data.\n, __func__);
+   dev_err(dev, %s: no platform data.\n, __func__);
return -ENODEV;
}
 
irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
if (unlikely(!irq)) {
-   dev_err(pdev-dev, %s: no IRQ resource.\n, __func__);
+   dev_err(dev, %s: no IRQ resource.\n, __func__);
return -ENODEV;
}
 
mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (unlikely(!mem)) {
-   dev_err(pdev-dev, %s: no memory resource.\n, __func__);
+   dev_err(dev, %s: no memory resource.\n, __func__);
return -ENODEV;
}
 
-   ioarea = request_mem_region(mem-start, resource_size(mem),
-   pdev-name);
-   if (!ioarea) {
-   dev_err(pdev-dev, %s: region already claimed.\n, __func__);
+   if (!devm_request_mem_region(dev, mem-start, resource_size(mem),
+   pdev-name)) {
+   dev_err(dev, %s: region already claimed.\n, __func__);
return -EBUSY;
}
 
-   timer = kzalloc(sizeof(struct omap_dm_timer), GFP_KERNEL);
+   timer = devm_kzalloc(dev, sizeof(struct omap_dm_timer), GFP_KERNEL);
if (!timer) {
-   dev_err(pdev-dev, %s: no memory for omap_dm_timer.\n,
-   __func__);
-   ret = -ENOMEM;
-   goto err_free_ioregion;
+   dev_err(dev, %s: memory alloc failed!\n, __func__);
+   return  -ENOMEM;
}
 
-   timer-io_base = ioremap(mem-start, resource_size(mem));
+   timer-io_base = devm_ioremap(dev, mem-start, resource_size(mem));
if (!timer-io_base) {
-   dev_err(pdev-dev, %s: ioremap failed.\n, __func__);
-   ret = -ENOMEM;
-   goto err_free_mem;
+   dev_err(dev, %s: ioremap failed.\n, __func__);
+   return -ENOMEM;
}
 
timer-id = pdev-id;
@@ -682,12 +678,12 @@ static int __devinit omap_dm_timer_probe(struct 
platform_device *pdev)
 
/* Skip pm_runtime_enable for OMAP1 */
if (!pdata-needs_manual_reset) {
-   pm_runtime_enable(pdev-dev);
-   pm_runtime_irq_safe(pdev-dev);
+   pm_runtime_enable(dev);
+   pm_runtime_irq_safe(dev);
}
 
if (!timer-reserved) {
-   pm_runtime_get_sync(pdev-dev);
+   pm_runtime_get_sync(dev);
__omap_dm_timer_init_regs(timer);
pm_runtime_put(pdev-dev);
}
@@ -697,17 +693,9 @@ static int __devinit omap_dm_timer_probe(struct 
platform_device *pdev)
list_add_tail(timer-node, omap_timer_list);
spin_unlock_irqrestore(dm_timer_lock, flags);
 
-   dev_dbg(pdev-dev, Device Probed.\n);
+   dev_dbg(dev, Device Probed.\n);
 
return 0;
-
-err_free_mem:
-   kfree(timer);
-
-err_free_ioregion:
-   release_mem_region(mem-start, resource_size(mem));
-
-   return ret;
 }
 
 /**
@@ -728,7 +716,6 @@ static int __devexit omap_dm_timer_remove(struct 
platform_device *pdev)
list_for_each_entry(timer, omap_timer_list, node)
if (timer-pdev-id == pdev-id) {
list_del(timer-node);
-   kfree(timer);
ret = 0;
break;
}
-- 
1.7.0.4

--
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 v2] ARM: OMAP2+: dmtimer: remove redundant sysconfig context restore

2012-04-12 Thread Tarun Kanti DebBarma
Since hwmod framework now manages sysconfig context save/restore
there is no more need to touch this register in driver. Hence,
remove restore of sysconfig register in omap_timer_restore_context.
This was causing incorrect context restore of sysconfig register.

Signed-off-by: Tarun Kanti DebBarma tarun.ka...@ti.com
---
v2: removed tiocp_cfg from struct timer_regs {}

 arch/arm/plat-omap/dmtimer.c  |2 --
 arch/arm/plat-omap/include/plat/dmtimer.h |1 -
 2 files changed, 0 insertions(+), 3 deletions(-)

diff --git a/arch/arm/plat-omap/dmtimer.c b/arch/arm/plat-omap/dmtimer.c
index 652139c..15e7882 100644
--- a/arch/arm/plat-omap/dmtimer.c
+++ b/arch/arm/plat-omap/dmtimer.c
@@ -82,8 +82,6 @@ static void omap_dm_timer_write_reg(struct omap_dm_timer 
*timer, u32 reg,
 
 static void omap_timer_restore_context(struct omap_dm_timer *timer)
 {
-   __raw_writel(timer-context.tiocp_cfg,
-   timer-io_base + OMAP_TIMER_OCP_CFG_OFFSET);
if (timer-revision == 1)
__raw_writel(timer-context.tistat, timer-sys_stat);
 
diff --git a/arch/arm/plat-omap/include/plat/dmtimer.h 
b/arch/arm/plat-omap/include/plat/dmtimer.h
index 9418f00..a4c08d0 100644
--- a/arch/arm/plat-omap/include/plat/dmtimer.h
+++ b/arch/arm/plat-omap/include/plat/dmtimer.h
@@ -75,7 +75,6 @@ struct clk;
 
 struct timer_regs {
u32 tidr;
-   u32 tiocp_cfg;
u32 tistat;
u32 tisr;
u32 tier;
-- 
1.7.0.4

--
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] ARM: OMAP2+: remove redundant sysconfig context restore

2012-04-11 Thread Tarun Kanti DebBarma
Since hwmod framework now manages sysconfig context save/restore
there is no more need to touch this register in driver. Hence,
remove restore of sysconfig register in omap_timer_restore_context.
This was causing incorrect context restore of sysconfig register.

Signed-off-by: Tarun Kanti DebBarma tarun.ka...@ti.com
---
 arch/arm/plat-omap/dmtimer.c |2 --
 1 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/arch/arm/plat-omap/dmtimer.c b/arch/arm/plat-omap/dmtimer.c
index 652139c..15e7882 100644
--- a/arch/arm/plat-omap/dmtimer.c
+++ b/arch/arm/plat-omap/dmtimer.c
@@ -82,8 +82,6 @@ static void omap_dm_timer_write_reg(struct omap_dm_timer 
*timer, u32 reg,
 
 static void omap_timer_restore_context(struct omap_dm_timer *timer)
 {
-   __raw_writel(timer-context.tiocp_cfg,
-   timer-io_base + OMAP_TIMER_OCP_CFG_OFFSET);
if (timer-revision == 1)
__raw_writel(timer-context.tistat, timer-sys_stat);
 
-- 
1.7.0.4

--
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] ARM: OMAP2+: dmtimer: remove redundant sysconfig context restore

2012-04-11 Thread Tarun Kanti DebBarma
Since hwmod framework now manages sysconfig context save/restore
there is no more need to touch this register in driver. Hence,
remove restore of sysconfig register in omap_timer_restore_context.
This was causing incorrect context restore of sysconfig register.

Signed-off-by: Tarun Kanti DebBarma tarun.ka...@ti.com
---
Modified the $SUBJECT to include *dmtimer* as per convention.

 arch/arm/plat-omap/dmtimer.c |2 --
 1 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/arch/arm/plat-omap/dmtimer.c b/arch/arm/plat-omap/dmtimer.c
index 652139c..15e7882 100644
--- a/arch/arm/plat-omap/dmtimer.c
+++ b/arch/arm/plat-omap/dmtimer.c
@@ -82,8 +82,6 @@ static void omap_dm_timer_write_reg(struct omap_dm_timer 
*timer, u32 reg,
 
 static void omap_timer_restore_context(struct omap_dm_timer *timer)
 {
-   __raw_writel(timer-context.tiocp_cfg,
-   timer-io_base + OMAP_TIMER_OCP_CFG_OFFSET);
if (timer-revision == 1)
__raw_writel(timer-context.tistat, timer-sys_stat);
 
-- 
1.7.0.4

--
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 v3 0/4] ARM: OMAP: boards: changes to support dynamic irq alloc

2012-03-29 Thread Tarun Kanti DebBarma
These four patches incorporate changes to OMAP1 and OMAP2 platforms
board files whereby older references to OMAP_GPIO_IRQ macro are
now replaced with gpio_to_irq(), thereby getting rid of static
irq references.

Reference: git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc.git omap/dt
Commit: fde7d9049e55ab85a390be7f415d74c9f62dd0f9

Test info:
OMAP1 Platforms:
Boot test on OMAP1710 H3.

OMAP2PLUS Platforms:
Boot test on OMAP2430SDP, OMAP3430SDP, OMAP3630-ZOOM3, OMAP4430-SDP.

v3:
Avoid accessing devices using device array index. Consider following list:

static struct platform_device *h2_devices[] __initdata = {
h2_nor_device,
h2_nand_device,
h2_smc91x_device,
h2_irda_device,
h2_kp_device,
h2_lcd_device,
};

static void __init h2_init(void)
{
[...]
   h2_devices[2]-resource[1].start = gpio_to_irq(0);
   h2_devices[2]-resource[1].end = gpio_to_irq(0);
[...]
}

The above implementation is immune to failure if someone inserts new device
in the list before h2_smc91x_device. In order to avoid such a problem access
the devices directly like this:

   h2_smc91x_resources[1].start = gpio_to_irq(0);
   h2_smc91x_resources[1].end = gpio_to_irq(0);

Similar change incorporated for all the boards wherever applicable.

v2:
- Modified the patch subjects as per convention.
- Added a new patch to remove OMAP_GPIO_IRQ from ams_delta_serio driver.
- Added a new patch to remove OMAP_GPIO_IRQ macro definition.

Tarun Kanti DebBarma (4):
  ARM: OMAP1: boards: Fix OMAP_GPIO_IRQ usage with gpio_to_irq()
  ARM: OMAP2+: boards: Fix OMAP_GPIO_IRQ usage with gpio_to_irq()
  drivers: input: Fix OMAP_GPIO_IRQ with gpio_to_irq() in
ams_delta_serio_exit()
  ARM: OMAP: Remove OMAP_GPIO_IRQ macro definition

 arch/arm/mach-omap1/board-h2.c   |8 
 arch/arm/mach-omap1/board-h3.c   |9 -
 arch/arm/mach-omap1/board-htcherald.c|6 +++---
 arch/arm/mach-omap1/board-innovator.c|4 ++--
 arch/arm/mach-omap1/board-nokia770.c |2 +-
 arch/arm/mach-omap1/board-osk.c  |   12 ++--
 arch/arm/mach-omap1/board-palmte.c   |2 +-
 arch/arm/mach-omap1/board-palmtt.c   |2 +-
 arch/arm/mach-omap1/board-palmz71.c  |2 +-
 arch/arm/mach-omap1/board-voiceblue.c|   16 +++-
 arch/arm/mach-omap2/board-2430sdp.c  |2 +-
 arch/arm/mach-omap2/board-4430sdp.c  |2 +-
 arch/arm/mach-omap2/board-apollon.c  |4 ++--
 arch/arm/mach-omap2/board-devkit8000.c   |2 +-
 arch/arm/mach-omap2/board-h4.c   |2 +-
 arch/arm/mach-omap2/board-omap3evm.c |2 +-
 arch/arm/mach-omap2/board-omap4panda.c   |2 +-
 arch/arm/mach-omap2/board-rx51-peripherals.c |3 ++-
 arch/arm/mach-omap2/board-zoom-debugboard.c  |3 ++-
 arch/arm/mach-omap2/board-zoom-peripherals.c |6 --
 arch/arm/mach-omap2/common-board-devices.c   |2 +-
 arch/arm/plat-omap/include/plat/gpio.h   |4 
 drivers/input/serio/ams_delta_serio.c|2 +-
 23 files changed, 48 insertions(+), 51 deletions(-)

--
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 v3 4/4] ARM: OMAP: Remove OMAP_GPIO_IRQ macro definition

2012-03-29 Thread Tarun Kanti DebBarma
Since all references to OMAP_GPIO_IRQ macro are replaced now
with gpio_to_irq(), this can be removed altogether.

Signed-off-by: Tarun Kanti DebBarma tarun.ka...@ti.com
---
 arch/arm/plat-omap/include/plat/gpio.h |4 
 1 files changed, 0 insertions(+), 4 deletions(-)

diff --git a/arch/arm/plat-omap/include/plat/gpio.h 
b/arch/arm/plat-omap/include/plat/gpio.h
index 9e86ee0..d4df414 100644
--- a/arch/arm/plat-omap/include/plat/gpio.h
+++ b/arch/arm/plat-omap/include/plat/gpio.h
@@ -158,10 +158,6 @@
 #define OMAP_MPUIO(nr) (OMAP_MAX_GPIO_LINES + (nr))
 #define OMAP_GPIO_IS_MPUIO(nr) ((nr) = OMAP_MAX_GPIO_LINES)
 
-#define OMAP_GPIO_IRQ(nr)  (OMAP_GPIO_IS_MPUIO(nr) ? \
-IH_MPUIO_BASE + ((nr)  0x0f) : \
-IH_GPIO_BASE + (nr))
-
 #define METHOD_MPUIO   0
 #define METHOD_GPIO_1510   1
 #define METHOD_GPIO_1610   2
-- 
1.7.0.4

--
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 v3 3/4] drivers: input: Fix OMAP_GPIO_IRQ with gpio_to_irq() in ams_delta_serio_exit()

2012-03-29 Thread Tarun Kanti DebBarma
Even though ams-delta-serio input driver uses gpio_to_irq() in all
relevent places to get irq number, the ams_delta_serio_exit() still
uses OMAP_GPIO_IRQ macro. Fix this.

Signed-off-by: Tarun Kanti DebBarma tarun.ka...@ti.com
---
 drivers/input/serio/ams_delta_serio.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/input/serio/ams_delta_serio.c 
b/drivers/input/serio/ams_delta_serio.c
index d4d08bd..dbe1ae8 100644
--- a/drivers/input/serio/ams_delta_serio.c
+++ b/drivers/input/serio/ams_delta_serio.c
@@ -170,7 +170,7 @@ module_init(ams_delta_serio_init);
 static void __exit ams_delta_serio_exit(void)
 {
serio_unregister_port(ams_delta_serio);
-   free_irq(OMAP_GPIO_IRQ(AMS_DELTA_GPIO_PIN_KEYBRD_CLK), 0);
+   free_irq(gpio_to_irq(AMS_DELTA_GPIO_PIN_KEYBRD_CLK), 0);
gpio_free(AMS_DELTA_GPIO_PIN_KEYBRD_CLK);
gpio_free(AMS_DELTA_GPIO_PIN_KEYBRD_DATA);
 }
-- 
1.7.0.4

--
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 v3 2/4] ARM: OMAP2+: boards: Fix OMAP_GPIO_IRQ usage with gpio_to_irq()

2012-03-29 Thread Tarun Kanti DebBarma
With dynamic allocation of IRQ the usage of OMAP_GPIO_IRQ
is no longer valid. We should be using gpio_to_irq() instead.

Signed-off-by: Tarun Kanti DebBarma tarun.ka...@ti.com
---
 arch/arm/mach-omap2/board-2430sdp.c  |2 +-
 arch/arm/mach-omap2/board-4430sdp.c  |2 +-
 arch/arm/mach-omap2/board-apollon.c  |4 ++--
 arch/arm/mach-omap2/board-devkit8000.c   |2 +-
 arch/arm/mach-omap2/board-h4.c   |2 +-
 arch/arm/mach-omap2/board-omap3evm.c |2 +-
 arch/arm/mach-omap2/board-omap4panda.c   |2 +-
 arch/arm/mach-omap2/board-rx51-peripherals.c |3 ++-
 arch/arm/mach-omap2/board-zoom-debugboard.c  |3 ++-
 arch/arm/mach-omap2/board-zoom-peripherals.c |6 --
 arch/arm/mach-omap2/common-board-devices.c   |2 +-
 11 files changed, 17 insertions(+), 13 deletions(-)

diff --git a/arch/arm/mach-omap2/board-2430sdp.c 
b/arch/arm/mach-omap2/board-2430sdp.c
index 7370983..5a1b6af 100644
--- a/arch/arm/mach-omap2/board-2430sdp.c
+++ b/arch/arm/mach-omap2/board-2430sdp.c
@@ -230,12 +230,12 @@ static struct i2c_board_info __initdata 
sdp2430_i2c1_boardinfo[] = {
{
I2C_BOARD_INFO(isp1301_omap, 0x2D),
.flags = I2C_CLIENT_WAKE,
-   .irq = OMAP_GPIO_IRQ(78),
},
 };
 
 static int __init omap2430_i2c_init(void)
 {
+   sdp2430_i2c1_boardinfo[0].irq = gpio_to_irq(78);
omap_register_i2c_bus(1, 100, sdp2430_i2c1_boardinfo,
ARRAY_SIZE(sdp2430_i2c1_boardinfo));
omap_pmic_init(2, 100, twl4030, INT_24XX_SYS_NIRQ,
diff --git a/arch/arm/mach-omap2/board-4430sdp.c 
b/arch/arm/mach-omap2/board-4430sdp.c
index 4e90715..a09c699 100644
--- a/arch/arm/mach-omap2/board-4430sdp.c
+++ b/arch/arm/mach-omap2/board-4430sdp.c
@@ -873,7 +873,6 @@ static void __init omap4_sdp4430_wifi_mux_init(void)
 }
 
 static struct wl12xx_platform_data omap4_sdp4430_wlan_data __initdata = {
-   .irq = OMAP_GPIO_IRQ(GPIO_WIFI_IRQ),
.board_ref_clock = WL12XX_REFCLOCK_26,
.board_tcxo_clock = WL12XX_TCXOCLOCK_26,
 };
@@ -883,6 +882,7 @@ static void __init omap4_sdp4430_wifi_init(void)
int ret;
 
omap4_sdp4430_wifi_mux_init();
+   omap4_sdp4430_wlan_data.irq = gpio_to_irq(GPIO_WIFI_IRQ);
ret = wl12xx_set_platform_data(omap4_sdp4430_wlan_data);
if (ret)
pr_err(Error setting wl12xx data: %d\n, ret);
diff --git a/arch/arm/mach-omap2/board-apollon.c 
b/arch/arm/mach-omap2/board-apollon.c
index ac77382..768ece2 100644
--- a/arch/arm/mach-omap2/board-apollon.c
+++ b/arch/arm/mach-omap2/board-apollon.c
@@ -136,8 +136,6 @@ static struct resource apollon_smc91x_resources[] = {
.flags  = IORESOURCE_MEM,
},
[1] = {
-   .start  = OMAP_GPIO_IRQ(APOLLON_ETHR_GPIO_IRQ),
-   .end= OMAP_GPIO_IRQ(APOLLON_ETHR_GPIO_IRQ),
.flags  = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
},
 };
@@ -341,6 +339,8 @@ static void __init omap_apollon_init(void)
 * You have to mux them off in device drivers later on
 * if not needed.
 */
+   apollon_smc91x_resources[1].start = gpio_to_irq(APOLLON_ETHR_GPIO_IRQ);
+   apollon_smc91x_resources[1].end = gpio_to_irq(APOLLON_ETHR_GPIO_IRQ);
platform_add_devices(apollon_devices, ARRAY_SIZE(apollon_devices));
omap_serial_init();
omap_sdrc_init(NULL, NULL);
diff --git a/arch/arm/mach-omap2/board-devkit8000.c 
b/arch/arm/mach-omap2/board-devkit8000.c
index e873063..87cdb86 100644
--- a/arch/arm/mach-omap2/board-devkit8000.c
+++ b/arch/arm/mach-omap2/board-devkit8000.c
@@ -410,7 +410,6 @@ static struct resource omap_dm9000_resources[] = {
.flags  = IORESOURCE_MEM,
},
[2] = {
-   .start  = OMAP_GPIO_IRQ(OMAP_DM9000_GPIO_IRQ),
.flags  = IORESOURCE_IRQ | IRQF_TRIGGER_LOW,
},
 };
@@ -637,6 +636,7 @@ static void __init devkit8000_init(void)
omap_dm9000_init();
 
devkit8000_i2c_init();
+   omap_dm9000_resources[2].start = gpio_to_irq(OMAP_DM9000_GPIO_IRQ);
platform_add_devices(devkit8000_devices,
ARRAY_SIZE(devkit8000_devices));
 
diff --git a/arch/arm/mach-omap2/board-h4.c b/arch/arm/mach-omap2/board-h4.c
index 54af800..0bbbabe 100644
--- a/arch/arm/mach-omap2/board-h4.c
+++ b/arch/arm/mach-omap2/board-h4.c
@@ -348,7 +348,6 @@ static struct at24_platform_data m24c01 = {
 static struct i2c_board_info __initdata h4_i2c_board_info[] = {
{
I2C_BOARD_INFO(isp1301_omap, 0x2d),
-   .irq= OMAP_GPIO_IRQ(125),
},
{   /* EEPROM on mainboard */
I2C_BOARD_INFO(24c01, 0x52),
@@ -377,6 +376,7 @@ static void __init omap_h4_init(void)
 */
 
board_mkp_init();
+   h4_i2c_board_info[0].irq = gpio_to_irq(125);
i2c_register_board_info(1

[PATCH v3 1/4] ARM: OMAP1: boards: Fix OMAP_GPIO_IRQ usage with gpio_to_irq()

2012-03-29 Thread Tarun Kanti DebBarma
With dynamic allocation of IRQ the usage of OMAP_GPIO_IRQ
is no longer valid. We should be using gpio_to_irq() instead.

Signed-off-by: Tarun Kanti DebBarma tarun.ka...@ti.com
---
 arch/arm/mach-omap1/board-h2.c|8 
 arch/arm/mach-omap1/board-h3.c|9 -
 arch/arm/mach-omap1/board-htcherald.c |6 +++---
 arch/arm/mach-omap1/board-innovator.c |4 ++--
 arch/arm/mach-omap1/board-nokia770.c  |2 +-
 arch/arm/mach-omap1/board-osk.c   |   12 ++--
 arch/arm/mach-omap1/board-palmte.c|2 +-
 arch/arm/mach-omap1/board-palmtt.c|2 +-
 arch/arm/mach-omap1/board-palmz71.c   |2 +-
 arch/arm/mach-omap1/board-voiceblue.c |   16 +++-
 10 files changed, 30 insertions(+), 33 deletions(-)

diff --git a/arch/arm/mach-omap1/board-h2.c b/arch/arm/mach-omap1/board-h2.c
index 00ad6b2..b6926d4 100644
--- a/arch/arm/mach-omap1/board-h2.c
+++ b/arch/arm/mach-omap1/board-h2.c
@@ -244,8 +244,6 @@ static struct resource h2_smc91x_resources[] = {
.flags  = IORESOURCE_MEM,
},
[1] = {
-   .start  = OMAP_GPIO_IRQ(0),
-   .end= OMAP_GPIO_IRQ(0),
.flags  = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWEDGE,
},
 };
@@ -364,11 +362,9 @@ static struct tps65010_board tps_board = {
 static struct i2c_board_info __initdata h2_i2c_board_info[] = {
{
I2C_BOARD_INFO(tps65010, 0x48),
-   .irq= OMAP_GPIO_IRQ(58),
.platform_data  = tps_board,
}, {
I2C_BOARD_INFO(isp1301_omap, 0x2d),
-   .irq= OMAP_GPIO_IRQ(2),
},
 };
 
@@ -437,10 +433,14 @@ static void __init h2_init(void)
omap_cfg_reg(E19_1610_KBR4);
omap_cfg_reg(N19_1610_KBR5);
 
+   h2_smc91x_resources[1].start = gpio_to_irq(0);
+   h2_smc91x_resources[1].end = gpio_to_irq(0);
platform_add_devices(h2_devices, ARRAY_SIZE(h2_devices));
omap_board_config = h2_config;
omap_board_config_size = ARRAY_SIZE(h2_config);
omap_serial_init();
+   h2_i2c_board_info[0].irq = gpio_to_irq(58);
+   h2_i2c_board_info[1].irq = gpio_to_irq(2);
omap_register_i2c_bus(1, 100, h2_i2c_board_info,
  ARRAY_SIZE(h2_i2c_board_info));
omap1_usb_init(h2_usb_config);
diff --git a/arch/arm/mach-omap1/board-h3.c b/arch/arm/mach-omap1/board-h3.c
index 4a7f251..15f1028 100644
--- a/arch/arm/mach-omap1/board-h3.c
+++ b/arch/arm/mach-omap1/board-h3.c
@@ -246,8 +246,6 @@ static struct resource smc91x_resources[] = {
.flags  = IORESOURCE_MEM,
},
[1] = {
-   .start  = OMAP_GPIO_IRQ(40),
-   .end= OMAP_GPIO_IRQ(40),
.flags  = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWEDGE,
},
 };
@@ -337,7 +335,6 @@ static struct spi_board_info h3_spi_board_info[] __initdata 
= {
.modalias   = tsc2101,
.bus_num= 2,
.chip_select= 0,
-   .irq= OMAP_GPIO_IRQ(H3_TS_GPIO),
.max_speed_hz   = 1600,
/* .platform_data   = tsc_platform_data, */
},
@@ -377,11 +374,9 @@ static struct omap_board_config_kernel h3_config[] 
__initdata = {
 static struct i2c_board_info __initdata h3_i2c_board_info[] = {
{
I2C_BOARD_INFO(tps65013, 0x48),
-   /* .irq = OMAP_GPIO_IRQ(??), */
},
{
I2C_BOARD_INFO(isp1301_omap, 0x2d),
-   .irq= OMAP_GPIO_IRQ(14),
},
 };
 
@@ -423,12 +418,16 @@ static void __init h3_init(void)
omap_cfg_reg(E19_1610_KBR4);
omap_cfg_reg(N19_1610_KBR5);
 
+   smc91x_resources[1].start = gpio_to_irq(40);
+   smc91x_resources[1].end = gpio_to_irq(40);
platform_add_devices(devices, ARRAY_SIZE(devices));
+   h3_spi_board_info[0].irq = gpio_to_irq(H3_TS_GPIO);
spi_register_board_info(h3_spi_board_info,
ARRAY_SIZE(h3_spi_board_info));
omap_board_config = h3_config;
omap_board_config_size = ARRAY_SIZE(h3_config);
omap_serial_init();
+   h3_i2c_board_info[1].irq = gpio_to_irq(14);
omap_register_i2c_bus(1, 100, h3_i2c_board_info,
  ARRAY_SIZE(h3_i2c_board_info));
omap1_usb_init(h3_usb_config);
diff --git a/arch/arm/mach-omap1/board-htcherald.c 
b/arch/arm/mach-omap1/board-htcherald.c
index 731cc3d..cc04144 100644
--- a/arch/arm/mach-omap1/board-htcherald.c
+++ b/arch/arm/mach-omap1/board-htcherald.c
@@ -324,8 +324,6 @@ static struct platform_device gpio_leds_device = {
 
 static struct resource htcpld_resources[] = {
[0] = {
-   .start  = OMAP_GPIO_IRQ(HTCHERALD_GIRQ_BTNS),
-   .end= OMAP_GPIO_IRQ(HTCHERALD_GIRQ_BTNS),
.flags  = IORESOURCE_IRQ,
},
 };
@@ -454,7 +452,6

[PATCH v3 1/4] ARM: OMAP1: boards: Fix OMAP_GPIO_IRQ usage with gpio_to_irq()

2012-03-29 Thread Tarun Kanti DebBarma
With dynamic allocation of IRQ the usage of OMAP_GPIO_IRQ
is no longer valid. We should be using gpio_to_irq() instead.

Signed-off-by: Tarun Kanti DebBarma tarun.ka...@ti.com
---
 arch/arm/mach-omap1/board-h2.c|8 
 arch/arm/mach-omap1/board-h3.c|9 -
 arch/arm/mach-omap1/board-htcherald.c |6 +++---
 arch/arm/mach-omap1/board-innovator.c |4 ++--
 arch/arm/mach-omap1/board-nokia770.c  |2 +-
 arch/arm/mach-omap1/board-osk.c   |   12 ++--
 arch/arm/mach-omap1/board-palmte.c|2 +-
 arch/arm/mach-omap1/board-palmtt.c|2 +-
 arch/arm/mach-omap1/board-palmz71.c   |2 +-
 arch/arm/mach-omap1/board-voiceblue.c |   16 +++-
 10 files changed, 30 insertions(+), 33 deletions(-)

diff --git a/arch/arm/mach-omap1/board-h2.c b/arch/arm/mach-omap1/board-h2.c
index 00ad6b2..b6926d4 100644
--- a/arch/arm/mach-omap1/board-h2.c
+++ b/arch/arm/mach-omap1/board-h2.c
@@ -244,8 +244,6 @@ static struct resource h2_smc91x_resources[] = {
.flags  = IORESOURCE_MEM,
},
[1] = {
-   .start  = OMAP_GPIO_IRQ(0),
-   .end= OMAP_GPIO_IRQ(0),
.flags  = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWEDGE,
},
 };
@@ -364,11 +362,9 @@ static struct tps65010_board tps_board = {
 static struct i2c_board_info __initdata h2_i2c_board_info[] = {
{
I2C_BOARD_INFO(tps65010, 0x48),
-   .irq= OMAP_GPIO_IRQ(58),
.platform_data  = tps_board,
}, {
I2C_BOARD_INFO(isp1301_omap, 0x2d),
-   .irq= OMAP_GPIO_IRQ(2),
},
 };
 
@@ -437,10 +433,14 @@ static void __init h2_init(void)
omap_cfg_reg(E19_1610_KBR4);
omap_cfg_reg(N19_1610_KBR5);
 
+   h2_smc91x_resources[1].start = gpio_to_irq(0);
+   h2_smc91x_resources[1].end = gpio_to_irq(0);
platform_add_devices(h2_devices, ARRAY_SIZE(h2_devices));
omap_board_config = h2_config;
omap_board_config_size = ARRAY_SIZE(h2_config);
omap_serial_init();
+   h2_i2c_board_info[0].irq = gpio_to_irq(58);
+   h2_i2c_board_info[1].irq = gpio_to_irq(2);
omap_register_i2c_bus(1, 100, h2_i2c_board_info,
  ARRAY_SIZE(h2_i2c_board_info));
omap1_usb_init(h2_usb_config);
diff --git a/arch/arm/mach-omap1/board-h3.c b/arch/arm/mach-omap1/board-h3.c
index 4a7f251..15f1028 100644
--- a/arch/arm/mach-omap1/board-h3.c
+++ b/arch/arm/mach-omap1/board-h3.c
@@ -246,8 +246,6 @@ static struct resource smc91x_resources[] = {
.flags  = IORESOURCE_MEM,
},
[1] = {
-   .start  = OMAP_GPIO_IRQ(40),
-   .end= OMAP_GPIO_IRQ(40),
.flags  = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWEDGE,
},
 };
@@ -337,7 +335,6 @@ static struct spi_board_info h3_spi_board_info[] __initdata 
= {
.modalias   = tsc2101,
.bus_num= 2,
.chip_select= 0,
-   .irq= OMAP_GPIO_IRQ(H3_TS_GPIO),
.max_speed_hz   = 1600,
/* .platform_data   = tsc_platform_data, */
},
@@ -377,11 +374,9 @@ static struct omap_board_config_kernel h3_config[] 
__initdata = {
 static struct i2c_board_info __initdata h3_i2c_board_info[] = {
{
I2C_BOARD_INFO(tps65013, 0x48),
-   /* .irq = OMAP_GPIO_IRQ(??), */
},
{
I2C_BOARD_INFO(isp1301_omap, 0x2d),
-   .irq= OMAP_GPIO_IRQ(14),
},
 };
 
@@ -423,12 +418,16 @@ static void __init h3_init(void)
omap_cfg_reg(E19_1610_KBR4);
omap_cfg_reg(N19_1610_KBR5);
 
+   smc91x_resources[1].start = gpio_to_irq(40);
+   smc91x_resources[1].end = gpio_to_irq(40);
platform_add_devices(devices, ARRAY_SIZE(devices));
+   h3_spi_board_info[0].irq = gpio_to_irq(H3_TS_GPIO);
spi_register_board_info(h3_spi_board_info,
ARRAY_SIZE(h3_spi_board_info));
omap_board_config = h3_config;
omap_board_config_size = ARRAY_SIZE(h3_config);
omap_serial_init();
+   h3_i2c_board_info[1].irq = gpio_to_irq(14);
omap_register_i2c_bus(1, 100, h3_i2c_board_info,
  ARRAY_SIZE(h3_i2c_board_info));
omap1_usb_init(h3_usb_config);
diff --git a/arch/arm/mach-omap1/board-htcherald.c 
b/arch/arm/mach-omap1/board-htcherald.c
index 731cc3d..cc04144 100644
--- a/arch/arm/mach-omap1/board-htcherald.c
+++ b/arch/arm/mach-omap1/board-htcherald.c
@@ -324,8 +324,6 @@ static struct platform_device gpio_leds_device = {
 
 static struct resource htcpld_resources[] = {
[0] = {
-   .start  = OMAP_GPIO_IRQ(HTCHERALD_GIRQ_BTNS),
-   .end= OMAP_GPIO_IRQ(HTCHERALD_GIRQ_BTNS),
.flags  = IORESOURCE_IRQ,
},
 };
@@ -454,7 +452,6

[PATCH v4 RESEND 6/7] gpio/omap: fix incorrect update to context.irqenable1

2012-03-21 Thread Tarun Kanti DebBarma
In _enable_gpio_irqbank() when bank-regs-set_irqenable is TRUE,
gpio_mask can be directly set by writing to set_irqenable register
without overwriting current value. In order to ensure the same is
stored in context.irqenable1, we must avoid overwriting it with
gpio_mask at the end of the function. Instead, update irqenable1
appropriately by OR'ing with gpio_mask.
For the case where bank-regs-set_irqenable is FALSE, irqenable1
can be directly overwritten with 'l' which holds correct computed
value.

if (bank-regs-set_irqenable) {
reg += bank-regs-set_irqenable;
l = gpio_mask;
} else {
reg += bank-regs-irqenable;
l = __raw_readl(reg);
if (bank-regs-irqenable_inv)
l = ~gpio_mask;
else
l |= gpio_mask;
}

Make similar change for _disable_gpio_irqbank().

Signed-off-by: Tarun Kanti DebBarma tarun.ka...@ti.com
Reviewed-by: Santosh Shilimkar santosh.shilim...@ti.com
---
Updated change log as per Kevin's suggestion.

 drivers/gpio/gpio-omap.c |6 --
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
index bcb1061..6c17e58 100644
--- a/drivers/gpio/gpio-omap.c
+++ b/drivers/gpio/gpio-omap.c
@@ -451,6 +451,7 @@ static void _enable_gpio_irqbank(struct gpio_bank *bank, 
int gpio_mask)
if (bank-regs-set_irqenable) {
reg += bank-regs-set_irqenable;
l = gpio_mask;
+   bank-context.irqenable1 |= gpio_mask;
} else {
reg += bank-regs-irqenable;
l = __raw_readl(reg);
@@ -458,10 +459,10 @@ static void _enable_gpio_irqbank(struct gpio_bank *bank, 
int gpio_mask)
l = ~gpio_mask;
else
l |= gpio_mask;
+   bank-context.irqenable1 = l;
}
 
__raw_writel(l, reg);
-   bank-context.irqenable1 = l;
 }
 
 static void _disable_gpio_irqbank(struct gpio_bank *bank, int gpio_mask)
@@ -472,6 +473,7 @@ static void _disable_gpio_irqbank(struct gpio_bank *bank, 
int gpio_mask)
if (bank-regs-clr_irqenable) {
reg += bank-regs-clr_irqenable;
l = gpio_mask;
+   bank-context.irqenable1 = ~gpio_mask;
} else {
reg += bank-regs-irqenable;
l = __raw_readl(reg);
@@ -479,10 +481,10 @@ static void _disable_gpio_irqbank(struct gpio_bank *bank, 
int gpio_mask)
l |= gpio_mask;
else
l = ~gpio_mask;
+   bank-context.irqenable1 = l;
}
 
__raw_writel(l, reg);
-   bank-context.irqenable1 = l;
 }
 
 static inline void _set_gpio_irqenable(struct gpio_bank *bank, int gpio, int 
enable)
-- 
1.7.0.4

--
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 v4 RESEND 4/7] gpio/omap: fix missing dataout context save in _set_gpio_dataout_reg

2012-03-20 Thread Tarun Kanti DebBarma
There are two functions, _set_gpio_dataout_reg() and _set_gpio_dataout_mask()
which writes to dataout register and the dataout context must be saved.
It is missing in the first function, _set_gpio_dataout_reg(). Fix this.

Signed-off-by: Tarun Kanti DebBarma tarun.ka...@ti.com
Reviewed-by: Santosh Shilimkar santosh.shilim...@ti.com
---
 drivers/gpio/gpio-omap.c |7 +--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
index 8901d57..bbe9648 100644
--- a/drivers/gpio/gpio-omap.c
+++ b/drivers/gpio/gpio-omap.c
@@ -120,10 +120,13 @@ static void _set_gpio_dataout_reg(struct gpio_bank *bank, 
int gpio, int enable)
void __iomem *reg = bank-base;
u32 l = GPIO_BIT(bank, gpio);
 
-   if (enable)
+   if (enable) {
reg += bank-regs-set_dataout;
-   else
+   bank-context.dataout |= l;
+   } else {
reg += bank-regs-clr_dataout;
+   bank-context.dataout = ~l;
+   }
 
__raw_writel(l, reg);
 }
-- 
1.7.0.4

--
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 v4 RESEND 6/7] gpio/omap: fix incorrect update to context.irqenable1

2012-03-20 Thread Tarun Kanti DebBarma
In _enable_gpio_irqbank() when bank-regs-set_irqenable is valid,
gpio_mask can be directly set by writing to set_irqenable register
without overwriting current value. In order to ensure the same is
stored in context.irqenable1, we must read from regs-irqenable
instead of overwriting it with gpio_mask.
The overwriting makes sense only in the second case where irqenable
is explicitly read and updated with new gpio_mask before writing it
back. However, for consistency reading regs-irqenable into the
bank-context.irqenable1 takes care of both the scenarios.

if (bank-regs-set_irqenable) {
reg += bank-regs-set_irqenable;
l = gpio_mask;
} else {
reg += bank-regs-irqenable;
l = __raw_readl(reg);
if (bank-regs-irqenable_inv)
l = ~gpio_mask;
else
l |= gpio_mask;
}

Make the same change for _disable_gpio_irqbank().

Signed-off-by: Tarun Kanti DebBarma tarun.ka...@ti.com
Reviewed-by: Santosh Shilimkar santosh.shilim...@ti.com
---
 drivers/gpio/gpio-omap.c |6 --
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
index bcb1061..6c17e58 100644
--- a/drivers/gpio/gpio-omap.c
+++ b/drivers/gpio/gpio-omap.c
@@ -451,6 +451,7 @@ static void _enable_gpio_irqbank(struct gpio_bank *bank, 
int gpio_mask)
if (bank-regs-set_irqenable) {
reg += bank-regs-set_irqenable;
l = gpio_mask;
+   bank-context.irqenable1 |= gpio_mask;
} else {
reg += bank-regs-irqenable;
l = __raw_readl(reg);
@@ -458,10 +459,10 @@ static void _enable_gpio_irqbank(struct gpio_bank *bank, 
int gpio_mask)
l = ~gpio_mask;
else
l |= gpio_mask;
+   bank-context.irqenable1 = l;
}
 
__raw_writel(l, reg);
-   bank-context.irqenable1 = l;
 }
 
 static void _disable_gpio_irqbank(struct gpio_bank *bank, int gpio_mask)
@@ -472,6 +473,7 @@ static void _disable_gpio_irqbank(struct gpio_bank *bank, 
int gpio_mask)
if (bank-regs-clr_irqenable) {
reg += bank-regs-clr_irqenable;
l = gpio_mask;
+   bank-context.irqenable1 = ~gpio_mask;
} else {
reg += bank-regs-irqenable;
l = __raw_readl(reg);
@@ -479,10 +481,10 @@ static void _disable_gpio_irqbank(struct gpio_bank *bank, 
int gpio_mask)
l |= gpio_mask;
else
l = ~gpio_mask;
+   bank-context.irqenable1 = l;
}
 
__raw_writel(l, reg);
-   bank-context.irqenable1 = l;
 }
 
 static inline void _set_gpio_irqenable(struct gpio_bank *bank, int gpio, int 
enable)
-- 
1.7.0.4

--
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 v4 RESEND 1/7] gpio/omap: fix wakeup_en register update in _set_gpio_wakeup()

2012-03-20 Thread Tarun Kanti DebBarma
There are two ways through which wakeup_en register can be programmed
using gpiolib APIs as shown below. It is seen that in the second case
in _set_gpio_wakeup(), even though bank-suspend_wakeup is updated
correctly, its value is not programmed in wakeup_en register. Fix this.

irq_set_type()-gpio_irq_type()-_set_gpio_triggering()-set_gpio_trigger()
irq_set_wake()-gpio_wake_enable()-_set_gpio_wakeup()

Signed-off-by: Tarun Kanti DebBarma tarun.ka...@ti.com
---
 drivers/gpio/gpio-omap.c |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
index 7cbad85..1a144ac 100644
--- a/drivers/gpio/gpio-omap.c
+++ b/drivers/gpio/gpio-omap.c
@@ -511,6 +511,7 @@ static int _set_gpio_wakeup(struct gpio_bank *bank, int 
gpio, int enable)
else
bank-suspend_wakeup = ~gpio_bit;
 
+   __raw_writel(bank-suspend_wakeup, bank-base + bank-regs-wkup_en);
spin_unlock_irqrestore(bank-lock, flags);
 
return 0;
-- 
1.7.0.4

--
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 v4 RESEND 3/7] gpio/omap: fix _set_gpio_irqenable implementation

2012-03-20 Thread Tarun Kanti DebBarma
This function should be capable of both enabling and disabling interrupts
based upon the *enable* parameter. Right now the function only enables
the interrupt and *enable* is not used at all. So add the interrupt
disable capability also using the parameter.

Signed-off-by: Tarun Kanti DebBarma tarun.ka...@ti.com
Reviewed-by: Santosh Shilimkar santosh.shilim...@ti.com
Acked-by: Felipe Balbi ba...@ti.com
---
 drivers/gpio/gpio-omap.c |5 -
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
index 2042857..8901d57 100644
--- a/drivers/gpio/gpio-omap.c
+++ b/drivers/gpio/gpio-omap.c
@@ -484,7 +484,10 @@ static void _disable_gpio_irqbank(struct gpio_bank *bank, 
int gpio_mask)
 
 static inline void _set_gpio_irqenable(struct gpio_bank *bank, int gpio, int 
enable)
 {
-   _enable_gpio_irqbank(bank, GPIO_BIT(bank, gpio));
+   if (enable)
+   _enable_gpio_irqbank(bank, GPIO_BIT(bank, gpio));
+   else
+   _disable_gpio_irqbank(bank, GPIO_BIT(bank, gpio));
 }
 
 /*
-- 
1.7.0.4

--
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 v4 RESEND 2/7] gpio/omap: fix trigger type to unsigned

2012-03-20 Thread Tarun Kanti DebBarma
The GPIO trigger parameter is of type unsigned.
enum {
IRQ_TYPE_NONE   = 0x,
IRQ_TYPE_EDGE_RISING= 0x0001,
IRQ_TYPE_EDGE_FALLING   = 0x0002,
IRQ_TYPE_EDGE_BOTH  = (IRQ_TYPE_EDGE_FALLING | 
IRQ_TYPE_EDGE_RISING),
IRQ_TYPE_LEVEL_HIGH = 0x0004,
IRQ_TYPE_LEVEL_LOW  = 0x0008,
IRQ_TYPE_LEVEL_MASK = (IRQ_TYPE_LEVEL_LOW | IRQ_TYPE_LEVEL_HIGH),
IRQ_TYPE_SENSE_MASK = 0x000f,

IRQ_TYPE_PROBE  = 0x0010,
...
};
Even though gpio_irq_type(struct irq_data *d, unsigned type) has the right type
of parameter, the subsequent called functions set_gpio_triggering() and
set_gpio_trigger() wrongly makes it signed integer. Fix this.

Signed-off-by: Tarun Kanti DebBarma tarun.ka...@ti.com
Reviewed-by: Santosh Shilimkar santosh.shilim...@ti.com
Acked-by: Felipe Balbi ba...@ti.com
---
 drivers/gpio/gpio-omap.c |5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
index 1a144ac..2042857 100644
--- a/drivers/gpio/gpio-omap.c
+++ b/drivers/gpio/gpio-omap.c
@@ -245,7 +245,7 @@ static void _set_gpio_debounce(struct gpio_bank *bank, 
unsigned gpio,
 }
 
 static inline void set_gpio_trigger(struct gpio_bank *bank, int gpio,
-   int trigger)
+   unsigned trigger)
 {
void __iomem *base = bank-base;
u32 gpio_bit = 1  gpio;
@@ -327,7 +327,8 @@ static void _toggle_gpio_edge_triggering(struct gpio_bank 
*bank, int gpio)
 static void _toggle_gpio_edge_triggering(struct gpio_bank *bank, int gpio) {}
 #endif
 
-static int _set_gpio_triggering(struct gpio_bank *bank, int gpio, int trigger)
+static int _set_gpio_triggering(struct gpio_bank *bank, int gpio,
+   unsigned trigger)
 {
void __iomem *reg = bank-base;
void __iomem *base = bank-base;
-- 
1.7.0.4

--
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 v4 RESEND 5/7] gpio/omap: fix incorrect context restore logic in omap_gpio_runtime_*

2012-03-20 Thread Tarun Kanti DebBarma
In omap_gpio_runtime_suspend/resume() the context save/restore should
be independent of bank-enabled_non_wakeup_gpios. This was preventing
context restore of GPIO lines which are not wakeup enabled.

Reported-by: Govindraj Raja govindraj.r...@ti.com
Signed-off-by: Tarun Kanti DebBarma tarun.ka...@ti.com
Reviewed-by: Santosh Shilimkar santosh.shilim...@ti.com
---
 drivers/gpio/gpio-omap.c |5 +
 1 files changed, 1 insertions(+), 4 deletions(-)

diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
index bbe9648..bcb1061 100644
--- a/drivers/gpio/gpio-omap.c
+++ b/drivers/gpio/gpio-omap.c
@@ -1247,9 +1247,6 @@ static int omap_gpio_runtime_suspend(struct device *dev)
 * non-wakeup GPIOs.  Otherwise spurious IRQs will be
 * generated.  See OMAP2420 Errata item 1.101.
 */
-   if (!(bank-enabled_non_wakeup_gpios))
-   goto update_gpio_context_count;
-
bank-saved_datain = __raw_readl(bank-base +
bank-regs-datain);
l1 = __raw_readl(bank-base + bank-regs-fallingdetect);
@@ -1298,7 +1295,7 @@ static int omap_gpio_runtime_resume(struct device *dev)
__raw_writel(bank-context.risingdetect,
 bank-base + bank-regs-risingdetect);
 
-   if (!bank-enabled_non_wakeup_gpios || !bank-workaround_enabled) {
+   if (!bank-workaround_enabled) {
spin_unlock_irqrestore(bank-lock, flags);
return 0;
}
-- 
1.7.0.4

--
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 v4 RESEND 0/7] gpio/omap: Some more driver fixes

2012-03-20 Thread Tarun Kanti DebBarma
This series excludes the cleanup patches as suggested by Kevin from
the previously posted series.

The fixes include correction of _set_gpio_irqenable() implementation,
missing wakeup_en register update in set_gpio_wakeup(), type mismatch
of gpio trigger parameter in set_gpio_trigger(), incorrect dataout
register update in set_gpio_dataout_() and few corrections in context
save logic.

It is baselined on top of:
git://git.secretlab.ca/git/linux-2.6.git gpio/next
Commit: 81b279d80a63628e580c71a31d30a8c3b3047ad4

Series is available here for reference:
git://gitorious.org/~tarunkanti/omap-sw-develoment/tarunkantis-linux-omap-dev 
for_3.4/gpio_more_fixes

Power Test:
Off-mode and Retention on OMAP3430 (Suspend and Idle paths).
Also confirmed that dataout register content preserved over
off-mode.

Functional Test:
OMAP2430, OMAP3430SDP, ZOOM3, OMAP4430, OMAP4-BLAZE

v4:
a) Implemented all comments on v3 which are mostly related to
avoiding unnecessary register read while updating the context.

b) Folded:
gpio/omap: fix dataout register overwrite in _set_gpio_dataout
into:
gpio/omap: fix missing dataout context save in _set_gpio_dataout_reg

v3:
- Added 4 more additional patches to the previous series
 which are all bug fixes.

v2:
- Added a new patch to update wakeup_en register in _set_gpio_wakeup()
 in addition to updating bank-context.wake_en.

- Added a new patch to remove redundant decoding of gpio offset in
 gpio_get(), _get_gpio_datain() and _get_gpio_dataout().

- Added a new patch to remove suspend/resume callbacks because the
 operations performed with the callbacks are redundant.

Tarun Kanti DebBarma (7):
  gpio/omap: fix wakeup_en register update in _set_gpio_wakeup()
  gpio/omap: fix trigger type to unsigned
  gpio/omap: fix _set_gpio_irqenable implementation
  gpio/omap: fix missing dataout context save in _set_gpio_dataout_reg
  gpio/omap: fix incorrect context restore logic in omap_gpio_runtime_*
  gpio/omap: fix incorrect update to context.irqenable1
  gpio/omap: fix redundant decoding of gpio offset

 drivers/gpio/gpio-omap.c |   47 -
 1 files changed, 25 insertions(+), 22 deletions(-)

--
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 v2 3/4] drivers: input: Fix OMAP_GPIO_IRQ with gpio_to_irq() in ams_delta_serio_exit()

2012-03-19 Thread Tarun Kanti DebBarma
Even though ams-delta-serio input driver uses gpio_to_irq() in all
relevent places to get irq number, the ams_delta_serio_exit() still
uses OMAP_GPIO_IRQ macro. Fix this.

Signed-off-by: Tarun Kanti DebBarma tarun.ka...@ti.com
---
 drivers/input/serio/ams_delta_serio.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/input/serio/ams_delta_serio.c 
b/drivers/input/serio/ams_delta_serio.c
index d4d08bd..dbe1ae8 100644
--- a/drivers/input/serio/ams_delta_serio.c
+++ b/drivers/input/serio/ams_delta_serio.c
@@ -170,7 +170,7 @@ module_init(ams_delta_serio_init);
 static void __exit ams_delta_serio_exit(void)
 {
serio_unregister_port(ams_delta_serio);
-   free_irq(OMAP_GPIO_IRQ(AMS_DELTA_GPIO_PIN_KEYBRD_CLK), 0);
+   free_irq(gpio_to_irq(AMS_DELTA_GPIO_PIN_KEYBRD_CLK), 0);
gpio_free(AMS_DELTA_GPIO_PIN_KEYBRD_CLK);
gpio_free(AMS_DELTA_GPIO_PIN_KEYBRD_DATA);
 }
-- 
1.7.0.4

--
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 v2 4/4] ARM: OMAP: Remove OMAP_GPIO_IRQ macro definition

2012-03-19 Thread Tarun Kanti DebBarma
Since all references to OMAP_GPIO_IRQ macro are replaced now
with gpio_to_irq(), this can be removed altogether.

Signed-off-by: Tarun Kanti DebBarma tarun.ka...@ti.com
---
 arch/arm/plat-omap/include/plat/gpio.h |4 
 1 files changed, 0 insertions(+), 4 deletions(-)

diff --git a/arch/arm/plat-omap/include/plat/gpio.h 
b/arch/arm/plat-omap/include/plat/gpio.h
index 9e86ee0..d4df414 100644
--- a/arch/arm/plat-omap/include/plat/gpio.h
+++ b/arch/arm/plat-omap/include/plat/gpio.h
@@ -158,10 +158,6 @@
 #define OMAP_MPUIO(nr) (OMAP_MAX_GPIO_LINES + (nr))
 #define OMAP_GPIO_IS_MPUIO(nr) ((nr) = OMAP_MAX_GPIO_LINES)
 
-#define OMAP_GPIO_IRQ(nr)  (OMAP_GPIO_IS_MPUIO(nr) ? \
-IH_MPUIO_BASE + ((nr)  0x0f) : \
-IH_GPIO_BASE + (nr))
-
 #define METHOD_MPUIO   0
 #define METHOD_GPIO_1510   1
 #define METHOD_GPIO_1610   2
-- 
1.7.0.4

--
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 v2 0/4] ARM: OMAP: boards: changes to support dynamic irq alloc

2012-03-19 Thread Tarun Kanti DebBarma
These two patches incorporate changes to OMAP1 and OMAP2 platforms
board files whereby older references to OMAP_GPIO_IRQ macro are
now replaced with gpio_to_irq(), thereby getting rid of static
irq references.

Reference: git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc.git omap/dt
Commit: 9a0cee711448335ec43eae83272495e9334c0098

Test info:
OMAP1 Platforms:
Boot test on OMAP1710 H3.

OMAP2PLUS Platforms:
OMAP2430SDP, OMAP3430SDP, OMAP3630-ZOOM3, OMAP4430-SDP,
OMAP4430-PANDA, OMAP4430-BLAZE

I have also done gpio functional testing after merging Grant's:
git://git.secretlab.ca/git/linux-2.6.git gpio/next
on top of these patches.

Again, I would request someone help me testing on other platforms.

v2:
- Modified the patch subjects as per convention.
- Added a new patch to remove OMAP_GPIO_IRQ from ams_delta_serio driver.
- Added a new patch to remove OMAP_GPIO_IRQ macro definition.

Tarun Kanti DebBarma (4):
  ARM: OMAP1: boards: Fix OMAP_GPIO_IRQ usage with gpio_to_irq()
  ARM: OMAP2+: boards: Fix OMAP_GPIO_IRQ usage with gpio_to_irq()
  drivers: input: Fix OMAP_GPIO_IRQ with gpio_to_irq() in
ams_delta_serio_exit()
  ARM: OMAP: Remove OMAP_GPIO_IRQ macro definition

 arch/arm/mach-omap1/board-h2.c   |8 
 arch/arm/mach-omap1/board-h3.c   |9 -
 arch/arm/mach-omap1/board-htcherald.c|6 +++---
 arch/arm/mach-omap1/board-innovator.c|4 ++--
 arch/arm/mach-omap1/board-nokia770.c |2 +-
 arch/arm/mach-omap1/board-osk.c  |   12 ++--
 arch/arm/mach-omap1/board-palmte.c   |2 +-
 arch/arm/mach-omap1/board-palmtt.c   |2 +-
 arch/arm/mach-omap1/board-palmz71.c  |2 +-
 arch/arm/mach-omap1/board-voiceblue.c|   16 +++-
 arch/arm/mach-omap2/board-2430sdp.c  |2 +-
 arch/arm/mach-omap2/board-4430sdp.c  |2 +-
 arch/arm/mach-omap2/board-apollon.c  |6 --
 arch/arm/mach-omap2/board-devkit8000.c   |3 ++-
 arch/arm/mach-omap2/board-h4.c   |2 +-
 arch/arm/mach-omap2/board-omap3evm.c |2 +-
 arch/arm/mach-omap2/board-omap4panda.c   |2 +-
 arch/arm/mach-omap2/board-rx51-peripherals.c |3 ++-
 arch/arm/mach-omap2/board-zoom-debugboard.c  |3 ++-
 arch/arm/mach-omap2/board-zoom-peripherals.c |6 --
 arch/arm/mach-omap2/common-board-devices.c   |2 +-
 arch/arm/plat-omap/include/plat/gpio.h   |4 
 drivers/input/serio/ams_delta_serio.c|2 +-
 23 files changed, 51 insertions(+), 51 deletions(-)

--
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 v2 2/4] ARM: OMAP2+: boards: Fix OMAP_GPIO_IRQ usage with gpio_to_irq()

2012-03-19 Thread Tarun Kanti DebBarma
With dynamic allocation of IRQ the usage of OMAP_GPIO_IRQ
is no longer valid. We should be using gpio_to_irq() instead.

Signed-off-by: Tarun Kanti DebBarma tarun.ka...@ti.com
---
 arch/arm/mach-omap2/board-2430sdp.c  |2 +-
 arch/arm/mach-omap2/board-4430sdp.c  |2 +-
 arch/arm/mach-omap2/board-apollon.c  |6 --
 arch/arm/mach-omap2/board-devkit8000.c   |3 ++-
 arch/arm/mach-omap2/board-h4.c   |2 +-
 arch/arm/mach-omap2/board-omap3evm.c |2 +-
 arch/arm/mach-omap2/board-omap4panda.c   |2 +-
 arch/arm/mach-omap2/board-rx51-peripherals.c |3 ++-
 arch/arm/mach-omap2/board-zoom-debugboard.c  |3 ++-
 arch/arm/mach-omap2/board-zoom-peripherals.c |6 --
 arch/arm/mach-omap2/common-board-devices.c   |2 +-
 11 files changed, 20 insertions(+), 13 deletions(-)

diff --git a/arch/arm/mach-omap2/board-2430sdp.c 
b/arch/arm/mach-omap2/board-2430sdp.c
index 7370983..5a1b6af 100644
--- a/arch/arm/mach-omap2/board-2430sdp.c
+++ b/arch/arm/mach-omap2/board-2430sdp.c
@@ -230,12 +230,12 @@ static struct i2c_board_info __initdata 
sdp2430_i2c1_boardinfo[] = {
{
I2C_BOARD_INFO(isp1301_omap, 0x2D),
.flags = I2C_CLIENT_WAKE,
-   .irq = OMAP_GPIO_IRQ(78),
},
 };
 
 static int __init omap2430_i2c_init(void)
 {
+   sdp2430_i2c1_boardinfo[0].irq = gpio_to_irq(78);
omap_register_i2c_bus(1, 100, sdp2430_i2c1_boardinfo,
ARRAY_SIZE(sdp2430_i2c1_boardinfo));
omap_pmic_init(2, 100, twl4030, INT_24XX_SYS_NIRQ,
diff --git a/arch/arm/mach-omap2/board-4430sdp.c 
b/arch/arm/mach-omap2/board-4430sdp.c
index 4e90715..a09c699 100644
--- a/arch/arm/mach-omap2/board-4430sdp.c
+++ b/arch/arm/mach-omap2/board-4430sdp.c
@@ -873,7 +873,6 @@ static void __init omap4_sdp4430_wifi_mux_init(void)
 }
 
 static struct wl12xx_platform_data omap4_sdp4430_wlan_data __initdata = {
-   .irq = OMAP_GPIO_IRQ(GPIO_WIFI_IRQ),
.board_ref_clock = WL12XX_REFCLOCK_26,
.board_tcxo_clock = WL12XX_TCXOCLOCK_26,
 };
@@ -883,6 +882,7 @@ static void __init omap4_sdp4430_wifi_init(void)
int ret;
 
omap4_sdp4430_wifi_mux_init();
+   omap4_sdp4430_wlan_data.irq = gpio_to_irq(GPIO_WIFI_IRQ);
ret = wl12xx_set_platform_data(omap4_sdp4430_wlan_data);
if (ret)
pr_err(Error setting wl12xx data: %d\n, ret);
diff --git a/arch/arm/mach-omap2/board-apollon.c 
b/arch/arm/mach-omap2/board-apollon.c
index ac77382..7dd9d4d 100644
--- a/arch/arm/mach-omap2/board-apollon.c
+++ b/arch/arm/mach-omap2/board-apollon.c
@@ -136,8 +136,6 @@ static struct resource apollon_smc91x_resources[] = {
.flags  = IORESOURCE_MEM,
},
[1] = {
-   .start  = OMAP_GPIO_IRQ(APOLLON_ETHR_GPIO_IRQ),
-   .end= OMAP_GPIO_IRQ(APOLLON_ETHR_GPIO_IRQ),
.flags  = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
},
 };
@@ -341,6 +339,10 @@ static void __init omap_apollon_init(void)
 * You have to mux them off in device drivers later on
 * if not needed.
 */
+   apollon_devices[1]-resource[1].start =
+   gpio_to_irq(APOLLON_ETHR_GPIO_IRQ);
+   apollon_devices[1]-resource[1].end =
+   gpio_to_irq(APOLLON_ETHR_GPIO_IRQ);
platform_add_devices(apollon_devices, ARRAY_SIZE(apollon_devices));
omap_serial_init();
omap_sdrc_init(NULL, NULL);
diff --git a/arch/arm/mach-omap2/board-devkit8000.c 
b/arch/arm/mach-omap2/board-devkit8000.c
index e873063..e947dc7 100644
--- a/arch/arm/mach-omap2/board-devkit8000.c
+++ b/arch/arm/mach-omap2/board-devkit8000.c
@@ -410,7 +410,6 @@ static struct resource omap_dm9000_resources[] = {
.flags  = IORESOURCE_MEM,
},
[2] = {
-   .start  = OMAP_GPIO_IRQ(OMAP_DM9000_GPIO_IRQ),
.flags  = IORESOURCE_IRQ | IRQF_TRIGGER_LOW,
},
 };
@@ -637,6 +636,8 @@ static void __init devkit8000_init(void)
omap_dm9000_init();
 
devkit8000_i2c_init();
+   devkit8000_devices[2]-resource[2].start =
+   gpio_to_irq(OMAP_DM9000_GPIO_IRQ);
platform_add_devices(devkit8000_devices,
ARRAY_SIZE(devkit8000_devices));
 
diff --git a/arch/arm/mach-omap2/board-h4.c b/arch/arm/mach-omap2/board-h4.c
index 54af800..0bbbabe 100644
--- a/arch/arm/mach-omap2/board-h4.c
+++ b/arch/arm/mach-omap2/board-h4.c
@@ -348,7 +348,6 @@ static struct at24_platform_data m24c01 = {
 static struct i2c_board_info __initdata h4_i2c_board_info[] = {
{
I2C_BOARD_INFO(isp1301_omap, 0x2d),
-   .irq= OMAP_GPIO_IRQ(125),
},
{   /* EEPROM on mainboard */
I2C_BOARD_INFO(24c01, 0x52),
@@ -377,6 +376,7 @@ static void __init omap_h4_init(void

[PATCH v2 1/4] ARM: OMAP1: boards: Fix OMAP_GPIO_IRQ usage with gpio_to_irq()

2012-03-19 Thread Tarun Kanti DebBarma
With dynamic allocation of IRQ the usage of OMAP_GPIO_IRQ
is no longer valid. We should be using gpio_to_irq() instead.

Signed-off-by: Tarun Kanti DebBarma tarun.ka...@ti.com
---
 arch/arm/mach-omap1/board-h2.c|8 
 arch/arm/mach-omap1/board-h3.c|9 -
 arch/arm/mach-omap1/board-htcherald.c |6 +++---
 arch/arm/mach-omap1/board-innovator.c |4 ++--
 arch/arm/mach-omap1/board-nokia770.c  |2 +-
 arch/arm/mach-omap1/board-osk.c   |   12 ++--
 arch/arm/mach-omap1/board-palmte.c|2 +-
 arch/arm/mach-omap1/board-palmtt.c|2 +-
 arch/arm/mach-omap1/board-palmz71.c   |2 +-
 arch/arm/mach-omap1/board-voiceblue.c |   16 +++-
 10 files changed, 30 insertions(+), 33 deletions(-)

diff --git a/arch/arm/mach-omap1/board-h2.c b/arch/arm/mach-omap1/board-h2.c
index 00ad6b2..ad0eece 100644
--- a/arch/arm/mach-omap1/board-h2.c
+++ b/arch/arm/mach-omap1/board-h2.c
@@ -244,8 +244,6 @@ static struct resource h2_smc91x_resources[] = {
.flags  = IORESOURCE_MEM,
},
[1] = {
-   .start  = OMAP_GPIO_IRQ(0),
-   .end= OMAP_GPIO_IRQ(0),
.flags  = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWEDGE,
},
 };
@@ -364,11 +362,9 @@ static struct tps65010_board tps_board = {
 static struct i2c_board_info __initdata h2_i2c_board_info[] = {
{
I2C_BOARD_INFO(tps65010, 0x48),
-   .irq= OMAP_GPIO_IRQ(58),
.platform_data  = tps_board,
}, {
I2C_BOARD_INFO(isp1301_omap, 0x2d),
-   .irq= OMAP_GPIO_IRQ(2),
},
 };
 
@@ -437,10 +433,14 @@ static void __init h2_init(void)
omap_cfg_reg(E19_1610_KBR4);
omap_cfg_reg(N19_1610_KBR5);
 
+   h2_devices[2]-resource[1].start = gpio_to_irq(0);
+   h2_devices[2]-resource[1].end = gpio_to_irq(0);
platform_add_devices(h2_devices, ARRAY_SIZE(h2_devices));
omap_board_config = h2_config;
omap_board_config_size = ARRAY_SIZE(h2_config);
omap_serial_init();
+   h2_i2c_board_info[0].irq = gpio_to_irq(58);
+   h2_i2c_board_info[1].irq = gpio_to_irq(2);
omap_register_i2c_bus(1, 100, h2_i2c_board_info,
  ARRAY_SIZE(h2_i2c_board_info));
omap1_usb_init(h2_usb_config);
diff --git a/arch/arm/mach-omap1/board-h3.c b/arch/arm/mach-omap1/board-h3.c
index 4a7f251..740ca6c 100644
--- a/arch/arm/mach-omap1/board-h3.c
+++ b/arch/arm/mach-omap1/board-h3.c
@@ -246,8 +246,6 @@ static struct resource smc91x_resources[] = {
.flags  = IORESOURCE_MEM,
},
[1] = {
-   .start  = OMAP_GPIO_IRQ(40),
-   .end= OMAP_GPIO_IRQ(40),
.flags  = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWEDGE,
},
 };
@@ -337,7 +335,6 @@ static struct spi_board_info h3_spi_board_info[] __initdata 
= {
.modalias   = tsc2101,
.bus_num= 2,
.chip_select= 0,
-   .irq= OMAP_GPIO_IRQ(H3_TS_GPIO),
.max_speed_hz   = 1600,
/* .platform_data   = tsc_platform_data, */
},
@@ -377,11 +374,9 @@ static struct omap_board_config_kernel h3_config[] 
__initdata = {
 static struct i2c_board_info __initdata h3_i2c_board_info[] = {
{
I2C_BOARD_INFO(tps65013, 0x48),
-   /* .irq = OMAP_GPIO_IRQ(??), */
},
{
I2C_BOARD_INFO(isp1301_omap, 0x2d),
-   .irq= OMAP_GPIO_IRQ(14),
},
 };
 
@@ -423,12 +418,16 @@ static void __init h3_init(void)
omap_cfg_reg(E19_1610_KBR4);
omap_cfg_reg(N19_1610_KBR5);
 
+   devices[2]-resource[1].start = gpio_to_irq(40);
+   devices[2]-resource[1].end = gpio_to_irq(40);
platform_add_devices(devices, ARRAY_SIZE(devices));
+   h3_spi_board_info[0].irq = gpio_to_irq(H3_TS_GPIO);
spi_register_board_info(h3_spi_board_info,
ARRAY_SIZE(h3_spi_board_info));
omap_board_config = h3_config;
omap_board_config_size = ARRAY_SIZE(h3_config);
omap_serial_init();
+   h3_i2c_board_info[1].irq = gpio_to_irq(14);
omap_register_i2c_bus(1, 100, h3_i2c_board_info,
  ARRAY_SIZE(h3_i2c_board_info));
omap1_usb_init(h3_usb_config);
diff --git a/arch/arm/mach-omap1/board-htcherald.c 
b/arch/arm/mach-omap1/board-htcherald.c
index 731cc3d..766b1e3 100644
--- a/arch/arm/mach-omap1/board-htcherald.c
+++ b/arch/arm/mach-omap1/board-htcherald.c
@@ -324,8 +324,6 @@ static struct platform_device gpio_leds_device = {
 
 static struct resource htcpld_resources[] = {
[0] = {
-   .start  = OMAP_GPIO_IRQ(HTCHERALD_GIRQ_BTNS),
-   .end= OMAP_GPIO_IRQ(HTCHERALD_GIRQ_BTNS),
.flags  = IORESOURCE_IRQ,
},
 };
@@ -454,7

[PATCH 0/2] omap: board file changes to support dynamic irq alloc

2012-03-16 Thread Tarun Kanti DebBarma
These two patches incorporate changes to OMAP1 and OMAP2 platforms
board files whereby older references to OMAP_GPIO_IRQ macro are
now replaced with gpio_to_irq(), thereby getting rid of static
irq references.

Reference: git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc.git omap/dt
Commit: 9a0cee711448335ec43eae83272495e9334c0098

Test info:
OMAP1 Platforms:
Boot test on OMAP1710 H3.

OMAP2PLUS Platforms:
OMAP2430SDP, OMAP3430SDP, OMAP3630-ZOOM3, OMAP4430-SDP,
OMAP4430-PANDA, OMAP4430-BLAZE

I have also done gpio functional testing after merging Grant's:
git://git.secretlab.ca/git/linux-2.6.git gpio/next
on top of these patches.

I would request someone help me testing on other platforms.

Tarun Kanti DebBarma (2):
  omap1/board-files: fix OMAP_GPIO_IRQ usage with gpio_to_irq()
  omap2plus/board-files: fix OMAP_GPIO_IRQ usage with gpio_to_irq()

 arch/arm/mach-omap1/board-h2.c   |8 
 arch/arm/mach-omap1/board-h3.c   |8 
 arch/arm/mach-omap1/board-htcherald.c|6 +++---
 arch/arm/mach-omap1/board-innovator.c|4 ++--
 arch/arm/mach-omap1/board-nokia770.c |1 +
 arch/arm/mach-omap1/board-osk.c  |   12 ++--
 arch/arm/mach-omap1/board-palmte.c   |2 +-
 arch/arm/mach-omap1/board-palmtt.c   |2 +-
 arch/arm/mach-omap1/board-palmz71.c  |2 +-
 arch/arm/mach-omap1/board-voiceblue.c|   16 +++-
 arch/arm/mach-omap2/board-2430sdp.c  |2 +-
 arch/arm/mach-omap2/board-4430sdp.c  |2 +-
 arch/arm/mach-omap2/board-apollon.c  |6 --
 arch/arm/mach-omap2/board-devkit8000.c   |3 ++-
 arch/arm/mach-omap2/board-h4.c   |2 +-
 arch/arm/mach-omap2/board-omap3evm.c |2 +-
 arch/arm/mach-omap2/board-omap4panda.c   |2 +-
 arch/arm/mach-omap2/board-rx51-peripherals.c |3 ++-
 arch/arm/mach-omap2/board-zoom-debugboard.c  |3 ++-
 arch/arm/mach-omap2/board-zoom-peripherals.c |6 --
 arch/arm/mach-omap2/common-board-devices.c   |2 +-
 21 files changed, 50 insertions(+), 44 deletions(-)

--
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 1/2] omap1/board-files: fix OMAP_GPIO_IRQ usage with gpio_to_irq()

2012-03-16 Thread Tarun Kanti DebBarma
With dynamic allocation of IRQ the usage of OMAP_GPIO_IRQ
is no longer valid. We should be using gpio_to_irq() instead.

Signed-off-by: Tarun Kanti DebBarma tarun.ka...@ti.com
---
 arch/arm/mach-omap1/board-h2.c|8 
 arch/arm/mach-omap1/board-h3.c|8 
 arch/arm/mach-omap1/board-htcherald.c |6 +++---
 arch/arm/mach-omap1/board-innovator.c |4 ++--
 arch/arm/mach-omap1/board-nokia770.c  |1 +
 arch/arm/mach-omap1/board-osk.c   |   12 ++--
 arch/arm/mach-omap1/board-palmte.c|2 +-
 arch/arm/mach-omap1/board-palmtt.c|2 +-
 arch/arm/mach-omap1/board-palmz71.c   |2 +-
 arch/arm/mach-omap1/board-voiceblue.c |   16 +++-
 10 files changed, 30 insertions(+), 31 deletions(-)

diff --git a/arch/arm/mach-omap1/board-h2.c b/arch/arm/mach-omap1/board-h2.c
index 00ad6b2..ad0eece 100644
--- a/arch/arm/mach-omap1/board-h2.c
+++ b/arch/arm/mach-omap1/board-h2.c
@@ -244,8 +244,6 @@ static struct resource h2_smc91x_resources[] = {
.flags  = IORESOURCE_MEM,
},
[1] = {
-   .start  = OMAP_GPIO_IRQ(0),
-   .end= OMAP_GPIO_IRQ(0),
.flags  = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWEDGE,
},
 };
@@ -364,11 +362,9 @@ static struct tps65010_board tps_board = {
 static struct i2c_board_info __initdata h2_i2c_board_info[] = {
{
I2C_BOARD_INFO(tps65010, 0x48),
-   .irq= OMAP_GPIO_IRQ(58),
.platform_data  = tps_board,
}, {
I2C_BOARD_INFO(isp1301_omap, 0x2d),
-   .irq= OMAP_GPIO_IRQ(2),
},
 };
 
@@ -437,10 +433,14 @@ static void __init h2_init(void)
omap_cfg_reg(E19_1610_KBR4);
omap_cfg_reg(N19_1610_KBR5);
 
+   h2_devices[2]-resource[1].start = gpio_to_irq(0);
+   h2_devices[2]-resource[1].end = gpio_to_irq(0);
platform_add_devices(h2_devices, ARRAY_SIZE(h2_devices));
omap_board_config = h2_config;
omap_board_config_size = ARRAY_SIZE(h2_config);
omap_serial_init();
+   h2_i2c_board_info[0].irq = gpio_to_irq(58);
+   h2_i2c_board_info[1].irq = gpio_to_irq(2);
omap_register_i2c_bus(1, 100, h2_i2c_board_info,
  ARRAY_SIZE(h2_i2c_board_info));
omap1_usb_init(h2_usb_config);
diff --git a/arch/arm/mach-omap1/board-h3.c b/arch/arm/mach-omap1/board-h3.c
index 4a7f251..692b16d 100644
--- a/arch/arm/mach-omap1/board-h3.c
+++ b/arch/arm/mach-omap1/board-h3.c
@@ -246,8 +246,6 @@ static struct resource smc91x_resources[] = {
.flags  = IORESOURCE_MEM,
},
[1] = {
-   .start  = OMAP_GPIO_IRQ(40),
-   .end= OMAP_GPIO_IRQ(40),
.flags  = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWEDGE,
},
 };
@@ -337,7 +335,6 @@ static struct spi_board_info h3_spi_board_info[] __initdata 
= {
.modalias   = tsc2101,
.bus_num= 2,
.chip_select= 0,
-   .irq= OMAP_GPIO_IRQ(H3_TS_GPIO),
.max_speed_hz   = 1600,
/* .platform_data   = tsc_platform_data, */
},
@@ -381,7 +378,6 @@ static struct i2c_board_info __initdata h3_i2c_board_info[] 
= {
},
{
I2C_BOARD_INFO(isp1301_omap, 0x2d),
-   .irq= OMAP_GPIO_IRQ(14),
},
 };
 
@@ -423,12 +419,16 @@ static void __init h3_init(void)
omap_cfg_reg(E19_1610_KBR4);
omap_cfg_reg(N19_1610_KBR5);
 
+   devices[2]-resource[1].start = gpio_to_irq(40);
+   devices[2]-resource[1].end = gpio_to_irq(40);
platform_add_devices(devices, ARRAY_SIZE(devices));
+   h3_spi_board_info[0].irq = gpio_to_irq(H3_TS_GPIO);
spi_register_board_info(h3_spi_board_info,
ARRAY_SIZE(h3_spi_board_info));
omap_board_config = h3_config;
omap_board_config_size = ARRAY_SIZE(h3_config);
omap_serial_init();
+   h3_i2c_board_info[1].irq = gpio_to_irq(14);
omap_register_i2c_bus(1, 100, h3_i2c_board_info,
  ARRAY_SIZE(h3_i2c_board_info));
omap1_usb_init(h3_usb_config);
diff --git a/arch/arm/mach-omap1/board-htcherald.c 
b/arch/arm/mach-omap1/board-htcherald.c
index 731cc3d..766b1e3 100644
--- a/arch/arm/mach-omap1/board-htcherald.c
+++ b/arch/arm/mach-omap1/board-htcherald.c
@@ -324,8 +324,6 @@ static struct platform_device gpio_leds_device = {
 
 static struct resource htcpld_resources[] = {
[0] = {
-   .start  = OMAP_GPIO_IRQ(HTCHERALD_GIRQ_BTNS),
-   .end= OMAP_GPIO_IRQ(HTCHERALD_GIRQ_BTNS),
.flags  = IORESOURCE_IRQ,
},
 };
@@ -454,7 +452,6 @@ static struct spi_board_info __initdata 
htcherald_spi_board_info[] = {
{
.modalias   = ads7846,
.platform_data

[PATCH 2/2] omap2plus/board-files: fix OMAP_GPIO_IRQ usage with gpio_to_irq()

2012-03-16 Thread Tarun Kanti DebBarma
With dynamic allocation of IRQ the usage of OMAP_GPIO_IRQi
is no longer valid. We should be using gpio_to_irq() instead.

Signed-off-by: Tarun Kanti DebBarma tarun.ka...@ti.com
---
 arch/arm/mach-omap2/board-2430sdp.c  |2 +-
 arch/arm/mach-omap2/board-4430sdp.c  |2 +-
 arch/arm/mach-omap2/board-apollon.c  |6 --
 arch/arm/mach-omap2/board-devkit8000.c   |3 ++-
 arch/arm/mach-omap2/board-h4.c   |2 +-
 arch/arm/mach-omap2/board-omap3evm.c |2 +-
 arch/arm/mach-omap2/board-omap4panda.c   |2 +-
 arch/arm/mach-omap2/board-rx51-peripherals.c |3 ++-
 arch/arm/mach-omap2/board-zoom-debugboard.c  |3 ++-
 arch/arm/mach-omap2/board-zoom-peripherals.c |6 --
 arch/arm/mach-omap2/common-board-devices.c   |2 +-
 11 files changed, 20 insertions(+), 13 deletions(-)

diff --git a/arch/arm/mach-omap2/board-2430sdp.c 
b/arch/arm/mach-omap2/board-2430sdp.c
index 7370983..5a1b6af 100644
--- a/arch/arm/mach-omap2/board-2430sdp.c
+++ b/arch/arm/mach-omap2/board-2430sdp.c
@@ -230,12 +230,12 @@ static struct i2c_board_info __initdata 
sdp2430_i2c1_boardinfo[] = {
{
I2C_BOARD_INFO(isp1301_omap, 0x2D),
.flags = I2C_CLIENT_WAKE,
-   .irq = OMAP_GPIO_IRQ(78),
},
 };
 
 static int __init omap2430_i2c_init(void)
 {
+   sdp2430_i2c1_boardinfo[0].irq = gpio_to_irq(78);
omap_register_i2c_bus(1, 100, sdp2430_i2c1_boardinfo,
ARRAY_SIZE(sdp2430_i2c1_boardinfo));
omap_pmic_init(2, 100, twl4030, INT_24XX_SYS_NIRQ,
diff --git a/arch/arm/mach-omap2/board-4430sdp.c 
b/arch/arm/mach-omap2/board-4430sdp.c
index 4e90715..a09c699 100644
--- a/arch/arm/mach-omap2/board-4430sdp.c
+++ b/arch/arm/mach-omap2/board-4430sdp.c
@@ -873,7 +873,6 @@ static void __init omap4_sdp4430_wifi_mux_init(void)
 }
 
 static struct wl12xx_platform_data omap4_sdp4430_wlan_data __initdata = {
-   .irq = OMAP_GPIO_IRQ(GPIO_WIFI_IRQ),
.board_ref_clock = WL12XX_REFCLOCK_26,
.board_tcxo_clock = WL12XX_TCXOCLOCK_26,
 };
@@ -883,6 +882,7 @@ static void __init omap4_sdp4430_wifi_init(void)
int ret;
 
omap4_sdp4430_wifi_mux_init();
+   omap4_sdp4430_wlan_data.irq = gpio_to_irq(GPIO_WIFI_IRQ);
ret = wl12xx_set_platform_data(omap4_sdp4430_wlan_data);
if (ret)
pr_err(Error setting wl12xx data: %d\n, ret);
diff --git a/arch/arm/mach-omap2/board-apollon.c 
b/arch/arm/mach-omap2/board-apollon.c
index ac77382..7dd9d4d 100644
--- a/arch/arm/mach-omap2/board-apollon.c
+++ b/arch/arm/mach-omap2/board-apollon.c
@@ -136,8 +136,6 @@ static struct resource apollon_smc91x_resources[] = {
.flags  = IORESOURCE_MEM,
},
[1] = {
-   .start  = OMAP_GPIO_IRQ(APOLLON_ETHR_GPIO_IRQ),
-   .end= OMAP_GPIO_IRQ(APOLLON_ETHR_GPIO_IRQ),
.flags  = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
},
 };
@@ -341,6 +339,10 @@ static void __init omap_apollon_init(void)
 * You have to mux them off in device drivers later on
 * if not needed.
 */
+   apollon_devices[1]-resource[1].start =
+   gpio_to_irq(APOLLON_ETHR_GPIO_IRQ);
+   apollon_devices[1]-resource[1].end =
+   gpio_to_irq(APOLLON_ETHR_GPIO_IRQ);
platform_add_devices(apollon_devices, ARRAY_SIZE(apollon_devices));
omap_serial_init();
omap_sdrc_init(NULL, NULL);
diff --git a/arch/arm/mach-omap2/board-devkit8000.c 
b/arch/arm/mach-omap2/board-devkit8000.c
index e873063..e947dc7 100644
--- a/arch/arm/mach-omap2/board-devkit8000.c
+++ b/arch/arm/mach-omap2/board-devkit8000.c
@@ -410,7 +410,6 @@ static struct resource omap_dm9000_resources[] = {
.flags  = IORESOURCE_MEM,
},
[2] = {
-   .start  = OMAP_GPIO_IRQ(OMAP_DM9000_GPIO_IRQ),
.flags  = IORESOURCE_IRQ | IRQF_TRIGGER_LOW,
},
 };
@@ -637,6 +636,8 @@ static void __init devkit8000_init(void)
omap_dm9000_init();
 
devkit8000_i2c_init();
+   devkit8000_devices[2]-resource[2].start =
+   gpio_to_irq(OMAP_DM9000_GPIO_IRQ);
platform_add_devices(devkit8000_devices,
ARRAY_SIZE(devkit8000_devices));
 
diff --git a/arch/arm/mach-omap2/board-h4.c b/arch/arm/mach-omap2/board-h4.c
index 54af800..0bbbabe 100644
--- a/arch/arm/mach-omap2/board-h4.c
+++ b/arch/arm/mach-omap2/board-h4.c
@@ -348,7 +348,6 @@ static struct at24_platform_data m24c01 = {
 static struct i2c_board_info __initdata h4_i2c_board_info[] = {
{
I2C_BOARD_INFO(isp1301_omap, 0x2d),
-   .irq= OMAP_GPIO_IRQ(125),
},
{   /* EEPROM on mainboard */
I2C_BOARD_INFO(24c01, 0x52),
@@ -377,6 +376,7 @@ static void __init omap_h4_init(void

[PATCH v4 04/12] gpio/omap: remove saved_wakeup field from struct gpio_bank

2012-03-16 Thread Tarun Kanti DebBarma
There is no more need to have saved_wakeup because bank-context.wake_en
already holds that value. So getting rid of read/write operation associated
with this field.

Signed-off-by: Tarun Kanti DebBarma tarun.ka...@ti.com
Reviewed-by: Santosh Shilimkar santosh.shilim...@ti.com
Acked-by: Felipe Balbi ba...@ti.com
---
 drivers/gpio/gpio-omap.c |   12 +++-
 1 files changed, 3 insertions(+), 9 deletions(-)

diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
index 3a4f151..3b91ade 100644
--- a/drivers/gpio/gpio-omap.c
+++ b/drivers/gpio/gpio-omap.c
@@ -57,7 +57,6 @@ struct gpio_bank {
u16 irq;
int irq_base;
struct irq_domain *domain;
-   u32 saved_wakeup;
u32 non_wakeup_gpios;
u32 enabled_non_wakeup_gpios;
struct gpio_regs context;
@@ -777,7 +776,6 @@ static int omap_mpuio_suspend_noirq(struct device *dev)
unsigned long   flags;
 
spin_lock_irqsave(bank-lock, flags);
-   bank-saved_wakeup = __raw_readl(mask_reg);
__raw_writel(0x  ~bank-context.wake_en, mask_reg);
spin_unlock_irqrestore(bank-lock, flags);
 
@@ -793,7 +791,7 @@ static int omap_mpuio_resume_noirq(struct device *dev)
unsigned long   flags;
 
spin_lock_irqsave(bank-lock, flags);
-   __raw_writel(bank-saved_wakeup, mask_reg);
+   __raw_writel(bank-context.wake_en, mask_reg);
spin_unlock_irqrestore(bank-lock, flags);
 
return 0;
@@ -1153,7 +1151,6 @@ static int omap_gpio_suspend(struct device *dev)
struct platform_device *pdev = to_platform_device(dev);
struct gpio_bank *bank = platform_get_drvdata(pdev);
void __iomem *base = bank-base;
-   void __iomem *wakeup_enable;
unsigned long flags;
 
if (!bank-mod_usage || !bank-loses_context)
@@ -1162,10 +1159,7 @@ static int omap_gpio_suspend(struct device *dev)
if (!bank-regs-wkup_en || !bank-context.wake_en)
return 0;
 
-   wakeup_enable = bank-base + bank-regs-wkup_en;
-
spin_lock_irqsave(bank-lock, flags);
-   bank-saved_wakeup = __raw_readl(wakeup_enable);
_gpio_rmw(base, bank-regs-wkup_en, 0x, 0);
_gpio_rmw(base, bank-regs-wkup_en, bank-context.wake_en, 1);
spin_unlock_irqrestore(bank-lock, flags);
@@ -1183,12 +1177,12 @@ static int omap_gpio_resume(struct device *dev)
if (!bank-mod_usage || !bank-loses_context)
return 0;
 
-   if (!bank-regs-wkup_en || !bank-saved_wakeup)
+   if (!bank-regs-wkup_en || !bank-context.wake_en)
return 0;
 
spin_lock_irqsave(bank-lock, flags);
_gpio_rmw(base, bank-regs-wkup_en, 0x, 0);
-   _gpio_rmw(base, bank-regs-wkup_en, bank-saved_wakeup, 1);
+   _gpio_rmw(base, bank-regs-wkup_en, bank-context.wake_en, 1);
spin_unlock_irqrestore(bank-lock, flags);
 
return 0;
-- 
1.7.0.4

--
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 v4 00/12] gpio/omap: Some more driver cleanup and fixes

2012-03-16 Thread Tarun Kanti DebBarma
The cleanup is mostly getting rid of redundant fields in struct gpio_bank{}
as we already have them as part of bank-context now. Also, remove un-used
variable from gpio_irq_handler. Also, the suspend/resume callbacks are
removed bacause they are not needed any more.

The fixes include correction of _set_gpio_irqenable() implementation,
missing wakeup_en register update in set_gpio_wakeup(), type mismatch
of gpio trigger parameter in set_gpio_trigger(), incorrect dataout
register update in set_gpio_dataout_() and few corrections in context
save logic.

It is baselined on top of:
git://git.secretlab.ca/git/linux-2.6.git gpio/next
Commit: 81b279d80a63628e580c71a31d30a8c3b3047ad4

Series is available here for reference:
git://gitorious.org/~tarunkanti/omap-sw-develoment/tarunkantis-linux-omap-dev 
for_3.4/gpio_more_cleanup_fixes

Power Test: 
Off-mode and Retention on OMAP3430 (Suspend and Idle paths).
Also confirmed that dataout register content preserved over
off-mode.

Functional Test:
OMAP2430, OMAP3430SDP, ZOOM3, OMAP4430, OMAP4-BLAZE, PANDA 

v4:
a) Implemented all comments on v3 which are mostly related to
avoiding unnecessary register read while updating the context.

b) Folded:
gpio/omap: fix dataout register overwrite in _set_gpio_dataout
into:
gpio/omap: fix missing dataout context save in _set_gpio_dataout_reg

v3:
- Added 4 more additional patches to the previous series
 which are all bug fixes.

v2:
- Added a new patch to update wakeup_en register in _set_gpio_wakeup()
 in addition to updating bank-context.wake_en.

- Added a new patch to remove redundant decoding of gpio offset in
 gpio_get(), _get_gpio_datain() and _get_gpio_dataout().

- Added a new patch to remove suspend/resume callbacks because the
 operations performed with the callbacks are redundant.

Tarun Kanti DebBarma (12):
  gpio/omap: remove saved_fallingdetect, saved_risingdetect fields
  gpio/omap: fix wakeup_en register update in _set_gpio_wakeup()
  gpio/omap: remove suspend_wakeup field from struct gpio_bank
  gpio/omap: remove saved_wakeup field from struct gpio_bank
  gpio/omap: get rid of retrigger variable in gpio_irq_handler
  gpio/omap: fix trigger type to unsigned
  gpio/omap: fix _set_gpio_irqenable implementation
  gpio/omap: remove redundant decoding of gpio offset
  gpio/omap: remove suspend/resume callbacks
  gpio/omap: fix missing dataout context save in _set_gpio_dataout_reg
  gpio/omap: fix incorrect context restore logic in omap_gpio_runtime_*
  gpio/omap: fix incorrect update to context.irqenable1

 drivers/gpio/gpio-omap.c |  131 +-
 1 files changed, 37 insertions(+), 94 deletions(-)

--
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 v4 07/12] gpio/omap: fix _set_gpio_irqenable implementation

2012-03-16 Thread Tarun Kanti DebBarma
This function should be capable of both enabling and disabling interrupts
based upon the *enable* parameter. Right now the function only enables
the interrupt and *enable* is not used at all. So add the interrupt
disable capability also using the parameter.

Signed-off-by: Tarun Kanti DebBarma tarun.ka...@ti.com
Reviewed-by: Santosh Shilimkar santosh.shilim...@ti.com
Acked-by: Felipe Balbi ba...@ti.com
---
 drivers/gpio/gpio-omap.c |5 -
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
index 4d23da1..8b453dd 100644
--- a/drivers/gpio/gpio-omap.c
+++ b/drivers/gpio/gpio-omap.c
@@ -480,7 +480,10 @@ static void _disable_gpio_irqbank(struct gpio_bank *bank, 
int gpio_mask)
 
 static inline void _set_gpio_irqenable(struct gpio_bank *bank, int gpio, int 
enable)
 {
-   _enable_gpio_irqbank(bank, GPIO_BIT(bank, gpio));
+   if (enable)
+   _enable_gpio_irqbank(bank, GPIO_BIT(bank, gpio));
+   else
+   _disable_gpio_irqbank(bank, GPIO_BIT(bank, gpio));
 }
 
 /*
-- 
1.7.0.4

--
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 v4 01/12] gpio/omap: remove saved_fallingdetect, saved_risingdetect fields

2012-03-16 Thread Tarun Kanti DebBarma
Since we already have context.fallingdetect and context.risingdetect
there is no more need to have these additional fields. Also, getting
rid of extra reads associated with them.

Signed-off-by: Tarun Kanti DebBarma tarun.ka...@ti.com
Reviewed-by: Santosh Shilimkar santosh.shilim...@ti.com
Acked-by: Felipe Balbi ba...@ti.com
---
 drivers/gpio/gpio-omap.c |   19 ---
 1 files changed, 8 insertions(+), 11 deletions(-)

diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
index 7cbad85..0c1c529 100644
--- a/drivers/gpio/gpio-omap.c
+++ b/drivers/gpio/gpio-omap.c
@@ -63,8 +63,6 @@ struct gpio_bank {
u32 enabled_non_wakeup_gpios;
struct gpio_regs context;
u32 saved_datain;
-   u32 saved_fallingdetect;
-   u32 saved_risingdetect;
u32 level_mask;
u32 toggle_mask;
spinlock_t lock;
@@ -1244,11 +1242,9 @@ static int omap_gpio_runtime_suspend(struct device *dev)
 
bank-saved_datain = __raw_readl(bank-base +
bank-regs-datain);
-   l1 = __raw_readl(bank-base + bank-regs-fallingdetect);
-   l2 = __raw_readl(bank-base + bank-regs-risingdetect);
+   l1 = bank-context.fallingdetect;
+   l2 = bank-context.risingdetect;
 
-   bank-saved_fallingdetect = l1;
-   bank-saved_risingdetect = l2;
l1 = ~bank-enabled_non_wakeup_gpios;
l2 = ~bank-enabled_non_wakeup_gpios;
 
@@ -1307,9 +1303,9 @@ static int omap_gpio_runtime_resume(struct device *dev)
}
}
 
-   __raw_writel(bank-saved_fallingdetect,
+   __raw_writel(bank-context.fallingdetect,
bank-base + bank-regs-fallingdetect);
-   __raw_writel(bank-saved_risingdetect,
+   __raw_writel(bank-context.risingdetect,
bank-base + bank-regs-risingdetect);
l = __raw_readl(bank-base + bank-regs-datain);
 
@@ -1326,14 +1322,15 @@ static int omap_gpio_runtime_resume(struct device *dev)
 * No need to generate IRQs for the rising edge for gpio IRQs
 * configured with falling edge only; and vice versa.
 */
-   gen0 = l  bank-saved_fallingdetect;
+   gen0 = l  bank-context.fallingdetect;
gen0 = bank-saved_datain;
 
-   gen1 = l  bank-saved_risingdetect;
+   gen1 = l  bank-context.risingdetect;
gen1 = ~(bank-saved_datain);
 
/* FIXME: Consider GPIO IRQs with level detections properly! */
-   gen = l  (~(bank-saved_fallingdetect)  ~(bank-saved_risingdetect));
+   gen = l  (~(bank-context.fallingdetect) 
+~(bank-context.risingdetect));
/* Consider all GPIO IRQs needed to be updated */
gen |= gen0 | gen1;
 
-- 
1.7.0.4

--
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 v4 08/12] gpio/omap: remove redundant decoding of gpio offset

2012-03-16 Thread Tarun Kanti DebBarma
In gpio_get(), _get_gpio_datain() and _get_gpio_dataout() get rid of
un-necessary operation to compute gpio mask. The gpio offset passed
to gpio_get() is sufficient to do that.

Here is Russell's original comment:
Can someone explain to me this:
#define GPIO_INDEX(bank, gpio) (gpio % bank-width)
#define GPIO_BIT(bank, gpio) (1  GPIO_INDEX(bank, gpio))

static int _get_gpio_datain(struct gpio_bank *bank, int gpio)
{
   void __iomem *reg = bank-base + bank-regs-datain;

   return (__raw_readl(reg)  GPIO_BIT(bank, gpio)) != 0;
}

static int gpio_get(struct gpio_chip *chip, unsigned offset)
{
   struct gpio_bank *bank = container_of(chip, struct gpio_bank, chip);
   void __iomem *reg = bank-base;
   int gpio = chip-base + offset;
   u32 mask = GPIO_BIT(bank, gpio);

   if (gpio_is_input(bank, mask))
   return _get_gpio_datain(bank, gpio);
   else
   return _get_gpio_dataout(bank, gpio);
}

Given that bank-width on OMAP is either 32 or 16, and GPIO numbers for
any GPIO chip are always aligned to 32 or 16, why does this code bother
adding the chips base gpio number and then modulo the width?

Surely this means if - for argument sake - you registered a GPIO chip
with 8 lines followed by one with 16 lines, GPIO0..7 would be chip 0
bit 0..7, GPIO8..15 would be chip 1 bit 8..15, GPIO16..23 would be
chip 1 bit 0..7.

However, if you registered a GPIO chip with 16 lines first, it would
mean GPIO0..15 would be chip 0 bit 0..15, and GPIO16..31 would be
chip 1 bit 0..15.

Surely this kind of behaviour is not intended?

Is there a reason why the bitmask can't just be (1  offset) where
offset is passed into these functions as GPIO number - chip-base ?

Reported-by: Russell King - ARM Linux li...@arm.linux.org.uk
Signed-off-by: Tarun Kanti DebBarma tarun.ka...@ti.com
Reviewed-by: Santosh Shilimkar santosh.shilim...@ti.com
---
 drivers/gpio/gpio-omap.c |   18 +++---
 1 files changed, 7 insertions(+), 11 deletions(-)

diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
index 8b453dd..cce2c73 100644
--- a/drivers/gpio/gpio-omap.c
+++ b/drivers/gpio/gpio-omap.c
@@ -140,18 +140,18 @@ static void _set_gpio_dataout_mask(struct gpio_bank 
*bank, int gpio, int enable)
bank-context.dataout = l;
 }
 
-static int _get_gpio_datain(struct gpio_bank *bank, int gpio)
+static int _get_gpio_datain(struct gpio_bank *bank, int offset)
 {
void __iomem *reg = bank-base + bank-regs-datain;
 
-   return (__raw_readl(reg)  GPIO_BIT(bank, gpio)) != 0;
+   return (__raw_readl(reg)  (1  offset)) != 0;
 }
 
-static int _get_gpio_dataout(struct gpio_bank *bank, int gpio)
+static int _get_gpio_dataout(struct gpio_bank *bank, int offset)
 {
void __iomem *reg = bank-base + bank-regs-dataout;
 
-   return (__raw_readl(reg)  GPIO_BIT(bank, gpio)) != 0;
+   return (__raw_readl(reg)  (1  offset)) != 0;
 }
 
 static inline void _gpio_rmw(void __iomem *base, u32 reg, u32 mask, bool set)
@@ -852,19 +852,15 @@ static int gpio_is_input(struct gpio_bank *bank, int mask)
 static int gpio_get(struct gpio_chip *chip, unsigned offset)
 {
struct gpio_bank *bank;
-   void __iomem *reg;
-   int gpio;
u32 mask;
 
-   gpio = chip-base + offset;
bank = container_of(chip, struct gpio_bank, chip);
-   reg = bank-base;
-   mask = GPIO_BIT(bank, gpio);
+   mask = (1  offset);
 
if (gpio_is_input(bank, mask))
-   return _get_gpio_datain(bank, gpio);
+   return _get_gpio_datain(bank, offset);
else
-   return _get_gpio_dataout(bank, gpio);
+   return _get_gpio_dataout(bank, offset);
 }
 
 static int gpio_output(struct gpio_chip *chip, unsigned offset, int value)
-- 
1.7.0.4

--
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 v4 05/12] gpio/omap: get rid of retrigger variable in gpio_irq_handler

2012-03-16 Thread Tarun Kanti DebBarma
commit 672e302e3c (ARM: OMAP: use edge/level handlers from generic IRQ
framework) removed retrigger support in favor of using generic IRQ
framework.  This patch cleans up some unused remnants of that removal.

Signed-off-by: Tarun Kanti DebBarma tarun.ka...@ti.com
Reviewed-by: Santosh Shilimkar santosh.shilim...@ti.com
Acked-by: Felipe Balbi ba...@ti.com
---
 drivers/gpio/gpio-omap.c |3 ---
 1 files changed, 0 insertions(+), 3 deletions(-)

diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
index 3b91ade..47143b7 100644
--- a/drivers/gpio/gpio-omap.c
+++ b/drivers/gpio/gpio-omap.c
@@ -627,7 +627,6 @@ static void gpio_irq_handler(unsigned int irq, struct 
irq_desc *desc)
u32 isr;
unsigned int gpio_irq, gpio_index;
struct gpio_bank *bank;
-   u32 retrigger = 0;
int unmasked = 0;
struct irq_chip *chip = irq_desc_get_chip(desc);
 
@@ -664,8 +663,6 @@ static void gpio_irq_handler(unsigned int irq, struct 
irq_desc *desc)
chained_irq_exit(chip, desc);
}
 
-   isr |= retrigger;
-   retrigger = 0;
if (!isr)
break;
 
-- 
1.7.0.4

--
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 v4 10/12] gpio/omap: fix missing dataout context save in _set_gpio_dataout_reg

2012-03-16 Thread Tarun Kanti DebBarma
There are two functions, _set_gpio_dataout_reg() and _set_gpio_dataout_mask()
which writes to dataout register and the dataout context must be saved.
It is missing in the first function, _set_gpio_dataout_reg(). Fix this.

Signed-off-by: Tarun Kanti DebBarma tarun.ka...@ti.com
Reviewed-by: Santosh Shilimkar santosh.shilim...@ti.com
---
 drivers/gpio/gpio-omap.c |7 +--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
index dba69b8..072a841 100644
--- a/drivers/gpio/gpio-omap.c
+++ b/drivers/gpio/gpio-omap.c
@@ -116,10 +116,13 @@ static void _set_gpio_dataout_reg(struct gpio_bank *bank, 
int gpio, int enable)
void __iomem *reg = bank-base;
u32 l = GPIO_BIT(bank, gpio);
 
-   if (enable)
+   if (enable) {
reg += bank-regs-set_dataout;
-   else
+   bank-context.dataout |= l;
+   } else {
reg += bank-regs-clr_dataout;
+   bank-context.dataout = ~l;
+   }
 
__raw_writel(l, reg);
 }
-- 
1.7.0.4

--
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 v4 06/12] gpio/omap: fix trigger type to unsigned

2012-03-16 Thread Tarun Kanti DebBarma
The GPIO trigger parameter is of type unsigned.
enum {
IRQ_TYPE_NONE   = 0x,
IRQ_TYPE_EDGE_RISING= 0x0001,
IRQ_TYPE_EDGE_FALLING   = 0x0002,
IRQ_TYPE_EDGE_BOTH  = (IRQ_TYPE_EDGE_FALLING | 
IRQ_TYPE_EDGE_RISING),
IRQ_TYPE_LEVEL_HIGH = 0x0004,
IRQ_TYPE_LEVEL_LOW  = 0x0008,
IRQ_TYPE_LEVEL_MASK = (IRQ_TYPE_LEVEL_LOW | IRQ_TYPE_LEVEL_HIGH),
IRQ_TYPE_SENSE_MASK = 0x000f,

IRQ_TYPE_PROBE  = 0x0010,
...
};
Even though gpio_irq_type(struct irq_data *d, unsigned type) has the right type
of parameter, the subsequent called functions set_gpio_triggering() and
set_gpio_trigger() wrongly makes it signed integer. Fix this.

Signed-off-by: Tarun Kanti DebBarma tarun.ka...@ti.com
Reviewed-by: Santosh Shilimkar santosh.shilim...@ti.com
Acked-by: Felipe Balbi ba...@ti.com
---
 drivers/gpio/gpio-omap.c |5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
index 47143b7..4d23da1 100644
--- a/drivers/gpio/gpio-omap.c
+++ b/drivers/gpio/gpio-omap.c
@@ -241,7 +241,7 @@ static void _set_gpio_debounce(struct gpio_bank *bank, 
unsigned gpio,
 }
 
 static inline void set_gpio_trigger(struct gpio_bank *bank, int gpio,
-   int trigger)
+   unsigned trigger)
 {
void __iomem *base = bank-base;
u32 gpio_bit = 1  gpio;
@@ -323,7 +323,8 @@ static void _toggle_gpio_edge_triggering(struct gpio_bank 
*bank, int gpio)
 static void _toggle_gpio_edge_triggering(struct gpio_bank *bank, int gpio) {}
 #endif
 
-static int _set_gpio_triggering(struct gpio_bank *bank, int gpio, int trigger)
+static int _set_gpio_triggering(struct gpio_bank *bank, int gpio,
+   unsigned trigger)
 {
void __iomem *reg = bank-base;
void __iomem *base = bank-base;
-- 
1.7.0.4

--
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 v4 03/12] gpio/omap: remove suspend_wakeup field from struct gpio_bank

2012-03-16 Thread Tarun Kanti DebBarma
Since we already have bank-context.wake_en to keep track
of gpios which are wakeup enabled, there is no need to have
this field any more.

Signed-off-by: Tarun Kanti DebBarma tarun.ka...@ti.com
Reviewed-by: Santosh Shilimkar santosh.shilim...@ti.com
Acked-by: Felipe Balbi ba...@ti.com
---
 drivers/gpio/gpio-omap.c |   13 ++---
 1 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
index 171f951..3a4f151 100644
--- a/drivers/gpio/gpio-omap.c
+++ b/drivers/gpio/gpio-omap.c
@@ -57,7 +57,6 @@ struct gpio_bank {
u16 irq;
int irq_base;
struct irq_domain *domain;
-   u32 suspend_wakeup;
u32 saved_wakeup;
u32 non_wakeup_gpios;
u32 enabled_non_wakeup_gpios;
@@ -505,11 +504,11 @@ static int _set_gpio_wakeup(struct gpio_bank *bank, int 
gpio, int enable)
 
spin_lock_irqsave(bank-lock, flags);
if (enable)
-   bank-suspend_wakeup |= gpio_bit;
+   bank-context.wake_en |= gpio_bit;
else
-   bank-suspend_wakeup = ~gpio_bit;
+   bank-context.wake_en = ~gpio_bit;
 
-   __raw_writel(bank-suspend_wakeup, bank-base + bank-regs-wkup_en);
+   __raw_writel(bank-context.wake_en, bank-base + bank-regs-wkup_en);
spin_unlock_irqrestore(bank-lock, flags);
 
return 0;
@@ -779,7 +778,7 @@ static int omap_mpuio_suspend_noirq(struct device *dev)
 
spin_lock_irqsave(bank-lock, flags);
bank-saved_wakeup = __raw_readl(mask_reg);
-   __raw_writel(0x  ~bank-suspend_wakeup, mask_reg);
+   __raw_writel(0x  ~bank-context.wake_en, mask_reg);
spin_unlock_irqrestore(bank-lock, flags);
 
return 0;
@@ -1160,7 +1159,7 @@ static int omap_gpio_suspend(struct device *dev)
if (!bank-mod_usage || !bank-loses_context)
return 0;
 
-   if (!bank-regs-wkup_en || !bank-suspend_wakeup)
+   if (!bank-regs-wkup_en || !bank-context.wake_en)
return 0;
 
wakeup_enable = bank-base + bank-regs-wkup_en;
@@ -1168,7 +1167,7 @@ static int omap_gpio_suspend(struct device *dev)
spin_lock_irqsave(bank-lock, flags);
bank-saved_wakeup = __raw_readl(wakeup_enable);
_gpio_rmw(base, bank-regs-wkup_en, 0x, 0);
-   _gpio_rmw(base, bank-regs-wkup_en, bank-suspend_wakeup, 1);
+   _gpio_rmw(base, bank-regs-wkup_en, bank-context.wake_en, 1);
spin_unlock_irqrestore(bank-lock, flags);
 
return 0;
-- 
1.7.0.4

--
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 v4 09/12] gpio/omap: remove suspend/resume callbacks

2012-03-16 Thread Tarun Kanti DebBarma
Both omap_gpio_suspend() and omap_gpio_resume() does programming
of wakeup_en register.
_gpio_rmw(base, bank-regs-wkup_en, 0x, 0);
_gpio_rmw(base, bank-regs-wkup_en, bank-context.wake_en, 1);

This is redundant in omap_gpio_suspend() because wakeup_en
register automatically gets initialized in _set_gpio_wakeup()
and set_gpio_trigger() while being called either from
chip.irq_set_wake() or chip.irq_set_type().

This is also redundant in omap_gpio_resume() because wakeup_en
register is programmed in omap_gpio_restore_context() called
which is called from runtime resume callback.

Signed-off-by: Tarun Kanti DebBarma tarun.ka...@ti.com
Reviewed-by: Santosh Shilimkar santosh.shilim...@ti.com
---
 drivers/gpio/gpio-omap.c |   47 --
 1 files changed, 0 insertions(+), 47 deletions(-)

diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
index cce2c73..dba69b8 100644
--- a/drivers/gpio/gpio-omap.c
+++ b/drivers/gpio/gpio-omap.c
@@ -1142,50 +1142,6 @@ static int __devinit omap_gpio_probe(struct 
platform_device *pdev)
 
 #ifdef CONFIG_ARCH_OMAP2PLUS
 
-#if defined(CONFIG_PM_SLEEP)
-static int omap_gpio_suspend(struct device *dev)
-{
-   struct platform_device *pdev = to_platform_device(dev);
-   struct gpio_bank *bank = platform_get_drvdata(pdev);
-   void __iomem *base = bank-base;
-   unsigned long flags;
-
-   if (!bank-mod_usage || !bank-loses_context)
-   return 0;
-
-   if (!bank-regs-wkup_en || !bank-context.wake_en)
-   return 0;
-
-   spin_lock_irqsave(bank-lock, flags);
-   _gpio_rmw(base, bank-regs-wkup_en, 0x, 0);
-   _gpio_rmw(base, bank-regs-wkup_en, bank-context.wake_en, 1);
-   spin_unlock_irqrestore(bank-lock, flags);
-
-   return 0;
-}
-
-static int omap_gpio_resume(struct device *dev)
-{
-   struct platform_device *pdev = to_platform_device(dev);
-   struct gpio_bank *bank = platform_get_drvdata(pdev);
-   void __iomem *base = bank-base;
-   unsigned long flags;
-
-   if (!bank-mod_usage || !bank-loses_context)
-   return 0;
-
-   if (!bank-regs-wkup_en || !bank-context.wake_en)
-   return 0;
-
-   spin_lock_irqsave(bank-lock, flags);
-   _gpio_rmw(base, bank-regs-wkup_en, 0x, 0);
-   _gpio_rmw(base, bank-regs-wkup_en, bank-context.wake_en, 1);
-   spin_unlock_irqrestore(bank-lock, flags);
-
-   return 0;
-}
-#endif /* CONFIG_PM_SLEEP */
-
 #if defined(CONFIG_PM_RUNTIME)
 static void omap_gpio_restore_context(struct gpio_bank *bank);
 
@@ -1417,14 +1373,11 @@ static void omap_gpio_restore_context(struct gpio_bank 
*bank)
 }
 #endif /* CONFIG_PM_RUNTIME */
 #else
-#define omap_gpio_suspend NULL
-#define omap_gpio_resume NULL
 #define omap_gpio_runtime_suspend NULL
 #define omap_gpio_runtime_resume NULL
 #endif
 
 static const struct dev_pm_ops gpio_pm_ops = {
-   SET_SYSTEM_SLEEP_PM_OPS(omap_gpio_suspend, omap_gpio_resume)
SET_RUNTIME_PM_OPS(omap_gpio_runtime_suspend, omap_gpio_runtime_resume,
NULL)
 };
-- 
1.7.0.4

--
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 v4 11/12] gpio/omap: fix incorrect context restore logic in omap_gpio_runtime_*

2012-03-16 Thread Tarun Kanti DebBarma
In omap_gpio_runtime_suspend/resume() the context save/restore should
be independent of bank-enabled_non_wakeup_gpios. This was preventing
context restore of GPIO lines which are not wakeup enabled.

Reported-by: Govindraj Raja govindraj.r...@ti.com
Signed-off-by: Tarun Kanti DebBarma tarun.ka...@ti.com
Reviewed-by: Santosh Shilimkar santosh.shilim...@ti.com
---
 drivers/gpio/gpio-omap.c |5 +
 1 files changed, 1 insertions(+), 4 deletions(-)

diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
index 072a841..c5aff7c 100644
--- a/drivers/gpio/gpio-omap.c
+++ b/drivers/gpio/gpio-omap.c
@@ -1187,9 +1187,6 @@ static int omap_gpio_runtime_suspend(struct device *dev)
 * non-wakeup GPIOs.  Otherwise spurious IRQs will be
 * generated.  See OMAP2420 Errata item 1.101.
 */
-   if (!(bank-enabled_non_wakeup_gpios))
-   goto update_gpio_context_count;
-
bank-saved_datain = __raw_readl(bank-base +
bank-regs-datain);
l1 = bank-context.fallingdetect;
@@ -1236,7 +1233,7 @@ static int omap_gpio_runtime_resume(struct device *dev)
__raw_writel(bank-context.risingdetect,
 bank-base + bank-regs-risingdetect);
 
-   if (!bank-enabled_non_wakeup_gpios || !bank-workaround_enabled) {
+   if (!bank-workaround_enabled) {
spin_unlock_irqrestore(bank-lock, flags);
return 0;
}
-- 
1.7.0.4

--
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 v4 12/12] gpio/omap: fix incorrect update to context.irqenable1

2012-03-16 Thread Tarun Kanti DebBarma
In _enable_gpio_irqbank() when bank-regs-set_irqenable is valid,
gpio_mask can be directly set by writing to set_irqenable register
without overwriting current value. In order to ensure the same is
stored in context.irqenable1, we must read from regs-irqenable
instead of overwriting it with gpio_mask.
The overwriting makes sense only in the second case where irqenable
is explicitly read and updated with new gpio_mask before writing it
back. However, for consistency reading regs-irqenable into the
bank-context.irqenable1 takes care of both the scenarios.

if (bank-regs-set_irqenable) {
reg += bank-regs-set_irqenable;
l = gpio_mask;
} else {
reg += bank-regs-irqenable;
l = __raw_readl(reg);
if (bank-regs-irqenable_inv)
l = ~gpio_mask;
else
l |= gpio_mask;
}

Make the same change for _disable_gpio_irqbank().

Signed-off-by: Tarun Kanti DebBarma tarun.ka...@ti.com
Reviewed-by: Santosh Shilimkar santosh.shilim...@ti.com
---
 drivers/gpio/gpio-omap.c |6 --
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
index c5aff7c..ae62c62 100644
--- a/drivers/gpio/gpio-omap.c
+++ b/drivers/gpio/gpio-omap.c
@@ -447,6 +447,7 @@ static void _enable_gpio_irqbank(struct gpio_bank *bank, 
int gpio_mask)
if (bank-regs-set_irqenable) {
reg += bank-regs-set_irqenable;
l = gpio_mask;
+   bank-context.irqenable1 |= gpio_mask;
} else {
reg += bank-regs-irqenable;
l = __raw_readl(reg);
@@ -454,10 +455,10 @@ static void _enable_gpio_irqbank(struct gpio_bank *bank, 
int gpio_mask)
l = ~gpio_mask;
else
l |= gpio_mask;
+   bank-context.irqenable1 = l;
}
 
__raw_writel(l, reg);
-   bank-context.irqenable1 = l;
 }
 
 static void _disable_gpio_irqbank(struct gpio_bank *bank, int gpio_mask)
@@ -468,6 +469,7 @@ static void _disable_gpio_irqbank(struct gpio_bank *bank, 
int gpio_mask)
if (bank-regs-clr_irqenable) {
reg += bank-regs-clr_irqenable;
l = gpio_mask;
+   bank-context.irqenable1 = ~gpio_mask;
} else {
reg += bank-regs-irqenable;
l = __raw_readl(reg);
@@ -475,10 +477,10 @@ static void _disable_gpio_irqbank(struct gpio_bank *bank, 
int gpio_mask)
l |= gpio_mask;
else
l = ~gpio_mask;
+   bank-context.irqenable1 = l;
}
 
__raw_writel(l, reg);
-   bank-context.irqenable1 = l;
 }
 
 static inline void _set_gpio_irqenable(struct gpio_bank *bank, int gpio, int 
enable)
-- 
1.7.0.4

--
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 v4 02/12] gpio/omap: fix wakeup_en register update in _set_gpio_wakeup()

2012-03-16 Thread Tarun Kanti DebBarma
There are two ways through which wakeup_en register can be programmed
using gpiolib APIs as shown below. It is seen that in the second case
in _set_gpio_wakeup(), even though bank-suspend_wakeup is updated
correctly, its value is not programmed in wakeup_en register. Fix this.

chip.irq_set_type()-gpio_irq_type()-_set_gpio_triggering()-set_gpio_trigger()
chip.irq_set_wake()-gpio_wake_enable()-_set_gpio_wakeup()

Signed-off-by: Tarun Kanti DebBarma tarun.ka...@ti.com
---
 drivers/gpio/gpio-omap.c |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
index 0c1c529..171f951 100644
--- a/drivers/gpio/gpio-omap.c
+++ b/drivers/gpio/gpio-omap.c
@@ -509,6 +509,7 @@ static int _set_gpio_wakeup(struct gpio_bank *bank, int 
gpio, int enable)
else
bank-suspend_wakeup = ~gpio_bit;
 
+   __raw_writel(bank-suspend_wakeup, bank-base + bank-regs-wkup_en);
spin_unlock_irqrestore(bank-lock, flags);
 
return 0;
-- 
1.7.0.4

--
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 v3 06/13] gpio/omap: fix trigger type to unsigned

2012-03-07 Thread Tarun Kanti DebBarma
The GPIO trigger parameter is of type unsigned.
enum {
IRQ_TYPE_NONE   = 0x,
IRQ_TYPE_EDGE_RISING= 0x0001,
IRQ_TYPE_EDGE_FALLING   = 0x0002,
IRQ_TYPE_EDGE_BOTH  = (IRQ_TYPE_EDGE_FALLING | 
IRQ_TYPE_EDGE_RISING),
IRQ_TYPE_LEVEL_HIGH = 0x0004,
IRQ_TYPE_LEVEL_LOW  = 0x0008,
IRQ_TYPE_LEVEL_MASK = (IRQ_TYPE_LEVEL_LOW | IRQ_TYPE_LEVEL_HIGH),
IRQ_TYPE_SENSE_MASK = 0x000f,

IRQ_TYPE_PROBE  = 0x0010,
...
};
Even though gpio_irq_type(struct irq_data *d, unsigned type) has the right type
of parameter, the subsequent called functions set_gpio_triggering() and
set_gpio_trigger() wrongly makes it signed integer. Fix this.

Signed-off-by: Tarun Kanti DebBarma tarun.ka...@ti.com
Reviewed-by: Santosh Shilimkar santosh.shilim...@ti.com
Acked-by: Felipe Balbi ba...@ti.com
---
 drivers/gpio/gpio-omap.c |5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
index de5fe8f..bb994db 100644
--- a/drivers/gpio/gpio-omap.c
+++ b/drivers/gpio/gpio-omap.c
@@ -234,7 +234,7 @@ static void _set_gpio_debounce(struct gpio_bank *bank, 
unsigned gpio,
 }
 
 static inline void set_gpio_trigger(struct gpio_bank *bank, int gpio,
-   int trigger)
+   unsigned trigger)
 {
void __iomem *base = bank-base;
u32 gpio_bit = 1  gpio;
@@ -316,7 +316,8 @@ static void _toggle_gpio_edge_triggering(struct gpio_bank 
*bank, int gpio)
 static void _toggle_gpio_edge_triggering(struct gpio_bank *bank, int gpio) {}
 #endif
 
-static int _set_gpio_triggering(struct gpio_bank *bank, int gpio, int trigger)
+static int _set_gpio_triggering(struct gpio_bank *bank, int gpio,
+   unsigned trigger)
 {
void __iomem *reg = bank-base;
void __iomem *base = bank-base;
-- 
1.7.0.4

--
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 v3 09/13] gpio/omap: remove suspend/resume callbacks

2012-03-07 Thread Tarun Kanti DebBarma
Both omap_gpio_suspend() and omap_gpio_resume() does programming
of wakeup_en register.
_gpio_rmw(base, bank-regs-wkup_en, 0x, 0);
_gpio_rmw(base, bank-regs-wkup_en, bank-context.wake_en, 1);

This is redundant in omap_gpio_suspend() because wakeup_en
register automatically gets initialized in _set_gpio_wakeup()
and set_gpio_trigger() while being called either from
chip.irq_set_wake() or chip.irq_set_type().

This is redundant in omap_gpio_resume() because wakeup_en
register is programmed in omap_gpio_restore_context() called
which is called from runtime resume callback.

Signed-off-by: Tarun Kanti DebBarma tarun.ka...@ti.com
---
 drivers/gpio/gpio-omap.c |   47 --
 1 files changed, 0 insertions(+), 47 deletions(-)

diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
index 186ce92..8b4a7ba 100644
--- a/drivers/gpio/gpio-omap.c
+++ b/drivers/gpio/gpio-omap.c
@@ -1132,50 +1132,6 @@ err_exit:
 
 #ifdef CONFIG_ARCH_OMAP2PLUS
 
-#if defined(CONFIG_PM_SLEEP)
-static int omap_gpio_suspend(struct device *dev)
-{
-   struct platform_device *pdev = to_platform_device(dev);
-   struct gpio_bank *bank = platform_get_drvdata(pdev);
-   void __iomem *base = bank-base;
-   unsigned long flags;
-
-   if (!bank-mod_usage || !bank-loses_context)
-   return 0;
-
-   if (!bank-regs-wkup_en || !bank-context.wake_en)
-   return 0;
-
-   spin_lock_irqsave(bank-lock, flags);
-   _gpio_rmw(base, bank-regs-wkup_en, 0x, 0);
-   _gpio_rmw(base, bank-regs-wkup_en, bank-context.wake_en, 1);
-   spin_unlock_irqrestore(bank-lock, flags);
-
-   return 0;
-}
-
-static int omap_gpio_resume(struct device *dev)
-{
-   struct platform_device *pdev = to_platform_device(dev);
-   struct gpio_bank *bank = platform_get_drvdata(pdev);
-   void __iomem *base = bank-base;
-   unsigned long flags;
-
-   if (!bank-mod_usage || !bank-loses_context)
-   return 0;
-
-   if (!bank-regs-wkup_en || !bank-context.wake_en)
-   return 0;
-
-   spin_lock_irqsave(bank-lock, flags);
-   _gpio_rmw(base, bank-regs-wkup_en, 0x, 0);
-   _gpio_rmw(base, bank-regs-wkup_en, bank-context.wake_en, 1);
-   spin_unlock_irqrestore(bank-lock, flags);
-
-   return 0;
-}
-#endif /* CONFIG_PM_SLEEP */
-
 #if defined(CONFIG_PM_RUNTIME)
 static void omap_gpio_restore_context(struct gpio_bank *bank);
 
@@ -1407,14 +1363,11 @@ static void omap_gpio_restore_context(struct gpio_bank 
*bank)
 }
 #endif /* CONFIG_PM_RUNTIME */
 #else
-#define omap_gpio_suspend NULL
-#define omap_gpio_resume NULL
 #define omap_gpio_runtime_suspend NULL
 #define omap_gpio_runtime_resume NULL
 #endif
 
 static const struct dev_pm_ops gpio_pm_ops = {
-   SET_SYSTEM_SLEEP_PM_OPS(omap_gpio_suspend, omap_gpio_resume)
SET_RUNTIME_PM_OPS(omap_gpio_runtime_suspend, omap_gpio_runtime_resume,
NULL)
 };
-- 
1.7.0.4

--
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 v3 12/13] gpio/omap: fix incorrect context restore logic in omap_gpio_runtime_resume

2012-03-07 Thread Tarun Kanti DebBarma
In omap_gpio_runtime_resume() the context restore should be independent
of bank-enabled_non_wakeup_gpios. This was preventing context restore
of GPIO lines which are not wakeup enabled.

Reported-by: Govindraj Raja govindraj.r...@ti.com
Signed-off-by: Tarun Kanti DebBarma tarun.ka...@ti.com
---
 drivers/gpio/gpio-omap.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
index 2e8e476..ccfbae0 100644
--- a/drivers/gpio/gpio-omap.c
+++ b/drivers/gpio/gpio-omap.c
@@ -1227,7 +1227,7 @@ static int omap_gpio_runtime_resume(struct device *dev)
__raw_writel(bank-context.risingdetect,
 bank-base + bank-regs-risingdetect);
 
-   if (!bank-enabled_non_wakeup_gpios || !bank-workaround_enabled) {
+   if (!bank-workaround_enabled) {
spin_unlock_irqrestore(bank-lock, flags);
return 0;
}
-- 
1.7.0.4

--
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 v3 13/13] gpio/omap: fix incorrect update to context.irqenable1

2012-03-07 Thread Tarun Kanti DebBarma
In _enable_gpio_irqbank() when bank-regs-set_irqenable is valid,
gpio_mask can be directly set by writing to set_irqenable register
without overwriting current value. In order to ensure the same is
stored in context.irqenable1, we must read from regs-irqenable
instead of overwriting it with gpio_mask.
The overwriting makes sense only in the second case where irqenable
is explicitly read and updated with new gpio_mask before writing it
back. However, for consistency reading regs-irqenable into the
bank-context.irqenable1 takes care of both the scenarios.

if (bank-regs-set_irqenable) {
reg += bank-regs-set_irqenable;
l = gpio_mask;
} else {
reg += bank-regs-irqenable;
l = __raw_readl(reg);
if (bank-regs-irqenable_inv)
l = ~gpio_mask;
else
l |= gpio_mask;
}

Make the same change for _disable_gpio_irqbank().

Signed-off-by: Tarun Kanti DebBarma tarun.ka...@ti.com
---
 drivers/gpio/gpio-omap.c |6 --
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
index ccfbae0..8b0d3ab 100644
--- a/drivers/gpio/gpio-omap.c
+++ b/drivers/gpio/gpio-omap.c
@@ -453,7 +453,8 @@ static void _enable_gpio_irqbank(struct gpio_bank *bank, 
int gpio_mask)
}
 
__raw_writel(l, reg);
-   bank-context.irqenable1 = l;
+   bank-context.irqenable1 =
+   __raw_readl(bank-base + bank-regs-irqenable);
 }
 
 static void _disable_gpio_irqbank(struct gpio_bank *bank, int gpio_mask)
@@ -474,7 +475,8 @@ static void _disable_gpio_irqbank(struct gpio_bank *bank, 
int gpio_mask)
}
 
__raw_writel(l, reg);
-   bank-context.irqenable1 = l;
+   bank-context.irqenable1 =
+   __raw_readl(bank-base + bank-regs-irqenable);
 }
 
 static inline void _set_gpio_irqenable(struct gpio_bank *bank, int gpio, int 
enable)
-- 
1.7.0.4

--
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 v3 03/13] gpio/omap: remove suspend_wakeup field from struct gpio_bank

2012-03-07 Thread Tarun Kanti DebBarma
Since we already have bank-context.wake_en to keep track
of gpios which are wakeup enabled, there is no need to have
this field any more.

Signed-off-by: Tarun Kanti DebBarma tarun.ka...@ti.com
Reviewed-by: Santosh Shilimkar santosh.shilim...@ti.com
Acked-by: Felipe Balbi ba...@ti.com
---
 drivers/gpio/gpio-omap.c |   13 ++---
 1 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
index 895df7f..14c61e2 100644
--- a/drivers/gpio/gpio-omap.c
+++ b/drivers/gpio/gpio-omap.c
@@ -54,7 +54,6 @@ struct gpio_bank {
void __iomem *base;
u16 irq;
u16 virtual_irq_start;
-   u32 suspend_wakeup;
u32 saved_wakeup;
u32 non_wakeup_gpios;
u32 enabled_non_wakeup_gpios;
@@ -500,11 +499,11 @@ static int _set_gpio_wakeup(struct gpio_bank *bank, int 
gpio, int enable)
 
spin_lock_irqsave(bank-lock, flags);
if (enable)
-   bank-suspend_wakeup |= gpio_bit;
+   bank-context.wake_en |= gpio_bit;
else
-   bank-suspend_wakeup = ~gpio_bit;
+   bank-context.wake_en = ~gpio_bit;
 
-   __raw_writel(bank-suspend_wakeup, bank-base + bank-regs-wkup_en);
+   __raw_writel(bank-context.wake_en, bank-base + bank-regs-wkup_en);
spin_unlock_irqrestore(bank-lock, flags);
 
return 0;
@@ -776,7 +775,7 @@ static int omap_mpuio_suspend_noirq(struct device *dev)
 
spin_lock_irqsave(bank-lock, flags);
bank-saved_wakeup = __raw_readl(mask_reg);
-   __raw_writel(0x  ~bank-suspend_wakeup, mask_reg);
+   __raw_writel(0x  ~bank-context.wake_en, mask_reg);
spin_unlock_irqrestore(bank-lock, flags);
 
return 0;
@@ -1150,7 +1149,7 @@ static int omap_gpio_suspend(struct device *dev)
if (!bank-mod_usage || !bank-loses_context)
return 0;
 
-   if (!bank-regs-wkup_en || !bank-suspend_wakeup)
+   if (!bank-regs-wkup_en || !bank-context.wake_en)
return 0;
 
wakeup_enable = bank-base + bank-regs-wkup_en;
@@ -1158,7 +1157,7 @@ static int omap_gpio_suspend(struct device *dev)
spin_lock_irqsave(bank-lock, flags);
bank-saved_wakeup = __raw_readl(wakeup_enable);
_gpio_rmw(base, bank-regs-wkup_en, 0x, 0);
-   _gpio_rmw(base, bank-regs-wkup_en, bank-suspend_wakeup, 1);
+   _gpio_rmw(base, bank-regs-wkup_en, bank-context.wake_en, 1);
spin_unlock_irqrestore(bank-lock, flags);
 
return 0;
-- 
1.7.0.4

--
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 v3 02/13] gpio/omap: fix wakeup_en register update in _set_gpio_wakeup()

2012-03-07 Thread Tarun Kanti DebBarma
There are two ways through which wakeup_en register can be programmed
using gpiolib APIs as shown below. It is seen that in the second case
in _set_gpio_wakeup(), even though bank-suspend_wakeup is updated
correctly, its value is not programmed in wakeup_en register. Fix this.

chip.irq_set_type()-gpio_irq_type()-_set_gpio_triggering()-set_gpio_trigger()
chip.irq_set_wake()-gpio_wake_enable()-_set_gpio_wakeup()

Signed-off-by: Tarun Kanti DebBarma tarun.ka...@ti.com
---
 drivers/gpio/gpio-omap.c |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
index c9369d2..895df7f 100644
--- a/drivers/gpio/gpio-omap.c
+++ b/drivers/gpio/gpio-omap.c
@@ -504,6 +504,7 @@ static int _set_gpio_wakeup(struct gpio_bank *bank, int 
gpio, int enable)
else
bank-suspend_wakeup = ~gpio_bit;
 
+   __raw_writel(bank-suspend_wakeup, bank-base + bank-regs-wkup_en);
spin_unlock_irqrestore(bank-lock, flags);
 
return 0;
-- 
1.7.0.4

--
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 v3 07/13] gpio/omap: fix _set_gpio_irqenable implementation

2012-03-07 Thread Tarun Kanti DebBarma
This function should be capable of both enabling and disabling interrupts
based upon the *enable* parameter. Right now the function only enables
the interrupt and *enable* is not used at all. So add the interrupt
disable capability also using the parameter.

Signed-off-by: Tarun Kanti DebBarma tarun.ka...@ti.com
Reviewed-by: Santosh Shilimkar santosh.shilim...@ti.com
Acked-by: Felipe Balbi ba...@ti.com
---
 drivers/gpio/gpio-omap.c |5 -
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
index bb994db..19f8f44 100644
--- a/drivers/gpio/gpio-omap.c
+++ b/drivers/gpio/gpio-omap.c
@@ -475,7 +475,10 @@ static void _disable_gpio_irqbank(struct gpio_bank *bank, 
int gpio_mask)
 
 static inline void _set_gpio_irqenable(struct gpio_bank *bank, int gpio, int 
enable)
 {
-   _enable_gpio_irqbank(bank, GPIO_BIT(bank, gpio));
+   if (enable)
+   _enable_gpio_irqbank(bank, GPIO_BIT(bank, gpio));
+   else
+   _disable_gpio_irqbank(bank, GPIO_BIT(bank, gpio));
 }
 
 /*
-- 
1.7.0.4

--
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 v3 11/13] gpio/omap: fix dataout register overwrite in _set_gpio_dataout_*

2012-03-07 Thread Tarun Kanti DebBarma
In the existing _set_gpio_dataout_*() implementation, the dataout
register is overwritten every time the function is called. This is
not intended behavior because that would end up one user of a GPIO
line overwriting what is written by another. Fix this so that previous
value is always preserved until explicitly changed by respective
user/driver of the GPIO line.

Signed-off-by: Tarun Kanti DebBarma tarun.ka...@ti.com
---
 drivers/gpio/gpio-omap.c |3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
index 04c2677..2e8e476 100644
--- a/drivers/gpio/gpio-omap.c
+++ b/drivers/gpio/gpio-omap.c
@@ -114,6 +114,7 @@ static void _set_gpio_dataout_reg(struct gpio_bank *bank, 
int gpio, int enable)
else
reg += bank-regs-clr_dataout;
 
+   l |= __raw_readl(bank-base + bank-regs-set_dataout);
__raw_writel(l, reg);
bank-context.dataout = l;
 }
@@ -130,6 +131,8 @@ static void _set_gpio_dataout_mask(struct gpio_bank *bank, 
int gpio, int enable)
l |= gpio_bit;
else
l = ~gpio_bit;
+
+   l |= __raw_readl(bank-base + bank-regs-set_dataout);
__raw_writel(l, reg);
bank-context.dataout = l;
 }
-- 
1.7.0.4

--
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 v3 10/13] gpio/omap: fix missing dataout context save in _set_gpio_dataout_reg

2012-03-07 Thread Tarun Kanti DebBarma
There are two functions, _set_gpio_dataout_reg() and _set_gpio_dataout_mask()
which writes to dataout register and the dataout context must be saved.
It is missing in the first function, _set_gpio_dataout_reg(). Fix this.

Reported-by: Govindraj Raja govindraj.r...@ti.com
Signed-off-by: Tarun Kanti DebBarma tarun.ka...@ti.com
---
 drivers/gpio/gpio-omap.c |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
index 8b4a7ba..04c2677 100644
--- a/drivers/gpio/gpio-omap.c
+++ b/drivers/gpio/gpio-omap.c
@@ -115,6 +115,7 @@ static void _set_gpio_dataout_reg(struct gpio_bank *bank, 
int gpio, int enable)
reg += bank-regs-clr_dataout;
 
__raw_writel(l, reg);
+   bank-context.dataout = l;
 }
 
 /* set data out value using mask register */
-- 
1.7.0.4

--
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 v3 01/13] gpio/omap: remove saved_fallingdetect, saved_risingdetect fields

2012-03-07 Thread Tarun Kanti DebBarma
Since we already have context.fallingdetect and context.risingdetect
there is no more need to have these additional fields. Also, getting
rid of extra reads associated with them.

Signed-off-by: Tarun Kanti DebBarma tarun.ka...@ti.com
Reviewed-by: Santosh Shilimkar santosh.shilim...@ti.com
Acked-by: Felipe Balbi ba...@ti.com
---
 drivers/gpio/gpio-omap.c |   19 ---
 1 files changed, 8 insertions(+), 11 deletions(-)

diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
index 752ae9b..c9369d2 100644
--- a/drivers/gpio/gpio-omap.c
+++ b/drivers/gpio/gpio-omap.c
@@ -60,8 +60,6 @@ struct gpio_bank {
u32 enabled_non_wakeup_gpios;
struct gpio_regs context;
u32 saved_datain;
-   u32 saved_fallingdetect;
-   u32 saved_risingdetect;
u32 level_mask;
u32 toggle_mask;
spinlock_t lock;
@@ -1234,11 +1232,9 @@ static int omap_gpio_runtime_suspend(struct device *dev)
 
bank-saved_datain = __raw_readl(bank-base +
bank-regs-datain);
-   l1 = __raw_readl(bank-base + bank-regs-fallingdetect);
-   l2 = __raw_readl(bank-base + bank-regs-risingdetect);
+   l1 = bank-context.fallingdetect;
+   l2 = bank-context.risingdetect;
 
-   bank-saved_fallingdetect = l1;
-   bank-saved_risingdetect = l2;
l1 = ~bank-enabled_non_wakeup_gpios;
l2 = ~bank-enabled_non_wakeup_gpios;
 
@@ -1297,9 +1293,9 @@ static int omap_gpio_runtime_resume(struct device *dev)
}
}
 
-   __raw_writel(bank-saved_fallingdetect,
+   __raw_writel(bank-context.fallingdetect,
bank-base + bank-regs-fallingdetect);
-   __raw_writel(bank-saved_risingdetect,
+   __raw_writel(bank-context.risingdetect,
bank-base + bank-regs-risingdetect);
l = __raw_readl(bank-base + bank-regs-datain);
 
@@ -1316,14 +1312,15 @@ static int omap_gpio_runtime_resume(struct device *dev)
 * No need to generate IRQs for the rising edge for gpio IRQs
 * configured with falling edge only; and vice versa.
 */
-   gen0 = l  bank-saved_fallingdetect;
+   gen0 = l  bank-context.fallingdetect;
gen0 = bank-saved_datain;
 
-   gen1 = l  bank-saved_risingdetect;
+   gen1 = l  bank-context.risingdetect;
gen1 = ~(bank-saved_datain);
 
/* FIXME: Consider GPIO IRQs with level detections properly! */
-   gen = l  (~(bank-saved_fallingdetect)  ~(bank-saved_risingdetect));
+   gen = l  (~(bank-context.fallingdetect) 
+~(bank-context.risingdetect));
/* Consider all GPIO IRQs needed to be updated */
gen |= gen0 | gen1;
 
-- 
1.7.0.4

--
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 v3 00/13] gpio/omap: Some more driver cleanup and fixes

2012-03-07 Thread Tarun Kanti DebBarma
The cleanup is mostly getting rid of redundant fields in struct gpio_bank{}
as we already have them as part of bank-context now. Also, remove un-used
variable from gpio_irq_handler.

The fixes include correction of _set_gpio_irqenable() implementation,
missing wakeup_en register update in set_gpio_wakeup(), type mismatch
of gpio trigger parameter in set_gpio_trigger(), incorrect dataout
register update in set_gpio_dataout_() and few corrections in context
save logic.

It is baselined on top of Kevin's following series:
gpio/omap: cleanup and runtime PM conversion for v3.4
git://git.kernel.org/pub/scm/linux/kernel/git/khilman/linux-omap-pm.git 
for_3.4/gpio/runtime-pm-cleanup

Series is available here for reference:
git://gitorious.org/~tarunkanti/omap-sw-develoment/tarunkantis-linux-omap-dev 
for_3.4/gpio_further_cleanup_fixes

Power Test: Off-mode and Retention on OMAP3430 (Suspend and Idle paths).
Functional Test: OMAP2430, OMAP3430SDP, ZOOM3, OMAP4430, OMAP4-BLAZE

v3:
- Added 4 more additional patches to the previous series
  which are all bug fixes.

v2:
- Added a new patch to update wakeup_en register in _set_gpio_wakeup()
 in addition to updating bank-context.wake_en.

- Added a new patch to remove redundant decoding of gpio offset in
 gpio_get(), _get_gpio_datain() and _get_gpio_dataout().

- Added a new patch to remove suspend/resume callbacks because the
 operations performed with the callbacks are redundant.

Tarun Kanti DebBarma (13):
  gpio/omap: remove saved_fallingdetect, saved_risingdetect fields
  gpio/omap: fix wakeup_en register update in _set_gpio_wakeup()
  gpio/omap: remove suspend_wakeup field from struct gpio_bank
  gpio/omap: remove saved_wakeup field from struct gpio_bank
  gpio/omap: get rid of retrigger variable in gpio_irq_handler
  gpio/omap: fix trigger type to unsigned
  gpio/omap: fix _set_gpio_irqenable implementation
  gpio/omap: remove redundant decoding of gpio offset
  gpio/omap: remove suspend/resume callbacks
  gpio/omap: fix missing dataout context save in _set_gpio_dataout_reg
  gpio/omap: fix dataout register overwrite in _set_gpio_dataout_*
  gpio/omap: fix incorrect context restore logic in omap_gpio_runtime_resume
  gpio/omap: fix incorrect update to context.irqenable1

 drivers/gpio/gpio-omap.c |  125 +
 1 files changed, 36 insertions(+), 89 deletions(-)

--
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 v3 05/13] gpio/omap: get rid of retrigger variable in gpio_irq_handler

2012-03-07 Thread Tarun Kanti DebBarma
This local variable is just assigned zero and then OR'ed
with isr. It does not appear to serve any purpose and so
removing it.

Signed-off-by: Tarun Kanti DebBarma tarun.ka...@ti.com
Reviewed-by: Santosh Shilimkar santosh.shilim...@ti.com
Acked-by: Felipe Balbi ba...@ti.com
---
 drivers/gpio/gpio-omap.c |3 ---
 1 files changed, 0 insertions(+), 3 deletions(-)

diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
index 3765654..de5fe8f 100644
--- a/drivers/gpio/gpio-omap.c
+++ b/drivers/gpio/gpio-omap.c
@@ -626,7 +626,6 @@ static void gpio_irq_handler(unsigned int irq, struct 
irq_desc *desc)
u32 isr;
unsigned int gpio_irq, gpio_index;
struct gpio_bank *bank;
-   u32 retrigger = 0;
int unmasked = 0;
struct irq_chip *chip = irq_desc_get_chip(desc);
 
@@ -663,8 +662,6 @@ static void gpio_irq_handler(unsigned int irq, struct 
irq_desc *desc)
chained_irq_exit(chip, desc);
}
 
-   isr |= retrigger;
-   retrigger = 0;
if (!isr)
break;
 
-- 
1.7.0.4

--
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 v3 08/13] gpio/omap: remove redundant decoding of gpio offset

2012-03-07 Thread Tarun Kanti DebBarma
In gpio_get(), _get_gpio_datain() and _get_gpio_dataout() get rid of
un-necessary operation to compute gpio mask. The gpio offset passed
to gpio_get() is sufficient to do that.

Here is Russell's original comment:
Can someone explain to me this:
#define GPIO_INDEX(bank, gpio) (gpio % bank-width)
#define GPIO_BIT(bank, gpio) (1  GPIO_INDEX(bank, gpio))

static int _get_gpio_datain(struct gpio_bank *bank, int gpio)
{
   void __iomem *reg = bank-base + bank-regs-datain;

   return (__raw_readl(reg)  GPIO_BIT(bank, gpio)) != 0;
}

static int gpio_get(struct gpio_chip *chip, unsigned offset)
{
   struct gpio_bank *bank = container_of(chip, struct gpio_bank, chip);
   void __iomem *reg = bank-base;
   int gpio = chip-base + offset;
   u32 mask = GPIO_BIT(bank, gpio);

   if (gpio_is_input(bank, mask))
   return _get_gpio_datain(bank, gpio);
   else
   return _get_gpio_dataout(bank, gpio);
}

Given that bank-width on OMAP is either 32 or 16, and GPIO numbers for
any GPIO chip are always aligned to 32 or 16, why does this code bother
adding the chips base gpio number and then modulo the width?

Surely this means if - for argument sake - you registered a GPIO chip
with 8 lines followed by one with 16 lines, GPIO0..7 would be chip 0
bit 0..7, GPIO8..15 would be chip 1 bit 8..15, GPIO16..23 would be
chip 1 bit 0..7.

However, if you registered a GPIO chip with 16 lines first, it would
mean GPIO0..15 would be chip 0 bit 0..15, and GPIO16..31 would be
chip 1 bit 0..15.

Surely this kind of behaviour is not intended?

Is there a reason why the bitmask can't just be (1  offset) where
offset is passed into these functions as GPIO number - chip-base ?

Reported-by: Russell King - ARM Linux li...@arm.linux.org.uk
Signed-off-by: Tarun Kanti DebBarma tarun.ka...@ti.com
---
 drivers/gpio/gpio-omap.c |   18 +++---
 1 files changed, 7 insertions(+), 11 deletions(-)

diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
index 19f8f44..186ce92 100644
--- a/drivers/gpio/gpio-omap.c
+++ b/drivers/gpio/gpio-omap.c
@@ -133,18 +133,18 @@ static void _set_gpio_dataout_mask(struct gpio_bank 
*bank, int gpio, int enable)
bank-context.dataout = l;
 }
 
-static int _get_gpio_datain(struct gpio_bank *bank, int gpio)
+static int _get_gpio_datain(struct gpio_bank *bank, int offset)
 {
void __iomem *reg = bank-base + bank-regs-datain;
 
-   return (__raw_readl(reg)  GPIO_BIT(bank, gpio)) != 0;
+   return (__raw_readl(reg)  (1  offset)) != 0;
 }
 
-static int _get_gpio_dataout(struct gpio_bank *bank, int gpio)
+static int _get_gpio_dataout(struct gpio_bank *bank, int offset)
 {
void __iomem *reg = bank-base + bank-regs-dataout;
 
-   return (__raw_readl(reg)  GPIO_BIT(bank, gpio)) != 0;
+   return (__raw_readl(reg)  (1  offset)) != 0;
 }
 
 static inline void _gpio_rmw(void __iomem *base, u32 reg, u32 mask, bool set)
@@ -849,19 +849,15 @@ static int gpio_is_input(struct gpio_bank *bank, int mask)
 static int gpio_get(struct gpio_chip *chip, unsigned offset)
 {
struct gpio_bank *bank;
-   void __iomem *reg;
-   int gpio;
u32 mask;
 
-   gpio = chip-base + offset;
bank = container_of(chip, struct gpio_bank, chip);
-   reg = bank-base;
-   mask = GPIO_BIT(bank, gpio);
+   mask = (1  offset);
 
if (gpio_is_input(bank, mask))
-   return _get_gpio_datain(bank, gpio);
+   return _get_gpio_datain(bank, offset);
else
-   return _get_gpio_dataout(bank, gpio);
+   return _get_gpio_dataout(bank, offset);
 }
 
 static int gpio_output(struct gpio_chip *chip, unsigned offset, int value)
-- 
1.7.0.4

--
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 v3 04/13] gpio/omap: remove saved_wakeup field from struct gpio_bank

2012-03-07 Thread Tarun Kanti DebBarma
There is no more need to have saved_wakeup because bank-context.wake_en
already holds that value. So getting rid of read/write operation associated
with this field.

Signed-off-by: Tarun Kanti DebBarma tarun.ka...@ti.com
Reviewed-by: Santosh Shilimkar santosh.shilim...@ti.com
Acked-by: Felipe Balbi ba...@ti.com
---
 drivers/gpio/gpio-omap.c |   12 +++-
 1 files changed, 3 insertions(+), 9 deletions(-)

diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
index 14c61e2..3765654 100644
--- a/drivers/gpio/gpio-omap.c
+++ b/drivers/gpio/gpio-omap.c
@@ -54,7 +54,6 @@ struct gpio_bank {
void __iomem *base;
u16 irq;
u16 virtual_irq_start;
-   u32 saved_wakeup;
u32 non_wakeup_gpios;
u32 enabled_non_wakeup_gpios;
struct gpio_regs context;
@@ -774,7 +773,6 @@ static int omap_mpuio_suspend_noirq(struct device *dev)
unsigned long   flags;
 
spin_lock_irqsave(bank-lock, flags);
-   bank-saved_wakeup = __raw_readl(mask_reg);
__raw_writel(0x  ~bank-context.wake_en, mask_reg);
spin_unlock_irqrestore(bank-lock, flags);
 
@@ -790,7 +788,7 @@ static int omap_mpuio_resume_noirq(struct device *dev)
unsigned long   flags;
 
spin_lock_irqsave(bank-lock, flags);
-   __raw_writel(bank-saved_wakeup, mask_reg);
+   __raw_writel(bank-context.wake_en, mask_reg);
spin_unlock_irqrestore(bank-lock, flags);
 
return 0;
@@ -1143,7 +1141,6 @@ static int omap_gpio_suspend(struct device *dev)
struct platform_device *pdev = to_platform_device(dev);
struct gpio_bank *bank = platform_get_drvdata(pdev);
void __iomem *base = bank-base;
-   void __iomem *wakeup_enable;
unsigned long flags;
 
if (!bank-mod_usage || !bank-loses_context)
@@ -1152,10 +1149,7 @@ static int omap_gpio_suspend(struct device *dev)
if (!bank-regs-wkup_en || !bank-context.wake_en)
return 0;
 
-   wakeup_enable = bank-base + bank-regs-wkup_en;
-
spin_lock_irqsave(bank-lock, flags);
-   bank-saved_wakeup = __raw_readl(wakeup_enable);
_gpio_rmw(base, bank-regs-wkup_en, 0x, 0);
_gpio_rmw(base, bank-regs-wkup_en, bank-context.wake_en, 1);
spin_unlock_irqrestore(bank-lock, flags);
@@ -1173,12 +1167,12 @@ static int omap_gpio_resume(struct device *dev)
if (!bank-mod_usage || !bank-loses_context)
return 0;
 
-   if (!bank-regs-wkup_en || !bank-saved_wakeup)
+   if (!bank-regs-wkup_en || !bank-context.wake_en)
return 0;
 
spin_lock_irqsave(bank-lock, flags);
_gpio_rmw(base, bank-regs-wkup_en, 0x, 0);
-   _gpio_rmw(base, bank-regs-wkup_en, bank-saved_wakeup, 1);
+   _gpio_rmw(base, bank-regs-wkup_en, bank-context.wake_en, 1);
spin_unlock_irqrestore(bank-lock, flags);
 
return 0;
-- 
1.7.0.4

--
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 v2 2/9] gpio/omap: fix wakeup_en register update in _set_gpio_wakeup()

2012-02-29 Thread Tarun Kanti DebBarma
There are two ways through which wakeup_en register can be programmed
using gpiolib APIs as shown below. It is seen that in the second case
in _set_gpio_wakeup(), even though bank-suspend_wakeup is updated
correctly, its value is not programmed in wakeup_en register. Fix this.

chip.irq_set_type()-gpio_irq_type()-_set_gpio_triggering()-set_gpio_trigger()
chip.irq_set_wake()-gpio_wake_enable()-_set_gpio_wakeup()

Signed-off-by: Tarun Kanti DebBarma tarun.ka...@ti.com
---
 drivers/gpio/gpio-omap.c |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
index c9369d2..895df7f 100644
--- a/drivers/gpio/gpio-omap.c
+++ b/drivers/gpio/gpio-omap.c
@@ -504,6 +504,7 @@ static int _set_gpio_wakeup(struct gpio_bank *bank, int 
gpio, int enable)
else
bank-suspend_wakeup = ~gpio_bit;
 
+   __raw_writel(bank-suspend_wakeup, bank-base + bank-regs-wkup_en);
spin_unlock_irqrestore(bank-lock, flags);
 
return 0;
-- 
1.7.0.4

--
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 v2 0/9] gpio/omap: Some more driver cleanup and fixes

2012-02-29 Thread Tarun Kanti DebBarma
The cleanup is mostly getting rid of redundant fields in struct gpio_bank{}
as we already have them as part of bank-context now. Also, remove un-used
variable from gpio_irq_handler.

The fix include correction of _set_gpio_irqenable() implementation and fix
type mismatch of gpio trigger parameter.

It is baselined on top of Kevin's following series:
gpio/omap: cleanup and runtime PM conversion for v3.4
git://git.kernel.org/pub/scm/linux/kernel/git/khilman/linux-omap-pm.git 
for_3.4/gpio/runtime-pm-cleanup

Series is available here for reference:
git://gitorious.org/~tarunkanti/omap-sw-develoment/tarunkantis-linux-omap-dev 
for_3.4/gpio_further_cleanup_fixes

Power Test: Off-mode and Retention on OMAP3430 (Suspend and Idle paths).
Functional Test: OMAP2430, OMAP3430SDP, ZOOM3, OMAP4430, OMAP4-BLAZE

v2:
- Added a new patch to update wakeup_en register in _set_gpio_wakeup()
  in addition to updating bank-context.wake_en.

- Added a new patch to remove redundant decoding of gpio offset in
  gpio_get(), _get_gpio_datain() and _get_gpio_dataout().

- Added a new patch to remove suspend/resume callbacks because the
  operations performed with the callbacks are redundant.

Tarun Kanti DebBarma (9):
  gpio/omap: remove saved_fallingdetect, saved_risingdetect fields
  gpio/omap: fix wakeup_en register update in _set_gpio_wakeup()
  gpio/omap: remove suspend_wakeup field from struct gpio_bank
  gpio/omap: remove saved_wakeup field from struct gpio_bank
  gpio/omap: get rid of retrigger variable in gpio_irq_handler
  gpio/omap: fix trigger type to unsigned
  gpio/omap: fix _set_gpio_irqenable implementation
  gpio/omap: remove redundant decoding of gpio offset
  gpio/omap: remove suspend/resume callbacks

 drivers/gpio/gpio-omap.c |  113 +++---
 1 files changed, 27 insertions(+), 86 deletions(-)

--
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 v2 8/9] gpio/omap: remove redundant decoding of gpio offset

2012-02-29 Thread Tarun Kanti DebBarma
In gpio_get(), _get_gpio_datain() and _get_gpio_dataout() get rid of
un-necessary operation to compute gpio mask. The gpio offset passed
to gpio_get() is sufficient to do that.

Here is Russell's original comment:
Can someone explain to me this:
#define GPIO_INDEX(bank, gpio) (gpio % bank-width)
#define GPIO_BIT(bank, gpio) (1  GPIO_INDEX(bank, gpio))

static int _get_gpio_datain(struct gpio_bank *bank, int gpio)
{
   void __iomem *reg = bank-base + bank-regs-datain;

   return (__raw_readl(reg)  GPIO_BIT(bank, gpio)) != 0;
}

static int gpio_get(struct gpio_chip *chip, unsigned offset)
{
   struct gpio_bank *bank = container_of(chip, struct gpio_bank, chip);
   void __iomem *reg = bank-base;
   int gpio = chip-base + offset;
   u32 mask = GPIO_BIT(bank, gpio);

   if (gpio_is_input(bank, mask))
   return _get_gpio_datain(bank, gpio);
   else
   return _get_gpio_dataout(bank, gpio);
}

Given that bank-width on OMAP is either 32 or 16, and GPIO numbers for
any GPIO chip are always aligned to 32 or 16, why does this code bother
adding the chips base gpio number and then modulo the width?

Surely this means if - for argument sake - you registered a GPIO chip
with 8 lines followed by one with 16 lines, GPIO0..7 would be chip 0
bit 0..7, GPIO8..15 would be chip 1 bit 8..15, GPIO16..23 would be
chip 1 bit 0..7.

However, if you registered a GPIO chip with 16 lines first, it would
mean GPIO0..15 would be chip 0 bit 0..15, and GPIO16..31 would be
chip 1 bit 0..15.

Surely this kind of behaviour is not intended?

Is there a reason why the bitmask can't just be (1  offset) where
offset is passed into these functions as GPIO number - chip-base ?

Reported-by: Russell King - ARM Linux li...@arm.linux.org.uk
Signed-off-by: Tarun Kanti DebBarma tarun.ka...@ti.com
---
 drivers/gpio/gpio-omap.c |   18 +++---
 1 files changed, 7 insertions(+), 11 deletions(-)

diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
index 19f8f44..186ce92 100644
--- a/drivers/gpio/gpio-omap.c
+++ b/drivers/gpio/gpio-omap.c
@@ -133,18 +133,18 @@ static void _set_gpio_dataout_mask(struct gpio_bank 
*bank, int gpio, int enable)
bank-context.dataout = l;
 }
 
-static int _get_gpio_datain(struct gpio_bank *bank, int gpio)
+static int _get_gpio_datain(struct gpio_bank *bank, int offset)
 {
void __iomem *reg = bank-base + bank-regs-datain;
 
-   return (__raw_readl(reg)  GPIO_BIT(bank, gpio)) != 0;
+   return (__raw_readl(reg)  (1  offset)) != 0;
 }
 
-static int _get_gpio_dataout(struct gpio_bank *bank, int gpio)
+static int _get_gpio_dataout(struct gpio_bank *bank, int offset)
 {
void __iomem *reg = bank-base + bank-regs-dataout;
 
-   return (__raw_readl(reg)  GPIO_BIT(bank, gpio)) != 0;
+   return (__raw_readl(reg)  (1  offset)) != 0;
 }
 
 static inline void _gpio_rmw(void __iomem *base, u32 reg, u32 mask, bool set)
@@ -849,19 +849,15 @@ static int gpio_is_input(struct gpio_bank *bank, int mask)
 static int gpio_get(struct gpio_chip *chip, unsigned offset)
 {
struct gpio_bank *bank;
-   void __iomem *reg;
-   int gpio;
u32 mask;
 
-   gpio = chip-base + offset;
bank = container_of(chip, struct gpio_bank, chip);
-   reg = bank-base;
-   mask = GPIO_BIT(bank, gpio);
+   mask = (1  offset);
 
if (gpio_is_input(bank, mask))
-   return _get_gpio_datain(bank, gpio);
+   return _get_gpio_datain(bank, offset);
else
-   return _get_gpio_dataout(bank, gpio);
+   return _get_gpio_dataout(bank, offset);
 }
 
 static int gpio_output(struct gpio_chip *chip, unsigned offset, int value)
-- 
1.7.0.4

--
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 v2 1/9] gpio/omap: remove saved_fallingdetect, saved_risingdetect fields

2012-02-29 Thread Tarun Kanti DebBarma
Since we already have context.fallingdetect and context.risingdetect
there is no more need to have these additional fields. Also, getting
rid of extra reads associated with them.

Signed-off-by: Tarun Kanti DebBarma tarun.ka...@ti.com
Reviewed-by: Santosh Shilimkar santosh.shilim...@ti.com
Acked-by: Felipe Balbi ba...@ti.com
---
 drivers/gpio/gpio-omap.c |   19 ---
 1 files changed, 8 insertions(+), 11 deletions(-)

diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
index 752ae9b..c9369d2 100644
--- a/drivers/gpio/gpio-omap.c
+++ b/drivers/gpio/gpio-omap.c
@@ -60,8 +60,6 @@ struct gpio_bank {
u32 enabled_non_wakeup_gpios;
struct gpio_regs context;
u32 saved_datain;
-   u32 saved_fallingdetect;
-   u32 saved_risingdetect;
u32 level_mask;
u32 toggle_mask;
spinlock_t lock;
@@ -1234,11 +1232,9 @@ static int omap_gpio_runtime_suspend(struct device *dev)
 
bank-saved_datain = __raw_readl(bank-base +
bank-regs-datain);
-   l1 = __raw_readl(bank-base + bank-regs-fallingdetect);
-   l2 = __raw_readl(bank-base + bank-regs-risingdetect);
+   l1 = bank-context.fallingdetect;
+   l2 = bank-context.risingdetect;
 
-   bank-saved_fallingdetect = l1;
-   bank-saved_risingdetect = l2;
l1 = ~bank-enabled_non_wakeup_gpios;
l2 = ~bank-enabled_non_wakeup_gpios;
 
@@ -1297,9 +1293,9 @@ static int omap_gpio_runtime_resume(struct device *dev)
}
}
 
-   __raw_writel(bank-saved_fallingdetect,
+   __raw_writel(bank-context.fallingdetect,
bank-base + bank-regs-fallingdetect);
-   __raw_writel(bank-saved_risingdetect,
+   __raw_writel(bank-context.risingdetect,
bank-base + bank-regs-risingdetect);
l = __raw_readl(bank-base + bank-regs-datain);
 
@@ -1316,14 +1312,15 @@ static int omap_gpio_runtime_resume(struct device *dev)
 * No need to generate IRQs for the rising edge for gpio IRQs
 * configured with falling edge only; and vice versa.
 */
-   gen0 = l  bank-saved_fallingdetect;
+   gen0 = l  bank-context.fallingdetect;
gen0 = bank-saved_datain;
 
-   gen1 = l  bank-saved_risingdetect;
+   gen1 = l  bank-context.risingdetect;
gen1 = ~(bank-saved_datain);
 
/* FIXME: Consider GPIO IRQs with level detections properly! */
-   gen = l  (~(bank-saved_fallingdetect)  ~(bank-saved_risingdetect));
+   gen = l  (~(bank-context.fallingdetect) 
+~(bank-context.risingdetect));
/* Consider all GPIO IRQs needed to be updated */
gen |= gen0 | gen1;
 
-- 
1.7.0.4

--
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 v2 7/9] gpio/omap: fix _set_gpio_irqenable implementation

2012-02-29 Thread Tarun Kanti DebBarma
This function should be capable of both enabling and disabling interrupts
based upon the *enable* parameter. Right now the function only enables
the interrupt and *enable* is not used at all. So add the interrupt
disable capability also using the parameter.

Signed-off-by: Tarun Kanti DebBarma tarun.ka...@ti.com
Reviewed-by: Santosh Shilimkar santosh.shilim...@ti.com
Acked-by: Felipe Balbi ba...@ti.com
---
 drivers/gpio/gpio-omap.c |5 -
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
index bb994db..19f8f44 100644
--- a/drivers/gpio/gpio-omap.c
+++ b/drivers/gpio/gpio-omap.c
@@ -475,7 +475,10 @@ static void _disable_gpio_irqbank(struct gpio_bank *bank, 
int gpio_mask)
 
 static inline void _set_gpio_irqenable(struct gpio_bank *bank, int gpio, int 
enable)
 {
-   _enable_gpio_irqbank(bank, GPIO_BIT(bank, gpio));
+   if (enable)
+   _enable_gpio_irqbank(bank, GPIO_BIT(bank, gpio));
+   else
+   _disable_gpio_irqbank(bank, GPIO_BIT(bank, gpio));
 }
 
 /*
-- 
1.7.0.4

--
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 v2 4/9] gpio/omap: remove saved_wakeup field from struct gpio_bank

2012-02-29 Thread Tarun Kanti DebBarma
There is no more need to have saved_wakeup because bank-context.wake_en
already holds that value. So getting rid of read/write operation associated
with this field.

Signed-off-by: Tarun Kanti DebBarma tarun.ka...@ti.com
Reviewed-by: Santosh Shilimkar santosh.shilim...@ti.com
Acked-by: Felipe Balbi ba...@ti.com
---
 drivers/gpio/gpio-omap.c |   12 +++-
 1 files changed, 3 insertions(+), 9 deletions(-)

diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
index 14c61e2..3765654 100644
--- a/drivers/gpio/gpio-omap.c
+++ b/drivers/gpio/gpio-omap.c
@@ -54,7 +54,6 @@ struct gpio_bank {
void __iomem *base;
u16 irq;
u16 virtual_irq_start;
-   u32 saved_wakeup;
u32 non_wakeup_gpios;
u32 enabled_non_wakeup_gpios;
struct gpio_regs context;
@@ -774,7 +773,6 @@ static int omap_mpuio_suspend_noirq(struct device *dev)
unsigned long   flags;
 
spin_lock_irqsave(bank-lock, flags);
-   bank-saved_wakeup = __raw_readl(mask_reg);
__raw_writel(0x  ~bank-context.wake_en, mask_reg);
spin_unlock_irqrestore(bank-lock, flags);
 
@@ -790,7 +788,7 @@ static int omap_mpuio_resume_noirq(struct device *dev)
unsigned long   flags;
 
spin_lock_irqsave(bank-lock, flags);
-   __raw_writel(bank-saved_wakeup, mask_reg);
+   __raw_writel(bank-context.wake_en, mask_reg);
spin_unlock_irqrestore(bank-lock, flags);
 
return 0;
@@ -1143,7 +1141,6 @@ static int omap_gpio_suspend(struct device *dev)
struct platform_device *pdev = to_platform_device(dev);
struct gpio_bank *bank = platform_get_drvdata(pdev);
void __iomem *base = bank-base;
-   void __iomem *wakeup_enable;
unsigned long flags;
 
if (!bank-mod_usage || !bank-loses_context)
@@ -1152,10 +1149,7 @@ static int omap_gpio_suspend(struct device *dev)
if (!bank-regs-wkup_en || !bank-context.wake_en)
return 0;
 
-   wakeup_enable = bank-base + bank-regs-wkup_en;
-
spin_lock_irqsave(bank-lock, flags);
-   bank-saved_wakeup = __raw_readl(wakeup_enable);
_gpio_rmw(base, bank-regs-wkup_en, 0x, 0);
_gpio_rmw(base, bank-regs-wkup_en, bank-context.wake_en, 1);
spin_unlock_irqrestore(bank-lock, flags);
@@ -1173,12 +1167,12 @@ static int omap_gpio_resume(struct device *dev)
if (!bank-mod_usage || !bank-loses_context)
return 0;
 
-   if (!bank-regs-wkup_en || !bank-saved_wakeup)
+   if (!bank-regs-wkup_en || !bank-context.wake_en)
return 0;
 
spin_lock_irqsave(bank-lock, flags);
_gpio_rmw(base, bank-regs-wkup_en, 0x, 0);
-   _gpio_rmw(base, bank-regs-wkup_en, bank-saved_wakeup, 1);
+   _gpio_rmw(base, bank-regs-wkup_en, bank-context.wake_en, 1);
spin_unlock_irqrestore(bank-lock, flags);
 
return 0;
-- 
1.7.0.4

--
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 v2 6/9] gpio/omap: fix trigger type to unsigned

2012-02-29 Thread Tarun Kanti DebBarma
The GPIO trigger parameter is of type unsigned.
enum {
IRQ_TYPE_NONE   = 0x,
IRQ_TYPE_EDGE_RISING= 0x0001,
IRQ_TYPE_EDGE_FALLING   = 0x0002,
IRQ_TYPE_EDGE_BOTH  = (IRQ_TYPE_EDGE_FALLING | 
IRQ_TYPE_EDGE_RISING),
IRQ_TYPE_LEVEL_HIGH = 0x0004,
IRQ_TYPE_LEVEL_LOW  = 0x0008,
IRQ_TYPE_LEVEL_MASK = (IRQ_TYPE_LEVEL_LOW | IRQ_TYPE_LEVEL_HIGH),
IRQ_TYPE_SENSE_MASK = 0x000f,

IRQ_TYPE_PROBE  = 0x0010,
...
};
Even though gpio_irq_type(struct irq_data *d, unsigned type) has the right type
of parameter, the subsequent called functions set_gpio_triggering() and
set_gpio_trigger() wrongly makes it signed integer. Fix this.

Signed-off-by: Tarun Kanti DebBarma tarun.ka...@ti.com
Reviewed-by: Santosh Shilimkar santosh.shilim...@ti.com
Acked-by: Felipe Balbi ba...@ti.com
---
 drivers/gpio/gpio-omap.c |5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
index de5fe8f..bb994db 100644
--- a/drivers/gpio/gpio-omap.c
+++ b/drivers/gpio/gpio-omap.c
@@ -234,7 +234,7 @@ static void _set_gpio_debounce(struct gpio_bank *bank, 
unsigned gpio,
 }
 
 static inline void set_gpio_trigger(struct gpio_bank *bank, int gpio,
-   int trigger)
+   unsigned trigger)
 {
void __iomem *base = bank-base;
u32 gpio_bit = 1  gpio;
@@ -316,7 +316,8 @@ static void _toggle_gpio_edge_triggering(struct gpio_bank 
*bank, int gpio)
 static void _toggle_gpio_edge_triggering(struct gpio_bank *bank, int gpio) {}
 #endif
 
-static int _set_gpio_triggering(struct gpio_bank *bank, int gpio, int trigger)
+static int _set_gpio_triggering(struct gpio_bank *bank, int gpio,
+   unsigned trigger)
 {
void __iomem *reg = bank-base;
void __iomem *base = bank-base;
-- 
1.7.0.4

--
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 v2 9/9] gpio/omap: remove suspend/resume callbacks

2012-02-29 Thread Tarun Kanti DebBarma
Both omap_gpio_suspend() and omap_gpio_resume() does programming
of wakeup_en register.
_gpio_rmw(base, bank-regs-wkup_en, 0x, 0);
_gpio_rmw(base, bank-regs-wkup_en, bank-context.wake_en, 1);

This is redundant in omap_gpio_suspend() because wakeup_en
register automatically gets initialized in _set_gpio_wakeup()
and set_gpio_trigger() while being called either from
chip.irq_set_wake() or chip.irq_set_type().

This is redundant in omap_gpio_resume() because wakeup_en
register is programmed in omap_gpio_restore_context() called
which is called from runtime resume callback.

Signed-off-by: Tarun Kanti DebBarma tarun.ka...@ti.com
---
 drivers/gpio/gpio-omap.c |   47 --
 1 files changed, 0 insertions(+), 47 deletions(-)

diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
index 186ce92..8b4a7ba 100644
--- a/drivers/gpio/gpio-omap.c
+++ b/drivers/gpio/gpio-omap.c
@@ -1132,50 +1132,6 @@ err_exit:
 
 #ifdef CONFIG_ARCH_OMAP2PLUS
 
-#if defined(CONFIG_PM_SLEEP)
-static int omap_gpio_suspend(struct device *dev)
-{
-   struct platform_device *pdev = to_platform_device(dev);
-   struct gpio_bank *bank = platform_get_drvdata(pdev);
-   void __iomem *base = bank-base;
-   unsigned long flags;
-
-   if (!bank-mod_usage || !bank-loses_context)
-   return 0;
-
-   if (!bank-regs-wkup_en || !bank-context.wake_en)
-   return 0;
-
-   spin_lock_irqsave(bank-lock, flags);
-   _gpio_rmw(base, bank-regs-wkup_en, 0x, 0);
-   _gpio_rmw(base, bank-regs-wkup_en, bank-context.wake_en, 1);
-   spin_unlock_irqrestore(bank-lock, flags);
-
-   return 0;
-}
-
-static int omap_gpio_resume(struct device *dev)
-{
-   struct platform_device *pdev = to_platform_device(dev);
-   struct gpio_bank *bank = platform_get_drvdata(pdev);
-   void __iomem *base = bank-base;
-   unsigned long flags;
-
-   if (!bank-mod_usage || !bank-loses_context)
-   return 0;
-
-   if (!bank-regs-wkup_en || !bank-context.wake_en)
-   return 0;
-
-   spin_lock_irqsave(bank-lock, flags);
-   _gpio_rmw(base, bank-regs-wkup_en, 0x, 0);
-   _gpio_rmw(base, bank-regs-wkup_en, bank-context.wake_en, 1);
-   spin_unlock_irqrestore(bank-lock, flags);
-
-   return 0;
-}
-#endif /* CONFIG_PM_SLEEP */
-
 #if defined(CONFIG_PM_RUNTIME)
 static void omap_gpio_restore_context(struct gpio_bank *bank);
 
@@ -1407,14 +1363,11 @@ static void omap_gpio_restore_context(struct gpio_bank 
*bank)
 }
 #endif /* CONFIG_PM_RUNTIME */
 #else
-#define omap_gpio_suspend NULL
-#define omap_gpio_resume NULL
 #define omap_gpio_runtime_suspend NULL
 #define omap_gpio_runtime_resume NULL
 #endif
 
 static const struct dev_pm_ops gpio_pm_ops = {
-   SET_SYSTEM_SLEEP_PM_OPS(omap_gpio_suspend, omap_gpio_resume)
SET_RUNTIME_PM_OPS(omap_gpio_runtime_suspend, omap_gpio_runtime_resume,
NULL)
 };
-- 
1.7.0.4

--
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 v2 5/9] gpio/omap: get rid of retrigger variable in gpio_irq_handler

2012-02-29 Thread Tarun Kanti DebBarma
This local variable is just assigned zero and then OR'ed
with isr. It does not appear to serve any purpose and so
removing it.

Signed-off-by: Tarun Kanti DebBarma tarun.ka...@ti.com
Reviewed-by: Santosh Shilimkar santosh.shilim...@ti.com
Acked-by: Felipe Balbi ba...@ti.com
---
 drivers/gpio/gpio-omap.c |3 ---
 1 files changed, 0 insertions(+), 3 deletions(-)

diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
index 3765654..de5fe8f 100644
--- a/drivers/gpio/gpio-omap.c
+++ b/drivers/gpio/gpio-omap.c
@@ -626,7 +626,6 @@ static void gpio_irq_handler(unsigned int irq, struct 
irq_desc *desc)
u32 isr;
unsigned int gpio_irq, gpio_index;
struct gpio_bank *bank;
-   u32 retrigger = 0;
int unmasked = 0;
struct irq_chip *chip = irq_desc_get_chip(desc);
 
@@ -663,8 +662,6 @@ static void gpio_irq_handler(unsigned int irq, struct 
irq_desc *desc)
chained_irq_exit(chip, desc);
}
 
-   isr |= retrigger;
-   retrigger = 0;
if (!isr)
break;
 
-- 
1.7.0.4

--
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 v2 3/9] gpio/omap: remove suspend_wakeup field from struct gpio_bank

2012-02-29 Thread Tarun Kanti DebBarma
Since we already have bank-context.wake_en to keep track
of gpios which are wakeup enabled, there is no need to have
this field any more.

Signed-off-by: Tarun Kanti DebBarma tarun.ka...@ti.com
Reviewed-by: Santosh Shilimkar santosh.shilim...@ti.com
Acked-by: Felipe Balbi ba...@ti.com
---
 drivers/gpio/gpio-omap.c |   13 ++---
 1 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
index 895df7f..14c61e2 100644
--- a/drivers/gpio/gpio-omap.c
+++ b/drivers/gpio/gpio-omap.c
@@ -54,7 +54,6 @@ struct gpio_bank {
void __iomem *base;
u16 irq;
u16 virtual_irq_start;
-   u32 suspend_wakeup;
u32 saved_wakeup;
u32 non_wakeup_gpios;
u32 enabled_non_wakeup_gpios;
@@ -500,11 +499,11 @@ static int _set_gpio_wakeup(struct gpio_bank *bank, int 
gpio, int enable)
 
spin_lock_irqsave(bank-lock, flags);
if (enable)
-   bank-suspend_wakeup |= gpio_bit;
+   bank-context.wake_en |= gpio_bit;
else
-   bank-suspend_wakeup = ~gpio_bit;
+   bank-context.wake_en = ~gpio_bit;
 
-   __raw_writel(bank-suspend_wakeup, bank-base + bank-regs-wkup_en);
+   __raw_writel(bank-context.wake_en, bank-base + bank-regs-wkup_en);
spin_unlock_irqrestore(bank-lock, flags);
 
return 0;
@@ -776,7 +775,7 @@ static int omap_mpuio_suspend_noirq(struct device *dev)
 
spin_lock_irqsave(bank-lock, flags);
bank-saved_wakeup = __raw_readl(mask_reg);
-   __raw_writel(0x  ~bank-suspend_wakeup, mask_reg);
+   __raw_writel(0x  ~bank-context.wake_en, mask_reg);
spin_unlock_irqrestore(bank-lock, flags);
 
return 0;
@@ -1150,7 +1149,7 @@ static int omap_gpio_suspend(struct device *dev)
if (!bank-mod_usage || !bank-loses_context)
return 0;
 
-   if (!bank-regs-wkup_en || !bank-suspend_wakeup)
+   if (!bank-regs-wkup_en || !bank-context.wake_en)
return 0;
 
wakeup_enable = bank-base + bank-regs-wkup_en;
@@ -1158,7 +1157,7 @@ static int omap_gpio_suspend(struct device *dev)
spin_lock_irqsave(bank-lock, flags);
bank-saved_wakeup = __raw_readl(wakeup_enable);
_gpio_rmw(base, bank-regs-wkup_en, 0x, 0);
-   _gpio_rmw(base, bank-regs-wkup_en, bank-suspend_wakeup, 1);
+   _gpio_rmw(base, bank-regs-wkup_en, bank-context.wake_en, 1);
spin_unlock_irqrestore(bank-lock, flags);
 
return 0;
-- 
1.7.0.4

--
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 4/6] gpio/omap: get rid of retrigger variable in gpio_irq_handler

2012-02-23 Thread Tarun Kanti DebBarma
This local variable is just assigned zero and then OR'ed
with isr. It does not appear to serve any purpose and so
removing it.

Signed-off-by: Tarun Kanti DebBarma tarun.ka...@ti.com
---
 drivers/gpio/gpio-omap.c |3 ---
 1 files changed, 0 insertions(+), 3 deletions(-)

diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
index b62e861..3dd4b3a 100644
--- a/drivers/gpio/gpio-omap.c
+++ b/drivers/gpio/gpio-omap.c
@@ -623,7 +623,6 @@ static void gpio_irq_handler(unsigned int irq, struct 
irq_desc *desc)
u32 isr;
unsigned int gpio_irq, gpio_index;
struct gpio_bank *bank;
-   u32 retrigger = 0;
int unmasked = 0;
struct irq_chip *chip = irq_desc_get_chip(desc);
 
@@ -660,8 +659,6 @@ static void gpio_irq_handler(unsigned int irq, struct 
irq_desc *desc)
chained_irq_exit(chip, desc);
}
 
-   isr |= retrigger;
-   retrigger = 0;
if (!isr)
break;
 
-- 
1.7.0.4

--
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 6/6] gpio/omap: fix _set_gpio_irqenable implementation

2012-02-23 Thread Tarun Kanti DebBarma
This function should be capable of both enabling and disabling interrupts
based upon the *enable* parameter. Right now the function only enables
the interrupt and *enable* is not used at all. So add the interrupt
disable capability also using the parameter.

Signed-off-by: Tarun Kanti DebBarma tarun.ka...@ti.com
---
 drivers/gpio/gpio-omap.c |5 -
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
index 67535c8..acc71a0 100644
--- a/drivers/gpio/gpio-omap.c
+++ b/drivers/gpio/gpio-omap.c
@@ -473,7 +473,10 @@ static void _disable_gpio_irqbank(struct gpio_bank *bank, 
int gpio_mask)
 
 static inline void _set_gpio_irqenable(struct gpio_bank *bank, int gpio, int 
enable)
 {
-   _enable_gpio_irqbank(bank, GPIO_BIT(bank, gpio));
+   if (enable)
+   _enable_gpio_irqbank(bank, GPIO_BIT(bank, gpio));
+   else
+   _disable_gpio_irqbank(bank, GPIO_BIT(bank, gpio));
 }
 
 /*
-- 
1.7.0.4

--
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 3/6] gpio/omap: remove suspend_wakeup field from struct gpio_bank

2012-02-23 Thread Tarun Kanti DebBarma
Since we already have bank-context.wake_en to keep track
of gpios which are wakeup enabled, there is no need to have
this field any more.

Signed-off-by: Tarun Kanti DebBarma tarun.ka...@ti.com
---
 drivers/gpio/gpio-omap.c |   11 +--
 1 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
index 64f15d5..b62e861 100644
--- a/drivers/gpio/gpio-omap.c
+++ b/drivers/gpio/gpio-omap.c
@@ -53,7 +53,6 @@ struct gpio_bank {
void __iomem *base;
u16 irq;
u16 virtual_irq_start;
-   u32 suspend_wakeup;
u32 non_wakeup_gpios;
u32 enabled_non_wakeup_gpios;
struct gpio_regs context;
@@ -497,9 +496,9 @@ static int _set_gpio_wakeup(struct gpio_bank *bank, int 
gpio, int enable)
 
spin_lock_irqsave(bank-lock, flags);
if (enable)
-   bank-suspend_wakeup |= gpio_bit;
+   bank-context.wake_en |= gpio_bit;
else
-   bank-suspend_wakeup = ~gpio_bit;
+   bank-context.wake_en = ~gpio_bit;
 
spin_unlock_irqrestore(bank-lock, flags);
 
@@ -772,7 +771,7 @@ static int omap_mpuio_suspend_noirq(struct device *dev)
 
spin_lock_irqsave(bank-lock, flags);
bank-context.wake_en = __raw_readl(mask_reg);
-   __raw_writel(0x  ~bank-suspend_wakeup, mask_reg);
+   __raw_writel(0x  ~bank-context.wake_en, mask_reg);
spin_unlock_irqrestore(bank-lock, flags);
 
return 0;
@@ -1137,12 +1136,12 @@ static int omap_gpio_suspend(struct device *dev)
if (!bank-mod_usage || !bank-loses_context)
return 0;
 
-   if (!bank-regs-wkup_en || !bank-suspend_wakeup)
+   if (!bank-regs-wkup_en || !bank-context.wake_en)
return 0;
 
spin_lock_irqsave(bank-lock, flags);
_gpio_rmw(base, bank-regs-wkup_en, 0x, 0);
-   _gpio_rmw(base, bank-regs-wkup_en, bank-suspend_wakeup, 1);
+   _gpio_rmw(base, bank-regs-wkup_en, bank-context.wake_en, 1);
spin_unlock_irqrestore(bank-lock, flags);
 
return 0;
-- 
1.7.0.4

--
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 1/6] gpio/omap: remove saved_fallingdetect, saved_risingdetect fields

2012-02-23 Thread Tarun Kanti DebBarma
Since we already have context.fallingdetect and context.risingdetect
there is no more need to have these additional fields. Also, getting
rid of extra reads associated with them.

Signed-off-by: Tarun Kanti DebBarma tarun.ka...@ti.com
---
 drivers/gpio/gpio-omap.c |   19 ---
 1 files changed, 8 insertions(+), 11 deletions(-)

diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
index f29252f..40a1fb2 100644
--- a/drivers/gpio/gpio-omap.c
+++ b/drivers/gpio/gpio-omap.c
@@ -59,8 +59,6 @@ struct gpio_bank {
u32 enabled_non_wakeup_gpios;
struct gpio_regs context;
u32 saved_datain;
-   u32 saved_fallingdetect;
-   u32 saved_risingdetect;
u32 level_mask;
u32 toggle_mask;
spinlock_t lock;
@@ -1224,11 +1222,9 @@ static int omap_gpio_runtime_suspend(struct device *dev)
 
bank-saved_datain = __raw_readl(bank-base +
bank-regs-datain);
-   l1 = __raw_readl(bank-base + bank-regs-fallingdetect);
-   l2 = __raw_readl(bank-base + bank-regs-risingdetect);
+   l1 = bank-context.fallingdetect;
+   l2 = bank-context.risingdetect;
 
-   bank-saved_fallingdetect = l1;
-   bank-saved_risingdetect = l2;
l1 = ~bank-enabled_non_wakeup_gpios;
l2 = ~bank-enabled_non_wakeup_gpios;
 
@@ -1287,9 +1283,9 @@ static int omap_gpio_runtime_resume(struct device *dev)
}
}
 
-   __raw_writel(bank-saved_fallingdetect,
+   __raw_writel(bank-context.fallingdetect,
bank-base + bank-regs-fallingdetect);
-   __raw_writel(bank-saved_risingdetect,
+   __raw_writel(bank-context.risingdetect,
bank-base + bank-regs-risingdetect);
l = __raw_readl(bank-base + bank-regs-datain);
 
@@ -1306,14 +1302,15 @@ static int omap_gpio_runtime_resume(struct device *dev)
 * No need to generate IRQs for the rising edge for gpio IRQs
 * configured with falling edge only; and vice versa.
 */
-   gen0 = l  bank-saved_fallingdetect;
+   gen0 = l  bank-context.fallingdetect;
gen0 = bank-saved_datain;
 
-   gen1 = l  bank-saved_risingdetect;
+   gen1 = l  bank-context.risingdetect;
gen1 = ~(bank-saved_datain);
 
/* FIXME: Consider GPIO IRQs with level detections properly! */
-   gen = l  (~(bank-saved_fallingdetect)  ~(bank-saved_risingdetect));
+   gen = l  (~(bank-context.fallingdetect) 
+~(bank-context.risingdetect));
/* Consider all GPIO IRQs needed to be updated */
gen |= gen0 | gen1;
 
-- 
1.7.0.4

--
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 2/6] gpio/omap: remove saved_wakeup field from struct gpio_bank

2012-02-23 Thread Tarun Kanti DebBarma
There is no more need to have saved_wakeup. Instead we can use
context.wake_en which holds the current wakeup enable register
context. This also means that the read from wakeup enable register
is not needed.

Signed-off-by: Tarun Kanti DebBarma tarun.ka...@ti.com
---
 drivers/gpio/gpio-omap.c |   13 -
 1 files changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
index 40a1fb2..64f15d5 100644
--- a/drivers/gpio/gpio-omap.c
+++ b/drivers/gpio/gpio-omap.c
@@ -54,7 +54,6 @@ struct gpio_bank {
u16 irq;
u16 virtual_irq_start;
u32 suspend_wakeup;
-   u32 saved_wakeup;
u32 non_wakeup_gpios;
u32 enabled_non_wakeup_gpios;
struct gpio_regs context;
@@ -772,7 +771,7 @@ static int omap_mpuio_suspend_noirq(struct device *dev)
unsigned long   flags;
 
spin_lock_irqsave(bank-lock, flags);
-   bank-saved_wakeup = __raw_readl(mask_reg);
+   bank-context.wake_en = __raw_readl(mask_reg);
__raw_writel(0x  ~bank-suspend_wakeup, mask_reg);
spin_unlock_irqrestore(bank-lock, flags);
 
@@ -788,7 +787,7 @@ static int omap_mpuio_resume_noirq(struct device *dev)
unsigned long   flags;
 
spin_lock_irqsave(bank-lock, flags);
-   __raw_writel(bank-saved_wakeup, mask_reg);
+   __raw_writel(bank-context.wake_en, mask_reg);
spin_unlock_irqrestore(bank-lock, flags);
 
return 0;
@@ -1133,7 +1132,6 @@ static int omap_gpio_suspend(struct device *dev)
struct platform_device *pdev = to_platform_device(dev);
struct gpio_bank *bank = platform_get_drvdata(pdev);
void __iomem *base = bank-base;
-   void __iomem *wakeup_enable;
unsigned long flags;
 
if (!bank-mod_usage || !bank-loses_context)
@@ -1142,10 +1140,7 @@ static int omap_gpio_suspend(struct device *dev)
if (!bank-regs-wkup_en || !bank-suspend_wakeup)
return 0;
 
-   wakeup_enable = bank-base + bank-regs-wkup_en;
-
spin_lock_irqsave(bank-lock, flags);
-   bank-saved_wakeup = __raw_readl(wakeup_enable);
_gpio_rmw(base, bank-regs-wkup_en, 0x, 0);
_gpio_rmw(base, bank-regs-wkup_en, bank-suspend_wakeup, 1);
spin_unlock_irqrestore(bank-lock, flags);
@@ -1163,12 +1158,12 @@ static int omap_gpio_resume(struct device *dev)
if (!bank-mod_usage || !bank-loses_context)
return 0;
 
-   if (!bank-regs-wkup_en || !bank-saved_wakeup)
+   if (!bank-regs-wkup_en || !bank-context.wake_en)
return 0;
 
spin_lock_irqsave(bank-lock, flags);
_gpio_rmw(base, bank-regs-wkup_en, 0x, 0);
-   _gpio_rmw(base, bank-regs-wkup_en, bank-saved_wakeup, 1);
+   _gpio_rmw(base, bank-regs-wkup_en, bank-context.wake_en, 1);
spin_unlock_irqrestore(bank-lock, flags);
 
return 0;
-- 
1.7.0.4

--
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 5/6] gpio/omap: fix trigger type to unsigned

2012-02-23 Thread Tarun Kanti DebBarma
The GPIO trigger parameter is of type unsigned.
enum {
IRQ_TYPE_NONE   = 0x,
IRQ_TYPE_EDGE_RISING= 0x0001,
IRQ_TYPE_EDGE_FALLING   = 0x0002,
IRQ_TYPE_EDGE_BOTH  = (IRQ_TYPE_EDGE_FALLING | 
IRQ_TYPE_EDGE_RISING),
IRQ_TYPE_LEVEL_HIGH = 0x0004,
IRQ_TYPE_LEVEL_LOW  = 0x0008,
IRQ_TYPE_LEVEL_MASK = (IRQ_TYPE_LEVEL_LOW | IRQ_TYPE_LEVEL_HIGH),
IRQ_TYPE_SENSE_MASK = 0x000f,

IRQ_TYPE_PROBE  = 0x0010,
...
};
Even though gpio_irq_type(struct irq_data *d, unsigned type) has the right type
of parameter, the subsequent called functions set_gpio_triggering() and
set_gpio_trigger() wrongly makes it signed integer. Fix this.

Signed-off-by: Tarun Kanti DebBarma tarun.ka...@ti.com
---
 drivers/gpio/gpio-omap.c |5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
index 3dd4b3a..67535c8 100644
--- a/drivers/gpio/gpio-omap.c
+++ b/drivers/gpio/gpio-omap.c
@@ -232,7 +232,7 @@ static void _set_gpio_debounce(struct gpio_bank *bank, 
unsigned gpio,
 }
 
 static inline void set_gpio_trigger(struct gpio_bank *bank, int gpio,
-   int trigger)
+   unsigned trigger)
 {
void __iomem *base = bank-base;
u32 gpio_bit = 1  gpio;
@@ -314,7 +314,8 @@ static void _toggle_gpio_edge_triggering(struct gpio_bank 
*bank, int gpio)
 static void _toggle_gpio_edge_triggering(struct gpio_bank *bank, int gpio) {}
 #endif
 
-static int _set_gpio_triggering(struct gpio_bank *bank, int gpio, int trigger)
+static int _set_gpio_triggering(struct gpio_bank *bank, int gpio,
+   unsigned trigger)
 {
void __iomem *reg = bank-base;
void __iomem *base = bank-base;
-- 
1.7.0.4

--
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 0/6] gpio/omap: Some more driver cleanup and fixes

2012-02-23 Thread Tarun Kanti DebBarma
The cleanup is mostly getting rid of redundant fields in struct gpio_bank{}
as we already have them as part of bank-context now. Also, remove un-used
variable from gpio_irq_handler.

The fix include correction of _set_gpio_irqenable() implementation and fix
type mismatch of gpio trigger parameter.

It is baselined on top of Kevin's following series:
gpio/omap: cleanup and runtime PM conversion for v3.4
git://git.kernel.org/pub/scm/linux/kernel/git/khilman/linux-omap-pm.git 
for_3.4/gpio/runtime-pm-cleanup

I have applied Benoit's GPIO patches in following series on top of Kevin's
before applying my changes.
gpio/omap: Cleanup and adaptation to Device Tree
git://git.kernel.org/pub/scm/linux/kernel/git/bcousson/linux-omap-dt.git 
for_3.4/dt_gpio

Series is available here for reference:
git://gitorious.org/~tarunkanti/omap-sw-develoment/tarunkantis-linux-omap-dev 
for_3.4/gpio_further_cleanup_fixes

Power Test: Off-mode and Retention on OMAP3430 (Suspend and Idle paths).
Functional Test: OMAP2430, OMAP3430SDP, ZOOM3, OMAP4430, OMAP4-BLAZE

Tarun Kanti DebBarma (6):
  gpio/omap: remove saved_fallingdetect, saved_risingdetect fields
  gpio/omap: remove saved_wakeup field from struct gpio_bank
  gpio/omap: remove suspend_wakeup field from struct gpio_bank
  gpio/omap: get rid of retrigger variable in gpio_irq_handler
  gpio/omap: fix trigger type to unsigned
  gpio/omap: fix _set_gpio_irqenable implementation

 drivers/gpio/gpio-omap.c |   56 +++--
 1 files changed, 24 insertions(+), 32 deletions(-)

--
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 v9 02/25] gpio/omap: use flag to identify wakeup domain

2012-02-02 Thread Tarun Kanti DebBarma
From: Charulatha V ch...@ti.com

In omap3, save/restore context is implemented for GPIO banks 2-6 as GPIO bank1
is in wakeup domain. Instead of identifying bank's power domain by bank id,
use 'loses_context' flag which is filled by pwrdm_can_ever_lose_context()
during dev_init.

For getting the powerdomain pointer, omap_hwmod_get_pwrdm() is used.
omap_device_get_pwrdm() could not be used as the pwrdm information needs to be
filled in pdata, whereas omap_device_get_pwrdm() could be used only after
omap_device_build() call.

Signed-off-by: Charulatha V ch...@ti.com
Reviewed-by: Santosh Shilimkar santosh.shilim...@ti.com
---
 arch/arm/mach-omap2/gpio.c |6 ++
 arch/arm/plat-omap/include/plat/gpio.h |1 +
 drivers/gpio/gpio-omap.c   |   13 ++---
 3 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/arch/arm/mach-omap2/gpio.c b/arch/arm/mach-omap2/gpio.c
index 07ac648..076be34 100644
--- a/arch/arm/mach-omap2/gpio.c
+++ b/arch/arm/mach-omap2/gpio.c
@@ -24,6 +24,8 @@
 #include plat/omap_hwmod.h
 #include plat/omap_device.h
 
+#include powerdomain.h
+
 static int omap2_gpio_dev_init(struct omap_hwmod *oh, void *unused)
 {
struct platform_device *pdev;
@@ -31,6 +33,7 @@ static int omap2_gpio_dev_init(struct omap_hwmod *oh, void 
*unused)
struct omap_gpio_dev_attr *dev_attr;
char *name = omap_gpio;
int id;
+   struct powerdomain *pwrdm;
 
/*
 * extract the device id from name field available in the
@@ -99,6 +102,9 @@ static int omap2_gpio_dev_init(struct omap_hwmod *oh, void 
*unused)
return -EINVAL;
}
 
+   pwrdm = omap_hwmod_get_pwrdm(oh);
+   pdata-loses_context = pwrdm_can_ever_lose_context(pwrdm);
+
pdev = omap_device_build(name, id - 1, oh, pdata,
sizeof(*pdata), NULL, 0, false);
kfree(pdata);
diff --git a/arch/arm/plat-omap/include/plat/gpio.h 
b/arch/arm/plat-omap/include/plat/gpio.h
index acf1c77..6eb035c 100644
--- a/arch/arm/plat-omap/include/plat/gpio.h
+++ b/arch/arm/plat-omap/include/plat/gpio.h
@@ -198,6 +198,7 @@ struct omap_gpio_platform_data {
int bank_width; /* GPIO bank width */
int bank_stride;/* Only needed for omap1 MPUIO */
bool dbck_flag; /* dbck required or not - True for OMAP34 */
+   bool loses_context; /* whether the bank would ever lose context */
 
struct omap_gpio_reg_offs *regs;
 };
diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
index 6ea7390..07efa15 100644
--- a/drivers/gpio/gpio-omap.c
+++ b/drivers/gpio/gpio-omap.c
@@ -56,6 +56,7 @@ struct gpio_bank {
u32 dbck_enable_mask;
struct device *dev;
bool dbck_flag;
+   bool loses_context;
int stride;
u32 width;
u16 id;
@@ -1181,7 +1182,7 @@ static int __devinit omap_gpio_probe(struct 
platform_device *pdev)
bank-dbck_flag = pdata-dbck_flag;
bank-stride = pdata-bank_stride;
bank-width = pdata-bank_width;
-
+   bank-loses_context = pdata-loses_context;
bank-regs = pdata-regs;
 
if (bank-regs-set_dataout  bank-regs-clr_dataout)
@@ -1337,8 +1338,7 @@ void omap2_gpio_prepare_for_idle(int off_mode)
u32 l1 = 0, l2 = 0;
int j;
 
-   /* TODO: Do not use cpu_is_omap34xx */
-   if ((cpu_is_omap34xx())  (bank-id == 0))
+   if (!bank-loses_context)
continue;
 
for (j = 0; j  hweight_long(bank-dbck_enable_mask); j++)
@@ -1405,8 +1405,7 @@ void omap2_gpio_resume_after_idle(void)
u32 l = 0, gen, gen0, gen1;
int j;
 
-   /* TODO: Do not use cpu_is_omap34xx */
-   if ((cpu_is_omap34xx())  (bank-id == 0))
+   if (!bank-loses_context)
continue;
 
for (j = 0; j  hweight_long(bank-dbck_enable_mask); j++)
@@ -1505,7 +1504,7 @@ void omap_gpio_save_context(void)
list_for_each_entry(bank, omap_gpio_list, node) {
i++;
 
-   if (bank-id == 0)
+   if (!bank-loses_context)
continue;
 
gpio_context[i].irqenable1 =
@@ -1539,7 +1538,7 @@ void omap_gpio_restore_context(void)
list_for_each_entry(bank, omap_gpio_list, node) {
i++;
 
-   if (bank-id == 0)
+   if (!bank-loses_context)
continue;
 
__raw_writel(gpio_context[i].irqenable1,
-- 
1.7.0.4

--
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 v9 10/25] gpio/omap: cleanup set_gpio_triggering function

2012-02-02 Thread Tarun Kanti DebBarma
Getting rid of ifdefs within the function by adding register offset intctrl
and associating OMAP_GPIO_INT_CONTROL in respective SoC specific files.
Also, use wkup_status register consistently instead of referring to wakeup
clear and wakeup set register offsets. Get rid of cpu_is_ checks in
set_gpio_trigger() using irqctrl.

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
Acked-by: Tony Lindgren t...@atomide.com
---
 arch/arm/mach-omap1/gpio15xx.c |2 +
 arch/arm/mach-omap1/gpio16xx.c |3 +
 arch/arm/mach-omap1/gpio7xx.c  |2 +
 arch/arm/plat-omap/include/plat/gpio.h |3 +
 drivers/gpio/gpio-omap.c   |  157 +---
 5 files changed, 53 insertions(+), 114 deletions(-)

diff --git a/arch/arm/mach-omap1/gpio15xx.c b/arch/arm/mach-omap1/gpio15xx.c
index f8c15ea..2adfece 100644
--- a/arch/arm/mach-omap1/gpio15xx.c
+++ b/arch/arm/mach-omap1/gpio15xx.c
@@ -42,6 +42,7 @@ static struct omap_gpio_reg_offs omap15xx_mpuio_regs = {
.irqstatus  = OMAP_MPUIO_GPIO_INT,
.irqenable  = OMAP_MPUIO_GPIO_MASKIT,
.irqenable_inv  = true,
+   .irqctrl= OMAP_MPUIO_GPIO_INT_EDGE,
 };
 
 static struct __initdata omap_gpio_platform_data omap15xx_mpu_gpio_config = {
@@ -83,6 +84,7 @@ static struct omap_gpio_reg_offs omap15xx_gpio_regs = {
.irqstatus  = OMAP1510_GPIO_INT_STATUS,
.irqenable  = OMAP1510_GPIO_INT_MASK,
.irqenable_inv  = true,
+   .irqctrl= OMAP1510_GPIO_INT_CONTROL,
 };
 
 static struct __initdata omap_gpio_platform_data omap15xx_gpio_config = {
diff --git a/arch/arm/mach-omap1/gpio16xx.c b/arch/arm/mach-omap1/gpio16xx.c
index 1eb47e2..46bb57a 100644
--- a/arch/arm/mach-omap1/gpio16xx.c
+++ b/arch/arm/mach-omap1/gpio16xx.c
@@ -45,6 +45,7 @@ static struct omap_gpio_reg_offs omap16xx_mpuio_regs = {
.irqstatus  = OMAP_MPUIO_GPIO_INT,
.irqenable  = OMAP_MPUIO_GPIO_MASKIT,
.irqenable_inv  = true,
+   .irqctrl= OMAP_MPUIO_GPIO_INT_EDGE,
 };
 
 static struct __initdata omap_gpio_platform_data omap16xx_mpu_gpio_config = {
@@ -90,6 +91,8 @@ static struct omap_gpio_reg_offs omap16xx_gpio_regs = {
.set_irqenable  = OMAP1610_GPIO_SET_IRQENABLE1,
.clr_irqenable  = OMAP1610_GPIO_CLEAR_IRQENABLE1,
.wkup_en= OMAP1610_GPIO_WAKEUPENABLE,
+   .edgectrl1  = OMAP1610_GPIO_EDGE_CTRL1,
+   .edgectrl2  = OMAP1610_GPIO_EDGE_CTRL2,
 };
 
 static struct __initdata omap_gpio_platform_data omap16xx_gpio1_config = {
diff --git a/arch/arm/mach-omap1/gpio7xx.c b/arch/arm/mach-omap1/gpio7xx.c
index 923eaa1..207a23c 100644
--- a/arch/arm/mach-omap1/gpio7xx.c
+++ b/arch/arm/mach-omap1/gpio7xx.c
@@ -47,6 +47,7 @@ static struct omap_gpio_reg_offs omap7xx_mpuio_regs = {
.irqstatus  = OMAP_MPUIO_GPIO_INT / 2,
.irqenable  = OMAP_MPUIO_GPIO_MASKIT / 2,
.irqenable_inv  = true,
+   .irqctrl= OMAP_MPUIO_GPIO_INT_EDGE  1,
 };
 
 static struct __initdata omap_gpio_platform_data omap7xx_mpu_gpio_config = {
@@ -88,6 +89,7 @@ static struct omap_gpio_reg_offs omap7xx_gpio_regs = {
.irqstatus  = OMAP7XX_GPIO_INT_STATUS,
.irqenable  = OMAP7XX_GPIO_INT_MASK,
.irqenable_inv  = true,
+   .irqctrl= OMAP7XX_GPIO_INT_CONTROL,
 };
 
 static struct __initdata omap_gpio_platform_data omap7xx_gpio1_config = {
diff --git a/arch/arm/plat-omap/include/plat/gpio.h 
b/arch/arm/plat-omap/include/plat/gpio.h
index 914c976..9e403e5 100644
--- a/arch/arm/plat-omap/include/plat/gpio.h
+++ b/arch/arm/plat-omap/include/plat/gpio.h
@@ -195,6 +195,9 @@ struct omap_gpio_reg_offs {
u16 leveldetect1;
u16 risingdetect;
u16 fallingdetect;
+   u16 irqctrl;
+   u16 edgectrl1;
+   u16 edgectrl2;
 
bool irqenable_inv;
 };
diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
index ceb9edf..f39d9e4 100644
--- a/drivers/gpio/gpio-omap.c
+++ b/drivers/gpio/gpio-omap.c
@@ -199,52 +199,32 @@ static void _set_gpio_debounce(struct gpio_bank *bank, 
unsigned gpio,
__raw_writel(val, reg);
 }
 
-#ifdef CONFIG_ARCH_OMAP2PLUS
-static inline void set_24xx_gpio_triggering(struct gpio_bank *bank, int gpio,
+static inline void set_gpio_trigger(struct gpio_bank *bank, int gpio,
int trigger)
 {
void __iomem *base = bank-base;
u32 gpio_bit = 1  gpio;
 
-   if (cpu_is_omap44xx()) {
-   _gpio_rmw(base, OMAP4_GPIO_LEVELDETECT0, gpio_bit,
- trigger  IRQ_TYPE_LEVEL_LOW);
-   _gpio_rmw(base, OMAP4_GPIO_LEVELDETECT1, gpio_bit,
- trigger  IRQ_TYPE_LEVEL_HIGH);
-   _gpio_rmw(base, OMAP4_GPIO_RISINGDETECT, gpio_bit,
- trigger  IRQ_TYPE_EDGE_RISING

[PATCH v9 15/25] gpio/omap: fix bankwidth for OMAP7xx MPUIO

2012-02-02 Thread Tarun Kanti DebBarma
From: Charulatha V ch...@ti.com

In all OMAP1 SoCs, the MPUIO bank width is 16 bits. But, in OMAP7xx,
it is wrongly initialised to 32. Fix this.

Signed-off-by: Charulatha V ch...@ti.com
Reviewed-by: Santosh Shilimkar santosh.shilim...@ti.com
Acked-by: Tony Lindgren t...@atomide.com
---
 arch/arm/mach-omap1/gpio7xx.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/arm/mach-omap1/gpio7xx.c b/arch/arm/mach-omap1/gpio7xx.c
index 433491c..4771d6b 100644
--- a/arch/arm/mach-omap1/gpio7xx.c
+++ b/arch/arm/mach-omap1/gpio7xx.c
@@ -52,8 +52,8 @@ static struct omap_gpio_reg_offs omap7xx_mpuio_regs = {
 
 static struct __initdata omap_gpio_platform_data omap7xx_mpu_gpio_config = {
.virtual_irq_start  = IH_MPUIO_BASE,
-   .bank_width = 32,
.is_mpuio   = true,
+   .bank_width = 16,
.bank_stride= 2,
.regs   = omap7xx_mpuio_regs,
 };
-- 
1.7.0.4

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


  1   2   3   4   5   6   7   >