drivers/i2c/busses/i2c-mt65xx.c
Source file repositories/reference/linux-study-clean/drivers/i2c/busses/i2c-mt65xx.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/i2c/busses/i2c-mt65xx.c- Extension
.c- Size
- 43021 bytes
- Lines
- 1574
- 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/completion.hlinux/delay.hlinux/device.hlinux/dma-mapping.hlinux/err.hlinux/errno.hlinux/i2c.hlinux/init.hlinux/interrupt.hlinux/io.hlinux/iopoll.hlinux/kernel.hlinux/mm.hlinux/module.hlinux/of.hlinux/platform_device.hlinux/regulator/consumer.hlinux/scatterlist.hlinux/sched.hlinux/slab.hlinux/units.h
Detected Declarations
struct mtk_i2c_compatiblestruct mtk_i2c_ac_timingstruct mtk_i2cstruct i2c_spec_valuesenum i2c_mt65xx_clksenum DMA_REGS_OFFSETenum i2c_trans_st_rsenum mtk_trans_openum I2C_REGS_OFFSETfunction mtk_i2c_readwfunction mtk_i2c_writewfunction mtk_i2c_init_hwfunction mtk_i2c_max_step_cntfunction mtk_i2c_get_clk_div_restrifunction mtk_i2c_check_ac_timingfunction mtk_i2c_calculate_speedfunction mtk_i2c_set_speedfunction i2c_dump_registerfunction mtk_i2c_do_transferfunction mtk_i2c_transferfunction mtk_i2c_irqfunction mtk_i2c_functionalityfunction mtk_i2c_parse_dtfunction mtk_i2c_probefunction mtk_i2c_removefunction mtk_i2c_suspend_noirqfunction mtk_i2c_resume_noirq
Annotated Snippet
struct mtk_i2c_compatible {
const struct i2c_adapter_quirks *quirks;
const u16 *regs;
unsigned char pmic_i2c: 1;
unsigned char dcm: 1;
unsigned char auto_restart: 1;
unsigned char aux_len_reg: 1;
unsigned char timing_adjust: 1;
unsigned char dma_sync: 1;
unsigned char ltiming_adjust: 1;
unsigned char apdma_sync: 1;
unsigned char max_dma_support;
};
struct mtk_i2c_ac_timing {
u16 htiming;
u16 ltiming;
u16 hs;
u16 ext;
u16 inter_clk_div;
u16 scl_hl_ratio;
u16 hs_scl_hl_ratio;
u16 sta_stop;
u16 hs_sta_stop;
u16 sda_timing;
};
struct mtk_i2c {
struct i2c_adapter adap; /* i2c host adapter */
struct device *dev;
struct completion msg_complete;
struct i2c_timings timing_info;
/* set in i2c probe */
void __iomem *base; /* i2c base addr */
void __iomem *pdmabase; /* dma base address*/
struct clk_bulk_data clocks[I2C_MT65XX_CLK_MAX]; /* clocks for i2c */
bool have_pmic; /* can use i2c pins from PMIC */
bool use_push_pull; /* IO config push-pull mode */
u16 irq_stat; /* interrupt status */
unsigned int clk_src_div;
unsigned int speed_hz; /* The speed in transfer */
enum mtk_trans_op op;
u16 timing_reg;
u16 high_speed_reg;
u16 ltiming_reg;
unsigned char auto_restart;
bool ignore_restart_irq;
struct mtk_i2c_ac_timing ac_timing;
const struct mtk_i2c_compatible *dev_comp;
};
/**
* struct i2c_spec_values:
* @min_low_ns: min LOW period of the SCL clock
* @min_su_sta_ns: min set-up time for a repeated START condition
* @max_hd_dat_ns: max data hold time
* @min_su_dat_ns: min data set-up time
*/
struct i2c_spec_values {
unsigned int min_low_ns;
unsigned int min_su_sta_ns;
unsigned int max_hd_dat_ns;
unsigned int min_su_dat_ns;
};
static const struct i2c_spec_values standard_mode_spec = {
.min_low_ns = 4700 + I2C_STANDARD_MODE_BUFFER,
.min_su_sta_ns = 4700 + I2C_STANDARD_MODE_BUFFER,
.max_hd_dat_ns = 3450 - I2C_STANDARD_MODE_BUFFER,
.min_su_dat_ns = 250 + I2C_STANDARD_MODE_BUFFER,
};
static const struct i2c_spec_values fast_mode_spec = {
.min_low_ns = 1300 + I2C_FAST_MODE_BUFFER,
.min_su_sta_ns = 600 + I2C_FAST_MODE_BUFFER,
.max_hd_dat_ns = 900 - I2C_FAST_MODE_BUFFER,
.min_su_dat_ns = 100 + I2C_FAST_MODE_BUFFER,
};
static const struct i2c_spec_values fast_mode_plus_spec = {
.min_low_ns = 500 + I2C_FAST_MODE_PLUS_BUFFER,
.min_su_sta_ns = 260 + I2C_FAST_MODE_PLUS_BUFFER,
.max_hd_dat_ns = 400 - I2C_FAST_MODE_PLUS_BUFFER,
.min_su_dat_ns = 50 + I2C_FAST_MODE_PLUS_BUFFER,
};
static const struct i2c_adapter_quirks mt6577_i2c_quirks = {
.flags = I2C_AQ_COMB_WRITE_THEN_READ,
Annotation
- Immediate include surface: `linux/clk.h`, `linux/completion.h`, `linux/delay.h`, `linux/device.h`, `linux/dma-mapping.h`, `linux/err.h`, `linux/errno.h`, `linux/i2c.h`.
- Detected declarations: `struct mtk_i2c_compatible`, `struct mtk_i2c_ac_timing`, `struct mtk_i2c`, `struct i2c_spec_values`, `enum i2c_mt65xx_clks`, `enum DMA_REGS_OFFSET`, `enum i2c_trans_st_rs`, `enum mtk_trans_op`, `enum I2C_REGS_OFFSET`, `function mtk_i2c_readw`.
- 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.