All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH 0/3] ARM: restart-notifier support for some architectures
@ 2014-07-06 18:42 ` Heiko Stübner
  0 siblings, 0 replies; 16+ messages in thread
From: Heiko Stübner @ 2014-07-06 18:42 UTC (permalink / raw)
  To: Guenter Roeck
  Cc: linux-watchdog, linux-arm-kernel, Wim Van Sebroeck,
	linux-samsung-soc, Tomasz Figa, Mike Turquette

This series provides restart-notifier integration for the architectures
I care about - S3C24XX and Rockchip.

It of course depends on "kernel: Add support for restart notifier call chain"
from Guenter Roeck.

Samsung machines can generally be reset using their watchdog, but some
also provide a special software-reset register in their system controller.

The rockchip reset integration of course also depends on the core clock
support series, currently still under review.


Heiko Stuebner (3):
  watchdog: s3c2410: add restart notifier
  clk: samsung: register restart notifiers for s3c2412 and s3c2443
  clk: rockchip: add restart notifier

 drivers/clk/rockchip/clk-rk3188.c |  2 ++
 drivers/clk/rockchip/clk-rk3288.c |  2 ++
 drivers/clk/rockchip/clk.c        | 23 +++++++++++++++++++++++
 drivers/clk/rockchip/clk.h        |  1 +
 drivers/clk/samsung/clk-s3c2412.c | 28 ++++++++++++++++++++++++++++
 drivers/clk/samsung/clk-s3c2443.c | 18 ++++++++++++++++++
 drivers/watchdog/s3c2410_wdt.c    | 33 +++++++++++++++++++++++++++++++++
 7 files changed, 107 insertions(+)

-- 
1.9.0

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [RFC PATCH 0/3] ARM: restart-notifier support for some architectures
@ 2014-07-06 18:42 ` Heiko Stübner
  0 siblings, 0 replies; 16+ messages in thread
From: Heiko Stübner @ 2014-07-06 18:42 UTC (permalink / raw)
  To: linux-arm-kernel

This series provides restart-notifier integration for the architectures
I care about - S3C24XX and Rockchip.

It of course depends on "kernel: Add support for restart notifier call chain"
from Guenter Roeck.

Samsung machines can generally be reset using their watchdog, but some
also provide a special software-reset register in their system controller.

The rockchip reset integration of course also depends on the core clock
support series, currently still under review.


Heiko Stuebner (3):
  watchdog: s3c2410: add restart notifier
  clk: samsung: register restart notifiers for s3c2412 and s3c2443
  clk: rockchip: add restart notifier

 drivers/clk/rockchip/clk-rk3188.c |  2 ++
 drivers/clk/rockchip/clk-rk3288.c |  2 ++
 drivers/clk/rockchip/clk.c        | 23 +++++++++++++++++++++++
 drivers/clk/rockchip/clk.h        |  1 +
 drivers/clk/samsung/clk-s3c2412.c | 28 ++++++++++++++++++++++++++++
 drivers/clk/samsung/clk-s3c2443.c | 18 ++++++++++++++++++
 drivers/watchdog/s3c2410_wdt.c    | 33 +++++++++++++++++++++++++++++++++
 7 files changed, 107 insertions(+)

-- 
1.9.0

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [RFC PATCH 1/3] watchdog: s3c2410: add restart notifier
  2014-07-06 18:42 ` Heiko Stübner
@ 2014-07-06 18:42   ` Heiko Stübner
  -1 siblings, 0 replies; 16+ messages in thread
From: Heiko Stübner @ 2014-07-06 18:42 UTC (permalink / raw)
  To: Guenter Roeck
  Cc: linux-watchdog, linux-arm-kernel, Wim Van Sebroeck,
	linux-samsung-soc, Tomasz Figa, Mike Turquette

On a lot of Samsung systems the watchdog is responsible for restarting the
system and until now this code was contained in plat-samsung/watchdog-reset.c .

With the introduction of the restart notifiers, this code can now move into
driver itself, removing the need for arch-specific code.

Tested on a S3C2442 based GTA02
Signed-off-by: Heiko Stuebner <heiko@sntech.de>
---
 drivers/watchdog/s3c2410_wdt.c | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/drivers/watchdog/s3c2410_wdt.c b/drivers/watchdog/s3c2410_wdt.c
index 7c6ccd0..3f89912 100644
--- a/drivers/watchdog/s3c2410_wdt.c
+++ b/drivers/watchdog/s3c2410_wdt.c
@@ -41,6 +41,7 @@
 #include <linux/of.h>
 #include <linux/mfd/syscon.h>
 #include <linux/regmap.h>
+#include <linux/reboot.h>
 
 #define S3C2410_WTCON		0x00
 #define S3C2410_WTDAT		0x04
@@ -438,6 +439,31 @@ static inline void s3c2410wdt_cpufreq_deregister(struct s3c2410_wdt *wdt)
 }
 #endif
 
+static struct s3c2410_wdt *s3c2410wdt_restart_ctx;
+static int s3c2410wdt_restart_notify(struct notifier_block *this,
+				     unsigned long mode, void *cmd)
+{
+	void __iomem *wdt_base = s3c2410wdt_restart_ctx->reg_base;
+
+	/* disable watchdog, to be safe  */
+	writel(0, wdt_base + S3C2410_WTCON);
+
+	/* put initial values into count and data */
+	writel(0x80, wdt_base + S3C2410_WTCNT);
+	writel(0x80, wdt_base + S3C2410_WTDAT);
+
+	/* set the watchdog to go and reset... */
+	writel(S3C2410_WTCON_ENABLE | S3C2410_WTCON_DIV16 |
+		S3C2410_WTCON_RSTEN | S3C2410_WTCON_PRESCALE(0x20),
+		wdt_base + S3C2410_WTCON);
+
+	return NOTIFY_DONE;
+}
+
+static struct notifier_block s3c2410wdt_restart_notifier = {
+	.notifier_call = s3c2410wdt_restart_notify,
+};
+
 static inline unsigned int s3c2410wdt_get_bootstatus(struct s3c2410_wdt *wdt)
 {
 	unsigned int rst_stat;
@@ -592,6 +618,11 @@ static int s3c2410wdt_probe(struct platform_device *pdev)
 
 	platform_set_drvdata(pdev, wdt);
 
+	s3c2410wdt_restart_ctx = wdt;
+	ret = register_restart_notifier(&s3c2410wdt_restart_notifier);
+	if (ret)
+		pr_err("cannot register restart notifier, %d\n", ret);
+
 	/* print out a statement of readiness */
 
 	wtcon = readl(wdt->reg_base + S3C2410_WTCON);
@@ -621,6 +652,8 @@ static int s3c2410wdt_remove(struct platform_device *dev)
 	int ret;
 	struct s3c2410_wdt *wdt = platform_get_drvdata(dev);
 
+	unregister_restart_notifier(&s3c2410wdt_restart_notifier);
+
 	ret = s3c2410wdt_mask_and_disable_reset(wdt, true);
 	if (ret < 0)
 		return ret;
-- 
1.9.0

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [RFC PATCH 1/3] watchdog: s3c2410: add restart notifier
@ 2014-07-06 18:42   ` Heiko Stübner
  0 siblings, 0 replies; 16+ messages in thread
From: Heiko Stübner @ 2014-07-06 18:42 UTC (permalink / raw)
  To: linux-arm-kernel

On a lot of Samsung systems the watchdog is responsible for restarting the
system and until now this code was contained in plat-samsung/watchdog-reset.c .

With the introduction of the restart notifiers, this code can now move into
driver itself, removing the need for arch-specific code.

Tested on a S3C2442 based GTA02
Signed-off-by: Heiko Stuebner <heiko@sntech.de>
---
 drivers/watchdog/s3c2410_wdt.c | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/drivers/watchdog/s3c2410_wdt.c b/drivers/watchdog/s3c2410_wdt.c
index 7c6ccd0..3f89912 100644
--- a/drivers/watchdog/s3c2410_wdt.c
+++ b/drivers/watchdog/s3c2410_wdt.c
@@ -41,6 +41,7 @@
 #include <linux/of.h>
 #include <linux/mfd/syscon.h>
 #include <linux/regmap.h>
+#include <linux/reboot.h>
 
 #define S3C2410_WTCON		0x00
 #define S3C2410_WTDAT		0x04
@@ -438,6 +439,31 @@ static inline void s3c2410wdt_cpufreq_deregister(struct s3c2410_wdt *wdt)
 }
 #endif
 
+static struct s3c2410_wdt *s3c2410wdt_restart_ctx;
+static int s3c2410wdt_restart_notify(struct notifier_block *this,
+				     unsigned long mode, void *cmd)
+{
+	void __iomem *wdt_base = s3c2410wdt_restart_ctx->reg_base;
+
+	/* disable watchdog, to be safe  */
+	writel(0, wdt_base + S3C2410_WTCON);
+
+	/* put initial values into count and data */
+	writel(0x80, wdt_base + S3C2410_WTCNT);
+	writel(0x80, wdt_base + S3C2410_WTDAT);
+
+	/* set the watchdog to go and reset... */
+	writel(S3C2410_WTCON_ENABLE | S3C2410_WTCON_DIV16 |
+		S3C2410_WTCON_RSTEN | S3C2410_WTCON_PRESCALE(0x20),
+		wdt_base + S3C2410_WTCON);
+
+	return NOTIFY_DONE;
+}
+
+static struct notifier_block s3c2410wdt_restart_notifier = {
+	.notifier_call = s3c2410wdt_restart_notify,
+};
+
 static inline unsigned int s3c2410wdt_get_bootstatus(struct s3c2410_wdt *wdt)
 {
 	unsigned int rst_stat;
@@ -592,6 +618,11 @@ static int s3c2410wdt_probe(struct platform_device *pdev)
 
 	platform_set_drvdata(pdev, wdt);
 
+	s3c2410wdt_restart_ctx = wdt;
+	ret = register_restart_notifier(&s3c2410wdt_restart_notifier);
+	if (ret)
+		pr_err("cannot register restart notifier, %d\n", ret);
+
 	/* print out a statement of readiness */
 
 	wtcon = readl(wdt->reg_base + S3C2410_WTCON);
@@ -621,6 +652,8 @@ static int s3c2410wdt_remove(struct platform_device *dev)
 	int ret;
 	struct s3c2410_wdt *wdt = platform_get_drvdata(dev);
 
+	unregister_restart_notifier(&s3c2410wdt_restart_notifier);
+
 	ret = s3c2410wdt_mask_and_disable_reset(wdt, true);
 	if (ret < 0)
 		return ret;
-- 
1.9.0

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [RFC PATCH 2/3] clk: samsung: register restart notifiers for s3c2412 and s3c2443
  2014-07-06 18:42 ` Heiko Stübner
@ 2014-07-06 18:43   ` Heiko Stübner
  -1 siblings, 0 replies; 16+ messages in thread
From: Heiko Stübner @ 2014-07-06 18:43 UTC (permalink / raw)
  To: Guenter Roeck
  Cc: linux-watchdog, linux-arm-kernel, Wim Van Sebroeck,
	linux-samsung-soc, Tomasz Figa, Mike Turquette

S3C2412, S3C2443 and their derivatives contain a special software-reset
register in their system-controller.

Therefore register a restart-notifier for those.

Tested on a s3c2416-based board, s3c2412 compile-tested.
Signed-off-by: Heiko Stuebner <heiko@sntech.de>
---
 drivers/clk/samsung/clk-s3c2412.c | 28 ++++++++++++++++++++++++++++
 drivers/clk/samsung/clk-s3c2443.c | 18 ++++++++++++++++++
 2 files changed, 46 insertions(+)

diff --git a/drivers/clk/samsung/clk-s3c2412.c b/drivers/clk/samsung/clk-s3c2412.c
index 23e4313..840f9bd 100644
--- a/drivers/clk/samsung/clk-s3c2412.c
+++ b/drivers/clk/samsung/clk-s3c2412.c
@@ -14,6 +14,7 @@
 #include <linux/of.h>
 #include <linux/of_address.h>
 #include <linux/syscore_ops.h>
+#include <linux/reboot.h>
 
 #include <dt-bindings/clock/s3c2412.h>
 
@@ -26,6 +27,7 @@
 #define CLKCON		0x0c
 #define CLKDIVN		0x14
 #define CLKSRC		0x1c
+#define SWRST		0x30
 
 /* list of PLLs to be registered */
 enum s3c2412_plls {
@@ -204,6 +206,27 @@ struct samsung_clock_alias s3c2412_aliases[] __initdata = {
 	ALIAS(MSYSCLK, NULL, "fclk"),
 };
 
+static int s3c2412_restart_notify(struct notifier_block *this,
+				  unsigned long mode, void *cmd)
+{
+	/* errata "Watch-dog/Software Reset Problem" specifies that
+	 * this reset must be done with the SYSCLK sourced from
+	 * EXTCLK instead of FOUT to avoid a glitch in the reset
+	 * mechanism.
+	 *
+	 * See the watchdog section of the S3C2412 manual for more
+	 * information on this fix.
+	 */
+
+	__raw_writel(0x00, reg_base + CLKSRC);
+	__raw_writel(0x533C2412, reg_base + SWRST);
+	return NOTIFY_DONE;
+}
+
+static struct notifier_block s3c2412_restart_notifier = {
+	.notifier_call = s3c2412_restart_notify,
+};
+
 /*
  * fixed rate clocks generated outside the soc
  * Only necessary until the devicetree-move is complete
@@ -233,6 +256,7 @@ void __init s3c2412_common_clk_init(struct device_node *np, unsigned long xti_f,
 				    unsigned long ext_f, void __iomem *base)
 {
 	struct samsung_clk_provider *ctx;
+	int ret;
 	reg_base = base;
 
 	if (np) {
@@ -265,6 +289,10 @@ void __init s3c2412_common_clk_init(struct device_node *np, unsigned long xti_f,
 				   ARRAY_SIZE(s3c2412_aliases));
 
 	s3c2412_clk_sleep_init();
+
+	ret = register_restart_notifier(&s3c2412_restart_notifier);
+	if (ret)
+		pr_warn("cannot register restart notifier, %d\n", ret);
 }
 
 static void __init s3c2412_clk_init(struct device_node *np)
diff --git a/drivers/clk/samsung/clk-s3c2443.c b/drivers/clk/samsung/clk-s3c2443.c
index c4bbdab..0be33cc 100644
--- a/drivers/clk/samsung/clk-s3c2443.c
+++ b/drivers/clk/samsung/clk-s3c2443.c
@@ -14,6 +14,7 @@
 #include <linux/of.h>
 #include <linux/of_address.h>
 #include <linux/syscore_ops.h>
+#include <linux/reboot.h>
 
 #include <dt-bindings/clock/s3c2443.h>
 
@@ -33,6 +34,7 @@
 #define HCLKCON		0x30
 #define PCLKCON		0x34
 #define SCLKCON		0x38
+#define SWRST		0x44
 
 /* the soc types */
 enum supported_socs {
@@ -354,6 +356,17 @@ struct samsung_clock_alias s3c2450_aliases[] __initdata = {
 	ALIAS(PCLK_I2C1, "s3c2410-i2c.1", "i2c"),
 };
 
+static int s3c2443_restart_notify(struct notifier_block *this,
+				  unsigned long mode, void *cmd)
+{
+	__raw_writel(0x533c2443, reg_base + SWRST);
+	return NOTIFY_DONE;
+}
+
+static struct notifier_block s3c2443_restart_notifier = {
+	.notifier_call = s3c2443_restart_notify,
+};
+
 /*
  * fixed rate clocks generated outside the soc
  * Only necessary until the devicetree-move is complete
@@ -378,6 +391,7 @@ void __init s3c2443_common_clk_init(struct device_node *np, unsigned long xti_f,
 				    void __iomem *base)
 {
 	struct samsung_clk_provider *ctx;
+	int ret;
 	reg_base = base;
 
 	if (np) {
@@ -445,6 +459,10 @@ void __init s3c2443_common_clk_init(struct device_node *np, unsigned long xti_f,
 	}
 
 	s3c2443_clk_sleep_init();
+
+	ret = register_restart_notifier(&s3c2443_restart_notifier);
+	if (ret)
+		pr_warn("cannot register restart notifier, %d\n", ret);
 }
 
 static void __init s3c2416_clk_init(struct device_node *np)
-- 
1.9.0



^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [RFC PATCH 2/3] clk: samsung: register restart notifiers for s3c2412 and s3c2443
@ 2014-07-06 18:43   ` Heiko Stübner
  0 siblings, 0 replies; 16+ messages in thread
From: Heiko Stübner @ 2014-07-06 18:43 UTC (permalink / raw)
  To: linux-arm-kernel

S3C2412, S3C2443 and their derivatives contain a special software-reset
register in their system-controller.

Therefore register a restart-notifier for those.

Tested on a s3c2416-based board, s3c2412 compile-tested.
Signed-off-by: Heiko Stuebner <heiko@sntech.de>
---
 drivers/clk/samsung/clk-s3c2412.c | 28 ++++++++++++++++++++++++++++
 drivers/clk/samsung/clk-s3c2443.c | 18 ++++++++++++++++++
 2 files changed, 46 insertions(+)

diff --git a/drivers/clk/samsung/clk-s3c2412.c b/drivers/clk/samsung/clk-s3c2412.c
index 23e4313..840f9bd 100644
--- a/drivers/clk/samsung/clk-s3c2412.c
+++ b/drivers/clk/samsung/clk-s3c2412.c
@@ -14,6 +14,7 @@
 #include <linux/of.h>
 #include <linux/of_address.h>
 #include <linux/syscore_ops.h>
+#include <linux/reboot.h>
 
 #include <dt-bindings/clock/s3c2412.h>
 
@@ -26,6 +27,7 @@
 #define CLKCON		0x0c
 #define CLKDIVN		0x14
 #define CLKSRC		0x1c
+#define SWRST		0x30
 
 /* list of PLLs to be registered */
 enum s3c2412_plls {
@@ -204,6 +206,27 @@ struct samsung_clock_alias s3c2412_aliases[] __initdata = {
 	ALIAS(MSYSCLK, NULL, "fclk"),
 };
 
+static int s3c2412_restart_notify(struct notifier_block *this,
+				  unsigned long mode, void *cmd)
+{
+	/* errata "Watch-dog/Software Reset Problem" specifies that
+	 * this reset must be done with the SYSCLK sourced from
+	 * EXTCLK instead of FOUT to avoid a glitch in the reset
+	 * mechanism.
+	 *
+	 * See the watchdog section of the S3C2412 manual for more
+	 * information on this fix.
+	 */
+
+	__raw_writel(0x00, reg_base + CLKSRC);
+	__raw_writel(0x533C2412, reg_base + SWRST);
+	return NOTIFY_DONE;
+}
+
+static struct notifier_block s3c2412_restart_notifier = {
+	.notifier_call = s3c2412_restart_notify,
+};
+
 /*
  * fixed rate clocks generated outside the soc
  * Only necessary until the devicetree-move is complete
@@ -233,6 +256,7 @@ void __init s3c2412_common_clk_init(struct device_node *np, unsigned long xti_f,
 				    unsigned long ext_f, void __iomem *base)
 {
 	struct samsung_clk_provider *ctx;
+	int ret;
 	reg_base = base;
 
 	if (np) {
@@ -265,6 +289,10 @@ void __init s3c2412_common_clk_init(struct device_node *np, unsigned long xti_f,
 				   ARRAY_SIZE(s3c2412_aliases));
 
 	s3c2412_clk_sleep_init();
+
+	ret = register_restart_notifier(&s3c2412_restart_notifier);
+	if (ret)
+		pr_warn("cannot register restart notifier, %d\n", ret);
 }
 
 static void __init s3c2412_clk_init(struct device_node *np)
diff --git a/drivers/clk/samsung/clk-s3c2443.c b/drivers/clk/samsung/clk-s3c2443.c
index c4bbdab..0be33cc 100644
--- a/drivers/clk/samsung/clk-s3c2443.c
+++ b/drivers/clk/samsung/clk-s3c2443.c
@@ -14,6 +14,7 @@
 #include <linux/of.h>
 #include <linux/of_address.h>
 #include <linux/syscore_ops.h>
+#include <linux/reboot.h>
 
 #include <dt-bindings/clock/s3c2443.h>
 
@@ -33,6 +34,7 @@
 #define HCLKCON		0x30
 #define PCLKCON		0x34
 #define SCLKCON		0x38
+#define SWRST		0x44
 
 /* the soc types */
 enum supported_socs {
@@ -354,6 +356,17 @@ struct samsung_clock_alias s3c2450_aliases[] __initdata = {
 	ALIAS(PCLK_I2C1, "s3c2410-i2c.1", "i2c"),
 };
 
+static int s3c2443_restart_notify(struct notifier_block *this,
+				  unsigned long mode, void *cmd)
+{
+	__raw_writel(0x533c2443, reg_base + SWRST);
+	return NOTIFY_DONE;
+}
+
+static struct notifier_block s3c2443_restart_notifier = {
+	.notifier_call = s3c2443_restart_notify,
+};
+
 /*
  * fixed rate clocks generated outside the soc
  * Only necessary until the devicetree-move is complete
@@ -378,6 +391,7 @@ void __init s3c2443_common_clk_init(struct device_node *np, unsigned long xti_f,
 				    void __iomem *base)
 {
 	struct samsung_clk_provider *ctx;
+	int ret;
 	reg_base = base;
 
 	if (np) {
@@ -445,6 +459,10 @@ void __init s3c2443_common_clk_init(struct device_node *np, unsigned long xti_f,
 	}
 
 	s3c2443_clk_sleep_init();
+
+	ret = register_restart_notifier(&s3c2443_restart_notifier);
+	if (ret)
+		pr_warn("cannot register restart notifier, %d\n", ret);
 }
 
 static void __init s3c2416_clk_init(struct device_node *np)
-- 
1.9.0

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [RFC PATCH 3/3] clk: rockchip: add restart notifier
  2014-07-06 18:42 ` Heiko Stübner
@ 2014-07-06 18:43   ` Heiko Stübner
  -1 siblings, 0 replies; 16+ messages in thread
From: Heiko Stübner @ 2014-07-06 18:43 UTC (permalink / raw)
  To: Guenter Roeck
  Cc: linux-watchdog, linux-arm-kernel, Wim Van Sebroeck,
	linux-samsung-soc, Tomasz Figa, Mike Turquette

Add infrastructure to write the correct value to the restart register and
register the restart notifier for both rk3188 (including rk3066) and rk3188.

Signed-off-by: Heiko Stuebner <heiko@sntech.de>
---
 drivers/clk/rockchip/clk-rk3188.c |  2 ++
 drivers/clk/rockchip/clk-rk3288.c |  2 ++
 drivers/clk/rockchip/clk.c        | 23 +++++++++++++++++++++++
 drivers/clk/rockchip/clk.h        |  1 +
 4 files changed, 28 insertions(+)

diff --git a/drivers/clk/rockchip/clk-rk3188.c b/drivers/clk/rockchip/clk-rk3188.c
index a83a6d8..71b661a 100644
--- a/drivers/clk/rockchip/clk-rk3188.c
+++ b/drivers/clk/rockchip/clk-rk3188.c
@@ -631,6 +631,8 @@ static void __init rk3188_common_clk_init(struct device_node *np)
 
 	rockchip_register_softrst(np, 9, reg_base + RK2928_SOFTRST_CON(0),
 				  ROCKCHIP_SOFTRST_HIWORD_MASK);
+
+	rockchip_register_restart_notifier(RK2928_GLB_SRST_FST);
 }
 
 static void __init rk3066a_clk_init(struct device_node *np)
diff --git a/drivers/clk/rockchip/clk-rk3288.c b/drivers/clk/rockchip/clk-rk3288.c
index 0d8c6c5..b604217 100644
--- a/drivers/clk/rockchip/clk-rk3288.c
+++ b/drivers/clk/rockchip/clk-rk3288.c
@@ -713,5 +713,7 @@ static void __init rk3288_clk_init(struct device_node *np)
 
 	rockchip_register_softrst(np, 9, reg_base + RK3288_SOFTRST_CON(0),
 				  ROCKCHIP_SOFTRST_HIWORD_MASK);
+
+	rockchip_register_restart_notifier(RK3288_GLB_SRST_FST);
 }
 CLK_OF_DECLARE(rk3288_cru, "rockchip,rk3288-cru", rk3288_clk_init);
diff --git a/drivers/clk/rockchip/clk.c b/drivers/clk/rockchip/clk.c
index 278cf9d..0594941 100644
--- a/drivers/clk/rockchip/clk.c
+++ b/drivers/clk/rockchip/clk.c
@@ -25,6 +25,7 @@
 #include <linux/clk-provider.h>
 #include <linux/mfd/syscon.h>
 #include <linux/regmap.h>
+#include <linux/reboot.h>
 #include "clk.h"
 
 /**
@@ -242,3 +243,25 @@ void __init rockchip_clk_register_branches(
 		rockchip_clk_add_lookup(clk, list->id);
 	}
 }
+
+static unsigned int reg_restart;
+static int rockchip_restart_notify(struct notifier_block *this,
+				   unsigned long mode, void *cmd)
+{
+	writel(0xfdb9, reg_base + reg_restart);
+	return NOTIFY_DONE;
+}
+
+static struct notifier_block rockchip_restart_notifier = {
+	.notifier_call = rockchip_restart_notify,
+};
+
+void __init rockchip_register_restart_notifier(unsigned int reg)
+{
+	int ret;
+
+	reg_restart = reg;
+	ret = register_restart_notifier(&rockchip_restart_notifier);
+	if (ret)
+		pr_err("cannot register restart notifier, %d\n", ret);
+}
diff --git a/drivers/clk/rockchip/clk.h b/drivers/clk/rockchip/clk.h
index 887cbde..0b5eab5 100644
--- a/drivers/clk/rockchip/clk.h
+++ b/drivers/clk/rockchip/clk.h
@@ -329,6 +329,7 @@ void rockchip_clk_register_branches(struct rockchip_clk_branch *clk_list,
 				    unsigned int nr_clk);
 void rockchip_clk_register_plls(struct rockchip_pll_clock *pll_list,
 				unsigned int nr_pll, int grf_lock_offset);
+void rockchip_register_restart_notifier(unsigned int reg);
 
 #define ROCKCHIP_SOFTRST_HIWORD_MASK	BIT(0)
 
-- 
1.9.0



^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [RFC PATCH 3/3] clk: rockchip: add restart notifier
@ 2014-07-06 18:43   ` Heiko Stübner
  0 siblings, 0 replies; 16+ messages in thread
From: Heiko Stübner @ 2014-07-06 18:43 UTC (permalink / raw)
  To: linux-arm-kernel

Add infrastructure to write the correct value to the restart register and
register the restart notifier for both rk3188 (including rk3066) and rk3188.

Signed-off-by: Heiko Stuebner <heiko@sntech.de>
---
 drivers/clk/rockchip/clk-rk3188.c |  2 ++
 drivers/clk/rockchip/clk-rk3288.c |  2 ++
 drivers/clk/rockchip/clk.c        | 23 +++++++++++++++++++++++
 drivers/clk/rockchip/clk.h        |  1 +
 4 files changed, 28 insertions(+)

diff --git a/drivers/clk/rockchip/clk-rk3188.c b/drivers/clk/rockchip/clk-rk3188.c
index a83a6d8..71b661a 100644
--- a/drivers/clk/rockchip/clk-rk3188.c
+++ b/drivers/clk/rockchip/clk-rk3188.c
@@ -631,6 +631,8 @@ static void __init rk3188_common_clk_init(struct device_node *np)
 
 	rockchip_register_softrst(np, 9, reg_base + RK2928_SOFTRST_CON(0),
 				  ROCKCHIP_SOFTRST_HIWORD_MASK);
+
+	rockchip_register_restart_notifier(RK2928_GLB_SRST_FST);
 }
 
 static void __init rk3066a_clk_init(struct device_node *np)
diff --git a/drivers/clk/rockchip/clk-rk3288.c b/drivers/clk/rockchip/clk-rk3288.c
index 0d8c6c5..b604217 100644
--- a/drivers/clk/rockchip/clk-rk3288.c
+++ b/drivers/clk/rockchip/clk-rk3288.c
@@ -713,5 +713,7 @@ static void __init rk3288_clk_init(struct device_node *np)
 
 	rockchip_register_softrst(np, 9, reg_base + RK3288_SOFTRST_CON(0),
 				  ROCKCHIP_SOFTRST_HIWORD_MASK);
+
+	rockchip_register_restart_notifier(RK3288_GLB_SRST_FST);
 }
 CLK_OF_DECLARE(rk3288_cru, "rockchip,rk3288-cru", rk3288_clk_init);
diff --git a/drivers/clk/rockchip/clk.c b/drivers/clk/rockchip/clk.c
index 278cf9d..0594941 100644
--- a/drivers/clk/rockchip/clk.c
+++ b/drivers/clk/rockchip/clk.c
@@ -25,6 +25,7 @@
 #include <linux/clk-provider.h>
 #include <linux/mfd/syscon.h>
 #include <linux/regmap.h>
+#include <linux/reboot.h>
 #include "clk.h"
 
 /**
@@ -242,3 +243,25 @@ void __init rockchip_clk_register_branches(
 		rockchip_clk_add_lookup(clk, list->id);
 	}
 }
+
+static unsigned int reg_restart;
+static int rockchip_restart_notify(struct notifier_block *this,
+				   unsigned long mode, void *cmd)
+{
+	writel(0xfdb9, reg_base + reg_restart);
+	return NOTIFY_DONE;
+}
+
+static struct notifier_block rockchip_restart_notifier = {
+	.notifier_call = rockchip_restart_notify,
+};
+
+void __init rockchip_register_restart_notifier(unsigned int reg)
+{
+	int ret;
+
+	reg_restart = reg;
+	ret = register_restart_notifier(&rockchip_restart_notifier);
+	if (ret)
+		pr_err("cannot register restart notifier, %d\n", ret);
+}
diff --git a/drivers/clk/rockchip/clk.h b/drivers/clk/rockchip/clk.h
index 887cbde..0b5eab5 100644
--- a/drivers/clk/rockchip/clk.h
+++ b/drivers/clk/rockchip/clk.h
@@ -329,6 +329,7 @@ void rockchip_clk_register_branches(struct rockchip_clk_branch *clk_list,
 				    unsigned int nr_clk);
 void rockchip_clk_register_plls(struct rockchip_pll_clock *pll_list,
 				unsigned int nr_pll, int grf_lock_offset);
+void rockchip_register_restart_notifier(unsigned int reg);
 
 #define ROCKCHIP_SOFTRST_HIWORD_MASK	BIT(0)
 
-- 
1.9.0

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: [RFC PATCH 1/3] watchdog: s3c2410: add restart notifier
  2014-07-06 18:42   ` Heiko Stübner
@ 2014-07-08 14:21     ` Tomasz Figa
  -1 siblings, 0 replies; 16+ messages in thread
From: Tomasz Figa @ 2014-07-08 14:21 UTC (permalink / raw)
  To: Heiko Stübner, Guenter Roeck
  Cc: linux-watchdog, linux-arm-kernel, Wim Van Sebroeck,
	linux-samsung-soc, Mike Turquette

Hi Heiko,

On 06.07.2014 20:42, Heiko Stübner wrote:
> On a lot of Samsung systems the watchdog is responsible for restarting the
> system and until now this code was contained in plat-samsung/watchdog-reset.c .
> 
> With the introduction of the restart notifiers, this code can now move into
> driver itself, removing the need for arch-specific code.
> 
> Tested on a S3C2442 based GTA02
> Signed-off-by: Heiko Stuebner <heiko@sntech.de>
> ---
>  drivers/watchdog/s3c2410_wdt.c | 33 +++++++++++++++++++++++++++++++++
>  1 file changed, 33 insertions(+)
> 
> diff --git a/drivers/watchdog/s3c2410_wdt.c b/drivers/watchdog/s3c2410_wdt.c
> index 7c6ccd0..3f89912 100644
> --- a/drivers/watchdog/s3c2410_wdt.c
> +++ b/drivers/watchdog/s3c2410_wdt.c
> @@ -41,6 +41,7 @@
>  #include <linux/of.h>
>  #include <linux/mfd/syscon.h>
>  #include <linux/regmap.h>
> +#include <linux/reboot.h>
>  
>  #define S3C2410_WTCON		0x00
>  #define S3C2410_WTDAT		0x04
> @@ -438,6 +439,31 @@ static inline void s3c2410wdt_cpufreq_deregister(struct s3c2410_wdt *wdt)
>  }
>  #endif
>  
> +static struct s3c2410_wdt *s3c2410wdt_restart_ctx;

This isn't the most elegant way to store context data. Maybe you could
embed the notifier_block struct into s3c2410_wdt struct and then use
container of to retrieve it from s3c2410wdt_restart_notify()?

> +static int s3c2410wdt_restart_notify(struct notifier_block *this,
> +				     unsigned long mode, void *cmd)
> +{
> +	void __iomem *wdt_base = s3c2410wdt_restart_ctx->reg_base;
> +
> +	/* disable watchdog, to be safe  */
> +	writel(0, wdt_base + S3C2410_WTCON);
> +
> +	/* put initial values into count and data */
> +	writel(0x80, wdt_base + S3C2410_WTCNT);
> +	writel(0x80, wdt_base + S3C2410_WTDAT);
> +
> +	/* set the watchdog to go and reset... */
> +	writel(S3C2410_WTCON_ENABLE | S3C2410_WTCON_DIV16 |
> +		S3C2410_WTCON_RSTEN | S3C2410_WTCON_PRESCALE(0x20),
> +		wdt_base + S3C2410_WTCON);

I wonder whether you shouldn't wait a bit here for the reset to be
actually triggered.

Best regards,
Tomasz

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [RFC PATCH 1/3] watchdog: s3c2410: add restart notifier
@ 2014-07-08 14:21     ` Tomasz Figa
  0 siblings, 0 replies; 16+ messages in thread
From: Tomasz Figa @ 2014-07-08 14:21 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Heiko,

On 06.07.2014 20:42, Heiko St?bner wrote:
> On a lot of Samsung systems the watchdog is responsible for restarting the
> system and until now this code was contained in plat-samsung/watchdog-reset.c .
> 
> With the introduction of the restart notifiers, this code can now move into
> driver itself, removing the need for arch-specific code.
> 
> Tested on a S3C2442 based GTA02
> Signed-off-by: Heiko Stuebner <heiko@sntech.de>
> ---
>  drivers/watchdog/s3c2410_wdt.c | 33 +++++++++++++++++++++++++++++++++
>  1 file changed, 33 insertions(+)
> 
> diff --git a/drivers/watchdog/s3c2410_wdt.c b/drivers/watchdog/s3c2410_wdt.c
> index 7c6ccd0..3f89912 100644
> --- a/drivers/watchdog/s3c2410_wdt.c
> +++ b/drivers/watchdog/s3c2410_wdt.c
> @@ -41,6 +41,7 @@
>  #include <linux/of.h>
>  #include <linux/mfd/syscon.h>
>  #include <linux/regmap.h>
> +#include <linux/reboot.h>
>  
>  #define S3C2410_WTCON		0x00
>  #define S3C2410_WTDAT		0x04
> @@ -438,6 +439,31 @@ static inline void s3c2410wdt_cpufreq_deregister(struct s3c2410_wdt *wdt)
>  }
>  #endif
>  
> +static struct s3c2410_wdt *s3c2410wdt_restart_ctx;

This isn't the most elegant way to store context data. Maybe you could
embed the notifier_block struct into s3c2410_wdt struct and then use
container of to retrieve it from s3c2410wdt_restart_notify()?

> +static int s3c2410wdt_restart_notify(struct notifier_block *this,
> +				     unsigned long mode, void *cmd)
> +{
> +	void __iomem *wdt_base = s3c2410wdt_restart_ctx->reg_base;
> +
> +	/* disable watchdog, to be safe  */
> +	writel(0, wdt_base + S3C2410_WTCON);
> +
> +	/* put initial values into count and data */
> +	writel(0x80, wdt_base + S3C2410_WTCNT);
> +	writel(0x80, wdt_base + S3C2410_WTDAT);
> +
> +	/* set the watchdog to go and reset... */
> +	writel(S3C2410_WTCON_ENABLE | S3C2410_WTCON_DIV16 |
> +		S3C2410_WTCON_RSTEN | S3C2410_WTCON_PRESCALE(0x20),
> +		wdt_base + S3C2410_WTCON);

I wonder whether you shouldn't wait a bit here for the reset to be
actually triggered.

Best regards,
Tomasz

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [RFC PATCH 2/3] clk: samsung: register restart notifiers for s3c2412 and s3c2443
  2014-07-06 18:43   ` Heiko Stübner
@ 2014-07-08 14:24     ` Tomasz Figa
  -1 siblings, 0 replies; 16+ messages in thread
From: Tomasz Figa @ 2014-07-08 14:24 UTC (permalink / raw)
  To: Heiko Stübner, Guenter Roeck
  Cc: linux-watchdog, linux-arm-kernel, Wim Van Sebroeck,
	linux-samsung-soc, Mike Turquette

Hi Heiko,

On 06.07.2014 20:43, Heiko Stübner wrote:
> S3C2412, S3C2443 and their derivatives contain a special software-reset
> register in their system-controller.
> 
> Therefore register a restart-notifier for those.

I wonder if we really need to differentiate between these SoCs instead
of just using the watchdog reset for all of them. If there is no reason
to prefer software reset, then some code could be removed and things
would be more unified.

Best regards,
Tomasz

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [RFC PATCH 2/3] clk: samsung: register restart notifiers for s3c2412 and s3c2443
@ 2014-07-08 14:24     ` Tomasz Figa
  0 siblings, 0 replies; 16+ messages in thread
From: Tomasz Figa @ 2014-07-08 14:24 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Heiko,

On 06.07.2014 20:43, Heiko St?bner wrote:
> S3C2412, S3C2443 and their derivatives contain a special software-reset
> register in their system-controller.
> 
> Therefore register a restart-notifier for those.

I wonder if we really need to differentiate between these SoCs instead
of just using the watchdog reset for all of them. If there is no reason
to prefer software reset, then some code could be removed and things
would be more unified.

Best regards,
Tomasz

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [RFC PATCH 1/3] watchdog: s3c2410: add restart notifier
  2014-07-08 14:21     ` Tomasz Figa
@ 2014-07-08 16:21       ` Guenter Roeck
  -1 siblings, 0 replies; 16+ messages in thread
From: Guenter Roeck @ 2014-07-08 16:21 UTC (permalink / raw)
  To: Tomasz Figa
  Cc: Heiko Stübner, linux-watchdog, linux-arm-kernel,
	Wim Van Sebroeck, linux-samsung-soc, Mike Turquette

On Tue, Jul 08, 2014 at 04:21:09PM +0200, Tomasz Figa wrote:
> Hi Heiko,
> 
> On 06.07.2014 20:42, Heiko Stübner wrote:
> > On a lot of Samsung systems the watchdog is responsible for restarting the
> > system and until now this code was contained in plat-samsung/watchdog-reset.c .
> > 
> > With the introduction of the restart notifiers, this code can now move into
> > driver itself, removing the need for arch-specific code.
> > 
> > Tested on a S3C2442 based GTA02
> > Signed-off-by: Heiko Stuebner <heiko@sntech.de>
> > ---
> >  drivers/watchdog/s3c2410_wdt.c | 33 +++++++++++++++++++++++++++++++++
> >  1 file changed, 33 insertions(+)
> > 
> > diff --git a/drivers/watchdog/s3c2410_wdt.c b/drivers/watchdog/s3c2410_wdt.c
> > index 7c6ccd0..3f89912 100644
> > --- a/drivers/watchdog/s3c2410_wdt.c
> > +++ b/drivers/watchdog/s3c2410_wdt.c
> > @@ -41,6 +41,7 @@
> >  #include <linux/of.h>
> >  #include <linux/mfd/syscon.h>
> >  #include <linux/regmap.h>
> > +#include <linux/reboot.h>
> >  
> >  #define S3C2410_WTCON		0x00
> >  #define S3C2410_WTDAT		0x04
> > @@ -438,6 +439,31 @@ static inline void s3c2410wdt_cpufreq_deregister(struct s3c2410_wdt *wdt)
> >  }
> >  #endif
> >  
> > +static struct s3c2410_wdt *s3c2410wdt_restart_ctx;
> 
> This isn't the most elegant way to store context data. Maybe you could
> embed the notifier_block struct into s3c2410_wdt struct and then use
> container of to retrieve it from s3c2410wdt_restart_notify()?
> 
Excellent idea. I'll do that for the moxart handler as well.

Guenter

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [RFC PATCH 1/3] watchdog: s3c2410: add restart notifier
@ 2014-07-08 16:21       ` Guenter Roeck
  0 siblings, 0 replies; 16+ messages in thread
From: Guenter Roeck @ 2014-07-08 16:21 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Jul 08, 2014 at 04:21:09PM +0200, Tomasz Figa wrote:
> Hi Heiko,
> 
> On 06.07.2014 20:42, Heiko St?bner wrote:
> > On a lot of Samsung systems the watchdog is responsible for restarting the
> > system and until now this code was contained in plat-samsung/watchdog-reset.c .
> > 
> > With the introduction of the restart notifiers, this code can now move into
> > driver itself, removing the need for arch-specific code.
> > 
> > Tested on a S3C2442 based GTA02
> > Signed-off-by: Heiko Stuebner <heiko@sntech.de>
> > ---
> >  drivers/watchdog/s3c2410_wdt.c | 33 +++++++++++++++++++++++++++++++++
> >  1 file changed, 33 insertions(+)
> > 
> > diff --git a/drivers/watchdog/s3c2410_wdt.c b/drivers/watchdog/s3c2410_wdt.c
> > index 7c6ccd0..3f89912 100644
> > --- a/drivers/watchdog/s3c2410_wdt.c
> > +++ b/drivers/watchdog/s3c2410_wdt.c
> > @@ -41,6 +41,7 @@
> >  #include <linux/of.h>
> >  #include <linux/mfd/syscon.h>
> >  #include <linux/regmap.h>
> > +#include <linux/reboot.h>
> >  
> >  #define S3C2410_WTCON		0x00
> >  #define S3C2410_WTDAT		0x04
> > @@ -438,6 +439,31 @@ static inline void s3c2410wdt_cpufreq_deregister(struct s3c2410_wdt *wdt)
> >  }
> >  #endif
> >  
> > +static struct s3c2410_wdt *s3c2410wdt_restart_ctx;
> 
> This isn't the most elegant way to store context data. Maybe you could
> embed the notifier_block struct into s3c2410_wdt struct and then use
> container of to retrieve it from s3c2410wdt_restart_notify()?
> 
Excellent idea. I'll do that for the moxart handler as well.

Guenter

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [RFC PATCH 2/3] clk: samsung: register restart notifiers for s3c2412 and s3c2443
  2014-07-08 14:24     ` Tomasz Figa
@ 2014-07-08 16:23       ` Guenter Roeck
  -1 siblings, 0 replies; 16+ messages in thread
From: Guenter Roeck @ 2014-07-08 16:23 UTC (permalink / raw)
  To: Tomasz Figa
  Cc: Heiko Stübner, linux-watchdog, linux-arm-kernel,
	Wim Van Sebroeck, linux-samsung-soc, Mike Turquette

On Tue, Jul 08, 2014 at 04:24:34PM +0200, Tomasz Figa wrote:
> Hi Heiko,
> 
> On 06.07.2014 20:43, Heiko Stübner wrote:
> > S3C2412, S3C2443 and their derivatives contain a special software-reset
> > register in their system-controller.
> > 
> > Therefore register a restart-notifier for those.
> 
> I wonder if we really need to differentiate between these SoCs instead
> of just using the watchdog reset for all of them. If there is no reason
> to prefer software reset, then some code could be removed and things
> would be more unified.
> 
Depends if the other method is always available. If not, it might make sense
to register this handler with lower priority to have a fallback.

Guenter

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [RFC PATCH 2/3] clk: samsung: register restart notifiers for s3c2412 and s3c2443
@ 2014-07-08 16:23       ` Guenter Roeck
  0 siblings, 0 replies; 16+ messages in thread
From: Guenter Roeck @ 2014-07-08 16:23 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Jul 08, 2014 at 04:24:34PM +0200, Tomasz Figa wrote:
> Hi Heiko,
> 
> On 06.07.2014 20:43, Heiko St?bner wrote:
> > S3C2412, S3C2443 and their derivatives contain a special software-reset
> > register in their system-controller.
> > 
> > Therefore register a restart-notifier for those.
> 
> I wonder if we really need to differentiate between these SoCs instead
> of just using the watchdog reset for all of them. If there is no reason
> to prefer software reset, then some code could be removed and things
> would be more unified.
> 
Depends if the other method is always available. If not, it might make sense
to register this handler with lower priority to have a fallback.

Guenter

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2014-07-08 16:23 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-06 18:42 [RFC PATCH 0/3] ARM: restart-notifier support for some architectures Heiko Stübner
2014-07-06 18:42 ` Heiko Stübner
2014-07-06 18:42 ` [RFC PATCH 1/3] watchdog: s3c2410: add restart notifier Heiko Stübner
2014-07-06 18:42   ` Heiko Stübner
2014-07-08 14:21   ` Tomasz Figa
2014-07-08 14:21     ` Tomasz Figa
2014-07-08 16:21     ` Guenter Roeck
2014-07-08 16:21       ` Guenter Roeck
2014-07-06 18:43 ` [RFC PATCH 2/3] clk: samsung: register restart notifiers for s3c2412 and s3c2443 Heiko Stübner
2014-07-06 18:43   ` Heiko Stübner
2014-07-08 14:24   ` Tomasz Figa
2014-07-08 14:24     ` Tomasz Figa
2014-07-08 16:23     ` Guenter Roeck
2014-07-08 16:23       ` Guenter Roeck
2014-07-06 18:43 ` [RFC PATCH 3/3] clk: rockchip: add restart notifier Heiko Stübner
2014-07-06 18:43   ` Heiko Stübner

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.