From: Domenico Andreoli <domenico.andreoli@linux.com>
To: linux-arch@vger.kernel.org
Cc: linux-arm-kernel@lists.infradead.org,
linux-mips@lvger.kernel.org,
Russell King <linux@arm.linux.org.uk>,
Arnd Bergmann <arnd@arndb.de>, Olof Johansson <olof@lixom.net>,
Ralf Baechle <ralf@linux-mips.org>,
Domenico Andreoli <domenico.andreoli@linux.com>
Subject: [PATCH 06/11] ARM: vexpress: use the common machine reset handling
Date: Thu, 31 Oct 2013 07:27:14 +0100 [thread overview]
Message-ID: <20131031062959.813485972@linux.com> (raw)
In-Reply-To: 20131031062708.520968323@linux.com
[-- Attachment #1: arm-machine-reset-vexpress-hooks.patch --]
[-- Type: text/plain, Size: 4352 bytes --]
From: Domenico Andreoli <domenico.andreoli@linux.com>
Proof of concept: vexpress as provider of reset hooks.
Platform hooks implementation.
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>
---
drivers/power/reset/Kconfig | 1 +
drivers/power/reset/vexpress-poweroff.c | 54 +++++++++++++++++++++++---------
2 files changed, 39 insertions(+), 16 deletions(-)
Index: b/drivers/power/reset/Kconfig
===================================================================
--- a/drivers/power/reset/Kconfig
+++ b/drivers/power/reset/Kconfig
@@ -41,6 +41,7 @@ config POWER_RESET_VEXPRESS
bool "ARM Versatile Express power-off and reset driver"
depends on ARM || ARM64
depends on POWER_RESET && VEXPRESS_CONFIG
+ select MACHINE_RESET
help
Power off and reset support for the ARM Ltd. Versatile
Express boards.
Index: b/drivers/power/reset/vexpress-poweroff.c
===================================================================
--- a/drivers/power/reset/vexpress-poweroff.c
+++ b/drivers/power/reset/vexpress-poweroff.c
@@ -19,7 +19,8 @@
#include <linux/vexpress.h>
#include <linux/machine_reset.h>
-#include <asm/system_misc.h>
+static enum reset_func vexpress_get_func(struct platform_device *pdev);
+static int vexpress_set_hook(struct platform_device *pdev);
static void vexpress_reset_do(struct device *dev, const char *what)
{
@@ -40,34 +41,40 @@ static void vexpress_reset_do(struct dev
dev_emerg(dev, "Unable to %s (%d)\n", what, err);
}
-static struct device *vexpress_power_off_device;
-
-static void vexpress_power_off(void)
+static void vexpress_power_off(void *dev)
{
- vexpress_reset_do(vexpress_power_off_device, "power off");
+ vexpress_reset_do(dev, "power off");
}
-static struct device *vexpress_restart_device;
-
-static void vexpress_restart(enum reboot_mode reboot_mode, const char *cmd)
+static void vexpress_restart(void *dev, enum reboot_mode reboot_mode,
+ const char *cmd)
{
- vexpress_reset_do(vexpress_restart_device, "restart");
+ vexpress_reset_do(dev, "restart");
}
static ssize_t vexpress_reset_active_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
- return sprintf(buf, "%d\n", vexpress_restart_device == dev);
+ struct platform_device *pdev;
+ enum reset_func func;
+
+ pdev = container_of(dev, struct platform_device, dev);
+ func = vexpress_get_func(pdev);
+
+ return sprintf(buf, "%d\n", isset_machine_reset(func, dev));
}
static ssize_t vexpress_reset_active_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count)
{
long value;
+ struct platform_device *pdev;
int err = kstrtol(buf, 0, &value);
+ pdev = container_of(dev, struct platform_device, dev);
+
if (!err && value)
- vexpress_restart_device = dev;
+ vexpress_set_hook(pdev);
return err ? err : count;
}
@@ -90,7 +97,7 @@ static struct of_device_id vexpress_rese
{}
};
-static int vexpress_reset_probe(struct platform_device *pdev)
+static enum reset_func vexpress_get_func(struct platform_device *pdev)
{
enum reset_func func;
const struct of_device_id *match =
@@ -101,23 +108,38 @@ static int vexpress_reset_probe(struct p
else
func = pdev->id_entry->driver_data;
+ return func;
+}
+
+static int vexpress_set_hook(struct platform_device *pdev)
+{
+ enum reset_func func;
+ struct reset_hook hook;
+
+ func = vexpress_get_func(pdev);
+ reset_hook_init(&hook);
+
switch (func) {
case RESET_POWER_OFF:
- vexpress_power_off_device = &pdev->dev;
- pm_power_off = vexpress_power_off;
+ hook.power_off = vexpress_power_off;
break;
case RESET_RESTART:
- vexpress_restart_device = &pdev->dev;
- arm_pm_restart = vexpress_restart;
+ hook.restart = vexpress_restart;
device_create_file(&pdev->dev, &dev_attr_active);
break;
default:
return -EINVAL;
};
+ set_machine_reset(func, &hook, &pdev->dev);
return 0;
}
+static int vexpress_reset_probe(struct platform_device *pdev)
+{
+ return vexpress_set_hook(pdev);
+}
+
static const struct platform_device_id vexpress_reset_id_table[] = {
{ .name = "vexpress-reset", .driver_data = RESET_RESTART, },
{ .name = "vexpress-shutdown", .driver_data = RESET_POWER_OFF, },
next prev parent reply other threads:[~2013-10-31 6:30 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-31 6:27 [PATCH 00/11] RFC: Common machine reset handling Domenico Andreoli
2013-10-31 6:27 ` [PATCH 01/11] machine-reset: platform generic handling Domenico Andreoli
2013-10-31 6:27 ` [PATCH 02/11] ARM: use the common machine reset handling Domenico Andreoli
2013-10-31 6:27 ` [PATCH 03/11] ARM64: " Domenico Andreoli
2013-10-31 6:27 ` [PATCH 04/11] MIPS: " Domenico Andreoli
2013-11-01 5:11 ` Vineet Gupta
2013-11-01 5:26 ` Domenico Andreoli
2013-10-31 6:27 ` [PATCH 05/11] ARM: vexpress: consolidate machine reset func Domenico Andreoli
2013-10-31 6:27 ` Domenico Andreoli [this message]
2013-10-31 6:27 ` [PATCH 07/11] ARM: bcm2835: use the common machine reset handling Domenico Andreoli
2013-10-31 6:27 ` [PATCH 08/11] ARM: u300: " Domenico Andreoli
2013-10-31 14:40 ` Linus Walleij
2013-10-31 15:19 ` Domenico Andreoli
2013-10-31 6:27 ` [PATCH 09/11] ARM: tps65910: " Domenico Andreoli
2013-10-31 6:27 ` [PATCH 10/11] max8907: " Domenico Andreoli
2013-10-31 6:27 ` [PATCH 11/11] ARM: sp805: " Domenico Andreoli
2013-10-31 10:21 ` [PATCH 00/11] RFC: Common " Russell King - ARM Linux
2013-10-31 21:49 ` Stephen Warren
2013-11-01 5:16 ` Domenico Andreoli
2013-11-01 15:58 ` Stephen Warren
2013-11-01 16:12 ` Russell King - ARM Linux
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20131031062959.813485972@linux.com \
--to=domenico.andreoli@linux.com \
--cc=arnd@arndb.de \
--cc=linux-arch@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-mips@lvger.kernel.org \
--cc=linux@arm.linux.org.uk \
--cc=olof@lixom.net \
--cc=ralf@linux-mips.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).