diff --git a/drivers/clk/rockchip/clk-rk3368.c b/drivers/clk/rockchip/clk-rk3368.c index d20e51dabb63..5477d1e89cd4 100644 --- a/drivers/clk/rockchip/clk-rk3368.c +++ b/drivers/clk/rockchip/clk-rk3368.c @@ -864,6 +864,18 @@ static const char *const rk3368_critical_clocks[] __initconst = { "pmu_hclk_otg0", }; +static void __iomem *rk3368_cru_base; + +static void rk3368_dump_cru(void) +{ + if (rk3368_cru_base) { + pr_warn("CRU:\n"); + print_hex_dump(KERN_WARNING, "", DUMP_PREFIX_OFFSET, + 32, 4, rk3368_cru_base, + 0x41c, false); + } +} + static void __init rk3368_clk_init(struct device_node *np) { struct rockchip_clk_provider *ctx; @@ -906,5 +918,10 @@ static void __init rk3368_clk_init(struct device_node *np) rockchip_register_restart_notifier(ctx, RK3368_GLB_SRST_FST, NULL); rockchip_clk_of_add_provider(np, ctx); + + if (!rk_dump_cru) { + rk3368_cru_base = reg_base; + rk_dump_cru = rk3368_dump_cru; + } } CLK_OF_DECLARE(rk3368_cru, "rockchip,rk3368-cru", rk3368_clk_init); diff --git a/drivers/clk/rockchip/clk.c b/drivers/clk/rockchip/clk.c index c18a0d343b68..abf6c7fc5245 100644 --- a/drivers/clk/rockchip/clk.c +++ b/drivers/clk/rockchip/clk.c @@ -733,6 +733,21 @@ void rockchip_clk_protect_critical(const char *const clocks[], } EXPORT_SYMBOL_GPL(rockchip_clk_protect_critical); +void (*rk_dump_cru)(void); +EXPORT_SYMBOL(rk_dump_cru); + +static int rk_clk_panic(struct notifier_block *this, + unsigned long ev, void *ptr) +{ + if (rk_dump_cru) + rk_dump_cru(); + return NOTIFY_DONE; +} + +static struct notifier_block rk_clk_panic_block = { + .notifier_call = rk_clk_panic, +}; + static void __iomem *rst_base; static unsigned int reg_restart; static void (*cb_restart)(void); @@ -765,5 +780,7 @@ rockchip_register_restart_notifier(struct rockchip_clk_provider *ctx, if (ret) pr_err("%s: cannot register restart handler, %d\n", __func__, ret); + atomic_notifier_chain_register(&panic_notifier_list, + &rk_clk_panic_block); } EXPORT_SYMBOL_GPL(rockchip_register_restart_notifier); diff --git a/drivers/clk/rockchip/clk.h b/drivers/clk/rockchip/clk.h index dabc730a3a40..74d935eaca32 100644 --- a/drivers/clk/rockchip/clk.h +++ b/drivers/clk/rockchip/clk.h @@ -1037,5 +1037,6 @@ static inline void rockchip_register_softrst(struct device_node *np, { } #endif +extern void (*rk_dump_cru)(void); #endif