Re: [PATCH:v4 12/13] OMAP: GPIO: Implement GPIO as a platform device

2010-06-25 Thread Kevin Hilman
Charulatha V ch...@ti.com writes:

 This patch implements GPIO as a platform device. Also it
 implements OMAP2PLUS specific GPIO as HWMOD FW adapted device.
 This patch makes GPIO to use runtime APIs.

 GPIO APIs are used in machine_init functions. Hence it is
 required to complete GPIO probe before machine_init. Therefore
 GPIO device register and driver register are implemented as
 postcore_initcalls.

 Inorder to convert GPIO as platform device, modifications are
 required in clock_data.c file for OMAP1 so that device names
 can be used to obtain clock instead of getting clocks by
 name/NULL ptr.

 omap_gpio_init() does nothing now and this function would be
 removed in the next patch as it's usage is spread across most of
 the board files.

 TODO:
 1. Cleanup the GPIO driver. Use function pointers and register
 offest pointers instead of using hardcoded values
 2. Remove all cpu_is_ checks and OMAP specific macros
 3. Remove usage of gpio_bank array so that only
 instance specific information is used in driver code
 4. Modify save/restore context, gpio_prepare_for_idle,
 and gpio_resume_after_idle functions as instance
 specific function and not for all instances in a single call

init_gpio_info() too.

I think this item (TODO #4) needs to be done as part of this series, as
this new generic driver needs to be completely ignorant of how many
banks are on chip, or currently in use.  All operations should be on a
single device (in this case, a single GPIO bank.)

As each hwmod has its own device, it can have it's own independent
suspend/resume.  To do this, you should remove the sysdev_class and
sys_device just use the regular device.  Here's a little patch[1] on top
of your current series that shows how you would hook up the standard PM
methods.  Also, the prepare_for_idle, resume_from_idle should be handled
by the runtime PM callbacks.

With the save/restore context handled on demand (when mod_usage
transitions to/from zero), and the runtime PM calls handled from within
the driver, we could get rid of all the GPIO calls from
omap_sram_idle().  That would be a huge improvement.

Kevin

[1] compile-tested only

diff --git a/arch/arm/plat-omap/gpio.c b/arch/arm/plat-omap/gpio.c
index 6dc5e4b..6a5a8f4 100644
--- a/arch/arm/plat-omap/gpio.c
+++ b/arch/arm/plat-omap/gpio.c
@@ -2091,10 +2091,44 @@ void omap_gpio_restore_context(void)
 }
 #endif
 
+static int gpio_bank_suspend(struct device *dev)
+{
+   return 0;
+}
+
+static int gpio_bank_resume(struct device *dev)
+{
+   return 0;
+}
+
+static int gpio_bank_runtime_idle(struct device *dev)
+{
+   return 0;
+}
+
+static int gpio_bank_runtime_suspend(struct device *dev)
+{
+   return 0;
+}
+
+static int gpio_bank_runtime_resume(struct device *dev)
+{
+   return 0;
+}
+
+static struct dev_pm_ops gpio_pm_ops = {
+   .suspend = gpio_bank_suspend,
+   .resume  = gpio_bank_resume,
+   .runtime_idle= gpio_bank_runtime_idle,
+   .runtime_suspend = gpio_bank_runtime_suspend,
+   .runtime_resume  = gpio_bank_runtime_resume,
+};
+
 static struct platform_driver omap_gpio_driver = {
.probe  = omap_gpio_probe,
.driver = {
.name   = omap-gpio,
+   .pm = gpio_pm_ops,
},
 };
 


--
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/13] OMAP: GPIO: Implement GPIO as a platform device

2010-06-22 Thread Charulatha V
This patch implements GPIO as a platform device. Also it
implements OMAP2PLUS specific GPIO as HWMOD FW adapted device.
This patch makes GPIO to use runtime APIs.

GPIO APIs are used in machine_init functions. Hence it is
required to complete GPIO probe before machine_init. Therefore
GPIO device register and driver register are implemented as
postcore_initcalls.

Inorder to convert GPIO as platform device, modifications are
required in clock_data.c file for OMAP1 so that device names
can be used to obtain clock instead of getting clocks by
name/NULL ptr.

omap_gpio_init() does nothing now and this function would be
removed in the next patch as it's usage is spread across most of
the board files.

TODO:
1. Cleanup the GPIO driver. Use function pointers and register
offest pointers instead of using hardcoded values
2. Remove all cpu_is_ checks and OMAP specific macros
3. Remove usage of gpio_bank array so that only
instance specific information is used in driver code
4. Modify save/restore context, gpio_prepare_for_idle,
and gpio_resume_after_idle functions as instance
specific function and not for all instances in a single call
5. Rename 'method'/ avoid it's usage

Signed-off-by: Charulatha V ch...@ti.com
Signed-off-by: Rajendra Nayak rna...@ti.com
Signed-off-by: Basak, Partha p-bas...@ti.com
---
 arch/arm/mach-omap1/Makefile   |6 +
 arch/arm/mach-omap1/clock_data.c   |4 +-
 arch/arm/mach-omap2/Makefile   |2 +-
 arch/arm/plat-omap/gpio.c  |  430 
 arch/arm/plat-omap/include/plat/gpio.h |3 +
 5 files changed, 122 insertions(+), 323 deletions(-)

diff --git a/arch/arm/mach-omap1/Makefile b/arch/arm/mach-omap1/Makefile
index fd4df71..69f293d 100644
--- a/arch/arm/mach-omap1/Makefile
+++ b/arch/arm/mach-omap1/Makefile
@@ -46,6 +46,12 @@ ifeq ($(CONFIG_ARCH_OMAP15XX),y)
 obj-$(CONFIG_MACH_OMAP_INNOVATOR)  += fpga.o
 endif
 
+# GPIO
+obj-$(CONFIG_ARCH_OMAP730) += gpio7xx.o
+obj-$(CONFIG_ARCH_OMAP850) += gpio7xx.o
+obj-$(CONFIG_ARCH_OMAP15XX)+= gpio15xx.o
+obj-$(CONFIG_ARCH_OMAP16XX)+= gpio16xx.o
+
 # LEDs support
 led-$(CONFIG_MACH_OMAP_H2) += leds-h2p2-debug.o
 led-$(CONFIG_MACH_OMAP_H3) += leds-h2p2-debug.o
diff --git a/arch/arm/mach-omap1/clock_data.c b/arch/arm/mach-omap1/clock_data.c
index aa8558a..5c2a0a1 100644
--- a/arch/arm/mach-omap1/clock_data.c
+++ b/arch/arm/mach-omap1/clock_data.c
@@ -99,7 +99,7 @@ static struct arm_idlect1_clk armper_ck = {
  * activation.  [ GPIO code for 1510 ]
  */
 static struct clk arm_gpio_ck = {
-   .name   = arm_gpio_ck,
+   .name   = ick,
.ops= clkops_generic,
.parent = ck_dpll1,
.flags  = ENABLE_ON_INIT,
@@ -589,7 +589,7 @@ static struct omap_clk omap_clks[] = {
CLK(NULL,   ck_sossi, sossi_ck,  CK_16XX),
CLK(NULL,   arm_ck,   arm_ck,CK_16XX | CK_1510 | 
CK_310),
CLK(NULL,   armper_ck,armper_ck.clk, CK_16XX | CK_1510 | 
CK_310),
-   CLK(NULL,   arm_gpio_ck,  arm_gpio_ck,   CK_1510 | CK_310),
+   CLK(omap-gpio.0, ick, arm_gpio_ck, CK_1510 | CK_310),
CLK(NULL,   armxor_ck,armxor_ck.clk, CK_16XX | CK_1510 | 
CK_310 | CK_7XX),
CLK(NULL,   armtim_ck,armtim_ck.clk, CK_16XX | CK_1510 | 
CK_310),
CLK(omap_wdt, fck,  armwdt_ck.clk, CK_16XX | CK_1510 | 
CK_310),
diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile
index ae5f36f..0756b84 100644
--- a/arch/arm/mach-omap2/Makefile
+++ b/arch/arm/mach-omap2/Makefile
@@ -3,7 +3,7 @@
 #
 
 # Common support
-obj-y := id.o io.o control.o mux.o devices.o serial.o gpmc.o timer-gp.o
+obj-y := id.o io.o control.o mux.o devices.o serial.o gpmc.o timer-gp.o gpio.o
 
 omap-2-3-common= irq.o sdrc.o
 hwmod-common   = omap_hwmod.o \
diff --git a/arch/arm/plat-omap/gpio.c b/arch/arm/plat-omap/gpio.c
index 3ea616a..7f8ef27 100644
--- a/arch/arm/plat-omap/gpio.c
+++ b/arch/arm/plat-omap/gpio.c
@@ -21,7 +21,10 @@
 #include linux/err.h
 #include linux/clk.h
 #include linux/io.h
+#include linux/slab.h
+#include linux/pm_runtime.h
 
+#include plat/omap_device.h
 #include mach/hardware.h
 #include asm/irq.h
 #include mach/irqs.h
@@ -32,7 +35,6 @@
 /*
  * OMAP1510 GPIO registers
  */
-#define OMAP1510_GPIO_BASE 0xfffce000
 #define OMAP1510_GPIO_DATA_INPUT   0x00
 #define OMAP1510_GPIO_DATA_OUTPUT  0x04
 #define OMAP1510_GPIO_DIR_CONTROL  0x08
@@ -46,10 +48,6 @@
 /*
  * OMAP1610 specific GPIO registers
  */
-#define OMAP1610_GPIO1_BASE0xfffbe400
-#define OMAP1610_GPIO2_BASE0xfffbec00
-#define OMAP1610_GPIO3_BASE0xfffbb400
-#define OMAP1610_GPIO4_BASE0xfffbbc00
 #define OMAP1610_GPIO_REVISION 0x
 #define OMAP1610_GPIO_SYSCONFIG0x0010