drivers/i2c/busses/i2c-xlp9xx.c
Source file repositories/reference/linux-study-clean/drivers/i2c/busses/i2c-xlp9xx.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/i2c/busses/i2c-xlp9xx.c- Extension
.c- Size
- 15675 bytes
- Lines
- 594
- 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.
- 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/acpi.hlinux/clk.hlinux/completion.hlinux/i2c.hlinux/i2c-smbus.hlinux/init.hlinux/interrupt.hlinux/io.hlinux/kernel.hlinux/module.hlinux/platform_device.hlinux/delay.h
Detected Declarations
struct xlp9xx_i2c_devfunction xlp9xx_write_i2c_regfunction xlp9xx_read_i2c_regfunction xlp9xx_i2c_mask_irqfunction xlp9xx_i2c_unmask_irqfunction xlp9xx_i2c_update_rx_fifo_thresfunction xlp9xx_i2c_fill_tx_fifofunction xlp9xx_i2c_update_rlenfunction xlp9xx_i2c_drain_rx_fifofunction xlp9xx_i2c_isrfunction xlp9xx_i2c_check_bus_statusfunction xlp9xx_i2c_initfunction xlp9xx_i2c_xfer_msgfunction xlp9xx_i2c_xferfunction xlp9xx_i2c_functionalityfunction xlp9xx_i2c_get_frequencyfunction xlp9xx_i2c_smbus_setupfunction xlp9xx_i2c_probefunction xlp9xx_i2c_remove
Annotated Snippet
struct xlp9xx_i2c_dev {
struct device *dev;
struct i2c_adapter adapter;
struct completion msg_complete;
struct i2c_smbus_alert_setup alert_data;
struct i2c_client *ara;
int irq;
bool msg_read;
bool len_recv;
bool client_pec;
u32 __iomem *base;
u32 msg_buf_remaining;
u32 msg_len;
u32 ip_clk_hz;
u32 clk_hz;
u32 msg_err;
u8 *msg_buf;
};
static inline void xlp9xx_write_i2c_reg(struct xlp9xx_i2c_dev *priv,
unsigned long reg, u32 val)
{
writel(val, priv->base + reg);
}
static inline u32 xlp9xx_read_i2c_reg(struct xlp9xx_i2c_dev *priv,
unsigned long reg)
{
return readl(priv->base + reg);
}
static void xlp9xx_i2c_mask_irq(struct xlp9xx_i2c_dev *priv, u32 mask)
{
u32 inten;
inten = xlp9xx_read_i2c_reg(priv, XLP9XX_I2C_INTEN) & ~mask;
xlp9xx_write_i2c_reg(priv, XLP9XX_I2C_INTEN, inten);
}
static void xlp9xx_i2c_unmask_irq(struct xlp9xx_i2c_dev *priv, u32 mask)
{
u32 inten;
inten = xlp9xx_read_i2c_reg(priv, XLP9XX_I2C_INTEN) | mask;
xlp9xx_write_i2c_reg(priv, XLP9XX_I2C_INTEN, inten);
}
static void xlp9xx_i2c_update_rx_fifo_thres(struct xlp9xx_i2c_dev *priv)
{
u32 thres;
if (priv->len_recv)
/* interrupt after the first read to examine
* the length byte before proceeding further
*/
thres = 1;
else if (priv->msg_buf_remaining > XLP9XX_I2C_FIFO_SIZE)
thres = XLP9XX_I2C_FIFO_SIZE;
else
thres = priv->msg_buf_remaining;
xlp9xx_write_i2c_reg(priv, XLP9XX_I2C_MFIFOCTRL,
thres << XLP9XX_I2C_MFIFOCTRL_HITH_SHIFT);
}
static void xlp9xx_i2c_fill_tx_fifo(struct xlp9xx_i2c_dev *priv)
{
u32 len, i;
u8 *buf = priv->msg_buf;
len = min(priv->msg_buf_remaining, XLP9XX_I2C_FIFO_SIZE);
for (i = 0; i < len; i++)
xlp9xx_write_i2c_reg(priv, XLP9XX_I2C_MTXFIFO, buf[i]);
priv->msg_buf_remaining -= len;
priv->msg_buf += len;
}
static void xlp9xx_i2c_update_rlen(struct xlp9xx_i2c_dev *priv)
{
u32 val, len;
/*
* Update receive length. Re-read len to get the latest value,
* and then add 4 to have a minimum value that can be safely
* written. This is to account for the byte read above, the
* transfer in progress and any delays in the register I/O
*/
val = xlp9xx_read_i2c_reg(priv, XLP9XX_I2C_CTRL);
len = xlp9xx_read_i2c_reg(priv, XLP9XX_I2C_FIFOWCNT) &
XLP9XX_I2C_FIFO_WCNT_MASK;
Annotation
- Immediate include surface: `linux/acpi.h`, `linux/clk.h`, `linux/completion.h`, `linux/i2c.h`, `linux/i2c-smbus.h`, `linux/init.h`, `linux/interrupt.h`, `linux/io.h`.
- Detected declarations: `struct xlp9xx_i2c_dev`, `function xlp9xx_write_i2c_reg`, `function xlp9xx_read_i2c_reg`, `function xlp9xx_i2c_mask_irq`, `function xlp9xx_i2c_unmask_irq`, `function xlp9xx_i2c_update_rx_fifo_thres`, `function xlp9xx_i2c_fill_tx_fifo`, `function xlp9xx_i2c_update_rlen`, `function xlp9xx_i2c_drain_rx_fifo`, `function xlp9xx_i2c_isr`.
- Atlas domain: Driver Families / drivers/i2c.
- Implementation status: source 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.