drivers/i2c/busses/i2c-designware-slave.c
Source file repositories/reference/linux-study-clean/drivers/i2c/busses/i2c-designware-slave.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/i2c/busses/i2c-designware-slave.c- Extension
.c- Size
- 5278 bytes
- Lines
- 195
- Domain
- Driver Families
- Bucket
- drivers/i2c
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/delay.hlinux/err.hlinux/errno.hlinux/i2c.hlinux/interrupt.hlinux/io.hlinux/module.hlinux/pm_runtime.hlinux/regmap.hi2c-designware-core.h
Detected Declarations
function driverfunction i2c_dw_unreg_slavefunction i2c_dw_read_clear_intrbits_slavefunction i2c_dw_isr_slavefunction i2c_dw_configure_slaveexport i2c_dw_configure_slave
Annotated Snippet
if (!(dev->status & STATUS_WRITE_IN_PROGRESS)) {
dev->status |= STATUS_WRITE_IN_PROGRESS;
dev->status &= ~STATUS_READ_IN_PROGRESS;
i2c_slave_event(dev->slave, I2C_SLAVE_WRITE_REQUESTED,
&val);
}
do {
regmap_read(dev->map, DW_IC_DATA_CMD, &tmp);
if (tmp & DW_IC_DATA_CMD_FIRST_DATA_BYTE)
i2c_slave_event(dev->slave,
I2C_SLAVE_WRITE_REQUESTED,
&val);
val = tmp;
i2c_slave_event(dev->slave, I2C_SLAVE_WRITE_RECEIVED,
&val);
regmap_read(dev->map, DW_IC_STATUS, &tmp);
} while (tmp & DW_IC_STATUS_RFNE);
}
if (stat & DW_IC_INTR_RD_REQ) {
if (slave_activity) {
regmap_read(dev->map, DW_IC_CLR_RD_REQ, &tmp);
if (!(dev->status & STATUS_READ_IN_PROGRESS)) {
i2c_slave_event(dev->slave,
I2C_SLAVE_READ_REQUESTED,
&val);
dev->status |= STATUS_READ_IN_PROGRESS;
dev->status &= ~STATUS_WRITE_IN_PROGRESS;
} else {
i2c_slave_event(dev->slave,
I2C_SLAVE_READ_PROCESSED,
&val);
}
regmap_write(dev->map, DW_IC_DATA_CMD, val);
}
}
if (stat & DW_IC_INTR_STOP_DET)
i2c_slave_event(dev->slave, I2C_SLAVE_STOP, &val);
return IRQ_HANDLED;
}
void i2c_dw_configure_slave(struct dw_i2c_dev *dev)
{
if (dev->flags & ACCESS_POLLING)
return;
dev->functionality |= I2C_FUNC_SLAVE;
dev->slave_cfg = DW_IC_CON_RX_FIFO_FULL_HLD_CTRL |
DW_IC_CON_RESTART_EN | DW_IC_CON_STOP_DET_IFADDRESSED;
}
EXPORT_SYMBOL_GPL(i2c_dw_configure_slave);
MODULE_AUTHOR("Luis Oliveira <lolivei@synopsys.com>");
MODULE_DESCRIPTION("Synopsys DesignWare I2C bus slave adapter");
MODULE_LICENSE("GPL v2");
MODULE_IMPORT_NS("I2C_DW_COMMON");
Annotation
- Immediate include surface: `linux/delay.h`, `linux/err.h`, `linux/errno.h`, `linux/i2c.h`, `linux/interrupt.h`, `linux/io.h`, `linux/module.h`, `linux/pm_runtime.h`.
- Detected declarations: `function driver`, `function i2c_dw_unreg_slave`, `function i2c_dw_read_clear_intrbits_slave`, `function i2c_dw_isr_slave`, `function i2c_dw_configure_slave`, `export i2c_dw_configure_slave`.
- Atlas domain: Driver Families / drivers/i2c.
- Implementation status: integration implementation candidate.
- 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.