Skip to contentSkip to conversation

riscv: enable SBI system reset

PATCH Superseded Heinrich Schuchardt 4 participants 19 messages Mar 4, 2021 – Mar 8, 2021

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover riscv: enable SBI system reset

The purpose of this series is to provide the UEFI ResetSystem() service at runtime on RISC-V systems.

With SBI v0.3 a system reset extension is available. This allows to implement reboot and poweroff in U-Boot in a system independent way.

OpenSBI already provides an implementation of the extension for the Kendryte K210 and other platforms.

* Provide a system reset driver using the system reset extension.
* Enable the driver on the MAIX board.
* Change the sbi command to use contants instead of raw numbers where applicable.

Heinrich Schuchardt (5):
risv: add missing SBI extension definitions cmd/sbi: use constants instead of numerical values
sysreset: provide SBI based sysreset driver
pinctrl: K210_PINCTRL depends on REGMAP and on SYSCON
maix: enable SBI system reset for MAIX

 MAINTAINERS                         |   1 +
 arch/riscv/include/asm/sbi.h        |  37 +++++++++-
 arch/riscv/lib/sbi.c                |  21 ++++--
 board/sipeed/maix/maix.c            |   4 ++
 cmd/riscv/sbi.c                     |  30 ++++----
 configs/sipeed_maix_smode_defconfig |   2 +
 drivers/pinctrl/Kconfig             |   2 +
 drivers/sysreset/Kconfig            |   7 ++
 drivers/sysreset/Makefile           |   1 +
 drivers/sysreset/sysreset_sbi.c     | 102 ++++++++++++++++++++++++++++
 lib/efi_loader/Kconfig              |   2 +-
 11 files changed, 187 insertions(+), 22 deletions(-)
 create mode 100644 drivers/sysreset/sysreset_sbi.c

--
2.30.1

#1 lore raw

PATCH 1/5 risv: add missing SBI extension definitions

Add the System Reset Extension and the Hart State Management Extension definitions.

Add missing RFENCE Extension enum values.

The SBI 0.1 extension constants are needed for for the sbi command. Remove an #ifdef.

Cf. https://github.com/riscv/riscv-sbi-doc/blob/master/riscv-sbi.adoc

---
 arch/riscv/include/asm/sbi.h | 36 ++++++++++++++++++++++++++++++++++--
 1 file changed, 34 insertions(+), 2 deletions(-)
arch/riscv/include/asm/sbi.h +34 -2
index 53ca316180..c598bb11ce 100644
@@ -12,7 +12,6 @@
 #include <linux/types.h>
 
 enum sbi_ext_id {
-#ifdef CONFIG_SBI_V01
 	SBI_EXT_0_1_SET_TIMER = 0x0,
 	SBI_EXT_0_1_CONSOLE_PUTCHAR = 0x1,
 	SBI_EXT_0_1_CONSOLE_GETCHAR = 0x2,
@@ -22,11 +21,12 @@ enum sbi_ext_id {
 	SBI_EXT_0_1_REMOTE_SFENCE_VMA = 0x6,
 	SBI_EXT_0_1_REMOTE_SFENCE_VMA_ASID = 0x7,
 	SBI_EXT_0_1_SHUTDOWN = 0x8,
-#endif
 	SBI_EXT_BASE = 0x10,
 	SBI_EXT_TIME = 0x54494D45,
 	SBI_EXT_IPI = 0x735049,
 	SBI_EXT_RFENCE = 0x52464E43,
+	SBI_EXT_HSM = 0x48534D,
+	SBI_EXT_SRST = 0x53525354,
 };
 
 enum sbi_ext_base_fid {
@@ -51,6 +51,38 @@ enum sbi_ext_rfence_fid {
 	SBI_EXT_RFENCE_REMOTE_FENCE_I = 0,
 	SBI_EXT_RFENCE_REMOTE_SFENCE_VMA,
 	SBI_EXT_RFENCE_REMOTE_SFENCE_VMA_ASID,
+	SBI_EXT_RFENCE_REMOTE_HFENCE_GVMA,
+	SBI_EXT_RFENCE_REMOTE_HFENCE_GVMA_VMID,
+	SBI_EXT_RFENCE_REMOTE_HFENCE_VVMA,
+	SBI_EXT_RFENCE_REMOTE_HFENCE_VVMA_ASID,
+};
+
+enum sbi_ext_hsm_fid {
+	SBI_EXT_HSM_HART_START = 0,
+	SBI_EXT_HSM_HART_STOP,
+	SBI_EXT_HSM_HART_STATUS,
+};
+
+enum sbi_hsm_hart_status {
+	SBI_HSM_HART_STATUS_STARTED = 0,
+	SBI_HSM_HART_STATUS_STOPPED,
+	SBI_HSM_HART_STATUS_START_PENDING,
+	SBI_HSM_HART_STATUS_STOP_PENDING,
+};
+
+enum sbi_ext_srst_fid {
+	SBI_EXT_SRST_RESET = 0,
+};
+
+enum sbi_srst_reset_type {
+	SBI_SRST_RESET_TYPE_SHUTDOWN = 0,
+	SBI_SRST_RESET_TYPE_COLD_REBOOT,
+	SBI_SRST_RESET_TYPE_WARM_REBOOT,
+};
+
+enum sbi_srst_reset_reason {
+	SBI_SRST_RESET_REASON_NONE = 0,
+	SBI_SRST_RESET_REASON_SYS_FAILURE,
 };
 
 #ifdef CONFIG_SBI_V01

--
2.30.1

#2 lore raw

PATCH 1/5 risv: add missing SBI extension definitions

Quoted 42 lines · Heinrich Schuchardt

Add the System Reset Extension and the Hart State Management Extension definitions.

Add missing RFENCE Extension enum values.

The SBI 0.1 extension constants are needed for for the sbi command. Remove an #ifdef.

Cf. https://github.com/riscv/riscv-sbi-doc/blob/master/riscv-sbi.adoc

---
  arch/riscv/include/asm/sbi.h | 36 ++++++++++++++++++++++++++++++++++--
  1 file changed, 34 insertions(+), 2 deletions(-)
arch/riscv/include/asm/sbi.h +2 -2
index 53ca316180..c598bb11ce 100644
@@ -12,7 +12,6 @@
  #include <linux/types.h>
 
  enum sbi_ext_id {
-#ifdef CONFIG_SBI_V01
  	SBI_EXT_0_1_SET_TIMER = 0x0,
  	SBI_EXT_0_1_CONSOLE_PUTCHAR = 0x1,
  	SBI_EXT_0_1_CONSOLE_GETCHAR = 0x2,
@@ -22,11 +21,12 @@ enum sbi_ext_id {
  	SBI_EXT_0_1_REMOTE_SFENCE_VMA = 0x6,
  	SBI_EXT_0_1_REMOTE_SFENCE_VMA_ASID = 0x7,
  	SBI_EXT_0_1_SHUTDOWN = 0x8,
-#endif
  	SBI_EXT_BASE = 0x10,
  	SBI_EXT_TIME = 0x54494D45,
  	SBI_EXT_IPI = 0x735049,
  	SBI_EXT_RFENCE = 0x52464E43,
+	SBI_EXT_HSM = 0x48534D,
+	SBI_EXT_SRST = 0x53525354,
  };
 
  enum sbi_ext_base_fid {

arch/riscv/include/asm/sbi.h enum sbi_ext_rfence_fid { · line 57

Quoted 7 lines
arch/riscv/include/asm/sbi.h +4 -0
@@ -51,6 +51,38 @@ enum sbi_ext_rfence_fid {
  	SBI_EXT_RFENCE_REMOTE_FENCE_I = 0,
  	SBI_EXT_RFENCE_REMOTE_SFENCE_VMA,
  	SBI_EXT_RFENCE_REMOTE_SFENCE_VMA_ASID,
+	SBI_EXT_RFENCE_REMOTE_HFENCE_GVMA,
+	SBI_EXT_RFENCE_REMOTE_HFENCE_GVMA_VMID,
+	SBI_EXT_RFENCE_REMOTE_HFENCE_VVMA,
+	SBI_EXT_RFENCE_REMOTE_HFENCE_VVMA_ASID,

Isn't this backwards? That is, we should have

+ SBI_EXT_RFENCE_REMOTE_HFENCE_GVMA_VMID,
+ SBI_EXT_RFENCE_REMOTE_HFENCE_GVMA,
+ SBI_EXT_RFENCE_REMOTE_HFENCE_VVMA_ASID,
+ SBI_EXT_RFENCE_REMOTE_HFENCE_VVMA,

so the FIDs match.

--Sean

Quoted 34 lines
arch/riscv/include/asm/sbi.h +28 -1
+};
+
+enum sbi_ext_hsm_fid {
+	SBI_EXT_HSM_HART_START = 0,
+	SBI_EXT_HSM_HART_STOP,
+	SBI_EXT_HSM_HART_STATUS,
+};
+
+enum sbi_hsm_hart_status {
+	SBI_HSM_HART_STATUS_STARTED = 0,
+	SBI_HSM_HART_STATUS_STOPPED,
+	SBI_HSM_HART_STATUS_START_PENDING,
+	SBI_HSM_HART_STATUS_STOP_PENDING,
+};
+
+enum sbi_ext_srst_fid {
+	SBI_EXT_SRST_RESET = 0,
+};
+
+enum sbi_srst_reset_type {
+	SBI_SRST_RESET_TYPE_SHUTDOWN = 0,
+	SBI_SRST_RESET_TYPE_COLD_REBOOT,
+	SBI_SRST_RESET_TYPE_WARM_REBOOT,
+};
+
+enum sbi_srst_reset_reason {
+	SBI_SRST_RESET_REASON_NONE = 0,
+	SBI_SRST_RESET_REASON_SYS_FAILURE,
  };
 
  #ifdef CONFIG_SBI_V01
--

2.30.1

#3 lore raw

PATCH 1/5 risv: add missing SBI extension definitions

Quoted 54 lines · Sean Anderson
Quoted 43 lines · Heinrich Schuchardt

Add the System Reset Extension and the Hart State Management Extension definitions.

Add missing RFENCE Extension enum values.

The SBI 0.1 extension constants are needed for for the sbi command. Remove
an #ifdef.

Cf. https://github.com/riscv/riscv-sbi-doc/blob/master/riscv-sbi.adoc

---
? arch/riscv/include/asm/sbi.h | 36 ++++++++++++++++++++++++++++++++++-- ? 1 file changed, 34 insertions(+), 2 deletions(-)

arch/riscv/include/asm/sbi.h +0 -0
index 53ca316180..c598bb11ce 100644
@@ -12,7 +12,6 @@

? #include <linux/types.h>

? enum sbi_ext_id {
-#ifdef CONFIG_SBI_V01
????? SBI_EXT_0_1_SET_TIMER = 0x0,
????? SBI_EXT_0_1_CONSOLE_PUTCHAR = 0x1,
????? SBI_EXT_0_1_CONSOLE_GETCHAR = 0x2,

arch/riscv/include/asm/sbi.h +2 -1
@@ -22,11 +21,12 @@ enum sbi_ext_id {
 ????? SBI_EXT_0_1_REMOTE_SFENCE_VMA = 0x6,
 ????? SBI_EXT_0_1_REMOTE_SFENCE_VMA_ASID = 0x7,
 ????? SBI_EXT_0_1_SHUTDOWN = 0x8,
-#endif
 ????? SBI_EXT_BASE = 0x10,
 ????? SBI_EXT_TIME = 0x54494D45,
 ????? SBI_EXT_IPI = 0x735049,
 ????? SBI_EXT_RFENCE = 0x52464E43,
+??? SBI_EXT_HSM = 0x48534D,
+??? SBI_EXT_SRST = 0x53525354,
 ? };
 
 ? enum sbi_ext_base_fid {

arch/riscv/include/asm/sbi.h enum sbi_ext_rfence_fid { · line 57

Quoted 7 lines
arch/riscv/include/asm/sbi.h +4 -0
@@ -51,6 +51,38 @@ enum sbi_ext_rfence_fid {
 ????? SBI_EXT_RFENCE_REMOTE_FENCE_I = 0,
 ????? SBI_EXT_RFENCE_REMOTE_SFENCE_VMA,
 ????? SBI_EXT_RFENCE_REMOTE_SFENCE_VMA_ASID,
+??? SBI_EXT_RFENCE_REMOTE_HFENCE_GVMA,
+??? SBI_EXT_RFENCE_REMOTE_HFENCE_GVMA_VMID,
+??? SBI_EXT_RFENCE_REMOTE_HFENCE_VVMA,
+??? SBI_EXT_RFENCE_REMOTE_HFENCE_VVMA_ASID,

Isn't this backwards? That is, we should have

Quoted 6 lines

+??? SBI_EXT_RFENCE_REMOTE_HFENCE_GVMA_VMID,
+??? SBI_EXT_RFENCE_REMOTE_HFENCE_GVMA,
+??? SBI_EXT_RFENCE_REMOTE_HFENCE_VVMA_ASID,
+??? SBI_EXT_RFENCE_REMOTE_HFENCE_VVMA,

so the FIDs match.

You are right. I should not have copied from Linux without checking.

Cf.
https://github.com/riscv/riscv-sbi-doc/blob/master/riscv-sbi.adoc#78-function-listing

Best regards

Heinrich

Quoted 38 lines

--Sean

Quoted 34 lines
arch/riscv/include/asm/sbi.h +28 -0
+};
+
+enum sbi_ext_hsm_fid {
+??? SBI_EXT_HSM_HART_START = 0,
+??? SBI_EXT_HSM_HART_STOP,
+??? SBI_EXT_HSM_HART_STATUS,
+};
+
+enum sbi_hsm_hart_status {
+??? SBI_HSM_HART_STATUS_STARTED = 0,
+??? SBI_HSM_HART_STATUS_STOPPED,
+??? SBI_HSM_HART_STATUS_START_PENDING,
+??? SBI_HSM_HART_STATUS_STOP_PENDING,
+};
+
+enum sbi_ext_srst_fid {
+??? SBI_EXT_SRST_RESET = 0,
+};
+
+enum sbi_srst_reset_type {
+??? SBI_SRST_RESET_TYPE_SHUTDOWN = 0,
+??? SBI_SRST_RESET_TYPE_COLD_REBOOT,
+??? SBI_SRST_RESET_TYPE_WARM_REBOOT,
+};
+
+enum sbi_srst_reset_reason {
+??? SBI_SRST_RESET_REASON_NONE = 0,
+??? SBI_SRST_RESET_REASON_SYS_FAILURE,
 ? };
 

? #ifdef CONFIG_SBI_V01
--
2.30.1

#4 lore raw

PATCH 1/5 risv: add missing SBI extension definitions

In reply to Heinrich Schuchardt
Quoted 9 lines · Heinrich Schuchardt

Add the System Reset Extension and the Hart State Management Extension definitions.

Add missing RFENCE Extension enum values.

The SBI 0.1 extension constants are needed for for the sbi command. Remove an #ifdef.

Quoted 7 lines

Cf. https://github.com/riscv/riscv-sbi-doc/blob/master/riscv-sbi.adoc

---
 arch/riscv/include/asm/sbi.h | 36 ++++++++++++++++++++++++++++++++++--
 1 file changed, 34 insertions(+), 2 deletions(-)

U-Boot does not need HSM.

Regards,
Bin

#5 lore raw

PATCH 1/5 risv: add missing SBI extension definitions

Quoted 12 lines · Bin Meng
Quoted 11 lines · Heinrich Schuchardt

Add the System Reset Extension and the Hart State Management Extension definitions.

Add missing RFENCE Extension enum values.

The SBI 0.1 extension constants are needed for for the sbi command. Remove an #ifdef.

Cf. https://github.com/riscv/riscv-sbi-doc/blob/master/riscv-sbi.adoc

Quoted 7 lines
Quoted 5 lines
---
  arch/riscv/include/asm/sbi.h | 36 ++++++++++++++++++++++++++++++++++--
  1 file changed, 34 insertions(+), 2 deletions(-)

U-Boot does not need HSM.

(yet)

As far as I can tell, it's completely conforming for all harts but one to be put into the STOPPED state by the SBI (with the expectation that U-Boot or something else start them). Also, while we currently figure out which harts to start via device tree passed from SBI, that behavior is not standardized. Going forward, I we may see some SBI implementations which communicate this sort of info through HSM. Though this has not happened yet...

--Sean

#6 lore raw

PATCH 2/5 cmd/sbi: use constants instead of numerical values

In reply to Heinrich Schuchardt

Use constants for extension IDs.

---
 cmd/riscv/sbi.c | 30 +++++++++++++++---------------
 1 file changed, 15 insertions(+), 15 deletions(-)
cmd/riscv/sbi.c +15 -15
index 90c0811e14..65a2c93290 100644
@@ -29,21 +29,21 @@ static struct sbi_imp implementations[] = {
 };
 
 static struct sbi_ext extensions[] = {
-	{ 0x00000000, "sbi_set_timer" },
-	{ 0x00000001, "sbi_console_putchar" },
-	{ 0x00000002, "sbi_console_getchar" },
-	{ 0x00000003, "sbi_clear_ipi" },
-	{ 0x00000004, "sbi_send_ipi" },
-	{ 0x00000005, "sbi_remote_fence_i" },
-	{ 0x00000006, "sbi_remote_sfence_vma" },
-	{ 0x00000007, "sbi_remote_sfence_vma_asid" },
-	{ 0x00000008, "sbi_shutdown" },
-	{ 0x00000010, "SBI Base Functionality" },
-	{ 0x54494D45, "Timer Extension" },
-	{ 0x00735049, "IPI Extension" },
-	{ 0x52464E43, "RFENCE Extension" },
-	{ 0x0048534D, "Hart State Management Extension" },
-	{ 0x53525354, "System Reset Extension" },
+	{ SBI_EXT_0_1_SET_TIMER,	      "sbi_set_timer" },
+	{ SBI_EXT_0_1_CONSOLE_PUTCHAR,	      "sbi_console_putchar" },
+	{ SBI_EXT_0_1_CONSOLE_GETCHAR,	      "sbi_console_getchar" },
+	{ SBI_EXT_0_1_CLEAR_IPI,	      "sbi_clear_ipi" },
+	{ SBI_EXT_0_1_SEND_IPI,		      "sbi_send_ipi" },
+	{ SBI_EXT_0_1_REMOTE_FENCE_I,	      "sbi_remote_fence_i" },
+	{ SBI_EXT_0_1_REMOTE_SFENCE_VMA,      "sbi_remote_sfence_vma" },
+	{ SBI_EXT_0_1_REMOTE_SFENCE_VMA_ASID, "sbi_remote_sfence_vma_asid" },
+	{ SBI_EXT_0_1_SHUTDOWN,		      "sbi_shutdown" },
+	{ SBI_EXT_BASE,			      "SBI Base Functionality" },
+	{ SBI_EXT_TIME,			      "Timer Extension" },
+	{ SBI_EXT_IPI,			      "IPI Extension" },
+	{ SBI_EXT_RFENCE,		      "RFENCE Extension" },
+	{ SBI_EXT_HSM,			      "Hart State Management Extension" },
+	{ SBI_EXT_SRST,			      "System Reset Extension" },
 };
 
 static int do_sbi(struct cmd_tbl *cmdtp, int flag, int argc,

--
2.30.1

#7 lore raw

PATCH 2/5 cmd/sbi: use constants instead of numerical values

Quoted 49 lines · Heinrich Schuchardt

Use constants for extension IDs.

---
  cmd/riscv/sbi.c | 30 +++++++++++++++---------------
  1 file changed, 15 insertions(+), 15 deletions(-)
cmd/riscv/sbi.c +15 -16
index 90c0811e14..65a2c93290 100644
@@ -29,21 +29,21 @@ static struct sbi_imp implementations[] = {
  };
 
  static struct sbi_ext extensions[] = {
-	{ 0x00000000, "sbi_set_timer" },
-	{ 0x00000001, "sbi_console_putchar" },
-	{ 0x00000002, "sbi_console_getchar" },
-	{ 0x00000003, "sbi_clear_ipi" },
-	{ 0x00000004, "sbi_send_ipi" },
-	{ 0x00000005, "sbi_remote_fence_i" },
-	{ 0x00000006, "sbi_remote_sfence_vma" },
-	{ 0x00000007, "sbi_remote_sfence_vma_asid" },
-	{ 0x00000008, "sbi_shutdown" },
-	{ 0x00000010, "SBI Base Functionality" },
-	{ 0x54494D45, "Timer Extension" },
-	{ 0x00735049, "IPI Extension" },
-	{ 0x52464E43, "RFENCE Extension" },
-	{ 0x0048534D, "Hart State Management Extension" },
-	{ 0x53525354, "System Reset Extension" },
+	{ SBI_EXT_0_1_SET_TIMER,	      "sbi_set_timer" },
+	{ SBI_EXT_0_1_CONSOLE_PUTCHAR,	      "sbi_console_putchar" },
+	{ SBI_EXT_0_1_CONSOLE_GETCHAR,	      "sbi_console_getchar" },
+	{ SBI_EXT_0_1_CLEAR_IPI,	      "sbi_clear_ipi" },
+	{ SBI_EXT_0_1_SEND_IPI,		      "sbi_send_ipi" },
+	{ SBI_EXT_0_1_REMOTE_FENCE_I,	      "sbi_remote_fence_i" },
+	{ SBI_EXT_0_1_REMOTE_SFENCE_VMA,      "sbi_remote_sfence_vma" },
+	{ SBI_EXT_0_1_REMOTE_SFENCE_VMA_ASID, "sbi_remote_sfence_vma_asid" },
+	{ SBI_EXT_0_1_SHUTDOWN,		      "sbi_shutdown" },
+	{ SBI_EXT_BASE,			      "SBI Base Functionality" },
+	{ SBI_EXT_TIME,			      "Timer Extension" },
+	{ SBI_EXT_IPI,			      "IPI Extension" },
+	{ SBI_EXT_RFENCE,		      "RFENCE Extension" },
+	{ SBI_EXT_HSM,			      "Hart State Management Extension" },
+	{ SBI_EXT_SRST,			      "System Reset Extension" },
  };
 
  static int do_sbi(struct cmd_tbl *cmdtp, int flag, int argc,
--
Quoted 2 lines

2.30.1

#8 lore raw

PATCH 2/5 cmd/sbi: use constants instead of numerical values

In reply to Heinrich Schuchardt
Quoted 49 lines · Heinrich Schuchardt

Use constants for extension IDs.

---
 cmd/riscv/sbi.c | 30 +++++++++++++++---------------
 1 file changed, 15 insertions(+), 15 deletions(-)
cmd/riscv/sbi.c +15 -16
index 90c0811e14..65a2c93290 100644
@@ -29,21 +29,21 @@ static struct sbi_imp implementations[] = {
 };
 
 static struct sbi_ext extensions[] = {
-	{ 0x00000000, "sbi_set_timer" },
-	{ 0x00000001, "sbi_console_putchar" },
-	{ 0x00000002, "sbi_console_getchar" },
-	{ 0x00000003, "sbi_clear_ipi" },
-	{ 0x00000004, "sbi_send_ipi" },
-	{ 0x00000005, "sbi_remote_fence_i" },
-	{ 0x00000006, "sbi_remote_sfence_vma" },
-	{ 0x00000007, "sbi_remote_sfence_vma_asid" },
-	{ 0x00000008, "sbi_shutdown" },
-	{ 0x00000010, "SBI Base Functionality" },
-	{ 0x54494D45, "Timer Extension" },
-	{ 0x00735049, "IPI Extension" },
-	{ 0x52464E43, "RFENCE Extension" },
-	{ 0x0048534D, "Hart State Management Extension" },
-	{ 0x53525354, "System Reset Extension" },
+	{ SBI_EXT_0_1_SET_TIMER,	      "sbi_set_timer" },
+	{ SBI_EXT_0_1_CONSOLE_PUTCHAR,	      "sbi_console_putchar" },
+	{ SBI_EXT_0_1_CONSOLE_GETCHAR,	      "sbi_console_getchar" },
+	{ SBI_EXT_0_1_CLEAR_IPI,	      "sbi_clear_ipi" },
+	{ SBI_EXT_0_1_SEND_IPI,		      "sbi_send_ipi" },
+	{ SBI_EXT_0_1_REMOTE_FENCE_I,	      "sbi_remote_fence_i" },
+	{ SBI_EXT_0_1_REMOTE_SFENCE_VMA,      "sbi_remote_sfence_vma" },
+	{ SBI_EXT_0_1_REMOTE_SFENCE_VMA_ASID, "sbi_remote_sfence_vma_asid" },
+	{ SBI_EXT_0_1_SHUTDOWN,		      "sbi_shutdown" },
+	{ SBI_EXT_BASE,			      "SBI Base Functionality" },
+	{ SBI_EXT_TIME,			      "Timer Extension" },
+	{ SBI_EXT_IPI,			      "IPI Extension" },
+	{ SBI_EXT_RFENCE,		      "RFENCE Extension" },
+	{ SBI_EXT_HSM,			      "Hart State Management Extension" },
+	{ SBI_EXT_SRST,			      "System Reset Extension" },
 };
 
 static int do_sbi(struct cmd_tbl *cmdtp, int flag, int argc,
--
Quoted 2 lines

2.30.1

#9 lore raw

PATCH 3/5 sysreset: provide SBI based sysreset driver

In reply to Heinrich Schuchardt

Provide sysreset driver using the SBI system reset extension.

---
 MAINTAINERS                     |   1 +
 arch/riscv/include/asm/sbi.h    |   1 +
 arch/riscv/lib/sbi.c            |  21 +++++--
 drivers/sysreset/Kconfig        |  11 ++++
 drivers/sysreset/Makefile       |   1 +
 drivers/sysreset/sysreset_sbi.c | 102 ++++++++++++++++++++++++++++++++
 lib/efi_loader/Kconfig          |   2 +-
 7 files changed, 134 insertions(+), 5 deletions(-)
 create mode 100644 drivers/sysreset/sysreset_sbi.c
MAINTAINERS +1 -0
index de499940e5..192db06ff9 100644
@@ -985,6 +985,7 @@ T:	git https://source.denx.de/u-boot/custodians/u-boot-riscv.git
 F:	arch/riscv/
 F:	cmd/riscv/
 F:	doc/usage/sbi.rst
+F:	drivers/sysreset/sysreset_sbi.c
 F:	drivers/timer/andes_plmt_timer.c
 F:	drivers/timer/sifive_clint_timer.c
 F:	tools/prelink-riscv.c
arch/riscv/include/asm/sbi.h +1 -0
index c598bb11ce..058e2e23a8 100644
@@ -150,5 +150,6 @@ void sbi_set_timer(uint64_t stime_value);
 long sbi_get_spec_version(void);
 int sbi_get_impl_id(void);
 int sbi_probe_extension(int ext);
+void sbi_srst_reset(unsigned long type, unsigned long reason);
 
 #endif
arch/riscv/lib/sbi.c +17 -4
index 77845a73ca..8508041f2a 100644
@@ -8,13 +8,14 @@
  */
 
 #include <common.h>
+#include <efi_loader.h>
 #include <asm/encoding.h>
 #include <asm/sbi.h>
 
-struct sbiret sbi_ecall(int ext, int fid, unsigned long arg0,
-			unsigned long arg1, unsigned long arg2,
-			unsigned long arg3, unsigned long arg4,
-			unsigned long arg5)
+struct sbiret __efi_runtime sbi_ecall(int ext, int fid, unsigned long arg0,
+				      unsigned long arg1, unsigned long arg2,
+				      unsigned long arg3, unsigned long arg4,
+				      unsigned long arg5)
 {
 	struct sbiret ret;
 
@@ -108,6 +109,18 @@ int sbi_probe_extension(int extid)
 	return -ENOTSUPP;
 }
 
+/**
+ * sbi_srst_reset() - invoke system reset extension
+ *
+ * @type:	type of reset
+ * @reason:	reason for reset
+ */
+void __efi_runtime sbi_srst_reset(unsigned long type, unsigned long reason)
+{
+	sbi_ecall(SBI_EXT_SRST, SBI_EXT_SRST_RESET, type, reason,
+		  0, 0, 0, 0);
+}
+
 #ifdef CONFIG_SBI_V01
 
 /**
drivers/sysreset/Kconfig +11 -0
index 0e5c7c9971..05a7e26300 100644
@@ -79,6 +79,17 @@ config SYSRESET_PSCI
 	  Enable PSCI SYSTEM_RESET function call.  To use this, PSCI firmware
 	  must be running on your system.
 
+config SYSRESET_SBI
+	bool "Enable support for SBI System Reset"
+	depends on RISCV_SMODE && SBI_V02
+	select SYSRESET_CMD_POWEROFF if CMD_POWEROFF
+	help
+	  Enable system reset and poweroff via the SBI system reset extension.
+	  If the SBI implemention provides the extension, is board specific.
+	  The extension was introduced in version 0.3 of the SBI specification.
+	  The SBI system reset driver supports the UEFI ResetSystem() service
+	  at runtime.
+
 config SYSRESET_SOCFPGA
 	bool "Enable support for Intel SOCFPGA family"
 	depends on ARCH_SOCFPGA && (TARGET_SOCFPGA_GEN5 || TARGET_SOCFPGA_ARRIA10)
drivers/sysreset/Makefile +1 -0
index de81c399d7..8e00be0779 100644
@@ -13,6 +13,7 @@ obj-$(CONFIG_SYSRESET_MPC83XX) += sysreset_mpc83xx.o
 obj-$(CONFIG_SYSRESET_MICROBLAZE) += sysreset_microblaze.o
 obj-$(CONFIG_SYSRESET_OCTEON) += sysreset_octeon.o
 obj-$(CONFIG_SYSRESET_PSCI) += sysreset_psci.o
+obj-$(CONFIG_SYSRESET_SBI) += sysreset_sbi.o
 obj-$(CONFIG_SYSRESET_SOCFPGA) += sysreset_socfpga.o
 obj-$(CONFIG_SYSRESET_SOCFPGA_SOC64) += sysreset_socfpga_soc64.o
 obj-$(CONFIG_SYSRESET_TI_SCI) += sysreset-ti-sci.o
drivers/sysreset/sysreset_sbi.c new file +102 -0

102 lines not on this page · raw message

lib/efi_loader/Kconfig +1 -1
index e729f727df..7e76435339 100644
@@ -277,7 +277,7 @@ config EFI_HAVE_RUNTIME_RESET
 	bool
 	default y
 	depends on ARCH_BCM283X || FSL_LAYERSCAPE || PSCI_RESET || \
-		   SANDBOX || SYSRESET_X86
+		   SANDBOX || SYSRESET_SBI || SYSRESET_X86
 
 config EFI_GRUB_ARM32_WORKAROUND
 	bool "Workaround for GRUB on 32bit ARM"

--
2.30.1

#10 lore raw

PATCH 3/5 sysreset: provide SBI based sysreset driver

Quoted 130 lines · Heinrich Schuchardt

Provide sysreset driver using the SBI system reset extension.

---
  MAINTAINERS                     |   1 +
  arch/riscv/include/asm/sbi.h    |   1 +
  arch/riscv/lib/sbi.c            |  21 +++++--
  drivers/sysreset/Kconfig        |  11 ++++
  drivers/sysreset/Makefile       |   1 +
  drivers/sysreset/sysreset_sbi.c | 102 ++++++++++++++++++++++++++++++++
  lib/efi_loader/Kconfig          |   2 +-
  7 files changed, 134 insertions(+), 5 deletions(-)

create mode 100644 drivers/sysreset/sysreset_sbi.c

MAINTAINERS +1 -0
index de499940e5..192db06ff9 100644
@@ -985,6 +985,7 @@ T:	git https://source.denx.de/u-boot/custodians/u-boot-riscv.git
  F:	arch/riscv/
  F:	cmd/riscv/
  F:	doc/usage/sbi.rst
+F:	drivers/sysreset/sysreset_sbi.c
  F:	drivers/timer/andes_plmt_timer.c
  F:	drivers/timer/sifive_clint_timer.c
  F:	tools/prelink-riscv.c
arch/riscv/include/asm/sbi.h +1 -0
index c598bb11ce..058e2e23a8 100644
@@ -150,5 +150,6 @@ void sbi_set_timer(uint64_t stime_value);
  long sbi_get_spec_version(void);
  int sbi_get_impl_id(void);
  int sbi_probe_extension(int ext);
+void sbi_srst_reset(unsigned long type, unsigned long reason);
 
  #endif
arch/riscv/lib/sbi.c +17 -4
index 77845a73ca..8508041f2a 100644
@@ -8,13 +8,14 @@
   */
 
  #include <common.h>
+#include <efi_loader.h>
  #include <asm/encoding.h>
  #include <asm/sbi.h>
 
-struct sbiret sbi_ecall(int ext, int fid, unsigned long arg0,
-			unsigned long arg1, unsigned long arg2,
-			unsigned long arg3, unsigned long arg4,
-			unsigned long arg5)
+struct sbiret __efi_runtime sbi_ecall(int ext, int fid, unsigned long arg0,
+				      unsigned long arg1, unsigned long arg2,
+				      unsigned long arg3, unsigned long arg4,
+				      unsigned long arg5)
  {
  	struct sbiret ret;
 
@@ -108,6 +109,18 @@ int sbi_probe_extension(int extid)
  	return -ENOTSUPP;
  }
 
+/**
+ * sbi_srst_reset() - invoke system reset extension
+ *
+ * @type:	type of reset
+ * @reason:	reason for reset
+ */
+void __efi_runtime sbi_srst_reset(unsigned long type, unsigned long reason)
+{
+	sbi_ecall(SBI_EXT_SRST, SBI_EXT_SRST_RESET, type, reason,
+		  0, 0, 0, 0);
+}
+
  #ifdef CONFIG_SBI_V01
 
  /**
drivers/sysreset/Kconfig +11 -0
index 0e5c7c9971..05a7e26300 100644
@@ -79,6 +79,17 @@ config SYSRESET_PSCI
  	  Enable PSCI SYSTEM_RESET function call.  To use this, PSCI firmware
  	  must be running on your system.
 
+config SYSRESET_SBI
+	bool "Enable support for SBI System Reset"
+	depends on RISCV_SMODE && SBI_V02
+	select SYSRESET_CMD_POWEROFF if CMD_POWEROFF
+	help
+	  Enable system reset and poweroff via the SBI system reset extension.
+	  If the SBI implemention provides the extension, is board specific.
+	  The extension was introduced in version 0.3 of the SBI specification.
+	  The SBI system reset driver supports the UEFI ResetSystem() service
+	  at runtime.
+
  config SYSRESET_SOCFPGA
  	bool "Enable support for Intel SOCFPGA family"
  	depends on ARCH_SOCFPGA && (TARGET_SOCFPGA_GEN5 || TARGET_SOCFPGA_ARRIA10)
drivers/sysreset/Makefile +1 -0
index de81c399d7..8e00be0779 100644
@@ -13,6 +13,7 @@ obj-$(CONFIG_SYSRESET_MPC83XX) += sysreset_mpc83xx.o
  obj-$(CONFIG_SYSRESET_MICROBLAZE) += sysreset_microblaze.o
  obj-$(CONFIG_SYSRESET_OCTEON) += sysreset_octeon.o
  obj-$(CONFIG_SYSRESET_PSCI) += sysreset_psci.o
+obj-$(CONFIG_SYSRESET_SBI) += sysreset_sbi.o
  obj-$(CONFIG_SYSRESET_SOCFPGA) += sysreset_socfpga.o
  obj-$(CONFIG_SYSRESET_SOCFPGA_SOC64) += sysreset_socfpga_soc64.o
  obj-$(CONFIG_SYSRESET_TI_SCI) += sysreset-ti-sci.o
drivers/sysreset/sysreset_sbi.c new file +11 -0
new file mode 100644
index 0000000000..87fbc3ea3e
@@ -0,0 +1,102 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2021, Heinrich Schuchardt <[email protected]>
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <errno.h>
+#include <efi_loader.h>
+#include <log.h>
+#include <sysreset.h>

drivers/sysreset/sysreset_sbi.c line 21

Quoted 10 lines
drivers/sysreset/sysreset_sbi.c new file +10 -0
+#include <asm/sbi.h>
+
+static long __efi_runtime_data have_reset;
+
+static int sbi_sysreset_request(struct udevice *dev, enum sysreset_t type)
+{
+	enum sbi_srst_reset_type reset_type;
+
+	if (!have_reset)
+		return -ENOENT;

Is this necessary? This should never be called if there is no reset, since we just fail to probe.

Quoted 20 lines
drivers/sysreset/sysreset_sbi.c new file +20 -0
+
+	switch (type) {
+	case SYSRESET_WARM:
+		reset_type = SBI_SRST_RESET_TYPE_WARM_REBOOT;
+		break;
+	case SYSRESET_COLD:
+		reset_type = SBI_SRST_RESET_TYPE_COLD_REBOOT;
+		break;
+	case SYSRESET_POWER_OFF:
+		reset_type = SBI_SRST_RESET_TYPE_SHUTDOWN;
+		break;
+	default:
+		log_err("SBI has no system reset extension\n");
+		return -ENOSYS;
+	}
+
+	sbi_srst_reset(reset_type, SBI_SRST_RESET_REASON_NONE);
+
+	return -EINPROGRESS;
+}

drivers/sysreset/sysreset_sbi.c line 51

Quoted 10 lines
drivers/sysreset/sysreset_sbi.c new file +10 -0
+
+efi_status_t efi_reset_system_init(void)
+{
+	return EFI_SUCCESS;
+}
+
+void __efi_runtime EFIAPI efi_reset_system(enum efi_reset_type type,
+					   efi_status_t reset_status,
+					   unsigned long data_size,
+					   void *reset_data)

As an aside, is there a reason why the generic (weak) efi_reset_system does not just call sysreset_walk_halt(type)?

Quoted 6 lines
drivers/sysreset/sysreset_sbi.c new file +6 -0
+{
+	enum sbi_srst_reset_type reset_type;
+
+	if (have_reset)
+		switch (type) {
+		case SYSRESET_WARM:

drivers/sysreset/sysreset_sbi.c line 67

Quoted 10 lines
drivers/sysreset/sysreset_sbi.c new file +10 -0
+			reset_type = SBI_SRST_RESET_TYPE_WARM_REBOOT;
+			break;
+		case SYSRESET_COLD:
+			reset_type = SBI_SRST_RESET_TYPE_COLD_REBOOT;
+			break;
+		case SYSRESET_POWER_OFF:
+			reset_type = SBI_SRST_RESET_TYPE_SHUTDOWN;
+			break;
+		default:
+			goto hang;

Why do we hang by default? For comparison, sysreset_x86 has

	if (reset_type == EFI_RESET_COLD ||
		 reset_type == EFI_RESET_PLATFORM_SPECIFIC)
		value = SYS_RST | RST_CPU | FULL_RST;
	else /* assume EFI_RESET_WARM since we cannot return an error */
		value = SYS_RST | RST_CPU;

drivers/sysreset/sysreset_sbi.c line 38

Quoted 3 lines
drivers/sysreset/sysreset_sbi.c new file +3 -0
+	}
+
+	sbi_srst_reset(reset_type, SBI_SRST_RESET_REASON_NONE);

Should we instead do

	enum sbi_srst_reset_reason reset_reason;
	if (reset_status == EFI_SUCCESS)
		reset_reason = SBI_SRST_RESET_REASON_NONE;
	else
		reset_reason = SBI_SRST_RESET_REASON_SYS_FAILURE;
	sbi_srst_reset(reset_type, reset_status == EFI_SUCCESS ? SBI_SRST_RESET_REASON_NONE : SBI_SRST_RESET_REASON_SYS_FAILURE);

since we have reset status available?

drivers/sysreset/sysreset_sbi.c line 83

Quoted 13 lines
drivers/sysreset/sysreset_sbi.c new file +13 -0
+
+hang:
+	while (1)
+		;
+}
+
+static int sbi_sysreset_probe(struct udevice *dev)
+{
+	have_reset = sbi_probe_extension(SBI_EXT_SRST);
+	if (have_reset)
+		return 0;
+
+	log_err("SBI has no system reset extension\n");

Is this an error? It's perfectly normal for SBI implementations to lack support for some extensions. Perhaps a warning/info would be better.

drivers/sysreset/sysreset_sbi.c line 88

Quoted 5 lines
drivers/sysreset/sysreset_sbi.c new file +5 -0
+	return -ENOENT;
+}
+
+static const struct udevice_id sbi_sysreset_ids[] = {
+	{ .compatible = "riscv" },

This compatible string is already in-use for RISC-V CPUs. And if this isn't supposed to have a device tree binding, do we even need of_match?

Quoted 19 lines
drivers/sysreset/sysreset_sbi.c new file +14 -0
+	{ }
+};
+
+static struct sysreset_ops sbi_sysreset_ops = {
+	.request = sbi_sysreset_request,
+};
+
+U_BOOT_DRIVER(sbi_sysreset) = {
+	.name = "sbi-sysreset",
+	.id = UCLASS_SYSRESET,
+	.of_match = sbi_sysreset_ids,
+	.ops = &sbi_sysreset_ops,
+	.probe = sbi_sysreset_probe,
+};
lib/efi_loader/Kconfig +0 -0
index e729f727df..7e76435339 100644

lib/efi_loader/Kconfig config EFI_HAVE_RUNTIME_RESET · line 280

Quoted 5 lines
lib/efi_loader/Kconfig +1 -1
@@ -277,7 +277,7 @@ config EFI_HAVE_RUNTIME_RESET
  	bool
  	default y
  	depends on ARCH_BCM283X || FSL_LAYERSCAPE || PSCI_RESET || \
-		   SANDBOX || SYSRESET_X86
+		   SANDBOX || SYSRESET_SBI || SYSRESET_X86

As a general note, perhaps it is better to set this from other Kconfigs? How long will this list get?

--Sean

Quoted 6 lines
lib/efi_loader/Kconfig +0 -1
  config EFI_GRUB_ARM32_WORKAROUND
  	bool "Workaround for GRUB on 32bit ARM"
--

2.30.1

#11 lore raw

PATCH 3/5 sysreset: provide SBI based sysreset driver

Quoted 146 lines · Sean Anderson
Quoted 145 lines · Heinrich Schuchardt

Provide sysreset driver using the SBI system reset extension.

---

? MAINTAINERS???????????????????? |?? 1 +
? arch/riscv/include/asm/sbi.h??? |?? 1 +
? arch/riscv/lib/sbi.c??????????? |? 21 +++++--
? drivers/sysreset/Kconfig??????? |? 11 ++++
? drivers/sysreset/Makefile?????? |?? 1 +
? drivers/sysreset/sysreset_sbi.c | 102 ++++++++++++++++++++++++++++++++
? lib/efi_loader/Kconfig????????? |?? 2 +-

? 7 files changed, 134 insertions(+), 5 deletions(-) ? create mode 100644 drivers/sysreset/sysreset_sbi.c

MAINTAINERS +0 -0
index de499940e5..192db06ff9 100644
@@ -985,6 +985,7 @@ T:??? git

https://source.denx.de/u-boot/custodians/u-boot-riscv.git
? F:??? arch/riscv/
? F:??? cmd/riscv/
? F:??? doc/usage/sbi.rst
+F:??? drivers/sysreset/sysreset_sbi.c
? F:??? drivers/timer/andes_plmt_timer.c
? F:??? drivers/timer/sifive_clint_timer.c
? F:??? tools/prelink-riscv.c

arch/riscv/include/asm/sbi.h +1 -0
index c598bb11ce..058e2e23a8 100644
@@ -150,5 +150,6 @@ void sbi_set_timer(uint64_t stime_value);
 ? long sbi_get_spec_version(void);
 ? int sbi_get_impl_id(void);
 ? int sbi_probe_extension(int ext);
+void sbi_srst_reset(unsigned long type, unsigned long reason);
 

? #endif

arch/riscv/lib/sbi.c +0 -0
index 77845a73ca..8508041f2a 100644
@@ -8,13 +8,14 @@

?? */

? #include <common.h>
+#include <efi_loader.h>
? #include <asm/encoding.h>
? #include <asm/sbi.h>

arch/riscv/lib/sbi.c +1 -4
-struct sbiret sbi_ecall(int ext, int fid, unsigned long arg0,
-??????????? unsigned long arg1, unsigned long arg2,
-??????????? unsigned long arg3, unsigned long arg4,
-??????????? unsigned long arg5)
+struct sbiret __efi_runtime sbi_ecall(int ext, int fid, unsigned long

arg0,
+????????????????????? unsigned long arg1, unsigned long arg2, +????????????????????? unsigned long arg3, unsigned long arg4, +????????????????????? unsigned long arg5)
? {
????? struct sbiret ret;

arch/riscv/lib/sbi.c +12 -0
@@ -108,6 +109,18 @@ int sbi_probe_extension(int extid)
 ????? return -ENOTSUPP;
 ? }
 
+/**
+ * sbi_srst_reset() - invoke system reset extension
+ *
+ * @type:??? type of reset
+ * @reason:??? reason for reset
+ */
+void __efi_runtime sbi_srst_reset(unsigned long type, unsigned long
 reason)
+{
+??? sbi_ecall(SBI_EXT_SRST, SBI_EXT_SRST_RESET, type, reason,
+????????? 0, 0, 0, 0);
+}
+

? #ifdef CONFIG_SBI_V01

? /**

drivers/sysreset/Kconfig +0 -0
index 0e5c7c9971..05a7e26300 100644
@@ -79,6 +79,17 @@ config SYSRESET_PSCI

??????? Enable PSCI SYSTEM_RESET function call.? To use this, PSCI firmware
??????? must be running on your system.

+config SYSRESET_SBI
+??? bool "Enable support for SBI System Reset"
+??? depends on RISCV_SMODE && SBI_V02
+??? select SYSRESET_CMD_POWEROFF if CMD_POWEROFF
+??? help
+????? Enable system reset and poweroff via the SBI system reset extension.
+????? If the SBI implemention provides the extension, is board specific. +????? The extension was introduced in version 0.3 of the SBI specification.
+????? The SBI system reset driver supports the UEFI ResetSystem() service
+????? at runtime.
+
? config SYSRESET_SOCFPGA
????? bool "Enable support for Intel SOCFPGA family"
????? depends on ARCH_SOCFPGA && (TARGET_SOCFPGA_GEN5 || TARGET_SOCFPGA_ARRIA10)

drivers/sysreset/Makefile +0 -0
index de81c399d7..8e00be0779 100644
@@ -13,6 +13,7 @@ obj-$(CONFIG_SYSRESET_MPC83XX) += sysreset_mpc83xx.o

? obj-$(CONFIG_SYSRESET_MICROBLAZE) += sysreset_microblaze.o ? obj-$(CONFIG_SYSRESET_OCTEON) += sysreset_octeon.o
? obj-$(CONFIG_SYSRESET_PSCI) += sysreset_psci.o +obj-$(CONFIG_SYSRESET_SBI) += sysreset_sbi.o
? obj-$(CONFIG_SYSRESET_SOCFPGA) += sysreset_socfpga.o ? obj-$(CONFIG_SYSRESET_SOCFPGA_SOC64) += sysreset_socfpga_soc64.o ? obj-$(CONFIG_SYSRESET_TI_SCI) += sysreset-ti-sci.o

drivers/sysreset/sysreset_sbi.c new file +16 -0
new file mode 100644
index 0000000000..87fbc3ea3e
@@ -0,0 +1,102 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2021, Heinrich Schuchardt <[email protected]>
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <errno.h>
+#include <efi_loader.h>
+#include <log.h>
+#include <sysreset.h>
+#include <asm/sbi.h>
+
+static long __efi_runtime_data have_reset;
+
+static int sbi_sysreset_request(struct udevice *dev, enum sysreset_t

type)

Quoted 8 lines

drivers/sysreset/sysreset_sbi.c

Quoted 5 lines
drivers/sysreset/sysreset_sbi.c new file +5 -0
+{
+??? enum sbi_srst_reset_type reset_type;
+
+??? if (!have_reset)
+??????? return -ENOENT;

Is this necessary? This should never be called if there is no reset, since we just fail to probe.

Thank you for reviewing.

Yes, we can skip it.

Quoted 26 lines
Quoted 26 lines
drivers/sysreset/sysreset_sbi.c new file +25 -0
+
+??? switch (type) {
+??? case SYSRESET_WARM:
+??????? reset_type = SBI_SRST_RESET_TYPE_WARM_REBOOT;
+??????? break;
+??? case SYSRESET_COLD:
+??????? reset_type = SBI_SRST_RESET_TYPE_COLD_REBOOT;
+??????? break;
+??? case SYSRESET_POWER_OFF:
+??????? reset_type = SBI_SRST_RESET_TYPE_SHUTDOWN;
+??????? break;
+??? default:
+??????? log_err("SBI has no system reset extension\n");
+??????? return -ENOSYS;
+??? }
+
+??? sbi_srst_reset(reset_type, SBI_SRST_RESET_REASON_NONE);
+
+??? return -EINPROGRESS;
+}
+
+efi_status_t efi_reset_system_init(void)
+{
+??? return EFI_SUCCESS;
+}
Quoted 8 lines

drivers/sysreset/sysreset_sbi.c

Quoted 5 lines
drivers/sysreset/sysreset_sbi.c new file +5 -0
+
+void __efi_runtime EFIAPI efi_reset_system(enum efi_reset_type type,
+?????????????????????? efi_status_t reset_status,
+?????????????????????? unsigned long data_size,
+?????????????????????? void *reset_data)

As an aside, is there a reason why the generic (weak) efi_reset_system does not just call sysreset_walk_halt(type)?

efi_reset_system is invoked at UEFI runtime. Most functions of U-Boot are no longer in memory after ExitBootServices(). Only functions in the __efi_runtime section may be called.

Quoted 20 lines
Quoted 7 lines
drivers/sysreset/sysreset_sbi.c new file +6 -0
+{
+??? enum sbi_srst_reset_type reset_type;
+
+??? if (have_reset)
+??????? switch (type) {
+??????? case SYSRESET_WARM:

drivers/sysreset/sysreset_sbi.c

Quoted 10 lines
drivers/sysreset/sysreset_sbi.c new file +10 -0
+??????????? reset_type = SBI_SRST_RESET_TYPE_WARM_REBOOT;
+??????????? break;
+??????? case SYSRESET_COLD:
+??????????? reset_type = SBI_SRST_RESET_TYPE_COLD_REBOOT;
+??????????? break;
+??????? case SYSRESET_POWER_OFF:
+??????????? reset_type = SBI_SRST_RESET_TYPE_SHUTDOWN;
+??????????? break;
+??????? default:
+??????????? goto hang;

Why do we hang by default? For comparison, sysreset_x86 has

Quoted 5 lines

????if (reset_type == EFI_RESET_COLD ||
???????? reset_type == EFI_RESET_PLATFORM_SPECIFIC) ??????? value = SYS_RST | RST_CPU | FULL_RST;
????else /* assume EFI_RESET_WARM since we cannot return an error */ ??????? value = SYS_RST | RST_CPU;

ok

Quoted 15 lines
Quoted 4 lines

+??? }
+
+??? sbi_srst_reset(reset_type, SBI_SRST_RESET_REASON_NONE);

Should we instead do

????enum sbi_srst_reset_reason reset_reason;
????if (reset_status == EFI_SUCCESS)
??????? reset_reason = SBI_SRST_RESET_REASON_NONE; ????else
??????? reset_reason = SBI_SRST_RESET_REASON_SYS_FAILURE; ????sbi_srst_reset(reset_type, reset_status == EFI_SUCCESS ?
SBI_SRST_RESET_REASON_NONE : SBI_SRST_RESET_REASON_SYS_FAILURE);

Quoted 1 line

since we have reset status available?

Makes sense.

Quoted 17 lines
Quoted 4 lines
drivers/sysreset/sysreset_sbi.c new file +3 -0
+
+hang:
+??? while (1)

drivers/sysreset/sysreset_sbi.c

Quoted 10 lines
drivers/sysreset/sysreset_sbi.c new file +10 -0
+??????? ;
+}
+
+static int sbi_sysreset_probe(struct udevice *dev)
+{
+??? have_reset = sbi_probe_extension(SBI_EXT_SRST);
+??? if (have_reset)
+??????? return 0;
+
+??? log_err("SBI has no system reset extension\n");

Is this an error? It's perfectly normal for SBI implementations to lack support for some extensions. Perhaps a warning/info would be better.

We shouldn't have chosen this driver in the configuration if the SBI does not support it.

I will change this to a warning.

Quoted 9 lines

drivers/sysreset/sysreset_sbi.c

Quoted 6 lines

+??? return -ENOENT;

drivers/sysreset/sysreset_sbi.c new file +4 -0
+}
+
+static const struct udevice_id sbi_sysreset_ids[] = {
+??? { .compatible = "riscv" },

This compatible string is already in-use for RISC-V CPUs. And if this isn't supposed to have a device tree binding, do we even need of_match?

I discussed this with Simon in

https://lists.denx.de/pipermail/u-boot/2021-March/443270.html

Instead of adding code to the board files we should have a device-tree node. A reasonable compatible string would be "riscv,sbi-sysreset".

Quoted 20 lines
Quoted 20 lines

+??? { }

drivers/sysreset/sysreset_sbi.c new file +13 -0
+};
+
+static struct sysreset_ops sbi_sysreset_ops = {
+??? .request = sbi_sysreset_request,
+};
+
+U_BOOT_DRIVER(sbi_sysreset) = {
+??? .name = "sbi-sysreset",
+??? .id = UCLASS_SYSRESET,
+??? .of_match = sbi_sysreset_ids,
+??? .ops = &sbi_sysreset_ops,
+??? .probe = sbi_sysreset_probe,
+};
lib/efi_loader/Kconfig +0 -0
index e729f727df..7e76435339 100644
@@ -277,7 +277,7 @@ config EFI_HAVE_RUNTIME_RESET
Quoted 8 lines
Quoted 5 lines

????? bool
????? default y
????? depends on ARCH_BCM283X || FSL_LAYERSCAPE || PSCI_RESET || \

-?????????? SANDBOX || SYSRESET_X86
+?????????? SANDBOX || SYSRESET_SBI || SYSRESET_X86

As a general note, perhaps it is better to set this from other Kconfigs? How long will this list get?

This seems to be a matter of taste.

Best regards

Heinrich

Quoted 10 lines

--Sean

Quoted 6 lines

? config EFI_GRUB_ARM32_WORKAROUND
????? bool "Workaround for GRUB on 32bit ARM"
--
2.30.1

#12 lore raw

PATCH 3/5 sysreset: provide SBI based sysreset driver

Quoted 264 lines · Heinrich Schuchardt
Quoted 146 lines · Sean Anderson
Quoted 145 lines · Heinrich Schuchardt

Provide sysreset driver using the SBI system reset extension.

---
  MAINTAINERS                     |   1 +
  arch/riscv/include/asm/sbi.h    |   1 +
  arch/riscv/lib/sbi.c            |  21 +++++--
  drivers/sysreset/Kconfig        |  11 ++++
  drivers/sysreset/Makefile       |   1 +
  drivers/sysreset/sysreset_sbi.c | 102 ++++++++++++++++++++++++++++++++
  lib/efi_loader/Kconfig          |   2 +-
  7 files changed, 134 insertions(+), 5 deletions(-)

create mode 100644 drivers/sysreset/sysreset_sbi.c

MAINTAINERS +0 -0
index de499940e5..192db06ff9 100644
@@ -985,6 +985,7 @@ T:    git

https://source.denx.de/u-boot/custodians/u-boot-riscv.git

  F:    arch/riscv/
  F:    cmd/riscv/
  F:    doc/usage/sbi.rst
MAINTAINERS +1 -0
+F:    drivers/sysreset/sysreset_sbi.c
  F:    drivers/timer/andes_plmt_timer.c
  F:    drivers/timer/sifive_clint_timer.c
  F:    tools/prelink-riscv.c
arch/riscv/include/asm/sbi.h +1 -0
index c598bb11ce..058e2e23a8 100644
@@ -150,5 +150,6 @@ void sbi_set_timer(uint64_t stime_value);
  long sbi_get_spec_version(void);
  int sbi_get_impl_id(void);
  int sbi_probe_extension(int ext);
+void sbi_srst_reset(unsigned long type, unsigned long reason);
 
  #endif
arch/riscv/lib/sbi.c +17 -4
index 77845a73ca..8508041f2a 100644
@@ -8,13 +8,14 @@
   */
 
  #include <common.h>
+#include <efi_loader.h>
  #include <asm/encoding.h>
  #include <asm/sbi.h>
 
-struct sbiret sbi_ecall(int ext, int fid, unsigned long arg0,
-            unsigned long arg1, unsigned long arg2,
-            unsigned long arg3, unsigned long arg4,
-            unsigned long arg5)
+struct sbiret __efi_runtime sbi_ecall(int ext, int fid, unsigned long
 arg0,
+                      unsigned long arg1, unsigned long arg2,
+                      unsigned long arg3, unsigned long arg4,
+                      unsigned long arg5)
  {
      struct sbiret ret;
@@ -108,6 +109,18 @@ int sbi_probe_extension(int extid)
      return -ENOTSUPP;
  }
 
+/**
+ * sbi_srst_reset() - invoke system reset extension
+ *
+ * @type:    type of reset
+ * @reason:    reason for reset
+ */
+void __efi_runtime sbi_srst_reset(unsigned long type, unsigned long
 reason)
+{
+    sbi_ecall(SBI_EXT_SRST, SBI_EXT_SRST_RESET, type, reason,
+          0, 0, 0, 0);
+}
+
  #ifdef CONFIG_SBI_V01
 

/**

drivers/sysreset/Kconfig +0 -0
index 0e5c7c9971..05a7e26300 100644
@@ -79,6 +79,17 @@ config SYSRESET_PSCI
        Enable PSCI SYSTEM_RESET function call.  To use this, PSCI

firmware
must be running on your system.

drivers/sysreset/Kconfig +6 -0
+config SYSRESET_SBI
+    bool "Enable support for SBI System Reset"
+    depends on RISCV_SMODE && SBI_V02
+    select SYSRESET_CMD_POWEROFF if CMD_POWEROFF
+    help
+      Enable system reset and poweroff via the SBI system reset

extension.

drivers/sysreset/Kconfig +2 -0
+      If the SBI implemention provides the extension, is board specific.
+      The extension was introduced in version 0.3 of the SBI

specification.
+ The SBI system reset driver supports the UEFI ResetSystem()
service

drivers/sysreset/Kconfig +2 -0
+      at runtime.
+
  config SYSRESET_SOCFPGA
      bool "Enable support for Intel SOCFPGA family"
      depends on ARCH_SOCFPGA && (TARGET_SOCFPGA_GEN5 ||

TARGET_SOCFPGA_ARRIA10)

drivers/sysreset/Makefile +1 -0
index de81c399d7..8e00be0779 100644
@@ -13,6 +13,7 @@ obj-$(CONFIG_SYSRESET_MPC83XX) += sysreset_mpc83xx.o
  obj-$(CONFIG_SYSRESET_MICROBLAZE) += sysreset_microblaze.o
  obj-$(CONFIG_SYSRESET_OCTEON) += sysreset_octeon.o
  obj-$(CONFIG_SYSRESET_PSCI) += sysreset_psci.o
+obj-$(CONFIG_SYSRESET_SBI) += sysreset_sbi.o
  obj-$(CONFIG_SYSRESET_SOCFPGA) += sysreset_socfpga.o
  obj-$(CONFIG_SYSRESET_SOCFPGA_SOC64) += sysreset_socfpga_soc64.o
  obj-$(CONFIG_SYSRESET_TI_SCI) += sysreset-ti-sci.o
drivers/sysreset/sysreset_sbi.c new file +16 -0
new file mode 100644
index 0000000000..87fbc3ea3e
@@ -0,0 +1,102 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2021, Heinrich Schuchardt <[email protected]>
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <errno.h>
+#include <efi_loader.h>
+#include <log.h>
+#include <sysreset.h>
+#include <asm/sbi.h>
+
+static long __efi_runtime_data have_reset;
+
+static int sbi_sysreset_request(struct udevice *dev, enum sysreset_t

type)

Quoted 8 lines

drivers/sysreset/sysreset_sbi.c line 21

Quoted 5 lines
drivers/sysreset/sysreset_sbi.c new file +5 -0
+{
+    enum sbi_srst_reset_type reset_type;
+
+    if (!have_reset)
+        return -ENOENT;

Is this necessary? This should never be called if there is no reset, since we just fail to probe.

Thank you for reviewing.

Yes, we can skip it.

Quoted 26 lines
Quoted 26 lines
drivers/sysreset/sysreset_sbi.c new file +25 -0
+
+    switch (type) {
+    case SYSRESET_WARM:
+        reset_type = SBI_SRST_RESET_TYPE_WARM_REBOOT;
+        break;
+    case SYSRESET_COLD:
+        reset_type = SBI_SRST_RESET_TYPE_COLD_REBOOT;
+        break;
+    case SYSRESET_POWER_OFF:
+        reset_type = SBI_SRST_RESET_TYPE_SHUTDOWN;
+        break;
+    default:
+        log_err("SBI has no system reset extension\n");
+        return -ENOSYS;
+    }
+
+    sbi_srst_reset(reset_type, SBI_SRST_RESET_REASON_NONE);
+
+    return -EINPROGRESS;
+}
+
+efi_status_t efi_reset_system_init(void)
+{
+    return EFI_SUCCESS;
+}
Quoted 8 lines

drivers/sysreset/sysreset_sbi.c line 51

Quoted 5 lines
drivers/sysreset/sysreset_sbi.c new file +5 -0
+
+void __efi_runtime EFIAPI efi_reset_system(enum efi_reset_type type,
+                       efi_status_t reset_status,
+                       unsigned long data_size,
+                       void *reset_data)

As an aside, is there a reason why the generic (weak) efi_reset_system does not just call sysreset_walk_halt(type)?

efi_reset_system is invoked at UEFI runtime. Most functions of U-Boot are no longer in memory after ExitBootServices(). Only functions in the __efi_runtime section may be called.

Quoted 20 lines
Quoted 7 lines
drivers/sysreset/sysreset_sbi.c new file +6 -0
+{
+    enum sbi_srst_reset_type reset_type;
+
+    if (have_reset)
+        switch (type) {
+        case SYSRESET_WARM:

drivers/sysreset/sysreset_sbi.c line 67

Quoted 10 lines
drivers/sysreset/sysreset_sbi.c new file +10 -0
+            reset_type = SBI_SRST_RESET_TYPE_WARM_REBOOT;
+            break;
+        case SYSRESET_COLD:
+            reset_type = SBI_SRST_RESET_TYPE_COLD_REBOOT;
+            break;
+        case SYSRESET_POWER_OFF:
+            reset_type = SBI_SRST_RESET_TYPE_SHUTDOWN;
+            break;
+        default:
+            goto hang;

Why do we hang by default? For comparison, sysreset_x86 has

Quoted 5 lines
     if (reset_type == EFI_RESET_COLD ||
          reset_type == EFI_RESET_PLATFORM_SPECIFIC)
         value = SYS_RST | RST_CPU | FULL_RST;
     else /* assume EFI_RESET_WARM since we cannot return an error */
         value = SYS_RST | RST_CPU;

ok

Quoted 13 lines

drivers/sysreset/sysreset_sbi.c line 38

Quoted 4 lines
drivers/sysreset/sysreset_sbi.c new file +3 -0
+    }
+
+    sbi_srst_reset(reset_type, SBI_SRST_RESET_REASON_NONE);

Should we instead do

     enum sbi_srst_reset_reason reset_reason;
     if (reset_status == EFI_SUCCESS)
         reset_reason = SBI_SRST_RESET_REASON_NONE;
     else
         reset_reason = SBI_SRST_RESET_REASON_SYS_FAILURE;
     sbi_srst_reset(reset_type, reset_status == EFI_SUCCESS ?
Quoted 3 lines

SBI_SRST_RESET_REASON_NONE : SBI_SRST_RESET_REASON_SYS_FAILURE);

since we have reset status available?

Makes sense.

Quoted 17 lines
Quoted 4 lines
drivers/sysreset/sysreset_sbi.c new file +3 -0
+
+hang:
+    while (1)

drivers/sysreset/sysreset_sbi.c line 83

Quoted 10 lines
drivers/sysreset/sysreset_sbi.c new file +10 -0
+        ;
+}
+
+static int sbi_sysreset_probe(struct udevice *dev)
+{
+    have_reset = sbi_probe_extension(SBI_EXT_SRST);
+    if (have_reset)
+        return 0;
+
+    log_err("SBI has no system reset extension\n");

Is this an error? It's perfectly normal for SBI implementations to lack support for some extensions. Perhaps a warning/info would be better.

Quoted 2 lines

We shouldn't have chosen this driver in the configuration if the SBI does not support it.

Yes, but we would like to use the same config for differing SBI implementations (e.g. say a vendor's SBI implementation and SBI).

Quoted 1 line

I will change this to a warning.

Great.

Quoted 11 lines
Quoted 10 lines

drivers/sysreset/sysreset_sbi.c line 88

Quoted 7 lines
drivers/sysreset/sysreset_sbi.c new file +5 -0
+    return -ENOENT;
+}
+
+static const struct udevice_id sbi_sysreset_ids[] = {
+    { .compatible = "riscv" },

This compatible string is already in-use for RISC-V CPUs. And if this isn't supposed to have a device tree binding, do we even need of_match?

Quoted 6 lines

I discussed this with Simon in

https://lists.denx.de/pipermail/u-boot/2021-March/443270.html

Instead of adding code to the board files we should have a device-tree node. A reasonable compatible string would be "riscv,sbi-sysreset".

Ok, so will patch 5 have the board parts dropped?

--Sean

Quoted 46 lines
Quoted 20 lines
Quoted 20 lines
drivers/sysreset/sysreset_sbi.c new file +14 -0
+    { }
+};
+
+static struct sysreset_ops sbi_sysreset_ops = {
+    .request = sbi_sysreset_request,
+};
+
+U_BOOT_DRIVER(sbi_sysreset) = {
+    .name = "sbi-sysreset",
+    .id = UCLASS_SYSRESET,
+    .of_match = sbi_sysreset_ids,
+    .ops = &sbi_sysreset_ops,
+    .probe = sbi_sysreset_probe,
+};
lib/efi_loader/Kconfig +0 -0
index e729f727df..7e76435339 100644
@@ -277,7 +277,7 @@ config EFI_HAVE_RUNTIME_RESET
Quoted 8 lines

lib/efi_loader/Kconfig config EFI_HAVE_RUNTIME_RESET · line 280

Quoted 5 lines
lib/efi_loader/Kconfig +1 -1
      bool
      default y
      depends on ARCH_BCM283X || FSL_LAYERSCAPE || PSCI_RESET || \
-           SANDBOX || SYSRESET_X86
+           SANDBOX || SYSRESET_SBI || SYSRESET_X86

As a general note, perhaps it is better to set this from other Kconfigs? How long will this list get?

This seems to be a matter of taste.

Best regards

Heinrich

Quoted 10 lines

--Sean

Quoted 6 lines
lib/efi_loader/Kconfig +0 -0
  config EFI_GRUB_ARM32_WORKAROUND
      bool "Workaround for GRUB on 32bit ARM"
Signature · 1 line
2.30.1
#13 lore raw

PATCH 4/5 pinctrl: K210_PINCTRL depends on REGMAP and on SYSCON

In reply to Heinrich Schuchardt

Select missing Kconfig dependencies.

---
 drivers/pinctrl/Kconfig | 2 ++
 1 file changed, 2 insertions(+)
drivers/pinctrl/Kconfig +2 -0
index 77fb851114..2a859ab5d0 100644
@@ -294,6 +294,8 @@ config ASPEED_AST2500_PINCTRL
 config PINCTRL_K210
 	bool "Kendryte K210 Fully-Programmable Input/Output Array driver"
 	depends on DM && PINCTRL_GENERIC
+	select REGMAP
+	select SYSCON
 	help
 	  Support pin multiplexing on the K210. The "FPIOA" can remap any
 	  supported function to any multifunctional IO pin. It can also perform

--
2.30.1

#14 lore raw

PATCH 4/5 pinctrl: K210_PINCTRL depends on REGMAP and on SYSCON

Quoted 21 lines · Heinrich Schuchardt

Select missing Kconfig dependencies.

---
  drivers/pinctrl/Kconfig | 2 ++
  1 file changed, 2 insertions(+)
drivers/pinctrl/Kconfig +2 -1
index 77fb851114..2a859ab5d0 100644
@@ -294,6 +294,8 @@ config ASPEED_AST2500_PINCTRL
  config PINCTRL_K210
  	bool "Kendryte K210 Fully-Programmable Input/Output Array driver"
  	depends on DM && PINCTRL_GENERIC
+	select REGMAP
+	select SYSCON
  	help
  	  Support pin multiplexing on the K210. The "FPIOA" can remap any
  	  supported function to any multifunctional IO pin. It can also perform
--
Quoted 2 lines

2.30.1

#15 lore raw

PATCH 4/5 pinctrl: K210_PINCTRL depends on REGMAP and on SYSCON

In reply to Heinrich Schuchardt
Quoted 21 lines · Heinrich Schuchardt

Select missing Kconfig dependencies.

---
 drivers/pinctrl/Kconfig | 2 ++
 1 file changed, 2 insertions(+)
drivers/pinctrl/Kconfig +2 -1
index 77fb851114..2a859ab5d0 100644
@@ -294,6 +294,8 @@ config ASPEED_AST2500_PINCTRL
 config PINCTRL_K210
 	bool "Kendryte K210 Fully-Programmable Input/Output Array driver"
 	depends on DM && PINCTRL_GENERIC
+	select REGMAP
+	select SYSCON
 	help
 	  Support pin multiplexing on the K210. The "FPIOA" can remap any
 	  supported function to any multifunctional IO pin. It can also perform
--
Quoted 2 lines

2.30.1

#16 lore raw

PATCH 5/5 maix: enable SBI system reset for MAIX

In reply to Heinrich Schuchardt

When running in S-mode we can use the SBI system reset extension to provide the system reset.

---
 board/sipeed/maix/maix.c            | 5 +++++
 configs/sipeed_maix_smode_defconfig | 2 ++
 2 files changed, 7 insertions(+)
board/sipeed/maix/maix.c +5 -0
index cbcb23cf5c..388eddee6e 100644
@@ -6,6 +6,7 @@
 #include <common.h>
 #include <clk.h>
 #include <dm.h>
+#include <dm/lists.h>
 #include <fdt_support.h>
 #include <asm/io.h>
 
@@ -37,5 +38,9 @@ int board_init(void)
 			return ret;
 	}
 
+	if (IS_ENABLED(CONFIG_SYSRESET_SBI))
+		ret = device_bind_driver(gd->dm_root, "sbi-sysreset",
+					 "sbi-sysreset", NULL);
+
 	return 0;
 }
configs/sipeed_maix_smode_defconfig +2 -0
index 2516bb7258..aa95893feb 100644
@@ -7,4 +7,6 @@ CONFIG_STACK_SIZE=0x100000
 # CONFIG_NET is not set
 # CONFIG_INPUT is not set
 # CONFIG_DM_ETH is not set
+CONFIG_SYSRESET_SBI=y
+# CONFIG_SYSRESET_SYSCON is not set
 # CONFIG_EFI_UNICODE_CAPITALIZATION is not set

--
2.30.1

#17 lore raw

PATCH 5/5 maix: enable SBI system reset for MAIX

Quoted 22 lines · Heinrich Schuchardt

When running in S-mode we can use the SBI system reset extension to provide the system reset.

---
  board/sipeed/maix/maix.c            | 5 +++++
  configs/sipeed_maix_smode_defconfig | 2 ++
  2 files changed, 7 insertions(+)
board/sipeed/maix/maix.c +1 -0
index cbcb23cf5c..388eddee6e 100644
@@ -6,6 +6,7 @@
  #include <common.h>
  #include <clk.h>
  #include <dm.h>
+#include <dm/lists.h>
  #include <fdt_support.h>
  #include <asm/io.h>
 

board/sipeed/maix/maix.c int board_init(void) · line 44

Quoted 7 lines
board/sipeed/maix/maix.c +4 -0
@@ -37,5 +38,9 @@ int board_init(void)
  			return ret;
  	}
 
+	if (IS_ENABLED(CONFIG_SYSRESET_SBI))
+		ret = device_bind_driver(gd->dm_root, "sbi-sysreset",
+					 "sbi-sysreset", NULL);
+

Besides that this isn't a device-tree driver, shouldn't this live in arch_early_init_r or similar? This isn't really board-specific.

--Sean

Quoted 16 lines
board/sipeed/maix/maix.c +0 -0
  	return 0;
  }
configs/sipeed_maix_smode_defconfig +2 -1
index 2516bb7258..aa95893feb 100644
@@ -7,4 +7,6 @@ CONFIG_STACK_SIZE=0x100000
  # CONFIG_NET is not set
  # CONFIG_INPUT is not set
  # CONFIG_DM_ETH is not set
+CONFIG_SYSRESET_SBI=y
+# CONFIG_SYSRESET_SYSCON is not set
  # CONFIG_EFI_UNICODE_CAPITALIZATION is not set
--

2.30.1

#18 lore raw

PATCH 5/5 maix: enable SBI system reset for MAIX

Quoted 27 lines · Sean Anderson
Quoted 26 lines · Heinrich Schuchardt

When running in S-mode we can use the SBI system reset extension to provide
the system reset.

---
? board/sipeed/maix/maix.c??????????? | 5 +++++
? configs/sipeed_maix_smode_defconfig | 2 ++
? 2 files changed, 7 insertions(+)

board/sipeed/maix/maix.c +0 -0
index cbcb23cf5c..388eddee6e 100644
@@ -6,6 +6,7 @@

? #include <common.h>
? #include <clk.h>
? #include <dm.h>
+#include <dm/lists.h>
? #include <fdt_support.h>
? #include <asm/io.h>

board/sipeed/maix/maix.c +0 -0
@@ -37,5 +38,9 @@ int board_init(void)
 ????????????? return ret;
 ????? }
 
Quoted 7 lines

board/sipeed/maix/maix.c int board_init(void) · line 44

Quoted 4 lines
board/sipeed/maix/maix.c +4 -0
+??? if (IS_ENABLED(CONFIG_SYSRESET_SBI))
+??????? ret = device_bind_driver(gd->dm_root, "sbi-sysreset",
+???????????????????? "sbi-sysreset", NULL);
+

Besides that this isn't a device-tree driver, shouldn't this live in arch_early_init_r or similar? This isn't really board-specific.

Using arch_early_init_r() seems to be a viable alternative to putting some dummy node into each device-tree.

Best regards

Heinrich

Quoted 21 lines

--Sean

Quoted 17 lines
board/sipeed/maix/maix.c +0 -0
 ????? return 0;
 ? }
configs/sipeed_maix_smode_defconfig +0 -0
index 2516bb7258..aa95893feb 100644
@@ -7,4 +7,6 @@ CONFIG_STACK_SIZE=0x100000

? # CONFIG_NET is not set
? # CONFIG_INPUT is not set
? # CONFIG_DM_ETH is not set

configs/sipeed_maix_smode_defconfig +2 -0
+CONFIG_SYSRESET_SBI=y
+# CONFIG_SYSRESET_SYSCON is not set

? # CONFIG_EFI_UNICODE_CAPITALIZATION is not set
--
2.30.1