drivers/i2c/busses/i2c-rtl9300.c
Source file repositories/reference/linux-study-clean/drivers/i2c/busses/i2c-rtl9300.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/i2c/busses/i2c-rtl9300.c- Extension
.c- Size
- 18215 bytes
- Lines
- 672
- 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.
- 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/bits.hlinux/clk.hlinux/i2c.hlinux/i2c-mux.hlinux/mod_devicetable.hlinux/mfd/syscon.hlinux/mutex.hlinux/platform_device.hlinux/regmap.hlinux/unaligned.h
Detected Declarations
struct rtl9300_i2cstruct rtl9300_i2c_chanstruct rtl9300_i2c_reg_fieldstruct rtl9300_i2c_drv_datastruct rtl9300_i2cstruct rtl9300_i2c_xferenum rtl9300_bus_freqenum rtl9300_i2c_reg_scopeenum rtl9300_i2c_reg_fieldsenum rtl9300_i2c_xfer_typefunction rtl9300_i2c_reg_addr_setfunction rtl9300_i2c_select_sclfunction rtl9310_i2c_select_sclfunction rtl9300_i2c_config_chanfunction rtl9607_i2c_config_chanfunction rtl9300_i2c_config_clockfunction rtl9607_i2c_config_clockfunction rtl9300_i2c_readfunction rtl9300_i2c_writefunction rtl9300_i2c_writelfunction rtl9300_i2c_prepare_xferfunction rtl9300_i2c_do_xferfunction rtl9300_i2c_smbus_xferfunction rtl9300_i2c_funcfunction rtl9300_i2c_initfunction rtl9607_i2c_initfunction rtl9300_i2c_probe
Annotated Snippet
struct rtl9300_i2c_chan {
struct i2c_adapter adap;
struct rtl9300_i2c *i2c;
enum rtl9300_bus_freq bus_freq;
u8 sda_num;
u32 clk_div;
};
enum rtl9300_i2c_reg_scope {
REG_SCOPE_GLOBAL,
REG_SCOPE_MASTER,
};
struct rtl9300_i2c_reg_field {
struct reg_field field;
enum rtl9300_i2c_reg_scope scope;
};
enum rtl9300_i2c_reg_fields {
F_DATA_WIDTH = 0,
F_DEV_ADDR,
F_I2C_FAIL,
F_I2C_TRIG,
F_MEM_ADDR,
F_MEM_ADDR_WIDTH,
F_RD_MODE,
F_RWOP,
F_SCL_FREQ,
F_SCL_SEL,
F_SDA_OUT_SEL,
F_SDA_SEL,
F_BUSY,
F_CLK_DIV,
F_EXT_SCK_5MS,
/* keep last */
F_NUM_FIELDS
};
struct rtl9300_i2c_drv_data {
struct rtl9300_i2c_reg_field field_desc[F_NUM_FIELDS];
int (*select_scl)(struct rtl9300_i2c *i2c, u8 scl);
int (*config_chan)(struct rtl9300_i2c *i2c, struct rtl9300_i2c_chan *chan);
void (*config_clock)(u32 clock_freq, struct rtl9300_i2c_chan *chan);
int (*misc_init)(struct rtl9300_i2c *i2c);
u32 rd_reg;
u32 wd_reg;
u8 max_nchan;
u8 max_data_len;
u8 reg_addr_8bit_len;
};
#define RTL9300_I2C_MUX_NCHAN 8
#define RTL9310_I2C_MUX_NCHAN 12
#define RTL9607_I2C_MUX_NCHAN 1
#define RTL9300_I2C_MAX_DATA_LEN 16
#define RTL9607_I2C_MAX_DATA_LEN 4
struct rtl9300_i2c {
struct regmap *regmap;
struct device *dev;
struct rtl9300_i2c_chan chans[RTL9310_I2C_MUX_NCHAN];
struct regmap_field *fields[F_NUM_FIELDS];
u32 reg_base;
u32 rd_reg;
u32 wd_reg;
u8 scl_num;
u8 sda_num;
struct mutex lock;
struct clk *clk;
};
DEFINE_GUARD(rtl9300_i2c, struct rtl9300_i2c *, mutex_lock(&_T->lock), mutex_unlock(&_T->lock))
enum rtl9300_i2c_xfer_type {
RTL9300_I2C_XFER_BYTE,
RTL9300_I2C_XFER_WORD,
RTL9300_I2C_XFER_BLOCK,
};
struct rtl9300_i2c_xfer {
enum rtl9300_i2c_xfer_type type;
u16 dev_addr;
u8 reg_addr;
u8 reg_addr_len;
u8 *data;
u8 data_len;
bool write;
};
Annotation
- Immediate include surface: `linux/bits.h`, `linux/clk.h`, `linux/i2c.h`, `linux/i2c-mux.h`, `linux/mod_devicetable.h`, `linux/mfd/syscon.h`, `linux/mutex.h`, `linux/platform_device.h`.
- Detected declarations: `struct rtl9300_i2c`, `struct rtl9300_i2c_chan`, `struct rtl9300_i2c_reg_field`, `struct rtl9300_i2c_drv_data`, `struct rtl9300_i2c`, `struct rtl9300_i2c_xfer`, `enum rtl9300_bus_freq`, `enum rtl9300_i2c_reg_scope`, `enum rtl9300_i2c_reg_fields`, `enum rtl9300_i2c_xfer_type`.
- 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.
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.