Skip to content

Commit 8e5c95e

Browse files
jerome-pouillerkartben
authored andcommitted
drivers: dma: siwx91x: Allow static allocation of DMA channel descriptors
Some instances of DMA (dma0) can use the normal sram to store their descriptors. In this case, it makes sense to allow the linker to allocate the memory rather than tweaking the memory layout. So, if the attribute silabs,sram-region is not defined, use a statically allocated buffer. Signed-off-by: Jérôme Pouiller <[email protected]>
1 parent 832a006 commit 8e5c95e

File tree

3 files changed

+11
-12
lines changed

3 files changed

+11
-12
lines changed

drivers/dma/dma_silabs_siwx91x.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -649,6 +649,10 @@ static DEVICE_API(dma, siwx91x_dma_api) = {
649649
static UDMA_Channel_Info dma_channel_info_##inst[DT_INST_PROP(inst, dma_channels)]; \
650650
SYS_MEM_BLOCKS_DEFINE_STATIC(desc_pool_##inst, sizeof(RSI_UDMA_DESC_T), \
651651
CONFIG_DMA_SILABS_SIWX91X_SG_BUFFER_COUNT, 4); \
652+
COND_CODE_1(DT_INST_NODE_HAS_PROP(inst, silabs_sram_region), \
653+
(), \
654+
(static __aligned(512) RSI_UDMA_DESC_T \
655+
siwx91x_dma_chan_desc##inst[DT_INST_PROP(inst, dma_channels) * 2];)) \
652656
static struct dma_siwx91x_channel_info \
653657
zephyr_channel_info_##inst[DT_INST_PROP(inst, dma_channels)]; \
654658
static struct dma_siwx91x_data dma_data_##inst = { \
@@ -670,7 +674,9 @@ static DEVICE_API(dma, siwx91x_dma_api) = {
670674
.clock_subsys = (clock_control_subsys_t)DT_INST_PHA(inst, clocks, clkid), \
671675
.reg = (UDMA0_Type *)DT_INST_REG_ADDR(inst), \
672676
.irq_number = DT_INST_PROP_BY_IDX(inst, interrupts, 0), \
673-
.sram_desc_addr = DT_REG_ADDR(DT_INST_PHANDLE(inst, silabs_sram_region)), \
677+
.sram_desc_addr = COND_CODE_1(DT_INST_NODE_HAS_PROP(inst, silabs_sram_region), \
678+
((RSI_UDMA_DESC_T *)DT_REG_ADDR(DT_INST_PHANDLE(inst, silabs_sram_region))), \
679+
(siwx91x_dma_chan_desc##inst)), \
674680
.irq_configure = siwx91x_dma_irq_configure_##inst, \
675681
}; \
676682
DEVICE_DT_INST_DEFINE(inst, &siwx91x_dma_init, NULL, &dma_data_##inst, &dma_cfg_##inst, \

dts/arm/silabs/siwg917.dtsi

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,6 @@
3232
reg = <0x00000000 DT_SIZE_K(191)>;
3333
};
3434

35-
sram_dma0: memory-dma@2fc00 {
36-
compatible = "zephyr,memory-region", "mmio-sram";
37-
reg = <0x0002fc00 DT_SIZE_K(1)>;
38-
zephyr,memory-region = "dma0";
39-
zephyr,memory-attr = <DT_MEM_ARM(ATTR_MPU_RAM_NOCACHE)>;
40-
};
41-
4235
sram_dma1: memory-dma@24061c00 {
4336
compatible = "zephyr,memory-region", "mmio-sram";
4437
reg = <0x24061c00 DT_SIZE_K(1)>;
@@ -259,7 +252,6 @@
259252
interrupts = <33 0>;
260253
interrupt-names = "dma0";
261254
clocks = <&clock0 SIWX91X_CLK_DMA0>;
262-
silabs,sram-region = <&sram_dma0>;
263255
#dma-cells = < 1>;
264256
dma-channels = <32>;
265257
status = "disabled";

dts/bindings/dma/silabs,siwx91x-dma.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@ properties:
1010

1111
silabs,sram-region:
1212
type: phandle
13-
required: true
1413
description: |
15-
SRAM Address for UDMA Descriptor Storage. This address must match to the
16-
location used by the hardware.
14+
SRAM Address for UDMA Descriptor Storage. Some instance require this
15+
buffer to be placed in a specific area. If the instance doesn't have
16+
this requirement, this attribute is not required and the memory will
17+
will be automatically allocated.
1718
1819
"#dma-cells":
1920
const: 1

0 commit comments

Comments
 (0)