From: Elaine Zhang Date: Wed, 20 Jul 2016 07:08:27 +0000 (+0800) Subject: clk: rockchip: rk3399: add cru regs dump for panic X-Git-Tag: firefly_0821_release~2107 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=ab5ef60b32d5da73bc7a4eecab9b81d3ecad3a42;p=firefly-linux-kernel-4.4.55.git clk: rockchip: rk3399: add cru regs dump for panic Add cru and pmucru regs dump when system panic. It's just for debug. Change-Id: I3f837f2941054129d20c2355d86f575d6ee84665 Signed-off-by: Elaine Zhang --- diff --git a/drivers/clk/rockchip/clk-rk3399.c b/drivers/clk/rockchip/clk-rk3399.c index f4f614a53a09..b32222b3eed1 100644 --- a/drivers/clk/rockchip/clk-rk3399.c +++ b/drivers/clk/rockchip/clk-rk3399.c @@ -1575,6 +1575,37 @@ static const char *const rk3399_pmucru_critical_clocks[] __initconst = { "pclk_rkpwm_pmu", }; +static void __iomem *rk3399_cru_base; +static void __iomem *rk3399_pmucru_base; + +void rk3399_dump_cru(void) +{ + if (rk3399_cru_base) { + pr_warn("CRU:\n"); + print_hex_dump(KERN_WARNING, "", DUMP_PREFIX_OFFSET, + 32, 4, rk3399_cru_base, + 0x594, false); + } + if (rk3399_pmucru_base) { + pr_warn("PMU CRU:\n"); + print_hex_dump(KERN_WARNING, "", DUMP_PREFIX_OFFSET, + 32, 4, rk3399_pmucru_base, + 0x134, false); + } +} +EXPORT_SYMBOL_GPL(rk3399_dump_cru); + +static int rk3399_clk_panic(struct notifier_block *this, + unsigned long ev, void *ptr) +{ + rk3399_dump_cru(); + return NOTIFY_DONE; +} + +static struct notifier_block rk3399_clk_panic_block = { + .notifier_call = rk3399_clk_panic, +}; + static void __init rk3399_clk_init(struct device_node *np) { struct rockchip_clk_provider *ctx; @@ -1587,6 +1618,8 @@ static void __init rk3399_clk_init(struct device_node *np) return; } + rk3399_cru_base = reg_base; + ctx = rockchip_clk_init(np, reg_base, CLK_NR_CLKS); if (IS_ERR(ctx)) { pr_err("%s: rockchip clk init failed\n", __func__); @@ -1640,6 +1673,8 @@ static void __init rk3399_pmu_clk_init(struct device_node *np) return; } + rk3399_pmucru_base = reg_base; + ctx = rockchip_clk_init(np, reg_base, CLKPMU_NR_CLKS); if (IS_ERR(ctx)) { pr_err("%s: rockchip pmu clk init failed\n", __func__); @@ -1659,5 +1694,8 @@ static void __init rk3399_pmu_clk_init(struct device_node *np) ROCKCHIP_SOFTRST_HIWORD_MASK); rockchip_clk_of_add_provider(np, ctx); + + atomic_notifier_chain_register(&panic_notifier_list, + &rk3399_clk_panic_block); } CLK_OF_DECLARE(rk3399_cru_pmu, "rockchip,rk3399-pmucru", rk3399_pmu_clk_init);