Skip to content

Commit a467d60

Browse files
committed
drivers: firmware: scmi: add scmi_read_message for notification handling
Introduce scmi_read_message() to allow protocols to read the associated event payload when a P2A notification is received. This enables protocol drivers to process notification-specific data after the SCMI core dispatches the event. Signed-off-by: Yongxu Wang <[email protected]>
1 parent 8e3fee3 commit a467d60

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

drivers/firmware/scmi/core.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,28 @@ int scmi_send_message(struct scmi_protocol *proto, struct scmi_message *msg,
258258
}
259259
}
260260

261+
int scmi_read_message(struct scmi_protocol *proto, struct scmi_message *msg)
262+
{
263+
if (!proto->rx) {
264+
return -ENODEV;
265+
}
266+
267+
if (!proto->rx->ready) {
268+
return -EINVAL;
269+
}
270+
271+
/* read message from platform, such as notification event
272+
*
273+
* Unlike scmi_send_message, reading messages with scmi_read_message is not currently
274+
* required in the PRE_KERNEL stage. The interrupt-based logic is used here.
275+
*/
276+
if (k_is_pre_kernel()) {
277+
return -EINVAL;
278+
}
279+
280+
return scmi_transport_read_message(proto->transport, proto->rx, msg);
281+
}
282+
261283
static int scmi_core_protocol_setup(const struct device *transport)
262284
{
263285
int ret;

include/zephyr/drivers/firmware/scmi/protocol.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,4 +184,16 @@ int scmi_send_message(struct scmi_protocol *proto,
184184
struct scmi_message *msg, struct scmi_message *reply,
185185
bool use_polling);
186186

187+
/**
188+
* @brief Read an SCMI message
189+
*
190+
* Blocking function used to read an SCMI message over a given channel
191+
*
192+
* @param proto pointer to SCMI protocol
193+
* @param msg pointer to SCMI message to read
194+
*
195+
* @retval 0 if successful
196+
* @retval negative errno if failure
197+
*/
198+
int scmi_read_message(struct scmi_protocol *proto, struct scmi_message *msg);
187199
#endif /* _INCLUDE_ZEPHYR_DRIVERS_FIRMWARE_SCMI_PROTOCOL_H_ */

0 commit comments

Comments
 (0)