Skip to contentSkip to conversation

power/reset: arm-versatile: Register with kernel restart handler

PATCH Superseded Guenter Roeck 3 participants 12 messages Jan 25, 2015

Subsystems (4)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#2 lore raw

PATCH 3/6 power/reset: Remove sun6i reboot driver

In reply to Guenter Roeck

sun6i 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
index 028e765..720a310 100644
@@ -110,12 +110,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
index 1d4804d..2f5e549 100644
@@ -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
#0 lore raw

PATCH 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
index 5b08bff..e533812 100644
@@ -13,7 +13,6 @@
 #include <linux/reboot.h>
 #include <linux/regmap.h>
 #include <linux/of.h>
-#include <asm/system_misc.h>
 
 #define REALVIEW_SYS_LOCK_OFFSET	0x20
 #define REALVIEW_SYS_LOCK_VAL		0xA05F
@@ -57,7 +56,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 */
 	regmap_write(syscon_regmap, REALVIEW_SYS_LOCK_OFFSET,
@@ -87,12 +87,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);
@@ -104,7 +112,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
#1 lore raw

PATCH 2/6 power/reset: at91: Register with kernel restart handler

Register 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
index 69a75d99..13584e2 100644
@@ -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");
+
+	return NOTIFY_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
#4 lore raw

PATCH 4/6 power/reset: st-poweroff: Register with kernel restart handler

In reply to Guenter Roeck

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/st-poweroff.c | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)
drivers/power/reset/st-poweroff.c +11 -6
index a0acf25..27383de 100644
@@ -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
#5 lore raw

PATCH 5/6 power/reset: st-poweroff: Fix misleading Kconfig description

In reply to Guenter Roeck

The 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
index 720a310..4b4b910 100644
@@ -111,10 +111,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
#6 lore raw

PATCH 6/6 power/reset: restart-poweroff: Remove arm dependencies

In reply to Guenter Roeck

This 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
index 4b4b910..a4fd2cb 100644
@@ -104,7 +104,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
index f46f2c2..41b22c4 100644
@@ -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
Acked-by on v1 3/6
#3 lore raw

Re: [PATCH 3/6] power/reset: Remove sun6i reboot driver

In reply to Guenter Roeck
Quoted 4 lines · Guenter Roeck

sun6i restart is now handled by its watchdog driver directly, so this driver is no longer needed.

Thanks!
Maxime

Signature · 10 lines
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20150125/128b8f3e/attachment.sig>
#8 lore raw
Quoted 11 lines · Sebastian Reichel

Hi,

Quoted 3 lines · Guenter Roeck

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.

This does not apply clean for me. Please rebase on top of

http://git.infradead.org/battery-2.6.git/

Hi Sebastian,

Sure, will do. I assume you mean battery/next-next since it applies cleanly to battery/master.

Thanks,
Guenter

#9 lore raw

Hi Guenter,

Quoted 6 lines · Guenter Roeck
Quoted 5 lines · Sebastian Reichel
Quoted 3 lines · Guenter Roeck

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.

Quoted 6 lines
Quoted 3 lines

This does not apply clean for me. Please rebase on top of

http://git.infradead.org/battery-2.6.git/

Sure, will do. I assume you mean battery/next-next since it applies cleanly to battery/master.

uhm no, I was talking about battery/master.
It does not apply cleanly for me:

Applying: power/reset: arm-versatile: Register with kernel restart handler
error: patch failed: drivers/power/reset/arm-versatile-reboot.c:13
error: drivers/power/reset/arm-versatile-reboot.c: patch does not apply

The error looks correct:

$ grep -A8 "+++ b/drivers/power/reset/arm-versatile-reboot.c" guenter_roeck.patch
+++ b/drivers/power/reset/arm-versatile-reboot.c
@@ -13,7 +13,6 @@
 #include <linux/reboot.h>
 #include <linux/regmap.h>
 #include <linux/of.h>
-#include <asm/system_misc.h>

#define REALVIEW_SYS_LOCK_OFFSET 0x20
#define REALVIEW_SYS_LOCK_VAL 0xA05F

$ git blame -L13,20 drivers/power/reset/arm-versatile-reboot.c
0e545f57 (Linus Walleij 2014-05-22 10:20:38 +0200 13) #include <linux/reboot.h>
0e545f57 (Linus Walleij 2014-05-22 10:20:38 +0200 14) #include <linux/regmap.h>
0e545f57 (Linus Walleij 2014-05-22 10:20:38 +0200 15) #include <linux/of.h>
0e545f57 (Linus Walleij 2014-05-22 10:20:38 +0200 16) #include <asm/system_misc.h>
0e545f57 (Linus Walleij 2014-05-22 10:20:38 +0200 17) 
0160817d (Linus Walleij 2014-12-19 16:56:27 +0100 18) #define INTEGRATOR_HDR_CTRL_OFFSET        0x0C
0160817d (Linus Walleij 2014-12-19 16:56:27 +0100 19) #define INTEGRATOR_HDR_LOCK_OFFSET        0x14
0160817d (Linus Walleij 2014-12-19 16:56:27 +0100 20) #define INTEGRATOR_CM_CTRL_RESET  (1 << 3)
$ git show -s --format=%ci 0160817d
2015-01-20 13:58:27 +0100

Maybe update the battery/master branch?

-- Sebastian

#10 lore raw

Hi Sebastian,

Quoted 3 lines · Sebastian Reichel

Maybe update the battery/master branch?

I thought I did. Tip is "99a7956 power: ds2782_battery: Simplify the PM hooks"

Does that look correct ?

Guenter

#11 lore raw
Quoted 11 lines · Guenter Roeck

Hi Sebastian,

Quoted 3 lines · Sebastian Reichel

Maybe update the battery/master branch?

I thought I did. Tip is "99a7956 power: ds2782_battery: Simplify the PM hooks"

Does that look correct ?

Never mind, that was -next. I just resent the series, rebased on top of battery/master.

Guenter