Jeremy Kerr | 3d36ee2 | 2019-05-30 11:15:37 +0800 | [diff] [blame] | 1 | /* SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later */ |
Jeremy Kerr | 672c885 | 2019-03-01 12:18:07 +0800 | [diff] [blame] | 2 | |
| 3 | #ifndef _LIBMCTP_ASTLPCL_H |
| 4 | #define _LIBMCTP_ASTLPCL_H |
| 5 | |
| 6 | #ifdef __cplusplus |
| 7 | extern "C" { |
| 8 | #endif |
| 9 | |
Jeremy Kerr | 8682ef2 | 2019-05-30 17:46:44 +0800 | [diff] [blame] | 10 | #include <libmctp.h> |
Jeremy Kerr | 672c885 | 2019-03-01 12:18:07 +0800 | [diff] [blame] | 11 | |
Andrew Jeffery | 7cd72f1 | 2020-05-12 20:27:59 +0930 | [diff] [blame] | 12 | #include <stdint.h> |
| 13 | |
Jeremy Kerr | 672c885 | 2019-03-01 12:18:07 +0800 | [diff] [blame] | 14 | struct mctp_binding_astlpc; |
| 15 | |
Andrew Jeffery | 7cd72f1 | 2020-05-12 20:27:59 +0930 | [diff] [blame] | 16 | /* todo: Remove enum from public interfaces */ |
Jeremy Kerr | bc53d35 | 2019-08-28 14:26:14 +0530 | [diff] [blame] | 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 { |
Andrew Jeffery | 0620b4c | 2021-03-09 21:50:31 +1030 | [diff] [blame] | 23 | int (*kcs_read)(void *data, enum mctp_binding_astlpc_kcs_reg reg, |
Jeremy Kerr | bc53d35 | 2019-08-28 14:26:14 +0530 | [diff] [blame] | 24 | uint8_t *val); |
Andrew Jeffery | 55fb90b | 2020-05-12 13:54:37 +0930 | [diff] [blame] | 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); |
Jeremy Kerr | bc53d35 | 2019-08-28 14:26:14 +0530 | [diff] [blame] | 29 | }; |
| 30 | |
Andrew Jeffery | 0af68f2 | 2022-09-30 14:26:28 +0930 | [diff] [blame] | 31 | #define MCTP_BINDING_ASTLPC_MODE_BMC 0 |
Andrew Jeffery | 7cd72f1 | 2020-05-12 20:27:59 +0930 | [diff] [blame] | 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); |
Andrew Jeffery | 4663f67 | 2020-03-10 23:36:24 +1030 | [diff] [blame] | 40 | void mctp_astlpc_destroy(struct mctp_binding_astlpc *astlpc); |
Jeremy Kerr | 3b36d17 | 2019-09-04 11:56:09 +0800 | [diff] [blame] | 41 | |
| 42 | struct mctp_binding *mctp_binding_astlpc_core(struct mctp_binding_astlpc *b); |
| 43 | |
Frederic Barrat | 4df106d | 2023-05-16 17:45:42 +0200 | [diff] [blame] | 44 | bool mctp_astlpc_tx_done(struct mctp_binding_astlpc *astlpc); |
Jeremy Kerr | 672c885 | 2019-03-01 12:18:07 +0800 | [diff] [blame] | 45 | int mctp_astlpc_poll(struct mctp_binding_astlpc *astlpc); |
| 46 | |
Jeremy Kerr | bc53d35 | 2019-08-28 14:26:14 +0530 | [diff] [blame] | 47 | /* fileio-based interface */ |
Konstantin Aladyshev | 400766f | 2023-09-07 15:57:25 +0300 | [diff] [blame] | 48 | struct mctp_binding_astlpc *mctp_astlpc_init_fileio(const char *kcs_path); |
Jeremy Kerr | bc53d35 | 2019-08-28 14:26:14 +0530 | [diff] [blame] | 49 | |
Andrew Jeffery | 1111c6a | 2022-07-25 20:44:39 +0930 | [diff] [blame] | 50 | struct pollfd; |
| 51 | int mctp_astlpc_init_pollfd(struct mctp_binding_astlpc *astlpc, |
| 52 | struct pollfd *pollfd); |
| 53 | |
Jeremy Kerr | 672c885 | 2019-03-01 12:18:07 +0800 | [diff] [blame] | 54 | #ifdef __cplusplus |
| 55 | } |
| 56 | #endif |
| 57 | |
Andrew Jeffery | 0ddd07e | 2020-05-25 19:53:34 +0930 | [diff] [blame] | 58 | #endif /* _LIBMCTP_ASTLPC_H */ |