drivers/i2c/busses/i2c-xiic.c
Source file repositories/reference/linux-study-clean/drivers/i2c/busses/i2c-xiic.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/i2c/busses/i2c-xiic.c- Extension
.c- Size
- 43388 bytes
- Lines
- 1571
- 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/kernel.hlinux/module.hlinux/errno.hlinux/err.hlinux/delay.hlinux/platform_device.hlinux/i2c.hlinux/interrupt.hlinux/completion.hlinux/platform_data/i2c-xiic.hlinux/io.hlinux/slab.hlinux/clk.hlinux/pm_runtime.hlinux/iopoll.hlinux/spinlock.h
Detected Declarations
struct xiic_i2cstruct xiic_version_datastruct timing_regsenum xilinx_i2c_stateenum xiic_endianenum i2c_scl_freqfunction xiic_i2c_runtime_suspendfunction xiic_i2c_runtime_resumefunction xiic_setreg8function xiic_getreg8function xiic_setreg16function xiic_setreg32function xiic_getreg32function xiic_irq_disfunction xiic_irq_enfunction xiic_irq_clrfunction xiic_irq_clr_enfunction xiic_clear_rx_fifofunction xiic_wait_tx_emptyfunction xiic_setclkfunction xiic_reinitfunction xiic_deinitfunction xiic_smbus_block_read_setupfunction xiic_read_rxfunction xiic_error_checkfunction xiic_tx_fifo_spacefunction xiic_fill_tx_fifofunction xiic_wakeupfunction xiic_processfunction xiic_bus_busyfunction xiic_wait_not_busyfunction xiic_recv_atomicfunction xiic_start_recvfunction xiic_send_rem_atomicfunction xiic_start_sendfunction __xiic_start_xferfunction xiic_start_xferfunction xiic_xferfunction xiic_xfer_atomicfunction xiic_funcfunction xiic_i2c_probefunction xiic_i2c_remove
Annotated Snippet
struct xiic_i2c {
struct device *dev;
void __iomem *base;
struct completion completion;
struct i2c_adapter adap;
struct i2c_msg *tx_msg;
struct mutex lock;
unsigned int tx_pos;
unsigned int nmsgs;
struct i2c_msg *rx_msg;
int rx_pos;
enum xiic_endian endianness;
struct clk *clk;
enum xilinx_i2c_state state;
bool singlemaster;
bool dynamic;
bool prev_msg_tx;
u32 quirks;
bool smbus_block_read;
unsigned long input_clk;
unsigned int i2c_clk;
bool atomic;
spinlock_t atomic_lock; /* Lock for atomic transfer mode */
enum xilinx_i2c_state atomic_xfer_state;
};
struct xiic_version_data {
u32 quirks;
};
/**
* struct timing_regs - AXI I2C timing registers that depend on I2C spec
* @tsusta: setup time for a repeated START condition
* @tsusto: setup time for a STOP condition
* @thdsta: hold time for a repeated START condition
* @tsudat: setup time for data
* @tbuf: bus free time between STOP and START
*/
struct timing_regs {
unsigned int tsusta;
unsigned int tsusto;
unsigned int thdsta;
unsigned int tsudat;
unsigned int tbuf;
};
/* Reg values in ns derived from I2C spec and AXI I2C PG for different frequencies */
static const struct timing_regs timing_reg_values[] = {
{ 5700, 5000, 4300, 550, 5000 }, /* Reg values for 100KHz */
{ 900, 900, 900, 400, 1600 }, /* Reg values for 400KHz */
{ 380, 380, 380, 170, 620 }, /* Reg values for 1MHz */
};
#define XIIC_MSB_OFFSET 0
#define XIIC_REG_OFFSET (0x100 + XIIC_MSB_OFFSET)
/*
* Register offsets in bytes from RegisterBase. Three is added to the
* base offset to access LSB (IBM style) of the word
*/
#define XIIC_CR_REG_OFFSET (0x00 + XIIC_REG_OFFSET) /* Control Register */
#define XIIC_SR_REG_OFFSET (0x04 + XIIC_REG_OFFSET) /* Status Register */
#define XIIC_DTR_REG_OFFSET (0x08 + XIIC_REG_OFFSET) /* Data Tx Register */
#define XIIC_DRR_REG_OFFSET (0x0C + XIIC_REG_OFFSET) /* Data Rx Register */
#define XIIC_ADR_REG_OFFSET (0x10 + XIIC_REG_OFFSET) /* Address Register */
#define XIIC_TFO_REG_OFFSET (0x14 + XIIC_REG_OFFSET) /* Tx FIFO Occupancy */
#define XIIC_RFO_REG_OFFSET (0x18 + XIIC_REG_OFFSET) /* Rx FIFO Occupancy */
#define XIIC_TBA_REG_OFFSET (0x1C + XIIC_REG_OFFSET) /* 10 Bit Address reg */
#define XIIC_RFD_REG_OFFSET (0x20 + XIIC_REG_OFFSET) /* Rx FIFO Depth reg */
#define XIIC_GPO_REG_OFFSET (0x24 + XIIC_REG_OFFSET) /* Output Register */
/*
* Timing register offsets from RegisterBase. These are used only for
* setting i2c clock frequency for the line.
*/
#define XIIC_TSUSTA_REG_OFFSET (0x28 + XIIC_REG_OFFSET) /* TSUSTA Register */
#define XIIC_TSUSTO_REG_OFFSET (0x2C + XIIC_REG_OFFSET) /* TSUSTO Register */
#define XIIC_THDSTA_REG_OFFSET (0x30 + XIIC_REG_OFFSET) /* THDSTA Register */
#define XIIC_TSUDAT_REG_OFFSET (0x34 + XIIC_REG_OFFSET) /* TSUDAT Register */
#define XIIC_TBUF_REG_OFFSET (0x38 + XIIC_REG_OFFSET) /* TBUF Register */
#define XIIC_THIGH_REG_OFFSET (0x3C + XIIC_REG_OFFSET) /* THIGH Register */
#define XIIC_TLOW_REG_OFFSET (0x40 + XIIC_REG_OFFSET) /* TLOW Register */
#define XIIC_THDDAT_REG_OFFSET (0x44 + XIIC_REG_OFFSET) /* THDDAT Register */
/* Control Register masks */
#define XIIC_CR_ENABLE_DEVICE_MASK 0x01 /* Device enable = 1 */
#define XIIC_CR_TX_FIFO_RESET_MASK 0x02 /* Transmit FIFO reset=1 */
#define XIIC_CR_MSMS_MASK 0x04 /* Master starts Txing=1 */
#define XIIC_CR_DIR_IS_TX_MASK 0x08 /* Dir of tx. Txing=1 */
#define XIIC_CR_NO_ACK_MASK 0x10 /* Tx Ack. NO ack = 1 */
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/module.h`, `linux/errno.h`, `linux/err.h`, `linux/delay.h`, `linux/platform_device.h`, `linux/i2c.h`, `linux/interrupt.h`.
- Detected declarations: `struct xiic_i2c`, `struct xiic_version_data`, `struct timing_regs`, `enum xilinx_i2c_state`, `enum xiic_endian`, `enum i2c_scl_freq`, `function xiic_i2c_runtime_suspend`, `function xiic_i2c_runtime_resume`, `function xiic_setreg8`, `function xiic_getreg8`.
- 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.