coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
i2c.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #ifndef _DEVICE_I2C_H_
4 #define _DEVICE_I2C_H_
5 
6 #include <stdint.h>
7 
8 /**
9  * struct i2c_msg - an I2C transaction segment beginning with START
10  * @addr: Slave address, either seven or ten bits. When this is a ten
11  * bit address, I2C_M_TEN must be set in @flags.
12  * @flags: I2C_M_RD is handled by all adapters.
13  * @len: Number of data bytes in @buf being read from or written to the
14  * I2C slave address. For read transactions where I2C_M_RECV_LEN
15  * is set, the caller guarantees that this buffer can hold up to
16  * 32 bytes in addition to the initial length byte sent by the
17  * slave (plus, if used, the SMBus PEC).
18  * @buf: The buffer into which data is read, or from which it's written.
19  *
20  * An i2c_msg is the low level representation of one segment of an I2C
21  * transaction. It is visible to drivers in the @i2c_transfer() procedure.
22  *
23  * All I2C adapters implement the standard rules for I2C transactions. Each
24  * transaction begins with a START. That is followed by the slave address,
25  * and a bit encoding read versus write. Then follow all the data bytes,
26  * possibly including a byte with SMBus PEC. The transfer terminates with
27  * a NAK, or when all those bytes have been transferred and ACKed. If this
28  * is the last message in a group, it is followed by a STOP. Otherwise it
29  * is followed by the next @i2c_msg transaction segment, beginning with a
30  * (repeated) START.
31  */
32 struct i2c_msg {
34 #define I2C_M_RD 0x0001 /* read data, from slave to master */
35 #define I2C_M_TEN 0x0010 /* this is a ten bit chip address */
36 #define I2C_M_RECV_LEN 0x0400 /* length will be first received byte */
37 #define I2C_M_NOSTART 0x4000 /* don't send a repeated START */
38  uint16_t slave; /* slave address */
39  uint16_t len; /* msg length */
40  uint8_t *buf; /* pointer to msg data */
41 };
42 
43 enum i2c_speed {
45  I2C_SPEED_FAST = 400000,
47  I2C_SPEED_HIGH = 3400000,
49 };
50 
54 };
55 
56 #endif /* _DEVICE_I2C_H_ */
i2c_speed
Definition: i2c.h:43
@ I2C_SPEED_FAST_ULTRA
Definition: i2c.h:48
@ I2C_SPEED_FAST_PLUS
Definition: i2c.h:46
@ I2C_SPEED_STANDARD
Definition: i2c.h:44
@ I2C_SPEED_HIGH
Definition: i2c.h:47
@ I2C_SPEED_FAST
Definition: i2c.h:45
i2c_address_mode
Definition: i2c.h:51
@ I2C_MODE_10_BIT
Definition: i2c.h:53
@ I2C_MODE_7_BIT
Definition: i2c.h:52
unsigned short uint16_t
Definition: stdint.h:11
unsigned char uint8_t
Definition: stdint.h:8
struct i2c_msg - an I2C transaction segment beginning with START @addr: Slave address,...
Definition: i2c.h:32
uint16_t len
Definition: i2c.h:39
uint16_t slave
Definition: i2c.h:38
uint16_t flags
Definition: i2c.h:33
uint8_t * buf
Definition: i2c.h:40