Skip to contentSkip to conversation

driver: reset: spacemit-p1: add driver for poweroff/reboot

PATCH Superseded Aurelien Jarno 6 participants 13 messages Oct 26, 2025 – Oct 27, 2025

Subsystems (4)

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v4 cover driver: reset: spacemit-p1: add driver for poweroff/reboot

This adds poweroff/reboot support for the SpacemiT P1 PMIC chip, which is commonly paired with the SpacemiT K1 SoC.

Note: For reliable operation, this driver depends on a this patch that adds atomic transfer support to the SpacemiT I2C controller driver:
https://lore.kernel.org/spacemit/[email protected]/

Changes between version 3 and version 4:
- Replace the "select" by a "depends on"
- Remove outdated Reviewed-by

Here is version 3 of this series:
https://lore.kernel.org/spacemit/[email protected]/

Changes between version 2 and version 3:
- Allow building as a module
- Remove outdated Acked-by and Tested-by
- Collect Reviewed-by

Here is version 2 of this series:
https://lore.kernel.org/spacemit/[email protected]/

Changes between version 1 and version 2:
- Rebase onto v6.18-rc1
- Use dev_err_probe() to simplify the code
- Fix indentation of patch 1
- Collect Acked-by and Tested-by

Here is version 1 of this series:
https://lore.kernel.org/spacemit/[email protected]/

Aurelien Jarno (2):
driver: reset: spacemit-p1: add driver for poweroff/reboot
mfd: simple-mfd-i2c: add a reboot cell for the SpacemiT P1 chip

 drivers/mfd/simple-mfd-i2c.c             |  1 +
 drivers/power/reset/Kconfig              |  9 +++
 drivers/power/reset/Makefile             |  1 +
 drivers/power/reset/spacemit-p1-reboot.c | 88 ++++++++++++++++++++++++
 4 files changed, 99 insertions(+)
 create mode 100644 drivers/power/reset/spacemit-p1-reboot.c
Signature · 1 line
2.47.2
#1 lore raw

PATCH v4 1/2 driver: reset: spacemit-p1: add driver for poweroff/reboot

This driver implements poweroff/reboot support for the SpacemiT P1 PMIC chip, which is commonly paired with the SpacemiT K1 SoC.

The SpacemiT P1 support is implemented as a MFD driver, so the access is done directly through the regmap interface. Reboot or poweroff is triggered by setting a specific bit in a control register, which is automatically cleared by the hardware afterwards.

---
v2:
- Replace the "select" by a "depends on"
- Remove outdated Reviewed-by

 drivers/power/reset/Kconfig              |  9 +++
 drivers/power/reset/Makefile             |  1 +
 drivers/power/reset/spacemit-p1-reboot.c | 88 ++++++++++++++++++++++++
 3 files changed, 98 insertions(+)
 create mode 100644 drivers/power/reset/spacemit-p1-reboot.c
drivers/power/reset/Kconfig +9 -0
index 8248895ca9038..61c16f3d5abc7 100644
@@ -283,6 +283,15 @@ config POWER_RESET_KEYSTONE
 	help
 	  Reboot support for the KEYSTONE SoCs.
 
+config POWER_RESET_SPACEMIT_P1
+	tristate "SpacemiT P1 poweroff and reset driver"
+	depends on ARCH_SPACEMIT || COMPILE_TEST
+	depends on MFD_SPACEMIT_P1
+	default m
+	help
+	  This driver supports power-off and reset operations for the SpacemiT
+	  P1 PMIC.
+
 config POWER_RESET_SYSCON
 	bool "Generic SYSCON regmap reset driver"
 	depends on OF
drivers/power/reset/Makefile +1 -0
index 51da87e05ce76..0e4ae6f6b5c55 100644
@@ -24,6 +24,7 @@ obj-$(CONFIG_POWER_RESET_LTC2952) += ltc2952-poweroff.o
 obj-$(CONFIG_POWER_RESET_QNAP) += qnap-poweroff.o
 obj-$(CONFIG_POWER_RESET_REGULATOR) += regulator-poweroff.o
 obj-$(CONFIG_POWER_RESET_RESTART) += restart-poweroff.o
+obj-$(CONFIG_POWER_RESET_SPACEMIT_P1) += spacemit-p1-reboot.o
 obj-$(CONFIG_POWER_RESET_ST) += st-poweroff.o
 obj-$(CONFIG_POWER_RESET_TH1520_AON) += th1520-aon-reboot.o
 obj-$(CONFIG_POWER_RESET_TORADEX_EC) += tdx-ec-poweroff.o
drivers/power/reset/spacemit-p1-reboot.c new file +88 -0

88 lines not on this page · raw message

Signature · 1 line
2.47.2
reviewer
#2 lore raw
Quoted 25 lines · Aurelien Jarno

This driver implements poweroff/reboot support for the SpacemiT P1 PMIC chip, which is commonly paired with the SpacemiT K1 SoC.

The SpacemiT P1 support is implemented as a MFD driver, so the access is done directly through the regmap interface. Reboot or poweroff is triggered by setting a specific bit in a control register, which is automatically cleared by the hardware afterwards.

---
v2:
- Replace the "select" by a "depends on"
- Remove outdated Reviewed-by

 drivers/power/reset/Kconfig              |  9 +++
 drivers/power/reset/Makefile             |  1 +
 drivers/power/reset/spacemit-p1-reboot.c | 88 ++++++++++++++++++++++++
 3 files changed, 98 insertions(+)
 create mode 100644 drivers/power/reset/spacemit-p1-reboot.c
drivers/power/reset/Kconfig +0 -0
index 8248895ca9038..61c16f3d5abc7 100644

drivers/power/reset/Kconfig config POWER_RESET_KEYSTONE · line 290

Quoted 8 lines
drivers/power/reset/Kconfig +5 -0
@@ -283,6 +283,15 @@ config POWER_RESET_KEYSTONE
 	help
 	  Reboot support for the KEYSTONE SoCs.
 
+config POWER_RESET_SPACEMIT_P1
+	tristate "SpacemiT P1 poweroff and reset driver"
+	depends on ARCH_SPACEMIT || COMPILE_TEST
+	depends on MFD_SPACEMIT_P1
+	default m

default m if ARCH_SPACEMIT? Or default ARCH_SPACEMIT?
I believe that reboot and shutdown are actually essential functionalities, so it might make more sense: default ARCH_SPACEMIT?

- Troy

Quoted 117 lines
drivers/power/reset/Kconfig +4 -0
+	help
+	  This driver supports power-off and reset operations for the SpacemiT
+	  P1 PMIC.
+
 config POWER_RESET_SYSCON
 	bool "Generic SYSCON regmap reset driver"
 	depends on OF
drivers/power/reset/Makefile +1 -0
index 51da87e05ce76..0e4ae6f6b5c55 100644
@@ -24,6 +24,7 @@ obj-$(CONFIG_POWER_RESET_LTC2952) += ltc2952-poweroff.o
 obj-$(CONFIG_POWER_RESET_QNAP) += qnap-poweroff.o
 obj-$(CONFIG_POWER_RESET_REGULATOR) += regulator-poweroff.o
 obj-$(CONFIG_POWER_RESET_RESTART) += restart-poweroff.o
+obj-$(CONFIG_POWER_RESET_SPACEMIT_P1) += spacemit-p1-reboot.o
 obj-$(CONFIG_POWER_RESET_ST) += st-poweroff.o
 obj-$(CONFIG_POWER_RESET_TH1520_AON) += th1520-aon-reboot.o
 obj-$(CONFIG_POWER_RESET_TORADEX_EC) += tdx-ec-poweroff.o
drivers/power/reset/spacemit-p1-reboot.c new file +88 -0
new file mode 100644
index 0000000000000..9ec3d1fff8f3d
@@ -0,0 +1,88 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2025 by Aurelien Jarno
+ */
+
+#include <linux/bits.h>
+#include <linux/mod_devicetable.h>
+#include <linux/platform_device.h>
+#include <linux/regmap.h>
+#include <linux/reboot.h>
+
+/* Power Control Register 2 */
+#define PWR_CTRL2		0x7e
+#define PWR_CTRL2_SHUTDOWN	BIT(2)	/* Shutdown request */
+#define PWR_CTRL2_RST		BIT(1)	/* Reset request */
+
+static int spacemit_p1_pwroff_handler(struct sys_off_data *data)
+{
+	struct regmap *regmap = data->cb_data;
+	int ret;
+
+	/* Put the PMIC into shutdown state */
+	ret = regmap_set_bits(regmap, PWR_CTRL2, PWR_CTRL2_SHUTDOWN);
+	if (ret) {
+		dev_err(data->dev, "shutdown failed: %d\n", ret);
+		return notifier_from_errno(ret);
+	}
+
+	return NOTIFY_DONE;
+}
+
+static int spacemit_p1_restart_handler(struct sys_off_data *data)
+{
+	struct regmap *regmap = data->cb_data;
+	int ret;
+
+	/* Put the PMIC into reset state */
+	ret = regmap_set_bits(regmap, PWR_CTRL2, PWR_CTRL2_RST);
+	if (ret) {
+		dev_err(data->dev, "restart failed: %d\n", ret);
+		return notifier_from_errno(ret);
+	}
+
+	return NOTIFY_DONE;
+}
+
+static int spacemit_p1_reboot_probe(struct platform_device *pdev)
+{
+	struct device *dev = &pdev->dev;
+	struct regmap *regmap;
+	int ret;
+
+	regmap = dev_get_regmap(dev->parent, NULL);
+	if (!regmap)
+		return -ENODEV;
+
+	ret = devm_register_power_off_handler(dev, &spacemit_p1_pwroff_handler,
+					      regmap);
+	if (ret)
+		return dev_err_probe(dev, ret,
+				     "Failed to register power off handler\n");
+
+	ret = devm_register_restart_handler(dev, spacemit_p1_restart_handler,
+					    regmap);
+	if (ret)
+		return dev_err_probe(dev, ret,
+				     "Failed to register restart handler\n");
+
+	return 0;
+}
+
+static const struct platform_device_id spacemit_p1_reboot_id_table[] = {
+	{ "spacemit-p1-reboot", },
+	{ /* sentinel */ },
+};
+MODULE_DEVICE_TABLE(platform, spacemit_p1_reboot_id_table);
+
+static struct platform_driver spacemit_p1_reboot_driver = {
+	.driver = {
+		.name = "spacemit-p1-reboot",
+	},
+	.probe = spacemit_p1_reboot_probe,
+	.id_table = spacemit_p1_reboot_id_table,
+};
+module_platform_driver(spacemit_p1_reboot_driver);
+
+MODULE_DESCRIPTION("SpacemiT P1 reboot/poweroff driver");
+MODULE_LICENSE("GPL");
Signature · 1 line
2.47.2
#3 lore raw
Quoted 29 lines · Troy Mitchell
Quoted 28 lines · Aurelien Jarno

This driver implements poweroff/reboot support for the SpacemiT P1 PMIC chip, which is commonly paired with the SpacemiT K1 SoC.

The SpacemiT P1 support is implemented as a MFD driver, so the access is done directly through the regmap interface. Reboot or poweroff is triggered by setting a specific bit in a control register, which is automatically cleared by the hardware afterwards.

---
v2:
- Replace the "select" by a "depends on"
- Remove outdated Reviewed-by

 drivers/power/reset/Kconfig              |  9 +++
 drivers/power/reset/Makefile             |  1 +
 drivers/power/reset/spacemit-p1-reboot.c | 88 ++++++++++++++++++++++++
 3 files changed, 98 insertions(+)
 create mode 100644 drivers/power/reset/spacemit-p1-reboot.c
drivers/power/reset/Kconfig +0 -0
index 8248895ca9038..61c16f3d5abc7 100644
@@ -283,6 +283,15 @@ config POWER_RESET_KEYSTONE
 	help
 	  Reboot support for the KEYSTONE SoCs.
 
Quoted 6 lines

drivers/power/reset/Kconfig config POWER_RESET_KEYSTONE · line 290

Quoted 5 lines
drivers/power/reset/Kconfig +5 -0
+config POWER_RESET_SPACEMIT_P1
+	tristate "SpacemiT P1 poweroff and reset driver"
+	depends on ARCH_SPACEMIT || COMPILE_TEST
+	depends on MFD_SPACEMIT_P1
+	default m

default m if ARCH_SPACEMIT?

As explained here, this is equivalent:
https://lore.kernel.org/spacemit/CAJM55Z_BzfRo5aKf2VrneTymSizwDQq6OfMK_LNgyoGjp43K8Q@mail.gmail.com/

But I can make a v5 to change that, if it's the preferred form on the SpacemiT side.

Quoted 3 lines

Or default ARCH_SPACEMIT?
I believe that reboot and shutdown are actually essential functionalities, so it might make more sense: default ARCH_SPACEMIT?

That was already changed in v3, following a request on v2:
https://lore.kernel.org/spacemit/CANBLGczi3GeaC4aWECV8NS-zqSHgRa-5onynz9fGsZeN8qgysg@mail.gmail.com/

Regards
Aurelien

Signature · 2 lines
Aurelien Jarno                          GPG: 4096R/1DDD8C9B
[email protected]                     http://aurel32.net
reviewer
#4 lore raw
Quoted 37 lines · Aurelien Jarno
Quoted 29 lines · Troy Mitchell
Quoted 28 lines · Aurelien Jarno

This driver implements poweroff/reboot support for the SpacemiT P1 PMIC chip, which is commonly paired with the SpacemiT K1 SoC.

The SpacemiT P1 support is implemented as a MFD driver, so the access is done directly through the regmap interface. Reboot or poweroff is triggered by setting a specific bit in a control register, which is automatically cleared by the hardware afterwards.

---
v2:
- Replace the "select" by a "depends on"
- Remove outdated Reviewed-by

 drivers/power/reset/Kconfig              |  9 +++
 drivers/power/reset/Makefile             |  1 +
 drivers/power/reset/spacemit-p1-reboot.c | 88 ++++++++++++++++++++++++
 3 files changed, 98 insertions(+)
 create mode 100644 drivers/power/reset/spacemit-p1-reboot.c
drivers/power/reset/Kconfig +0 -0
index 8248895ca9038..61c16f3d5abc7 100644
@@ -283,6 +283,15 @@ config POWER_RESET_KEYSTONE
 	help
 	  Reboot support for the KEYSTONE SoCs.
 
Quoted 6 lines

drivers/power/reset/Kconfig config POWER_RESET_KEYSTONE · line 290

Quoted 5 lines
drivers/power/reset/Kconfig +5 -0
+config POWER_RESET_SPACEMIT_P1
+	tristate "SpacemiT P1 poweroff and reset driver"
+	depends on ARCH_SPACEMIT || COMPILE_TEST
+	depends on MFD_SPACEMIT_P1
+	default m

default m if ARCH_SPACEMIT?

Quoted 5 lines

As explained here, this is equivalent:
https://lore.kernel.org/spacemit/CAJM55Z_BzfRo5aKf2VrneTymSizwDQq6OfMK_LNgyoGjp43K8Q@mail.gmail.com/

But I can make a v5 to change that, if it's the preferred form on the SpacemiT side.

I missed that conversation. Just keep it!

Quoted 7 lines
Quoted 4 lines

Or default ARCH_SPACEMIT?
I believe that reboot and shutdown are actually essential functionalities, so it might make more sense: default ARCH_SPACEMIT?

That was already changed in v3, following a request on v2:
https://lore.kernel.org/spacemit/CANBLGczi3GeaC4aWECV8NS-zqSHgRa-5onynz9fGsZeN8qgysg@mail.gmail.com/

Thanks for your link.

- Troy

Quoted 8 lines

Regards
Aurelien

Signature · 2 lines
Aurelien Jarno                          GPG: 4096R/1DDD8C9B
[email protected]                     http://aurel32.net
#5 lore raw
In reply to Troy Mitchell
Quoted 29 lines · Troy Mitchell
Quoted 28 lines · Aurelien Jarno

This driver implements poweroff/reboot support for the SpacemiT P1 PMIC chip, which is commonly paired with the SpacemiT K1 SoC.

The SpacemiT P1 support is implemented as a MFD driver, so the access is done directly through the regmap interface. Reboot or poweroff is triggered by setting a specific bit in a control register, which is automatically cleared by the hardware afterwards.

---
v2:
- Replace the "select" by a "depends on"
- Remove outdated Reviewed-by

 drivers/power/reset/Kconfig              |  9 +++
 drivers/power/reset/Makefile             |  1 +
 drivers/power/reset/spacemit-p1-reboot.c | 88 ++++++++++++++++++++++++
 3 files changed, 98 insertions(+)
 create mode 100644 drivers/power/reset/spacemit-p1-reboot.c
drivers/power/reset/Kconfig +0 -0
index 8248895ca9038..61c16f3d5abc7 100644
@@ -283,6 +283,15 @@ config POWER_RESET_KEYSTONE
 	help
 	  Reboot support for the KEYSTONE SoCs.
 
Quoted 8 lines

drivers/power/reset/Kconfig config POWER_RESET_KEYSTONE · line 290

Quoted 5 lines
drivers/power/reset/Kconfig +5 -0
+config POWER_RESET_SPACEMIT_P1
+	tristate "SpacemiT P1 poweroff and reset driver"
+	depends on ARCH_SPACEMIT || COMPILE_TEST
+	depends on MFD_SPACEMIT_P1
+	default m

default m if ARCH_SPACEMIT? Or default ARCH_SPACEMIT?
I believe that reboot and shutdown are actually essential functionalities, so it might make more sense: default ARCH_SPACEMIT?

I don't think there's anything preventing it to be built as module by
default: even though it's "essential", it's unnecessary during kernel and userspace startup, thus I see no reason to build it in the image.

Building it as module by default shrinks the kernel image, which most distributions are willing to see, thus helps distro maintainers to maintain the configuration.

The default value has been discussed in v2 of the series[1], where Emil, Yixun have expressed preference on "default m". So do I here.

Quoted 1 line

- Troy

Regards,
Yao Zi

[1]: https://lore.kernel.org/spacemit/[email protected]/

Quoted 7 lines
Quoted 7 lines
drivers/power/reset/Kconfig +4 -0
+	help
+	  This driver supports power-off and reset operations for the SpacemiT
+	  P1 PMIC.
+
 config POWER_RESET_SYSCON
 	bool "Generic SYSCON regmap reset driver"
 	depends on OF
#6 lore raw
Quoted 39 lines · Yao Zi
Quoted 29 lines · Troy Mitchell
Quoted 28 lines · Aurelien Jarno

This driver implements poweroff/reboot support for the SpacemiT P1 PMIC chip, which is commonly paired with the SpacemiT K1 SoC.

The SpacemiT P1 support is implemented as a MFD driver, so the access is done directly through the regmap interface. Reboot or poweroff is triggered by setting a specific bit in a control register, which is automatically cleared by the hardware afterwards.

---
v2:
- Replace the "select" by a "depends on"
- Remove outdated Reviewed-by

 drivers/power/reset/Kconfig              |  9 +++
 drivers/power/reset/Makefile             |  1 +
 drivers/power/reset/spacemit-p1-reboot.c | 88 ++++++++++++++++++++++++
 3 files changed, 98 insertions(+)
 create mode 100644 drivers/power/reset/spacemit-p1-reboot.c
drivers/power/reset/Kconfig +0 -0
index 8248895ca9038..61c16f3d5abc7 100644
@@ -283,6 +283,15 @@ config POWER_RESET_KEYSTONE
 	help
 	  Reboot support for the KEYSTONE SoCs.
 
Quoted 8 lines

drivers/power/reset/Kconfig config POWER_RESET_KEYSTONE · line 290

Quoted 5 lines
drivers/power/reset/Kconfig +5 -0
+config POWER_RESET_SPACEMIT_P1
+	tristate "SpacemiT P1 poweroff and reset driver"
+	depends on ARCH_SPACEMIT || COMPILE_TEST
+	depends on MFD_SPACEMIT_P1
+	default m

default m if ARCH_SPACEMIT? Or default ARCH_SPACEMIT?
I believe that reboot and shutdown are actually essential functionalities, so it might make more sense: default ARCH_SPACEMIT?

Quoted 3 lines

I don't think there's anything preventing it to be built as module by
default: even though it's "essential", it's unnecessary during kernel and userspace startup, thus I see no reason to build it in the image.

Wouldn't it be needed in a reboot-on-panic situation?

Signature · 3 lines
Andreas Schwab, SUSE Labs, [email protected]
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."
#7 lore raw
Quoted 41 lines · Andreas Schwab
Quoted 39 lines · Yao Zi
Quoted 37 lines · Troy Mitchell
Quoted 25 lines · Aurelien Jarno

This driver implements poweroff/reboot support for the SpacemiT P1 PMIC chip, which is commonly paired with the SpacemiT K1 SoC.

The SpacemiT P1 support is implemented as a MFD driver, so the access is done directly through the regmap interface. Reboot or poweroff is triggered by setting a specific bit in a control register, which is automatically cleared by the hardware afterwards.

---
v2:
- Replace the "select" by a "depends on"
- Remove outdated Reviewed-by

 drivers/power/reset/Kconfig              |  9 +++
 drivers/power/reset/Makefile             |  1 +
 drivers/power/reset/spacemit-p1-reboot.c | 88 ++++++++++++++++++++++++
 3 files changed, 98 insertions(+)
 create mode 100644 drivers/power/reset/spacemit-p1-reboot.c
drivers/power/reset/Kconfig +0 -0
index 8248895ca9038..61c16f3d5abc7 100644

drivers/power/reset/Kconfig config POWER_RESET_KEYSTONE · line 290

Quoted 8 lines
drivers/power/reset/Kconfig +5 -0
@@ -283,6 +283,15 @@ config POWER_RESET_KEYSTONE
 	help
 	  Reboot support for the KEYSTONE SoCs.
 
+config POWER_RESET_SPACEMIT_P1
+	tristate "SpacemiT P1 poweroff and reset driver"
+	depends on ARCH_SPACEMIT || COMPILE_TEST
+	depends on MFD_SPACEMIT_P1
+	default m

default m if ARCH_SPACEMIT? Or default ARCH_SPACEMIT?
I believe that reboot and shutdown are actually essential functionalities, so it might make more sense: default ARCH_SPACEMIT?

Quoted 5 lines
Quoted 3 lines

I don't think there's anything preventing it to be built as module by
default: even though it's "essential", it's unnecessary during kernel and userspace startup, thus I see no reason to build it in the image.

Wouldn't it be needed in a reboot-on-panic situation?

Oops, yeah, I missed this stuff. Seems systemd automatic boot assessment could switch to another boot option if one fails to boot. And if it's caused by a (very early) kernel panic, then reboot support does play a part here.

So my statement, maybe as well as the module's default value, should be re-evaluated. Yixun, Emil, what do you think about it?

Best regards,
Yao Zi

Quoted 9 lines
Signature · 8 lines
Andreas Schwab, SUSE Labs, [email protected]
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."

_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
#8 lore raw

Quoting Yao Zi (2025-10-27 10:24:30)

Quoted 25 lines · Andreas Schwab
Quoted 24 lines · Yao Zi
Quoted 22 lines · Troy Mitchell
Quoted 9 lines · Aurelien Jarno
Quoted 8 lines
drivers/power/reset/Kconfig +0 -0
index 8248895ca9038..61c16f3d5abc7 100644
@@ -283,6 +283,15 @@ config POWER_RESET_KEYSTONE
         help
           Reboot support for the KEYSTONE SoCs.
 
Quoted 8 lines

drivers/power/reset/Kconfig config POWER_RESET_KEYSTONE · line 290

Quoted 5 lines
drivers/power/reset/Kconfig +5 -0
+config POWER_RESET_SPACEMIT_P1
+        tristate "SpacemiT P1 poweroff and reset driver"
+        depends on ARCH_SPACEMIT || COMPILE_TEST
+        depends on MFD_SPACEMIT_P1
+        default m

default m if ARCH_SPACEMIT? Or default ARCH_SPACEMIT?
I believe that reboot and shutdown are actually essential functionalities, so it might make more sense: default ARCH_SPACEMIT?

I don't think there's anything preventing it to be built as module by
default: even though it's "essential", it's unnecessary during kernel and userspace startup, thus I see no reason to build it in the image.

Quoted 6 lines
Quoted 1 line

Wouldn't it be needed in a reboot-on-panic situation?

Oops, yeah, I missed this stuff. Seems systemd automatic boot assessment could switch to another boot option if one fails to boot. And if it's caused by a (very early) kernel panic, then reboot support does play a part here.

But if systemd is running then you've at least got as far as the initramfs, and have the module available. So I don't see the problem.

/Emil

#9 lore raw

Hi

Quoted 28 lines · Emil Renner Berthing

Quoting Yao Zi (2025-10-27 10:24:30)

Quoted 27 lines · Andreas Schwab
Quoted 25 lines · Yao Zi
Quoted 19 lines · Troy Mitchell
Quoted 9 lines · Aurelien Jarno
Quoted 8 lines
drivers/power/reset/Kconfig +0 -0
index 8248895ca9038..61c16f3d5abc7 100644
@@ -283,6 +283,15 @@ config POWER_RESET_KEYSTONE
         help
           Reboot support for the KEYSTONE SoCs.
 
Quoted 8 lines

drivers/power/reset/Kconfig config POWER_RESET_KEYSTONE · line 290

Quoted 5 lines
drivers/power/reset/Kconfig +5 -0
+config POWER_RESET_SPACEMIT_P1
+        tristate "SpacemiT P1 poweroff and reset driver"
+        depends on ARCH_SPACEMIT || COMPILE_TEST
+        depends on MFD_SPACEMIT_P1
+        default m

default m if ARCH_SPACEMIT? Or default ARCH_SPACEMIT?
I believe that reboot and shutdown are actually essential functionalities, so it might make more sense: default ARCH_SPACEMIT?

Quoted 3 lines

I don't think there's anything preventing it to be built as module by
default: even though it's "essential", it's unnecessary during kernel and userspace startup, thus I see no reason to build it in the image.

Wouldn't it be needed in a reboot-on-panic situation?

Quoted 8 lines
Quoted 4 lines

Oops, yeah, I missed this stuff. Seems systemd automatic boot assessment could switch to another boot option if one fails to boot. And if it's caused by a (very early) kernel panic, then reboot support does play a part here.

But if systemd is running then you've at least got as far as the initramfs, and have the module available. So I don't see the problem.

In rare case, if got kernel panic before load this module, then we should really fix it instead.. Besides, there is no restriction to prevent user to make this driver as built-in, right?

So I think this isn't really a big problem either

Signature · 1 line
Yixun Lan (dlan)
#10 lore raw
Quoted 36 lines · Yixun Lan

Hi

Quoted 33 lines · Emil Renner Berthing

Quoting Yao Zi (2025-10-27 10:24:30)

Quoted 31 lines · Andreas Schwab
Quoted 20 lines · Yao Zi
Quoted 19 lines · Troy Mitchell
Quoted 17 lines · Aurelien Jarno

drivers/power/reset/Kconfig config POWER_RESET_KEYSTONE · line 290

Quoted 13 lines
drivers/power/reset/Kconfig +5 -0
index 8248895ca9038..61c16f3d5abc7 100644
@@ -283,6 +283,15 @@ config POWER_RESET_KEYSTONE
         help
           Reboot support for the KEYSTONE SoCs.
 
+config POWER_RESET_SPACEMIT_P1
+        tristate "SpacemiT P1 poweroff and reset driver"
+        depends on ARCH_SPACEMIT || COMPILE_TEST
+        depends on MFD_SPACEMIT_P1
+        default m

default m if ARCH_SPACEMIT? Or default ARCH_SPACEMIT?
I believe that reboot and shutdown are actually essential functionalities, so it might make more sense: default ARCH_SPACEMIT?

Quoted 5 lines
Quoted 3 lines

I don't think there's anything preventing it to be built as module by
default: even though it's "essential", it's unnecessary during kernel and userspace startup, thus I see no reason to build it in the image.

Wouldn't it be needed in a reboot-on-panic situation?

Oops, yeah, I missed this stuff. Seems systemd automatic boot assessment could switch to another boot option if one fails to boot. And if it's caused by a (very early) kernel panic, then reboot support does play a part here.

Quoted 8 lines
Quoted 3 lines

But if systemd is running then you've at least got as far as the initramfs, and have the module available. So I don't see the problem.

In rare case, if got kernel panic before load this module, then we should really fix it instead.. Besides, there is no restriction to prevent user to make this driver as built-in, right?

So I think this isn't really a big problem either

A possible compromise here might be to use "default MFD_SPACEMIT_P1". This would defer the decision to another level, but I think it makes sense to have all parts of the MFD either built-in or as modules.

Regards
Aurelien

Signature · 2 lines
Aurelien Jarno                          GPG: 4096R/1DDD8C9B
[email protected]                     http://aurel32.net
reviewer
#11 lore raw
Quoted 44 lines · Aurelien Jarno
Quoted 43 lines · Yixun Lan

Hi

Quoted 28 lines · Emil Renner Berthing

Quoting Yao Zi (2025-10-27 10:24:30)

Quoted 27 lines · Andreas Schwab
Quoted 25 lines · Yao Zi
Quoted 19 lines · Troy Mitchell
Quoted 9 lines · Aurelien Jarno
Quoted 8 lines
drivers/power/reset/Kconfig +0 -0
index 8248895ca9038..61c16f3d5abc7 100644
@@ -283,6 +283,15 @@ config POWER_RESET_KEYSTONE
         help
           Reboot support for the KEYSTONE SoCs.
 
Quoted 8 lines

drivers/power/reset/Kconfig config POWER_RESET_KEYSTONE · line 290

Quoted 5 lines
drivers/power/reset/Kconfig +5 -0
+config POWER_RESET_SPACEMIT_P1
+        tristate "SpacemiT P1 poweroff and reset driver"
+        depends on ARCH_SPACEMIT || COMPILE_TEST
+        depends on MFD_SPACEMIT_P1
+        default m

default m if ARCH_SPACEMIT? Or default ARCH_SPACEMIT?
I believe that reboot and shutdown are actually essential functionalities, so it might make more sense: default ARCH_SPACEMIT?

Quoted 3 lines

I don't think there's anything preventing it to be built as module by
default: even though it's "essential", it's unnecessary during kernel and userspace startup, thus I see no reason to build it in the image.

Wouldn't it be needed in a reboot-on-panic situation?

Quoted 8 lines
Quoted 4 lines

Oops, yeah, I missed this stuff. Seems systemd automatic boot assessment could switch to another boot option if one fails to boot. And if it's caused by a (very early) kernel panic, then reboot support does play a part here.

But if systemd is running then you've at least got as far as the initramfs, and have the module available. So I don't see the problem.

In rare case, if got kernel panic before load this module, then we should really fix it instead.. Besides, there is no restriction to prevent user to make this driver as built-in, right?

Quoted 5 lines
Quoted 1 line

So I think this isn't really a big problem either

A possible compromise here might be to use "default MFD_SPACEMIT_P1". This would defer the decision to another level, but I think it makes sense to have all parts of the MFD either built-in or as modules.

I think both the regulator and shutdown/reboot drivers should be default MFD_SPACEMIT_P1.

Otherwise, enabling MFD_SPACEMIT_P1 alone doesn't make much sense, right?

- Troy

Quoted 8 lines

Regards
Aurelien

Signature · 2 lines
Aurelien Jarno                          GPG: 4096R/1DDD8C9B
[email protected]                     http://aurel32.net
#12 lore raw

PATCH v4 2/2 mfd: simple-mfd-i2c: add a reboot cell for the SpacemiT P1 chip

In reply to Aurelien Jarno

Add a "spacemit-p1-reboot" cell for the SpacemiT P1 chip.

---
v2: no changes

 drivers/mfd/simple-mfd-i2c.c | 1 +
 1 file changed, 1 insertion(+)
drivers/mfd/simple-mfd-i2c.c +1 -0
index 0a607a1e3ca1d..542d378cdcd1f 100644
@@ -99,6 +99,7 @@ static const struct regmap_config spacemit_p1_regmap_config = {
 };
 
 static const struct mfd_cell spacemit_p1_cells[] = {
+	{ .name = "spacemit-p1-reboot", },
 	{ .name = "spacemit-p1-regulator", },
 	{ .name = "spacemit-p1-rtc", },
 };
Signature · 1 line
2.47.2