summaryrefslogtreecommitdiffstats
path: root/plat/socionext/uniphier/uniphier_cci.c
blob: 3ca176895b0927d3c7d993869fc06db7b8fe01bd (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
72
73
74
75
76
77
78
79
80
81
/*
 * Copyright (c) 2017, ARM Limited and Contributors. All rights reserved.
 *
 * SPDX-License-Identifier: BSD-3-Clause
 */

#include <stddef.h>

#include <arch_helpers.h>
#include <drivers/arm/cci.h>
#include <lib/utils_def.h>

#include "uniphier.h"

#define UNIPHIER_CCI500_BASE	0x5FD00000

static const int uniphier_cci_map[] = {1, 0};

static void __uniphier_cci_init(void)
{
	cci_init(UNIPHIER_CCI500_BASE, uniphier_cci_map,
		 ARRAY_SIZE(uniphier_cci_map));
}

static void __uniphier_cci_enable(void)
{
	cci_enable_snoop_dvm_reqs(MPIDR_AFFLVL1_VAL(read_mpidr_el1()));
}

static void __uniphier_cci_disable(void)
{
	cci_disable_snoop_dvm_reqs(MPIDR_AFFLVL1_VAL(read_mpidr_el1()));
}

struct uniphier_cci_ops {
	void (*init)(void);
	void (*enable)(void);
	void (*disable)(void);
};

static const struct uniphier_cci_ops uniphier_cci_ops_table[] = {
	[UNIPHIER_SOC_LD11] = {
		.init = NULL,
		.enable = NULL,
		.disable = NULL,
	},
	[UNIPHIER_SOC_LD20] = {
		.init = __uniphier_cci_init,
		.enable = __uniphier_cci_enable,
		.disable = __uniphier_cci_disable,
	},
	[UNIPHIER_SOC_PXS3] = {
		.init = NULL,
		.enable = NULL,
		.disable = NULL,
	},
};

static struct uniphier_cci_ops uniphier_cci_ops;

void uniphier_cci_init(unsigned int soc)
{
	uniphier_cci_ops = uniphier_cci_ops_table[soc];
	flush_dcache_range((uint64_t)&uniphier_cci_ops,
			   sizeof(uniphier_cci_ops));

	if (uniphier_cci_ops.init)
		uniphier_cci_ops.init();
}

void uniphier_cci_enable(void)
{
	if (uniphier_cci_ops.enable)
		uniphier_cci_ops.enable();
}

void uniphier_cci_disable(void)
{
	if (uniphier_cci_ops.disable)
		uniphier_cci_ops.disable();
}