power/reset: restart handler patch series
Subsystems (4)
v2 cover power/reset: restart handler patch series
Register with kernel restart handler instead of setting arm_pm_restart directly, plus some other cleanup.
v2: Rebased to master branch of battery tree
PATCH v2 1/6 power/reset: arm-versatile: Register with kernel restart handler
Register with kernel restart handler instead of setting arm_pm_restart directly. Select high priority since the restart handler is instantiated through devicetree, indicating that it should be used if configured.
--- drivers/power/reset/arm-versatile-reboot.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-)
drivers/power/reset/arm-versatile-reboot.c +14 -3
@@ -13,7 +13,6 @@#include <linux/reboot.h> #include <linux/regmap.h> #include <linux/of.h> -#include <asm/system_misc.h> #define INTEGRATOR_HDR_CTRL_OFFSET 0x0C#define INTEGRATOR_HDR_LOCK_OFFSET 0x14
@@ -69,7 +68,8 @@ static const struct of_device_id versatile_reboot_of_match[] = { {}, }; -static void versatile_reboot (enum reboot_mode mode,const char *cmd) +static int versatile_reboot (struct notifier_block *this,unsigned long mode, +void *cmd) {/* Unlock the reset register */ /* Then hit reset on the different machines */
@@ -113,12 +113,20 @@ static void versatile_reboot(enum reboot_mode mode, const char *cmd)break ; }dsb (); + +return NOTIFY_DONE ; } +static struct notifier_block versatile_reboot_nb = { + .notifier_call = versatile_reboot, + .priority =192 , +}; +static int __init versatile_reboot_probe (void ) {const struct of_device_id *reboot_id;struct device_node *np; +int err; np =of_find_matching_node_and_match (NULL , versatile_reboot_of_match, &reboot_id);
@@ -130,7 +138,10 @@ static int __init versatile_reboot_probe(void)if (IS_ERR (syscon_regmap))return PTR_ERR (syscon_regmap); - arm_pm_restart = versatile_reboot; + err =register_restart_handler (&versatile_reboot_nb); +if (err) +return err; +pr_info ("versatile reboot driver registered\n" );return 0 ; }
Signature · 1 line
2.1.0
PATCH v2 2/6 power/reset: at91: Register with kernel restart handler
In reply to Guenter RoeckRegister with kernel restart handler instead of setting arm_pm_restart directly. Register with high priority since the driver unconditionally overwrites other restart handlers if instantiated.
--- drivers/power/reset/at91-reset.c | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-)
drivers/power/reset/at91-reset.c +18 -10
@@ -17,8 +17,6 @@#include <linux/platform_device.h> #include <linux/reboot.h> -#include <asm/system_misc.h> -#include <soc/at91/at91sam9_ddrsdr.h> #include <soc/at91/at91sam9_sdramc.h>
@@ -54,7 +52,8 @@ static void __iomem *at91_ramc_base[2], *at91_rstc_base;* reset register it can be left driving the data bus and * killing the chance of a subsequent boot from NAND */ -static void at91sam9260_restart (enum reboot_mode mode,const char *cmd) +static int at91sam9260_restart (struct notifier_block *this,unsigned long mode, +void *cmd) { asm volatile(/* Align to cache lines */
@@ -76,9 +75,12 @@ static void at91sam9260_restart(enum reboot_mode mode, const char *cmd)"r" (1 ),"r" (AT91_SDRAMC_LPCB_POWER_DOWN ), "r" (AT91_RSTC_KEY | AT91_RSTC_PERRST | AT91_RSTC_PROCRST)); + +return NOTIFY_DONE ; } -static void at91sam9g45_restart (enum reboot_mode mode,const char *cmd) +static int at91sam9g45_restart (struct notifier_block *this,unsigned long mode, +void *cmd) { asm volatile(/*
@@ -117,6 +119,8 @@ static void at91sam9g45_restart(enum reboot_mode mode, const char *cmd) "r" (AT91_DDRSDRC_LPCB_POWER_DOWN), "r" (AT91_RSTC_KEY | AT91_RSTC_PERRST | AT91_RSTC_PROCRST) : "r0"); + + returnNOTIFY_DONE ; }static void __init at91_reset_status (struct platform_device *pdev)
@@ -161,6 +165,10 @@ static struct of_device_id at91_reset_of_match[] = { {/* sentinel */ } }; +static struct notifier_block at91_restart_nb = { + .priority =192 , +}; +static int at91_reset_of_probe (struct platform_device *pdev) {const struct of_device_id *match;
@@ -183,9 +191,8 @@ static int at91_reset_of_probe(struct platform_device *pdev) } match =of_match_node (at91_reset_of_match, pdev->dev.of_node); - arm_pm_restart = match->data; - -return 0 ; + at91_restart_nb.notifier_call = match->data; +return register_restart_handler (&at91_restart_nb); }static int at91_reset_platform_probe (struct platform_device *pdev)
@@ -212,10 +219,11 @@ static int at91_reset_platform_probe(struct platform_device *pdev) } match =platform_get_device_id (pdev); - arm_pm_restart = (void (*)(enum reboot_mode ,const char *)) - match->driver_data; + at91_restart_nb.notifier_call = + (int (*)(struct notifier_block *, +unsigned long ,void *)) match->driver_data; -return 0 ; +return register_restart_handler (&at91_restart_nb); }static int at91_reset_probe (struct platform_device *pdev)
Signature · 1 line
2.1.0
PATCH v2 3/6 power/reset: Remove sun6i reboot driver
In reply to Guenter Roecksun6i restart is now handled by its watchdog driver directly, so this driver is no longer needed.
--- drivers/power/reset/Kconfig | 6 --- drivers/power/reset/Makefile | 1 - drivers/power/reset/sun6i-reboot.c | 85 -------------------------------------- 3 files changed, 92 deletions(-) delete mode 100644 drivers/power/reset/sun6i-reboot.c
drivers/power/reset/Kconfig +0 -6
@@ -109,12 +109,6 @@ config POWER_RESET_RESTART Instead they restart, and u-boot holds the SoC until the user presses a key. u-boot then boots into Linux. -config POWER_RESET_SUN6I - bool "Allwinner A31 SoC reset driver" - depends on ARCH_SUNXI - help - Reboot support for the Allwinner A31 SoCs. - config POWER_RESET_ST bool "ST restart power-off driver" depends on ARCH_STI
drivers/power/reset/Makefile +0 -1
@@ -11,7 +11,6 @@ obj-$(CONFIG_POWER_RESET_MSM) += msm-poweroff.o obj-$(CONFIG_POWER_RESET_LTC2952) += ltc2952-poweroff.o obj-$(CONFIG_POWER_RESET_QNAP) += qnap-poweroff.o obj-$(CONFIG_POWER_RESET_RESTART) += restart-poweroff.o -obj-$(CONFIG_POWER_RESET_SUN6I) += sun6i-reboot.o obj-$(CONFIG_POWER_RESET_ST) += st-poweroff.o obj-$(CONFIG_POWER_RESET_VERSATILE) += arm-versatile-reboot.o obj-$(CONFIG_POWER_RESET_VEXPRESS) += vexpress-poweroff.o
drivers/power/reset/sun6i-reboot.c deleted +0 -85
85 lines not on this page · raw message
Signature · 1 line
2.1.0
PATCH v2 4/6 power/reset: st-poweroff: Register with kernel restart handler
In reply to Guenter RoeckRegister with kernel restart handler instead of setting arm_pm_restart directly. Select high priority since the restart handler is instantiated through devicetree, indicating that it should be used if configured.
--- drivers/power/reset/st-poweroff.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-)
drivers/power/reset/st-poweroff.c +11 -6
@@ -15,10 +15,9 @@#include <linux/of_platform.h> #include <linux/platform_device.h> #include <linux/mfd/syscon.h> +#include <linux/reboot.h> #include <linux/regmap.h> -#include <asm/system_misc.h> -struct reset_syscfg {struct regmap *regmap;/* syscfg used for reset */
@@ -75,7 +74,8 @@ static struct reset_syscfg stid127_reset = {static struct reset_syscfg *st_restart_syscfg; -static void st_restart (enum reboot_mode reboot_mode,const char *cmd) +static int st_restart (struct notifier_block *this,unsigned long mode, +void *cmd) {/* reset syscfg updated */ regmap_update_bits(st_restart_syscfg->regmap,
@@ -88,8 +88,15 @@ static void st_restart(enum reboot_mode reboot_mode, const char *cmd) st_restart_syscfg->offset_rst_msk, st_restart_syscfg->mask_rst_msk, 0); + +return NOTIFY_DONE ; } +static struct notifier_block st_restart_nb = { + .notifier_call = st_restart, + .priority =192 , +}; +static struct of_device_id st_reset_of_match[] = { { .compatible ="st,stih415-restart" ,
@@ -126,9 +133,7 @@ static int st_reset_probe(struct platform_device *pdev)return PTR_ERR (st_restart_syscfg->regmap); } - arm_pm_restart = st_restart; - -return 0 ; +return register_restart_handler (&st_restart_nb); }static struct platform_driver st_reset_driver = {
Signature · 1 line
2.1.0
PATCH v2 5/6 power/reset: st-poweroff: Fix misleading Kconfig description
In reply to Guenter RoeckThe st-poweroff driver does not really power off the system but resets it, so Kconfig should not claim that the driver would handle power-off.
--- drivers/power/reset/Kconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/power/reset/Kconfig +2 -2
@@ -110,10 +110,10 @@ config POWER_RESET_RESTART user presses a key. u-boot then boots into Linux. config POWER_RESET_ST - bool "ST restart power-off driver" + bool "ST restart driver" depends on ARCH_STI help - Power off and reset support for STMicroelectronics boards. + Reset support for STMicroelectronics boards. config POWER_RESET_VERSATILE bool "ARM Versatile family reboot driver"
Signature · 1 line
2.1.0
PATCH v2 6/6 power/reset: restart-poweroff: Remove arm dependencies
In reply to Guenter RoeckThis driver is now arm specific anymore, so there is no need to include an arm specific include file. Also drop unnecessary depencency on ARM from Kconfig.
--- drivers/power/reset/Kconfig | 1 - drivers/power/reset/restart-poweroff.c | 1 - 2 files changed, 2 deletions(-)
drivers/power/reset/Kconfig +0 -1
@@ -103,7 +103,6 @@ config POWER_RESET_QNAP config POWER_RESET_RESTART bool "Restart power-off driver" - depends on ARM help Some boards don't actually have the ability to power off. Instead they restart, and u-boot holds the SoC until the
drivers/power/reset/restart-poweroff.c +0 -1
@@ -16,7 +16,6 @@#include <linux/of_platform.h> #include <linux/module.h> #include <linux/reboot.h> -#include <asm/system_misc.h> static void restart_poweroff_do_poweroff (void ) {
Signature · 1 line
2.1.0
Sebastian Reichel
maintainerHi Guenter,
Quoted 4 lines · Guenter Roeck
Register with kernel restart handler instead of setting
arm_pm_restartdirectly, plus some other cleanup.v2: Rebased to master branch of battery tree
Thanks, series applied.
-- Sebastian