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


Groups > linux.kernel > #1204909

[PATCH v3 3/5] power/reset: at91-reset: get and use slow clock

From Alexandre Belloni <alexandre.belloni@free-electrons.com>
Newsgroups linux.kernel
Subject [PATCH v3 3/5] power/reset: at91-reset: get and use slow clock
Date 2015-08-11 11:20 +0200
Message-ID <pWdSW-L4-17@gated-at.bofh.it> (permalink)
References <pWdSV-L4-5@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Commit dca1a4b5ff6e ("clk: at91: keep slow clk enabled to prevent system
hang") added a workaround for the slow clock as it is not properly handled
by its users.

Get and use the slow clock as it is necessary for the at91 reset
controller.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 drivers/power/reset/at91-reset.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/drivers/power/reset/at91-reset.c b/drivers/power/reset/at91-reset.c
index 120f3dec9574..8f0bcb232149 100644
--- a/drivers/power/reset/at91-reset.c
+++ b/drivers/power/reset/at91-reset.c
@@ -11,6 +11,7 @@
  * warranty of any kind, whether express or implied.
  */
 
+#include <linux/clk.h>
 #include <linux/io.h>
 #include <linux/module.h>
 #include <linux/of_address.h>
@@ -46,6 +47,7 @@ enum reset_type {
 };
 
 static void __iomem *at91_ramc_base[2], *at91_rstc_base;
+static struct clk *sclk;
 
 /*
 * unless the SDRAM is cleanly shutdown before we hit the
@@ -193,9 +195,21 @@ static int __init at91_reset_probe(struct platform_device *pdev)
 	match = of_match_node(at91_reset_of_match, pdev->dev.of_node);
 	at91_restart_nb.notifier_call = match->data;
 
+	sclk = devm_clk_get(&pdev->dev, NULL);
+	if (IS_ERR(sclk))
+		return PTR_ERR(sclk);
+
+	ret = clk_prepare_enable(sclk);
+	if (ret) {
+		dev_err(&pdev->dev, "Could not enable slow clock\n");
+		return ret;
+	}
+
 	ret = register_restart_handler(&at91_restart_nb);
-	if (ret)
+	if (ret) {
+		clk_disable_unprepare(sclk);
 		return ret;
+	}
 
 	at91_reset_status(pdev);
 
@@ -205,6 +219,7 @@ static int __init at91_reset_probe(struct platform_device *pdev)
 static int __exit at91_reset_remove(struct platform_device *pdev)
 {
 	unregister_restart_handler(&at91_restart_nb);
+	clk_disable_unprepare(sclk);
 
 	return 0;
 }
-- 
2.1.4

--
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/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v3 0/5] power/reset: at91: cleanups and slow clock Alexandre Belloni <alexandre.belloni@free-electrons.com> - 2015-08-11 11:20 +0200
  [PATCH v3 4/5] power/reset: at91-poweroff: allow compiling as a module Alexandre Belloni <alexandre.belloni@free-electrons.com> - 2015-08-11 11:20 +0200
  [PATCH v3 3/5] power/reset: at91-reset: get and use slow clock Alexandre Belloni <alexandre.belloni@free-electrons.com> - 2015-08-11 11:20 +0200
  [PATCH v3 2/5] power/reset: at91-reset: allow compiling as a module Alexandre Belloni <alexandre.belloni@free-electrons.com> - 2015-08-11 11:20 +0200
  [PATCH v3 1/5] power/reset: at91-reset: remove useless at91_reset_platform_probe() Alexandre Belloni <alexandre.belloni@free-electrons.com> - 2015-08-11 11:20 +0200
  [PATCH v3 5/5] power/reset: at91-poweroff: get and use slow clock Alexandre Belloni <alexandre.belloni@free-electrons.com> - 2015-08-11 11:20 +0200

csiph-web