driver: reset: spacemit-p1: add driver for poweroff/reboot
Subsystems (4)
v2 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 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
PATCH v2 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:
- Rebase onto v6.18-rc1
- Use dev_err_probe() to simplify the code
- Fix indentation of patch 1
- Collect Acked-by and Tested-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
@@ -283,6 +283,15 @@ config POWER_RESET_KEYSTONE help Reboot support for the KEYSTONE SoCs. +config POWER_RESET_SPACEMIT_P1 + bool "SpacemiT P1 poweroff and reset driver" + depends on ARCH_SPACEMIT || COMPILE_TEST + select MFD_SPACEMIT_P1 + default ARCH_SPACEMIT + 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
@@ -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
Quoted 30 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.
Signed-off-by Aurelien Jarno <[email protected]>Acked-by Troy Mitchell <[email protected]>Tested-by Troy Mitchell <[email protected]>---
v2:
- Rebase onto v6.18-rc1
- Usedev_err_probe()to simplify the code
- Fix indentation of patch 1
- Collect Acked-by and Tested-bydrivers/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.cdrivers/power/reset/Kconfig +0
-0
drivers/power/reset/Kconfig config POWER_RESET_KEYSTONE · line 287
Quoted 5 lines
drivers/power/reset/Kconfig +2
-0@@ -283,6 +283,15 @@ config POWER_RESET_KEYSTONE help Reboot support for the KEYSTONE SoCs. +config POWER_RESET_SPACEMIT_P1 + bool "SpacemiT P1 poweroff and reset driver"
The driver code looks to be written to work as a module, but here it says "bool" not "tristate".
drivers/power/reset/Kconfig config POWER_RESET_KEYSTONE · line 290
Quoted 3 lines
drivers/power/reset/Kconfig +3
-0+ depends on ARCH_SPACEMIT || COMPILE_TEST + select MFD_SPACEMIT_P1 + default ARCH_SPACEMIT
If it does work as a module I'd prefer "default m" here.
/Emil
Yixun Lan
Reviewed-byHi Aurelien,
Quoted 40 lines · Emil Renner Berthing
Quoted 30 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.
Signed-off-by Aurelien Jarno <[email protected]>Acked-by Troy Mitchell <[email protected]>Tested-by Troy Mitchell <[email protected]>---
v2:
- Rebase onto v6.18-rc1
- Usedev_err_probe()to simplify the code
- Fix indentation of patch 1
- Collect Acked-by and Tested-bydrivers/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.cdrivers/power/reset/Kconfig +0
-0drivers/power/reset/Kconfig config POWER_RESET_KEYSTONE · line 287
Quoted 5 lines
drivers/power/reset/Kconfig +2
-0@@ -283,6 +283,15 @@ config POWER_RESET_KEYSTONE help Reboot support for the KEYSTONE SoCs. +config POWER_RESET_SPACEMIT_P1 + bool "SpacemiT P1 poweroff and reset driver"The driver code looks to be written to work as a module, but here it says "bool" not "tristate".
Quoted 6 lines
drivers/power/reset/Kconfig config POWER_RESET_KEYSTONE · line 290
Quoted 3 lines
drivers/power/reset/Kconfig +3
-0+ depends on ARCH_SPACEMIT || COMPILE_TEST + select MFD_SPACEMIT_P1 + default ARCH_SPACEMITIf it does work as a module I'd prefer "default m" here.
I second this, you can add my RoB if with it fixed
Signature · 1 line
Yixun Lan (dlan)
Hi Emil,
Quoted 34 lines · Emil Renner Berthing
Quoted 33 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.
Signed-off-by Aurelien Jarno <[email protected]>Acked-by Troy Mitchell <[email protected]>Tested-by Troy Mitchell <[email protected]>---
v2:
- Rebase onto v6.18-rc1
- Usedev_err_probe()to simplify the code
- Fix indentation of patch 1
- Collect Acked-by and Tested-bydrivers/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.cdrivers/power/reset/Kconfig +0
-0@@ -283,6 +283,15 @@ config POWER_RESET_KEYSTONE help Reboot support for the KEYSTONE SoCs.
Quoted 5 lines
drivers/power/reset/Kconfig config POWER_RESET_KEYSTONE · line 287
Quoted 2 lines
drivers/power/reset/Kconfig +2
-0+config POWER_RESET_SPACEMIT_P1 + bool "SpacemiT P1 poweroff and reset driver"The driver code looks to be written to work as a module, but here it says "bool" not "tristate".
I have just tested to build it as a module, and it indeed works that way. I'll change that to tristate in the next version.
Quoted 5 lines
drivers/power/reset/Kconfig config POWER_RESET_KEYSTONE · line 290
Quoted 3 lines
drivers/power/reset/Kconfig +3
-0+ depends on ARCH_SPACEMIT || COMPILE_TEST + select MFD_SPACEMIT_P1 + default ARCH_SPACEMITIf it does work as a module I'd prefer "default m" here.
Do you mean "default m" or "default m if ARCH_SPACEMIT"?
Regards
Aurelien
Signature · 2 lines
Aurelien Jarno GPG: 4096R/1DDD8C9B [email protected] http://aurel32.net
Troy Mitchell
reviewerQuoted 46 lines · Aurelien Jarno
Hi Emil,
Quoted 34 lines · Emil Renner Berthing
Quoted 33 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.
Signed-off-by Aurelien Jarno <[email protected]>Acked-by Troy Mitchell <[email protected]>Tested-by Troy Mitchell <[email protected]>---
v2:
- Rebase onto v6.18-rc1
- Usedev_err_probe()to simplify the code
- Fix indentation of patch 1
- Collect Acked-by and Tested-bydrivers/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.cdrivers/power/reset/Kconfig +0
-0@@ -283,6 +283,15 @@ config POWER_RESET_KEYSTONE help Reboot support for the KEYSTONE SoCs.Quoted 5 lines
drivers/power/reset/Kconfig config POWER_RESET_KEYSTONE · line 287
Quoted 2 lines
drivers/power/reset/Kconfig +2
-0+config POWER_RESET_SPACEMIT_P1 + bool "SpacemiT P1 poweroff and reset driver"The driver code looks to be written to work as a module, but here it says "bool" not "tristate".
I have just tested to build it as a module, and it indeed works that way. I'll change that to tristate in the next version.
Quoted 7 lines
Quoted 5 lines
drivers/power/reset/Kconfig config POWER_RESET_KEYSTONE · line 290
Quoted 3 lines
drivers/power/reset/Kconfig +3
-0+ depends on ARCH_SPACEMIT || COMPILE_TEST + select MFD_SPACEMIT_P1 + default ARCH_SPACEMITIf it does work as a module I'd prefer "default m" here.
Do you mean "default m" or "default m if
ARCH_SPACEMIT"?
I think it's "default m if ARCH_SPACEMIT".
because only SpacemiT uses P1.
- Troy
Quoted 8 lines
Regards
AurelienSignature · 2 lines
Aurelien Jarno GPG: 4096R/1DDD8C9B [email protected] http://aurel32.net
Quoting Aurelien Jarno (2025-10-20 06:55:37)
Quoted 21 lines
Hi Emil,
Quoted 9 lines · Emil Renner Berthing
Quoted 8 lines · Aurelien Jarno
drivers/power/reset/Kconfig +0
-0@@ -283,6 +283,15 @@ config POWER_RESET_KEYSTONE help Reboot support for the KEYSTONE SoCs.Quoted 5 lines
drivers/power/reset/Kconfig config POWER_RESET_KEYSTONE · line 287
Quoted 2 lines
drivers/power/reset/Kconfig +2
-0+config POWER_RESET_SPACEMIT_P1 + bool "SpacemiT P1 poweroff and reset driver"The driver code looks to be written to work as a module, but here it says "bool" not "tristate".
I have just tested to build it as a module, and it indeed works that way. I'll change that to tristate in the next version.
Quoted 7 lines
Quoted 5 lines
drivers/power/reset/Kconfig config POWER_RESET_KEYSTONE · line 290
Quoted 3 lines
drivers/power/reset/Kconfig +3
-0+ depends on ARCH_SPACEMIT || COMPILE_TEST + select MFD_SPACEMIT_P1 + default ARCH_SPACEMITIf it does work as a module I'd prefer "default m" here.
Do you mean "default m" or "default m if
ARCH_SPACEMIT"?
Just "default m" should be fine since the driver already depends on ARCH_SPACEMIT, but the 2nd version is more explicit.
A quick grep doesn't show an overwhelming majority of one over the other, so I guess it's up to the maintainers.
/Emil
PATCH v2 2/2 mfd: simple-mfd-i2c: add a reboot cell for the SpacemiT P1 chip
In reply to Aurelien JarnoAdd a "spacemit-p1-reboot" cell for the SpacemiT P1 chip.
---
v2:
- Rebase onto v6.18-rc1
drivers/mfd/simple-mfd-i2c.c | 1 + 1 file changed, 1 insertion(+)
drivers/mfd/simple-mfd-i2c.c +1 -0
@@ -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