Linux-RISC-V Archive on lore.kernel.org
 help / color / mirror / Atom feed
* driver: reset: spacemit-p1: add driver for poweroff/reboot
@ 2025-09-27 22:07 Aurelien Jarno
  2025-09-27 22:07 ` [PATCH 1/2] " Aurelien Jarno
  2025-09-27 22:07 ` [PATCH 2/2] mfd: simple-mfd-i2c: add a reboot cell for the SpacemiT P1 chip Aurelien Jarno
  0 siblings, 2 replies; 9+ messages in thread
From: Aurelien Jarno @ 2025-09-27 22:07 UTC (permalink / raw)
  To: linux-kernel, Lee Jones, Sebastian Reichel, Yixun Lan,
	Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti
  Cc: Aurelien Jarno, open list:SYSTEM RESET/SHUTDOWN DRIVERS,
	open list:RISC-V SPACEMIT SoC Support,
	open list:RISC-V SPACEMIT SoC Support

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 separate patch series
that adds atomic transfer support to the SpacemiT I2C controller driver:
https://lore.kernel.org/spacemit/48B175EBF0F1A347+aNXwqlO1mD-7BGtE@kernel.org/T/#t
The two fixes mentioned there are also required:
https://lore.kernel.org/spacemit/aNbDkn9AC4FFx-Zc@aurel32.net/

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

-- 
2.47.2


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

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

* [PATCH 1/2] driver: reset: spacemit-p1: add driver for poweroff/reboot
  2025-09-27 22:07 driver: reset: spacemit-p1: add driver for poweroff/reboot Aurelien Jarno
@ 2025-09-27 22:07 ` Aurelien Jarno
  2025-09-28  0:02   ` Yixun Lan
                     ` (2 more replies)
  2025-09-27 22:07 ` [PATCH 2/2] mfd: simple-mfd-i2c: add a reboot cell for the SpacemiT P1 chip Aurelien Jarno
  1 sibling, 3 replies; 9+ messages in thread
From: Aurelien Jarno @ 2025-09-27 22:07 UTC (permalink / raw)
  To: linux-kernel, Lee Jones, Sebastian Reichel, Yixun Lan,
	Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti
  Cc: Aurelien Jarno, open list:SYSTEM RESET/SHUTDOWN DRIVERS,
	open list:RISC-V SPACEMIT SoC Support,
	open list:RISC-V SPACEMIT SoC Support

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 <aurelien@aurel32.net>
---
 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

diff --git a/drivers/power/reset/Kconfig b/drivers/power/reset/Kconfig
index 77ea3129c7080..5afef049760d6 100644
--- a/drivers/power/reset/Kconfig
+++ b/drivers/power/reset/Kconfig
@@ -276,6 +276,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
diff --git a/drivers/power/reset/Makefile b/drivers/power/reset/Makefile
index b7c2b5940be99..cb6fb1be865db 100644
--- a/drivers/power/reset/Makefile
+++ b/drivers/power/reset/Makefile
@@ -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_TORADEX_EC) += tdx-ec-poweroff.o
 obj-$(CONFIG_POWER_RESET_TPS65086) += tps65086-restart.o
diff --git a/drivers/power/reset/spacemit-p1-reboot.c b/drivers/power/reset/spacemit-p1-reboot.c
new file mode 100644
index 0000000000000..105e19701ef85
--- /dev/null
+++ b/drivers/power/reset/spacemit-p1-reboot.c
@@ -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) {
+		dev_err(dev, "Failed to register power off handler: %d\n", ret);
+		return ret;
+	}
+
+	ret = devm_register_restart_handler(dev, spacemit_p1_restart_handler, regmap);
+	if (ret) {
+		dev_err(dev, "Failed to register restart handler: %d\n", ret);
+		return ret;
+	}
+
+	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");
-- 
2.47.2


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

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

* [PATCH 2/2] mfd: simple-mfd-i2c: add a reboot cell for the SpacemiT P1 chip
  2025-09-27 22:07 driver: reset: spacemit-p1: add driver for poweroff/reboot Aurelien Jarno
  2025-09-27 22:07 ` [PATCH 1/2] " Aurelien Jarno
@ 2025-09-27 22:07 ` Aurelien Jarno
  2025-09-28  2:08   ` Troy Mitchell
  1 sibling, 1 reply; 9+ messages in thread
From: Aurelien Jarno @ 2025-09-27 22:07 UTC (permalink / raw)
  To: linux-kernel, Lee Jones, Sebastian Reichel, Yixun Lan,
	Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti
  Cc: Aurelien Jarno, open list:SYSTEM RESET/SHUTDOWN DRIVERS,
	open list:RISC-V SPACEMIT SoC Support,
	open list:RISC-V SPACEMIT SoC Support

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

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
---
 drivers/mfd/simple-mfd-i2c.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/mfd/simple-mfd-i2c.c b/drivers/mfd/simple-mfd-i2c.c
index 696b602051260..2e86efb0c82b8 100644
--- a/drivers/mfd/simple-mfd-i2c.c
+++ b/drivers/mfd/simple-mfd-i2c.c
@@ -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", },
 };
-- 
2.47.2


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

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

* Re: [PATCH 1/2] driver: reset: spacemit-p1: add driver for poweroff/reboot
  2025-09-27 22:07 ` [PATCH 1/2] " Aurelien Jarno
@ 2025-09-28  0:02   ` Yixun Lan
  2025-09-28 18:01     ` Aurelien Jarno
  2025-09-28  2:10   ` Troy Mitchell
  2025-09-29  6:35   ` Troy Mitchell
  2 siblings, 1 reply; 9+ messages in thread
From: Yixun Lan @ 2025-09-28  0:02 UTC (permalink / raw)
  To: Aurelien Jarno
  Cc: linux-kernel, Lee Jones, Sebastian Reichel, Paul Walmsley,
	Palmer Dabbelt, Albert Ou, Alexandre Ghiti,
	open list:SYSTEM RESET/SHUTDOWN DRIVERS,
	open list:RISC-V SPACEMIT SoC Support,
	open list:RISC-V SPACEMIT SoC Support

Hi Aurelien, 

On 00:07 Sun 28 Sep     , Aurelien Jarno wrote:
> 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 <aurelien@aurel32.net>
> ---
>  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
> 
> diff --git a/drivers/power/reset/Kconfig b/drivers/power/reset/Kconfig
> index 77ea3129c7080..5afef049760d6 100644
> --- a/drivers/power/reset/Kconfig
> +++ b/drivers/power/reset/Kconfig
[snip]..
> +
> +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) {
> +		dev_err(dev, "Failed to register power off handler: %d\n", ret);
> +		return ret;
suggest to simplify with dev_err_probe(), which will save few lines
> +	}
> +
> +	ret = devm_register_restart_handler(dev, spacemit_p1_restart_handler, regmap);
> +	if (ret) {
> +		dev_err(dev, "Failed to register restart handler: %d\n", ret);
> +		return ret;
ditto
> +	}
> +
> +	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");
> -- 
> 2.47.2
> 

-- 
Yixun Lan (dlan)

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

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

* Re: [PATCH 2/2] mfd: simple-mfd-i2c: add a reboot cell for the SpacemiT P1 chip
  2025-09-27 22:07 ` [PATCH 2/2] mfd: simple-mfd-i2c: add a reboot cell for the SpacemiT P1 chip Aurelien Jarno
@ 2025-09-28  2:08   ` Troy Mitchell
  2025-09-28 21:01     ` Aurelien Jarno
  0 siblings, 1 reply; 9+ messages in thread
From: Troy Mitchell @ 2025-09-28  2:08 UTC (permalink / raw)
  To: Aurelien Jarno, linux-kernel, Lee Jones, Sebastian Reichel,
	Yixun Lan, Paul Walmsley, Palmer Dabbelt, Albert Ou,
	Alexandre Ghiti
  Cc: open list:SYSTEM RESET/SHUTDOWN DRIVERS,
	open list:RISC-V SPACEMIT SoC Support,
	open list:RISC-V SPACEMIT SoC Support, Troy Mitchell

Hi Aurelien, Thanks for your patch!

On Sun, Sep 28, 2025 at 12:07:41AM +0200, Aurelien Jarno wrote:
> Add a "spacemit-p1-reboot" cell for the SpacemiT P1 chip.
> 
> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
> ---
>  drivers/mfd/simple-mfd-i2c.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/mfd/simple-mfd-i2c.c b/drivers/mfd/simple-mfd-i2c.c
> index 696b602051260..2e86efb0c82b8 100644
> --- a/drivers/mfd/simple-mfd-i2c.c
> +++ b/drivers/mfd/simple-mfd-i2c.c
> @@ -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", },
I’m not sure if this name is the best fit here.
Since the driver also implements reboot and power-off functionality,
would it make more sense to call it spacemit-p1-power?
I’ll leave it up to you.

Otherwise, LGTM.

Reviewed-by: Troy Mitchell <troy.mitchell@linux.spacemit.com>
>  	{ .name = "spacemit-p1-regulator", },
>  	{ .name = "spacemit-p1-rtc", },
>  };
> -- 
> 2.47.2
> 
> 
> _______________________________________________
> linux-riscv mailing list
> linux-riscv@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-riscv

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

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

* Re: [PATCH 1/2] driver: reset: spacemit-p1: add driver for poweroff/reboot
  2025-09-27 22:07 ` [PATCH 1/2] " Aurelien Jarno
  2025-09-28  0:02   ` Yixun Lan
@ 2025-09-28  2:10   ` Troy Mitchell
  2025-09-29  6:35   ` Troy Mitchell
  2 siblings, 0 replies; 9+ messages in thread
From: Troy Mitchell @ 2025-09-28  2:10 UTC (permalink / raw)
  To: Aurelien Jarno, linux-kernel, Lee Jones, Sebastian Reichel,
	Yixun Lan, Paul Walmsley, Palmer Dabbelt, Albert Ou,
	Alexandre Ghiti
  Cc: open list:SYSTEM RESET/SHUTDOWN DRIVERS,
	open list:RISC-V SPACEMIT SoC Support,
	open list:RISC-V SPACEMIT SoC Support, Troy Mitchell

On Sun, Sep 28, 2025 at 12:07:40AM +0200, Aurelien Jarno wrote:
> 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 <aurelien@aurel32.net>
> ---
>  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
> 
[...]
> +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) {
> +		dev_err(dev, "Failed to register power off handler: %d\n", ret);
> +		return ret;
> +	}
With fixing what Yixun said, LGTM.

Acked-by: Troy Mitchell <troy.mitchell@linux.spacemit.com>
> +
> +	ret = devm_register_restart_handler(dev, spacemit_p1_restart_handler, regmap);
> +	if (ret) {
> +		dev_err(dev, "Failed to register restart handler: %d\n", ret);
> +		return ret;
> +	}
> +
> +	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");
> -- 
> 2.47.2
> 
> 
> _______________________________________________
> linux-riscv mailing list
> linux-riscv@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-riscv

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

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

* Re: [PATCH 1/2] driver: reset: spacemit-p1: add driver for poweroff/reboot
  2025-09-28  0:02   ` Yixun Lan
@ 2025-09-28 18:01     ` Aurelien Jarno
  0 siblings, 0 replies; 9+ messages in thread
From: Aurelien Jarno @ 2025-09-28 18:01 UTC (permalink / raw)
  To: Yixun Lan
  Cc: linux-kernel, Lee Jones, Sebastian Reichel, Paul Walmsley,
	Palmer Dabbelt, Albert Ou, Alexandre Ghiti,
	open list:SYSTEM RESET/SHUTDOWN DRIVERS,
	open list:RISC-V SPACEMIT SoC Support,
	open list:RISC-V SPACEMIT SoC Support

Hi Yixun,

On 2025-09-28 08:02, Yixun Lan wrote:
> Hi Aurelien, 
> 
> On 00:07 Sun 28 Sep     , Aurelien Jarno wrote:
> > 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 <aurelien@aurel32.net>
> > ---
> >  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
> > 
> > diff --git a/drivers/power/reset/Kconfig b/drivers/power/reset/Kconfig
> > index 77ea3129c7080..5afef049760d6 100644
> > --- a/drivers/power/reset/Kconfig
> > +++ b/drivers/power/reset/Kconfig
> [snip]..
> > +
> > +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) {
> > +		dev_err(dev, "Failed to register power off handler: %d\n", ret);
> > +		return ret;
> suggest to simplify with dev_err_probe(), which will save few lines
> > +	}
> > +
> > +	ret = devm_register_restart_handler(dev, spacemit_p1_restart_handler, regmap);
> > +	if (ret) {
> > +		dev_err(dev, "Failed to register restart handler: %d\n", ret);
> > +		return ret;
> ditto

Thanks for the hint, that'll be in the next version.

Regards
Aurelien

-- 
Aurelien Jarno                          GPG: 4096R/1DDD8C9B
aurelien@aurel32.net                     http://aurel32.net

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

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

* Re: [PATCH 2/2] mfd: simple-mfd-i2c: add a reboot cell for the SpacemiT P1 chip
  2025-09-28  2:08   ` Troy Mitchell
@ 2025-09-28 21:01     ` Aurelien Jarno
  0 siblings, 0 replies; 9+ messages in thread
From: Aurelien Jarno @ 2025-09-28 21:01 UTC (permalink / raw)
  To: Troy Mitchell
  Cc: linux-kernel, Lee Jones, Sebastian Reichel, Yixun Lan,
	Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti,
	open list:SYSTEM RESET/SHUTDOWN DRIVERS,
	open list:RISC-V SPACEMIT SoC Support,
	open list:RISC-V SPACEMIT SoC Support

On 2025-09-28 10:08, Troy Mitchell wrote:
> Hi Aurelien, Thanks for your patch!
> 
> On Sun, Sep 28, 2025 at 12:07:41AM +0200, Aurelien Jarno wrote:
> > Add a "spacemit-p1-reboot" cell for the SpacemiT P1 chip.
> > 
> > Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
> > ---
> >  drivers/mfd/simple-mfd-i2c.c | 1 +
> >  1 file changed, 1 insertion(+)
> > 
> > diff --git a/drivers/mfd/simple-mfd-i2c.c b/drivers/mfd/simple-mfd-i2c.c
> > index 696b602051260..2e86efb0c82b8 100644
> > --- a/drivers/mfd/simple-mfd-i2c.c
> > +++ b/drivers/mfd/simple-mfd-i2c.c
> > @@ -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", },
> I’m not sure if this name is the best fit here.
> Since the driver also implements reboot and power-off functionality,
> would it make more sense to call it spacemit-p1-power?
> I’ll leave it up to you.

I see your point, for this driver naming everything was among the most 
complex things. I have chosen "spacemit-p1-reboot" to be consistent with  
the naming used in the driver itself. I chose them from recently added 
drivers supporting both poweroff and reset, that seems to all use the 
term reboot.

> Otherwise, LGTM.
> 
> Reviewed-by: Troy Mitchell <troy.mitchell@linux.spacemit.com>
> >  	{ .name = "spacemit-p1-regulator", },
> >  	{ .name = "spacemit-p1-rtc", },
> >  };
> > -- 
> > 2.47.2
> > 
> > 
> > _______________________________________________
> > linux-riscv mailing list
> > linux-riscv@lists.infradead.org
> > http://lists.infradead.org/mailman/listinfo/linux-riscv
> 

-- 
Aurelien Jarno                          GPG: 4096R/1DDD8C9B
aurelien@aurel32.net                     http://aurel32.net

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

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

* Re: [PATCH 1/2] driver: reset: spacemit-p1: add driver for poweroff/reboot
  2025-09-27 22:07 ` [PATCH 1/2] " Aurelien Jarno
  2025-09-28  0:02   ` Yixun Lan
  2025-09-28  2:10   ` Troy Mitchell
@ 2025-09-29  6:35   ` Troy Mitchell
  2 siblings, 0 replies; 9+ messages in thread
From: Troy Mitchell @ 2025-09-29  6:35 UTC (permalink / raw)
  To: Aurelien Jarno, linux-kernel, Lee Jones, Sebastian Reichel,
	Yixun Lan, Paul Walmsley, Palmer Dabbelt, Albert Ou,
	Alexandre Ghiti
  Cc: open list:SYSTEM RESET/SHUTDOWN DRIVERS,
	open list:RISC-V SPACEMIT SoC Support,
	open list:RISC-V SPACEMIT SoC Support, Troy Mitchell

On Sun, Sep 28, 2025 at 12:07:40AM +0200, Aurelien Jarno wrote:
> 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 <aurelien@aurel32.net>
Thanks.

Tested-by: Troy Mitchell <troy.mitchell@linux.spacemit.com>

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

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

end of thread, other threads:[~2025-09-29  6:37 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-27 22:07 driver: reset: spacemit-p1: add driver for poweroff/reboot Aurelien Jarno
2025-09-27 22:07 ` [PATCH 1/2] " Aurelien Jarno
2025-09-28  0:02   ` Yixun Lan
2025-09-28 18:01     ` Aurelien Jarno
2025-09-28  2:10   ` Troy Mitchell
2025-09-29  6:35   ` Troy Mitchell
2025-09-27 22:07 ` [PATCH 2/2] mfd: simple-mfd-i2c: add a reboot cell for the SpacemiT P1 chip Aurelien Jarno
2025-09-28  2:08   ` Troy Mitchell
2025-09-28 21:01     ` Aurelien Jarno

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox