1/*
2 * Copyright 2015, DornerWorks, Ltd.
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 */
6
7#include <config.h>
8#include <types.h>
9#include <machine/io.h>
10#include <kernel/vspace.h>
11#include <arch/machine.h>
12#include <arch/kernel/vspace.h>
13#include <plat/machine.h>
14#include <linker.h>
15#include <plat/machine/hardware.h>
16
17#define TIMER_CTL_EN_FLAG               BIT(0)
18#define TIMER_CTL_RELOAD_FLAG           BIT(1)
19
20#define TMR0_IRQ_EN_FLAG            BIT(0)
21
22timer_t *timer = (timer_t *) TIMER0_PPTR;
23
24/* Configure gptimer11 as kernel preemption timer */
25BOOT_CODE void initTimer(void)
26{
27    /* Set the reload value */
28    timer->tmr0_intv_value_reg = TIMER_RELOAD;
29
30    /* Enables interrupt */
31    timer->tmr_irq_en_reg = TMR0_IRQ_EN_FLAG;
32
33    /* Set autoreload and start the timer */
34    timer->tmr0_ctrl_reg = TIMER_CTL_EN_FLAG | TIMER_CTL_RELOAD_FLAG;
35}
36
37