blob: 110b998a00977e85f71d662db68f32007f55d9d1 [file] [log] [blame]
Jeremy Kerr3d36ee22019-05-30 11:15:37 +08001/* SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later */
Jeremy Kerr672c8852019-03-01 12:18:07 +08002
3#ifndef _LIBMCTP_ASTLPCL_H
4#define _LIBMCTP_ASTLPCL_H
5
6#ifdef __cplusplus
7extern "C" {
8#endif
9
Jeremy Kerr8682ef22019-05-30 17:46:44 +080010#include <libmctp.h>
Jeremy Kerr672c8852019-03-01 12:18:07 +080011
Andrew Jeffery7cd72f12020-05-12 20:27:59 +093012#include <stdint.h>
13
Jeremy Kerr672c8852019-03-01 12:18:07 +080014struct mctp_binding_astlpc;
15
Andrew Jeffery7cd72f12020-05-12 20:27:59 +093016/* todo: Remove enum from public interfaces */
Jeremy Kerrbc53d352019-08-28 14:26:14 +053017enum mctp_binding_astlpc_kcs_reg {
18 MCTP_ASTLPC_KCS_REG_DATA = 0,
19 MCTP_ASTLPC_KCS_REG_STATUS = 1,
20};
21
22struct mctp_binding_astlpc_ops {
Andrew Jeffery0620b4c2021-03-09 21:50:31 +103023 int (*kcs_read)(void *data, enum mctp_binding_astlpc_kcs_reg reg,
Jeremy Kerrbc53d352019-08-28 14:26:14 +053024 uint8_t *val);
Andrew Jeffery55fb90b2020-05-12 13:54:37 +093025 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);
Jeremy Kerrbc53d352019-08-28 14:26:14 +053029};
30
Andrew Jeffery0af68f22022-09-30 14:26:28 +093031#define MCTP_BINDING_ASTLPC_MODE_BMC 0
Andrew Jeffery7cd72f12020-05-12 20:27:59 +093032#define MCTP_BINDING_ASTLPC_MODE_HOST 1
33struct mctp_binding_astlpc *
34mctp_astlpc_init(uint8_t mode, uint32_t mtu, void *lpc_map,
35 const struct mctp_binding_astlpc_ops *ops, void *ops_data);
36
37struct mctp_binding_astlpc *
38mctp_astlpc_init_ops(const struct mctp_binding_astlpc_ops *ops, void *ops_data,
39 void *lpc_map);
Andrew Jeffery4663f672020-03-10 23:36:24 +103040void mctp_astlpc_destroy(struct mctp_binding_astlpc *astlpc);
Jeremy Kerr3b36d172019-09-04 11:56:09 +080041
42struct mctp_binding *mctp_binding_astlpc_core(struct mctp_binding_astlpc *b);
43
Frederic Barrat4df106d2023-05-16 17:45:42 +020044bool mctp_astlpc_tx_done(struct mctp_binding_astlpc *astlpc);
Jeremy Kerr672c8852019-03-01 12:18:07 +080045int mctp_astlpc_poll(struct mctp_binding_astlpc *astlpc);
46
Jeremy Kerrbc53d352019-08-28 14:26:14 +053047/* fileio-based interface */
48struct mctp_binding_astlpc *mctp_astlpc_init_fileio(void);
Jeremy Kerrbc53d352019-08-28 14:26:14 +053049
Andrew Jeffery1111c6a2022-07-25 20:44:39 +093050struct pollfd;
51int mctp_astlpc_init_pollfd(struct mctp_binding_astlpc *astlpc,
52 struct pollfd *pollfd);
53
Jeremy Kerr672c8852019-03-01 12:18:07 +080054#ifdef __cplusplus
55}
56#endif
57
Andrew Jeffery0ddd07e2020-05-25 19:53:34 +093058#endif /* _LIBMCTP_ASTLPC_H */