Zephyr API Documentation 4.3.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
sf32lb.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2025 Core Devices LLC
3 * SPDX-License-Identifier: Apache-2.0
4 */
5
6#ifndef INCLUDE_ZEPHYR_DRIVERS_DMA_SF32LB_H_
7#define INCLUDE_ZEPHYR_DRIVERS_DMA_SF32LB_H_
8
9#include <stdint.h>
10
11#include <zephyr/device.h>
12#include <zephyr/devicetree.h>
13#include <zephyr/drivers/dma.h>
15#include <zephyr/sys/util.h>
16
23
35
41#define SF32LB_DMA_DT_SPEC_GET(node_id) \
42 { \
43 .dev = DEVICE_DT_GET(DT_DMAS_CTLR(node_id)), \
44 .channel = DT_DMAS_CELL_BY_IDX(node_id, 0, channel), \
45 .request = DT_DMAS_CELL_BY_IDX(node_id, 0, request), \
46 .config = DT_DMAS_CELL_BY_IDX(node_id, 0, config), \
47 }
48
54#define SF32LB_DMA_DT_SPEC_GET_BY_NAME(node_id, name) \
55 { \
56 .dev = DEVICE_DT_GET(DT_DMAS_CTLR_BY_NAME(node_id, name)), \
57 .channel = DT_DMAS_CELL_BY_NAME(node_id, name, channel), \
58 .request = DT_DMAS_CELL_BY_NAME(node_id, name, request), \
59 .config = DT_DMAS_CELL_BY_NAME(node_id, name, config), \
60 }
61
70#define SF32LB_DMA_DT_SPEC_GET_BY_NAME_OR(node_id, name, default_value) \
71 COND_CODE_1(DT_DMAS_HAS_NAME(node_id, name), \
72 (SF32LB_DMA_DT_SPEC_GET_BY_NAME(node_id, name)), (default_value))
73
79#define SF32LB_DMA_DT_INST_SPEC_GET(index) SF32LB_DMA_DT_SPEC_GET(DT_DRV_INST(index))
80
87#define SF32LB_DMA_DT_INST_SPEC_GET_BY_NAME(index, name) \
88 SF32LB_DMA_DT_SPEC_GET_BY_NAME(DT_DRV_INST(index), name)
89
97#define SF32LB_DMA_DT_INST_SPEC_GET_BY_NAME_OR(index, name, default_value) \
98 SF32LB_DMA_DT_SPEC_GET_BY_NAME_OR(DT_DRV_INST(index), name, default_value)
99
108static inline bool sf32lb_dma_is_ready_dt(const struct sf32lb_dma_dt_spec *spec)
109{
110 return device_is_ready(spec->dev);
111}
112
123static inline void sf32lb_dma_config_init_dt(const struct sf32lb_dma_dt_spec *spec,
124 struct dma_config *config)
125{
126 config->dma_slot = spec->request;
127 config->channel_priority = FIELD_GET(SF32LB_DMA_PL_MSK, spec->config);
128}
129
140static inline int sf32lb_dma_config_dt(const struct sf32lb_dma_dt_spec *spec,
141 struct dma_config *config)
142{
143 return dma_config(spec->dev, spec->channel, config);
144}
145
154static inline int sf32lb_dma_start_dt(const struct sf32lb_dma_dt_spec *spec)
155{
156 return dma_start(spec->dev, spec->channel);
157}
158
167static inline int sf32lb_dma_stop_dt(const struct sf32lb_dma_dt_spec *spec)
168{
169 return dma_stop(spec->dev, spec->channel);
170}
171
183static inline int sf32lb_dma_reload_dt(const struct sf32lb_dma_dt_spec *spec, uintptr_t src,
184 uintptr_t dst, size_t size)
185{
186 return dma_reload(spec->dev, spec->channel, src, dst, size);
187}
188
198static inline int sf32lb_dma_get_status_dt(const struct sf32lb_dma_dt_spec *spec,
199 struct dma_status *status)
200{
201 return dma_get_status(spec->dev, spec->channel, status);
202}
203
205
206#endif /* INCLUDE_ZEPHYR_DRIVERS_DMA_SF32LB_H_ */
Devicetree main header.
Main header file for DMA (Direct Memory Access) driver API.
bool device_is_ready(const struct device *dev)
Verify that a device is ready for use.
static int dma_get_status(const struct device *dev, uint32_t channel, struct dma_status *stat)
get current runtime status of DMA transfer
Definition dma.h:662
static int dma_reload(const struct device *dev, uint32_t channel, uint32_t src, uint32_t dst, size_t size)
Reload buffer(s) for a DMA channel.
Definition dma.h:425
static int dma_config(const struct device *dev, uint32_t channel, struct dma_config *config)
Configure individual channel for DMA transfer.
Definition dma.h:399
static int dma_start(const struct device *dev, uint32_t channel)
Enables DMA channel and starts the transfer, the channel must be configured beforehand.
Definition dma.h:458
static int dma_stop(const struct device *dev, uint32_t channel)
Stops the DMA transfer and disables the channel.
Definition dma.h:484
static void sf32lb_dma_config_init_dt(const struct sf32lb_dma_dt_spec *spec, struct dma_config *config)
Initialize a DMA configuration structure from a DT spec.
Definition sf32lb.h:123
static int sf32lb_dma_start_dt(const struct sf32lb_dma_dt_spec *spec)
Start a DMA transfer from a DT spec.
Definition sf32lb.h:154
static int sf32lb_dma_config_dt(const struct sf32lb_dma_dt_spec *spec, struct dma_config *config)
Configure a DMA channel from a DT spec.
Definition sf32lb.h:140
static bool sf32lb_dma_is_ready_dt(const struct sf32lb_dma_dt_spec *spec)
Check if the DMA controller is ready.
Definition sf32lb.h:108
static int sf32lb_dma_get_status_dt(const struct sf32lb_dma_dt_spec *spec, struct dma_status *status)
Get the status of a DMA transfer from a DT spec.
Definition sf32lb.h:198
static int sf32lb_dma_stop_dt(const struct sf32lb_dma_dt_spec *spec)
Stop a DMA transfer from a DT spec.
Definition sf32lb.h:167
static int sf32lb_dma_reload_dt(const struct sf32lb_dma_dt_spec *spec, uintptr_t src, uintptr_t dst, size_t size)
Reload a DMA transfer from a DT spec.
Definition sf32lb.h:183
#define SF32LB_DMA_PL_MSK
Definition sf32lb-dma-config.h:10
#define FIELD_GET(mask, value)
Definition silabs-pinctrl-siwx91x.h:14
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
__UINTPTR_TYPE__ uintptr_t
Definition stdint.h:105
Runtime device structure (in ROM) per driver instance.
Definition device.h:513
const void * config
Address of device instance config information.
Definition device.h:517
DMA configuration structure.
Definition dma.h:198
DMA runtime status structure.
Definition dma.h:278
SF32LB DMA DT spec.
Definition sf32lb.h:25
const struct device * dev
DMA controller.
Definition sf32lb.h:27
uint8_t channel
DMA channel.
Definition sf32lb.h:29
uint8_t config
DMA configuration.
Definition sf32lb.h:33
uint8_t request
DMA request.
Definition sf32lb.h:31
Misc utilities.