All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] Add support for jtag disable/enable and multiboot get/set for zynq
@ 2024-03-28  9:01 lukas.funke-oss
  2024-03-28  9:01 ` [PATCH 1/3] zynq: Add get function for multi boot address register lukas.funke-oss
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: lukas.funke-oss @ 2024-03-28  9:01 UTC (permalink / raw)
  To: u-boot
  Cc: Lukas Funke, Michal Simek, Michal Simek, Stefan Herbrechtsmeier,
	Tom Rini

From: Lukas Funke <lukas.funke@weidmueller.com>


This series adds support to enable/disable/lock the jtag interface
from u-boot. This becomes handy if secure boot is used but debugging
should be poissible for non-productions builds.

The series also adds support to get/set the multiboot register in order
to ensure a freash bootimage search after soft reset.



Stefan Herbrechtsmeier (3):
  zynq: Add get function for multi boot address register
  zynq: Add function to enable JTAG
  zynq: Add function to lock JTAG enable bits

 arch/arm/mach-zynq/cpu.c                    | 48 ++++++++++++++++++++-
 arch/arm/mach-zynq/include/mach/hardware.h  |  3 +-
 arch/arm/mach-zynq/include/mach/sys_proto.h |  4 ++
 3 files changed, 52 insertions(+), 3 deletions(-)

-- 
2.30.2


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

* [PATCH 1/3] zynq: Add get function for multi boot address register
  2024-03-28  9:01 [PATCH 0/3] Add support for jtag disable/enable and multiboot get/set for zynq lukas.funke-oss
@ 2024-03-28  9:01 ` lukas.funke-oss
  2024-03-28  9:01 ` [PATCH 2/3] zynq: Add function to enable JTAG lukas.funke-oss
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: lukas.funke-oss @ 2024-03-28  9:01 UTC (permalink / raw)
  To: u-boot
  Cc: Stefan Herbrechtsmeier, Lukas Funke, Michal Simek, Michal Simek,
	Tom Rini

From: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>

This commit adds a function to get/set the multiboot register. This
becomes handy in order to ensure a fresh bootimage search after reset.

Signed-off-by: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>
Signed-off-by: Lukas Funke <lukas.funke@weidmueller.com>
---

 arch/arm/mach-zynq/cpu.c                    | 19 +++++++++++++++++--
 arch/arm/mach-zynq/include/mach/hardware.h  |  3 ++-
 arch/arm/mach-zynq/include/mach/sys_proto.h |  2 ++
 3 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/arch/arm/mach-zynq/cpu.c b/arch/arm/mach-zynq/cpu.c
index 3b6518c71c..3d2866422e 100644
--- a/arch/arm/mach-zynq/cpu.c
+++ b/arch/arm/mach-zynq/cpu.c
@@ -14,8 +14,9 @@
 #include <asm/arch/ps7_init_gpl.h>
 #include <asm/arch/sys_proto.h>
 
-#define ZYNQ_SILICON_VER_MASK	0xF0000000
-#define ZYNQ_SILICON_VER_SHIFT	28
+#define ZYNQ_SILICON_VER_MASK		0xF0000000
+#define ZYNQ_SILICON_VER_SHIFT		28
+#define ZYNQ_MULTIBOOT_ADDR_MASK	0x00001FFF
 
 #if CONFIG_IS_ENABLED(FPGA)
 xilinx_desc fpga = {
@@ -79,6 +80,20 @@ unsigned int zynq_get_silicon_version(void)
 						>> ZYNQ_SILICON_VER_SHIFT;
 }
 
+unsigned int zynq_get_mulitboot_addr(void)
+{
+	return readl(&devcfg_base->multiboot_addr) & ZYNQ_MULTIBOOT_ADDR_MASK;
+}
+
+void zynq_set_mulitboot_addr(unsigned int value)
+{
+	unsigned int v = readl(&devcfg_base->multiboot_addr);
+
+	v &= ~ZYNQ_MULTIBOOT_ADDR_MASK;
+	v |= value & ZYNQ_MULTIBOOT_ADDR_MASK;
+	writel(v, &devcfg_base->multiboot_addr);
+}
+
 void reset_cpu(void)
 {
 	zynq_slcr_cpu_reset();
diff --git a/arch/arm/mach-zynq/include/mach/hardware.h b/arch/arm/mach-zynq/include/mach/hardware.h
index 89eb565c94..9199baccfa 100644
--- a/arch/arm/mach-zynq/include/mach/hardware.h
+++ b/arch/arm/mach-zynq/include/mach/hardware.h
@@ -96,7 +96,8 @@ struct devcfg_regs {
 	u32 dma_src_len; /* 0x20 */
 	u32 dma_dst_len; /* 0x24 */
 	u32 rom_shadow; /* 0x28 */
-	u32 reserved1[2];
+	u32 multiboot_addr; /* 0x2c */
+	u32 reserved1[1];
 	u32 unlock; /* 0x34 */
 	u32 reserved2[18];
 	u32 mctrl; /* 0x80 */
diff --git a/arch/arm/mach-zynq/include/mach/sys_proto.h b/arch/arm/mach-zynq/include/mach/sys_proto.h
index 268ec50ad8..6b85682808 100644
--- a/arch/arm/mach-zynq/include/mach/sys_proto.h
+++ b/arch/arm/mach-zynq/include/mach/sys_proto.h
@@ -16,5 +16,7 @@ extern u32 zynq_slcr_get_idcode(void);
 extern int zynq_slcr_get_mio_pin_status(const char *periph);
 extern void zynq_ddrc_init(void);
 extern unsigned int zynq_get_silicon_version(void);
+extern unsigned int zynq_get_mulitboot_addr(void);
+extern void zynq_set_mulitboot_addr(unsigned int);
 
 #endif /* _SYS_PROTO_H_ */
-- 
2.30.2


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

* [PATCH 2/3] zynq: Add function to enable JTAG
  2024-03-28  9:01 [PATCH 0/3] Add support for jtag disable/enable and multiboot get/set for zynq lukas.funke-oss
  2024-03-28  9:01 ` [PATCH 1/3] zynq: Add get function for multi boot address register lukas.funke-oss
@ 2024-03-28  9:01 ` lukas.funke-oss
  2024-03-28  9:01 ` [PATCH 3/3] zynq: Add function to lock JTAG enable bits lukas.funke-oss
  2024-04-02 13:20 ` [PATCH 0/3] Add support for jtag disable/enable and multiboot get/set for zynq Michal Simek
  3 siblings, 0 replies; 5+ messages in thread
From: lukas.funke-oss @ 2024-03-28  9:01 UTC (permalink / raw)
  To: u-boot
  Cc: Stefan Herbrechtsmeier, Lukas Funke, Michal Simek, Michal Simek,
	Tom Rini

From: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>

In non-secure boot mode jtag is restored by the BootROM. In secure boot
mode jtag has to be restored by the trusted application, i.e. the
bootloader.

This commit adds a function to enable the jtag interface on zynq
devices from u-boot.

Signed-off-by: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>
Signed-off-by: Lukas Funke <lukas.funke@weidmueller.com>
---

 arch/arm/mach-zynq/cpu.c                    | 19 +++++++++++++++++++
 arch/arm/mach-zynq/include/mach/sys_proto.h |  1 +
 2 files changed, 20 insertions(+)

diff --git a/arch/arm/mach-zynq/cpu.c b/arch/arm/mach-zynq/cpu.c
index 3d2866422e..b8d413b69a 100644
--- a/arch/arm/mach-zynq/cpu.c
+++ b/arch/arm/mach-zynq/cpu.c
@@ -14,6 +14,13 @@
 #include <asm/arch/ps7_init_gpl.h>
 #include <asm/arch/sys_proto.h>
 
+#define ZYNQ_DEV_CFG_CTRL_DAP_EN		GENMASK(0, 2)
+#define ZYNQ_DEV_CFG_CTRL_DBGEN			BIT(3)
+#define ZYNQ_DEV_CFG_CTRL_NIDEN			BIT(4)
+#define ZYNQ_DEV_CFG_CTRL_SPIDEM		BIT(5)
+#define ZYNQ_DEV_CFG_CTRL_SPNIDEN		BIT(6)
+#define ZYNQ_DEV_CFG_CTRL_JTAG_CHAIN_DIS	BIT(23)
+
 #define ZYNQ_SILICON_VER_MASK		0xF0000000
 #define ZYNQ_SILICON_VER_SHIFT		28
 #define ZYNQ_MULTIBOOT_ADDR_MASK	0x00001FFF
@@ -74,6 +81,18 @@ int arch_cpu_init(void)
 	return 0;
 }
 
+void zynq_enable_jtag(void)
+{
+	unsigned int v;
+
+	v = readl(&devcfg_base->ctrl);
+	v &= ~ZYNQ_DEV_CFG_CTRL_JTAG_CHAIN_DIS;
+	v |= ZYNQ_DEV_CFG_CTRL_DAP_EN | ZYNQ_DEV_CFG_CTRL_DBGEN
+	   | ZYNQ_DEV_CFG_CTRL_NIDEN | ZYNQ_DEV_CFG_CTRL_NIDEN
+	   | ZYNQ_DEV_CFG_CTRL_SPIDEM | ZYNQ_DEV_CFG_CTRL_SPNIDEN;
+	writel(v, &devcfg_base->ctrl);
+}
+
 unsigned int zynq_get_silicon_version(void)
 {
 	return (readl(&devcfg_base->mctrl) & ZYNQ_SILICON_VER_MASK)
diff --git a/arch/arm/mach-zynq/include/mach/sys_proto.h b/arch/arm/mach-zynq/include/mach/sys_proto.h
index 6b85682808..f583ef090d 100644
--- a/arch/arm/mach-zynq/include/mach/sys_proto.h
+++ b/arch/arm/mach-zynq/include/mach/sys_proto.h
@@ -15,6 +15,7 @@ extern u32 zynq_slcr_get_boot_mode(void);
 extern u32 zynq_slcr_get_idcode(void);
 extern int zynq_slcr_get_mio_pin_status(const char *periph);
 extern void zynq_ddrc_init(void);
+extern void zynq_enable_jtag(void);
 extern unsigned int zynq_get_silicon_version(void);
 extern unsigned int zynq_get_mulitboot_addr(void);
 extern void zynq_set_mulitboot_addr(unsigned int);
-- 
2.30.2


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

* [PATCH 3/3] zynq: Add function to lock JTAG enable bits
  2024-03-28  9:01 [PATCH 0/3] Add support for jtag disable/enable and multiboot get/set for zynq lukas.funke-oss
  2024-03-28  9:01 ` [PATCH 1/3] zynq: Add get function for multi boot address register lukas.funke-oss
  2024-03-28  9:01 ` [PATCH 2/3] zynq: Add function to enable JTAG lukas.funke-oss
@ 2024-03-28  9:01 ` lukas.funke-oss
  2024-04-02 13:20 ` [PATCH 0/3] Add support for jtag disable/enable and multiboot get/set for zynq Michal Simek
  3 siblings, 0 replies; 5+ messages in thread
From: lukas.funke-oss @ 2024-03-28  9:01 UTC (permalink / raw)
  To: u-boot
  Cc: Stefan Herbrechtsmeier, Lukas Funke, Michal Simek, Michal Simek,
	Tom Rini

From: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>

Add function to prevent debug access from being enabled. If the debug
lock is set the debug access cannot be enabled after a soft-reset.
The debug access can only be enabled after a power-on-reset is
performed.

Signed-off-by: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>
Signed-off-by: Lukas Funke <lukas.funke@weidmueller.com>
---

 arch/arm/mach-zynq/cpu.c                    | 10 ++++++++++
 arch/arm/mach-zynq/include/mach/sys_proto.h |  1 +
 2 files changed, 11 insertions(+)

diff --git a/arch/arm/mach-zynq/cpu.c b/arch/arm/mach-zynq/cpu.c
index b8d413b69a..e6151bc21d 100644
--- a/arch/arm/mach-zynq/cpu.c
+++ b/arch/arm/mach-zynq/cpu.c
@@ -20,6 +20,7 @@
 #define ZYNQ_DEV_CFG_CTRL_SPIDEM		BIT(5)
 #define ZYNQ_DEV_CFG_CTRL_SPNIDEN		BIT(6)
 #define ZYNQ_DEV_CFG_CTRL_JTAG_CHAIN_DIS	BIT(23)
+#define ZYNQ_DEV_CFG_LOCK_DBG_LOCK		BIT(0)
 
 #define ZYNQ_SILICON_VER_MASK		0xF0000000
 #define ZYNQ_SILICON_VER_SHIFT		28
@@ -93,6 +94,15 @@ void zynq_enable_jtag(void)
 	writel(v, &devcfg_base->ctrl);
 }
 
+void zynq_lock_jtag(void)
+{
+	unsigned int v;
+
+	v = readl(&devcfg_base->lock);
+	v |= ZYNQ_DEV_CFG_LOCK_DBG_LOCK;
+	writel(v, &devcfg_base->lock);
+}
+
 unsigned int zynq_get_silicon_version(void)
 {
 	return (readl(&devcfg_base->mctrl) & ZYNQ_SILICON_VER_MASK)
diff --git a/arch/arm/mach-zynq/include/mach/sys_proto.h b/arch/arm/mach-zynq/include/mach/sys_proto.h
index f583ef090d..3377fe2c23 100644
--- a/arch/arm/mach-zynq/include/mach/sys_proto.h
+++ b/arch/arm/mach-zynq/include/mach/sys_proto.h
@@ -16,6 +16,7 @@ extern u32 zynq_slcr_get_idcode(void);
 extern int zynq_slcr_get_mio_pin_status(const char *periph);
 extern void zynq_ddrc_init(void);
 extern void zynq_enable_jtag(void);
+extern void zynq_lock_jtag(void);
 extern unsigned int zynq_get_silicon_version(void);
 extern unsigned int zynq_get_mulitboot_addr(void);
 extern void zynq_set_mulitboot_addr(unsigned int);
-- 
2.30.2


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

* Re: [PATCH 0/3] Add support for jtag disable/enable and multiboot get/set for zynq
  2024-03-28  9:01 [PATCH 0/3] Add support for jtag disable/enable and multiboot get/set for zynq lukas.funke-oss
                   ` (2 preceding siblings ...)
  2024-03-28  9:01 ` [PATCH 3/3] zynq: Add function to lock JTAG enable bits lukas.funke-oss
@ 2024-04-02 13:20 ` Michal Simek
  3 siblings, 0 replies; 5+ messages in thread
From: Michal Simek @ 2024-04-02 13:20 UTC (permalink / raw)
  To: lukas.funke-oss, u-boot
  Cc: Lukas Funke, Michal Simek, Stefan Herbrechtsmeier, Tom Rini

Hi,

On 3/28/24 10:01, lukas.funke-oss@weidmueller.com wrote:
> From: Lukas Funke <lukas.funke@weidmueller.com>
> 
> 
> This series adds support to enable/disable/lock the jtag interface
> from u-boot. This becomes handy if secure boot is used but debugging
> should be poissible for non-productions builds.
> 
> The series also adds support to get/set the multiboot register in order
> to ensure a freash bootimage search after soft reset.

nit: typo here.

I understand what you do and why but completely missing wiring for using it.
Likely you are calling it from your code but pretty much when this is applied it 
is just dead code. Can we wire it up somehow?

1/3 - showing multiboot at boot
Then do similar things as are done with SPL_ZYNQMP_ALT_BOOTMODE

2/3 this is pretty much the same what it is done via
ZYNQMP_RESTORE_JTAG (also please rename it to be aligned together).

3/3 - I would be fine if this is connected to zynq specific command for example 
(unlock can be wired like that too).

Thanks,
Michal

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

end of thread, other threads:[~2024-04-02 13:20 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-28  9:01 [PATCH 0/3] Add support for jtag disable/enable and multiboot get/set for zynq lukas.funke-oss
2024-03-28  9:01 ` [PATCH 1/3] zynq: Add get function for multi boot address register lukas.funke-oss
2024-03-28  9:01 ` [PATCH 2/3] zynq: Add function to enable JTAG lukas.funke-oss
2024-03-28  9:01 ` [PATCH 3/3] zynq: Add function to lock JTAG enable bits lukas.funke-oss
2024-04-02 13:20 ` [PATCH 0/3] Add support for jtag disable/enable and multiboot get/set for zynq Michal Simek

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.