Zephyr Project API 4.4.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
protocol.h
Go to the documentation of this file.
1/*
2 * Copyright 2024,2026 NXP
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
12
13#ifndef _INCLUDE_ZEPHYR_DRIVERS_FIRMWARE_SCMI_PROTOCOL_H_
14#define _INCLUDE_ZEPHYR_DRIVERS_FIRMWARE_SCMI_PROTOCOL_H_
15
22
23#include <zephyr/device.h>
25#include <stdint.h>
26#include <errno.h>
27
29#define SCMI_SHORT_NAME_MAX_SIZE 16
30
47#define SCMI_MESSAGE_HDR_MAKE(id, type, proto, token) \
48 (SCMI_FIELD_MAKE(id, GENMASK(7, 0), 0) | SCMI_FIELD_MAKE(type, GENMASK(1, 0), 8) | \
49 SCMI_FIELD_MAKE(proto, GENMASK(7, 0), 10) | SCMI_FIELD_MAKE(token, GENMASK(9, 0), 18))
50
54#define SCMI_MESSAGE_HDR_TAKE_MSGID(hdr) FIELD_GET(GENMASK(7, 0), (hdr))
55
59#define SCMI_MESSAGE_HDR_TAKE_TYPE(hdr) FIELD_GET(GENMASK(9, 8), (hdr))
60
64#define SCMI_MESSAGE_HDR_TAKE_PROTOCOL(hdr) FIELD_GET(GENMASK(17, 10), (hdr))
65
69#define SCMI_MESSAGE_HDR_TAKE_TOKEN(hdr) FIELD_GET(GENMASK(27, 18), (hdr))
70
71struct scmi_channel;
72
84
114
136
149typedef void (*scmi_protocol_event_callback)(struct scmi_protocol *proto, uint32_t msg_id);
150
164
177 union {
180 struct {
185 };
186 };
187};
188
202
210int scmi_status_to_errno(int scmi_status);
211
232int scmi_send_message(struct scmi_protocol *proto, struct scmi_message *msg,
233 struct scmi_message *reply, bool use_polling);
234
244
254
265 uint32_t *attributes);
266
276
286int scmi_read_message(struct scmi_protocol *proto, struct scmi_message *msg);
287
291
297
298#endif /* _INCLUDE_ZEPHYR_DRIVERS_FIRMWARE_SCMI_PROTOCOL_H_ */
Header file for SCMI Utility Macros.
System error numbers.
scmi_message_type
SCMI message type.
Definition protocol.h:76
int scmi_protocol_message_attributes_get(struct scmi_protocol *proto, uint32_t message_id, uint32_t *attributes)
Get protocol message attributes.
scmi_status_code
SCMI status codes.
Definition protocol.h:88
void(* scmi_protocol_event_callback)(struct scmi_protocol *proto, uint32_t msg_id)
Per‑protocol notification callback invoked by the SCMI core.
Definition protocol.h:149
int scmi_protocol_get_version(struct scmi_protocol *proto, uint32_t *version)
Get protocol version.
int scmi_protocol_attributes_get(struct scmi_protocol *proto, uint32_t *attributes)
Get protocol attributes.
int scmi_send_message(struct scmi_protocol *proto, struct scmi_message *msg, struct scmi_message *reply, bool use_polling)
Send an SCMI message and wait for its reply.
int scmi_read_message(struct scmi_protocol *proto, struct scmi_message *msg)
Read SCMI notification or delayed reply.
int scmi_protocol_version_negotiate(struct scmi_protocol *proto, uint32_t version)
Negotiate protocol version.
int scmi_status_to_errno(int scmi_status)
Convert an SCMI status code to its Linux equivalent (if possible).
@ SCMI_NOTIFICATION
Notification message.
Definition protocol.h:82
@ SCMI_DELAYED_REPLY
Delayed reply message.
Definition protocol.h:80
@ SCMI_COMMAND
Command message.
Definition protocol.h:78
@ SCMI_SUCCESS
Successful completion.
Definition protocol.h:90
@ SCMI_INVALID_PARAMETERS
One or more parameters are invalid.
Definition protocol.h:94
@ SCMI_BUSY
The platform is busy and cannot service the command.
Definition protocol.h:102
@ SCMI_GENERIC_ERROR
An unspecified error occurred.
Definition protocol.h:106
@ SCMI_HARDWARE_ERROR
A hardware error occurred.
Definition protocol.h:108
@ SCMI_OUT_OF_RANGE
A parameter or value is out of the supported range.
Definition protocol.h:100
@ SCMI_PROTOCOL_ERROR
A protocol error (e.g.
Definition protocol.h:110
@ SCMI_NOT_FOUND
The entity referenced by the command was not found.
Definition protocol.h:98
@ SCMI_DENIED
The caller is not permitted to perform the operation.
Definition protocol.h:96
@ SCMI_IN_USE
The resource is already in use.
Definition protocol.h:112
@ SCMI_NOT_SUPPORTED
The command is not supported.
Definition protocol.h:92
@ SCMI_COMMS_ERROR
A communication error occurred.
Definition protocol.h:104
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
__UINT16_TYPE__ uint16_t
Definition stdint.h:89
Runtime device structure (in ROM) per driver instance.
Definition device.h:513
SCMI channel structure.
Definition transport.h:53
SCMI message structure.
Definition protocol.h:194
uint32_t hdr
Message header (see SCMI_MESSAGE_HDR_MAKE).
Definition protocol.h:196
uint32_t len
Size in bytes of the data pointed to by content.
Definition protocol.h:198
void * content
Pointer to the message payload (parameters or return values).
Definition protocol.h:200
SCMI protocol events structure.
Definition protocol.h:156
uint32_t num_events
Number of supported protocol notifications.
Definition protocol.h:160
scmi_protocol_event_callback cb
protocol notification callback
Definition protocol.h:162
const uint32_t * evts
Supported notification message IDs.
Definition protocol.h:158
SCMI protocol version.
Definition protocol.h:175
uint16_t major
Major protocol revision.
Definition protocol.h:184
uint16_t minor
Minor protocol revision.
Definition protocol.h:182
uint32_t raw
Raw 32-bit protocol version value.
Definition protocol.h:179
SCMI protocol structure.
Definition protocol.h:120
const struct scmi_protocol_events * events
protocol events
Definition protocol.h:134
struct scmi_channel * rx
RX channel.
Definition protocol.h:126
uint32_t version
Protocol supported version.
Definition protocol.h:132
const struct device * transport
Transport layer device.
Definition protocol.h:128
struct scmi_channel * tx
TX channel.
Definition protocol.h:124
void * data
Protocol private data.
Definition protocol.h:130
uint32_t id
Protocol ID.
Definition protocol.h:122