Skip to content

Commit 22d1f76

Browse files
committed
firmware: arm_scmi: Add mechanism to unpack message headers
In order to identify the message type when a response arrives, we need a mechanism to unpack the message header similar to packing. Let's add one. Signed-off-by: Sudeep Holla <[email protected]>
1 parent 38c927f commit 22d1f76

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

drivers/firmware/arm_scmi/driver.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,14 @@
3030
#include "common.h"
3131

3232
#define MSG_ID_MASK GENMASK(7, 0)
33+
#define MSG_XTRACT_ID(hdr) FIELD_GET(MSG_ID_MASK, (hdr))
3334
#define MSG_TYPE_MASK GENMASK(9, 8)
35+
#define MSG_XTRACT_TYPE(hdr) FIELD_GET(MSG_TYPE_MASK, (hdr))
36+
#define MSG_TYPE_COMMAND 0
37+
#define MSG_TYPE_DELAYED_RESP 2
38+
#define MSG_TYPE_NOTIFICATION 3
3439
#define MSG_PROTOCOL_ID_MASK GENMASK(17, 10)
40+
#define MSG_XTRACT_PROT_ID(hdr) FIELD_GET(MSG_PROTOCOL_ID_MASK, (hdr))
3541
#define MSG_TOKEN_ID_MASK GENMASK(27, 18)
3642
#define MSG_XTRACT_TOKEN(hdr) FIELD_GET(MSG_TOKEN_ID_MASK, (hdr))
3743
#define MSG_TOKEN_MAX (MSG_XTRACT_TOKEN(MSG_TOKEN_ID_MASK) + 1)
@@ -214,6 +220,18 @@ static inline u32 pack_scmi_header(struct scmi_msg_hdr *hdr)
214220
FIELD_PREP(MSG_PROTOCOL_ID_MASK, hdr->protocol_id);
215221
}
216222

223+
/**
224+
* unpack_scmi_header() - unpacks and records message and protocol id
225+
*
226+
* @msg_hdr: 32-bit packed message header sent from the platform
227+
* @hdr: pointer to header to fetch message and protocol id.
228+
*/
229+
static inline void unpack_scmi_header(u32 msg_hdr, struct scmi_msg_hdr *hdr)
230+
{
231+
hdr->id = MSG_XTRACT_ID(msg_hdr);
232+
hdr->protocol_id = MSG_XTRACT_PROT_ID(msg_hdr);
233+
}
234+
217235
/**
218236
* scmi_tx_prepare() - mailbox client callback to prepare for the transfer
219237
*

0 commit comments

Comments
 (0)