[PORT FROM GB] I2C patches
authorLi, Ning <ning.li@intel.com>
Wed, 14 Dec 2011 07:32:02 +0000 (15:32 +0800)
committerbuildbot <buildbot@intel.com>
Thu, 15 Dec 2011 07:57:26 +0000 (23:57 -0800)
BZ: 17357

This BZ includes the following BZ:
15120, 13176

Change-Id: I9762daad766811cf87379aa2fa33ce8d418987c7
Signed-off-by: Li, Ning <ning.li@intel.com>
Reviewed-on: http://android.intel.com:8080/27295
Reviewed-by: Du, Alek <alek.du@intel.com>
Reviewed-by: Yang, Bin <bin.yang@intel.com>
Tested-by: Wang, Zhifeng <zhifeng.wang@intel.com>
Reviewed-by: buildbot <buildbot@intel.com>
Tested-by: buildbot <buildbot@intel.com>
arch/x86/platform/mfld/blackbay_pr2.c
drivers/i2c/busses/i2c-designware-core.c
drivers/i2c/busses/i2c-designware-pcidrv.c
drivers/i2c/busses/i2c-gpio.c

index 9edb786..628a814 100644 (file)
@@ -21,7 +21,8 @@
 #include <linux/input/lis3dh.h>
 #include <linux/ms5607.h>
 #include <linux/a1026.h>
-
+#include <linux/i2c-gpio.h>
+#include <linux/lnw_gpio.h>
 
 static struct lis3dh_acc_platform_data lis3dh_pdata = {
        .poll_interval = 200,
@@ -213,3 +214,45 @@ static int __init platform_bkbpr2_subsys_init(void)
 }
 device_initcall(platform_bkbpr2_subsys_init);
 
+static int hdmi_i2c_workaround(void)
+{
+       int ret;
+       struct platform_device *pdev;
+       struct i2c_gpio_platform_data *pdata;
+
+       /*
+        * Hard code a gpio controller platform device to take over
+        * the two gpio pins used to be controlled by i2c bus 3.
+        * This is to support HDMI EDID extension block read, which
+        * is not supported by the current i2c controller, so we use
+        * GPIO pin the simulate an i2c bus.
+        */
+       pdev = platform_device_alloc("i2c-gpio", 8);
+       if (!pdev) {
+               pr_err("i2c-gpio: failed to alloc platform device\n");
+               ret = -ENOMEM;
+               goto out;
+       }
+
+       pdata = kzalloc(sizeof(struct i2c_gpio_platform_data), GFP_KERNEL);
+       if (!pdata) {
+               pr_err("i2c-gpio: failed to alloc platform data\n");
+               kfree(pdev);
+               ret = -ENOMEM;
+               goto out;
+       }
+       pdata->scl_pin = 35 + 96;
+       pdata->sda_pin = 36 + 96;
+       pdata->sda_is_open_drain = 0;
+       pdata->scl_is_open_drain = 0;
+       pdev->dev.platform_data = pdata;
+
+       platform_device_add(pdev);
+
+       lnw_gpio_set_alt(pdata->sda_pin, LNW_GPIO);
+       lnw_gpio_set_alt(pdata->scl_pin, LNW_GPIO);
+
+out:
+       return ret;
+}
+rootfs_initcall(hdmi_i2c_workaround);
index 0480177..52aa660 100644 (file)
@@ -307,28 +307,28 @@ int i2c_dw_init(struct dw_i2c_dev *dev)
 
        /* Standard-mode */
        hcnt = i2c_dw_scl_hcnt(input_clock_khz,
-                               40,     /* tHD;STA = tHIGH = 4.0 us */
+                               227,    /* tHD;STA = tHIGH = 22.7 us */
                                3,      /* tf = 0.3 us */
                                0,      /* 0: DW default, 1: Ideal */
-                               0);     /* No offset */
+                               23);    /* offset = 23 */
        lcnt = i2c_dw_scl_lcnt(input_clock_khz,
-                               47,     /* tLOW = 4.7 us */
+                               227,    /* tLOW = 22.7 us */
                                3,      /* tf = 0.3 us */
-                               0);     /* No offset */
+                               28);    /* offset = 28 */
        dw_writel(dev, hcnt, DW_IC_SS_SCL_HCNT);
        dw_writel(dev, lcnt, DW_IC_SS_SCL_LCNT);
        dev_dbg(dev->dev, "Standard-mode HCNT:LCNT = %d:%d\n", hcnt, lcnt);
 
        /* Fast-mode */
        hcnt = i2c_dw_scl_hcnt(input_clock_khz,
-                               6,      /* tHD;STA = tHIGH = 0.6 us */
+                               52,     /* tHD;STA = tHIGH = 5.2 us */
                                3,      /* tf = 0.3 us */
                                0,      /* 0: DW default, 1: Ideal */
-                               0);     /* No offset */
+                               11);    /* offset = 11 */
        lcnt = i2c_dw_scl_lcnt(input_clock_khz,
-                               13,     /* tLOW = 1.3 us */
+                               72,     /* tLOW = 7.2 us */
                                3,      /* tf = 0.3 us */
-                               0);     /* No offset */
+                               12);    /* offset = 12 */
        dw_writel(dev, hcnt, DW_IC_FS_SCL_HCNT);
        dw_writel(dev, lcnt, DW_IC_FS_SCL_LCNT);
        dev_dbg(dev->dev, "Fast-mode HCNT:LCNT = %d:%d\n", hcnt, lcnt);
index 9de1b60..10223fa 100644 (file)
@@ -124,7 +124,7 @@ static struct  dw_pci_controller  dw_pci_controllers[] = {
                .bus_cfg   = INTEL_MID_STD_CFG | DW_IC_CON_SPEED_STD,
                .tx_fifo_depth = 32,
                .rx_fifo_depth = 32,
-               .clk_khz      = 17000,
+               .clk_khz      = 20500,
        },
        [medfield_4] = {
                .bus_num     = 4,
index 80c7fe3..0256571 100644 (file)
@@ -14,7 +14,6 @@
 #include <linux/module.h>
 #include <linux/slab.h>
 #include <linux/platform_device.h>
-#include <linux/lnw_gpio.h>
 
 #include <asm/gpio.h>
 
@@ -105,9 +104,6 @@ static int __devinit i2c_gpio_probe(struct platform_device *pdev)
        if (ret)
                goto err_request_scl;
 
-       lnw_gpio_set_alt(pdata->sda_pin, LNW_GPIO);
-       lnw_gpio_set_alt(pdata->scl_pin, LNW_GPIO);
-
        if (pdata->sda_is_open_drain) {
                gpio_direction_output(pdata->sda_pin, 1);
                bit_data->setsda = i2c_gpio_setsda_val;
@@ -208,43 +204,11 @@ static struct platform_driver i2c_gpio_driver = {
 static int __init i2c_gpio_init(void)
 {
        int ret;
-       struct platform_device *pdev;
-       struct i2c_gpio_platform_data *pdata;
-
-       /*
-        * Hard code a gpio controller platform device to take over
-        * the two gpio pins used to be controlled by i2c bus 3.
-        * This is to support HDMI EDID extension block read, which
-        * is not supported by the current i2c controller, so we use
-        * GPIO pin the simulate an i2c bus.
-        */
-       pdev = platform_device_alloc("i2c-gpio", 8);
-       if (!pdev) {
-               pr_err("i2c-gpio: failed to alloc platform device\n");
-               ret = -ENOMEM;
-               goto out;
-       }
-
-       pdata = kzalloc(sizeof(struct i2c_gpio_platform_data), GFP_KERNEL);
-       if (!pdata) {
-               pr_err("i2c-gpio: failed to alloc platform data\n");
-               kfree(pdev);
-               ret = -ENOMEM;
-               goto out;
-       }
-       pdata->scl_pin = 35 + 96;
-       pdata->sda_pin = 36 + 96;
-       pdata->sda_is_open_drain = 1;
-       pdata->scl_is_open_drain = 1;
-       pdev->dev.platform_data = pdata;
-
-       platform_device_add(pdev);
 
        ret = platform_driver_register(&i2c_gpio_driver);
        if (ret)
                printk(KERN_ERR "i2c-gpio: probe failed: %d\n", ret);
 
-out:
        return ret;
 }
 late_initcall(i2c_gpio_init);