xref: /linux/drivers/misc/issei/hw_msg.h (revision 93e4b3076b5f2d853462b9777d083c77fc0b7b23)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* Copyright (C) 2023-2026 Intel Corporation */
3 #ifndef _ISSEI_HW_MSG_H_
4 #define _ISSEI_HW_MSG_H_
5 
6 #include <linux/types.h>
7 #include <linux/uuid.h>
8 
9 #define HAM_CB_MESSAGE_ID_REQ	0x8086cafe
10 #define HAM_CB_MESSAGE_ID_RES	0xcafe8086
11 #define HAM_CB_MESSAGE_VER	0x1
12 
13 /**
14  * struct ham_setup_shared_memory_req - shared memory setup request
15  * @msg_id: message id, should be %HAM_CB_MESSAGE_ID_REQ
16  * @ver: message version (%HAM_CB_MESSAGE_VER)
17  * @reserved: reserved
18  * @buffer_physical_address: physical address of DMA buffer
19  * @host_to_fw_section_length: memory size for host to fw communication
20  * @fw_to_host_section_length: memory size for fw to host communication
21  * @control_length: memory size for control buffer
22  */
23 struct ham_setup_shared_memory_req {
24 	u32 msg_id;
25 	u16 ver;
26 	u16 reserved;
27 	u64 buffer_physical_address;
28 	u32 host_to_fw_section_length;
29 	u32 fw_to_host_section_length;
30 	u32 control_length;
31 } __packed __aligned(4);
32 
33 /**
34  * struct ham_setup_shared_memory_res - shared memory setup response
35  * @msg_id: message id, should be %HAM_CB_MESSAGE_ID_RES
36  * @status: operation status
37  */
38 struct ham_setup_shared_memory_res {
39 	u32 msg_id;
40 	u32 status;
41 };
42 
43 /**
44  * struct control_buffer - control buffer structure
45  * @h2f_counter_wr: write counter host to fw
46  * @h2f_counter_rd: read counter host to fw
47  * @f2h_counter_wr: write counter fw to host
48  * @f2h_counter_rd: read counter fw to host
49  */
50 struct control_buffer {
51 	u32 h2f_counter_wr;
52 	u32 h2f_counter_rd;
53 	u32 f2h_counter_wr;
54 	u32 f2h_counter_rd;
55 };
56 
57 /* HAM messages over DMA */
58 
59 /**
60  * struct ham_message_header - message header over DMA
61  * @length: message length (payload only, not including header)
62  * @fw_id: firmware client id (0 means Bus Message)
63  * @host_id: host client id (0 means Bus Message)
64  * @flags: message flags
65  * @status: operation status
66  * @reserved: reserved
67  */
68 struct ham_message_header {
69 	u32 length;
70 	u16 fw_id;
71 	u16 host_id;
72 	u32 flags;
73 	u32 status;
74 	u32 reserved;
75 };
76 
77 /* Bus Commands */
78 #define HAM_BUS_CMD_START_REQ 0x00
79 #define HAM_BUS_CMD_START_RSP 0x80
80 #define HAM_BUS_CMD_CLIENT_REQ 0x01
81 #define HAM_BUS_CMD_CLIENT_RSP 0x81
82 
83 /**
84  * struct ham_bus_message - bus message header
85  * @cmd: command code
86  */
87 struct ham_bus_message {
88 	u32 cmd;
89 };
90 
91 #define HAM_SUPPORTED_VERSION 0x01
92 
93 /**
94  * struct ham_start_message_req - start message
95  * @header: bus message header (%HAM_BUS_CMD_START_REQ)
96  * @supported_version: supported protocol version
97  * @heci_capabilities_length: protocol capabilities length in bytes
98  * @heci_capabilities: protocol capabilities data
99  */
100 struct ham_start_message_req {
101 	struct ham_bus_message header;
102 	u16 supported_version;
103 	u8 heci_capabilities_length;
104 	u8 heci_capabilities[] __counted_by(heci_capabilities_length);
105 } __packed;
106 
107 /**
108  * struct ham_start_message_res - start message response
109  * @header: bus message header (%HAM_BUS_CMD_START_RSP)
110  * @fw_version: firmware version (four u16 blocks)
111  * @supported_version: supported protocol version
112  * @heci_capabilities_length: protocol capabilities length in bytes
113  * @heci_capabilities: protocol capabilities data
114  */
115 struct ham_start_message_res {
116 	struct ham_bus_message header;
117 	u16 fw_version[4];
118 	u16 supported_version;
119 	u8 heci_capabilities_length;
120 	u8 heci_capabilities[] __counted_by(heci_capabilities_length);
121 } __packed;
122 
123 /**
124  * struct ham_get_clients_req - clients list request
125  * @header: bus message header (%HAM_BUS_CMD_CLIENT_REQ)
126  */
127 struct ham_get_clients_req {
128 	struct ham_bus_message header;
129 };
130 
131 /**
132  * struct ham_client_properties - single client properties
133  * @client_number: client id in firmware
134  * @protocol_ver: client protocol version
135  * @reserved: reserved
136  * @client_uuid: protocol name (UUID)
137  * @client_mtu: max message length supported by client
138  * @flags: client flags
139  */
140 struct ham_client_properties {
141 	u16 client_number;
142 	u8 protocol_ver;
143 	u8 reserved;
144 	uuid_t client_uuid;
145 	u32 client_mtu;
146 	u32 flags;
147 };
148 
149 /**
150  * struct ham_get_clients_res - client properties response
151  * @header: bus message header (%HAM_BUS_CMD_CLIENT_RSP)
152  * @client_count: number of clients in firmware
153  * @reserved: reserved
154  * @clients_props: list of client properties
155  */
156 struct ham_get_clients_res {
157 	struct ham_bus_message header;
158 	u16 client_count;
159 	u16 reserved;
160 	struct ham_client_properties clients_props[] __counted_by(client_count);
161 };
162 
163 #endif /* _ISSEI_HW_MSG_H_ */
164