All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] cmd/dma: fix generic naming, spacing, and Dependencies
@ 2025-09-13 16:39 briansune
  2025-09-23 11:47 ` Quentin Schulz
  2025-09-23 18:12 ` [PATCH v2] cmd/dma: implement dmareset command briansune
  0 siblings, 2 replies; 7+ messages in thread
From: briansune @ 2025-09-13 16:39 UTC (permalink / raw)
  To: u-boot; +Cc: trini, briansune

This adds a new U-Boot command 'c5_pl330_dma' for Cyclone V SoCDK
boards. It provides access to the Reset Manager's Per2ModRst register
to release the reset for ARM PrimeCell PL330 DMA channels. This allows
software to initialize and use the PL330 DMA controller properly after
reset.

Signed-off-by: briansune <briansune@gmail.com>
---
 cmd/4913           |  0
 cmd/5036           |  0
 cmd/Kconfig        |  9 +++++++++
 cmd/Makefile       |  1 +
 cmd/c5_pl330_dma.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 60 insertions(+)
 create mode 100644 cmd/4913
 create mode 100644 cmd/5036
 create mode 100644 cmd/c5_pl330_dma.c

diff --git a/cmd/4913 b/cmd/4913
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/cmd/5036 b/cmd/5036
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/cmd/Kconfig b/cmd/Kconfig
index 29de857ba7c..75c388d19da 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -1791,6 +1791,15 @@ endmenu
 
 menu "Shell scripting commands"
 
+if TARGET_SOCFPGA_CYCLONE5_SOCDK
+
+config CMD_C5_PL330_DMA
+	bool "Release Reset DMA Channels for PL330 Handshake"
+	help
+	  Provides access to Reset Manager Per2ModRst. Enables DMA
+	  channels for ARM PrimeCell PL330 via reset release.
+endif
+
 config CMD_CAT
 	bool "cat"
 	help
diff --git a/cmd/Makefile b/cmd/Makefile
index 36e79cc3c28..d16e6fae20a 100644
--- a/cmd/Makefile
+++ b/cmd/Makefile
@@ -42,6 +42,7 @@ obj-$(CONFIG_CMD_BOOTI) += booti.o
 obj-$(CONFIG_CMD_BTRFS) += btrfs.o
 obj-$(CONFIG_CMD_BUTTON) += button.o
 obj-$(CONFIG_CMD_CAT) += cat.o
+obj-$(CONFIG_CMD_C5_PL330_DMA) += c5_pl330_dma.o
 obj-$(CONFIG_CMD_CACHE) += cache.o
 obj-$(CONFIG_CMD_CBFS) += cbfs.o
 obj-$(CONFIG_CMD_CEDIT) += cedit.o
diff --git a/cmd/c5_pl330_dma.c b/cmd/c5_pl330_dma.c
new file mode 100644
index 00000000000..5267ea2bd44
--- /dev/null
+++ b/cmd/c5_pl330_dma.c
@@ -0,0 +1,50 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Brian Sune <briansune@gmail.com>
+ */
+
+#include <vsprintf.h>
+#include <command.h>
+#include <asm/io.h>
+
+#include <asm/arch/base_addr_ac5.h>
+
+#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) for SoCFPGA",
+	"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] 7+ messages in thread

* Re: [PATCH] cmd/dma: fix generic naming, spacing, and Dependencies
  2025-09-13 16:39 [PATCH] cmd/dma: fix generic naming, spacing, and Dependencies briansune
@ 2025-09-23 11:47 ` Quentin Schulz
  2025-09-23 18:12 ` [PATCH v2] cmd/dma: implement dmareset command briansune
  1 sibling, 0 replies; 7+ messages in thread
From: Quentin Schulz @ 2025-09-23 11:47 UTC (permalink / raw)
  To: briansune, u-boot; +Cc: trini

Hi Brian,


The git commit title doesn't seem related to the actual content of the 
patch?

On 9/13/25 6:39 PM, briansune wrote:
> [You don't often get email from briansune@gmail.com. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
> 
> This adds a new U-Boot command 'c5_pl330_dma' for Cyclone V SoCDK
> boards. It provides access to the Reset Manager's Per2ModRst register
> to release the reset for ARM PrimeCell PL330 DMA channels. This allows
> software to initialize and use the PL330 DMA controller properly after
> reset.

Isn't this something that should be done by boards directly (i.e. 
somewhere in board/ directory) or at the SoC/arch level (i.e. arch/arm 
or arch/arm/mach-socfpga) or handle that in a DMA driver (I assume 
there's none now looking at drivers/dma/)? Essentially the question is 
"why do we need this as a command?".

> 
> Signed-off-by: briansune <briansune@gmail.com>

Needs to be Brian Sune here (same for the commit author which you can 
change with git commit --amend --author="Brian Sune 
<briansune@gmail.com>" if I remember correctly).

> ---
>   cmd/4913           |  0
>   cmd/5036           |  0

We don't need those files I assume?

Cheers,
Quentin

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v2] cmd/dma: implement dmareset command
  2025-09-13 16:39 [PATCH] cmd/dma: fix generic naming, spacing, and Dependencies briansune
  2025-09-23 11:47 ` Quentin Schulz
@ 2025-09-23 18:12 ` briansune
  2025-10-08  4:22   ` Tom Rini
  1 sibling, 1 reply; 7+ messages in thread
From: briansune @ 2025-09-23 18:12 UTC (permalink / raw)
  To: u-boot; +Cc: trini, quentin.schulz, briansune

This adds a new U-Boot command 'c5_pl330_dma' for Cyclone V SoCDK
boards. It provides access to the Reset Manager's Per2ModRst register
to release the reset for ARM PrimeCell PL330 DMA channels. This allows
software to initialize and use the PL330 DMA controller properly after
reset.

Signed-off-by: Brian Sune <briansune@gmail.com>
---
 cmd/Kconfig        |  9 +++++++++
 cmd/Makefile       |  1 +
 cmd/c5_pl330_dma.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 60 insertions(+)
 create mode 100644 cmd/c5_pl330_dma.c

diff --git a/cmd/Kconfig b/cmd/Kconfig
index 29de857ba7c..75c388d19da 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -1791,6 +1791,15 @@ endmenu
 
 menu "Shell scripting commands"
 
+if TARGET_SOCFPGA_CYCLONE5_SOCDK
+
+config CMD_C5_PL330_DMA
+	bool "Release Reset DMA Channels for PL330 Handshake"
+	help
+	  Provides access to Reset Manager Per2ModRst. Enables DMA
+	  channels for ARM PrimeCell PL330 via reset release.
+endif
+
 config CMD_CAT
 	bool "cat"
 	help
diff --git a/cmd/Makefile b/cmd/Makefile
index 36e79cc3c28..d16e6fae20a 100644
--- a/cmd/Makefile
+++ b/cmd/Makefile
@@ -42,6 +42,7 @@ obj-$(CONFIG_CMD_BOOTI) += booti.o
 obj-$(CONFIG_CMD_BTRFS) += btrfs.o
 obj-$(CONFIG_CMD_BUTTON) += button.o
 obj-$(CONFIG_CMD_CAT) += cat.o
+obj-$(CONFIG_CMD_C5_PL330_DMA) += c5_pl330_dma.o
 obj-$(CONFIG_CMD_CACHE) += cache.o
 obj-$(CONFIG_CMD_CBFS) += cbfs.o
 obj-$(CONFIG_CMD_CEDIT) += cedit.o
diff --git a/cmd/c5_pl330_dma.c b/cmd/c5_pl330_dma.c
new file mode 100644
index 00000000000..5267ea2bd44
--- /dev/null
+++ b/cmd/c5_pl330_dma.c
@@ -0,0 +1,50 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Brian Sune <briansune@gmail.com>
+ */
+
+#include <vsprintf.h>
+#include <command.h>
+#include <asm/io.h>
+
+#include <asm/arch/base_addr_ac5.h>
+
+#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) for SoCFPGA",
+	"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] 7+ messages in thread

* Re: [PATCH v2] cmd/dma: implement dmareset command
  2025-09-23 18:12 ` [PATCH v2] cmd/dma: implement dmareset command briansune
@ 2025-10-08  4:22   ` Tom Rini
  2025-10-08 11:09     ` Sune Brian
  2025-10-08 15:34     ` Sune Brian
  0 siblings, 2 replies; 7+ messages in thread
From: Tom Rini @ 2025-10-08  4:22 UTC (permalink / raw)
  To: u-boot, briansune; +Cc: quentin.schulz

On Wed, 24 Sep 2025 02:12:54 +0800, briansune wrote:

> This adds a new U-Boot command 'c5_pl330_dma' for Cyclone V SoCDK
> boards. It provides access to the Reset Manager's Per2ModRst register
> to release the reset for ARM PrimeCell PL330 DMA channels. This allows
> software to initialize and use the PL330 DMA controller properly after
> reset.
> 
> 
> [...]

Applied to u-boot/master, thanks!

[1/1] cmd/dma: implement dmareset command
      commit: 92dcb3ad5d98f494b2448a7345e1cb7eefa50278
-- 
Tom



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] cmd/dma: implement dmareset command
  2025-10-08  4:22   ` Tom Rini
@ 2025-10-08 11:09     ` Sune Brian
  2025-10-08 15:34     ` Sune Brian
  1 sibling, 0 replies; 7+ messages in thread
From: Sune Brian @ 2025-10-08 11:09 UTC (permalink / raw)
  To: Tom Rini; +Cc: u-boot

Tom Rini <trini@konsulko.com> 於 2025年10月8日 週三 下午12:22寫道:
> Applied to u-boot/master, thanks!
>
> [1/1] cmd/dma: implement dmareset command
>       commit: 92dcb3ad5d98f494b2448a7345e1cb7eefa50278
> --
> Tom

Welcome to help.
Brian

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] cmd/dma: implement dmareset command
  2025-10-08  4:22   ` Tom Rini
  2025-10-08 11:09     ` Sune Brian
@ 2025-10-08 15:34     ` Sune Brian
  2025-10-08 16:06       ` Tom Rini
  1 sibling, 1 reply; 7+ messages in thread
From: Sune Brian @ 2025-10-08 15:34 UTC (permalink / raw)
  To: Tom Rini; +Cc: u-boot, quentin.schulz

Tom Rini <trini@konsulko.com> 於 2025年10月8日 週三 下午12:22寫道:

> [1/1] cmd/dma: implement dmareset command
>       commit: 92dcb3ad5d98f494b2448a7345e1cb7eefa50278
> --
> Tom

May I ask do there are any documentation to show how to run this
command on boot.scr
Or possible during U-Boot setup?

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] cmd/dma: implement dmareset command
  2025-10-08 15:34     ` Sune Brian
@ 2025-10-08 16:06       ` Tom Rini
  0 siblings, 0 replies; 7+ messages in thread
From: Tom Rini @ 2025-10-08 16:06 UTC (permalink / raw)
  To: Sune Brian; +Cc: u-boot, quentin.schulz

[-- Attachment #1: Type: text/plain, Size: 624 bytes --]

On Wed, Oct 08, 2025 at 11:34:11PM +0800, Sune Brian wrote:
> Tom Rini <trini@konsulko.com> 於 2025年10月8日 週三 下午12:22寫道:
> 
> > [1/1] cmd/dma: implement dmareset command
> >       commit: 92dcb3ad5d98f494b2448a7345e1cb7eefa50278
> > --
> > Tom
> 
> May I ask do there are any documentation to show how to run this
> command on boot.scr
> Or possible during U-Boot setup?

Well, once it's enabled in your build you can invoke it like normal, or
add it to your boot.cmd script, or possibly add it to CONFIG_PREBOOT and
run it that way, depending on how it's supposed to be used.

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2025-10-08 16:06 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-13 16:39 [PATCH] cmd/dma: fix generic naming, spacing, and Dependencies briansune
2025-09-23 11:47 ` Quentin Schulz
2025-09-23 18:12 ` [PATCH v2] cmd/dma: implement dmareset command briansune
2025-10-08  4:22   ` Tom Rini
2025-10-08 11:09     ` Sune Brian
2025-10-08 15:34     ` Sune Brian
2025-10-08 16:06       ` Tom Rini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.