ls_gic.c 1.12 KB
Newer Older
1
2
3
4
5
6
7
/*
 * Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
 *
 * SPDX-License-Identifier: BSD-3-Clause
 */

#include <endian.h>
8
9
10
11
12
13

#include <platform_def.h>

#include <common/debug.h>
#include <lib/mmio.h>

14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include "soc.h"

/*
 * Get GIC offset
 * For LS1043a rev1.0, GIC base address align with 4k.
 * For LS1043a rev1.1, if DCFG_GIC400_ALIGN[GIC_ADDR_BIT]
 * is set, GIC base address align with 4K, or else align
 * with 64k.
 */
void get_gic_offset(uint32_t *gicc_base, uint32_t *gicd_base)
{

	uint32_t *ccsr_svr = (uint32_t *)DCFG_CCSR_SVR;
	uint32_t *gic_align = (uint32_t *)SCFG_GIC400_ALIGN;
	uint32_t val;
	uint32_t soc_dev_id;

	val = be32toh(mmio_read_32((uintptr_t)ccsr_svr));
	soc_dev_id = val & (SVR_WO_E << 8);

	if ((soc_dev_id == (SVR_LS1043A << 8) ||
			soc_dev_id == (SVR_LS1043AE << 8)) &&
			((val & 0xff) == REV1_1)) {
		val = be32toh(mmio_read_32((uintptr_t)gic_align));
38
		if (val & (1U << GIC_ADDR_BIT)) {
39
40
41
42
43
44
45
46
47
48
49
			*gicc_base = GICC_BASE;
			*gicd_base = GICD_BASE;
		} else {
			*gicc_base = GICC_BASE_64K;
			*gicd_base = GICD_BASE_64K;
		}
	} else {
		*gicc_base = GICC_BASE;
		*gicd_base = GICD_BASE;
	}
}