Zephyr Project API  3.2.0
A Scalable Open Source RTOS
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 <zephyr/device.h>
18#include <zephyr/kernel.h>
19#include <zephyr/types.h>
20#include <zephyr/sys/util.h>
21
22#ifdef __cplusplus
23extern "C" {
24#endif
25
26struct i3c_driver_api;
27
39 bool enable;
40
48
51
59
62
65
68
71
79};
80
95
101
104
107};
108
126 int (*write_requested_cb)(struct i3c_target_config *config);
127
148 uint8_t val);
149
171 uint8_t *val);
172
194 uint8_t *val);
195
211 int (*stop_cb)(struct i3c_target_config *config);
212};
213
215 int (*driver_register)(const struct device *dev);
216 int (*driver_unregister)(const struct device *dev);
217};
218
242static inline int i3c_target_register(const struct device *dev,
243 struct i3c_target_config *cfg)
244{
245 const struct i3c_driver_api *api =
246 (const struct i3c_driver_api *)dev->api;
247
248 if (api->target_register == NULL) {
249 return -ENOSYS;
250 }
251
252 return api->target_register(dev, cfg);
253}
254
271static inline int i3c_target_unregister(const struct device *dev,
272 struct i3c_target_config *cfg)
273{
274 const struct i3c_driver_api *api =
275 (const struct i3c_driver_api *)dev->api;
276
277 if (api->target_unregister == NULL) {
278 return -ENOSYS;
279 }
280
281 return api->target_unregister(dev, cfg);
282}
283
284#ifdef __cplusplus
285}
286#endif
287
292#endif /* ZEPHYR_INCLUDE_DRIVERS_I3C_TARGET_DEVICE_H_ */
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:271
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:242
#define ENOSYS
Definition: errno.h:83
Public kernel APIs.
struct _snode sys_snode_t
Definition: slist.h:33
__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:435
const void * api
Definition: device.h:441
Configuration parameters for I3C hardware to act as target device.
Definition: target_device.h:34
uint8_t bcr
Definition: target_device.h:61
bool pid_random
Definition: target_device.h:58
uint16_t max_read_len
Definition: target_device.h:67
uint64_t pid
Definition: target_device.h:50
uint8_t supported_hdr
Definition: target_device.h:78
uint8_t static_addr
Definition: target_device.h:47
bool enable
Definition: target_device.h:39
uint16_t max_write_len
Definition: target_device.h:70
uint8_t dcr
Definition: target_device.h:64
Definition: target_device.h:109
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:211
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:147
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:170
int(* write_requested_cb)(struct i3c_target_config *config)
Function called when a write to the device is initiated.
Definition: target_device.h:126
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:193
Structure describing a device that supports the I3C target API.
Definition: target_device.h:92
const struct i3c_target_callbacks * callbacks
Definition: target_device.h:106
sys_snode_t node
Definition: target_device.h:94
uint8_t address
Definition: target_device.h:103
uint8_t flags
Definition: target_device.h:100
Definition: target_device.h:214
int(* driver_unregister)(const struct device *dev)
Definition: target_device.h:216
int(* driver_register)(const struct device *dev)
Definition: target_device.h:215
Misc utilities.