Skip to content

Commit b1ec724

Browse files
smalaefabiobaltieri
authored andcommitted
drivers: dma: siwx917: Use accessors for HW reg access
Replaced direct hardware register access with appropriate accessors Signed-off-by: Sai Santhosh Malae <Santhosh.Malae@silabs.com>
1 parent a550157 commit b1ec724

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

drivers/dma/dma_silabs_siwx91x.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <errno.h>
88
#include <zephyr/irq.h>
99
#include <zephyr/sys/util.h>
10+
#include <zephyr/sys/sys_io.h>
1011
#include <zephyr/device.h>
1112
#include <zephyr/drivers/dma.h>
1213
#include <zephyr/drivers/clock_control.h>
@@ -269,7 +270,7 @@ static int dma_siwx91x_start(const struct device *dev, uint32_t channel)
269270
if (udma_table[channel].vsUDMAChaConfigData1.srcInc != UDMA_SRC_INC_NONE &&
270271
udma_table[channel].vsUDMAChaConfigData1.dstInc != UDMA_DST_INC_NONE) {
271272
/* Apply software trigger to start transfer */
272-
cfg->reg->CHNL_SW_REQUEST |= BIT(channel);
273+
sys_set_bit((mem_addr_t)&cfg->reg->CHNL_SW_REQUEST, channel);
273274
}
274275
return 0;
275276
}
@@ -303,11 +304,7 @@ static int dma_siwx91x_get_status(const struct device *dev, uint32_t channel,
303304
return -EINVAL;
304305
}
305306
/* Read the channel status register */
306-
if (cfg->reg->CHANNEL_STATUS_REG & BIT(channel)) {
307-
stat->busy = 1;
308-
} else {
309-
stat->busy = 0;
310-
}
307+
stat->busy = sys_test_bit((mem_addr_t)&cfg->reg->CHANNEL_STATUS_REG, channel);
311308

312309
/* Obtain the transfer direction from channel descriptors */
313310
if (udma_table[channel].vsUDMAChaConfigData1.srcInc == UDMA_SRC_INC_NONE) {
@@ -379,7 +376,7 @@ static void dma_siwx91x_isr(const struct device *dev)
379376
/* Transfer complete, call user callback */
380377
data->dma_callback(dev, data->cb_data, channel, 0);
381378
}
382-
cfg->reg->UDMA_DONE_STATUS_REG = BIT(channel);
379+
sys_write32(BIT(channel), (mem_addr_t)&cfg->reg->UDMA_DONE_STATUS_REG);
383380
} else {
384381
/* Call UDMA ROM IRQ handler. */
385382
ROMAPI_UDMA_WRAPPER_API->uDMAx_IRQHandler(&udma_resources, udma_resources.desc,
@@ -388,7 +385,7 @@ static void dma_siwx91x_isr(const struct device *dev)
388385
if (udma_resources.desc[channel].vsUDMAChaConfigData1.srcInc != UDMA_SRC_INC_NONE &&
389386
udma_resources.desc[channel].vsUDMAChaConfigData1.dstInc != UDMA_DST_INC_NONE) {
390387
/* Set the software trigger bit for starting next transfer */
391-
cfg->reg->CHNL_SW_REQUEST |= BIT(channel);
388+
sys_set_bit((mem_addr_t)&cfg->reg->CHNL_SW_REQUEST, channel);
392389
}
393390
}
394391
out:

0 commit comments

Comments
 (0)