include/linux/i2c.h
Source file repositories/reference/linux-study-clean/include/linux/i2c.h
File Facts
- System
- Linux kernel
- Corpus path
include/linux/i2c.h- Extension
.h- Size
- 40624 bytes
- Lines
- 1125
- Domain
- Core OS
- Bucket
- Core Kernel Interface
- Inferred role
- Core OS: operation-table or driver-model contract
- Status
- pattern implementation candidate
Why This File Exists
Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/acpi.hlinux/bits.hlinux/mod_devicetable.hlinux/device.hlinux/sched.hlinux/mutex.hlinux/regulator/consumer.hlinux/rtmutex.hlinux/irqdomain.hlinux/of.hlinux/swab.huapi/linux/i2c.h
Detected Declarations
struct i2c_msgstruct i2c_adapterstruct i2c_clientstruct i2c_driverstruct i2c_device_identitystruct i2c_board_infostruct modulestruct property_entrystruct i2c_device_identitystruct i2c_driverstruct i2c_clientstruct i2c_board_infostruct i2c_algorithmstruct i2c_lock_operationsstruct i2c_timingsstruct i2c_bus_recovery_infostruct i2c_adapter_quirksstruct i2c_adapterstruct acpi_resourcestruct acpi_resource_i2c_serialbusenum i2c_slave_eventenum i2c_alert_protocolenum i2c_driver_flagsenum i2c_slave_eventfunction i2c_master_recvfunction i2c_master_recv_dmasafefunction i2c_master_sendfunction i2c_master_send_dmasafefunction i2c_smbus_read_word_swappedfunction i2c_smbus_write_word_swappedfunction i2c_set_clientdatafunction i2c_detect_slave_modefunction i2c_register_board_infofunction i2c_set_adapdatafunction i2c_parent_is_i2c_adapterfunction i2c_lock_busfunction i2c_trylock_busfunction i2c_unlock_busfunction i2c_mark_adapter_suspendedfunction i2c_mark_adapter_resumedfunction i2c_client_has_driverfunction i2c_get_functionalityfunction i2c_check_functionalityfunction i2c_check_quirksfunction i2c_adapter_idfunction i2c_8bit_addr_from_msgfunction i2c_10bit_addr_hi_from_msgfunction i2c_10bit_addr_lo_from_msg
Annotated Snippet
extern const struct bus_type i2c_bus_type;
extern const struct device_type i2c_adapter_type;
extern const struct device_type i2c_client_type;
/* --- General options ------------------------------------------------ */
struct i2c_msg;
struct i2c_adapter;
struct i2c_client;
struct i2c_driver;
struct i2c_device_identity;
union i2c_smbus_data;
struct i2c_board_info;
enum i2c_slave_event;
typedef int (*i2c_slave_cb_t)(struct i2c_client *client,
enum i2c_slave_event event, u8 *val);
/* I2C Frequency Modes */
#define I2C_MAX_STANDARD_MODE_FREQ 100000
#define I2C_MAX_FAST_MODE_FREQ 400000
#define I2C_MAX_FAST_MODE_PLUS_FREQ 1000000
#define I2C_MAX_TURBO_MODE_FREQ 1400000
#define I2C_MAX_HIGH_SPEED_MODE_FREQ 3400000
#define I2C_MAX_ULTRA_FAST_MODE_FREQ 5000000
struct module;
struct property_entry;
#if IS_ENABLED(CONFIG_I2C)
/* Return the Frequency mode string based on the bus frequency */
const char *i2c_freq_mode_string(u32 bus_freq_hz);
/*
* The master routines are the ones normally used to transmit data to devices
* on a bus (or read from them). Apart from two basic transfer functions to
* transmit one message at a time, a more complex version can be used to
* transmit an arbitrary number of messages without interruption.
* @count must be less than 64k since msg.len is u16.
*/
int i2c_transfer_buffer_flags(const struct i2c_client *client,
char *buf, int count, u16 flags);
/**
* i2c_master_recv - issue a single I2C message in master receive mode
* @client: Handle to slave device
* @buf: Where to store data read from slave
* @count: How many bytes to read, must be less than 64k since msg.len is u16
*
* Returns negative errno, or else the number of bytes read.
*/
static inline int i2c_master_recv(const struct i2c_client *client,
char *buf, int count)
{
return i2c_transfer_buffer_flags(client, buf, count, I2C_M_RD);
};
/**
* i2c_master_recv_dmasafe - issue a single I2C message in master receive mode
* using a DMA safe buffer
* @client: Handle to slave device
* @buf: Where to store data read from slave, must be safe to use with DMA
* @count: How many bytes to read, must be less than 64k since msg.len is u16
*
* Returns negative errno, or else the number of bytes read.
*/
static inline int i2c_master_recv_dmasafe(const struct i2c_client *client,
char *buf, int count)
{
return i2c_transfer_buffer_flags(client, buf, count,
I2C_M_RD | I2C_M_DMA_SAFE);
};
/**
* i2c_master_send - issue a single I2C message in master transmit mode
* @client: Handle to slave device
* @buf: Data that will be written to the slave
* @count: How many bytes to write, must be less than 64k since msg.len is u16
*
* Returns negative errno, or else the number of bytes written.
*/
static inline int i2c_master_send(const struct i2c_client *client,
const char *buf, int count)
{
return i2c_transfer_buffer_flags(client, (char *)buf, count, 0);
};
/**
* i2c_master_send_dmasafe - issue a single I2C message in master transmit mode
* using a DMA safe buffer
* @client: Handle to slave device
Annotation
- Immediate include surface: `linux/acpi.h`, `linux/bits.h`, `linux/mod_devicetable.h`, `linux/device.h`, `linux/sched.h`, `linux/mutex.h`, `linux/regulator/consumer.h`, `linux/rtmutex.h`.
- Detected declarations: `struct i2c_msg`, `struct i2c_adapter`, `struct i2c_client`, `struct i2c_driver`, `struct i2c_device_identity`, `struct i2c_board_info`, `struct module`, `struct property_entry`, `struct i2c_device_identity`, `struct i2c_driver`.
- Atlas domain: Core OS / Core Kernel Interface.
- Implementation status: pattern 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.