drivers/i2c/busses/i2c-octeon-core.c
Source file repositories/reference/linux-study-clean/drivers/i2c/busses/i2c-octeon-core.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/i2c/busses/i2c-octeon-core.c- Extension
.c- Size
- 25934 bytes
- Lines
- 1003
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/delay.hlinux/i2c.hlinux/interrupt.hlinux/kernel.hlinux/module.hlinux/pci.hi2c-octeon-core.h
Detected Declarations
function Copyrightfunction octeon_i2c_test_iflgfunction octeon_i2c_waitfunction octeon_i2c_hlc_test_validfunction octeon_i2c_hlc_int_clearfunction octeon_i2c_hlc_enablefunction octeon_i2c_hlc_disablefunction octeon_i2c_block_enablefunction octeon_i2c_block_disablefunction octeon_i2c_hlc_waitfunction octeon_i2c_check_statusfunction octeon_i2c_recoveryfunction octeon_i2c_startfunction octeon_i2c_stopfunction octeon_i2c_readfunction octeon_i2c_writefunction octeon_i2c_hlc_readfunction octeon_i2c_hlc_writefunction octeon_i2c_hlc_cmd_sendfunction octeon_i2c_hlc_extfunction octeon_i2c_hlc_read_cmdfunction octeon_i2c_hlc_comp_readfunction octeon_i2c_hlc_comp_writefunction octeon_i2c_hlc_block_comp_readfunction octeon_i2c_hlc_block_comp_writefunction octeon_i2c_xferfunction octeon_i2c_set_clockfunction octeon_i2c_init_lowlevelfunction octeon_i2c_get_sclfunction octeon_i2c_set_sclfunction octeon_i2c_get_sdafunction octeon_i2c_prepare_recoveryfunction octeon_i2c_unprepare_recovery
Annotated Snippet
octeon_i2c_test_iflg(i2c)) {
dev_err(i2c->dev, "broken irq connection detected, switching to polling mode.\n");
i2c->broken_irq_mode = true;
return 0;
}
if (!time_left)
return -ETIMEDOUT;
return 0;
}
static bool octeon_i2c_hlc_test_valid(struct octeon_i2c *i2c)
{
return (__raw_readq(i2c->twsi_base + OCTEON_REG_SW_TWSI(i2c)) & SW_TWSI_V) == 0;
}
static void octeon_i2c_hlc_int_clear(struct octeon_i2c *i2c)
{
/* clear ST/TS events, listen for neither */
octeon_i2c_write_int(i2c, TWSI_INT_ST_INT | TWSI_INT_TS_INT);
}
/*
* Cleanup low-level state & enable high-level controller.
*/
static void octeon_i2c_hlc_enable(struct octeon_i2c *i2c)
{
int try = 0;
u64 val;
if (i2c->hlc_enabled)
return;
i2c->hlc_enabled = true;
while (1) {
val = octeon_i2c_ctl_read(i2c);
if (!(val & (TWSI_CTL_STA | TWSI_CTL_STP)))
break;
/* clear IFLG event */
if (val & TWSI_CTL_IFLG)
octeon_i2c_ctl_write(i2c, TWSI_CTL_ENAB);
if (try++ > 100) {
pr_err("%s: giving up\n", __func__);
break;
}
/* spin until any start/stop has finished */
udelay(10);
}
octeon_i2c_ctl_write(i2c, TWSI_CTL_CE | TWSI_CTL_AAK | TWSI_CTL_ENAB);
}
static void octeon_i2c_hlc_disable(struct octeon_i2c *i2c)
{
if (!i2c->hlc_enabled)
return;
i2c->hlc_enabled = false;
octeon_i2c_ctl_write(i2c, TWSI_CTL_ENAB);
}
static void octeon_i2c_block_enable(struct octeon_i2c *i2c)
{
u64 mode;
if (i2c->block_enabled || !OCTEON_REG_BLOCK_CTL(i2c))
return;
i2c->block_enabled = true;
mode = __raw_readq(i2c->twsi_base + OCTEON_REG_MODE(i2c));
mode |= TWSX_MODE_BLOCK_MODE;
octeon_i2c_writeq_flush(mode, i2c->twsi_base + OCTEON_REG_MODE(i2c));
}
static void octeon_i2c_block_disable(struct octeon_i2c *i2c)
{
u64 mode;
if (!i2c->block_enabled || !OCTEON_REG_BLOCK_CTL(i2c))
return;
i2c->block_enabled = false;
mode = __raw_readq(i2c->twsi_base + OCTEON_REG_MODE(i2c));
mode &= ~TWSX_MODE_BLOCK_MODE;
octeon_i2c_writeq_flush(mode, i2c->twsi_base + OCTEON_REG_MODE(i2c));
}
Annotation
- Immediate include surface: `linux/delay.h`, `linux/i2c.h`, `linux/interrupt.h`, `linux/kernel.h`, `linux/module.h`, `linux/pci.h`, `i2c-octeon-core.h`.
- Detected declarations: `function Copyright`, `function octeon_i2c_test_iflg`, `function octeon_i2c_wait`, `function octeon_i2c_hlc_test_valid`, `function octeon_i2c_hlc_int_clear`, `function octeon_i2c_hlc_enable`, `function octeon_i2c_hlc_disable`, `function octeon_i2c_block_enable`, `function octeon_i2c_block_disable`, `function octeon_i2c_hlc_wait`.
- 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.