mirror of https://github.com/thesofproject/sof.git
timer: add cpu timer to sof global context
A cpu timer may be used with arch_timer api to read a cpu timer in a common way including platforms that have a dedicated platform timer and their platform_timer api is not a simple redirection to arch_timer. Sometimes it is important to have access to both, e.g. when computing performance counters, since the platform one is expected to be always running timer while the cpu timer may be gated in idle. Signed-off-by: Marcin Maka <marcin.maka@linux.intel.com>
This commit is contained in:
parent
426525b594
commit
8dcf0a7c89
|
@ -31,6 +31,11 @@ static inline struct timer *timer_get(void)
|
|||
return sof_get()->platform_timer;
|
||||
}
|
||||
|
||||
static inline struct timer *cpu_timer_get(void)
|
||||
{
|
||||
return sof_get()->cpu_timer;
|
||||
}
|
||||
|
||||
static inline int64_t timer_set(struct timer *timer, uint64_t ticks)
|
||||
{
|
||||
return arch_timer_set(timer, ticks);
|
||||
|
|
|
@ -55,6 +55,9 @@ struct sof {
|
|||
/* default platform timer */
|
||||
struct timer *platform_timer;
|
||||
|
||||
/* cpu (arch) timer */
|
||||
struct timer *cpu_timer;
|
||||
|
||||
/* timer domain for driving timer LL scheduler */
|
||||
struct ll_schedule_domain *platform_timer_domain;
|
||||
|
||||
|
|
|
@ -173,6 +173,7 @@ int platform_init(struct sof *sof)
|
|||
int ret;
|
||||
|
||||
sof->platform_timer = &timer;
|
||||
sof->cpu_timer = &timer;
|
||||
|
||||
/* clear mailbox for early trace and debug */
|
||||
trace_point(TRACE_BOOT_PLATFORM_MBOX);
|
||||
|
|
|
@ -170,6 +170,7 @@ int platform_init(struct sof *sof)
|
|||
int ret;
|
||||
|
||||
sof->platform_timer = &timer;
|
||||
sof->cpu_timer = &timer;
|
||||
|
||||
/* clear mailbox for early trace and debug */
|
||||
trace_point(TRACE_BOOT_PLATFORM_MBOX);
|
||||
|
|
|
@ -152,6 +152,7 @@ int platform_init(struct sof *sof)
|
|||
int ret;
|
||||
|
||||
sof->platform_timer = &timer;
|
||||
sof->cpu_timer = &timer;
|
||||
|
||||
platform_interrupt_init();
|
||||
platform_clock_init(sof);
|
||||
|
|
|
@ -257,6 +257,11 @@ struct timer timer = {
|
|||
.irq_name = irq_name_level2,
|
||||
};
|
||||
|
||||
struct timer arch_timer = {
|
||||
.id = TIMER1, /* internal timer */
|
||||
.irq = IRQ_NUM_TIMER2,
|
||||
};
|
||||
|
||||
#if CONFIG_DW_SPI
|
||||
|
||||
#include <sof/drivers/spi.h>
|
||||
|
@ -338,6 +343,7 @@ int platform_init(struct sof *sof)
|
|||
int i;
|
||||
|
||||
sof->platform_timer = &timer;
|
||||
sof->cpu_timer = &arch_timer;
|
||||
|
||||
/* Turn off memory for all unused cores */
|
||||
for (i = 0; i < PLATFORM_CORE_COUNT; i++)
|
||||
|
|
Loading…
Reference in New Issue