clk: rockchip: add restart handler
authorHeiko Stübner <heiko@sntech.de>
Wed, 20 Aug 2014 00:45:38 +0000 (17:45 -0700)
committerHeiko Stuebner <heiko@sntech.de>
Wed, 1 Oct 2014 12:11:42 +0000 (14:11 +0200)
Add infrastructure to write the correct value to the restart register and
register the restart notifier for both rk3188 (including rk3066) and rk3288.

Signed-off-by: Heiko Stuebner <heiko@sntech.de>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
drivers/clk/rockchip/clk-rk3188.c
drivers/clk/rockchip/clk-rk3288.c
drivers/clk/rockchip/clk.c
drivers/clk/rockchip/clk.h

index ceabce5..beed49c 100644 (file)
@@ -735,6 +735,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)
index b488f6a..2327829 100644 (file)
@@ -808,5 +808,7 @@ static void __init rk3288_clk_init(struct device_node *np)
 
        rockchip_register_softrst(np, 12, 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);
index fd3b5ef..1e68bff 100644 (file)
@@ -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"
 
 /**
@@ -330,3 +331,27 @@ void __init rockchip_clk_protect_critical(const char *clocks[], int nclocks)
                        clk_prepare_enable(clk);
        }
 }
+
+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_handler = {
+       .notifier_call = rockchip_restart_notify,
+       .priority = 128,
+};
+
+void __init rockchip_register_restart_notifier(unsigned int reg)
+{
+       int ret;
+
+       reg_restart = reg;
+       ret = register_restart_handler(&rockchip_restart_handler);
+       if (ret)
+               pr_err("%s: cannot register restart handler, %d\n",
+                      __func__, ret);
+}
index f4791fb..ca009ab 100644 (file)
@@ -367,6 +367,7 @@ void rockchip_clk_register_armclk(unsigned int lookup_id, const char *name,
                        const struct rockchip_cpuclk_rate_table *rates,
                        int nrates);
 void rockchip_clk_protect_critical(const char *clocks[], int nclocks);
+void rockchip_register_restart_notifier(unsigned int reg);
 
 #define ROCKCHIP_SOFTRST_HIWORD_MASK   BIT(0)