Zephyr Project API 4.4.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
16
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
90
105
123 int (*write_requested_cb)(struct i3c_target_config *config);
124
145 uint8_t val);
146
168 uint8_t *val);
169
191 uint8_t *val);
192
193#if defined(CONFIG_I3C_TARGET_BUFFER_MODE) || defined(__DOXYGEN__)
209 void (*buf_write_received_cb)(struct i3c_target_config *config, uint8_t *ptr, uint32_t len);
210
237 int (*buf_read_requested_cb)(struct i3c_target_config *config, uint8_t **ptr, uint32_t *len,
238 uint8_t *hdr_mode);
239#endif /* CONFIG_I3C_TARGET_BUFFER_MODE */
240
256 int (*stop_cb)(struct i3c_target_config *config);
257
273};
274
275__subsystem struct i3c_target_driver_api {
276 int (*driver_register)(const struct device *dev);
277 int (*driver_unregister)(const struct device *dev);
278};
279
292static inline int i3c_target_controller_handoff(const struct device *dev,
293 bool accept)
294{
295 const struct i3c_driver_api *api = DEVICE_API_GET(i3c, dev);
296
297 if (api->target_controller_handoff == NULL) {
298 return -ENOSYS;
299 }
300
301 return api->target_controller_handoff(dev, accept);
302}
303
328static inline int i3c_target_tx_write(const struct device *dev,
329 uint8_t *buf, uint16_t len, uint8_t hdr_mode)
330{
331 const struct i3c_driver_api *api = DEVICE_API_GET(i3c, dev);
332
333 if (api->target_tx_write == NULL) {
334 return -ENOSYS;
335 }
336
337 return api->target_tx_write(dev, buf, len, hdr_mode);
338}
339
362static inline int i3c_target_register(const struct device *dev,
363 struct i3c_target_config *cfg)
364{
365 const struct i3c_driver_api *api = DEVICE_API_GET(i3c, dev);
366
367 if (api->target_register == NULL) {
368 return -ENOSYS;
369 }
370
371 return api->target_register(dev, cfg);
372}
373
390static inline int i3c_target_unregister(const struct device *dev,
391 struct i3c_target_config *cfg)
392{
393 const struct i3c_driver_api *api = DEVICE_API_GET(i3c, dev);
394
395 if (api->target_unregister == NULL) {
396 return -ENOSYS;
397 }
398
399 return api->target_unregister(dev, cfg);
400}
401
402#ifdef __cplusplus
403}
404#endif
405
409
410#endif /* ZEPHYR_INCLUDE_DRIVERS_I3C_TARGET_DEVICE_H_ */
#define DEVICE_API_GET(_class, _dev)
Expands to the pointer of a device's API for a given class.
Definition device.h:1449
System error numbers.
static int i3c_target_controller_handoff(const struct device *dev, bool accept)
Accept or Decline Controller Handoffs.
Definition target_device.h:292
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:390
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:362
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:328
#define ENOSYS
Function not implemented.
Definition errno.h:83
#define NULL
Definition iar_missing_defs.h:20
int accept(int sock, struct sockaddr *addr, socklen_t *addrlen)
Header file for the single-linked list API.
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
__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:513
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:74
bool enabled
If the hardware is currently acting as a target device on the bus.
Definition target_device.h:41
bool pid_random
True if lower 32-bit of Provisioned ID is random.
Definition target_device.h:71
uint16_t max_read_len
Maximum Read Length (MRL).
Definition target_device.h:80
uint64_t pid
Provisioned ID.
Definition target_device.h:63
uint8_t supported_hdr
Bit mask of supported HDR modes (0 - 7).
Definition target_device.h:88
uint8_t dynamic_addr
I3C target dynamic address.
Definition target_device.h:52
uint8_t static_addr
I3C target static address.
Definition target_device.h:60
uint16_t max_write_len
Maximum Write Length (MWL).
Definition target_device.h:83
uint8_t dcr
Device Characteristics Register (DCR).
Definition target_device.h:77
Definition target_device.h:106
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:256
int(* controller_handoff_cb)(struct i3c_target_config *config)
Function called when an active controller handoffs controlership to this target.
Definition target_device.h:272
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:144
int(* buf_read_requested_cb)(struct i3c_target_config *config, uint8_t **ptr, uint32_t *len, uint8_t *hdr_mode)
Function called when a read from the device is initiated.
Definition target_device.h:237
void(* buf_write_received_cb)(struct i3c_target_config *config, uint8_t *ptr, uint32_t len)
Function called when a write to the device is completed.
Definition target_device.h:209
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:167
int(* write_requested_cb)(struct i3c_target_config *config)
Function called when a write to the device is initiated.
Definition target_device.h:123
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:190
Structure describing a device that supports the I3C target API.
Definition target_device.h:101
const struct i3c_target_callbacks * callbacks
Callback functions.
Definition target_device.h:103
Definition target_device.h:275
int(* driver_unregister)(const struct device *dev)
Definition target_device.h:277
int(* driver_register)(const struct device *dev)
Definition target_device.h:276