#include <config.h>
#include <types.h>
#include <machine/io.h>
#include <kernel/vspace.h>
#include <arch/machine.h>
#include <arch/kernel/vspace.h>
#include <plat/machine.h>
#include <arch/linker.h>
#include <plat/machine/devices.h>
#include <plat/machine/hardware.h>
static void
write_cntp_ctl(uint32_t v)
{
asm volatile ("mcr p15, 0, %0, c14, c2, 1" ::"r"(v));
}
static void
write_cntp_tval(uint32_t v)
{
asm volatile ("mcr p15, 0, %0, c14, c2, 0" :: "r"(v));
}
static uint32_t
read_cntfrq(void)
{
uint32_t val;
asm volatile ("mrc p15, 0, %0, c14, c0, 0" : "=r"(val));
return val;
}
#define GPT_DEFAULT_FREQ 0x7a1200
#define GPT_DEFAULT_FREQ_MHZ 8ull
static uint32_t gpt_cntp_tval = 0;
void
initTimer(void)
{
uint32_t freq = read_cntfrq();
uint64_t tval = 0;
if (freq != GPT_DEFAULT_FREQ) {
printf("Default timer has a different frequency %x\n", freq);
}
tval = (uint64_t)CONFIG_TIMER_TICK_MS * (freq / 1000);
if (tval > 0xffffffff) {
printf("timer interval value out of range \n");
halt();
}
gpt_cntp_tval = (uint32_t)tval;
write_cntp_tval(gpt_cntp_tval);
write_cntp_ctl(0x1);
}
void
resetTimer(void)
{
write_cntp_tval(gpt_cntp_tval);
}
void
initL2Cache(void)
{
}
void plat_cleanL2Range(paddr_t start, paddr_t end) {}
void plat_invalidateL2Range(paddr_t start, paddr_t end) {}
void plat_cleanInvalidateL2Range(paddr_t start, paddr_t end) {}
void plat_cleanInvalidateCache(void) {}