xref: /openbmc/libmctp/libmctp-i2c.h (revision e5b941d9)
1*e5b941d9SMatt Johnston #include <stdint.h>
2*e5b941d9SMatt Johnston 
3*e5b941d9SMatt Johnston #include "libmctp.h"
4*e5b941d9SMatt Johnston 
5*e5b941d9SMatt Johnston struct mctp_binding_i2c;
6*e5b941d9SMatt Johnston 
7*e5b941d9SMatt Johnston typedef int (*mctp_i2c_tx_fn)(const void *buf, size_t len, void *ctx);
8*e5b941d9SMatt Johnston 
9*e5b941d9SMatt Johnston /* Configures the i2c binding. */
10*e5b941d9SMatt Johnston int mctp_i2c_setup(struct mctp_binding_i2c *i2c, uint8_t own_addr,
11*e5b941d9SMatt Johnston 		   mctp_i2c_tx_fn tx_fn, void *tx_ctx);
12*e5b941d9SMatt Johnston void mctp_i2c_cleanup(struct mctp_binding_i2c *i2c);
13*e5b941d9SMatt Johnston 
14*e5b941d9SMatt Johnston int mctp_i2c_set_address(struct mctp_binding_i2c *i2c, uint8_t own_addr);
15*e5b941d9SMatt Johnston 
16*e5b941d9SMatt Johnston struct mctp_binding *mctp_binding_i2c_core(struct mctp_binding_i2c *i2c);
17*e5b941d9SMatt Johnston 
18*e5b941d9SMatt Johnston int mctp_i2c_set_neighbour(struct mctp_binding_i2c *i2c, uint8_t eid,
19*e5b941d9SMatt Johnston 			   uint8_t addr);
20*e5b941d9SMatt Johnston 
21*e5b941d9SMatt Johnston void mctp_i2c_rx(struct mctp_binding_i2c *i2c, const void *data, size_t len);
22*e5b941d9SMatt Johnston int mctp_i2c_parse_hdr(const void *data, size_t len, uint8_t *src_addr,
23*e5b941d9SMatt Johnston 		       uint8_t *dest_addr, uint8_t *bytecount);
24*e5b941d9SMatt Johnston void mctp_i2c_tx_poll(struct mctp_binding_i2c *i2c);
25*e5b941d9SMatt Johnston 
26*e5b941d9SMatt Johnston /* Can be customised if needed */
27*e5b941d9SMatt Johnston #ifndef I2C_BTU
28*e5b941d9SMatt Johnston #define I2C_BTU MCTP_BTU
29*e5b941d9SMatt Johnston #endif
30*e5b941d9SMatt Johnston 
31*e5b941d9SMatt Johnston #define MCTP_I2C_PACKET_SIZE (MCTP_PACKET_SIZE(I2C_BTU) + 4)
32