/* * Don't bother checking ACKE here, this and the reset * are handled in highlander_i2c_wait_xfer_done() when * waiting for the ACK.
*/
if (smcr & SMCR_IRIC) return; if (time_after(jiffies, timeout)) break;
cpu_relax();
cond_resched();
}
dev_err(dev->dev, "polling timed out\n");
}
staticinlineint highlander_i2c_wait_xfer_done(struct highlander_i2c_dev *dev)
{ if (dev->irq)
wait_for_completion_timeout(&dev->cmd_complete,
msecs_to_jiffies(iic_timeout)); else /* busy looping, the IRQ of champions */
highlander_i2c_poll(dev);
return highlander_i2c_wait_for_ack(dev);
}
staticint highlander_i2c_read(struct highlander_i2c_dev *dev)
{ int i, cnt;
u16 data[16];
if (highlander_i2c_wait_for_bbsy(dev)) return -EAGAIN;
highlander_i2c_start(dev);
if (highlander_i2c_wait_xfer_done(dev)) {
dev_err(dev->dev, "Arbitration loss\n"); return -EAGAIN;
}
/* * The R0P7780LC0011RL FPGA needs a significant delay between * data read cycles, otherwise the transceiver gets confused and * garbage is returned when the read is subsequently aborted. * * It is not sufficient to wait for BBSY. * * While this generally only applies to the older SH7780-based * Highlanders, the same issue can be observed on SH7785 ones, * albeit less frequently. SH7780-based Highlanders may need * this to be as high as 1000 ms.
*/ if (iic_read_delay && time_before(jiffies, dev->last_read_time +
msecs_to_jiffies(iic_read_delay)))
msleep(jiffies_to_msecs((dev->last_read_time +
msecs_to_jiffies(iic_read_delay)) - jiffies));
cnt = (dev->buf_len + 1) >> 1; for (i = 0; i < cnt; i++) {
data[i] = ioread16(dev->base + SMTRDR + (i * sizeof(u16)));
dev_dbg(dev->dev, "read data[%x] 0x%04x\n", i, data[i]);
}
smbus_read_data(data, dev->buf, dev->buf_len);
dev->last_read_time = jiffies;
return 0;
}
staticint highlander_i2c_write(struct highlander_i2c_dev *dev)
{ int i, cnt;
u16 data[16];
smbus_write_data(dev->buf, data, dev->buf_len);
cnt = (dev->buf_len + 1) >> 1; for (i = 0; i < cnt; i++) {
iowrite16(data[i], dev->base + SMTRDR + (i * sizeof(u16)));
dev_dbg(dev->dev, "write data[%x] 0x%04x\n", i, data[i]);
}
if (highlander_i2c_wait_for_bbsy(dev)) return -EAGAIN;
/* * Reset the adapter
*/
ret = highlander_i2c_reset(dev); if (unlikely(ret)) {
dev_err(&pdev->dev, "controller didn't come up\n"); goto err_free_irq;
}
ret = i2c_add_numbered_adapter(adap); if (unlikely(ret)) {
dev_err(&pdev->dev, "failure adding adapter\n"); goto err_free_irq;
}
return 0;
err_free_irq: if (dev->irq)
free_irq(dev->irq, dev);
err_unmap:
iounmap(dev->base);
err:
kfree(dev);
MODULE_PARM_DESC(iic_force_poll, "Force polling mode");
MODULE_PARM_DESC(iic_force_normal, "Force normal mode (100 kHz), default is fast mode (400 kHz)");
MODULE_PARM_DESC(iic_timeout, "Set timeout value in msecs (default 1000 ms)");
MODULE_PARM_DESC(iic_read_delay, "Delay between data read cycles (default 0 ms)");
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.