drivers/i2c/busses/i2c-bcm-iproc.c
Source file repositories/reference/linux-study-clean/drivers/i2c/busses/i2c-bcm-iproc.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/i2c/busses/i2c-bcm-iproc.c- Extension
.c- Size
- 35755 bytes
- Lines
- 1253
- 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/delay.hlinux/i2c.hlinux/interrupt.hlinux/io.hlinux/kernel.hlinux/module.hlinux/of.hlinux/platform_device.hlinux/slab.h
Detected Declarations
struct bcm_iproc_i2c_devenum i2c_slave_read_statusenum bus_speed_indexenum bcm_iproc_i2c_typefunction iproc_i2c_rd_regfunction iproc_i2c_wr_regfunction bcm_iproc_i2c_slave_initfunction bcm_iproc_i2c_enable_disablefunction bcm_iproc_i2c_check_slave_statusfunction bcm_iproc_i2c_slave_readfunction slave_rx_tasklet_fnfunction bcm_iproc_i2c_slave_isrfunction bcm_iproc_i2c_read_valid_bytesfunction bcm_iproc_i2c_sendfunction bcm_iproc_i2c_readfunction bcm_iproc_i2c_process_m_eventfunction bcm_iproc_i2c_isrfunction bcm_iproc_i2c_initfunction bcm_iproc_i2c_check_statusfunction bcm_iproc_i2c_xfer_waitfunction bcm_iproc_i2c_xfer_internalfunction bcm_iproc_i2c_xferfunction bcm_iproc_i2c_functionalityfunction bcm_iproc_i2c_reg_slavefunction bcm_iproc_i2c_unreg_slavefunction bcm_iproc_i2c_cfg_speedfunction bcm_iproc_i2c_probefunction bcm_iproc_i2c_removefunction bcm_iproc_i2c_suspendfunction bcm_iproc_i2c_resume
Annotated Snippet
struct bcm_iproc_i2c_dev {
struct device *device;
enum bcm_iproc_i2c_type type;
int irq;
void __iomem *base;
void __iomem *idm_base;
u32 ape_addr_mask;
/* lock for indirect access through IDM */
spinlock_t idm_lock;
struct i2c_adapter adapter;
unsigned int bus_speed;
struct completion done;
int xfer_is_done;
struct i2c_msg *msg;
struct i2c_client *slave;
/* bytes that have been transferred */
unsigned int tx_bytes;
/* bytes that have been read */
unsigned int rx_bytes;
unsigned int thld_bytes;
bool slave_rx_only;
bool rx_start_rcvd;
bool slave_read_complete;
u32 tx_underrun;
u32 slave_int_mask;
struct tasklet_struct slave_rx_tasklet;
};
/* tasklet to process slave rx data */
static void slave_rx_tasklet_fn(unsigned long);
/*
* Can be expanded in the future if more interrupt status bits are utilized
*/
#define ISR_MASK (BIT(IS_M_START_BUSY_SHIFT) | BIT(IS_M_TX_UNDERRUN_SHIFT)\
| BIT(IS_M_RX_THLD_SHIFT))
#define ISR_MASK_SLAVE (BIT(IS_S_START_BUSY_SHIFT)\
| BIT(IS_S_RX_EVENT_SHIFT) | BIT(IS_S_RD_EVENT_SHIFT)\
| BIT(IS_S_TX_UNDERRUN_SHIFT) | BIT(IS_S_RX_FIFO_FULL_SHIFT)\
| BIT(IS_S_RX_THLD_SHIFT))
static inline u32 iproc_i2c_rd_reg(struct bcm_iproc_i2c_dev *iproc_i2c,
u32 offset)
{
u32 val;
unsigned long flags;
if (iproc_i2c->idm_base) {
spin_lock_irqsave(&iproc_i2c->idm_lock, flags);
writel(iproc_i2c->ape_addr_mask,
iproc_i2c->idm_base + IDM_CTRL_DIRECT_OFFSET);
val = readl(iproc_i2c->base + offset);
spin_unlock_irqrestore(&iproc_i2c->idm_lock, flags);
} else {
val = readl(iproc_i2c->base + offset);
}
return val;
}
static inline void iproc_i2c_wr_reg(struct bcm_iproc_i2c_dev *iproc_i2c,
u32 offset, u32 val)
{
unsigned long flags;
if (iproc_i2c->idm_base) {
spin_lock_irqsave(&iproc_i2c->idm_lock, flags);
writel(iproc_i2c->ape_addr_mask,
iproc_i2c->idm_base + IDM_CTRL_DIRECT_OFFSET);
writel(val, iproc_i2c->base + offset);
spin_unlock_irqrestore(&iproc_i2c->idm_lock, flags);
} else {
writel(val, iproc_i2c->base + offset);
}
}
static void bcm_iproc_i2c_slave_init(struct bcm_iproc_i2c_dev *iproc_i2c,
bool need_reset)
{
u32 val;
Annotation
- Immediate include surface: `linux/delay.h`, `linux/i2c.h`, `linux/interrupt.h`, `linux/io.h`, `linux/kernel.h`, `linux/module.h`, `linux/of.h`, `linux/platform_device.h`.
- Detected declarations: `struct bcm_iproc_i2c_dev`, `enum i2c_slave_read_status`, `enum bus_speed_index`, `enum bcm_iproc_i2c_type`, `function iproc_i2c_rd_reg`, `function iproc_i2c_wr_reg`, `function bcm_iproc_i2c_slave_init`, `function bcm_iproc_i2c_enable_disable`, `function bcm_iproc_i2c_check_slave_status`, `function bcm_iproc_i2c_slave_read`.
- 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.