drivers/i2c/busses/i2c-iop3xx.c
Source file repositories/reference/linux-study-clean/drivers/i2c/busses/i2c-iop3xx.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/i2c/busses/i2c-iop3xx.c- Extension
.c- Size
- 13136 bytes
- Lines
- 540
- Domain
- Driver Families
- Bucket
- drivers/i2c
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/interrupt.hlinux/kernel.hlinux/module.hlinux/delay.hlinux/slab.hlinux/errno.hlinux/platform_device.hlinux/i2c.hlinux/io.hlinux/gpio/consumer.hi2c-iop3xx.h
Detected Declarations
function iic_cook_addrfunction iop3xx_i2c_resetfunction iop3xx_i2c_enablefunction iop3xx_i2c_transaction_cleanupfunction iop3xx_i2c_irq_handlerfunction iop3xx_i2c_errorfunction iop3xx_i2c_get_srstatfunction iop3xx_i2c_wait_eventfunction all_bits_clearfunction any_bits_setfunction iop3xx_i2c_wait_tx_donefunction iop3xx_i2c_wait_rx_donefunction iop3xx_i2c_wait_idlefunction iop3xx_i2c_send_target_addrfunction iop3xx_i2c_write_bytefunction iop3xx_i2c_read_bytefunction iop3xx_i2c_writebytesfunction iop3xx_i2c_readbytesfunction transferfunction iop3xx_i2c_xferfunction iop3xx_i2c_funcfunction iop3xx_i2c_removefunction iop3xx_i2c_probe
Annotated Snippet
if ((rc = iop3xx_i2c_error(sr)) < 0) {
*status = sr;
return rc;
} else if (!interrupted) {
*status = sr;
return -ETIMEDOUT;
}
} while (!done);
*status = sr;
return 0;
}
/*
* Concrete compare_funcs
*/
static int
all_bits_clear(unsigned test, unsigned mask)
{
return (test & mask) == 0;
}
static int
any_bits_set(unsigned test, unsigned mask)
{
return (test & mask) != 0;
}
static int
iop3xx_i2c_wait_tx_done(struct i2c_algo_iop3xx_data *iop3xx_adap, int *status)
{
return iop3xx_i2c_wait_event(
iop3xx_adap,
IOP3XX_ISR_TXEMPTY | IOP3XX_ISR_ALD | IOP3XX_ISR_BERRD,
status, any_bits_set);
}
static int
iop3xx_i2c_wait_rx_done(struct i2c_algo_iop3xx_data *iop3xx_adap, int *status)
{
return iop3xx_i2c_wait_event(
iop3xx_adap,
IOP3XX_ISR_RXFULL | IOP3XX_ISR_ALD | IOP3XX_ISR_BERRD,
status, any_bits_set);
}
static int
iop3xx_i2c_wait_idle(struct i2c_algo_iop3xx_data *iop3xx_adap, int *status)
{
return iop3xx_i2c_wait_event(
iop3xx_adap, IOP3XX_ISR_UNITBUSY, status, all_bits_clear);
}
static int
iop3xx_i2c_send_target_addr(struct i2c_algo_iop3xx_data *iop3xx_adap,
struct i2c_msg *msg)
{
unsigned long cr = __raw_readl(iop3xx_adap->ioaddr + CR_OFFSET);
int status;
int rc;
/* avoid writing to local target address (hangs on 80331),
* forbidden in Intel developer manual
*/
if (msg->addr == MYSAR) {
return -EBUSY;
}
__raw_writel(iic_cook_addr(msg), iop3xx_adap->ioaddr + DBR_OFFSET);
cr &= ~(IOP3XX_ICR_MSTOP | IOP3XX_ICR_NACK);
cr |= IOP3XX_ICR_MSTART | IOP3XX_ICR_TBYTE;
__raw_writel(cr, iop3xx_adap->ioaddr + CR_OFFSET);
rc = iop3xx_i2c_wait_tx_done(iop3xx_adap, &status);
return rc;
}
static int
iop3xx_i2c_write_byte(struct i2c_algo_iop3xx_data *iop3xx_adap, char byte,
int stop)
{
unsigned long cr = __raw_readl(iop3xx_adap->ioaddr + CR_OFFSET);
int status;
int rc = 0;
__raw_writel(byte, iop3xx_adap->ioaddr + DBR_OFFSET);
cr &= ~IOP3XX_ICR_MSTART;
Annotation
- Immediate include surface: `linux/interrupt.h`, `linux/kernel.h`, `linux/module.h`, `linux/delay.h`, `linux/slab.h`, `linux/errno.h`, `linux/platform_device.h`, `linux/i2c.h`.
- Detected declarations: `function iic_cook_addr`, `function iop3xx_i2c_reset`, `function iop3xx_i2c_enable`, `function iop3xx_i2c_transaction_cleanup`, `function iop3xx_i2c_irq_handler`, `function iop3xx_i2c_error`, `function iop3xx_i2c_get_srstat`, `function iop3xx_i2c_wait_event`, `function all_bits_clear`, `function any_bits_set`.
- Atlas domain: Driver Families / drivers/i2c.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.