summaryrefslogtreecommitdiff
path: root/src/soc/mediatek/common/devapc.c
blob: f491817f0680e5cc584ff4504cc4a78ef1ab528b (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
/* SPDX-License-Identifier: GPL-2.0-only OR MIT */

#include <console/console.h>
#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));
}