drivers/i2c/busses/i2c-rk3x.c
Source file repositories/reference/linux-study-clean/drivers/i2c/busses/i2c-rk3x.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/i2c/busses/i2c-rk3x.c- Extension
.c- Size
- 37603 bytes
- Lines
- 1414
- 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/kernel.hlinux/module.hlinux/i2c.hlinux/interrupt.hlinux/iopoll.hlinux/errno.hlinux/err.hlinux/platform_device.hlinux/io.hlinux/of_address.hlinux/of_irq.hlinux/spinlock.hlinux/clk.hlinux/units.hlinux/wait.hlinux/mfd/syscon.hlinux/regmap.hlinux/math64.h
Detected Declarations
struct i2c_spec_valuesstruct rk3x_i2c_calced_timingsstruct rk3x_i2c_soc_datastruct rk3x_i2cenum rk3x_i2c_statefunction i2c_writelfunction i2c_readlfunction rk3x_i2c_clean_ipdfunction rk3x_i2c_startfunction rk3x_i2c_stopfunction rk3x_i2c_prepare_readfunction rk3x_i2c_fill_transmit_buffunction rk3x_i2c_handle_startfunction rk3x_i2c_handle_writefunction rk3x_i2c_handle_readfunction rk3x_i2c_handle_stopfunction rk3x_i2c_irqfunction rk3x_i2c_v0_calc_timingsfunction rk3x_i2c_v1_calc_timingsfunction rk3x_i2c_adapt_divfunction rk3x_i2c_clk_notifier_cbfunction rk3x_i2c_setupfunction smallfunction rk3x_i2c_wait_xfer_pollfunction rk3x_i2c_xfer_commonfunction rk3x_i2c_xferfunction rk3x_i2c_xfer_pollingfunction rk3x_i2c_resumefunction rk3x_i2c_funcfunction rk3x_i2c_probefunction rk3x_i2c_remove
Annotated Snippet
struct i2c_spec_values {
unsigned long min_hold_start_ns;
unsigned long min_low_ns;
unsigned long min_high_ns;
unsigned long min_setup_start_ns;
unsigned long max_data_hold_ns;
unsigned long min_data_setup_ns;
unsigned long min_setup_stop_ns;
unsigned long min_hold_buffer_ns;
};
static const struct i2c_spec_values standard_mode_spec = {
.min_hold_start_ns = 4000,
.min_low_ns = 4700,
.min_high_ns = 4000,
.min_setup_start_ns = 4700,
.max_data_hold_ns = 3450,
.min_data_setup_ns = 250,
.min_setup_stop_ns = 4000,
.min_hold_buffer_ns = 4700,
};
static const struct i2c_spec_values fast_mode_spec = {
.min_hold_start_ns = 600,
.min_low_ns = 1300,
.min_high_ns = 600,
.min_setup_start_ns = 600,
.max_data_hold_ns = 900,
.min_data_setup_ns = 100,
.min_setup_stop_ns = 600,
.min_hold_buffer_ns = 1300,
};
static const struct i2c_spec_values fast_mode_plus_spec = {
.min_hold_start_ns = 260,
.min_low_ns = 500,
.min_high_ns = 260,
.min_setup_start_ns = 260,
.max_data_hold_ns = 400,
.min_data_setup_ns = 50,
.min_setup_stop_ns = 260,
.min_hold_buffer_ns = 500,
};
/**
* struct rk3x_i2c_calced_timings - calculated V1 timings
* @div_low: Divider output for low
* @div_high: Divider output for high
* @tuning: Used to adjust setup/hold data time,
* setup/hold start time and setup stop time for
* v1's calc_timings, the tuning should all be 0
* for old hardware anyone using v0's calc_timings.
*/
struct rk3x_i2c_calced_timings {
unsigned long div_low;
unsigned long div_high;
unsigned int tuning;
};
enum rk3x_i2c_state {
STATE_IDLE,
STATE_START,
STATE_READ,
STATE_WRITE,
STATE_STOP
};
/**
* struct rk3x_i2c_soc_data - SOC-specific data
* @grf_offset: offset inside the grf regmap for setting the i2c type
* @calc_timings: Callback function for i2c timing information calculated
*/
struct rk3x_i2c_soc_data {
int grf_offset;
int (*calc_timings)(unsigned long, struct i2c_timings *,
struct rk3x_i2c_calced_timings *);
};
/**
* struct rk3x_i2c - private data of the controller
* @adap: corresponding I2C adapter
* @dev: device for this controller
* @soc_data: related soc data struct
* @regs: virtual memory area
* @clk: function clk for rk3399 or function & Bus clks for others
* @pclk: Bus clk for rk3399
* @clk_rate_nb: i2c clk rate change notify
* @irq: irq number
* @t: I2C known timing information
* @lock: spinlock for the i2c bus
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/module.h`, `linux/i2c.h`, `linux/interrupt.h`, `linux/iopoll.h`, `linux/errno.h`, `linux/err.h`, `linux/platform_device.h`.
- Detected declarations: `struct i2c_spec_values`, `struct rk3x_i2c_calced_timings`, `struct rk3x_i2c_soc_data`, `struct rk3x_i2c`, `enum rk3x_i2c_state`, `function i2c_writel`, `function i2c_readl`, `function rk3x_i2c_clean_ipd`, `function rk3x_i2c_start`, `function rk3x_i2c_stop`.
- 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.