blob: b55da5e8ec5b4165a12afefeb356821ae9a41ceb [file] [log] [blame]
Andrew Jeffery4fe996c2018-02-27 12:16:48 +10301/* SPDX-License-Identifier: Apache-2.0 */
2/* Copyright (C) 2018 IBM Corp. */
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +11003
4#ifndef MBOXD_MSG_H
5#define MBOXD_MSG_H
6
Andrew Jeffery26558db2018-08-10 00:22:38 +09307#include <stdint.h>
8
9struct mbox_context;
10
11/* Command Values */
12#define MBOX_C_RESET_STATE 0x01
13#define MBOX_C_GET_MBOX_INFO 0x02
14#define MBOX_C_GET_FLASH_INFO 0x03
15#define MBOX_C_READ_WINDOW 0x04
16#define MBOX_C_CLOSE_WINDOW 0x05
17#define MBOX_C_WRITE_WINDOW 0x06
18#define MBOX_C_WRITE_DIRTY 0x07
19#define MBOX_C_WRITE_FLUSH 0x08
20#define MBOX_C_ACK 0x09
21#define MBOX_C_WRITE_ERASE 0x0a
22#define NUM_MBOX_CMDS MBOX_C_WRITE_ERASE
23
24/* Response Values */
25#define MBOX_R_SUCCESS 0x01
26#define MBOX_R_PARAM_ERROR 0x02
27#define MBOX_R_WRITE_ERROR 0x03
28#define MBOX_R_SYSTEM_ERROR 0x04
29#define MBOX_R_TIMEOUT 0x05
30#define MBOX_R_BUSY 0x06
31#define MBOX_R_WINDOW_ERROR 0x07
32#define MBOX_R_SEQ_ERROR 0x08
33
34/* MBOX Registers */
35#define MBOX_HOST_PATH "/dev/aspeed-mbox"
36#define MBOX_HOST_TIMEOUT_SEC 1
37#define MBOX_ARGS_BYTES 11
38#define MBOX_REG_BYTES 16
39#define MBOX_HOST_EVENT 14
40#define MBOX_BMC_EVENT 15
41
42struct mbox_msg {
43 uint8_t command;
44 uint8_t seq;
45 uint8_t args[MBOX_ARGS_BYTES];
46 uint8_t response;
47};
48
49union mbox_regs {
50 uint8_t raw[MBOX_REG_BYTES];
51 struct mbox_msg msg;
52};
Suraj Jitindar Singh5a3a0662017-04-27 11:55:26 +100053
Andrew Jefferyd86141b2018-08-09 14:58:53 +093054int transport_mbox_dispatch(struct mbox_context *context);
Andrew Jefferyb2466ee2018-08-09 15:03:27 +093055int transport_mbox_init(struct mbox_context *context);
Andrew Jeffery55260ce2018-08-09 15:05:59 +093056void transport_mbox_free(struct mbox_context *context);
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +110057
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +110058#endif /* MBOXD_MSG_H */