summaryrefslogtreecommitdiff
path: root/big-little/common/vgic_setup.c
blob: e9c7873e573a2515a40387337233673bdb9eeb2a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/*
 * $Copyright:
 * ----------------------------------------------------------------
 * This confidential and proprietary software may be used only as
 * authorised by a licensing agreement from ARM Limited
 *  (C) COPYRIGHT 2008-2011 ARM Limited
 *       ALL RIGHTS RESERVED
 * The entire notice above must be reproduced on all authorised
 * copies and copies may only be made to the extent permitted
 * by a licensing agreement from ARM Limited.
 * ----------------------------------------------------------------
 * File:     vgic_setup.c
 * ----------------------------------------------------------------
 * $
 */

#include "int_master.h"
#include "gic_registers.h"
#include "virt_helpers.h"
#include "misc.h"
#include "events.h"
#include "vgiclib.h"

/*
 * The Big-little spftware needs to bother itself with
 * bareminimal vGIC configuration. 
 *
 * 1. Distributor. Security bits should be taken care of 
 * by the boot firmaware after a cold reset. Big-little
 * code should initialise private interrupts as secure
 * after a warm reset.
 *
 * 2. Physical Cpu interface. Initialised by us after
 * both warm and cold reset.
 *
 * 3. Virtual CPU interface (HYP view). Initialised by us 
 * after cold reset & restored after warm reset.
 *
 * 4. Virtual CPU interface (CPU view). Initialised by 
 * the payload software after cold reset and restored by 
 * us after a warm reset.
 */
static void gic_cpuinit()
{
        /* Disable the PCPUIF before configuring it. */
        write32(GIC_IC_PHY_BASE + GICC_CTL, 0x0);
        write32(GIC_IC_PHY_BASE + GICC_BP, 0x0);
        write32(GIC_IC_PHY_BASE + GICC_PRIMASK, 0xFF);
        /* Enable split EOI & Non-secure PCPUIF */
        write32(GIC_IC_PHY_BASE + GICC_CTL, 0x201);
}

void SetupVGIC(unsigned warm_reset)
{
        /* 
         * Initialise the HYP view Virtual CPU interface after
         * a cold reset
         */
        if (!warm_reset)
                vgic_init();

        /* Initialise the Physical cpu interface */
        gic_cpuinit();

        /*
         * Enable Virtual exceptions
         */
        write_hcr(read_hcr() | HCR_AMO | HCR_IMO | HCR_FMO);

        return;
}