drivers/i2c/busses/i2c-qcom-geni.c
Source file repositories/reference/linux-study-clean/drivers/i2c/busses/i2c-qcom-geni.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/i2c/busses/i2c-qcom-geni.c- Extension
.c- Size
- 34378 bytes
- Lines
- 1300
- 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/acpi.hlinux/clk.hlinux/dmaengine.hlinux/dma-mapping.hlinux/dma/qcom-gpi-dma.hlinux/err.hlinux/i2c.hlinux/interrupt.hlinux/io.hlinux/module.hlinux/of.hlinux/platform_device.hlinux/pm_runtime.hlinux/soc/qcom/geni-se.hlinux/spinlock.hlinux/units.h
Detected Declarations
struct geni_i2c_gpi_multi_desc_xferstruct geni_i2c_devstruct geni_i2c_descstruct geni_i2c_err_logstruct geni_i2c_clk_fldenum geni_i2c_err_codefunction geni_i2c_clk_map_idxfunction qcom_geni_i2c_conffunction geni_i2c_err_miscfunction geni_i2c_errfunction geni_i2c_irqfunction geni_i2c_abort_xferfunction geni_i2c_rx_fsm_rstfunction geni_i2c_tx_fsm_rstfunction geni_i2c_rx_msg_cleanupfunction geni_i2c_tx_msg_cleanupfunction geni_i2c_rx_one_msgfunction geni_i2c_tx_one_msgfunction i2c_gpi_cb_resultfunction geni_i2c_gpi_unmapfunction geni_i2c_gpi_multi_desc_unmapfunction geni_i2c_gpi_multi_xfer_timeout_handlerfunction geni_i2c_gpifunction messagefunction geni_i2c_gpi_xferfunction geni_i2c_fifo_xferfunction geni_i2c_xferfunction geni_i2c_funcfunction release_gpi_dmafunction setup_gpi_dmafunction geni_i2c_probefunction geni_i2c_removefunction geni_i2c_shutdownfunction geni_i2c_runtime_suspendfunction geni_i2c_runtime_resumefunction geni_i2c_suspend_noirqfunction geni_i2c_resume_noirq
Annotated Snippet
struct geni_i2c_gpi_multi_desc_xfer {
u32 msg_idx_cnt;
u32 unmap_msg_cnt;
u32 irq_cnt;
void **dma_buf;
dma_addr_t *dma_addr;
};
struct geni_i2c_dev {
struct geni_se se;
u32 tx_wm;
int irq;
int err;
struct i2c_adapter adap;
struct completion done;
struct i2c_msg *cur;
int cur_wr;
int cur_rd;
spinlock_t lock;
struct clk *core_clk;
u32 clk_freq_out;
const struct geni_i2c_clk_fld *clk_fld;
void *dma_buf;
size_t xfer_len;
dma_addr_t dma_addr;
struct dma_chan *tx_c;
struct dma_chan *rx_c;
bool no_dma;
bool gpi_mode;
bool abort_done;
bool is_tx_multi_desc_xfer;
u32 num_msgs;
struct geni_i2c_gpi_multi_desc_xfer i2c_multi_desc_config;
};
struct geni_i2c_desc {
bool has_core_clk;
char *icc_ddr;
bool no_dma_support;
unsigned int tx_fifo_depth;
};
struct geni_i2c_err_log {
int err;
const char *msg;
};
static const struct geni_i2c_err_log gi2c_log[] = {
[GP_IRQ0] = {-EIO, "Unknown I2C err GP_IRQ0"},
[NACK] = {-ENXIO, "NACK: slv unresponsive, check its power/reset-ln"},
[GP_IRQ2] = {-EIO, "Unknown I2C err GP IRQ2"},
[BUS_PROTO] = {-EPROTO, "Bus proto err, noisy/unexpected start/stop"},
[ARB_LOST] = {-EAGAIN, "Bus arbitration lost, clock line undriveable"},
[GP_IRQ5] = {-EIO, "Unknown I2C err GP IRQ5"},
[GENI_OVERRUN] = {-EIO, "Cmd overrun, check GENI cmd-state machine"},
[GENI_ILLEGAL_CMD] = {-EIO, "Illegal cmd, check GENI cmd-state machine"},
[GENI_ABORT_DONE] = {-ETIMEDOUT, "Abort after timeout successful"},
[GENI_TIMEOUT] = {-ETIMEDOUT, "I2C TXN timed out"},
};
struct geni_i2c_clk_fld {
u32 clk_freq_out;
u8 clk_div;
u8 t_high_cnt;
u8 t_low_cnt;
u8 t_cycle_cnt;
};
/*
* Hardware uses the underlying formula to calculate time periods of
* SCL clock cycle. Firmware uses some additional cycles excluded from the
* below formula and it is confirmed that the time periods are within
* specification limits.
*
* time of high period of SCL: t_high = (t_high_cnt * clk_div) / source_clock
* time of low period of SCL: t_low = (t_low_cnt * clk_div) / source_clock
* time of full period of SCL: t_cycle = (t_cycle_cnt * clk_div) / source_clock
* clk_freq_out = t / t_cycle
* source_clock = 19.2 MHz
*/
static const struct geni_i2c_clk_fld geni_i2c_clk_map_19p2mhz[] = {
{ I2C_MAX_STANDARD_MODE_FREQ, 7, 10, 12, 26 },
{ I2C_MAX_FAST_MODE_FREQ, 2, 5, 11, 22 },
{ I2C_MAX_FAST_MODE_PLUS_FREQ, 1, 2, 8, 18 },
{}
};
/* source_clock = 32 MHz */
static const struct geni_i2c_clk_fld geni_i2c_clk_map_32mhz[] = {
{ I2C_MAX_STANDARD_MODE_FREQ, 8, 14, 18, 38 },
Annotation
- Immediate include surface: `linux/acpi.h`, `linux/clk.h`, `linux/dmaengine.h`, `linux/dma-mapping.h`, `linux/dma/qcom-gpi-dma.h`, `linux/err.h`, `linux/i2c.h`, `linux/interrupt.h`.
- Detected declarations: `struct geni_i2c_gpi_multi_desc_xfer`, `struct geni_i2c_dev`, `struct geni_i2c_desc`, `struct geni_i2c_err_log`, `struct geni_i2c_clk_fld`, `enum geni_i2c_err_code`, `function geni_i2c_clk_map_idx`, `function qcom_geni_i2c_conf`, `function geni_i2c_err_misc`, `function geni_i2c_err`.
- 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.