drivers/i2c/busses/i2c-xgene-slimpro.c
Source file repositories/reference/linux-study-clean/drivers/i2c/busses/i2c-xgene-slimpro.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/i2c/busses/i2c-xgene-slimpro.c- Extension
.c- Size
- 15231 bytes
- Lines
- 565
- 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
acpi/pcc.hlinux/acpi.hlinux/dma-mapping.hlinux/i2c.hlinux/interrupt.hlinux/io.hlinux/mailbox_client.hlinux/module.hlinux/of.hlinux/platform_device.h
Detected Declarations
struct slimpro_i2c_devenum slimpro_i2c_versionfunction xgene_word_tst_and_clrfunction slimpro_i2c_rx_cbfunction slimpro_i2c_pcc_rx_cbfunction slimpro_i2c_pcc_tx_preparefunction start_i2c_msg_xferfunction slimpro_i2c_send_msgfunction slimpro_i2c_rdfunction slimpro_i2c_wrfunction slimpro_i2c_blkrdfunction slimpro_i2c_blkwrfunction xgene_slimpro_i2c_xferfunction xgene_slimpro_i2c_funcfunction xgene_slimpro_i2c_probefunction xgene_slimpro_i2c_remove
Annotated Snippet
struct slimpro_i2c_dev {
struct i2c_adapter adapter;
struct device *dev;
struct mbox_chan *mbox_chan;
struct pcc_mbox_chan *pcc_chan;
struct mbox_client mbox_client;
int mbox_idx;
struct completion rd_complete;
u8 dma_buffer[I2C_SMBUS_BLOCK_MAX + 1]; /* dma_buffer[0] is used for length */
u32 *resp_msg;
};
#define to_slimpro_i2c_dev(cl) \
container_of(cl, struct slimpro_i2c_dev, mbox_client)
enum slimpro_i2c_version {
XGENE_SLIMPRO_I2C_V1 = 0,
XGENE_SLIMPRO_I2C_V2 = 1,
};
/*
* This function tests and clears a bitmask then returns its old value
*/
static u16 xgene_word_tst_and_clr(u16 *addr, u16 mask)
{
u16 ret, val;
val = le16_to_cpu(READ_ONCE(*addr));
ret = val & mask;
val &= ~mask;
WRITE_ONCE(*addr, cpu_to_le16(val));
return ret;
}
static void slimpro_i2c_rx_cb(struct mbox_client *cl, void *mssg)
{
struct slimpro_i2c_dev *ctx = to_slimpro_i2c_dev(cl);
/*
* Response message format:
* mssg[0] is the return code of the operation
* mssg[1] is the first data word
* mssg[2] is NOT used
*/
if (ctx->resp_msg)
*ctx->resp_msg = ((u32 *)mssg)[1];
if (ctx->mbox_client.tx_block)
complete(&ctx->rd_complete);
}
static void slimpro_i2c_pcc_rx_cb(struct mbox_client *cl, void *msg)
{
struct slimpro_i2c_dev *ctx = to_slimpro_i2c_dev(cl);
struct acpi_pcct_shared_memory __iomem *generic_comm_base =
ctx->pcc_chan->shmem;
/* Check if platform sends interrupt */
if (!xgene_word_tst_and_clr(&generic_comm_base->status,
PCC_STATUS_SCI_DOORBELL))
return;
if (xgene_word_tst_and_clr(&generic_comm_base->status,
PCC_STATUS_CMD_COMPLETE)) {
msg = generic_comm_base + 1;
/* Response message msg[1] contains the return value. */
if (ctx->resp_msg)
*ctx->resp_msg = ((u32 *)msg)[1];
complete(&ctx->rd_complete);
}
}
static void slimpro_i2c_pcc_tx_prepare(struct slimpro_i2c_dev *ctx, u32 *msg)
{
struct acpi_pcct_shared_memory __iomem *generic_comm_base =
ctx->pcc_chan->shmem;
u32 *ptr = (void *)(generic_comm_base + 1);
u16 status;
int i;
WRITE_ONCE(generic_comm_base->signature,
cpu_to_le32(PCC_SIGNATURE | ctx->mbox_idx));
WRITE_ONCE(generic_comm_base->command,
cpu_to_le16(SLIMPRO_MSG_TYPE(msg[0]) | PCC_CMD_GENERATE_DB_INTR));
status = le16_to_cpu(READ_ONCE(generic_comm_base->status));
Annotation
- Immediate include surface: `acpi/pcc.h`, `linux/acpi.h`, `linux/dma-mapping.h`, `linux/i2c.h`, `linux/interrupt.h`, `linux/io.h`, `linux/mailbox_client.h`, `linux/module.h`.
- Detected declarations: `struct slimpro_i2c_dev`, `enum slimpro_i2c_version`, `function xgene_word_tst_and_clr`, `function slimpro_i2c_rx_cb`, `function slimpro_i2c_pcc_rx_cb`, `function slimpro_i2c_pcc_tx_prepare`, `function start_i2c_msg_xfer`, `function slimpro_i2c_send_msg`, `function slimpro_i2c_rd`, `function slimpro_i2c_wr`.
- 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.