From 93f5ccd03793aa678ea01e2f1891e39a3e264ad5 Mon Sep 17 00:00:00 2001 From: Christian Marangi Date: Tue, 13 Jun 2023 17:02:32 +0200 Subject: [PATCH] debugcc: supports custom xo rate Some device have a different rate for the xo debug oscillator. Add support for defining custom xo rate in the primary debug mux. Signed-off-by: Christian Marangi --- debugcc.c | 6 +++++- debugcc.h | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/debugcc.c b/debugcc.c index 0071647..0299964 100644 --- a/debugcc.c +++ b/debugcc.c @@ -116,11 +116,15 @@ void mux_disable(struct debug_mux *mux) unsigned long measure_gcc(const struct measure_clk *clk, const struct debug_mux *mux) { + unsigned int xo_rate = 4800000; uint64_t raw_count_short; uint64_t raw_count_full; struct gcc_mux *gcc = container_of(mux, struct gcc_mux, mux); unsigned long xo_div4; + if (gcc->xo_rate) + xo_rate = gcc->xo_rate; + xo_div4 = readl(mux->base + gcc->xo_div4_reg); if (gcc->xo_div4_val) writel(xo_div4 | gcc->xo_div4_val, mux->base + gcc->xo_div4_reg); @@ -136,7 +140,7 @@ unsigned long measure_gcc(const struct measure_clk *clk, return 0; } - raw_count_full = ((raw_count_full * 10) + 15) * 4800000; + raw_count_full = ((raw_count_full * 10) + 15) * xo_rate; raw_count_full = raw_count_full / ((0x10000 * 10) + 35); if (mux->div_val) diff --git a/debugcc.h b/debugcc.h index 517a2ca..df9981a 100644 --- a/debugcc.h +++ b/debugcc.h @@ -65,6 +65,8 @@ struct debug_mux { struct gcc_mux { struct debug_mux mux; + unsigned int xo_rate; + unsigned int xo_div4_reg; unsigned int xo_div4_val;