Zephyr API Documentation 4.4.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
42typedef void (*scmi_channel_cb)(struct scmi_channel *chan);
43
54 void *data;
69 struct k_mutex lock;
70
76 struct k_sem sem;
77
79 bool ready;
87};
88
110 int (*init)(const struct device *transport);
111
129 int (*send_message)(const struct device *transport,
130 struct scmi_channel *chan,
131 struct scmi_message *msg,
132 bool use_polling);
133
147 int (*setup_chan)(const struct device *transport,
148 struct scmi_channel *chan,
149 bool tx);
150
164 int (*read_message)(const struct device *transport,
165 struct scmi_channel *chan,
166 struct scmi_message *msg);
167
182 bool (*channel_is_free)(const struct device *transport,
183 struct scmi_channel *chan);
184
202 struct scmi_channel *(*request_channel)(const struct device *transport,
203 uint32_t proto, bool tx);
204};
205
207
211static inline struct scmi_channel *
212scmi_transport_request_channel(const struct device *transport,
213 uint32_t proto, bool tx)
214{
215 const struct scmi_transport_api *api =
216 (const struct scmi_transport_api *)transport->api;
217
218 if (api->request_channel) {
219 return api->request_channel(transport, proto, tx);
220 }
221
222 return NULL;
223}
224
228static inline int scmi_transport_init(const struct device *transport)
229{
230 const struct scmi_transport_api *api =
231 (const struct scmi_transport_api *)transport->api;
232
233 if (api->init) {
234 return api->init(transport);
235 }
236
237 return 0;
238}
239
243static inline int scmi_transport_setup_chan(const struct device *transport,
244 struct scmi_channel *chan,
245 bool tx)
246{
247 const struct scmi_transport_api *api =
248 (const struct scmi_transport_api *)transport->api;
249
250 if (!api || !api->setup_chan) {
251 return -ENOSYS;
252 }
253
254 return api->setup_chan(transport, chan, tx);
255}
256
260static inline int scmi_transport_send_message(const struct device *transport,
261 struct scmi_channel *chan,
262 struct scmi_message *msg,
263 bool use_polling)
264{
265 const struct scmi_transport_api *api =
266 (const struct scmi_transport_api *)transport->api;
267
268 if (!api || !api->send_message) {
269 return -ENOSYS;
270 }
271
272 return api->send_message(transport, chan, msg, use_polling);
273}
274
278static inline int scmi_transport_read_message(const struct device *transport,
279 struct scmi_channel *chan,
280 struct scmi_message *msg)
281{
282 const struct scmi_transport_api *api =
283 (const struct scmi_transport_api *)transport->api;
284
285 if (!api || !api->read_message) {
286 return -ENOSYS;
287 }
288
289 return api->read_message(transport, chan, msg);
290}
291
295static inline bool scmi_transport_channel_is_free(const struct device *transport,
296 struct scmi_channel *chan)
297{
298 const struct scmi_transport_api *api =
299 (const struct scmi_transport_api *)transport->api;
300
301 if (!api || !api->channel_is_free) {
302 return -ENOSYS;
303 }
304
305 return api->channel_is_free(transport, chan);
306}
307
317int scmi_core_transport_init(const struct device *transport);
318
320
324
325#endif /* _INCLUDE_ZEPHYR_DRIVERS_FIRMWARE_SCMI_TRANSPORT_H_ */
void(* scmi_channel_cb)(struct scmi_channel *chan)
Callback function for message replies.
Definition transport.h:42
#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
Kernel mutex structure.
Definition kernel.h:3437
Semaphore structure.
Definition kernel.h:3663
SCMI channel structure.
Definition transport.h:52
void * data
channel private data
Definition transport.h:54
scmi_channel_cb cb
callback function.
Definition transport.h:61
bool polling_only
indicates if the channel requires polling-only operation.
Definition transport.h:86
SCMI message structure.
Definition protocol.h:137
SCMI transport driver operations.
Definition transport.h:96
int(* init)(const struct device *transport)
Initialize the transport driver.
Definition transport.h:110
int(* setup_chan)(const struct device *transport, struct scmi_channel *chan, bool tx)
Prepare a channel for communication.
Definition transport.h:147
struct scmi_channel *(* request_channel)(const struct device *transport, uint32_t proto, bool tx)
Request a channel dynamically.
Definition transport.h:202
bool(* channel_is_free)(const struct device *transport, struct scmi_channel *chan)
Check if a TX channel is free.
Definition transport.h:182
int(* read_message)(const struct device *transport, struct scmi_channel *chan, struct scmi_message *msg)
Read a message from the platform.
Definition transport.h:164
int(* send_message)(const struct device *transport, struct scmi_channel *chan, struct scmi_message *msg, bool use_polling)
Send a message to the platform.
Definition transport.h:129