From 7365bca626881ef4f26ddb5db593c1384e7e5687 Mon Sep 17 00:00:00 2001 From: Marijn Suijten Date: Thu, 19 Jan 2023 00:35:23 +0100 Subject: [PATCH] Implement MCCC measurements for SM8150 and SM8250 --- debugcc.c | 6 ++++++ debugcc.h | 1 + sm8150.c | 10 +++++++++- sm8250.c | 14 +++++++------- 4 files changed, 23 insertions(+), 8 deletions(-) diff --git a/debugcc.c b/debugcc.c index 7ecfe94..cfcb4cd 100644 --- a/debugcc.c +++ b/debugcc.c @@ -186,6 +186,12 @@ static unsigned long measure_default(const struct measure_clk *clk) return raw_count_full; } +unsigned long measure_mccc(const struct measure_clk *clk) +{ + /* MCCC is always on, just read the rate and return. */ + return 1000000000000ULL / readl(clk->leaf->base + clk->leaf_mux); +} + static void measure(const struct measure_clk *clk) { unsigned long clk_rate; diff --git a/debugcc.h b/debugcc.h index e9f27f4..a851543 100644 --- a/debugcc.h +++ b/debugcc.h @@ -87,6 +87,7 @@ struct debugcc_platform { int mmap_mux(int devmem, struct debug_mux *mux); void mux_enable(struct debug_mux *mux); void mux_disable(struct debug_mux *mux); +unsigned long measure_mccc(const struct measure_clk *clk); extern struct debugcc_platform msm8936_debugcc; extern struct debugcc_platform msm8996_debugcc; diff --git a/sm8150.c b/sm8150.c index 718f36a..1767f3c 100644 --- a/sm8150.c +++ b/sm8150.c @@ -138,6 +138,14 @@ static struct debug_mux npu_cc = { .div_val = 2, }; +static struct debug_mux mc_cc = { + .phys = 0x90b0000, + .size = /* 0x54 */ 0x1000, + .block_name = "mc", + + .measure = measure_mccc, +}; + static struct debug_mux cpu_cc = { .phys = 0x182a0000, .size = 0x1000, @@ -247,7 +255,7 @@ static struct measure_clk sm8150_clocks[] = { { "measure_only_cdsp_clk", &gcc, 0xdb, 0, 0, 2 }, { "measure_only_snoc_clk", &gcc, 0x7 }, { "measure_only_cnoc_clk", &gcc, 0x19 }, - // { "measure_only_mccc_clk", &gcc, 0xd0, 1, MC_CC, 0xd0 }, // TODO: at 90b0000 + { "measure_only_mccc_clk", &gcc, 0xd0, &mc_cc, 0x50 }, { "measure_only_ipa_2x_clk", &gcc, 0x147 }, { "gcc_aggre_noc_pcie_tbu_clk", &gcc, 0x36 }, { "gcc_aggre_ufs_card_axi_clk", &gcc, 0x141 }, diff --git a/sm8250.c b/sm8250.c index a1330e1..1776b5a 100644 --- a/sm8250.c +++ b/sm8250.c @@ -138,13 +138,13 @@ static struct debug_mux video_cc = { .div_val = 3, }; -// static struct debug_mux mc_cc = { -// .phys = 0x90ba000, -// .size = /* 0x54 */ 0x1000, -// .block_name = "mc", +static struct debug_mux mc_cc = { + .phys = 0x90ba000, + .size = /* 0x54 */ 0x1000, + .block_name = "mc", -// /* TODO: Requires custom readback from https://github.com/andersson/debugcc/pull/15 */ -// }; + .measure = measure_mccc, +}; static struct debug_mux apss_cc = { .phys = 0x182a0000, @@ -477,7 +477,7 @@ static struct measure_clk sm8250_clocks[] = { { "video_cc_sleep_clk", &gcc, 0x57, &video_cc, 0xc }, { "video_cc_xo_clk", &gcc, 0x57, &video_cc, 0xb }, - // { "measure_only_mccc_clk", &gcc, 0xd1, &mc_cc }, + { "measure_only_mccc_clk", &gcc, 0xd1, &mc_cc, 0x50 }, { "measure_only_apcs_gold_post_acd_clk", &gcc, 0xe7, &apss_cc, 0x25, /* TODO: Are these pre_div_vals? */ 8 }, { "measure_only_apcs_goldplus_post_acd_clk", &gcc, 0xe7, &apss_cc, 0x61, /* TODO: Are these pre_div_vals? */ 8 },