Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

boards: nxp: rd_rw612_bga: enable DMA #70192

Merged
merged 3 commits into from Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions boards/nxp/rd_rw612_bga/doc/index.rst
Expand Up @@ -39,6 +39,8 @@ Supported Features
+-----------+------------+-----------------------------------+
| USART | on-chip | serial |
+-----------+------------+-----------------------------------+
| DMA | on-chip | dma |
+-----------+------------+-----------------------------------+
| SPI | on-chip | spi |
+-----------+------------+-----------------------------------+

Expand Down
4 changes: 4 additions & 0 deletions boards/nxp/rd_rw612_bga/rd_rw612_bga.dtsi
Expand Up @@ -100,3 +100,7 @@ arduino_spi: &flexcomm0 {
};
};
};

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to update the documentation to indicate this support

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the reminder- board doc page updated

&dma0 {
status = "okay";
};
1 change: 1 addition & 0 deletions boards/nxp/rd_rw612_bga/rd_rw612_bga.yaml
Expand Up @@ -15,5 +15,6 @@ toolchain:
ram: 960
flash: 65536
supported:
- dma
- gpio
- spi
32 changes: 32 additions & 0 deletions drivers/dma/dma_mcux_lpc.c
Expand Up @@ -114,6 +114,28 @@ static void dma_mcux_lpc_irq_handler(const struct device *dev)
#endif
}

#ifdef CONFIG_SOC_SERIES_RW6XX
static inline void rw6xx_dma_addr_fixup(struct dma_block_config *block)
{
/* RW6xx AHB design does not route DMA engine through FlexSPI CACHE.
* Therefore, to use DMA from the FlexSPI space we must adjust the
* source address to use the non cached FlexSPI region.
* FlexSPI cached region is at 0x800_0000 (nonsecure) or 0x1800_0000
* (secure). We move the address into non cached region, which is at
* 0x4800_0000 or 0x5800_000.
*/
if (((block->source_address & 0xF8000000) == 0x18000000) ||
((block->source_address & 0xF8000000) == 0x8000000)) {
block->source_address = block->source_address + 0x40000000;
}
if (((block->dest_address & 0xF8000000) == 0x18000000) ||
((block->dest_address & 0xF8000000) == 0x8000000)) {
block->dest_address = block->dest_address + 0x40000000;
}

}
#endif

static int dma_mcux_lpc_queue_descriptors(struct channel_data *data,
struct dma_block_config *block,
uint8_t src_inc,
Expand Down Expand Up @@ -228,6 +250,9 @@ static int dma_mcux_lpc_queue_descriptors(struct channel_data *data,
dest_inc,
MIN(local_block.block_size, max_xfer_bytes));

#ifdef CONFIG_SOC_SERIES_RW6XX
rw6xx_dma_addr_fixup(&local_block);
#endif
DMA_SetupDescriptor(data->curr_descriptor,
xfer_config,
(void *)local_block.source_address,
Expand Down Expand Up @@ -271,6 +296,9 @@ static int dma_mcux_lpc_queue_descriptors(struct channel_data *data,
MIN(local_block.block_size, max_xfer_bytes));
/* Mark this as invalid */
xfer_config &= ~DMA_CHANNEL_XFERCFG_CFGVALID_MASK;
#ifdef CONFIG_SOC_SERIES_RW6XX
rw6xx_dma_addr_fixup(&local_block);
#endif
DMA_SetupDescriptor(data->curr_descriptor,
xfer_config,
(void *)local_block.source_address,
Expand Down Expand Up @@ -586,6 +614,10 @@ static int dma_mcux_lpc_configure(const struct device *dev, uint32_t channel,
assert(block_config->source_address == ROUND_UP(block_config->source_address, width));
assert(block_config->dest_address == ROUND_UP(block_config->dest_address, width));

#ifdef CONFIG_SOC_SERIES_RW6XX
rw6xx_dma_addr_fixup(block_config);
#endif

DMA_SubmitChannelTransferParameter(p_handle,
xfer_config,
(void *)block_config->source_address,
Expand Down
9 changes: 9 additions & 0 deletions dts/arm/nxp/nxp_rw6xx_common.dtsi
Expand Up @@ -145,6 +145,15 @@
num-lines = <8>;
num-inputs = <64>;
};

dma0: dma-controller@104000 {
compatible = "nxp,lpc-dma";
reg = <0x104000 0x1000>;
interrupts = <1 0>;
status = "disabled";
#dma-cells = <1>;
dma-channels = <33>;
};
};

&flexspi {
Expand Down
7 changes: 7 additions & 0 deletions tests/drivers/dma/loop_transfer/boards/rd_rw612_bga.overlay
@@ -0,0 +1,7 @@
/*
* Copyright 2023-2024 NXP
*
* SPDX-License-Identifier: Apache-2.0
*/

tst_dma0: &dma0 { };