Andrew Jeffery | 4fe996c | 2018-02-27 12:16:48 +1030 | [diff] [blame] | 1 | /* SPDX-License-Identifier: Apache-2.0 */ |
| 2 | /* Copyright (C) 2018 IBM Corp. */ |
Suraj Jitindar Singh | e39c916 | 2017-03-28 10:47:43 +1100 | [diff] [blame] | 3 | |
| 4 | #ifndef MBOXD_MSG_H |
| 5 | #define MBOXD_MSG_H |
| 6 | |
Andrew Jeffery | 26558db | 2018-08-10 00:22:38 +0930 | [diff] [blame] | 7 | #include <stdint.h> |
| 8 | |
| 9 | struct mbox_context; |
Andrew Jeffery | fe0c9e8 | 2018-11-01 14:02:17 +1030 | [diff] [blame] | 10 | struct transport_ops; |
Andrew Jeffery | 26558db | 2018-08-10 00:22:38 +0930 | [diff] [blame] | 11 | |
| 12 | /* Command Values */ |
| 13 | #define MBOX_C_RESET_STATE 0x01 |
| 14 | #define MBOX_C_GET_MBOX_INFO 0x02 |
| 15 | #define MBOX_C_GET_FLASH_INFO 0x03 |
| 16 | #define MBOX_C_READ_WINDOW 0x04 |
| 17 | #define MBOX_C_CLOSE_WINDOW 0x05 |
| 18 | #define MBOX_C_WRITE_WINDOW 0x06 |
| 19 | #define MBOX_C_WRITE_DIRTY 0x07 |
| 20 | #define MBOX_C_WRITE_FLUSH 0x08 |
| 21 | #define MBOX_C_ACK 0x09 |
| 22 | #define MBOX_C_WRITE_ERASE 0x0a |
| 23 | #define NUM_MBOX_CMDS MBOX_C_WRITE_ERASE |
| 24 | |
| 25 | /* Response Values */ |
| 26 | #define MBOX_R_SUCCESS 0x01 |
| 27 | #define MBOX_R_PARAM_ERROR 0x02 |
| 28 | #define MBOX_R_WRITE_ERROR 0x03 |
| 29 | #define MBOX_R_SYSTEM_ERROR 0x04 |
| 30 | #define MBOX_R_TIMEOUT 0x05 |
| 31 | #define MBOX_R_BUSY 0x06 |
| 32 | #define MBOX_R_WINDOW_ERROR 0x07 |
| 33 | #define MBOX_R_SEQ_ERROR 0x08 |
| 34 | |
| 35 | /* MBOX Registers */ |
| 36 | #define MBOX_HOST_PATH "/dev/aspeed-mbox" |
| 37 | #define MBOX_HOST_TIMEOUT_SEC 1 |
| 38 | #define MBOX_ARGS_BYTES 11 |
| 39 | #define MBOX_REG_BYTES 16 |
| 40 | #define MBOX_HOST_EVENT 14 |
| 41 | #define MBOX_BMC_EVENT 15 |
| 42 | |
| 43 | struct mbox_msg { |
| 44 | uint8_t command; |
| 45 | uint8_t seq; |
| 46 | uint8_t args[MBOX_ARGS_BYTES]; |
| 47 | uint8_t response; |
| 48 | }; |
| 49 | |
| 50 | union mbox_regs { |
| 51 | uint8_t raw[MBOX_REG_BYTES]; |
| 52 | struct mbox_msg msg; |
| 53 | }; |
Suraj Jitindar Singh | 5a3a066 | 2017-04-27 11:55:26 +1000 | [diff] [blame] | 54 | |
Andrew Jeffery | d86141b | 2018-08-09 14:58:53 +0930 | [diff] [blame] | 55 | int transport_mbox_dispatch(struct mbox_context *context); |
Andrew Jeffery | fe0c9e8 | 2018-11-01 14:02:17 +1030 | [diff] [blame] | 56 | int transport_mbox_init(struct mbox_context *context, |
| 57 | const struct transport_ops **ops); |
Andrew Jeffery | 55260ce | 2018-08-09 15:05:59 +0930 | [diff] [blame] | 58 | void transport_mbox_free(struct mbox_context *context); |
Suraj Jitindar Singh | e39c916 | 2017-03-28 10:47:43 +1100 | [diff] [blame] | 59 | |
Suraj Jitindar Singh | e39c916 | 2017-03-28 10:47:43 +1100 | [diff] [blame] | 60 | #endif /* MBOXD_MSG_H */ |