* [PATCH v2 1/3] mfd: sprd-sc27xx: Integrate power off and reboot support
2025-11-10 19:08 [PATCH v2 0/3] mfd: sprd-sc27xx: Move poweroff/reboot support to the parent MFD driver Otto Pflüger
@ 2025-11-10 19:08 ` Otto Pflüger
2025-11-20 15:30 ` Lee Jones
2025-11-10 19:08 ` [PATCH v2 2/3] spi: sprd-adi: Remove code for storing the reboot mode Otto Pflüger
` (2 subsequent siblings)
3 siblings, 1 reply; 9+ messages in thread
From: Otto Pflüger @ 2025-11-10 19:08 UTC (permalink / raw)
To: Lee Jones, Orson Zhai, Baolin Wang, Chunyan Zhang, Mark Brown,
Sebastian Reichel
Cc: Rob Herring, linux-kernel, linux-spi, linux-pm, Otto Pflüger
The SC27xx PMICs allow restarting and powering off the device. Since
this functionality is rather simple and not configurable in any way,
make it part of the main PMIC driver.
Signed-off-by: Otto Pflüger <otto.pflueger@abscue.de>
---
drivers/mfd/sprd-sc27xx-spi.c | 148 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 148 insertions(+)
diff --git a/drivers/mfd/sprd-sc27xx-spi.c b/drivers/mfd/sprd-sc27xx-spi.c
index d6b4350779e6aecfa19d9fa21b9174447d589e33..250938db549cbba1428371b20f92ad48ca9557f7 100644
--- a/drivers/mfd/sprd-sc27xx-spi.c
+++ b/drivers/mfd/sprd-sc27xx-spi.c
@@ -10,6 +10,7 @@
#include <linux/mfd/sc27xx-pmic.h>
#include <linux/of.h>
#include <linux/of_platform.h>
+#include <linux/reboot.h>
#include <linux/regmap.h>
#include <linux/spi/spi.h>
#include <uapi/linux/usb/charger.h>
@@ -21,10 +22,48 @@
#define SPRD_SC2730_IRQ_BASE 0x80
#define SPRD_SC2730_IRQ_NUMS 10
#define SPRD_SC2730_CHG_DET 0x1b9c
+
+#define SPRD_SC2730_PWR_PD_HW 0x1820
+#define SPRD_SC2730_SOFT_RST_HW 0x1824
+#define SPRD_SC2730_SLP_CTRL 0x1a48
+#define SPRD_SC2730_RST_STATUS 0x1bac
+#define SPRD_SC2730_SWRST_CTRL0 0x1bf8
+
#define SPRD_SC2731_IRQ_BASE 0x140
#define SPRD_SC2731_IRQ_NUMS 16
#define SPRD_SC2731_CHG_DET 0xedc
+#define SPRD_SC2731_PWR_PD_HW 0xc2c
+#define SPRD_SC2731_SLP_CTRL 0xdf0
+#define SPRD_SC2731_RST_STATUS 0xee8
+
+/* PMIC power off and reset definition */
+#define SPRD_SC2730_LDO_XTL_EN BIT(2)
+#define SPRD_SC2730_SLP_LDO_PD_EN BIT(0)
+
+#define SPRD_SC2731_LDO_XTL_EN BIT(3)
+#define SPRD_SC2731_SLP_LDO_PD_EN BIT(0)
+
+#define SPRD_PMIC_PWR_OFF BIT(0)
+#define SPRD_PMIC_RESET BIT(0)
+#define SPRD_PMIC_SOFT_RST_EN BIT(4)
+
+#define HWRST_STATUS_SECURITY 0x02
+#define HWRST_STATUS_RECOVERY 0x20
+#define HWRST_STATUS_NORMAL 0x40
+#define HWRST_STATUS_ALARM 0x50
+#define HWRST_STATUS_SLEEP 0x60
+#define HWRST_STATUS_FASTBOOT 0x30
+#define HWRST_STATUS_SPECIAL 0x70
+#define HWRST_STATUS_PANIC 0x80
+#define HWRST_STATUS_CFTREBOOT 0x90
+#define HWRST_STATUS_AUTODLOADER 0xa0
+#define HWRST_STATUS_IQMODE 0xb0
+#define HWRST_STATUS_SPRDISK 0xc0
+#define HWRST_STATUS_FACTORYTEST 0xe0
+#define HWRST_STATUS_WATCHDOG 0xf0
+#define HWRST_STATUS_MASK 0xff
+
/* PMIC charger detection definition */
#define SPRD_PMIC_CHG_DET_DELAY_US 200000
#define SPRD_PMIC_CHG_DET_TIMEOUT 2000000
@@ -48,6 +87,14 @@ struct sprd_pmic_data {
u32 irq_base;
u32 num_irqs;
u32 charger_det;
+
+ u32 poweroff_reg;
+ u32 slp_ctrl_reg;
+ u32 slp_ctrl_mask;
+
+ u32 reset_reg;
+ u32 rst_sts_reg;
+ u32 swrst_ctrl_reg;
};
/*
@@ -59,12 +106,26 @@ static const struct sprd_pmic_data sc2730_data = {
.irq_base = SPRD_SC2730_IRQ_BASE,
.num_irqs = SPRD_SC2730_IRQ_NUMS,
.charger_det = SPRD_SC2730_CHG_DET,
+
+ .poweroff_reg = SPRD_SC2730_PWR_PD_HW,
+ .slp_ctrl_reg = SPRD_SC2730_SLP_CTRL,
+ .slp_ctrl_mask = SPRD_SC2730_LDO_XTL_EN | SPRD_SC2730_SLP_LDO_PD_EN,
+
+ .reset_reg = SPRD_SC2730_SOFT_RST_HW,
+ .rst_sts_reg = SPRD_SC2730_RST_STATUS,
+ .swrst_ctrl_reg = SPRD_SC2730_SWRST_CTRL0,
};
static const struct sprd_pmic_data sc2731_data = {
.irq_base = SPRD_SC2731_IRQ_BASE,
.num_irqs = SPRD_SC2731_IRQ_NUMS,
.charger_det = SPRD_SC2731_CHG_DET,
+
+ .poweroff_reg = SPRD_SC2731_PWR_PD_HW,
+ .slp_ctrl_reg = SPRD_SC2731_SLP_CTRL,
+ .slp_ctrl_mask = SPRD_SC2731_LDO_XTL_EN | SPRD_SC2731_SLP_LDO_PD_EN,
+
+ .rst_sts_reg = SPRD_SC2731_RST_STATUS,
};
enum usb_charger_type sprd_pmic_detect_charger_type(struct device *dev)
@@ -149,6 +210,77 @@ static const struct regmap_config sprd_pmic_config = {
.max_register = 0xffff,
};
+static int sprd_pmic_poweroff(struct sys_off_data *off_data)
+{
+ struct sprd_pmic *ddata = off_data->cb_data;
+ const struct sprd_pmic_data *pdata = ddata->pdata;
+
+ regmap_clear_bits(ddata->regmap, pdata->slp_ctrl_reg, pdata->slp_ctrl_mask);
+
+ regmap_write(ddata->regmap, pdata->poweroff_reg, SPRD_PMIC_PWR_OFF);
+
+ mdelay(1000);
+
+ dev_err(ddata->dev, "Unable to poweroff system\n");
+
+ return NOTIFY_DONE;
+}
+
+static int sprd_pmic_restart(struct sys_off_data *off_data)
+{
+ struct sprd_pmic *ddata = off_data->cb_data;
+ const struct sprd_pmic_data *pdata = ddata->pdata;
+ u32 reboot_mode;
+
+ if (!off_data->cmd)
+ reboot_mode = HWRST_STATUS_NORMAL;
+ else if (!strcmp(off_data->cmd, "recovery"))
+ reboot_mode = HWRST_STATUS_RECOVERY;
+ else if (!strcmp(off_data->cmd, "alarm"))
+ reboot_mode = HWRST_STATUS_ALARM;
+ else if (!strcmp(off_data->cmd, "fastsleep"))
+ reboot_mode = HWRST_STATUS_SLEEP;
+ else if (!strcmp(off_data->cmd, "bootloader"))
+ reboot_mode = HWRST_STATUS_FASTBOOT;
+ else if (!strcmp(off_data->cmd, "panic"))
+ reboot_mode = HWRST_STATUS_PANIC;
+ else if (!strcmp(off_data->cmd, "special"))
+ reboot_mode = HWRST_STATUS_SPECIAL;
+ else if (!strcmp(off_data->cmd, "cftreboot"))
+ reboot_mode = HWRST_STATUS_CFTREBOOT;
+ else if (!strcmp(off_data->cmd, "autodloader"))
+ reboot_mode = HWRST_STATUS_AUTODLOADER;
+ else if (!strcmp(off_data->cmd, "iqmode"))
+ reboot_mode = HWRST_STATUS_IQMODE;
+ else if (!strcmp(off_data->cmd, "sprdisk"))
+ reboot_mode = HWRST_STATUS_SPRDISK;
+ else if (!strcmp(off_data->cmd, "tospanic"))
+ reboot_mode = HWRST_STATUS_SECURITY;
+ else if (!strcmp(off_data->cmd, "factorytest"))
+ reboot_mode = HWRST_STATUS_FACTORYTEST;
+ else
+ reboot_mode = HWRST_STATUS_NORMAL;
+
+ regmap_update_bits(ddata->regmap, pdata->rst_sts_reg,
+ HWRST_STATUS_MASK, reboot_mode);
+
+ /*
+ * On SC2731, this part is skipped because there is no reset register
+ * and the restart must be performed using the watchdog.
+ */
+ if (pdata->reset_reg) {
+ regmap_set_bits(ddata->regmap, pdata->swrst_ctrl_reg, SPRD_PMIC_SOFT_RST_EN);
+
+ regmap_write(ddata->regmap, pdata->reset_reg, SPRD_PMIC_RESET);
+
+ mdelay(1000);
+
+ dev_err(ddata->dev, "Unable to restart system\n");
+ }
+
+ return NOTIFY_DONE;
+}
+
static int sprd_pmic_probe(struct spi_device *spi)
{
struct sprd_pmic *ddata;
@@ -204,6 +336,22 @@ static int sprd_pmic_probe(struct spi_device *spi)
return ret;
}
+ ret = devm_register_sys_off_handler(&spi->dev, SYS_OFF_MODE_RESTART,
+ SYS_OFF_PRIO_HIGH,
+ sprd_pmic_restart, ddata);
+ if (ret) {
+ dev_err(&spi->dev, "Failed to register restart handler: %d\n", ret);
+ return ret;
+ }
+
+ ret = devm_register_sys_off_handler(&spi->dev, SYS_OFF_MODE_POWER_OFF,
+ SYS_OFF_PRIO_DEFAULT,
+ sprd_pmic_poweroff, ddata);
+ if (ret) {
+ dev_err(&spi->dev, "Failed to register poweroff handler: %d\n", ret);
+ return ret;
+ }
+
ret = devm_of_platform_populate(&spi->dev);
if (ret) {
dev_err(&spi->dev, "Failed to populate sub-devices %d\n", ret);
--
2.50.0
^ permalink raw reply related [flat|nested] 9+ messages in thread* Re: [PATCH v2 1/3] mfd: sprd-sc27xx: Integrate power off and reboot support
2025-11-10 19:08 ` [PATCH v2 1/3] mfd: sprd-sc27xx: Integrate power off and reboot support Otto Pflüger
@ 2025-11-20 15:30 ` Lee Jones
2025-11-23 17:34 ` Otto Pflüger
0 siblings, 1 reply; 9+ messages in thread
From: Lee Jones @ 2025-11-20 15:30 UTC (permalink / raw)
To: Otto Pflüger
Cc: Orson Zhai, Baolin Wang, Chunyan Zhang, Mark Brown,
Sebastian Reichel, Rob Herring, linux-kernel, linux-spi, linux-pm
On Mon, 10 Nov 2025, Otto Pflüger wrote:
> The SC27xx PMICs allow restarting and powering off the device. Since
> this functionality is rather simple and not configurable in any way,
> make it part of the main PMIC driver.
This sounds like more of a drivers/power thing.
>
> Signed-off-by: Otto Pflüger <otto.pflueger@abscue.de>
> ---
> drivers/mfd/sprd-sc27xx-spi.c | 148 ++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 148 insertions(+)
--
Lee Jones [李琼斯]
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 1/3] mfd: sprd-sc27xx: Integrate power off and reboot support
2025-11-20 15:30 ` Lee Jones
@ 2025-11-23 17:34 ` Otto Pflüger
2025-11-26 15:36 ` Lee Jones
0 siblings, 1 reply; 9+ messages in thread
From: Otto Pflüger @ 2025-11-23 17:34 UTC (permalink / raw)
To: Lee Jones
Cc: Orson Zhai, Baolin Wang, Chunyan Zhang, Mark Brown,
Sebastian Reichel, Rob Herring, linux-kernel, linux-spi, linux-pm
On Thu, Nov 20, 2025 at 03:30:24PM +0000, Lee Jones wrote:
> On Mon, 10 Nov 2025, Otto Pflüger wrote:
>
> > The SC27xx PMICs allow restarting and powering off the device. Since
> > this functionality is rather simple and not configurable in any way,
> > make it part of the main PMIC driver.
>
> This sounds like more of a drivers/power thing.
This was originally in drivers/power, but according to [1], it should
not be a separate device tree node. Using a separate driver without a
separate device tree node would still involve some code here that
instantiates a platform device and selects the right platform data for
it.
Registering the poweroff handler directly seemed less complex, and I
assumed it was okay since some other MFD drivers (e.g. rk8xx) also
implement the same functionality without a separate power driver.
Is it a good idea to use devm_mfd_add_devices here instead?
[1]: https://lore.kernel.org/all/20251002025344.GA2958334-robh@kernel.org/
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 1/3] mfd: sprd-sc27xx: Integrate power off and reboot support
2025-11-23 17:34 ` Otto Pflüger
@ 2025-11-26 15:36 ` Lee Jones
0 siblings, 0 replies; 9+ messages in thread
From: Lee Jones @ 2025-11-26 15:36 UTC (permalink / raw)
To: Otto Pflüger
Cc: Orson Zhai, Baolin Wang, Chunyan Zhang, Mark Brown,
Sebastian Reichel, Rob Herring, linux-kernel, linux-spi, linux-pm
On Sun, 23 Nov 2025, Otto Pflüger wrote:
> On Thu, Nov 20, 2025 at 03:30:24PM +0000, Lee Jones wrote:
> > On Mon, 10 Nov 2025, Otto Pflüger wrote:
> >
> > > The SC27xx PMICs allow restarting and powering off the device. Since
> > > this functionality is rather simple and not configurable in any way,
> > > make it part of the main PMIC driver.
> >
> > This sounds like more of a drivers/power thing.
>
> This was originally in drivers/power, but according to [1], it should
> not be a separate device tree node. Using a separate driver without a
> separate device tree node would still involve some code here that
> instantiates a platform device and selects the right platform data for
> it.
>
> Registering the poweroff handler directly seemed less complex, and I
> assumed it was okay since some other MFD drivers (e.g. rk8xx) also
> implement the same functionality without a separate power driver.
>
> Is it a good idea to use devm_mfd_add_devices here instead?
>
> [1]: https://lore.kernel.org/all/20251002025344.GA2958334-robh@kernel.org/
Well that is quite the predicament.
Let me catch-up with Rob out-of-band and see if we can come up with a
solution.
--
Lee Jones [李琼斯]
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v2 2/3] spi: sprd-adi: Remove code for storing the reboot mode
2025-11-10 19:08 [PATCH v2 0/3] mfd: sprd-sc27xx: Move poweroff/reboot support to the parent MFD driver Otto Pflüger
2025-11-10 19:08 ` [PATCH v2 1/3] mfd: sprd-sc27xx: Integrate power off and reboot support Otto Pflüger
@ 2025-11-10 19:08 ` Otto Pflüger
2025-11-10 19:09 ` [PATCH v2 3/3] power: reset: sc27xx: Drop unused driver Otto Pflüger
2025-11-19 6:33 ` [PATCH v2 0/3] mfd: sprd-sc27xx: Move poweroff/reboot support to the parent MFD driver Baolin Wang
3 siblings, 0 replies; 9+ messages in thread
From: Otto Pflüger @ 2025-11-10 19:08 UTC (permalink / raw)
To: Lee Jones, Orson Zhai, Baolin Wang, Chunyan Zhang, Mark Brown,
Sebastian Reichel
Cc: Rob Herring, linux-kernel, linux-spi, linux-pm, Otto Pflüger
This functionality is now provided by the PMIC driver. Ideally, the
entire reboot code should be removed since it does not belong in the bus
driver, but it is kept for now since there is no driver for the PMIC
watchdog on SC2731 yet.
Acked-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Otto Pflüger <otto.pflueger@abscue.de>
---
drivers/spi/spi-sprd-adi.c | 73 +---------------------------------------------
1 file changed, 1 insertion(+), 72 deletions(-)
diff --git a/drivers/spi/spi-sprd-adi.c b/drivers/spi/spi-sprd-adi.c
index 262c11d977ea350c3b8a861064d9f109cc57a45e..47e6fbbf9991dbe77ad22e03c9709e6ee3a1b01e 100644
--- a/drivers/spi/spi-sprd-adi.c
+++ b/drivers/spi/spi-sprd-adi.c
@@ -101,27 +101,10 @@
#define BIT_WDG_EN BIT(2)
/* Registers definitions for PMIC */
-#define PMIC_RST_STATUS 0xee8
#define PMIC_MODULE_EN 0xc08
#define PMIC_CLK_EN 0xc18
#define PMIC_WDG_BASE 0x80
-/* Definition of PMIC reset status register */
-#define HWRST_STATUS_SECURITY 0x02
-#define HWRST_STATUS_RECOVERY 0x20
-#define HWRST_STATUS_NORMAL 0x40
-#define HWRST_STATUS_ALARM 0x50
-#define HWRST_STATUS_SLEEP 0x60
-#define HWRST_STATUS_FASTBOOT 0x30
-#define HWRST_STATUS_SPECIAL 0x70
-#define HWRST_STATUS_PANIC 0x80
-#define HWRST_STATUS_CFTREBOOT 0x90
-#define HWRST_STATUS_AUTODLOADER 0xa0
-#define HWRST_STATUS_IQMODE 0xb0
-#define HWRST_STATUS_SPRDISK 0xc0
-#define HWRST_STATUS_FACTORYTEST 0xe0
-#define HWRST_STATUS_WATCHDOG 0xf0
-
/* Use default timeout 50 ms that converts to watchdog values */
#define WDG_LOAD_VAL ((50 * 32768) / 1000)
#define WDG_LOAD_MASK GENMASK(15, 0)
@@ -139,7 +122,6 @@ struct sprd_adi_data {
u32 slave_addr_size;
int (*read_check)(u32 val, u32 reg);
int (*restart)(struct sys_off_data *data);
- void (*wdg_rst)(void *p);
};
struct sprd_adi {
@@ -355,58 +337,10 @@ static int sprd_adi_transfer_one(struct spi_controller *ctlr,
return ret;
}
-static void sprd_adi_set_wdt_rst_mode(void *p)
-{
-#if IS_ENABLED(CONFIG_SPRD_WATCHDOG)
- u32 val;
- struct sprd_adi *sadi = (struct sprd_adi *)p;
-
- /* Init watchdog reset mode */
- sprd_adi_read(sadi, PMIC_RST_STATUS, &val);
- val |= HWRST_STATUS_WATCHDOG;
- sprd_adi_write(sadi, PMIC_RST_STATUS, val);
-#endif
-}
-
static int sprd_adi_restart(struct sprd_adi *sadi, unsigned long mode,
const char *cmd, struct sprd_adi_wdg *wdg)
{
- u32 val, reboot_mode = 0;
-
- if (!cmd)
- reboot_mode = HWRST_STATUS_NORMAL;
- else if (!strncmp(cmd, "recovery", 8))
- reboot_mode = HWRST_STATUS_RECOVERY;
- else if (!strncmp(cmd, "alarm", 5))
- reboot_mode = HWRST_STATUS_ALARM;
- else if (!strncmp(cmd, "fastsleep", 9))
- reboot_mode = HWRST_STATUS_SLEEP;
- else if (!strncmp(cmd, "bootloader", 10))
- reboot_mode = HWRST_STATUS_FASTBOOT;
- else if (!strncmp(cmd, "panic", 5))
- reboot_mode = HWRST_STATUS_PANIC;
- else if (!strncmp(cmd, "special", 7))
- reboot_mode = HWRST_STATUS_SPECIAL;
- else if (!strncmp(cmd, "cftreboot", 9))
- reboot_mode = HWRST_STATUS_CFTREBOOT;
- else if (!strncmp(cmd, "autodloader", 11))
- reboot_mode = HWRST_STATUS_AUTODLOADER;
- else if (!strncmp(cmd, "iqmode", 6))
- reboot_mode = HWRST_STATUS_IQMODE;
- else if (!strncmp(cmd, "sprdisk", 7))
- reboot_mode = HWRST_STATUS_SPRDISK;
- else if (!strncmp(cmd, "tospanic", 8))
- reboot_mode = HWRST_STATUS_SECURITY;
- else if (!strncmp(cmd, "factorytest", 11))
- reboot_mode = HWRST_STATUS_FACTORYTEST;
- else
- reboot_mode = HWRST_STATUS_NORMAL;
-
- /* Record the reboot mode */
- sprd_adi_read(sadi, wdg->rst_sts, &val);
- val &= ~HWRST_STATUS_WATCHDOG;
- val |= reboot_mode;
- sprd_adi_write(sadi, wdg->rst_sts, val);
+ u32 val;
/* Enable the interface clock of the watchdog */
sprd_adi_read(sadi, wdg->wdg_en, &val);
@@ -448,7 +382,6 @@ static int sprd_adi_restart_sc9860(struct sys_off_data *data)
{
struct sprd_adi_wdg wdg = {
.base = PMIC_WDG_BASE,
- .rst_sts = PMIC_RST_STATUS,
.wdg_en = PMIC_MODULE_EN,
.wdg_clk = PMIC_CLK_EN,
};
@@ -568,9 +501,6 @@ static int sprd_adi_probe(struct platform_device *pdev)
sprd_adi_hw_init(sadi);
- if (sadi->data->wdg_rst)
- sadi->data->wdg_rst(sadi);
-
ctlr->dev.of_node = pdev->dev.of_node;
ctlr->bus_num = pdev->id;
ctlr->num_chipselect = num_chipselect;
@@ -606,7 +536,6 @@ static struct sprd_adi_data sc9860_data = {
.slave_addr_size = ADI_10BIT_SLAVE_ADDR_SIZE,
.read_check = sprd_adi_read_check_r2,
.restart = sprd_adi_restart_sc9860,
- .wdg_rst = sprd_adi_set_wdt_rst_mode,
};
static struct sprd_adi_data sc9863_data = {
--
2.50.0
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH v2 3/3] power: reset: sc27xx: Drop unused driver
2025-11-10 19:08 [PATCH v2 0/3] mfd: sprd-sc27xx: Move poweroff/reboot support to the parent MFD driver Otto Pflüger
2025-11-10 19:08 ` [PATCH v2 1/3] mfd: sprd-sc27xx: Integrate power off and reboot support Otto Pflüger
2025-11-10 19:08 ` [PATCH v2 2/3] spi: sprd-adi: Remove code for storing the reboot mode Otto Pflüger
@ 2025-11-10 19:09 ` Otto Pflüger
2025-11-19 6:33 ` [PATCH v2 0/3] mfd: sprd-sc27xx: Move poweroff/reboot support to the parent MFD driver Baolin Wang
3 siblings, 0 replies; 9+ messages in thread
From: Otto Pflüger @ 2025-11-10 19:09 UTC (permalink / raw)
To: Lee Jones, Orson Zhai, Baolin Wang, Chunyan Zhang, Mark Brown,
Sebastian Reichel
Cc: Rob Herring, linux-kernel, linux-spi, linux-pm, Otto Pflüger,
Sebastian Reichel
This driver was never actually probed because it was missing an OF match
table and was not integrated into the MFD driver. Remove it now that the
power off functionality is handled directly in the MFD driver.
Acked-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Otto Pflüger <otto.pflueger@abscue.de>
---
drivers/power/reset/Kconfig | 9 ----
drivers/power/reset/Makefile | 1 -
drivers/power/reset/sc27xx-poweroff.c | 79 -----------------------------------
3 files changed, 89 deletions(-)
diff --git a/drivers/power/reset/Kconfig b/drivers/power/reset/Kconfig
index f6c1bcbb57deff3568d6b1b326454add3b3bbf06..007e2cd53bbfba8dddcd1a71118ddaf5ec47c0ff 100644
--- a/drivers/power/reset/Kconfig
+++ b/drivers/power/reset/Kconfig
@@ -329,15 +329,6 @@ config SYSCON_REBOOT_MODE
register, then the bootloader can read it to take different
action according to the mode.
-config POWER_RESET_SC27XX
- tristate "Spreadtrum SC27xx PMIC power-off driver"
- depends on MFD_SC27XX_PMIC || COMPILE_TEST
- help
- This driver supports powering off a system through
- Spreadtrum SC27xx series PMICs. The SC27xx series
- PMICs includes the SC2720, SC2721, SC2723, SC2730
- and SC2731 chips.
-
config NVMEM_REBOOT_MODE
tristate "Generic NVMEM reboot mode driver"
depends on OF
diff --git a/drivers/power/reset/Makefile b/drivers/power/reset/Makefile
index 0e4ae6f6b5c55729cf60846d47e6fe0fec24f3cc..14876511c675bd52a99a10890cd685a254f0e030 100644
--- a/drivers/power/reset/Makefile
+++ b/drivers/power/reset/Makefile
@@ -38,6 +38,5 @@ obj-$(CONFIG_POWER_RESET_SYSCON_POWEROFF) += syscon-poweroff.o
obj-$(CONFIG_POWER_RESET_RMOBILE) += rmobile-reset.o
obj-$(CONFIG_REBOOT_MODE) += reboot-mode.o
obj-$(CONFIG_SYSCON_REBOOT_MODE) += syscon-reboot-mode.o
-obj-$(CONFIG_POWER_RESET_SC27XX) += sc27xx-poweroff.o
obj-$(CONFIG_NVMEM_REBOOT_MODE) += nvmem-reboot-mode.o
obj-$(CONFIG_POWER_MLXBF) += pwr-mlxbf.o
diff --git a/drivers/power/reset/sc27xx-poweroff.c b/drivers/power/reset/sc27xx-poweroff.c
deleted file mode 100644
index 90287c31992c4889f9241e82a21a1949ecca7702..0000000000000000000000000000000000000000
--- a/drivers/power/reset/sc27xx-poweroff.c
+++ /dev/null
@@ -1,79 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * Copyright (C) 2018 Spreadtrum Communications Inc.
- * Copyright (C) 2018 Linaro Ltd.
- */
-
-#include <linux/cpu.h>
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/platform_device.h>
-#include <linux/pm.h>
-#include <linux/regmap.h>
-#include <linux/syscore_ops.h>
-
-#define SC27XX_PWR_PD_HW 0xc2c
-#define SC27XX_PWR_OFF_EN BIT(0)
-#define SC27XX_SLP_CTRL 0xdf0
-#define SC27XX_LDO_XTL_EN BIT(3)
-
-static struct regmap *regmap;
-
-/*
- * On Spreadtrum platform, we need power off system through external SC27xx
- * series PMICs, and it is one similar SPI bus mapped by regmap to access PMIC,
- * which is not fast io access.
- *
- * So before stopping other cores, we need release other cores' resource by
- * taking cpus down to avoid racing regmap or spi mutex lock when poweroff
- * system through PMIC.
- */
-static void sc27xx_poweroff_shutdown(void)
-{
-#ifdef CONFIG_HOTPLUG_CPU
- int cpu;
-
- for_each_online_cpu(cpu) {
- if (cpu != smp_processor_id())
- remove_cpu(cpu);
- }
-#endif
-}
-
-static struct syscore_ops poweroff_syscore_ops = {
- .shutdown = sc27xx_poweroff_shutdown,
-};
-
-static void sc27xx_poweroff_do_poweroff(void)
-{
- /* Disable the external subsys connection's power firstly */
- regmap_write(regmap, SC27XX_SLP_CTRL, SC27XX_LDO_XTL_EN);
-
- regmap_write(regmap, SC27XX_PWR_PD_HW, SC27XX_PWR_OFF_EN);
-}
-
-static int sc27xx_poweroff_probe(struct platform_device *pdev)
-{
- if (regmap)
- return -EINVAL;
-
- regmap = dev_get_regmap(pdev->dev.parent, NULL);
- if (!regmap)
- return -ENODEV;
-
- pm_power_off = sc27xx_poweroff_do_poweroff;
- register_syscore_ops(&poweroff_syscore_ops);
- return 0;
-}
-
-static struct platform_driver sc27xx_poweroff_driver = {
- .probe = sc27xx_poweroff_probe,
- .driver = {
- .name = "sc27xx-poweroff",
- },
-};
-module_platform_driver(sc27xx_poweroff_driver);
-
-MODULE_DESCRIPTION("Power off driver for SC27XX PMIC Device");
-MODULE_AUTHOR("Baolin Wang <baolin.wang@unisoc.com>");
-MODULE_LICENSE("GPL v2");
--
2.50.0
^ permalink raw reply related [flat|nested] 9+ messages in thread* Re: [PATCH v2 0/3] mfd: sprd-sc27xx: Move poweroff/reboot support to the parent MFD driver
2025-11-10 19:08 [PATCH v2 0/3] mfd: sprd-sc27xx: Move poweroff/reboot support to the parent MFD driver Otto Pflüger
` (2 preceding siblings ...)
2025-11-10 19:09 ` [PATCH v2 3/3] power: reset: sc27xx: Drop unused driver Otto Pflüger
@ 2025-11-19 6:33 ` Baolin Wang
2025-11-21 2:29 ` Cixi Geng
3 siblings, 1 reply; 9+ messages in thread
From: Baolin Wang @ 2025-11-19 6:33 UTC (permalink / raw)
To: Otto Pflüger, Lee Jones, Orson Zhai, Chunyan Zhang,
Mark Brown, Sebastian Reichel, Cixi Geng
Cc: Rob Herring, linux-kernel, linux-spi, linux-pm, Sebastian Reichel
CC Cixi.
On 2025/11/11 03:08, Otto Pflüger wrote:
> Registers for powering off the system are present in all SC27xx-series
> PMICs, although their locations vary between the specific PMIC models.
> On systems using these chips, the PMIC can always power off the system
> and is usually the only chip capable of doing this. Similarly, the PMICs
> (except for SC2731) contain a reset register that can always be used to
> restart the system.
>
> There is an existing sc27xx-poweroff driver, but it currently only works
> on SC2731 and is not probed anywhere since it is missing an OF match
> table and is not instantiated by the MFD driver. Reboot for SC2731 is
> implemented in drivers/spi/spi-sprd-adi.c, which is not really an
> appropriate location for PMIC-specific code.
>
> Since a separate device tree node for the poweroff support would not
> provide anything useful (see [1]) and passing platform-specific data
> between drivers is unnecessarily complex for such a simple feature,
> reimplement the poweroff functionality in the main MFD driver. While at
> it, add support for the newer SC2730 PMIC and its hardware reset
> register.
>
> Reboot is special because it requires storing the reboot mode. Move the
> existing code for this from the SPI bus driver to the MFD driver.
>
> [1]: https://lore.kernel.org/all/20251002025344.GA2958334-robh@kernel.org/
>
> Signed-off-by: Otto Pflüger <otto.pflueger@abscue.de>
> ---
Overall, it looks reasonable to me, but I cannot test your patchset
right now due to the lack of hardware. Cixi (who is from Unisoc), could
you help test this patchset? Thanks.
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [PATCH v2 0/3] mfd: sprd-sc27xx: Move poweroff/reboot support to the parent MFD driver
2025-11-19 6:33 ` [PATCH v2 0/3] mfd: sprd-sc27xx: Move poweroff/reboot support to the parent MFD driver Baolin Wang
@ 2025-11-21 2:29 ` Cixi Geng
0 siblings, 0 replies; 9+ messages in thread
From: Cixi Geng @ 2025-11-21 2:29 UTC (permalink / raw)
To: Baolin Wang, Otto Pflüger, Lee Jones, Orson Zhai,
Chunyan Zhang, Mark Brown, Sebastian Reichel
Cc: Rob Herring, linux-kernel, linux-spi, linux-pm, Sebastian Reichel
On 19/11/2025 14:33, Baolin Wang wrote:
> CC Cixi.
>
> On 2025/11/11 03:08, Otto Pflüger wrote:
>> Registers for powering off the system are present in all SC27xx-series
>> PMICs, although their locations vary between the specific PMIC models.
>> On systems using these chips, the PMIC can always power off the system
>> and is usually the only chip capable of doing this. Similarly, the PMICs
>> (except for SC2731) contain a reset register that can always be used to
>> restart the system.
>>
>> There is an existing sc27xx-poweroff driver, but it currently only works
>> on SC2731 and is not probed anywhere since it is missing an OF match
>> table and is not instantiated by the MFD driver. Reboot for SC2731 is
>> implemented in drivers/spi/spi-sprd-adi.c, which is not really an
>> appropriate location for PMIC-specific code.
>>
>> Since a separate device tree node for the poweroff support would not
>> provide anything useful (see [1]) and passing platform-specific data
>> between drivers is unnecessarily complex for such a simple feature,
>> reimplement the poweroff functionality in the main MFD driver. While at
>> it, add support for the newer SC2730 PMIC and its hardware reset
>> register.
>>
>> Reboot is special because it requires storing the reboot mode. Move the
>> existing code for this from the SPI bus driver to the MFD driver.
>>
>> [1]:
>> https://lore.kernel.org/all/20251002025344.GA2958334-robh@kernel.org/
>>
>> Signed-off-by: Otto Pflüger <otto.pflueger@abscue.de>
>> ---
>
> Overall, it looks reasonable to me, but I cannot test your patchset
> right now due to the lack of hardware. Cixi (who is from Unisoc),
> could you help test this patchset? Thanks.
the patchset test reboot function on ums512 is ok.
Tested-by: Cixi Geng <cixi.geng@linux.dev>
^ permalink raw reply [flat|nested] 9+ messages in thread