From 4033430f859097076f1b531714efd4fa1faafc99 Mon Sep 17 00:00:00 2001 From: Raghavendra Prasad N Date: Fri, 1 Sep 2023 18:13:02 +0530 Subject: [PATCH] soc: qcom: qcom_stats: Add support for deep sleep exit time Add get_aosd_sleep_exit_time() to get aosd deep sleep exit time. Change-Id: I8a03a99ccf2eb38e531999a914e04486311bcdae Signed-off-by: Raghavendra Prasad N --- drivers/soc/qcom/qcom_stats.c | 35 +++++++++++++++++++++++++++++++++++ include/soc/qcom/qcom_stats.h | 3 +++ 2 files changed, 38 insertions(+) diff --git a/drivers/soc/qcom/qcom_stats.c b/drivers/soc/qcom/qcom_stats.c index 2ab0bec5912f..4b9bb3141f95 100644 --- a/drivers/soc/qcom/qcom_stats.c +++ b/drivers/soc/qcom/qcom_stats.c @@ -149,6 +149,7 @@ struct stats_drvdata { }; static struct stats_drvdata *drv; +static u64 deep_sleep_last_exited_time; struct sleep_stats { u32 stat_type; @@ -275,6 +276,40 @@ static bool ddr_stats_is_freq_overtime(struct sleep_stats *data) return false; } +uint64_t get_aosd_sleep_exit_time(void) +{ + int i; + u64 last_exited_at; + u32 count; + static u32 saved_deep_sleep_count; + u32 s_type = 0; + char stat_type[5] = {0}; + + for (i = 0; i < drv->config->num_records; i++) { + s_type = readl_relaxed(drv->d[i].base); + memcpy(stat_type, &s_type, sizeof(u32)); + strim(stat_type); + + if (!memcmp((const void *)stat_type, (const void *)"aosd", 4)) { + count = readl_relaxed(drv->d[i].base + COUNT_OFFSET); + + if (saved_deep_sleep_count == count) + deep_sleep_last_exited_time = 0; + else { + saved_deep_sleep_count = count; + last_exited_at = readq_relaxed(drv->d[i].base + + LAST_EXITED_AT_OFFSET); + deep_sleep_last_exited_time = last_exited_at; + } + break; + + } + } + + return deep_sleep_last_exited_time; +} +EXPORT_SYMBOL_GPL(get_aosd_sleep_exit_time); + static u64 qcom_stats_fill_ddr_stats(void __iomem *reg, struct sleep_stats *data, u32 *entry_count) { u64 accumulated_duration = 0; diff --git a/include/soc/qcom/qcom_stats.h b/include/soc/qcom/qcom_stats.h index 0ad497a0f552..567ad6cbb289 100644 --- a/include/soc/qcom/qcom_stats.h +++ b/include/soc/qcom/qcom_stats.h @@ -37,6 +37,7 @@ void subsystem_sleep_debug_enable(bool enable); int cx_stats_get_ss_vote_info(int ss_count, struct qcom_stats_cx_vote_info *vote_info); +uint64_t get_aosd_sleep_exit_time(void); #else @@ -62,6 +63,8 @@ void subsystem_sleep_debug_enable(bool enable) static inline int cx_stats_get_ss_vote_info(int ss_count, struct qcom_stats_cx_vote_info *vote_info) { return -ENODEV; } +uint64_t get_aosd_sleep_exit_time(void) +{ return -ENODEV; } #endif #endif /*__QCOM_STATS_H__ */