* [PATCH] cmd/dma: implement dmareset command
@ 2025-08-31 22:25 briansune
0 siblings, 0 replies; only message in thread
From: briansune @ 2025-08-31 22:25 UTC (permalink / raw)
To: u-boot; +Cc: briansune
Add dmareset command to release PL330 DMA channel resets.
Signed-off-by: briansune <briansune@gmail.com>
---
cmd/Kconfig | 7 +++++++
cmd/Makefile | 1 +
cmd/dma.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 60 insertions(+)
create mode 100644 cmd/dma.c
diff --git a/cmd/Kconfig b/cmd/Kconfig
index e55a48a49af..720e3121018 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -1149,6 +1149,13 @@ config CMD_DM
can be useful to see the state of driver model for debugging or
interest.
+config CMD_DMA
+ bool "dma - Release Reset DMA Channels for PL330 Handshake"
+ default y
+ help
+ Provides access to Reset Manager Per2ModRst. Enables DMA
+ channels for ARM PrimeCell PL330 via reset release.
+
config CMD_FASTBOOT
bool "fastboot - Android fastboot support"
depends on FASTBOOT
diff --git a/cmd/Makefile b/cmd/Makefile
index 082470fa104..748c53767b8 100644
--- a/cmd/Makefile
+++ b/cmd/Makefile
@@ -54,6 +54,7 @@ obj-$(CONFIG_CMD_CPU) += cpu.o
obj-$(CONFIG_CMD_DATE) += date.o
obj-$(CONFIG_CMD_DEMO) += demo.o
obj-$(CONFIG_CMD_DM) += dm.o
+obj-$(CONFIG_CMD_DMA) += dma.o
obj-$(CONFIG_CMD_UFETCH) += ufetch.o
obj-$(CONFIG_CMD_SOUND) += sound.o
ifdef CONFIG_POST
diff --git a/cmd/dma.c b/cmd/dma.c
new file mode 100644
index 00000000000..b35c2f32fcc
--- /dev/null
+++ b/cmd/dma.c
@@ -0,0 +1,52 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Brian Sune <briansune@gmail.com>
+ */
+
+#include <vsprintf.h>
+#include <command.h>
+#include <asm/io.h>
+
+#ifdef CONFIG_TARGET_SOCFPGA_GEN5
+#include <asm/arch/base_addr_ac5.h>
+#endif
+
+#define RSTMGR_PERMODRST 0x18 /* PERMODRST register offset */
+
+static int do_dmareset(struct cmd_tbl *cmdtp, int flag, int argc,
+ char * const argv[])
+{
+ u8 val;
+ int i, ch;
+
+ if (argc < 2) {
+ printf("Usage: dmareset <channel 0-7> [<channel 0-7> ...]\n");
+ return CMD_RET_USAGE;
+ }
+
+ /* Read current register value */
+ val = readb(SOCFPGA_RSTMGR_ADDRESS + RSTMGR_PERMODRST);
+
+ /* Iterate over all channels given as arguments */
+ for (i = 1; i < argc; i++) {
+ ch = simple_strtoul(argv[i], NULL, 0);
+ if (ch < 0 || ch > 7) {
+ printf("Error: channel must be 0-7\n");
+ return CMD_RET_USAGE;
+ }
+ val &= ~(1 << ch);
+ printf("PL330 DMA channel %d reset released\n", ch);
+ }
+
+ /* Write back */
+ writeb(val, (SOCFPGA_RSTMGR_ADDRESS + RSTMGR_PERMODRST));
+
+ return 0;
+}
+
+U_BOOT_CMD(
+ dmareset, 8, 0, do_dmareset,
+ "Release PL330 DMA channel reset(s)",
+ "dmareset <channel 0-7> [<channel 0-7> ...] - release reset for one or more DMA channels"
+);
+
--
2.47.1.windows.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2025-09-01 13:15 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-31 22:25 [PATCH] cmd/dma: implement dmareset command briansune
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).