drivers/i2c/busses/i2c-au1550.c
Source file repositories/reference/linux-study-clean/drivers/i2c/busses/i2c-au1550.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/i2c/busses/i2c-au1550.c- Extension
.c- Size
- 8512 bytes
- Lines
- 380
- 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.
- 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/delay.hlinux/kernel.hlinux/module.hlinux/platform_device.hlinux/errno.hlinux/i2c.hlinux/slab.hasm/mach-au1x00/au1000.hasm/mach-au1x00/au1xxx_psc.h
Detected Declarations
struct i2c_au1550_datafunction WRfunction RDfunction wait_xfer_donefunction wait_ackfunction wait_controller_donefunction do_addressfunction wait_for_rx_bytefunction i2c_readfunction i2c_writefunction au1550_xferfunction au1550_funcfunction i2c_au1550_setupfunction i2c_au1550_disablefunction i2c_au1550_probefunction i2c_au1550_removefunction i2c_au1550_suspendfunction i2c_au1550_resume
Annotated Snippet
struct i2c_au1550_data {
void __iomem *psc_base;
int xfer_timeout;
struct i2c_adapter adap;
};
static inline void WR(struct i2c_au1550_data *a, int r, unsigned long v)
{
__raw_writel(v, a->psc_base + r);
wmb();
}
static inline unsigned long RD(struct i2c_au1550_data *a, int r)
{
return __raw_readl(a->psc_base + r);
}
static int wait_xfer_done(struct i2c_au1550_data *adap)
{
int i;
/* Wait for Tx Buffer Empty */
for (i = 0; i < adap->xfer_timeout; i++) {
if (RD(adap, PSC_SMBSTAT) & PSC_SMBSTAT_TE)
return 0;
udelay(1);
}
return -ETIMEDOUT;
}
static int wait_ack(struct i2c_au1550_data *adap)
{
unsigned long stat;
if (wait_xfer_done(adap))
return -ETIMEDOUT;
stat = RD(adap, PSC_SMBEVNT);
if ((stat & (PSC_SMBEVNT_DN | PSC_SMBEVNT_AN | PSC_SMBEVNT_AL)) != 0)
return -ETIMEDOUT;
return 0;
}
static int wait_controller_done(struct i2c_au1550_data *adap)
{
int i;
for (i = 0; i < 2 * adap->xfer_timeout; i++) {
if ((RD(adap, PSC_SMBEVNT) & PSC_SMBEVNT_MD) != 0)
return 0;
udelay(1);
}
return -ETIMEDOUT;
}
static int
do_address(struct i2c_au1550_data *adap, unsigned int addr, int rd, int q)
{
unsigned long stat;
/* Reset the FIFOs, clear events. */
stat = RD(adap, PSC_SMBSTAT);
WR(adap, PSC_SMBEVNT, PSC_SMBEVNT_ALLCLR);
if (!(stat & PSC_SMBSTAT_TE) || !(stat & PSC_SMBSTAT_RE)) {
WR(adap, PSC_SMBPCR, PSC_SMBPCR_DC);
while ((RD(adap, PSC_SMBPCR) & PSC_SMBPCR_DC) != 0)
cpu_relax();
udelay(50);
}
/* Write out the i2c chip address and specify operation */
addr <<= 1;
if (rd)
addr |= 1;
/* zero-byte xfers stop immediately */
if (q)
addr |= PSC_SMBTXRX_STP;
/* Put byte into fifo, start up controller */
WR(adap, PSC_SMBTXRX, addr);
WR(adap, PSC_SMBPCR, PSC_SMBPCR_MS);
if (wait_ack(adap))
return -EIO;
return (q) ? wait_controller_done(adap) : 0;
Annotation
- Immediate include surface: `linux/delay.h`, `linux/kernel.h`, `linux/module.h`, `linux/platform_device.h`, `linux/errno.h`, `linux/i2c.h`, `linux/slab.h`, `asm/mach-au1x00/au1000.h`.
- Detected declarations: `struct i2c_au1550_data`, `function WR`, `function RD`, `function wait_xfer_done`, `function wait_ack`, `function wait_controller_done`, `function do_address`, `function wait_for_rx_byte`, `function i2c_read`, `function i2c_write`.
- Atlas domain: Driver Families / drivers/i2c.
- Implementation status: source implementation candidate.
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.