diff mbox

[08/11] ARM: u300: use the common machine reset handling

Message ID 20131031063000.361406973@linux.com (mailing list archive)
State New, archived
Headers show

Commit Message

Domenico Andreoli Oct. 31, 2013, 6:27 a.m. UTC
From: Domenico Andreoli <domenico.andreoli@linux.com>

Proof of concept: u300 as provider of reset hooks.

Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: Russell King <linux@arm.linux.org.uk>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Olof Johansson <olof@lixom.net>
Cc: linux-arm-kernel@lists.infradead.org
Signed-off-by: Domenico Andreoli <domenico.andreoli@linux.com>
---
 arch/arm/mach-u300/regulator.c |   23 ++++++++++++++---------
 drivers/regulator/Kconfig      |    1 +
 2 files changed, 15 insertions(+), 9 deletions(-)

Comments

Linus Walleij Oct. 31, 2013, 2:40 p.m. UTC | #1
On Wed, Oct 30, 2013 at 11:27 PM, Domenico Andreoli
<domenico.andreoli@linux.com> wrote:

> From: Domenico Andreoli <domenico.andreoli@linux.com>
>
> Proof of concept: u300 as provider of reset hooks.

Do you have a u300 to test this on or are you just guessing?

Anyway, concept looks correct, so Acked-by given that the
overall idea is accepted.

Yours,
Linus Walleij
Domenico Andreoli Oct. 31, 2013, 3:19 p.m. UTC | #2
On Thu, Oct 31, 2013 at 07:40:25AM -0700, Linus Walleij wrote:
> On Wed, Oct 30, 2013 at 11:27 PM, Domenico Andreoli
> <domenico.andreoli@linux.com> wrote:
> 
> > From: Domenico Andreoli <domenico.andreoli@linux.com>
> >
> > Proof of concept: u300 as provider of reset hooks.
> 
> Do you have a u300 to test this on or are you just guessing?

I don't have any u300, I picked it randomly. It's just to show some usage
and possibly discuss it. There are quite a lot of these hooks all around.

> Anyway, concept looks correct, so Acked-by given that the
> overall idea is accepted.

uhm.. don't see any general acceptance right now. maybe later..

thanks,
Domenico
diff mbox

Patch

Index: b/drivers/regulator/Kconfig
===================================================================
--- a/drivers/regulator/Kconfig
+++ b/drivers/regulator/Kconfig
@@ -106,6 +106,7 @@  config REGULATOR_AB3100
 	tristate "ST-Ericsson AB3100 Regulator functions"
 	depends on AB3100_CORE
 	default y if AB3100_CORE
+	select MACHINE_RESET
 	help
 	 These regulators correspond to functionality in the
 	 AB3100 analog baseband dealing with power regulators
Index: b/arch/arm/mach-u300/regulator.c
===================================================================
--- a/arch/arm/mach-u300/regulator.c
+++ b/arch/arm/mach-u300/regulator.c
@@ -17,6 +17,7 @@ 
 #include <linux/regulator/consumer.h>
 #include <linux/mfd/syscon.h>
 #include <linux/regmap.h>
+#include <linux/machine_reset.h>
 
 /* Power Management Control 16bit (R/W) */
 #define U300_SYSCON_PMCR					(0x50)
@@ -24,20 +25,14 @@ 
 #define U300_SYSCON_PMCR_PWR_MGNT_ENABLE			(0x0001)
 
 /*
- * Regulators that power the board and chip and which are
- * not copuled to specific drivers are hogged in these
- * instances.
- */
-static struct regulator *main_power_15;
-
-/*
  * This function is used from pm.h to shut down the system by
  * resetting all regulators in turn and then disable regulator
  * LDO D (main power).
  */
-void u300_pm_poweroff(void)
+void u300_pm_poweroff(void *dev)
 {
 	sigset_t old, all;
+	struct regulator *main_power_15 = dev;
 
 	sigfillset(&all);
 	if (!sigprocmask(SIG_BLOCK, &all, &old)) {
@@ -51,6 +46,11 @@  void u300_pm_poweroff(void)
 	return;
 }
 
+static void u300_reset_hook_release(void *dev)
+{
+	regulator_put(dev);
+}
+
 /*
  * Hog the regulators needed to power up the board.
  */
@@ -58,7 +58,9 @@  static int __init __u300_init_boardpower
 {
 	struct device_node *np = pdev->dev.of_node;
 	struct device_node *syscon_np;
+	struct regulator *main_power_15;
 	struct regmap *regmap;
+	struct reset_hook hook;
 	int err;
 
 	pr_info("U300: setting up board power\n");
@@ -98,7 +100,10 @@  static int __init __u300_init_boardpower
 			   U300_SYSCON_PMCR_DCON_ENABLE, 0);
 
 	/* Register globally exported PM poweroff hook */
-	pm_power_off = u300_pm_poweroff;
+	reset_hook_init(&hook);
+	hook.power_off = u300_pm_poweroff;
+	hook.release = u300_reset_hook_release;
+	set_machine_reset(RESET_POWER_OFF, &hook, main_power_15);
 
 	return 0;
 }