Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1275976 > unrolled thread

[PATCH] reset: ath79: Add system restart support

Started byAlban Bedel <albeu@free.fr>
First post2015-11-24 01:10 +0100
Last post2015-11-24 19:40 +0100
Articles 3 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] reset: ath79: Add system restart support Alban Bedel <albeu@free.fr> - 2015-11-24 01:10 +0100
    Re: [PATCH] reset: ath79: Add system restart support Philipp Zabel <p.zabel@pengutronix.de> - 2015-11-24 13:10 +0100
      Re: [PATCH] reset: ath79: Add system restart support Alban <albeu@free.fr> - 2015-11-24 19:40 +0100

#1275976 — [PATCH] reset: ath79: Add system restart support

FromAlban Bedel <albeu@free.fr>
Date2015-11-24 01:10 +0100
Subject[PATCH] reset: ath79: Add system restart support
Message-ID<qy9lg-zO-9@gated-at.bofh.it>
Add a system restart handler that use the FULL_CHIP_RESET bit of the
reset controller.

Signed-off-by: Alban Bedel <albeu@free.fr>
---
 drivers/reset/reset-ath79.c | 30 +++++++++++++++++++++++++++++-
 1 file changed, 29 insertions(+), 1 deletion(-)

diff --git a/drivers/reset/reset-ath79.c b/drivers/reset/reset-ath79.c
index 9aaf646..692fc89 100644
--- a/drivers/reset/reset-ath79.c
+++ b/drivers/reset/reset-ath79.c
@@ -15,13 +15,17 @@
 #include <linux/module.h>
 #include <linux/platform_device.h>
 #include <linux/reset-controller.h>
+#include <linux/reboot.h>
 
 struct ath79_reset {
 	struct reset_controller_dev rcdev;
+	struct notifier_block restart_nb;
 	void __iomem *base;
 	spinlock_t lock;
 };
 
+#define FULL_CHIP_RESET 24
+
 static int ath79_reset_update(struct reset_controller_dev *rcdev,
 			unsigned long id, bool assert)
 {
@@ -72,10 +76,22 @@ static struct reset_control_ops ath79_reset_ops = {
 	.status = ath79_reset_status,
 };
 
+static int ath79_reset_restart_handler(struct notifier_block *nb,
+				unsigned long action, void *data)
+{
+	struct ath79_reset *ath79_reset =
+		container_of(nb, struct ath79_reset, restart_nb);
+
+	ath79_reset_assert(&ath79_reset->rcdev, FULL_CHIP_RESET);
+
+	return NOTIFY_DONE;
+}
+
 static int ath79_reset_probe(struct platform_device *pdev)
 {
 	struct ath79_reset *ath79_reset;
 	struct resource *res;
+	int err;
 
 	ath79_reset = devm_kzalloc(&pdev->dev,
 				sizeof(*ath79_reset), GFP_KERNEL);
@@ -96,13 +112,25 @@ static int ath79_reset_probe(struct platform_device *pdev)
 	ath79_reset->rcdev.of_reset_n_cells = 1;
 	ath79_reset->rcdev.nr_resets = 32;
 
-	return reset_controller_register(&ath79_reset->rcdev);
+	err = reset_controller_register(&ath79_reset->rcdev);
+	if (err)
+		return err;
+
+	ath79_reset->restart_nb.notifier_call = ath79_reset_restart_handler;
+	ath79_reset->restart_nb.priority = 128;
+
+	err = register_restart_handler(&ath79_reset->restart_nb);
+	if (err)
+		dev_warn(&pdev->dev, "Failed to register restart handler\n");
+
+	return 0;
 }
 
 static int ath79_reset_remove(struct platform_device *pdev)
 {
 	struct ath79_reset *ath79_reset = platform_get_drvdata(pdev);
 
+	unregister_restart_handler(&ath79_reset->restart_nb);
 	reset_controller_unregister(&ath79_reset->rcdev);
 
 	return 0;
-- 
2.0.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1276367

FromPhilipp Zabel <p.zabel@pengutronix.de>
Date2015-11-24 13:10 +0100
Message-ID<qykA1-7Vh-19@gated-at.bofh.it>
In reply to#1275976
Hi Alban,

Am Dienstag, den 24.11.2015, 01:00 +0100 schrieb Alban Bedel:
> Add a system restart handler that use the FULL_CHIP_RESET bit of the
> reset controller.
> 
> Signed-off-by: Alban Bedel <albeu@free.fr>

Applied, thanks.

Btw, should this driver #include <linux/io.h> for readl/writel?

regards
Philipp

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1276713

FromAlban <albeu@free.fr>
Date2015-11-24 19:40 +0100
Message-ID<qyqFs-3m4-23@gated-at.bofh.it>
In reply to#1276367
On Tue, 24 Nov 2015 13:01:46 +0100
Philipp Zabel <p.zabel@pengutronix.de> wrote:

> Hi Alban,
> 
> Am Dienstag, den 24.11.2015, 01:00 +0100 schrieb Alban Bedel:
> > Add a system restart handler that use the FULL_CHIP_RESET bit of the
> > reset controller.
> > 
> > Signed-off-by: Alban Bedel <albeu@free.fr>
> 
> Applied, thanks.

Thanks to you :)

> Btw, should this driver #include <linux/io.h> for readl/writel?

Good question :) It turns out to be a MIPS glitch, asm/io.h is included
by asm/page.h which here come from linux/module.h. But we shouldn't
rely on this glitch and the driver should #include <linux/io.h>.
I'll fix this and add support for CONFIG_COMPILE_TEST to better catch
this kind of bugs in the future.

Alban
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web