Skip to content

Commit 42eff40

Browse files
jerome-pouillerdkalowsk
authored andcommitted
drivers: dma: siwx91x: Fix DMA_ADDR_ADJ_NO_CHANGE w/ memory source
GPDMA does not support DMA_ADDR_ADJ_NO_CHANGE with a memory buffer. This feature is required for the SPI driver. Hopefully, SPI driver is the only user of this feature. Therefore, this commit introduces a hack for SPI. When the user request an Rx transaction, rather than copying content of mosi_overrun parameter, it configures the DMA to fill the destination memory (with either 0s or 1s). Obviously, this only works if mosi_overrun is 0x00 or 0xFF. Hopefully, none will need any other value. Signed-off-by: Jérôme Pouiller <[email protected]>
1 parent b359d5d commit 42eff40

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

drivers/dma/dma_silabs_siwx91x_gpdma.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,22 @@ static int siwx91x_gpdma_desc_config(struct siwx19x_gpdma_data *data,
183183
}
184184
if (block->source_addr_adj == DMA_ADDR_ADJ_NO_CHANGE) {
185185
desc->chnlCtrlConfig.srcFifoMode = 1;
186+
/* HACK: GPDMA does not support DMA_ADDR_ADJ_NO_CHANGE with a memory buffer.
187+
* So, instead of transferring the real data, we fill the peripheral with 0s
188+
* or 1s. It should be sufficient for most of the SPI usages. We hope the
189+
* users won't need any values other than 0x00 of 0xFF.
190+
*/
191+
if (config->channel_direction == MEMORY_TO_PERIPHERAL) {
192+
desc->miscChnlCtrlConfig.memoryFillEn = 1;
193+
if (*(uint8_t *)block->source_address == 0xFF) {
194+
desc->miscChnlCtrlConfig.memoryOneFill = 1;
195+
} else if (*(uint8_t *)block->source_address == 0x00) {
196+
desc->miscChnlCtrlConfig.memoryOneFill = 0;
197+
} else {
198+
LOG_ERR("Only 0xFF and 0x00 are supported as input");
199+
goto free_desc;
200+
}
201+
}
186202
}
187203

188204

0 commit comments

Comments
 (0)