drivers/i2c/busses/i2c-st.c
Source file repositories/reference/linux-study-clean/drivers/i2c/busses/i2c-st.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/i2c/busses/i2c-st.c- Extension
.c- Size
- 22883 bytes
- Lines
- 892
- 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/err.hlinux/i2c.hlinux/interrupt.hlinux/io.hlinux/minmax.hlinux/module.hlinux/of_address.hlinux/of_irq.hlinux/of.hlinux/pinctrl/consumer.hlinux/platform_device.hlinux/units.h
Detected Declarations
struct st_i2c_timingsstruct st_i2c_clientstruct st_i2c_devenum st_i2c_modefunction st_i2c_set_bitsfunction st_i2c_clr_bitsfunction st_i2c_flush_rx_fifofunction st_i2c_soft_resetfunction st_i2c_hw_configfunction st_i2c_recover_busfunction st_i2c_wait_free_busfunction st_i2c_write_tx_fifofunction st_i2c_wr_fill_tx_fifofunction st_i2c_rd_fill_tx_fifofunction st_i2c_read_rx_fifofunction st_i2c_terminate_xferfunction st_i2c_handle_writefunction st_i2c_handle_readfunction st_i2c_isr_threadfunction st_i2c_xfer_msgfunction st_i2c_xferfunction st_i2c_suspendfunction st_i2c_resumefunction st_i2c_funcfunction st_i2c_of_get_deglitchfunction st_i2c_probefunction st_i2c_remove
Annotated Snippet
struct st_i2c_timings {
u32 rate;
u32 rep_start_hold;
u32 rep_start_setup;
u32 start_hold;
u32 data_setup_time;
u32 stop_setup_time;
u32 bus_free_time;
u32 sda_pulse_min_limit;
};
/**
* struct st_i2c_client - client specific data
* @addr: 8-bit target addr, including r/w bit
* @count: number of bytes to be transferred
* @xfered: number of bytes already transferred
* @buf: data buffer
* @result: result of the transfer
* @stop: last I2C msg to be sent, i.e. STOP to be generated
*/
struct st_i2c_client {
u8 addr;
u32 count;
u32 xfered;
u8 *buf;
int result;
bool stop;
};
/**
* struct st_i2c_dev - private data of the controller
* @adap: I2C adapter for this controller
* @dev: device for this controller
* @base: virtual memory area
* @complete: completion of I2C message
* @irq: interrupt line for th controller
* @clk: hw ssc block clock
* @mode: I2C mode of the controller. Standard or Fast only supported
* @scl_min_width_us: SCL line minimum pulse width in us
* @sda_min_width_us: SDA line minimum pulse width in us
* @client: I2C transfert information
* @busy: I2C transfer on-going
*/
struct st_i2c_dev {
struct i2c_adapter adap;
struct device *dev;
void __iomem *base;
struct completion complete;
int irq;
struct clk *clk;
int mode;
u32 scl_min_width_us;
u32 sda_min_width_us;
struct st_i2c_client client;
bool busy;
};
static inline void st_i2c_set_bits(void __iomem *reg, u32 mask)
{
writel_relaxed(readl_relaxed(reg) | mask, reg);
}
static inline void st_i2c_clr_bits(void __iomem *reg, u32 mask)
{
writel_relaxed(readl_relaxed(reg) & ~mask, reg);
}
/*
* From I2C Specifications v0.5.
*
* All the values below have +10% margin added to be
* compatible with some out-of-spec devices,
* like HDMI link of the Toshiba 19AV600 TV.
*/
static struct st_i2c_timings i2c_timings[] = {
[I2C_MODE_STANDARD] = {
.rate = I2C_MAX_STANDARD_MODE_FREQ,
.rep_start_hold = 4400,
.rep_start_setup = 5170,
.start_hold = 4400,
.data_setup_time = 275,
.stop_setup_time = 4400,
.bus_free_time = 5170,
},
[I2C_MODE_FAST] = {
.rate = I2C_MAX_FAST_MODE_FREQ,
.rep_start_hold = 660,
.rep_start_setup = 660,
.start_hold = 660,
.data_setup_time = 110,
Annotation
- Immediate include surface: `linux/clk.h`, `linux/delay.h`, `linux/err.h`, `linux/i2c.h`, `linux/interrupt.h`, `linux/io.h`, `linux/minmax.h`, `linux/module.h`.
- Detected declarations: `struct st_i2c_timings`, `struct st_i2c_client`, `struct st_i2c_dev`, `enum st_i2c_mode`, `function st_i2c_set_bits`, `function st_i2c_clr_bits`, `function st_i2c_flush_rx_fifo`, `function st_i2c_soft_reset`, `function st_i2c_hw_config`, `function st_i2c_recover_bus`.
- 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.