xref: /openbmc/libmctp/i2c-internal.h (revision d8f0c68bbf840bb8e94fb0534e673118cb1d460d)
1e5b941d9SMatt Johnston /* SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later */
2e5b941d9SMatt Johnston #pragma once
3e5b941d9SMatt Johnston 
4e5b941d9SMatt Johnston #include <assert.h>
5e5b941d9SMatt Johnston #include "libmctp.h"
6e5b941d9SMatt Johnston #include "libmctp-i2c.h"
7e5b941d9SMatt Johnston 
8e5b941d9SMatt Johnston /* Limited by bytecount field */
9*d8f0c68bSMatt Johnston static_assert(I2C_BTU <= 254, "I2C BTU is limited to 254");
10e5b941d9SMatt Johnston 
11e5b941d9SMatt Johnston #ifndef MCTP_I2C_NEIGH_COUNT
12e5b941d9SMatt Johnston #define MCTP_I2C_NEIGH_COUNT 4
13e5b941d9SMatt Johnston #endif
14e5b941d9SMatt Johnston 
15e5b941d9SMatt Johnston struct mctp_i2c_hdr {
16e5b941d9SMatt Johnston 	uint8_t dest;
17e5b941d9SMatt Johnston 	uint8_t cmd;
18e5b941d9SMatt Johnston 	uint8_t bytecount;
19e5b941d9SMatt Johnston 	uint8_t source;
20e5b941d9SMatt Johnston };
21e5b941d9SMatt Johnston 
22e5b941d9SMatt Johnston struct mctp_i2c_neigh {
23e5b941d9SMatt Johnston 	bool used;
24e5b941d9SMatt Johnston 	/* 7-bit address */
25e5b941d9SMatt Johnston 	uint8_t addr;
26e5b941d9SMatt Johnston 	uint8_t eid;
27e5b941d9SMatt Johnston 	/* from platform_now(), for LRU eviction */
28e5b941d9SMatt Johnston 	uint64_t last_seen_timestamp;
29e5b941d9SMatt Johnston };
30e5b941d9SMatt Johnston 
31e5b941d9SMatt Johnston struct mctp_binding_i2c {
32e5b941d9SMatt Johnston 	struct mctp_binding binding;
33e5b941d9SMatt Johnston 
34e5b941d9SMatt Johnston 	struct mctp_i2c_neigh neigh[MCTP_I2C_NEIGH_COUNT];
35e5b941d9SMatt Johnston 
36e5b941d9SMatt Johnston 	uint8_t own_addr;
37e5b941d9SMatt Johnston 
38a3830d25SMatt Johnston 	uint8_t tx_storage[MCTP_PKTBUF_SIZE(I2C_BTU)] PKTBUF_STORAGE_ALIGN;
39a3830d25SMatt Johnston 	uint8_t rx_storage[MCTP_PKTBUF_SIZE(I2C_BTU)] PKTBUF_STORAGE_ALIGN;
40e5b941d9SMatt Johnston 
41e5b941d9SMatt Johnston 	mctp_i2c_tx_fn tx_fn;
42e5b941d9SMatt Johnston 	void *tx_ctx;
43e5b941d9SMatt Johnston };
44