Zephyr API Documentation 4.4.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
regmap.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2025 STMicroelectronics
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
12
13#ifndef ZEPHYR_INCLUDE_RTIO_REGMAP_H_
14#define ZEPHYR_INCLUDE_RTIO_REGMAP_H_
15
16#include <zephyr/rtio/rtio.h>
17
18#ifdef __cplusplus
19extern "C" {
20#endif
21
42
54
60static inline bool rtio_is_spi(rtio_bus_type bus_type)
61{
62 return (bus_type == RTIO_BUS_SPI);
63}
64
70static inline bool rtio_is_i2c(rtio_bus_type bus_type)
71{
72 return (bus_type == RTIO_BUS_I2C);
73}
74
80static inline bool rtio_is_i3c(rtio_bus_type bus_type)
81{
82 return (bus_type == RTIO_BUS_I3C);
83}
84
119static inline void rtio_read_regs_async(struct rtio *r, struct rtio_iodev *iodev,
120 rtio_bus_type bus_type, struct rtio_regs *regs,
121 struct rtio_iodev_sqe *iodev_sqe, const struct device *dev,
122 rtio_callback_t complete_op_cb)
123{
124 struct rtio_sqe *write_addr;
125 struct rtio_sqe *read_reg;
126 struct rtio_sqe *complete_op;
127
128 for (uint8_t i = 0; i < regs->rtio_regs_num; i++) {
129
130 write_addr = rtio_sqe_acquire(r);
131 read_reg = rtio_sqe_acquire(r);
132
133 if (write_addr == NULL || read_reg == NULL) {
134 rtio_iodev_sqe_err(iodev_sqe, -ENOMEM);
136 return;
137 }
138
140 &regs->rtio_regs_list[i].reg_addr, 1, NULL);
141 write_addr->flags = RTIO_SQE_TRANSACTION;
142
144 regs->rtio_regs_list[i].len, NULL);
145 read_reg->flags = RTIO_SQE_CHAINED;
146
147 switch (bus_type) {
148 case RTIO_BUS_I2C:
150 break;
151 case RTIO_BUS_I3C:
153 break;
154 case RTIO_BUS_SPI:
155 default:
156 break;
157 }
158 }
159
160 complete_op = rtio_sqe_acquire(r);
161 if (complete_op == NULL) {
162 rtio_iodev_sqe_err(iodev_sqe, -ENOMEM);
164 return;
165 }
166
167 rtio_sqe_prep_callback_no_cqe(complete_op, complete_op_cb, (void *)dev, iodev_sqe);
168
169 rtio_submit(r, 0);
170}
171
172#ifdef __cplusplus
173}
174#endif
175
176#endif /* ZEPHYR_INCLUDE_RTIO_REGMAP_H_ */
#define RTIO_IODEV_I2C_RESTART
Equivalent to the I2C_MSG_RESTART flag.
Definition sqe.h:200
#define RTIO_IODEV_I2C_STOP
Equivalent to the I2C_MSG_STOP flag.
Definition sqe.h:195
#define RTIO_IODEV_I3C_STOP
Equivalent to the I3C_MSG_STOP flag.
Definition sqe.h:221
#define RTIO_IODEV_I3C_RESTART
Equivalent to the I3C_MSG_RESTART flag.
Definition sqe.h:226
#define RTIO_SQE_TRANSACTION
The next request in the queue is part of a transaction.
Definition sqe.h:94
#define RTIO_SQE_CHAINED
The next request in the queue should wait on this one.
Definition sqe.h:82
#define RTIO_PRIO_NORM
Normal priority.
Definition sqe.h:56
static void rtio_sqe_prep_tiny_write(struct rtio_sqe *sqe, const struct rtio_iodev *iodev, int8_t prio, const uint8_t *tiny_write_data, uint8_t tiny_write_len, void *userdata)
Prepare a tiny write op submission.
Definition sqe.h:528
void(* rtio_callback_t)(struct rtio *r, const struct rtio_sqe *sqe, int res, void *arg0)
Callback signature for RTIO_OP_CALLBACK.
Definition sqe.h:292
static void rtio_sqe_prep_read(struct rtio_sqe *sqe, const struct rtio_iodev *iodev, int8_t prio, uint8_t *buf, uint32_t len, void *userdata)
Prepare a read op submission.
Definition sqe.h:457
static struct rtio_sqe * rtio_sqe_acquire(struct rtio *r)
Acquire a single submission queue event if available.
Definition rtio.h:341
static void rtio_sqe_drop_all(struct rtio *r)
Drop all previously acquired sqe.
Definition rtio.h:407
static void rtio_iodev_sqe_err(struct rtio_iodev_sqe *iodev_sqe, int result)
Inform the executor of a submissions completion with error.
Definition rtio.h:680
static void rtio_sqe_prep_callback_no_cqe(struct rtio_sqe *sqe, rtio_callback_t callback, void *arg0, void *userdata)
Prepare a callback op submission that does not create a CQE.
Definition sqe.h:579
int rtio_submit(struct rtio *r, uint32_t wait_count)
Submit I/O requests to the underlying executor.
#define ENOMEM
Not enough core.
Definition errno.h:51
static void rtio_read_regs_async(struct rtio *r, struct rtio_iodev *iodev, rtio_bus_type bus_type, struct rtio_regs *regs, struct rtio_iodev_sqe *iodev_sqe, const struct device *dev, rtio_callback_t complete_op_cb)
Create a chain of SQEs representing a bus transaction to read a reg.
Definition regmap.h:119
rtio_bus_type
bus type
Definition regmap.h:49
@ RTIO_BUS_I2C
I2C bus.
Definition regmap.h:50
@ RTIO_BUS_I3C
I3C bus.
Definition regmap.h:52
@ RTIO_BUS_SPI
SPI bus.
Definition regmap.h:51
static bool rtio_is_i3c(rtio_bus_type bus_type)
check if bus is I3C
Definition regmap.h:80
static bool rtio_is_spi(rtio_bus_type bus_type)
check if bus is SPI
Definition regmap.h:60
static bool rtio_is_i2c(rtio_bus_type bus_type)
check if bus is I2C
Definition regmap.h:70
Real-Time IO device API for moving bytes with low effort.
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
Runtime device structure (in ROM) per driver instance.
Definition device.h:513
IO device submission queue entry.
Definition sqe.h:398
An IO device with a function table for submitting requests.
Definition iodev.h:49
Description of a single memory chunk.
Definition regmap.h:31
uint8_t * bufp
Valid pointer to a data buffer.
Definition regmap.h:36
size_t len
Length of the buffer in bytes.
Definition regmap.h:39
uint8_t reg_addr
Register address.
Definition regmap.h:33
A structure to describe a list of not-consecutive memory chunks for RTIO operations.
Definition regmap.h:26
size_t rtio_regs_num
Number of registers in the list.
Definition regmap.h:28
struct rtio_regs::rtio_regs_list * rtio_regs_list
Array of rtio_regs_num memory chunks.
A submission queue event.
Definition sqe.h:305
const struct rtio_iodev * iodev
Device to operation on.
Definition sqe.h:314
uint32_t iodev_flags
Op iodev flags.
Definition sqe.h:312
uint16_t flags
Op Flags.
Definition sqe.h:310
An RTIO context containing what can be viewed as a pair of queues.
Definition rtio.h:71