platform: pm: Add HP_CLK management to pm_runtime

Clock manegement is important part for power consumption optimization,
what is a task of this module.

Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
This commit is contained in:
Karol Trzcinski 2020-07-07 20:59:37 +02:00 committed by Liam Girdwood
parent a2c276e446
commit 447359f16f
4 changed files with 52 additions and 2 deletions

View File

@ -40,6 +40,7 @@ enum pm_runtime_context {
DMIC_POW, /**< DMIC Power */
DW_DMAC_CLK, /**< DW DMAC Clock */
CORE_MEMORY_POW, /**< Core Memory power */
CORE_HP_CLK, /**< High Performance Clock*/
PM_RUNTIME_DSP /**< DSP */
};

View File

@ -22,6 +22,7 @@ struct pm_runtime_data;
struct cavs_pm_runtime_data {
int dsp_d0_sref; /**< simple ref counter, accessed by core 0 only */
int host_dma_l1_sref; /**< ref counter for Host DMA accesses */
uint32_t sleep_core_mask; /**< represents cores in waiti state */
};
#endif

View File

@ -9,6 +9,7 @@
#include <sof/lib/clk.h>
#include <sof/lib/memory.h>
#include <sof/lib/notifier.h>
#include <sof/lib/pm_runtime.h>
#include <sof/sof.h>
#include <sof/spinlock.h>
@ -127,12 +128,12 @@ static void platform_clock_low_power_mode(int clock, bool enable)
void platform_clock_on_wakeup(void)
{
clock_low_power_mode(CLK_CPU(cpu_get_id()), false);
pm_runtime_get(CORE_HP_CLK, cpu_get_id());
}
void platform_clock_on_waiti(void)
{
clock_low_power_mode(CLK_CPU(cpu_get_id()), true);
pm_runtime_put(CORE_HP_CLK, cpu_get_id());
}
#else

View File

@ -337,6 +337,47 @@ static inline void cavs_pm_runtime_core_en_memory(uint32_t index)
#endif
}
static inline void cavs_pm_runtime_core_dis_hp_clk(uint32_t index)
{
int all_active_cores_sleep;
int enabled_cores = cpu_enabled_cores();
struct pm_runtime_data *prd = pm_runtime_data_get();
struct cavs_pm_runtime_data *pprd = prd->platform_data;
uint32_t flags;
spin_lock_irq(&prd->lock, flags);
pprd->sleep_core_mask |= BIT(index);
all_active_cores_sleep =
(enabled_cores & pprd->sleep_core_mask) == enabled_cores;
if (all_active_cores_sleep)
clock_low_power_mode(CLK_CPU(index), true);
platform_shared_commit(prd, sizeof(*prd));
platform_shared_commit(pprd, sizeof(*pprd));
spin_unlock_irq(&prd->lock, flags);
}
static inline void cavs_pm_runtime_core_en_hp_clk(uint32_t index)
{
struct pm_runtime_data *prd = pm_runtime_data_get();
struct cavs_pm_runtime_data *pprd = prd->platform_data;
uint32_t flags;
spin_lock_irq(&prd->lock, flags);
pprd->sleep_core_mask &= ~BIT(index);
clock_low_power_mode(CLK_CPU(index), false);
platform_shared_commit(prd, sizeof(*prd));
platform_shared_commit(pprd, sizeof(*pprd));
spin_unlock_irq(&prd->lock, flags);
}
static inline void cavs_pm_runtime_dis_dsp_pg(uint32_t index)
{
#if CAVS_VERSION >= CAVS_VERSION_1_8
@ -434,6 +475,9 @@ void platform_pm_runtime_get(enum pm_runtime_context context, uint32_t index,
case CORE_MEMORY_POW:
cavs_pm_runtime_core_en_memory(index);
break;
case CORE_HP_CLK:
cavs_pm_runtime_core_en_hp_clk(index);
break;
case PM_RUNTIME_DSP:
cavs_pm_runtime_dis_dsp_pg(index);
break;
@ -471,6 +515,9 @@ void platform_pm_runtime_put(enum pm_runtime_context context, uint32_t index,
case CORE_MEMORY_POW:
cavs_pm_runtime_core_dis_memory(index);
break;
case CORE_HP_CLK:
cavs_pm_runtime_core_dis_hp_clk(index);
break;
case PM_RUNTIME_DSP:
cavs_pm_runtime_en_dsp_pg(index);
break;