drivers/i2c/busses/i2c-highlander.c
Source file repositories/reference/linux-study-clean/drivers/i2c/busses/i2c-highlander.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/i2c/busses/i2c-highlander.c- Extension
.c- Size
- 10850 bytes
- Lines
- 477
- 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/module.hlinux/interrupt.hlinux/i2c.hlinux/platform_device.hlinux/completion.hlinux/io.hlinux/delay.hlinux/slab.h
Detected Declarations
struct highlander_i2c_devfunction highlander_i2c_irq_enablefunction highlander_i2c_irq_disablefunction highlander_i2c_startfunction highlander_i2c_donefunction highlander_i2c_setupfunction smbus_write_datafunction smbus_read_datafunction highlander_i2c_commandfunction highlander_i2c_wait_for_bbsyfunction highlander_i2c_resetfunction highlander_i2c_wait_for_ackfunction highlander_i2c_irqfunction highlander_i2c_pollfunction highlander_i2c_wait_xfer_donefunction highlander_i2c_readfunction highlander_i2c_writefunction highlander_i2c_smbus_xferfunction highlander_i2c_funcfunction highlander_i2c_probefunction highlander_i2c_remove
Annotated Snippet
struct highlander_i2c_dev {
struct device *dev;
void __iomem *base;
struct i2c_adapter adapter;
struct completion cmd_complete;
unsigned long last_read_time;
int irq;
u8 *buf;
size_t buf_len;
};
static bool iic_force_poll, iic_force_normal;
static int iic_timeout = 1000, iic_read_delay;
static inline void highlander_i2c_irq_enable(struct highlander_i2c_dev *dev)
{
iowrite16(ioread16(dev->base + SMCR) | SMCR_IEIC, dev->base + SMCR);
}
static inline void highlander_i2c_irq_disable(struct highlander_i2c_dev *dev)
{
iowrite16(ioread16(dev->base + SMCR) & ~SMCR_IEIC, dev->base + SMCR);
}
static inline void highlander_i2c_start(struct highlander_i2c_dev *dev)
{
iowrite16(ioread16(dev->base + SMCR) | SMCR_START, dev->base + SMCR);
}
static inline void highlander_i2c_done(struct highlander_i2c_dev *dev)
{
iowrite16(ioread16(dev->base + SMCR) | SMCR_IRIC, dev->base + SMCR);
}
static void highlander_i2c_setup(struct highlander_i2c_dev *dev)
{
u16 smmr;
smmr = ioread16(dev->base + SMMR);
smmr |= SMMR_TMMD;
if (iic_force_normal)
smmr &= ~SMMR_SP;
else
smmr |= SMMR_SP;
iowrite16(smmr, dev->base + SMMR);
}
static void smbus_write_data(u8 *src, u16 *dst, int len)
{
for (; len > 1; len -= 2) {
*dst++ = be16_to_cpup((__be16 *)src);
src += 2;
}
if (len)
*dst = *src << 8;
}
static void smbus_read_data(u16 *src, u8 *dst, int len)
{
for (; len > 1; len -= 2) {
*(__be16 *)dst = cpu_to_be16p(src++);
dst += 2;
}
if (len)
*dst = *src >> 8;
}
static void highlander_i2c_command(struct highlander_i2c_dev *dev,
u8 command, int len)
{
unsigned int i;
u16 cmd = (command << 8) | command;
for (i = 0; i < len; i += 2) {
if (len - i == 1)
cmd = command << 8;
iowrite16(cmd, dev->base + SMSADR + i);
dev_dbg(dev->dev, "command data[%x] 0x%04x\n", i/2, cmd);
}
}
static int highlander_i2c_wait_for_bbsy(struct highlander_i2c_dev *dev)
{
unsigned long timeout;
timeout = jiffies + msecs_to_jiffies(iic_timeout);
Annotation
- Immediate include surface: `linux/module.h`, `linux/interrupt.h`, `linux/i2c.h`, `linux/platform_device.h`, `linux/completion.h`, `linux/io.h`, `linux/delay.h`, `linux/slab.h`.
- Detected declarations: `struct highlander_i2c_dev`, `function highlander_i2c_irq_enable`, `function highlander_i2c_irq_disable`, `function highlander_i2c_start`, `function highlander_i2c_done`, `function highlander_i2c_setup`, `function smbus_write_data`, `function smbus_read_data`, `function highlander_i2c_command`, `function highlander_i2c_wait_for_bbsy`.
- 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.