Skip to contentSkip to conversation

sysreset: add support for socfpga sysreset

PATCH New Simon Goldschmidt 2 participants 4 messages May 3, 2019

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sysreset: add support for socfpga sysreset

This moves sysreset support for socfgpa from ad-hoc code in mach-socfpga to a UCLASS_SYSRESET based dm driver.

A side effect is that gen5 and a10 can now differ between cold and warm reset.

---

 arch/arm/Kconfig                              |  3 +
 arch/arm/mach-socfpga/Makefile                |  1 -
 .../mach-socfpga/include/mach/reset_manager.h |  1 +
 arch/arm/mach-socfpga/reset_manager.c         | 41 -------------
 drivers/sysreset/Kconfig                      |  6 ++
 drivers/sysreset/Makefile                     |  1 +
 drivers/sysreset/sysreset_socfpga.c           | 58 +++++++++++++++++++
 7 files changed, 69 insertions(+), 42 deletions(-)
 delete mode 100644 arch/arm/mach-socfpga/reset_manager.c
 create mode 100644 drivers/sysreset/sysreset_socfpga.c
arch/arm/Kconfig +3 -0
index 49f01f1ff1..656ff92bd8 100644
@@ -823,6 +823,7 @@ config ARCH_SOCFPGA
 	select OF_CONTROL
 	select SPL_DM_RESET if DM_RESET
 	select SPL_DM_SERIAL
+	select SPL_DRIVERS_MISC_SUPPORT
 	select SPL_LIBCOMMON_SUPPORT
 	select SPL_LIBGENERIC_SUPPORT
 	select SPL_NAND_SUPPORT if SPL_NAND_DENALI
@@ -833,6 +834,8 @@ config ARCH_SOCFPGA
 	select SUPPORT_SPL
 	select SYS_NS16550
 	select SYS_THUMB_BUILD if TARGET_SOCFPGA_GEN5 || TARGET_SOCFPGA_ARRIA10
+	select SYSRESET
+	select SYSRESET_SOCFPGA
 	imply CMD_DM
 	imply CMD_MTDPARTS
 	imply CRC32_VERIFY
arch/arm/mach-socfpga/Makefile +0 -1
index e66720447f..fc1181cb27 100644
@@ -8,7 +8,6 @@
 obj-y	+= board.o
 obj-y	+= clock_manager.o
 obj-y	+= misc.o
-obj-y	+= reset_manager.o
 
 ifdef CONFIG_TARGET_SOCFPGA_GEN5
 obj-y	+= clock_manager_gen5.o
arch/arm/mach-socfpga/include/mach/reset_manager.h +1 -0
index 42beaecdd6..6ad037e325 100644
@@ -11,6 +11,7 @@ void reset_cpu(ulong addr);
 void socfpga_per_reset(u32 reset, int set);
 void socfpga_per_reset_all(void);
 
+#define RSTMGR_CTRL_SWCOLDRSTREQ_LSB 0
 #define RSTMGR_CTRL_SWWARMRSTREQ_LSB 1
 
 /*
arch/arm/mach-socfpga/reset_manager.c deleted +0 -41

41 lines not on this page · raw message

drivers/sysreset/Kconfig +6 -0
index 8ce3e2e207..8b6e6626d2 100644
@@ -36,6 +36,12 @@ config SYSRESET_PSCI
 	  Enable PSCI SYSTEM_RESET function call.  To use this, PSCI firmware
 	  must be running on your system.
 
+config SYSRESET_SOCFPGA
+	bool "Enable support for Intel SOCFPGA family"
+	depends on ARCH_SOCFPGA
+	help
+	  This enables the system reset driver support for Intel SOCFPGA SoCs.
+
 config SYSRESET_TI_SCI
 	bool "TI System Control Interface (TI SCI) system reset driver"
 	depends on TI_SCI_PROTOCOL
drivers/sysreset/Makefile +1 -0
index b3728ac17f..0241b0132d 100644
@@ -11,6 +11,7 @@ obj-$(CONFIG_SYSRESET_GPIO) += sysreset_gpio.o
 obj-$(CONFIG_SYSRESET_MCP83XX) += sysreset_mpc83xx.o
 obj-$(CONFIG_SYSRESET_MICROBLAZE) += sysreset_microblaze.o
 obj-$(CONFIG_SYSRESET_PSCI) += sysreset_psci.o
+obj-$(CONFIG_SYSRESET_SOCFPGA) += sysreset_socfpga.o
 obj-$(CONFIG_SYSRESET_TI_SCI) += sysreset-ti-sci.o
 obj-$(CONFIG_SYSRESET_SYSCON) += sysreset_syscon.o
 obj-$(CONFIG_SYSRESET_WATCHDOG) += sysreset_watchdog.o
drivers/sysreset/sysreset_socfpga.c new file +58 -0

58 lines not on this page · raw message

Signature · 1 line
2.20.1
#1 lore raw

PATCH 1/1 sysreset: add support for socfpga sysreset

Quoted 5 lines · Simon Goldschmidt

This moves sysreset support for socfgpa from ad-hoc code in mach-socfpga to a UCLASS_SYSRESET based dm driver.

A side effect is that gen5 and a10 can now differ between cold and warm reset.

s/differ/select/ ?

Quoted 19 lines

---

 arch/arm/Kconfig                              |  3 +
 arch/arm/mach-socfpga/Makefile                |  1 -
 .../mach-socfpga/include/mach/reset_manager.h |  1 +
 arch/arm/mach-socfpga/reset_manager.c         | 41 -------------
 drivers/sysreset/Kconfig                      |  6 ++
 drivers/sysreset/Makefile                     |  1 +
 drivers/sysreset/sysreset_socfpga.c           | 58 +++++++++++++++++++
 7 files changed, 69 insertions(+), 42 deletions(-)
 delete mode 100644 arch/arm/mach-socfpga/reset_manager.c
 create mode 100644 drivers/sysreset/sysreset_socfpga.c
arch/arm/Kconfig +0 -0
index 49f01f1ff1..656ff92bd8 100644

arch/arm/Kconfig config ARCH_SOCFPGA · line 826

Quoted 4 lines
arch/arm/Kconfig +1 -0
@@ -823,6 +823,7 @@ config ARCH_SOCFPGA
 	select OF_CONTROL
 	select SPL_DM_RESET if DM_RESET
 	select SPL_DM_SERIAL
+	select SPL_DRIVERS_MISC_SUPPORT

Why MISC ?

Quoted 29 lines
arch/arm/Kconfig +2 -0
 	select SPL_LIBCOMMON_SUPPORT
 	select SPL_LIBGENERIC_SUPPORT
 	select SPL_NAND_SUPPORT if SPL_NAND_DENALI
@@ -833,6 +834,8 @@ config ARCH_SOCFPGA
 	select SUPPORT_SPL
 	select SYS_NS16550
 	select SYS_THUMB_BUILD if TARGET_SOCFPGA_GEN5 || TARGET_SOCFPGA_ARRIA10
+	select SYSRESET
+	select SYSRESET_SOCFPGA
 	imply CMD_DM
 	imply CMD_MTDPARTS
 	imply CRC32_VERIFY
arch/arm/mach-socfpga/Makefile +0 -1
index e66720447f..fc1181cb27 100644
@@ -8,7 +8,6 @@
 obj-y	+= board.o
 obj-y	+= clock_manager.o
 obj-y	+= misc.o
-obj-y	+= reset_manager.o
 
 ifdef CONFIG_TARGET_SOCFPGA_GEN5
 obj-y	+= clock_manager_gen5.o
arch/arm/mach-socfpga/include/mach/reset_manager.h +0 -0
index 42beaecdd6..6ad037e325 100644

arch/arm/mach-socfpga/include/mach/reset_manager.h void reset_cpu(ulong addr); · line 14

Quoted 4 lines
arch/arm/mach-socfpga/include/mach/reset_manager.h +1 -0
@@ -11,6 +11,7 @@ void reset_cpu(ulong addr);
 void socfpga_per_reset(u32 reset, int set);
 void socfpga_per_reset_all(void);
 
+#define RSTMGR_CTRL_SWCOLDRSTREQ_LSB 0

Separate patch

Quoted 93 lines
arch/arm/mach-socfpga/include/mach/reset_manager.h +0 -0
 #define RSTMGR_CTRL_SWWARMRSTREQ_LSB 1
 
 /*
arch/arm/mach-socfpga/reset_manager.c deleted +0 -41
deleted file mode 100644
index e0a01ed07a..0000000000
@@ -1,41 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+
-/*
- *  Copyright (C) 2013 Altera Corporation <www.altera.com>
- */
-
-
-#include <common.h>
-#include <asm/io.h>
-#include <asm/arch/reset_manager.h>
-
-#if defined(CONFIG_TARGET_SOCFPGA_STRATIX10)
-#include <asm/arch/mailbox_s10.h>
-#endif
-
-DECLARE_GLOBAL_DATA_PTR;
-
-#if !defined(CONFIG_TARGET_SOCFPGA_STRATIX10)
-static const struct socfpga_reset_manager *reset_manager_base =
-		(void *)SOCFPGA_RSTMGR_ADDRESS;
-#endif
-
-/*
- * Write the reset manager register to cause reset
- */
-void reset_cpu(ulong addr)
-{
-	/* request a warm reset */
-#if defined(CONFIG_TARGET_SOCFPGA_STRATIX10)
-	puts("Mailbox: Issuing mailbox cmd REBOOT_HPS\n");
-	mbox_reset_cold();
-#else
-	writel(1 << RSTMGR_CTRL_SWWARMRSTREQ_LSB,
-	       &reset_manager_base->ctrl);
-#endif
-	/*
-	 * infinite loop here as watchdog will trigger and reset
-	 * the processor
-	 */
-	while (1)
-		;
-}
drivers/sysreset/Kconfig +6 -0
index 8ce3e2e207..8b6e6626d2 100644
@@ -36,6 +36,12 @@ config SYSRESET_PSCI
 	  Enable PSCI SYSTEM_RESET function call.  To use this, PSCI firmware
 	  must be running on your system.
 
+config SYSRESET_SOCFPGA
+	bool "Enable support for Intel SOCFPGA family"
+	depends on ARCH_SOCFPGA
+	help
+	  This enables the system reset driver support for Intel SOCFPGA SoCs.
+
 config SYSRESET_TI_SCI
 	bool "TI System Control Interface (TI SCI) system reset driver"
 	depends on TI_SCI_PROTOCOL
drivers/sysreset/Makefile +1 -0
index b3728ac17f..0241b0132d 100644
@@ -11,6 +11,7 @@ obj-$(CONFIG_SYSRESET_GPIO) += sysreset_gpio.o
 obj-$(CONFIG_SYSRESET_MCP83XX) += sysreset_mpc83xx.o
 obj-$(CONFIG_SYSRESET_MICROBLAZE) += sysreset_microblaze.o
 obj-$(CONFIG_SYSRESET_PSCI) += sysreset_psci.o
+obj-$(CONFIG_SYSRESET_SOCFPGA) += sysreset_socfpga.o
 obj-$(CONFIG_SYSRESET_TI_SCI) += sysreset-ti-sci.o
 obj-$(CONFIG_SYSRESET_SYSCON) += sysreset_syscon.o
 obj-$(CONFIG_SYSRESET_WATCHDOG) += sysreset_watchdog.o
drivers/sysreset/sysreset_socfpga.c new file +8 -0
new file mode 100644
index 0000000000..b5bbf4aad6
@@ -0,0 +1,58 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2019 Pepperl+Fuchs
+ * Simon Goldschmidt <[email protected]>
+ */
+
+#include <common.h>
+#include <dm.h>

drivers/sysreset/sysreset_socfpga.c line 18

Quoted 10 lines
drivers/sysreset/sysreset_socfpga.c new file +10 -0
+#include <errno.h>
+#include <sysreset.h>
+#include <asm/io.h>
+#include <asm/arch/reset_manager.h>
+
+#if defined(CONFIG_TARGET_SOCFPGA_STRATIX10)
+#include <asm/arch/mailbox_s10.h>
+#else
+static const struct socfpga_reset_manager *reset_manager_base =
+		(void *)SOCFPGA_RSTMGR_ADDRESS;

Shouldn't this come from DT ?

drivers/sysreset/sysreset_socfpga.c line 25

Quoted 7 lines
drivers/sysreset/sysreset_socfpga.c new file +7 -0
+
+#endif
+
+static int socfpga_sysreset_request(struct udevice *dev,
+				    enum sysreset_t type)
+{
+#if defined(CONFIG_TARGET_SOCFPGA_STRATIX10)

You want a different driver for S10 instead of this ifdeffery.

Quoted 20 lines
drivers/sysreset/sysreset_socfpga.c new file +20 -0
+	puts("Mailbox: Issuing mailbox cmd REBOOT_HPS\n");
+	mbox_reset_cold();
+#else
+	switch (type) {
+	case SYSRESET_WARM:
+		writel(1 << RSTMGR_CTRL_SWWARMRSTREQ_LSB,
+		       &reset_manager_base->ctrl);
+		break;
+	case SYSRESET_COLD:
+		writel(1 << RSTMGR_CTRL_SWCOLDRSTREQ_LSB,
+		       &reset_manager_base->ctrl);
+		break;
+	default:
+		return -EPROTONOSUPPORT;
+	}
+#endif
+	return -EINPROGRESS;
+}
+
+static struct sysreset_ops socfpga_sysreset = {

drivers/sysreset/sysreset_socfpga.c line 55

Quoted 10 lines
drivers/sysreset/sysreset_socfpga.c new file +10 -0
+	.request = socfpga_sysreset_request,
+};
+
+U_BOOT_DRIVER(sysreset_socfpga) = {
+	.id	= UCLASS_SYSRESET,
+	.name	= "socfpga_sysreset",
+	.ops	= &socfpga_sysreset,
+};
+
+/* The reset driver does not have a device node, so bind it here */

Isn't that part of reset manager ?

Quoted 4 lines
drivers/sysreset/sysreset_socfpga.c new file +3 -0
+U_BOOT_DEVICE(sysreset_socfpga) = {
+	.name = "socfpga_sysreset",
+};
Signature · 2 lines
Best regards,
Marek Vasut
#2 lore raw

PATCH 1/1 sysreset: add support for socfpga sysreset

Quoted 8 lines · Marek Vasut
Quoted 5 lines · Simon Goldschmidt

This moves sysreset support for socfgpa from ad-hoc code in mach-socfpga to a UCLASS_SYSRESET based dm driver.

A side effect is that gen5 and a10 can now differ between cold and warm reset.

s/differ/select/ ?

Right.

Quoted 15 lines
Quoted 15 lines

---

  arch/arm/Kconfig                              |  3 +
  arch/arm/mach-socfpga/Makefile                |  1 -
  .../mach-socfpga/include/mach/reset_manager.h |  1 +
  arch/arm/mach-socfpga/reset_manager.c         | 41 -------------
  drivers/sysreset/Kconfig                      |  6 ++
  drivers/sysreset/Makefile                     |  1 +
  drivers/sysreset/sysreset_socfpga.c           | 58 +++++++++++++++++++
  7 files changed, 69 insertions(+), 42 deletions(-)

delete mode 100644 arch/arm/mach-socfpga/reset_manager.c create mode 100644 drivers/sysreset/sysreset_socfpga.c

Quoted 11 lines

arch/arm/Kconfig config ARCH_SOCFPGA · line 826

Quoted 9 lines
arch/arm/Kconfig +1 -0
index 49f01f1ff1..656ff92bd8 100644
@@ -823,6 +823,7 @@ config ARCH_SOCFPGA
  	select OF_CONTROL
  	select SPL_DM_RESET if DM_RESET
  	select SPL_DM_SERIAL
+	select SPL_DRIVERS_MISC_SUPPORT

Why MISC ?

Because that's what includes the sysreset drivers into SPL.

Quoted 33 lines
Quoted 33 lines
arch/arm/Kconfig +2 -0
  	select SPL_LIBCOMMON_SUPPORT
  	select SPL_LIBGENERIC_SUPPORT
  	select SPL_NAND_SUPPORT if SPL_NAND_DENALI
@@ -833,6 +834,8 @@ config ARCH_SOCFPGA
  	select SUPPORT_SPL
  	select SYS_NS16550
  	select SYS_THUMB_BUILD if TARGET_SOCFPGA_GEN5 || TARGET_SOCFPGA_ARRIA10
+	select SYSRESET
+	select SYSRESET_SOCFPGA
  	imply CMD_DM
  	imply CMD_MTDPARTS
  	imply CRC32_VERIFY
arch/arm/mach-socfpga/Makefile +0 -1
index e66720447f..fc1181cb27 100644
@@ -8,7 +8,6 @@
  obj-y	+= board.o
  obj-y	+= clock_manager.o
  obj-y	+= misc.o
-obj-y	+= reset_manager.o
 
  ifdef CONFIG_TARGET_SOCFPGA_GEN5
  obj-y	+= clock_manager_gen5.o
arch/arm/mach-socfpga/include/mach/reset_manager.h +0 -0
index 42beaecdd6..6ad037e325 100644
@@ -11,6 +11,7 @@ void reset_cpu(ulong addr);
  void socfpga_per_reset(u32 reset, int set);
  void socfpga_per_reset_all(void);
 
Quoted 3 lines

arch/arm/mach-socfpga/include/mach/reset_manager.h void reset_cpu(ulong addr); · line 14

Quoted 1 line
arch/arm/mach-socfpga/include/mach/reset_manager.h +1 -0
+#define RSTMGR_CTRL_SWCOLDRSTREQ_LSB 0

Separate patch

Fair enough.

Quoted 98 lines
Quoted 98 lines
arch/arm/mach-socfpga/include/mach/reset_manager.h +0 -0
  #define RSTMGR_CTRL_SWWARMRSTREQ_LSB 1
 
  /*
arch/arm/mach-socfpga/reset_manager.c deleted +0 -41
deleted file mode 100644
index e0a01ed07a..0000000000
@@ -1,41 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+
-/*
- *  Copyright (C) 2013 Altera Corporation <www.altera.com>
- */
-
-
-#include <common.h>
-#include <asm/io.h>
-#include <asm/arch/reset_manager.h>
-
-#if defined(CONFIG_TARGET_SOCFPGA_STRATIX10)
-#include <asm/arch/mailbox_s10.h>
-#endif
-
-DECLARE_GLOBAL_DATA_PTR;
-
-#if !defined(CONFIG_TARGET_SOCFPGA_STRATIX10)
-static const struct socfpga_reset_manager *reset_manager_base =
-		(void *)SOCFPGA_RSTMGR_ADDRESS;
-#endif
-
-/*
- * Write the reset manager register to cause reset
- */
-void reset_cpu(ulong addr)
-{
-	/* request a warm reset */
-#if defined(CONFIG_TARGET_SOCFPGA_STRATIX10)
-	puts("Mailbox: Issuing mailbox cmd REBOOT_HPS\n");
-	mbox_reset_cold();
-#else
-	writel(1 << RSTMGR_CTRL_SWWARMRSTREQ_LSB,
-	       &reset_manager_base->ctrl);
-#endif
-	/*
-	 * infinite loop here as watchdog will trigger and reset
-	 * the processor
-	 */
-	while (1)
-		;
-}
drivers/sysreset/Kconfig +6 -0
index 8ce3e2e207..8b6e6626d2 100644
@@ -36,6 +36,12 @@ config SYSRESET_PSCI
  	  Enable PSCI SYSTEM_RESET function call.  To use this, PSCI firmware
  	  must be running on your system.
 
+config SYSRESET_SOCFPGA
+	bool "Enable support for Intel SOCFPGA family"
+	depends on ARCH_SOCFPGA
+	help
+	  This enables the system reset driver support for Intel SOCFPGA SoCs.
+
  config SYSRESET_TI_SCI
  	bool "TI System Control Interface (TI SCI) system reset driver"
  	depends on TI_SCI_PROTOCOL
drivers/sysreset/Makefile +1 -0
index b3728ac17f..0241b0132d 100644
@@ -11,6 +11,7 @@ obj-$(CONFIG_SYSRESET_GPIO) += sysreset_gpio.o
  obj-$(CONFIG_SYSRESET_MCP83XX) += sysreset_mpc83xx.o
  obj-$(CONFIG_SYSRESET_MICROBLAZE) += sysreset_microblaze.o
  obj-$(CONFIG_SYSRESET_PSCI) += sysreset_psci.o
+obj-$(CONFIG_SYSRESET_SOCFPGA) += sysreset_socfpga.o
  obj-$(CONFIG_SYSRESET_TI_SCI) += sysreset-ti-sci.o
  obj-$(CONFIG_SYSRESET_SYSCON) += sysreset_syscon.o
  obj-$(CONFIG_SYSRESET_WATCHDOG) += sysreset_watchdog.o
drivers/sysreset/sysreset_socfpga.c new file +12 -0
new file mode 100644
index 0000000000..b5bbf4aad6
@@ -0,0 +1,58 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2019 Pepperl+Fuchs
+ * Simon Goldschmidt <[email protected]>
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <errno.h>
+#include <sysreset.h>
+#include <asm/io.h>
+#include <asm/arch/reset_manager.h>
Quoted 8 lines

drivers/sysreset/sysreset_socfpga.c line 18

Quoted 6 lines
drivers/sysreset/sysreset_socfpga.c new file +6 -0
+
+#if defined(CONFIG_TARGET_SOCFPGA_STRATIX10)
+#include <asm/arch/mailbox_s10.h>
+#else
+static const struct socfpga_reset_manager *reset_manager_base =
+		(void *)SOCFPGA_RSTMGR_ADDRESS;

Shouldn't this come from DT ?

Hmm, that would indeed be better, yes. The thing is we do have a driver matching the dts node in question, but it supplies peripheral resets, not sysreset. Thinking about this, I don't know how to make 2 drivers match the same dts node...?

Quoted 10 lines

drivers/sysreset/sysreset_socfpga.c line 25

Quoted 8 lines
drivers/sysreset/sysreset_socfpga.c new file +7 -0
+
+#endif
+
+static int socfpga_sysreset_request(struct udevice *dev,
+				    enum sysreset_t type)
+{
+#if defined(CONFIG_TARGET_SOCFPGA_STRATIX10)

You want a different driver for S10 instead of this ifdeffery.

That might indeed be a better solution, yes.

Quoted 25 lines
Quoted 25 lines
drivers/sysreset/sysreset_socfpga.c new file +24 -0
+	puts("Mailbox: Issuing mailbox cmd REBOOT_HPS\n");
+	mbox_reset_cold();
+#else
+	switch (type) {
+	case SYSRESET_WARM:
+		writel(1 << RSTMGR_CTRL_SWWARMRSTREQ_LSB,
+		       &reset_manager_base->ctrl);
+		break;
+	case SYSRESET_COLD:
+		writel(1 << RSTMGR_CTRL_SWCOLDRSTREQ_LSB,
+		       &reset_manager_base->ctrl);
+		break;
+	default:
+		return -EPROTONOSUPPORT;
+	}
+#endif
+	return -EINPROGRESS;
+}
+
+static struct sysreset_ops socfpga_sysreset = {
+	.request = socfpga_sysreset_request,
+};
+
+U_BOOT_DRIVER(sysreset_socfpga) = {
Quoted 8 lines

drivers/sysreset/sysreset_socfpga.c line 55

Quoted 6 lines
drivers/sysreset/sysreset_socfpga.c new file +6 -0
+	.id	= UCLASS_SYSRESET,
+	.name	= "socfpga_sysreset",
+	.ops	= &socfpga_sysreset,
+};
+
+/* The reset driver does not have a device node, so bind it here */

Isn't that part of reset manager ?

Exactly, see above. 1 dts node, 2 UCLASSes...
Any idea how to overcome this limit?

Regards,
Simon

Quoted 7 lines
Quoted 5 lines
drivers/sysreset/sysreset_socfpga.c new file +3 -0
+U_BOOT_DEVICE(sysreset_socfpga) = {
+	.name = "socfpga_sysreset",
+};
#3 lore raw

PATCH 1/1 sysreset: add support for socfpga sysreset

Quoted 41 lines · Simon Goldschmidt
Quoted 8 lines · Marek Vasut
Quoted 5 lines · Simon Goldschmidt

This moves sysreset support for socfgpa from ad-hoc code in mach-socfpga to a UCLASS_SYSRESET based dm driver.

A side effect is that gen5 and a10 can now differ between cold and warm reset.

s/differ/select/ ?

Right.

Quoted 15 lines
Quoted 15 lines

---

  arch/arm/Kconfig                              |  3 + arch/arm/mach-socfpga/Makefile                |  1 - .../mach-socfpga/include/mach/reset_manager.h |  1 + arch/arm/mach-socfpga/reset_manager.c         | 41 ------------- drivers/sysreset/Kconfig                      |  6 ++ drivers/sysreset/Makefile                     |  1 + drivers/sysreset/sysreset_socfpga.c           | 58 +++++++++++++++++++

  7 files changed, 69 insertions(+), 42 deletions(-)

  delete mode 100644 arch/arm/mach-socfpga/reset_manager.c create mode 100644 drivers/sysreset/sysreset_socfpga.c

Quoted 11 lines
Quoted 9 lines
arch/arm/Kconfig +0 -0
index 49f01f1ff1..656ff92bd8 100644
@@ -823,6 +823,7 @@ config ARCH_SOCFPGA

      select OF_CONTROL
      select SPL_DM_RESET if DM_RESET
      select SPL_DM_SERIAL
+    select SPL_DRIVERS_MISC_SUPPORT

Why MISC ?

Quoted 1 line

Because that's what includes the sysreset drivers into SPL.

That seems wrong ?

Quoted 148 lines
Quoted 28 lines
Quoted 28 lines

      select SPL_LIBCOMMON_SUPPORT
      select SPL_LIBGENERIC_SUPPORT
      select SPL_NAND_SUPPORT if SPL_NAND_DENALI

arch/arm/Kconfig +0 -0
@@ -833,6 +834,8 @@ config ARCH_SOCFPGA

      select SUPPORT_SPL
      select SYS_NS16550
      select SYS_THUMB_BUILD if TARGET_SOCFPGA_GEN5 || TARGET_SOCFPGA_ARRIA10
+    select SYSRESET
+    select SYSRESET_SOCFPGA
      imply CMD_DM
      imply CMD_MTDPARTS
      imply CRC32_VERIFY

arch/arm/mach-socfpga/Makefile +0 -0
index e66720447f..fc1181cb27 100644
@@ -8,7 +8,6 @@

  obj-y    += board.o
  obj-y    += clock_manager.o
  obj-y    += misc.o
-obj-y    += reset_manager.o
    ifdef CONFIG_TARGET_SOCFPGA_GEN5
  obj-y    += clock_manager_gen5.o

arch/arm/mach-socfpga/include/mach/reset_manager.h +0 -0
index 42beaecdd6..6ad037e325 100644
Quoted 8 lines
Quoted 6 lines
arch/arm/mach-socfpga/include/mach/reset_manager.h +0 -0
@@ -11,6 +11,7 @@ void reset_cpu(ulong addr);
   void socfpga_per_reset(u32 reset, int set);
   void socfpga_per_reset_all(void);

  +#define RSTMGR_CTRL_SWCOLDRSTREQ_LSB 0

Separate patch

Fair enough.

Quoted 100 lines
Quoted 100 lines

  #define RSTMGR_CTRL_SWWARMRSTREQ_LSB 1
    /*

arch/arm/mach-socfpga/reset_manager.c deleted +0 -41
deleted file mode 100644
index e0a01ed07a..0000000000
@@ -1,41 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+
-/*
- *  Copyright (C) 2013 Altera Corporation <www.altera.com>
- */
-
-
-#include <common.h>
-#include <asm/io.h>
-#include <asm/arch/reset_manager.h>
-
-#if defined(CONFIG_TARGET_SOCFPGA_STRATIX10)
-#include <asm/arch/mailbox_s10.h>
-#endif
-
-DECLARE_GLOBAL_DATA_PTR;
-
-#if !defined(CONFIG_TARGET_SOCFPGA_STRATIX10)
-static const struct socfpga_reset_manager *reset_manager_base =
-        (void *)SOCFPGA_RSTMGR_ADDRESS;
-#endif
-
-/*
- * Write the reset manager register to cause reset
- */
-void reset_cpu(ulong addr)
-{
-    /* request a warm reset */
-#if defined(CONFIG_TARGET_SOCFPGA_STRATIX10)
-    puts("Mailbox: Issuing mailbox cmd REBOOT_HPS\n");
-    mbox_reset_cold();
-#else
-    writel(1 << RSTMGR_CTRL_SWWARMRSTREQ_LSB,
-           &reset_manager_base->ctrl);
-#endif
-    /*
-     * infinite loop here as watchdog will trigger and reset
-     * the processor
-     */
-    while (1)
-        ;
-}
drivers/sysreset/Kconfig +0 -0
index 8ce3e2e207..8b6e6626d2 100644
@@ -36,6 +36,12 @@ config SYSRESET_PSCI

        Enable PSCI SYSTEM_RESET function call.  To use this, PSCI firmware
        must be running on your system.
  +config SYSRESET_SOCFPGA
+    bool "Enable support for Intel SOCFPGA family"
+    depends on ARCH_SOCFPGA
+    help
+      This enables the system reset driver support for Intel SOCFPGA SoCs.
+
  config SYSRESET_TI_SCI
      bool "TI System Control Interface (TI SCI) system reset driver" depends on TI_SCI_PROTOCOL

drivers/sysreset/Makefile +0 -0
index b3728ac17f..0241b0132d 100644
@@ -11,6 +11,7 @@ obj-$(CONFIG_SYSRESET_GPIO) += sysreset_gpio.o

  obj-$(CONFIG_SYSRESET_MCP83XX) += sysreset_mpc83xx.o obj-$(CONFIG_SYSRESET_MICROBLAZE) += sysreset_microblaze.o obj-$(CONFIG_SYSRESET_PSCI) += sysreset_psci.o +obj-$(CONFIG_SYSRESET_SOCFPGA) += sysreset_socfpga.o obj-$(CONFIG_SYSRESET_TI_SCI) += sysreset-ti-sci.o obj-$(CONFIG_SYSRESET_SYSCON) += sysreset_syscon.o obj-$(CONFIG_SYSRESET_WATCHDOG) += sysreset_watchdog.o

drivers/sysreset/sysreset_socfpga.c new file +12 -0
new file mode 100644
index 0000000000..b5bbf4aad6
@@ -0,0 +1,58 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2019 Pepperl+Fuchs
+ * Simon Goldschmidt <[email protected]>
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <errno.h>
+#include <sysreset.h>
+#include <asm/io.h>
+#include <asm/arch/reset_manager.h>
Quoted 8 lines

drivers/sysreset/sysreset_socfpga.c line 18

Quoted 6 lines
drivers/sysreset/sysreset_socfpga.c new file +6 -0
+
+#if defined(CONFIG_TARGET_SOCFPGA_STRATIX10)
+#include <asm/arch/mailbox_s10.h>
+#else
+static const struct socfpga_reset_manager *reset_manager_base =
+        (void *)SOCFPGA_RSTMGR_ADDRESS;

Shouldn't this come from DT ?

Quoted 4 lines

Hmm, that would indeed be better, yes. The thing is we do have a driver matching the dts node in question, but it supplies peripheral resets, not sysreset. Thinking about this, I don't know how to make 2 drivers match the same dts node...?

Make it one driver or something MFDish ?

Quoted 10 lines
Quoted 8 lines

drivers/sysreset/sysreset_socfpga.c line 25

Quoted 6 lines
drivers/sysreset/sysreset_socfpga.c new file +6 -0
+#endif
+
+static int socfpga_sysreset_request(struct udevice *dev,
+                    enum sysreset_t type)
+{
+#if defined(CONFIG_TARGET_SOCFPGA_STRATIX10)

You want a different driver for S10 instead of this ifdeffery.

That might indeed be a better solution, yes.

Yes please

Quoted 33 lines
Quoted 24 lines
Quoted 24 lines
drivers/sysreset/sysreset_socfpga.c new file +24 -0
+    puts("Mailbox: Issuing mailbox cmd REBOOT_HPS\n");
+    mbox_reset_cold();
+#else
+    switch (type) {
+    case SYSRESET_WARM:
+        writel(1 << RSTMGR_CTRL_SWWARMRSTREQ_LSB,
+               &reset_manager_base->ctrl);
+        break;
+    case SYSRESET_COLD:
+        writel(1 << RSTMGR_CTRL_SWCOLDRSTREQ_LSB,
+               &reset_manager_base->ctrl);
+        break;
+    default:
+        return -EPROTONOSUPPORT;
+    }
+#endif
+    return -EINPROGRESS;
+}
+
+static struct sysreset_ops socfpga_sysreset = {
+    .request = socfpga_sysreset_request,
+};
+
+U_BOOT_DRIVER(sysreset_socfpga) = {
Quoted 8 lines

drivers/sysreset/sysreset_socfpga.c line 55

Quoted 6 lines
drivers/sysreset/sysreset_socfpga.c new file +6 -0
+    .id    = UCLASS_SYSRESET,
+    .name    = "socfpga_sysreset",
+    .ops    = &socfpga_sysreset,
+};
+
+/* The reset driver does not have a device node, so bind it here */

Isn't that part of reset manager ?

Quoted 2 lines

Exactly, see above. 1 dts node, 2 UCLASSes...
Any idea how to overcome this limit?

See above, or look at syscon_get_regmap() to export a register to a different driver(s).

Signature · 2 lines
Best regards,
Marek Vasut