UPSTREAM: clk: rockchip: only enter pll slow-mode directly before reboots on rk3288
authorHeiko Stuebner <heiko@sntech.de>
Fri, 18 Dec 2015 16:51:55 +0000 (17:51 +0100)
committerHuang, Tao <huangtao@rock-chips.com>
Tue, 15 Mar 2016 09:21:33 +0000 (17:21 +0800)
As commit 1d33929e2a2b ("clk: rockchip: switch PLLs to slow mode before
reboot for rk3288") states, switching the PLLs to slow-mode is only
necessary when rebooting using the soft-reset done through the CRU.

The dwc2 controllers used create really big number of interrupts in
special constellations involving usb-hubs and their number is so high,
it can even overwhelm the interrupt handler if the cpu-speed os to low.

Right now the PLLs are put into slow-mode in a shutdown syscore_ops
callback which means it happens on all reboots (not only the soft-reset
ones) and even on poweroff actions.

This can result in the system not powering off and getting stuck instead,
so we should move the slow-mode change nearer to the actual reboot action.

For this we introduce the possiblity to also set a callback that gets
called from the restart-handler directly prior to restarting the system
and move the shutdown-callback to this new option.

With this the slow-mode switch is done only on the necessary reboots
and also has a smaller possibility of causing artifacts.

Fixes: 1d33929e2a2b ("clk: rockchip: switch PLLs to slow mode before reboot for rk3288")
Signed-off-by: Heiko Stuebner <heiko.stuebner@collabora.com>
Reviewed-by: Douglas Anderson <dianders@chromium.org>
(cherry picked from commit dfff24bde7fb8d57482e907d5dfb0be3a9e28119)

Conflicts:

drivers/clk/rockchip/clk-rk3228.c
[zx: there is no rk3228 clock controller, apply for clk-rk3366]

Change-Id: I2e91afd893c87eb3ab8a41db1fe81f5c43409951
Signed-off-by: Xing Zheng <zhengxing@rock-chips.com>
drivers/clk/rockchip/clk-rk3036.c
drivers/clk/rockchip/clk-rk3188.c
drivers/clk/rockchip/clk-rk3288.c
drivers/clk/rockchip/clk-rk3366.c
drivers/clk/rockchip/clk-rk3368.c
drivers/clk/rockchip/clk.c
drivers/clk/rockchip/clk.h

index 34c78f499ab7ed8c723a36ac72f77fb3ee163eb7..c289fdc3a17fcf489cbc2539c6a36fe7cf0e28d7 100644 (file)
@@ -488,6 +488,6 @@ static void __init rk3036_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);
+       rockchip_register_restart_notifier(RK2928_GLB_SRST_FST, NULL);
 }
 CLK_OF_DECLARE(rk3036_cru, "rockchip,rk3036-cru", rk3036_clk_init);
index 1211af71849d868c753b40183692f123c6887ce7..7f7444cbf6fcc0e62ae85c195792edc10daca2f3 100644 (file)
@@ -780,7 +780,7 @@ 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);
+       rockchip_register_restart_notifier(RK2928_GLB_SRST_FST, NULL);
 }
 
 static void __init rk3066a_clk_init(struct device_node *np)
index 2b4adfe5140d30f5ed6ab161c7adabfef561db32..05589e56d7da7dea20ba1f7f7c81b921c54c029a 100644 (file)
@@ -874,7 +874,6 @@ static void rk3288_clk_shutdown(void)
 static struct syscore_ops rk3288_clk_syscore_ops = {
        .suspend = rk3288_clk_suspend,
        .resume = rk3288_clk_resume,
-       .shutdown = rk3288_clk_shutdown,
 };
 
 static void __init rk3288_clk_init(struct device_node *np)
@@ -932,7 +931,8 @@ static void __init rk3288_clk_init(struct device_node *np)
                                  rk3288_cru_base + RK3288_SOFTRST_CON(0),
                                  ROCKCHIP_SOFTRST_HIWORD_MASK);
 
-       rockchip_register_restart_notifier(RK3288_GLB_SRST_FST);
+       rockchip_register_restart_notifier(RK3288_GLB_SRST_FST,
+                                          rk3288_clk_shutdown);
        register_syscore_ops(&rk3288_clk_syscore_ops);
 }
 CLK_OF_DECLARE(rk3288_cru, "rockchip,rk3288-cru", rk3288_clk_init);
index 4c892a6224e64c54ca9336ccc700425f14d98fcb..8c95e07440851a98b6f24607ceb84074a337eeea 100644 (file)
@@ -854,6 +854,6 @@ static void __init rk3366_clk_init(struct device_node *np)
        rockchip_register_softrst(np, 15, reg_base + RK3368_SOFTRST_CON(0),
                                  ROCKCHIP_SOFTRST_HIWORD_MASK);
 
-       rockchip_register_restart_notifier(RK3368_GLB_SRST_FST);
+       rockchip_register_restart_notifier(RK3368_GLB_SRST_FST, NULL);
 }
 CLK_OF_DECLARE(rk3368_cru, "rockchip,rk3366-cru", rk3366_clk_init);
index cdaba8587437458da54d836cd6ffaacc6720710a..74c4ea65d3fe153c6dc8c2328e82b90d6c989c6e 100644 (file)
@@ -908,6 +908,6 @@ static void __init rk3368_clk_init(struct device_node *np)
        rockchip_register_softrst(np, 15, reg_base + RK3368_SOFTRST_CON(0),
                                  ROCKCHIP_SOFTRST_HIWORD_MASK);
 
-       rockchip_register_restart_notifier(RK3368_GLB_SRST_FST);
+       rockchip_register_restart_notifier(RK3368_GLB_SRST_FST, NULL);
 }
 CLK_OF_DECLARE(rk3368_cru, "rockchip,rk3368-cru", rk3368_clk_init);
index 3c73703fb180edbebac82382adaf8669cc417cba..1ac942d546a2ac03ac41d4a0c284526ad106ae52 100644 (file)
@@ -507,9 +507,13 @@ void __init rockchip_clk_protect_critical(const char *const clocks[],
 }
 
 static unsigned int reg_restart;
+static void (*cb_restart)(void);
 static int rockchip_restart_notify(struct notifier_block *this,
                                   unsigned long mode, void *cmd)
 {
+       if (cb_restart)
+               cb_restart();
+
        writel(0xfdb9, reg_base + reg_restart);
        return NOTIFY_DONE;
 }
@@ -519,11 +523,12 @@ static struct notifier_block rockchip_restart_handler = {
        .priority = 128,
 };
 
-void __init rockchip_register_restart_notifier(unsigned int reg)
+void __init rockchip_register_restart_notifier(unsigned int reg, void (*cb)(void))
 {
        int ret;
 
        reg_restart = reg;
+       cb_restart = cb;
        ret = register_restart_handler(&rockchip_restart_handler);
        if (ret)
                pr_err("%s: cannot register restart handler, %d\n",
index f0f07ce14723ac8d70a15927531dd311308bb011..7e3a084f92c04ba7837b6110af5ac19e06c598fd 100644 (file)
@@ -558,7 +558,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 *const clocks[], int nclocks);
-void rockchip_register_restart_notifier(unsigned int reg);
+void rockchip_register_restart_notifier(unsigned int reg, void (*cb)(void));
 
 #define ROCKCHIP_SOFTRST_HIWORD_MASK   BIT(0)