Zephyr API Documentation 3.7.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
target_device.h
Go to the documentation of this file.
1/*
2 * Copyright 2022 Intel Corporation
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7#ifndef ZEPHYR_INCLUDE_DRIVERS_I3C_TARGET_DEVICE_H_
8#define ZEPHYR_INCLUDE_DRIVERS_I3C_TARGET_DEVICE_H_
9
17#include <errno.h>
18#include <stddef.h>
19#include <stdint.h>
20
21#include <zephyr/device.h>
22#include <zephyr/sys/slist.h>
23
24#ifdef __cplusplus
25extern "C" {
26#endif
27
28struct i3c_driver_api;
29
82
109
127 int (*write_requested_cb)(struct i3c_target_config *config);
128
149 uint8_t val);
150
172 uint8_t *val);
173
195 uint8_t *val);
196
212 int (*stop_cb)(struct i3c_target_config *config);
213};
214
215__subsystem struct i3c_target_driver_api {
216 int (*driver_register)(const struct device *dev);
217 int (*driver_unregister)(const struct device *dev);
218};
219
244static inline int i3c_target_tx_write(const struct device *dev,
245 uint8_t *buf, uint16_t len, uint8_t hdr_mode)
246{
247 const struct i3c_driver_api *api =
248 (const struct i3c_driver_api *)dev->api;
249
250 if (api->target_tx_write == NULL) {
251 return -ENOSYS;
252 }
253
254 return api->target_tx_write(dev, buf, len, hdr_mode);
255}
256
280static inline int i3c_target_register(const struct device *dev,
281 struct i3c_target_config *cfg)
282{
283 const struct i3c_driver_api *api =
284 (const struct i3c_driver_api *)dev->api;
285
286 if (api->target_register == NULL) {
287 return -ENOSYS;
288 }
289
290 return api->target_register(dev, cfg);
291}
292
309static inline int i3c_target_unregister(const struct device *dev,
310 struct i3c_target_config *cfg)
311{
312 const struct i3c_driver_api *api =
313 (const struct i3c_driver_api *)dev->api;
314
315 if (api->target_unregister == NULL) {
316 return -ENOSYS;
317 }
318
319 return api->target_unregister(dev, cfg);
320}
321
322#ifdef __cplusplus
323}
324#endif
325
330#endif /* ZEPHYR_INCLUDE_DRIVERS_I3C_TARGET_DEVICE_H_ */
System error numbers.
static int i3c_target_unregister(const struct device *dev, struct i3c_target_config *cfg)
Unregisters the provided config as target device.
Definition target_device.h:309
static int i3c_target_register(const struct device *dev, struct i3c_target_config *cfg)
Registers the provided config as target device of a controller.
Definition target_device.h:280
static int i3c_target_tx_write(const struct device *dev, uint8_t *buf, uint16_t len, uint8_t hdr_mode)
Writes to the target's TX FIFO.
Definition target_device.h:244
struct _snode sys_snode_t
Single-linked list node structure.
Definition slist.h:39
#define ENOSYS
Function not implemented.
Definition errno.h:82
__UINT64_TYPE__ uint64_t
Definition stdint.h:91
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
__UINT16_TYPE__ uint16_t
Definition stdint.h:89
Runtime device structure (in ROM) per driver instance.
Definition device.h:403
const void * api
Address of the API structure exposed by the device instance.
Definition device.h:409
Configuration parameters for I3C hardware to act as target device.
Definition target_device.h:36
uint8_t bcr
Bus Characteristics Register (BCR).
Definition target_device.h:63
bool pid_random
True if lower 32-bit of Provisioned ID is random.
Definition target_device.h:60
uint16_t max_read_len
Maximum Read Length (MRL).
Definition target_device.h:69
uint64_t pid
Provisioned ID.
Definition target_device.h:52
uint8_t supported_hdr
Bit mask of supported HDR modes (0 - 7).
Definition target_device.h:80
uint8_t static_addr
I3C target address.
Definition target_device.h:49
bool enable
If the hardware is to act as a target device on the bus.
Definition target_device.h:41
uint16_t max_write_len
Maximum Write Length (MWL).
Definition target_device.h:72
uint8_t dcr
Device Characteristics Register (DCR).
Definition target_device.h:66
Definition target_device.h:110
int(* stop_cb)(struct i3c_target_config *config)
Function called when a stop condition is observed after a start condition addressed to a particular d...
Definition target_device.h:212
int(* write_received_cb)(struct i3c_target_config *config, uint8_t val)
Function called when a write to the device is continued.
Definition target_device.h:148
int(* read_requested_cb)(struct i3c_target_config *config, uint8_t *val)
Function called when a read from the device is initiated.
Definition target_device.h:171
int(* write_requested_cb)(struct i3c_target_config *config)
Function called when a write to the device is initiated.
Definition target_device.h:127
int(* read_processed_cb)(struct i3c_target_config *config, uint8_t *val)
Function called when a read from the device is continued.
Definition target_device.h:194
Structure describing a device that supports the I3C target API.
Definition target_device.h:94
const struct i3c_target_callbacks * callbacks
Callback functions.
Definition target_device.h:107
sys_snode_t node
Definition target_device.h:95
uint8_t address
Address for this target device.
Definition target_device.h:104
uint8_t flags
Flags for the target device defined by I3C_TARGET_FLAGS_* constants.
Definition target_device.h:101
Definition target_device.h:215
int(* driver_unregister)(const struct device *dev)
Definition target_device.h:217
int(* driver_register)(const struct device *dev)
Definition target_device.h:216