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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Domenico Andreoli <domenico.andreoli@xxxxxxxxx>

Proof of concept: u300 as provider of reset hooks.

Cc: Linus Walleij <linus.walleij@xxxxxxxxxx>
Cc: Russell King <linux@xxxxxxxxxxxxxxxx>
Cc: Arnd Bergmann <arnd@xxxxxxxx>
Cc: Olof Johansson <olof@xxxxxxxxx>
Cc: linux-arm-kernel@xxxxxxxxxxxxxxxxxxx
Signed-off-by: Domenico Andreoli <domenico.andreoli@xxxxxxxxx>
---
 arch/arm/mach-u300/regulator.c |   23 ++++++++++++++---------
 drivers/regulator/Kconfig      |    1 +
 2 files changed, 15 insertions(+), 9 deletions(-)

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;
 }

--
To unsubscribe from this list: send the line "unsubscribe linux-arch" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel]     [Kernel Newbies]     [x86 Platform Driver]     [Netdev]     [Linux Wireless]     [Netfilter]     [Bugtraq]     [Linux Filesystems]     [Yosemite Discussion]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]

  Powered by Linux