Zephyr API Documentation 4.3.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
transport.h
Go to the documentation of this file.
1/*
2 * Copyright 2024 NXP
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
12
13#ifndef _INCLUDE_ZEPHYR_DRIVERS_FIRMWARE_SCMI_TRANSPORT_H_
14#define _INCLUDE_ZEPHYR_DRIVERS_FIRMWARE_SCMI_TRANSPORT_H_
15
16#include <zephyr/device.h>
17#include <zephyr/kernel.h>
18
25
26struct scmi_message;
27struct scmi_channel;
28
43typedef void (*scmi_channel_cb)(struct scmi_channel *chan);
44
55 void *data;
70 struct k_mutex lock;
71
77 struct k_sem sem;
78
80 bool ready;
82};
83
105 int (*init)(const struct device *transport);
106
119 int (*send_message)(const struct device *transport,
120 struct scmi_channel *chan,
121 struct scmi_message *msg);
122
136 int (*setup_chan)(const struct device *transport,
137 struct scmi_channel *chan,
138 bool tx);
139
153 int (*read_message)(const struct device *transport,
154 struct scmi_channel *chan,
155 struct scmi_message *msg);
156
171 bool (*channel_is_free)(const struct device *transport,
172 struct scmi_channel *chan);
173
191 struct scmi_channel *(*request_channel)(const struct device *transport,
192 uint32_t proto, bool tx);
193};
194
196
200static inline struct scmi_channel *
201scmi_transport_request_channel(const struct device *transport,
202 uint32_t proto, bool tx)
203{
204 const struct scmi_transport_api *api =
205 (const struct scmi_transport_api *)transport->api;
206
207 if (api->request_channel) {
208 return api->request_channel(transport, proto, tx);
209 }
210
211 return NULL;
212}
213
217static inline int scmi_transport_init(const struct device *transport)
218{
219 const struct scmi_transport_api *api =
220 (const struct scmi_transport_api *)transport->api;
221
222 if (api->init) {
223 return api->init(transport);
224 }
225
226 return 0;
227}
228
232static inline int scmi_transport_setup_chan(const struct device *transport,
233 struct scmi_channel *chan,
234 bool tx)
235{
236 const struct scmi_transport_api *api =
237 (const struct scmi_transport_api *)transport->api;
238
239 if (!api || !api->setup_chan) {
240 return -ENOSYS;
241 }
242
243 return api->setup_chan(transport, chan, tx);
244}
245
249static inline int scmi_transport_send_message(const struct device *transport,
250 struct scmi_channel *chan,
251 struct scmi_message *msg)
252{
253 const struct scmi_transport_api *api =
254 (const struct scmi_transport_api *)transport->api;
255
256 if (!api || !api->send_message) {
257 return -ENOSYS;
258 }
259
260 return api->send_message(transport, chan, msg);
261}
262
266static inline int scmi_transport_read_message(const struct device *transport,
267 struct scmi_channel *chan,
268 struct scmi_message *msg)
269{
270 const struct scmi_transport_api *api =
271 (const struct scmi_transport_api *)transport->api;
272
273 if (!api || !api->read_message) {
274 return -ENOSYS;
275 }
276
277 return api->read_message(transport, chan, msg);
278}
279
283static inline bool scmi_transport_channel_is_free(const struct device *transport,
284 struct scmi_channel *chan)
285{
286 const struct scmi_transport_api *api =
287 (const struct scmi_transport_api *)transport->api;
288
289 if (!api || !api->channel_is_free) {
290 return -ENOSYS;
291 }
292
293 return api->channel_is_free(transport, chan);
294}
295
305int scmi_core_transport_init(const struct device *transport);
306
308
312
313#endif /* _INCLUDE_ZEPHYR_DRIVERS_FIRMWARE_SCMI_TRANSPORT_H_ */
void(* scmi_channel_cb)(struct scmi_channel *chan)
Callback function for message replies.
Definition transport.h:43
#define ENOSYS
Function not implemented.
Definition errno.h:82
#define NULL
Definition iar_missing_defs.h:20
Public kernel APIs.
#define bool
Definition stdbool.h:13
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
Runtime device structure (in ROM) per driver instance.
Definition device.h:513
const void * api
Address of the API structure exposed by the device instance.
Definition device.h:519
Mutex Structure.
Definition kernel.h:3402
Semaphore structure.
Definition kernel.h:3607
SCMI channel structure.
Definition transport.h:53
void * data
channel private data
Definition transport.h:55
scmi_channel_cb cb
callback function.
Definition transport.h:62
SCMI message structure.
Definition protocol.h:110
SCMI transport driver operations.
Definition transport.h:91
int(* init)(const struct device *transport)
Initialize the transport driver.
Definition transport.h:105
int(* setup_chan)(const struct device *transport, struct scmi_channel *chan, bool tx)
Prepare a channel for communication.
Definition transport.h:136
struct scmi_channel *(* request_channel)(const struct device *transport, uint32_t proto, bool tx)
Request a channel dynamically.
Definition transport.h:191
bool(* channel_is_free)(const struct device *transport, struct scmi_channel *chan)
Check if a TX channel is free.
Definition transport.h:171
int(* send_message)(const struct device *transport, struct scmi_channel *chan, struct scmi_message *msg)
Send a message to the platform.
Definition transport.h:119
int(* read_message)(const struct device *transport, struct scmi_channel *chan, struct scmi_message *msg)
Read a message from the platform.
Definition transport.h:153