Google is committed to advancing racial equity for Black communities. See how.

fuchsia.hardware.i2c

PROTOCOLS

Device

Defined in fuchsia.hardware.i2c/i2c.fidl

SubordinateTransfer

Send and receive data on the I2C device.

Request

NameType
in vector<uint8>[8196]

Response

NameType
s zx/status
out vector<uint8>[8196]

Device2

Defined in fuchsia.hardware.i2c/i2c.fidl

Transfer

Write and read segments of data for a particular I2C device.

The segments_is_write vector specifies the type (write or read) of each segment. The write_segments_data vector of segments specifies the data to write for each write segment. Each segment itself is a vector of uint8s, so write_segments_data is a vector of vectors of uint8s. The read_segments_length vector specifies the length of the read segments. If there is no error, read_segments_data returns a vector of segments, with each segment data itself returned in vectors.

For a simple I2C read, for instance 2 bytes write followed by one byte read, segments_is_write would be a vector with 2 elements: true, false and write_segments_data would be a vector with 1 element including the 2 bytes address of the read. Upon success read_segments_data would return a vector with one element, the byte read.

Request

NameType
segments_is_write vector<bool>[8]
write_segments_data vector<vector<uint8>>[8]
read_segments_length vector<uint8>[8]

Response

NameType
result Device2_Transfer_Result

I2c

Defined in fuchsia.hardware.i2c/i2c.fidl

GetInterrupt

Request

NameType
flags uint32

Response

NameType
s zx/status
irq handle<interrupt>

GetMaxTransferSize

Returns the maximum transfer size for read and write operations on the channel.

Request

NameType

Response

NameType
s zx/status
size uint64

Transact

Writes and reads data on an i2c channel. Up to I2C_MAX_RW_OPS operations can be passed in with a maximum of I2C_MAX_TOTAL_TRANSFER total bytes transfered. For write ops, i2c_op_t.data points to data to write. The data to write does not need to be kept alive after this call. For read ops, i2c_op_t.data is ignored. Any combination of reads and writes can be specified. At least the last op must have the stop flag set. The results of the operations are returned asynchronously via the transact_cb. The cookie parameter can be used to pass your own private data to the transact_cb callback.

Request

NameType
op vector<I2cOp>

Response

NameType
status zx/status
op vector<I2cOp>

STRUCTS

Device2_Transfer_Response

Defined in fuchsia.hardware.i2c/i2c.fidl

NameTypeDescriptionDefault
read_segments_data vector<vector<uint8>>[8] No default

I2cOp

Defined in fuchsia.hardware.i2c/i2c.fidl

See Transact below for usage.

NameTypeDescriptionDefault
data vector<uint8> No default
is_read bool No default
stop bool No default

Segment

Defined in fuchsia.hardware.i2c/i2c.fidl

Segment header for a serialized SubordinateTransfer. TODO(fxbug.dev/32864): Avoid requiring serialization and have SubordinateTransfer take an argument of vector<Segment>:MAX_SEGMENTS instead once we have better support in the C bindings or for C++.

NameTypeDescriptionDefault
type uint32 No default
len uint32 No default

ENUMS

SegmentType strict

Type: uint32

Defined in fuchsia.hardware.i2c/i2c.fidl

NameValueDescription
END 1

Flags the end of a serialized list of segments.

READ 2

Segment to be read from the I2C device.

WRITE 3

Segment to be written to the I2C device.

TABLES

I2CBusMetadata

Defined in fuchsia.hardware.i2c/i2c.fidl

Passed to the i2c driver in metadata as DEVICE_METADATA_I2C_CHANNELS.

OrdinalNameTypeDescription
1 channels vector<I2CChannel>[128]

I2CChannel

Defined in fuchsia.hardware.i2c/i2c.fidl

Used to inform the i2c driver about an attached i2c device.

OrdinalNameTypeDescription
1 bus_id uint32

ID of the bus that this device is on.

2 address uint16

Adress of the device.

3 i2c_class uint32

Class of the device. TODO(fxbug.dev/78198): remove this once x86 uses ACPI properly.

4 vid uint32

Vendor ID. Used when binding via platform bus device IDs.

5 pid uint32

Product ID. Used when binding via platform bus device IDs.

6 did uint32

Device ID. Used when binding via platform bus device IDs.

7 is_bus_controller bool

Are we in charge of the bus?

8 is_ten_bit bool

Is this device using 10-bit addressing mode (if false, use 7-bit).

9 bus_speed uint32

Speed of the bus.

UNIONS

Device2_Transfer_Result strict

Defined in fuchsia.hardware.i2c/i2c.fidl

NameTypeDescription
response Device2_Transfer_Response
err zx/status

CONSTANTS

NameValueTypeDescription
I2C_10_BIT_ADDR_MASK 61440 uint32
I2C_MAX_RW_OPS 8 uint32
I2C_MAX_TOTAL_TRANSFER 4096 uint32
MAX_COUNT_SEGMENTS 8 uint32
MAX_I2C_CHANNEL 128 uint32
MAX_TRANSFER_SIZE 8196 uint32