drivers/i2c/busses/i2c-taos-evm.c
Source file repositories/reference/linux-study-clean/drivers/i2c/busses/i2c-taos-evm.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/i2c/busses/i2c-taos-evm.c- Extension
.c- Size
- 7528 bytes
- Lines
- 312
- 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/delay.hlinux/module.hlinux/slab.hlinux/interrupt.hlinux/input.hlinux/serio.hlinux/init.hlinux/i2c.h
Detected Declarations
struct taos_datafunction taos_smbus_xferfunction taos_smbus_funcfunction taos_interruptfunction taos_connectfunction taos_disconnect
Annotated Snippet
struct taos_data {
struct i2c_adapter adapter;
struct i2c_client *client;
int state;
u8 addr; /* last used address */
unsigned char buffer[TAOS_BUFFER_SIZE];
unsigned int pos; /* position inside the buffer */
};
/* TAOS TSL2550 EVM */
static const struct i2c_board_info tsl2550_info = {
I2C_BOARD_INFO("tsl2550", 0x39),
};
/* Instantiate i2c devices based on the adapter name */
static struct i2c_client *taos_instantiate_device(struct i2c_adapter *adapter)
{
if (!strncmp(adapter->name, "TAOS TSL2550 EVM", 16)) {
dev_info(&adapter->dev, "Instantiating device %s at 0x%02x\n",
tsl2550_info.type, tsl2550_info.addr);
return i2c_new_client_device(adapter, &tsl2550_info);
}
return ERR_PTR(-ENODEV);
}
static int taos_smbus_xfer(struct i2c_adapter *adapter, u16 addr,
unsigned short flags, char read_write, u8 command,
int size, union i2c_smbus_data *data)
{
struct serio *serio = adapter->algo_data;
struct taos_data *taos = serio_get_drvdata(serio);
char *p;
/* Encode our transaction. "@" is for the device address, "$" for the
SMBus command and "#" for the data. */
p = taos->buffer;
/* The device remembers the last used address, no need to send it
again if it's the same */
if (addr != taos->addr)
p += sprintf(p, "@%02X", addr);
switch (size) {
case I2C_SMBUS_BYTE:
if (read_write == I2C_SMBUS_WRITE)
sprintf(p, "$#%02X", command);
else
sprintf(p, "$");
break;
case I2C_SMBUS_BYTE_DATA:
if (read_write == I2C_SMBUS_WRITE)
sprintf(p, "$%02X#%02X", command, data->byte);
else
sprintf(p, "$%02X", command);
break;
default:
dev_warn(&adapter->dev, "Unsupported transaction %d\n", size);
return -EOPNOTSUPP;
}
/* Send the transaction to the TAOS EVM */
dev_dbg(&adapter->dev, "Command buffer: %s\n", taos->buffer);
for (p = taos->buffer; *p; p++)
serio_write(serio, *p);
taos->addr = addr;
/* Start the transaction and read the answer */
taos->pos = 0;
taos->state = TAOS_STATE_RECV;
serio_write(serio, read_write == I2C_SMBUS_WRITE ? '>' : '<');
wait_event_interruptible_timeout(wq, taos->state == TAOS_STATE_IDLE,
msecs_to_jiffies(150));
if (taos->state != TAOS_STATE_IDLE
|| taos->pos != 5) {
dev_err(&adapter->dev, "Transaction timeout (pos=%d)\n",
taos->pos);
return -EIO;
}
dev_dbg(&adapter->dev, "Answer buffer: %s\n", taos->buffer);
/* Interpret the returned string */
p = taos->buffer + 1;
p[3] = '\0';
if (!strcmp(p, "NAK"))
return -ENODEV;
if (read_write == I2C_SMBUS_WRITE) {
if (!strcmp(p, "ACK"))
Annotation
- Immediate include surface: `linux/delay.h`, `linux/module.h`, `linux/slab.h`, `linux/interrupt.h`, `linux/input.h`, `linux/serio.h`, `linux/init.h`, `linux/i2c.h`.
- Detected declarations: `struct taos_data`, `function taos_smbus_xfer`, `function taos_smbus_func`, `function taos_interrupt`, `function taos_connect`, `function taos_disconnect`.
- 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.