Skip to content

Commit

Permalink
Merge branch 'i2c-for-linus' of git://jdelvare.pck.nerim.net/jdelvare…
Browse files Browse the repository at this point in the history
…-2.6

* 'i2c-for-linus' of git://jdelvare.pck.nerim.net/jdelvare-2.6:
  i2c: Fix docbook problem
  ASoC/TLV320AIC3X: Stop I2C driver ID abuse
  i2c-omap: Fix unhandled fault
  i2c-bfin-twi: Disable BF54x support for now
  • Loading branch information
Linus Torvalds committed Mar 25, 2008
2 parents e584152 + 8c07e46 commit 5004de1
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 13 deletions.
2 changes: 1 addition & 1 deletion drivers/i2c/busses/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ config I2C_AU1550

config I2C_BLACKFIN_TWI
tristate "Blackfin TWI I2C support"
depends on BF534 || BF536 || BF537 || BF54x
depends on BF534 || BF536 || BF537
help
This is the TWI I2C device driver for Blackfin 534/536/537/54x.
This driver can also be built as a module. If so, the module
Expand Down
36 changes: 28 additions & 8 deletions drivers/i2c/busses/i2c-omap.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ struct omap_i2c_dev {
size_t buf_len;
struct i2c_adapter adapter;
unsigned rev1:1;
unsigned idle:1;
u16 iestate; /* Saved interrupt register */
};

static inline void omap_i2c_write_reg(struct omap_i2c_dev *i2c_dev,
Expand Down Expand Up @@ -174,18 +176,30 @@ static void omap_i2c_put_clocks(struct omap_i2c_dev *dev)
}
}

static void omap_i2c_enable_clocks(struct omap_i2c_dev *dev)
static void omap_i2c_unidle(struct omap_i2c_dev *dev)
{
if (dev->iclk != NULL)
clk_enable(dev->iclk);
clk_enable(dev->fclk);
if (dev->iestate)
omap_i2c_write_reg(dev, OMAP_I2C_IE_REG, dev->iestate);
dev->idle = 0;
}

static void omap_i2c_disable_clocks(struct omap_i2c_dev *dev)
static void omap_i2c_idle(struct omap_i2c_dev *dev)
{
u16 iv;

dev->idle = 1;
dev->iestate = omap_i2c_read_reg(dev, OMAP_I2C_IE_REG);
omap_i2c_write_reg(dev, OMAP_I2C_IE_REG, 0);
if (dev->rev1)
iv = omap_i2c_read_reg(dev, OMAP_I2C_IV_REG); /* Read clears */
else
omap_i2c_write_reg(dev, OMAP_I2C_STAT_REG, dev->iestate);
clk_disable(dev->fclk);
if (dev->iclk != NULL)
clk_disable(dev->iclk);
clk_disable(dev->fclk);
}

static int omap_i2c_init(struct omap_i2c_dev *dev)
Expand Down Expand Up @@ -360,7 +374,7 @@ omap_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num)
int i;
int r;

omap_i2c_enable_clocks(dev);
omap_i2c_unidle(dev);

if ((r = omap_i2c_wait_for_bb(dev)) < 0)
goto out;
Expand All @@ -374,7 +388,7 @@ omap_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num)
if (r == 0)
r = num;
out:
omap_i2c_disable_clocks(dev);
omap_i2c_idle(dev);
return r;
}

Expand Down Expand Up @@ -403,6 +417,9 @@ omap_i2c_rev1_isr(int this_irq, void *dev_id)
struct omap_i2c_dev *dev = dev_id;
u16 iv, w;

if (dev->idle)
return IRQ_NONE;

iv = omap_i2c_read_reg(dev, OMAP_I2C_IV_REG);
switch (iv) {
case 0x00: /* None */
Expand Down Expand Up @@ -457,6 +474,9 @@ omap_i2c_isr(int this_irq, void *dev_id)
u16 stat, w;
int count = 0;

if (dev->idle)
return IRQ_NONE;

bits = omap_i2c_read_reg(dev, OMAP_I2C_IE_REG);
while ((stat = (omap_i2c_read_reg(dev, OMAP_I2C_STAT_REG))) & bits) {
dev_dbg(dev->dev, "IRQ (ISR = 0x%04x)\n", stat);
Expand Down Expand Up @@ -575,7 +595,7 @@ omap_i2c_probe(struct platform_device *pdev)
if ((r = omap_i2c_get_clocks(dev)) != 0)
goto err_free_mem;

omap_i2c_enable_clocks(dev);
omap_i2c_unidle(dev);

if (cpu_is_omap15xx())
dev->rev1 = omap_i2c_read_reg(dev, OMAP_I2C_REV_REG) < 0x20;
Expand Down Expand Up @@ -610,15 +630,15 @@ omap_i2c_probe(struct platform_device *pdev)
goto err_free_irq;
}

omap_i2c_disable_clocks(dev);
omap_i2c_idle(dev);

return 0;

err_free_irq:
free_irq(dev->irq, dev);
err_unuse_clocks:
omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, 0);
omap_i2c_disable_clocks(dev);
omap_i2c_idle(dev);
omap_i2c_put_clocks(dev);
err_free_mem:
platform_set_drvdata(pdev, NULL);
Expand Down
4 changes: 2 additions & 2 deletions drivers/i2c/i2c-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -489,8 +489,8 @@ EXPORT_SYMBOL(i2c_add_adapter);
* Context: can sleep
*
* This routine is used to declare an I2C adapter when its bus number
* matters. Example: for I2C adapters from system-on-chip CPUs, or
* otherwise built in to the system's mainboard, and where i2c_board_info
* matters. For example, use it for I2C adapters from system-on-chip CPUs,
* or otherwise built in to the system's mainboard, and where i2c_board_info
* is used to properly configure I2C devices.
*
* If no devices have pre-been declared for this bus, then be sure to
Expand Down
2 changes: 0 additions & 2 deletions sound/soc/codecs/tlv320aic3x.c
Original file line number Diff line number Diff line change
Expand Up @@ -1187,10 +1187,8 @@ static struct i2c_driver aic3x_i2c_driver = {
.name = "aic3x I2C Codec",
.owner = THIS_MODULE,
},
.id = I2C_DRIVERID_I2CDEV,
.attach_adapter = aic3x_i2c_attach,
.detach_client = aic3x_i2c_detach,
.command = NULL,
};

static struct i2c_client client_template = {
Expand Down

0 comments on commit 5004de1

Please sign in to comment.