pm_runtime: add pm runtime data to sof context

Adds pm runtime data to sof main context. Also implements
getter to easily retrieve the data through one point of access.

Signed-off-by: Tomasz Lauda <tomasz.lauda@linux.intel.com>
This commit is contained in:
Tomasz Lauda 2020-01-08 10:29:23 +01:00 committed by Liam Girdwood
parent 41a5e795a7
commit af79cf4656
4 changed files with 26 additions and 18 deletions

View File

@ -16,13 +16,12 @@
#define __SOF_LIB_PM_RUNTIME_H__
#include <platform/lib/pm_runtime.h>
#include <sof/sof.h>
#include <sof/spinlock.h>
#include <sof/trace/trace.h>
#include <user/trace.h>
#include <stdint.h>
struct sof;
/** \addtogroup pm_runtime PM Runtime
* PM runtime specification.
* @{
@ -119,6 +118,16 @@ void pm_runtime_disable(enum pm_runtime_context context, uint32_t index);
*/
bool pm_runtime_is_active(enum pm_runtime_context context, uint32_t index);
/**
* \brief Retrieves pointer to runtime power management data.
*
* @return Runtime power management data pointer.
*/
static inline struct pm_runtime_data *pm_runtime_data_get(void)
{
return sof_get()->prd;
}
/** @}*/
#endif /* __SOF_LIB_PM_RUNTIME_H__ */

View File

@ -17,6 +17,7 @@ struct dma_trace_data;
struct ipc;
struct ll_schedule_domain;
struct mm;
struct pm_runtime_data;
struct sa;
struct timer;
struct trace;
@ -60,6 +61,9 @@ struct sof {
/* memory map */
struct mm *memory_map;
/* runtime power management data */
struct pm_runtime_data *prd;
__aligned(PLATFORM_DCACHE_ALIGN) int alignment[0];
} __aligned(PLATFORM_DCACHE_ALIGN);

View File

@ -17,15 +17,13 @@
#include <ipc/topology.h>
#include <stdint.h>
/** \brief Runtime power management data pointer. */
static struct pm_runtime_data *prd;
void pm_runtime_init(struct sof *sof)
{
prd = rzalloc(SOF_MEM_ZONE_SYS, 0, SOF_MEM_CAPS_RAM, sizeof(*prd));
spinlock_init(&prd->lock);
sof->prd = rzalloc(SOF_MEM_ZONE_SYS, 0, SOF_MEM_CAPS_RAM,
sizeof(*sof->prd));
spinlock_init(&sof->prd->lock);
platform_pm_runtime_init(prd);
platform_pm_runtime_init(sof->prd);
}
void pm_runtime_get(enum pm_runtime_context context, uint32_t index)

View File

@ -38,17 +38,15 @@
#include <cavs/lib/power_down.h>
#endif
/** \brief Runtime power management data pointer. */
struct pm_runtime_data *_prd;
/**
* \brief Forces Host DMAs to exit L1.
*/
static inline void cavs_pm_runtime_force_host_dma_l1_exit(void)
{
struct pm_runtime_data *prd = pm_runtime_data_get();
uint32_t flags;
spin_lock_irq(_prd->lock, flags);
spin_lock_irq(prd->lock, flags);
if (!(shim_read(SHIM_SVCFG) & SHIM_SVCFG_FORCE_L1_EXIT)) {
shim_write(SHIM_SVCFG,
@ -60,13 +58,14 @@ static inline void cavs_pm_runtime_force_host_dma_l1_exit(void)
shim_read(SHIM_SVCFG) & ~(SHIM_SVCFG_FORCE_L1_EXIT));
}
spin_unlock_irq(_prd->lock, flags);
spin_unlock_irq(prd->lock, flags);
}
static inline void cavs_pm_runtime_enable_dsp(bool enable)
{
uint32_t flags;
struct cavs_pm_runtime_data *pprd = _prd->platform_data;
struct cavs_pm_runtime_data *pprd =
pm_runtime_data_get()->platform_data;
/* request is always run on dsp0 and applies to dsp0,
* so no global lock is required.
@ -83,7 +82,7 @@ static inline void cavs_pm_runtime_enable_dsp(bool enable)
static inline bool cavs_pm_runtime_is_active_dsp(void)
{
struct cavs_pm_runtime_data *pprd =
(struct cavs_pm_runtime_data *)_prd->platform_data;
pm_runtime_data_get()->platform_data;
return pprd->dsp_d0_sref > 0;
}
@ -350,10 +349,8 @@ void platform_pm_runtime_init(struct pm_runtime_data *prd)
{
struct cavs_pm_runtime_data *pprd;
_prd = prd;
pprd = rzalloc(SOF_MEM_ZONE_SYS, 0, SOF_MEM_CAPS_RAM, sizeof(*pprd));
_prd->platform_data = pprd;
prd->platform_data = pprd;
}
void platform_pm_runtime_get(enum pm_runtime_context context, uint32_t index,