Commit 38da590b authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'next-i2c' of git://git.fluff.org/bjdooks/linux

* 'next-i2c' of git://git.fluff.org/bjdooks/linux:
  i2c-eg20t : Fix the issue of Combined R/W transfer mode
  i2c-eg20t : Support Combined R/W transfer mode
  i2c: Tegra: Add DeviceTree support
parents 7505cb60 07e729ce
...@@ -673,7 +673,8 @@ static s32 pch_i2c_xfer(struct i2c_adapter *i2c_adap, ...@@ -673,7 +673,8 @@ static s32 pch_i2c_xfer(struct i2c_adapter *i2c_adap,
/* transfer not completed */ /* transfer not completed */
adap->pch_i2c_xfer_in_progress = true; adap->pch_i2c_xfer_in_progress = true;
pmsg = &msgs[0]; for (i = 0; i < num && ret >= 0; i++) {
pmsg = &msgs[i];
pmsg->flags |= adap->pch_buff_mode_en; pmsg->flags |= adap->pch_buff_mode_en;
status = pmsg->flags; status = pmsg->flags;
pch_dbg(adap, pch_dbg(adap,
...@@ -684,21 +685,21 @@ static s32 pch_i2c_xfer(struct i2c_adapter *i2c_adap, ...@@ -684,21 +685,21 @@ static s32 pch_i2c_xfer(struct i2c_adapter *i2c_adap,
/* calculate actual message length excluding /* calculate actual message length excluding
* the sub address fields */ * the sub address fields */
msglen = (pmsg->len) - (subaddrlen + 1); msglen = (pmsg->len) - (subaddrlen + 1);
if (status & (I2C_M_RD)) {
pch_dbg(adap, "invoking pch_i2c_readbytes\n"); if ((status & (I2C_M_RD)) != false) {
ret = pch_i2c_readbytes(i2c_adap, pmsg, (i + 1 == num), ret = pch_i2c_readbytes(i2c_adap, pmsg, (i + 1 == num),
(i == 0)); (i == 0));
} else { } else {
pch_dbg(adap, "invoking pch_i2c_writebytes\n");
ret = pch_i2c_writebytes(i2c_adap, pmsg, (i + 1 == num), ret = pch_i2c_writebytes(i2c_adap, pmsg, (i + 1 == num),
(i == 0)); (i == 0));
} }
}
adap->pch_i2c_xfer_in_progress = false; /* transfer completed */ adap->pch_i2c_xfer_in_progress = false; /* transfer completed */
mutex_unlock(&pch_mutex); mutex_unlock(&pch_mutex);
return ret; return (ret < 0) ? ret : num;
} }
/** /**
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/i2c-tegra.h> #include <linux/i2c-tegra.h>
#include <linux/of_i2c.h>
#include <asm/unaligned.h> #include <asm/unaligned.h>
...@@ -546,6 +547,7 @@ static int tegra_i2c_probe(struct platform_device *pdev) ...@@ -546,6 +547,7 @@ static int tegra_i2c_probe(struct platform_device *pdev)
struct resource *iomem; struct resource *iomem;
struct clk *clk; struct clk *clk;
struct clk *i2c_clk; struct clk *i2c_clk;
const unsigned int *prop;
void *base; void *base;
int irq; int irq;
int ret = 0; int ret = 0;
...@@ -603,7 +605,17 @@ static int tegra_i2c_probe(struct platform_device *pdev) ...@@ -603,7 +605,17 @@ static int tegra_i2c_probe(struct platform_device *pdev)
i2c_dev->irq = irq; i2c_dev->irq = irq;
i2c_dev->cont_id = pdev->id; i2c_dev->cont_id = pdev->id;
i2c_dev->dev = &pdev->dev; i2c_dev->dev = &pdev->dev;
i2c_dev->bus_clk_rate = pdata ? pdata->bus_clk_rate : 100000;
i2c_dev->bus_clk_rate = 100000; /* default clock rate */
if (pdata) {
i2c_dev->bus_clk_rate = pdata->bus_clk_rate;
} else if (i2c_dev->dev->of_node) { /* if there is a device tree node ... */
prop = of_get_property(i2c_dev->dev->of_node,
"clock-frequency", NULL);
if (prop)
i2c_dev->bus_clk_rate = be32_to_cpup(prop);
}
if (pdev->id == 3) if (pdev->id == 3)
i2c_dev->is_dvc = 1; i2c_dev->is_dvc = 1;
...@@ -633,6 +645,7 @@ static int tegra_i2c_probe(struct platform_device *pdev) ...@@ -633,6 +645,7 @@ static int tegra_i2c_probe(struct platform_device *pdev)
i2c_dev->adapter.algo = &tegra_i2c_algo; i2c_dev->adapter.algo = &tegra_i2c_algo;
i2c_dev->adapter.dev.parent = &pdev->dev; i2c_dev->adapter.dev.parent = &pdev->dev;
i2c_dev->adapter.nr = pdev->id; i2c_dev->adapter.nr = pdev->id;
i2c_dev->adapter.dev.of_node = pdev->dev.of_node;
ret = i2c_add_numbered_adapter(&i2c_dev->adapter); ret = i2c_add_numbered_adapter(&i2c_dev->adapter);
if (ret) { if (ret) {
...@@ -640,6 +653,8 @@ static int tegra_i2c_probe(struct platform_device *pdev) ...@@ -640,6 +653,8 @@ static int tegra_i2c_probe(struct platform_device *pdev)
goto err_free_irq; goto err_free_irq;
} }
of_i2c_register_devices(&i2c_dev->adapter);
return 0; return 0;
err_free_irq: err_free_irq:
free_irq(i2c_dev->irq, i2c_dev); free_irq(i2c_dev->irq, i2c_dev);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment