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
|
/* SPDX-License-Identifier: GPL-2.0-only OR MIT */
#include <soc/devapc.h>
#include <soc/devapc_common.h>
void *getreg_domain(uintptr_t base, unsigned int offset,
enum domain_id domain_id, unsigned int index)
{
return (void *)(base + offset + domain_id * DOMAIN_OFT + index * IDX_OFT);
}
void *getreg(uintptr_t base, unsigned int offset)
{
return getreg_domain(base, offset, 0, 0);
}
void set_module_apc(uintptr_t base, uint32_t module, enum domain_id domain_id,
enum devapc_perm_type perm)
{
uint32_t apc_register_index;
uint32_t apc_set_index;
apc_register_index = module / MOD_NO_IN_1_DEVAPC;
apc_set_index = module % MOD_NO_IN_1_DEVAPC;
clrsetbits32(getreg_domain(base, 0, domain_id, apc_register_index),
0x3 << (apc_set_index * 2),
perm << (apc_set_index * 2));
}
void dapc_init(void)
{
size_t i;
uintptr_t devapc_ao_base;
for (i = 0; i < devapc_init_cnt; i++) {
devapc_ao_base = devapc_init[i].base;
/* Init dapc */
write32(getreg(devapc_ao_base, AO_APC_CON), 0x0);
write32(getreg(devapc_ao_base, AO_APC_CON), 0x1);
/* Initialization */
if (devapc_init[i].init)
devapc_init[i].init(devapc_ao_base);
/* Dump setting */
if (CONFIG(DEVAPC_DEBUG) && devapc_init[i].dump)
devapc_init[i].dump(devapc_ao_base);
}
}
|