1/*
2 * Copyright 2014, General Dynamics C4 Systems
3 *
4 * This software may be distributed and modified according to the terms of
5 * the GNU General Public License version 2. Note that NO WARRANTY is provided.
6 * See "LICENSE_GPLv2.txt" for details.
7 *
8 * @TAG(GD_GPL)
9 */
10
11#include <config.h>
12#include <types.h>
13#include <machine/io.h>
14#include <kernel/vspace.h>
15#include <arch/machine.h>
16#include <arch/kernel/vspace.h>
17#include <plat/machine.h>
18#include <linker.h>
19#include <plat/machine/devices.h>
20#include <plat/machine/hardware.h>
21#include <plat/machine/timer.h>
22
23#define INTCPS_SYSCONFIG_SOFTRESET BIT(1)
24#define INTCPS_SYSSTATUS_RESETDONE BIT(0)
25
26#define TIMER_INTERVAL_MS (CONFIG_TIMER_TICK_MS)
27
28#define TIOCP_CFG_SOFTRESET BIT(1)
29#define TCLR_AUTORELOAD     BIT(1)
30#define TCLR_COMPAREENABLE  BIT(6)
31#define TCLR_STARTTIMER     BIT(0)
32#define TIER_MATCHENABLE    BIT(0)
33#define TIER_OVERFLOWENABLE BIT(1)
34
35timer_t *timer = (timer_t *) GPTIMER9_PPTR;
36
37BOOT_CODE void
38initTimer(void)
39{
40    /* Configure gptimer9 as kernel timer */
41    timer->cfg = TIOCP_CFG_SOFTRESET;
42
43    while (!timer->tistat);
44
45    maskInterrupt(/*disable*/ true, GPT9_IRQ);
46
47    /* Set the reload value */
48    timer->tldr = 0xFFFFFFFFUL - TIMER_RELOAD;
49
50    /* Enables interrupt on overflow */
51    timer->tier = TIER_OVERFLOWENABLE;
52
53    /* Clear the read register */
54    timer->tcrr = 0xFFFFFFFFUL - TIMER_RELOAD;
55
56    /* Set autoreload and start the timer */
57    timer->tclr = TCLR_AUTORELOAD | TCLR_STARTTIMER;
58}
59
60BOOT_CODE void
61initIRQController(void)
62{
63    intc->intcps_sysconfig = INTCPS_SYSCONFIG_SOFTRESET;
64    while (!(intc->intcps_sysstatus & INTCPS_SYSSTATUS_RESETDONE)) ;
65}
66
67BOOT_CODE void cpu_initLocalIRQController(void) {}
68
69void plat_cleanL2Range(paddr_t start, paddr_t end) {}
70void plat_invalidateL2Range(paddr_t start, paddr_t end) {}
71void plat_cleanInvalidateL2Range(paddr_t start, paddr_t end) {}
72void plat_cleanInvalidateCache(void) {}
73