Zephyr API Documentation 4.2.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
67#define SF32LB_DMA_DT_INST_SPEC_GET(index) SF32LB_DMA_DT_SPEC_GET(DT_DRV_INST(index))
68
75#define SF32LB_DMA_DT_INST_SPEC_GET_BY_NAME(index, name) \
76 SF32LB_DMA_DT_SPEC_GET_BY_NAME(DT_DRV_INST(index), name)
77
86static inline bool sf32lb_dma_is_ready_dt(const struct sf32lb_dma_dt_spec *spec)
87{
88 return device_is_ready(spec->dev);
89}
90
101static inline void sf32lb_dma_config_init_dt(const struct sf32lb_dma_dt_spec *spec,
102 struct dma_config *config)
103{
104 config->dma_slot = spec->request;
105 config->channel_priority = FIELD_GET(SF32LB_DMA_PL_MSK, spec->config);
106}
107
118static inline int sf32lb_dma_config_dt(const struct sf32lb_dma_dt_spec *spec,
119 struct dma_config *config)
120{
121 return dma_config(spec->dev, spec->channel, config);
122}
123
132static inline int sf32lb_dma_start_dt(const struct sf32lb_dma_dt_spec *spec)
133{
134 return dma_start(spec->dev, spec->channel);
135}
136
145static inline int sf32lb_dma_stop_dt(const struct sf32lb_dma_dt_spec *spec)
146{
147 return dma_stop(spec->dev, spec->channel);
148}
149
161static inline int sf32lb_dma_reload_dt(const struct sf32lb_dma_dt_spec *spec, uintptr_t src,
162 uintptr_t dst, size_t size)
163{
164 return dma_reload(spec->dev, spec->channel, src, dst, size);
165}
166
176static inline int sf32lb_dma_get_status_dt(const struct sf32lb_dma_dt_spec *spec,
177 struct dma_status *status)
178{
179 return dma_get_status(spec->dev, spec->channel, status);
180}
181
183
184#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:678
int dma_stop(const struct device *dev, uint32_t channel)
Stops the DMA transfer and disables the channel.
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:421
static int dma_config(const struct device *dev, uint32_t channel, struct dma_config *config)
Configure individual channel for DMA transfer.
Definition dma.h:395
int dma_start(const struct device *dev, uint32_t channel)
Enables DMA channel and starts the transfer, the channel must be configured beforehand.
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:101
static int sf32lb_dma_start_dt(const struct sf32lb_dma_dt_spec *spec)
Start a DMA transfer from a DT spec.
Definition sf32lb.h:132
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:118
static bool sf32lb_dma_is_ready_dt(const struct sf32lb_dma_dt_spec *spec)
Check if the DMA controller is ready.
Definition sf32lb.h:86
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:176
static int sf32lb_dma_stop_dt(const struct sf32lb_dma_dt_spec *spec)
Stop a DMA transfer from a DT spec.
Definition sf32lb.h:145
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:161
#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:510
const void * config
Address of device instance config information.
Definition device.h:514
DMA configuration structure.
Definition dma.h:196
DMA runtime status structure.
Definition dma.h:274
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.