xref: /openbmc/libmctp/libmctp-astlpc.h (revision d98b2b23)
1 /* SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later */
2 
3 #ifndef _LIBMCTP_ASTLPCL_H
4 #define _LIBMCTP_ASTLPCL_H
5 
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
9 
10 #include <libmctp.h>
11 
12 #include <stdint.h>
13 
14 struct mctp_binding_astlpc;
15 
16 /* todo: Remove enum from public interfaces */
17 enum mctp_binding_astlpc_kcs_reg {
18 	MCTP_ASTLPC_KCS_REG_DATA = 0,
19 	MCTP_ASTLPC_KCS_REG_STATUS = 1,
20 };
21 
22 struct mctp_binding_astlpc_ops {
23 	int	(*kcs_read)(void *data, enum mctp_binding_astlpc_kcs_reg reg,
24 			uint8_t *val);
25 	int (*kcs_write)(void *data, enum mctp_binding_astlpc_kcs_reg reg,
26 			 uint8_t val);
27 	int (*lpc_read)(void *data, void *buf, long offset, size_t len);
28 	int (*lpc_write)(void *data, const void *buf, long offset, size_t len);
29 };
30 
31 #define MCTP_BINDING_ASTLPC_MODE_BMC 0
32 #define MCTP_BINDING_ASTLPC_MODE_HOST 1
33 struct mctp_binding_astlpc *
34 mctp_astlpc_init(uint8_t mode, uint32_t mtu, void *lpc_map,
35 		 const struct mctp_binding_astlpc_ops *ops, void *ops_data);
36 
37 struct mctp_binding_astlpc *
38 mctp_astlpc_init_ops(const struct mctp_binding_astlpc_ops *ops, void *ops_data,
39 		     void *lpc_map);
40 void mctp_astlpc_destroy(struct mctp_binding_astlpc *astlpc);
41 
42 struct mctp_binding *mctp_binding_astlpc_core(struct mctp_binding_astlpc *b);
43 
44 int mctp_astlpc_poll(struct mctp_binding_astlpc *astlpc);
45 
46 /* fileio-based interface */
47 struct mctp_binding_astlpc *mctp_astlpc_init_fileio(void);
48 int mctp_astlpc_get_fd(struct mctp_binding_astlpc *astlpc);
49 
50 #ifdef __cplusplus
51 }
52 #endif
53 
54 #endif /* _LIBMCTP_ASTLPC_H */
55