Re: [PATCH 02/16] ARM: OMAP: Split plat-omap/i2c.c into mach-omap1 and mach-omap2

2012-10-05 Thread Shubhrajyoti
On Friday 05 October 2012 03:34 AM, Tony Lindgren wrote:
 There's no need to keep the device related things in the
 common i2c.c as omap2+ is using hwmod. Split the code to
 mach-omap1 and mach-omap2 parts and only leave common
 code to plat-omap/i2c.c.

 Note that as omap1 only has one i2c controller, we can
 now remove the old device related macros.
Reviewed-by: Shubhrajyoti D shubhrajy...@ti.com
 Signed-off-by: Tony Lindgren t...@atomide.com
 ---
  arch/arm/mach-omap1/common.h   |3 +
  arch/arm/mach-omap1/i2c.c  |   59 +++
  arch/arm/mach-omap2/board-rm680.c  |1 
  arch/arm/mach-omap2/common.h   |4 +
  arch/arm/mach-omap2/i2c.c  |   72 +
  arch/arm/mach-omap2/i2c.h  |   25 +
  arch/arm/mach-omap2/omap_hwmod_2420_data.c |4 +
  arch/arm/mach-omap2/omap_hwmod_2430_data.c |4 +
  arch/arm/mach-omap2/omap_hwmod_33xx_data.c |4 +
  arch/arm/mach-omap2/omap_hwmod_3xxx_data.c |4 +
  arch/arm/mach-omap2/omap_hwmod_44xx_data.c |3 -
  arch/arm/mach-omap2/twl-common.c   |1 
  arch/arm/plat-omap/i2c.c   |  152 
 +---
  arch/arm/plat-omap/i2c.h   |   46 
  arch/arm/plat-omap/include/plat/common.h   |1 
  15 files changed, 202 insertions(+), 181 deletions(-)
  rename arch/arm/{plat-omap/include/plat/i2c.h = mach-omap2/i2c.h} (66%)
  create mode 100644 arch/arm/plat-omap/i2c.h

 diff --git a/arch/arm/mach-omap1/common.h b/arch/arm/mach-omap1/common.h
 index c2552b2..306b7ac 100644
 --- a/arch/arm/mach-omap1/common.h
 +++ b/arch/arm/mach-omap1/common.h
 @@ -28,6 +28,9 @@
  
  #include plat/common.h
  #include linux/mtd/mtd.h
 +#include linux/i2c-omap.h
 +
 +#include ../plat-omap/i2c.h
  
  #if defined(CONFIG_ARCH_OMAP730) || defined(CONFIG_ARCH_OMAP850)
  void omap7xx_map_io(void);
 diff --git a/arch/arm/mach-omap1/i2c.c b/arch/arm/mach-omap1/i2c.c
 index a0551a6..a6f465a 100644
 --- a/arch/arm/mach-omap1/i2c.c
 +++ b/arch/arm/mach-omap1/i2c.c
 @@ -19,11 +19,25 @@
   *
   */
  
 -#include plat/i2c.h
 +#include linux/i2c-omap.h
  #include mach/mux.h
  #include plat/cpu.h
  
 -void __init omap1_i2c_mux_pins(int bus_id)
 +#include ../plat-omap/i2c.h
 +
 +#define OMAP_I2C_SIZE0x3f
 +#define OMAP1_I2C_BASE   0xfffb3800
 +#define OMAP1_INT_I2C(32 + 4)
 +
 +static const char name[] = omap_i2c;
 +
 +static struct resource i2c_resources[2] = {
 +};
 +
 +static struct platform_device omap_i2c_devices[1] = {
 +};
 +
 +static void __init omap1_i2c_mux_pins(int bus_id)
  {
   if (cpu_is_omap7xx()) {
   omap_cfg_reg(I2C_7XX_SDA);
 @@ -33,3 +47,44 @@ void __init omap1_i2c_mux_pins(int bus_id)
   omap_cfg_reg(I2C_SCL);
   }
  }
 +
 +int __init omap_i2c_add_bus(struct omap_i2c_bus_platform_data *pdata,
 + int bus_id)
 +{
 + struct platform_device *pdev;
 + struct resource *res;
 +
 + omap1_i2c_mux_pins(bus_id);
 +
 + pdev = omap_i2c_devices[bus_id - 1];
 + pdev-id = bus_id;
 + pdev-name = name;
 + pdev-num_resources = ARRAY_SIZE(i2c_resources);
 + res = i2c_resources;
 + res[0].start = OMAP1_I2C_BASE;
 + res[0].end = res[0].start + OMAP_I2C_SIZE;
 + res[0].flags = IORESOURCE_MEM;
 + res[1].start = OMAP1_INT_I2C;
 + res[1].flags = IORESOURCE_IRQ;
 + pdev-resource = res;
 +
 + /* all OMAP1 have IP version 1 register set */
 + pdata-rev = OMAP_I2C_IP_VERSION_1;
 +
 + /* all OMAP1 I2C are implemented like this */
 + pdata-flags = OMAP_I2C_FLAG_NO_FIFO |
 +OMAP_I2C_FLAG_SIMPLE_CLOCK |
 +OMAP_I2C_FLAG_16BIT_DATA_REG |
 +OMAP_I2C_FLAG_ALWAYS_ARMXOR_CLK;
 +
 + /* how the cpu bus is wired up differs for 7xx only */
 +
 + if (cpu_is_omap7xx())
 + pdata-flags |= OMAP_I2C_FLAG_BUS_SHIFT_1;
 + else
 + pdata-flags |= OMAP_I2C_FLAG_BUS_SHIFT_2;
 +
 + pdev-dev.platform_data = pdata;
 +
 + return platform_device_register(pdev);
 +}
 diff --git a/arch/arm/mach-omap2/board-rm680.c 
 b/arch/arm/mach-omap2/board-rm680.c
 index 45997bf..a57ed21 100644
 --- a/arch/arm/mach-omap2/board-rm680.c
 +++ b/arch/arm/mach-omap2/board-rm680.c
 @@ -22,7 +22,6 @@
  #include asm/mach/arch.h
  #include asm/mach-types.h
  
 -#include plat/i2c.h
  #include plat/mmc.h
  #include plat/usb.h
  #include plat/gpmc.h
 diff --git a/arch/arm/mach-omap2/common.h b/arch/arm/mach-omap2/common.h
 index 7045e4d..a68b421 100644
 --- a/arch/arm/mach-omap2/common.h
 +++ b/arch/arm/mach-omap2/common.h
 @@ -28,7 +28,9 @@
  
  #include linux/irq.h
  #include linux/delay.h
 +#include linux/i2c.h
  #include linux/i2c/twl.h
 +#include linux/i2c-omap.h
  
  #include asm/proc-fns.h
  
 @@ -36,6 +38,8 @@
  #include plat/serial.h
  #include plat/common.h
  
 +#include i2c.h
 +
  #define OMAP_INTC_START  

[PATCH 02/16] ARM: OMAP: Split plat-omap/i2c.c into mach-omap1 and mach-omap2

2012-10-04 Thread Tony Lindgren
There's no need to keep the device related things in the
common i2c.c as omap2+ is using hwmod. Split the code to
mach-omap1 and mach-omap2 parts and only leave common
code to plat-omap/i2c.c.

Note that as omap1 only has one i2c controller, we can
now remove the old device related macros.

Signed-off-by: Tony Lindgren t...@atomide.com
---
 arch/arm/mach-omap1/common.h   |3 +
 arch/arm/mach-omap1/i2c.c  |   59 +++
 arch/arm/mach-omap2/board-rm680.c  |1 
 arch/arm/mach-omap2/common.h   |4 +
 arch/arm/mach-omap2/i2c.c  |   72 +
 arch/arm/mach-omap2/i2c.h  |   25 +
 arch/arm/mach-omap2/omap_hwmod_2420_data.c |4 +
 arch/arm/mach-omap2/omap_hwmod_2430_data.c |4 +
 arch/arm/mach-omap2/omap_hwmod_33xx_data.c |4 +
 arch/arm/mach-omap2/omap_hwmod_3xxx_data.c |4 +
 arch/arm/mach-omap2/omap_hwmod_44xx_data.c |3 -
 arch/arm/mach-omap2/twl-common.c   |1 
 arch/arm/plat-omap/i2c.c   |  152 +---
 arch/arm/plat-omap/i2c.h   |   46 
 arch/arm/plat-omap/include/plat/common.h   |1 
 15 files changed, 202 insertions(+), 181 deletions(-)
 rename arch/arm/{plat-omap/include/plat/i2c.h = mach-omap2/i2c.h} (66%)
 create mode 100644 arch/arm/plat-omap/i2c.h

diff --git a/arch/arm/mach-omap1/common.h b/arch/arm/mach-omap1/common.h
index c2552b2..306b7ac 100644
--- a/arch/arm/mach-omap1/common.h
+++ b/arch/arm/mach-omap1/common.h
@@ -28,6 +28,9 @@
 
 #include plat/common.h
 #include linux/mtd/mtd.h
+#include linux/i2c-omap.h
+
+#include ../plat-omap/i2c.h
 
 #if defined(CONFIG_ARCH_OMAP730) || defined(CONFIG_ARCH_OMAP850)
 void omap7xx_map_io(void);
diff --git a/arch/arm/mach-omap1/i2c.c b/arch/arm/mach-omap1/i2c.c
index a0551a6..a6f465a 100644
--- a/arch/arm/mach-omap1/i2c.c
+++ b/arch/arm/mach-omap1/i2c.c
@@ -19,11 +19,25 @@
  *
  */
 
-#include plat/i2c.h
+#include linux/i2c-omap.h
 #include mach/mux.h
 #include plat/cpu.h
 
-void __init omap1_i2c_mux_pins(int bus_id)
+#include ../plat-omap/i2c.h
+
+#define OMAP_I2C_SIZE  0x3f
+#define OMAP1_I2C_BASE 0xfffb3800
+#define OMAP1_INT_I2C  (32 + 4)
+
+static const char name[] = omap_i2c;
+
+static struct resource i2c_resources[2] = {
+};
+
+static struct platform_device omap_i2c_devices[1] = {
+};
+
+static void __init omap1_i2c_mux_pins(int bus_id)
 {
if (cpu_is_omap7xx()) {
omap_cfg_reg(I2C_7XX_SDA);
@@ -33,3 +47,44 @@ void __init omap1_i2c_mux_pins(int bus_id)
omap_cfg_reg(I2C_SCL);
}
 }
+
+int __init omap_i2c_add_bus(struct omap_i2c_bus_platform_data *pdata,
+   int bus_id)
+{
+   struct platform_device *pdev;
+   struct resource *res;
+
+   omap1_i2c_mux_pins(bus_id);
+
+   pdev = omap_i2c_devices[bus_id - 1];
+   pdev-id = bus_id;
+   pdev-name = name;
+   pdev-num_resources = ARRAY_SIZE(i2c_resources);
+   res = i2c_resources;
+   res[0].start = OMAP1_I2C_BASE;
+   res[0].end = res[0].start + OMAP_I2C_SIZE;
+   res[0].flags = IORESOURCE_MEM;
+   res[1].start = OMAP1_INT_I2C;
+   res[1].flags = IORESOURCE_IRQ;
+   pdev-resource = res;
+
+   /* all OMAP1 have IP version 1 register set */
+   pdata-rev = OMAP_I2C_IP_VERSION_1;
+
+   /* all OMAP1 I2C are implemented like this */
+   pdata-flags = OMAP_I2C_FLAG_NO_FIFO |
+  OMAP_I2C_FLAG_SIMPLE_CLOCK |
+  OMAP_I2C_FLAG_16BIT_DATA_REG |
+  OMAP_I2C_FLAG_ALWAYS_ARMXOR_CLK;
+
+   /* how the cpu bus is wired up differs for 7xx only */
+
+   if (cpu_is_omap7xx())
+   pdata-flags |= OMAP_I2C_FLAG_BUS_SHIFT_1;
+   else
+   pdata-flags |= OMAP_I2C_FLAG_BUS_SHIFT_2;
+
+   pdev-dev.platform_data = pdata;
+
+   return platform_device_register(pdev);
+}
diff --git a/arch/arm/mach-omap2/board-rm680.c 
b/arch/arm/mach-omap2/board-rm680.c
index 45997bf..a57ed21 100644
--- a/arch/arm/mach-omap2/board-rm680.c
+++ b/arch/arm/mach-omap2/board-rm680.c
@@ -22,7 +22,6 @@
 #include asm/mach/arch.h
 #include asm/mach-types.h
 
-#include plat/i2c.h
 #include plat/mmc.h
 #include plat/usb.h
 #include plat/gpmc.h
diff --git a/arch/arm/mach-omap2/common.h b/arch/arm/mach-omap2/common.h
index 7045e4d..a68b421 100644
--- a/arch/arm/mach-omap2/common.h
+++ b/arch/arm/mach-omap2/common.h
@@ -28,7 +28,9 @@
 
 #include linux/irq.h
 #include linux/delay.h
+#include linux/i2c.h
 #include linux/i2c/twl.h
+#include linux/i2c-omap.h
 
 #include asm/proc-fns.h
 
@@ -36,6 +38,8 @@
 #include plat/serial.h
 #include plat/common.h
 
+#include i2c.h
+
 #define OMAP_INTC_STARTNR_IRQS
 
 #ifdef CONFIG_SOC_OMAP2420
diff --git a/arch/arm/mach-omap2/i2c.c b/arch/arm/mach-omap2/i2c.c
index fc57e67..b15416c 100644
--- a/arch/arm/mach-omap2/i2c.c
+++ b/arch/arm/mach-omap2/i2c.c
@@