Omap2430 has additional support for high-speed I2C.
This patch moves I2C speed parameter (from module) to platform data.
Also added basic High Speed support based on I2C bus speed.
Signed-off-by: Syed Mohammed Khasim  <x0khasim@ti.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
        {OMAP_TAG_UART, &sdp2430_uart_config},
 };
 
+#if    defined(CONFIG_I2C_OMAP) || defined(CONFIG_I2C_OMAP_MODULE)
+
+#define OMAP2_I2C_BASE1                0x48070000
+#define OMAP2_I2C_BASE2                0x48072000
+#define OMAP2_I2C_INT1         56
+#define OMAP2_I2C_INT2         57
+
+static u32 omap2_i2c1_clkrate  = 400;
+static u32 omap2_i2c2_clkrate  = 2600;
+
+static struct resource i2c_resources1[] = {
+       {
+               .start  = OMAP2_I2C_BASE1,
+               .end    = OMAP2_I2C_BASE1 + 0x3f,
+               .flags  = IORESOURCE_MEM,
+       },
+       {
+               .start  = OMAP2_I2C_INT1,
+               .flags  = IORESOURCE_IRQ,
+       },
+};
+
+static struct resource i2c_resources2[] = {
+       {
+               .start  = OMAP2_I2C_BASE2,
+               .end    = OMAP2_I2C_BASE2 + 0x3f,
+               .flags  = IORESOURCE_MEM,
+       },
+       {
+               .start  = OMAP2_I2C_INT2,
+               .flags  = IORESOURCE_IRQ,
+       },
+};
+
+static struct platform_device omap_i2c_device1 = {
+       .name           = "i2c_omap",
+       .id             = 1,
+       .num_resources  = ARRAY_SIZE(i2c_resources1),
+       .resource       = i2c_resources1,
+       .dev            = {
+               .platform_data  = &omap2_i2c1_clkrate,
+       },
+};
+
+static struct platform_device omap_i2c_device2 = {
+       .name           = "i2c_omap",
+       .id             = 2,
+       .num_resources  = ARRAY_SIZE(i2c_resources2),
+       .resource       = i2c_resources2,
+       .dev            = {
+               .platform_data  = &omap2_i2c2_clkrate,
+       },
+};
+
+static void omap_init_i2c(void)
+{
+       (void) platform_device_register(&omap_i2c_device2);
+       (void) platform_device_register(&omap_i2c_device1);
+}
+
+#else
+
+static void omap_init_i2c(void) {}
+
+#endif
+
+static int __init omap2430_i2c_init(void)
+{
+       omap_init_i2c();
+       return 0;
+}
+
 static void __init omap_2430sdp_init(void)
 {
        platform_add_devices(sdp2430_devices, ARRAY_SIZE(sdp2430_devices));
        omap2_map_common_io();
 }
 
+arch_initcall(omap2430_i2c_init);
+
 MACHINE_START(OMAP_2430SDP, "OMAP2430 sdp2430 board")
        /* Maintainer: Syed Khasim - Texas Instruments Inc */
        .phys_io        = 0x48000000,
 
 };
 
 static struct clk i2chs2_fck = {
-       .name           = "i2chs2_fck",
+       .name           = "i2chs_fck",
+       .id             = 2,
        .parent         = &func_96m_ck,
        .flags          = CLOCK_IN_OMAP243X,
        .enable_reg     = (void __iomem *)&CM_FCLKEN2_CORE,
 };
 
 static struct clk i2chs1_fck = {
-       .name           = "i2chs1_fck",
+       .name           = "i2chs_fck",
+       .id             = 1,
        .parent         = &func_96m_ck,
        .flags          = CLOCK_IN_OMAP243X,
        .enable_reg     = (void __iomem *)&CM_FCLKEN2_CORE,
 
 #include <asm/arch/gpio.h>
 #include <asm/arch/eac.h>
 
+#if    !defined(CONFIG_ARCH_OMAP243X)
 #if    defined(CONFIG_I2C_OMAP) || defined(CONFIG_I2C_OMAP_MODULE)
 
 #define OMAP2_I2C_BASE2                0x48072000
 #define OMAP2_I2C_INT2         57
 
+static u32 omap2_i2c2_clkrate  = 100;
 static struct resource i2c_resources2[] = {
        {
                .start          = OMAP2_I2C_BASE2,
        .id             = 2,
        .num_resources  = ARRAY_SIZE(i2c_resources2),
        .resource       = i2c_resources2,
+       .dev            = {
+               .platform_data  = &omap2_i2c2_clkrate,
+       },
 };
 
 /* See also arch/arm/plat-omap/devices.c for first I2C on 24xx */
        if (machine_is_omap_h4())
                return;
 
-       if (!cpu_is_omap2430()) {
-               omap_cfg_reg(J15_24XX_I2C2_SCL);
-               omap_cfg_reg(H19_24XX_I2C2_SDA);
-       }
+       omap_cfg_reg(J15_24XX_I2C2_SCL);
+       omap_cfg_reg(H19_24XX_I2C2_SDA);
+
        (void) platform_device_register(&omap_i2c_device2);
 }
 
 
 static void omap_init_i2c(void) {}
 
+#endif
 #endif
 
 #if defined(CONFIG_OMAP_DSP) || defined(CONFIG_OMAP_DSP_MODULE)
        /* please keep these calls, and their implementations above,
         * in alphabetical order so they're easier to sort through.
         */
-       omap_init_i2c();
+       if (!cpu_is_omap2430()) {
+               omap_init_i2c();
+       }
        omap_init_mbox();
        omap_init_mcspi();
        omap_init_sti();
 
 #endif /* CONFIG_OMAP_DSP */
 
 /*-------------------------------------------------------------------------*/
+#if    !defined(CONFIG_ARCH_OMAP243X)
 #if    defined(CONFIG_I2C_OMAP) || defined(CONFIG_I2C_OMAP_MODULE)
 
 #define        OMAP1_I2C_BASE          0xfffb3800
 #define OMAP1_I2C_INT          INT_I2C
 #define OMAP2_I2C_INT1         56
 
+static u32 omap2_i2c1_clkrate  = 100;
+
 static struct resource i2c_resources1[] = {
        {
                .start          = 0,
        .id             = 1,
        .num_resources  = ARRAY_SIZE(i2c_resources1),
        .resource       = i2c_resources1,
+       .dev            = {
+               .platform_data  = &omap2_i2c1_clkrate,
+       },
 };
 
 /* See also arch/arm/mach-omap2/devices.c for second I2C on 24xx */
 static void omap_init_i2c(void)
 {
-       if (cpu_is_omap24xx()) {
+       if (cpu_is_omap242x()) {
                i2c_resources1[0].start = OMAP2_I2C_BASE1;
                i2c_resources1[0].end = OMAP2_I2C_BASE1 + OMAP_I2C_SIZE;
                i2c_resources1[1].start = OMAP2_I2C_INT1;
 #else
 static inline void omap_init_i2c(void) {}
 #endif
-
+#endif
 /*-------------------------------------------------------------------------*/
 #if    defined(CONFIG_KEYBOARD_OMAP) || defined(CONFIG_KEYBOARD_OMAP_MODULE)
 
 
 static u64 mmc2_dmamask = 0xffffffff;
 
+
 static struct resource mmc2_resources[] = {
        {
                .start          = OMAP_MMC2_BASE,
        omap_init_uwire();
        omap_init_wdt();
        omap_init_rng();
-       omap_init_i2c();
+       if (!cpu_is_omap2430()) {
+               omap_init_i2c();
+       }
        return 0;
 }
 arch_initcall(omap_init_devices);