drivers/i2c/busses/i2c-cadence.c
Source file repositories/reference/linux-study-clean/drivers/i2c/busses/i2c-cadence.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/i2c/busses/i2c-cadence.c- Extension
.c- Size
- 47333 bytes
- Lines
- 1673
- 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/clk.hlinux/delay.hlinux/i2c.hlinux/interrupt.hlinux/io.hlinux/iopoll.hlinux/module.hlinux/platform_device.hlinux/of.hlinux/pm_runtime.hlinux/pinctrl/consumer.hlinux/reset.h
Detected Declarations
struct cdns_i2cstruct cdns_platform_dataenum cdns_i2c_modeenum cdns_i2c_slave_statefunction cdns_i2c_initfunction cdns_i2c_runtime_suspendfunction cdns_i2c_runtime_resumefunction cdns_i2c_clear_bus_holdfunction cdns_is_holdquirkfunction cdns_i2c_set_modefunction cdns_i2c_slave_rcv_datafunction cdns_i2c_slave_send_datafunction cdns_i2c_slave_isrfunction cdns_i2c_master_isrfunction cdns_i2c_isrfunction cdns_i2c_error_checkfunction cdns_i2c_mrecv_atomicfunction cdns_i2c_mrecvfunction cdns_i2c_msend_rem_atomicfunction cdns_i2c_msendfunction cdns_i2c_master_resetfunction cdns_i2c_process_msgfunction cdns_i2c_master_common_xferfunction cdns_i2c_master_xferfunction cdns_i2c_master_xfer_atomicfunction cdns_i2c_funcfunction cdns_reg_slavefunction cdns_unreg_slavefunction cdns_i2c_calc_divsfunction cdns_i2c_setclkfunction cdns_i2c_clk_notifier_cbfunction cdns_i2c_suspendfunction cdns_i2c_resumefunction cdns_i2c_detect_transfer_sizefunction cdns_i2c_probefunction cdns_i2c_removefunction cdns_i2c_shutdown
Annotated Snippet
struct cdns_i2c {
struct device *dev;
void __iomem *membase;
struct i2c_adapter adap;
struct i2c_msg *p_msg;
int err_status;
struct completion xfer_done;
unsigned char *p_send_buf;
unsigned char *p_recv_buf;
unsigned int send_count;
unsigned int recv_count;
unsigned int curr_recv_count;
unsigned long input_clk;
unsigned int i2c_clk;
unsigned int bus_hold_flag;
struct clk *clk;
struct notifier_block clk_rate_change_nb;
struct reset_control *reset;
u32 quirks;
u32 ctrl_reg;
struct i2c_bus_recovery_info rinfo;
#if IS_ENABLED(CONFIG_I2C_SLAVE)
u16 ctrl_reg_diva_divb;
struct i2c_client *slave;
enum cdns_i2c_mode dev_mode;
enum cdns_i2c_slave_state slave_state;
#endif
u32 fifo_depth;
unsigned int transfer_size;
bool atomic;
int err_status_atomic;
};
struct cdns_platform_data {
u32 quirks;
};
#define to_cdns_i2c(_nb) container_of(_nb, struct cdns_i2c, \
clk_rate_change_nb)
/**
* cdns_i2c_init - Controller initialisation
* @id: Device private data structure
*
* Initialise the i2c controller.
*
*/
static void cdns_i2c_init(struct cdns_i2c *id)
{
cdns_i2c_writereg(id->ctrl_reg, CDNS_I2C_CR_OFFSET);
/*
* Cadence I2C controller has a bug wherein it generates
* invalid read transaction after HW timeout in master receiver mode.
* HW timeout is not used by this driver and the interrupt is disabled.
* But the feature itself cannot be disabled. Hence maximum value
* is written to this register to reduce the chances of error.
*/
cdns_i2c_writereg(CDNS_I2C_TIMEOUT_MAX, CDNS_I2C_TIME_OUT_OFFSET);
}
/**
* cdns_i2c_runtime_suspend - Runtime suspend method for the driver
* @dev: Address of the platform_device structure
*
* Put the driver into low power mode.
*
* Return: 0 always
*/
static int cdns_i2c_runtime_suspend(struct device *dev)
{
struct cdns_i2c *xi2c = dev_get_drvdata(dev);
clk_disable(xi2c->clk);
return 0;
}
/**
* cdns_i2c_runtime_resume - Runtime resume
* @dev: Address of the platform_device structure
*
* Runtime resume callback.
*
* Return: 0 on success and error value on error
*/
static int cdns_i2c_runtime_resume(struct device *dev)
{
struct cdns_i2c *xi2c = dev_get_drvdata(dev);
int ret;
Annotation
- Immediate include surface: `linux/clk.h`, `linux/delay.h`, `linux/i2c.h`, `linux/interrupt.h`, `linux/io.h`, `linux/iopoll.h`, `linux/module.h`, `linux/platform_device.h`.
- Detected declarations: `struct cdns_i2c`, `struct cdns_platform_data`, `enum cdns_i2c_mode`, `enum cdns_i2c_slave_state`, `function cdns_i2c_init`, `function cdns_i2c_runtime_suspend`, `function cdns_i2c_runtime_resume`, `function cdns_i2c_clear_bus_hold`, `function cdns_is_holdquirk`, `function cdns_i2c_set_mode`.
- 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.