Commit 0b500768 authored by Tony Lindgren's avatar Tony Lindgren

Sync i2c-omap with patchesg going to mainline tree

Sync i2c-omap with patchesg going to mainline tree:

- Unify the clock naming for 242x and 243x
- Don't try to set a NULL pointer to 100
- Do a readback to flush posted write instead of wmb()
Signed-off-by: default avatarTony Lindgren <tony@atomide.com>
parent 41cc3cea
...@@ -2500,7 +2500,7 @@ static struct clk i2c2_fck = { ...@@ -2500,7 +2500,7 @@ static struct clk i2c2_fck = {
}; };
static struct clk i2chs2_fck = { static struct clk i2chs2_fck = {
.name = "i2chs_fck", .name = "i2c_fck",
.id = 2, .id = 2,
.parent = &func_96m_ck, .parent = &func_96m_ck,
.prcm_mod = CORE_MOD, .prcm_mod = CORE_MOD,
...@@ -2538,7 +2538,7 @@ static struct clk i2c1_fck = { ...@@ -2538,7 +2538,7 @@ static struct clk i2c1_fck = {
}; };
static struct clk i2chs1_fck = { static struct clk i2chs1_fck = {
.name = "i2chs_fck", .name = "i2c_fck",
.id = 1, .id = 1,
.parent = &func_96m_ck, .parent = &func_96m_ck,
.prcm_mod = CORE_MOD, .prcm_mod = CORE_MOD,
......
...@@ -165,28 +165,17 @@ static int __init omap_i2c_get_clocks(struct omap_i2c_dev *dev) ...@@ -165,28 +165,17 @@ static int __init omap_i2c_get_clocks(struct omap_i2c_dev *dev)
return -ENODEV; return -ENODEV;
} }
} }
/* For I2C operations on 2430 we need 96Mhz clock */
if (cpu_is_omap2430()) { dev->fclk = clk_get(dev->dev, "i2c_fck");
dev->fclk = clk_get(dev->dev, "i2chs_fck"); if (IS_ERR(dev->fclk)) {
if (IS_ERR(dev->fclk)) { if (dev->iclk != NULL) {
if (dev->iclk != NULL) { clk_put(dev->iclk);
clk_put(dev->iclk); dev->iclk = NULL;
dev->iclk = NULL;
}
dev->fclk = NULL;
return -ENODEV;
}
} else {
dev->fclk = clk_get(dev->dev, "i2c_fck");
if (IS_ERR(dev->fclk)) {
if (dev->iclk != NULL) {
clk_put(dev->iclk);
dev->iclk = NULL;
}
dev->fclk = NULL;
return -ENODEV;
} }
dev->fclk = NULL;
return -ENODEV;
} }
return 0; return 0;
} }
...@@ -220,16 +209,14 @@ static void omap_i2c_idle(struct omap_i2c_dev *dev) ...@@ -220,16 +209,14 @@ static void omap_i2c_idle(struct omap_i2c_dev *dev)
dev->iestate = omap_i2c_read_reg(dev, OMAP_I2C_IE_REG); dev->iestate = omap_i2c_read_reg(dev, OMAP_I2C_IE_REG);
omap_i2c_write_reg(dev, OMAP_I2C_IE_REG, 0); omap_i2c_write_reg(dev, OMAP_I2C_IE_REG, 0);
if (dev->rev1) if (dev->rev1) {
iv = omap_i2c_read_reg(dev, OMAP_I2C_IV_REG); /* Read clears */ iv = omap_i2c_read_reg(dev, OMAP_I2C_IV_REG); /* Read clears */
else } else {
omap_i2c_write_reg(dev, OMAP_I2C_STAT_REG, dev->iestate); omap_i2c_write_reg(dev, OMAP_I2C_STAT_REG, dev->iestate);
/*
* The wmb() is to ensure that the I2C interrupt mask write /* Flush posted write before the dev->idle store occurs */
* reaches the I2C controller before the dev->idle store omap_i2c_read_reg(dev, OMAP_I2C_STAT_REG);
* occurs. }
*/
wmb();
dev->idle = 1; dev->idle = 1;
clk_disable(dev->fclk); clk_disable(dev->fclk);
if (dev->iclk != NULL) if (dev->iclk != NULL)
...@@ -415,7 +402,7 @@ static int omap_i2c_xfer_msg(struct i2c_adapter *adap, ...@@ -415,7 +402,7 @@ static int omap_i2c_xfer_msg(struct i2c_adapter *adap,
omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, w); omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, w);
/* /*
* Don't write stt and stp together on some hardware * Don't write stt and stp together on some hardware.
*/ */
if (dev->b_hw && stop) { if (dev->b_hw && stop) {
unsigned long delay = jiffies + OMAP_I2C_TIMEOUT; unsigned long delay = jiffies + OMAP_I2C_TIMEOUT;
...@@ -436,6 +423,11 @@ static int omap_i2c_xfer_msg(struct i2c_adapter *adap, ...@@ -436,6 +423,11 @@ static int omap_i2c_xfer_msg(struct i2c_adapter *adap,
w &= ~OMAP_I2C_CON_STT; w &= ~OMAP_I2C_CON_STT;
omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, w); omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, w);
} }
/*
* REVISIT: We should abort the transfer on signals, but the bus goes
* into arbitration and we're currently unable to recover from it.
*/
r = wait_for_completion_timeout(&dev->cmd_complete, r = wait_for_completion_timeout(&dev->cmd_complete,
OMAP_I2C_TIMEOUT); OMAP_I2C_TIMEOUT);
dev->buf_len = 0; dev->buf_len = 0;
...@@ -578,7 +570,7 @@ omap_i2c_rev1_isr(int this_irq, void *dev_id) ...@@ -578,7 +570,7 @@ omap_i2c_rev1_isr(int this_irq, void *dev_id)
return IRQ_HANDLED; return IRQ_HANDLED;
} }
#else #else
#define omap_i2c_rev1_isr 0 #define omap_i2c_rev1_isr NULL
#endif #endif
static irqreturn_t static irqreturn_t
...@@ -719,7 +711,7 @@ omap_i2c_probe(struct platform_device *pdev) ...@@ -719,7 +711,7 @@ omap_i2c_probe(struct platform_device *pdev)
struct i2c_adapter *adap; struct i2c_adapter *adap;
struct resource *mem, *irq, *ioarea; struct resource *mem, *irq, *ioarea;
int r; int r;
u32 *speed = NULL; u32 speed = 0;
/* NOTE: driver uses the static register mapping */ /* NOTE: driver uses the static register mapping */
mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
...@@ -747,11 +739,11 @@ omap_i2c_probe(struct platform_device *pdev) ...@@ -747,11 +739,11 @@ omap_i2c_probe(struct platform_device *pdev)
} }
if (pdev->dev.platform_data != NULL) if (pdev->dev.platform_data != NULL)
speed = (u32 *) pdev->dev.platform_data; speed = *(u32 *)pdev->dev.platform_data;
else else
*speed = 100; /* Defualt speed */ speed = 100; /* Defualt speed */
dev->speed = *speed; dev->speed = speed;
dev->idle = 1; dev->idle = 1;
dev->dev = &pdev->dev; dev->dev = &pdev->dev;
dev->irq = irq->start; dev->irq = irq->start;
...@@ -763,8 +755,7 @@ omap_i2c_probe(struct platform_device *pdev) ...@@ -763,8 +755,7 @@ omap_i2c_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, dev); platform_set_drvdata(pdev, dev);
r = omap_i2c_get_clocks(dev); if ((r = omap_i2c_get_clocks(dev)) != 0)
if (r != 0)
goto err_iounmap; goto err_iounmap;
omap_i2c_unidle(dev); omap_i2c_unidle(dev);
...@@ -868,14 +859,14 @@ static struct platform_driver omap_i2c_driver = { ...@@ -868,14 +859,14 @@ static struct platform_driver omap_i2c_driver = {
}; };
/* I2C may be needed to bring up other drivers */ /* I2C may be needed to bring up other drivers */
static int __devinit static int __init
omap_i2c_init_driver(void) omap_i2c_init_driver(void)
{ {
return platform_driver_register(&omap_i2c_driver); return platform_driver_register(&omap_i2c_driver);
} }
subsys_initcall(omap_i2c_init_driver); subsys_initcall(omap_i2c_init_driver);
static void __devexit omap_i2c_exit_driver(void) static void __exit omap_i2c_exit_driver(void)
{ {
platform_driver_unregister(&omap_i2c_driver); platform_driver_unregister(&omap_i2c_driver);
} }
......
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