From: Li, Ning Date: Wed, 14 Dec 2011 07:32:02 +0000 (+0800) Subject: [PORT FROM GB] I2C patches X-Git-Tag: 2.1b_release~1814 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=33ca1d3f41b29669b9054e56e805434988b1c238;p=kernel%2Fkernel-mfld-blackbay.git [PORT FROM GB] I2C patches BZ: 17357 This BZ includes the following BZ: 15120, 13176 Change-Id: I9762daad766811cf87379aa2fa33ce8d418987c7 Signed-off-by: Li, Ning Reviewed-on: http://android.intel.com:8080/27295 Reviewed-by: Du, Alek Reviewed-by: Yang, Bin Tested-by: Wang, Zhifeng Reviewed-by: buildbot Tested-by: buildbot --- diff --git a/arch/x86/platform/mfld/blackbay_pr2.c b/arch/x86/platform/mfld/blackbay_pr2.c index 9edb786..628a814 100644 --- a/arch/x86/platform/mfld/blackbay_pr2.c +++ b/arch/x86/platform/mfld/blackbay_pr2.c @@ -21,7 +21,8 @@ #include #include #include - +#include +#include 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); diff --git a/drivers/i2c/busses/i2c-designware-core.c b/drivers/i2c/busses/i2c-designware-core.c index 0480177..52aa660 100644 --- a/drivers/i2c/busses/i2c-designware-core.c +++ b/drivers/i2c/busses/i2c-designware-core.c @@ -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); diff --git a/drivers/i2c/busses/i2c-designware-pcidrv.c b/drivers/i2c/busses/i2c-designware-pcidrv.c index 9de1b60..10223fa 100644 --- a/drivers/i2c/busses/i2c-designware-pcidrv.c +++ b/drivers/i2c/busses/i2c-designware-pcidrv.c @@ -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, diff --git a/drivers/i2c/busses/i2c-gpio.c b/drivers/i2c/busses/i2c-gpio.c index 80c7fe3..0256571 100644 --- a/drivers/i2c/busses/i2c-gpio.c +++ b/drivers/i2c/busses/i2c-gpio.c @@ -14,7 +14,6 @@ #include #include #include -#include #include @@ -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);