diff options
author | Bo-Chen Chen <rex-bc.chen@mediatek.com> | 2022-08-29 19:05:06 +0800 |
---|---|---|
committer | Martin Roth <martin.roth@amd.corp-partner.google.com> | 2022-08-31 16:45:58 +0000 |
commit | 297b6340623cf351ba219237e8e9d049e8c10c67 (patch) | |
tree | 9610d336ebdec7f773214376afbb83800d70b321 /src/soc/mediatek/common/devapc.c | |
parent | 40adaf6e7c5966e1e4bec6528d0a24339c10e226 (diff) |
soc/mediatek: Move common DEVPAC enums and functions to common
Some enums and functions are the same in DEVAPC driver for MT8195,
MT8186, and MT8188, so we move them to common folder.
TEST=build pass.
BUG=b:233720142
Signed-off-by: Bo-Chen Chen <rex-bc.chen@mediatek.com>
Change-Id: Ia7d2145780780fd54b76952db96424b8ea477594
Reviewed-on: https://review.coreboot.org/c/coreboot/+/67171
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Yu-Ping Wu <yupingso@google.com>
Diffstat (limited to 'src/soc/mediatek/common/devapc.c')
-rw-r--r-- | src/soc/mediatek/common/devapc.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/soc/mediatek/common/devapc.c b/src/soc/mediatek/common/devapc.c new file mode 100644 index 0000000000..f491817f06 --- /dev/null +++ b/src/soc/mediatek/common/devapc.c @@ -0,0 +1,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)); +} |