diff --git a/drivers/clk/rockchip/clk-rk3368.c b/drivers/clk/rockchip/clk-rk3368.c index 0201713f7374..a3fa7fc7466c 100644 --- a/drivers/clk/rockchip/clk-rk3368.c +++ b/drivers/clk/rockchip/clk-rk3368.c @@ -899,6 +899,18 @@ static const char *const rk3368_critical_clocks[] __initconst = { "aclk_dmac_bus", }; +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; @@ -950,5 +962,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 d5e130263c05..3a6994ff9655 100644 --- a/drivers/clk/rockchip/clk.c +++ b/drivers/clk/rockchip/clk.c @@ -654,6 +654,21 @@ void __init rockchip_clk_protect_critical(const char *const clocks[], } } +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); @@ -684,4 +699,6 @@ void __init 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); } diff --git a/drivers/clk/rockchip/clk.h b/drivers/clk/rockchip/clk.h index 45c9fb3a409a..e4967565e521 100644 --- a/drivers/clk/rockchip/clk.h +++ b/drivers/clk/rockchip/clk.h @@ -958,5 +958,6 @@ static inline void rockchip_register_softrst(struct device_node *np, { } #endif +extern void (*rk_dump_cru)(void); #endif