123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571 |
- /*
- * Copyright (c) 2021, MediaTek Inc. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
- #include <common/debug.h>
- #include <mtk_apusys_apc.h>
- #include <mtk_apusys_apc_def.h>
- #include <mtk_plat_common.h>
- #include <platform_def.h>
- static const struct APC_DOM_16 APUSYS_NOC_DAPC_AO[] = {
- /* 0~3 */
- APUSYS_APC_AO_ATTR("slv07-0",
- NO_PROTECTION, NO_PROTECTION, NO_PROTECTION, NO_PROTECTION,
- NO_PROTECTION, NO_PROTECTION, NO_PROTECTION, NO_PROTECTION,
- NO_PROTECTION, NO_PROTECTION, NO_PROTECTION, NO_PROTECTION,
- NO_PROTECTION, NO_PROTECTION, NO_PROTECTION, NO_PROTECTION),
- APUSYS_APC_AO_ATTR("slv07-1",
- NO_PROTECTION, NO_PROTECTION, NO_PROTECTION, NO_PROTECTION,
- NO_PROTECTION, NO_PROTECTION, NO_PROTECTION, NO_PROTECTION,
- NO_PROTECTION, NO_PROTECTION, NO_PROTECTION, NO_PROTECTION,
- NO_PROTECTION, NO_PROTECTION, NO_PROTECTION, NO_PROTECTION),
- APUSYS_APC_AO_ATTR("slv07-2",
- NO_PROTECTION, NO_PROTECTION, NO_PROTECTION, NO_PROTECTION,
- NO_PROTECTION, NO_PROTECTION, NO_PROTECTION, NO_PROTECTION,
- NO_PROTECTION, NO_PROTECTION, NO_PROTECTION, NO_PROTECTION,
- NO_PROTECTION, NO_PROTECTION, NO_PROTECTION, NO_PROTECTION),
- APUSYS_APC_AO_ATTR("slv07-3",
- NO_PROTECTION, NO_PROTECTION, NO_PROTECTION, NO_PROTECTION,
- NO_PROTECTION, NO_PROTECTION, NO_PROTECTION, NO_PROTECTION,
- NO_PROTECTION, NO_PROTECTION, NO_PROTECTION, NO_PROTECTION,
- NO_PROTECTION, NO_PROTECTION, NO_PROTECTION, NO_PROTECTION),
- /* 16~18 */
- APUSYS_APC_AO_ATTR("slv01-0",
- NO_PROTECTION, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN),
- APUSYS_APC_AO_ATTR("slv01-1",
- NO_PROTECTION, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN),
- APUSYS_APC_AO_ATTR("slv01-2",
- NO_PROTECTION, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN),
- /* 19~21 */
- APUSYS_APC_AO_ATTR("slv00-0",
- NO_PROTECTION, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN),
- APUSYS_APC_AO_ATTR("slv00-1",
- NO_PROTECTION, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN),
- APUSYS_APC_AO_ATTR("slv00-2",
- NO_PROTECTION, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN),
- /* 22~26 */
- APUSYS_APC_AO_ATTR("slv02-0",
- NO_PROTECTION, NO_PROTECTION, NO_PROTECTION, NO_PROTECTION,
- NO_PROTECTION, NO_PROTECTION, NO_PROTECTION, NO_PROTECTION,
- NO_PROTECTION, NO_PROTECTION, NO_PROTECTION, NO_PROTECTION,
- NO_PROTECTION, NO_PROTECTION, NO_PROTECTION, NO_PROTECTION),
- APUSYS_APC_AO_ATTR("slv02-1",
- NO_PROTECTION, NO_PROTECTION, NO_PROTECTION, NO_PROTECTION,
- NO_PROTECTION, NO_PROTECTION, NO_PROTECTION, NO_PROTECTION,
- NO_PROTECTION, NO_PROTECTION, NO_PROTECTION, NO_PROTECTION,
- NO_PROTECTION, NO_PROTECTION, NO_PROTECTION, NO_PROTECTION),
- APUSYS_APC_AO_ATTR("slv02-2",
- NO_PROTECTION, NO_PROTECTION, NO_PROTECTION, NO_PROTECTION,
- NO_PROTECTION, NO_PROTECTION, NO_PROTECTION, NO_PROTECTION,
- NO_PROTECTION, NO_PROTECTION, NO_PROTECTION, NO_PROTECTION,
- NO_PROTECTION, NO_PROTECTION, NO_PROTECTION, NO_PROTECTION),
- APUSYS_APC_AO_ATTR("slv02-3",
- NO_PROTECTION, NO_PROTECTION, NO_PROTECTION, NO_PROTECTION,
- NO_PROTECTION, NO_PROTECTION, NO_PROTECTION, NO_PROTECTION,
- NO_PROTECTION, NO_PROTECTION, NO_PROTECTION, NO_PROTECTION,
- NO_PROTECTION, NO_PROTECTION, NO_PROTECTION, NO_PROTECTION),
- APUSYS_APC_AO_ATTR("slv02-4",
- NO_PROTECTION, NO_PROTECTION, NO_PROTECTION, NO_PROTECTION,
- NO_PROTECTION, NO_PROTECTION, NO_PROTECTION, NO_PROTECTION,
- NO_PROTECTION, NO_PROTECTION, NO_PROTECTION, NO_PROTECTION,
- NO_PROTECTION, NO_PROTECTION, NO_PROTECTION, NO_PROTECTION),
- };
- static int32_t set_slave_noc_dapc(uint32_t slave,
- enum APUSYS_APC_DOMAIN_ID domain_id,
- enum APUSYS_APC_PERM_TYPE perm)
- {
- uint32_t apc_register_index;
- uint32_t apc_set_index;
- uintptr_t base;
- uint32_t clr_bit;
- uint32_t set_bit;
- int32_t ret;
- if (perm >= PERM_NUM) {
- ERROR("[NOC_DAPC] perm type:0x%x is not supported!\n", perm);
- ret = APUSYS_APC_ERR_PERMISSION_NOT_SUPPORTED;
- goto exit;
- }
- apc_register_index = slave / APUSYS_NOC_DAPC_AO_SLAVE_NUM_IN_1_DOM;
- apc_set_index = slave % APUSYS_NOC_DAPC_AO_SLAVE_NUM_IN_1_DOM;
- clr_bit = 0xFFFFFFFF ^ (0x3U << (apc_set_index * 2));
- set_bit = perm << (apc_set_index * 2);
- if ((slave < APUSYS_NOC_DAPC_AO_SLAVE_NUM) &&
- (domain_id < APUSYS_NOC_DAPC_AO_DOM_NUM)) {
- base = APUSYS_NOC_DAPC_AO_BASE +
- (domain_id * 0x40) + (apc_register_index * 4);
- apuapc_writel(apuapc_readl(base) & clr_bit, base);
- apuapc_writel(apuapc_readl(base) | set_bit, base);
- ret = APUSYS_APC_OK;
- } else {
- ERROR("[NOC_DAPC] %s: %s, %s:0x%x, %s:0x%x\n",
- __func__, "out of boundary",
- "slave", slave,
- "domain_id", domain_id);
- ret = APUSYS_APC_ERR_OUT_OF_BOUNDARY;
- }
- exit:
- return ret;
- }
- static void dump_apusys_noc_dapc(void)
- {
- uint32_t reg_num;
- uint32_t d, i;
- reg_num = APUSYS_NOC_DAPC_AO_SLAVE_NUM /
- APUSYS_NOC_DAPC_AO_SLAVE_NUM_IN_1_DOM;
- for (d = 0U; d < APUSYS_NOC_DAPC_AO_DOM_NUM; d++) {
- for (i = 0U; i <= reg_num; i++) {
- INFO("[NOCDAPC] D%d_APC_%d: 0x%x\n", d, i,
- apuapc_readl(APUSYS_NOC_DAPC_AO_BASE +
- (d * 0x40) + (i * 4)));
- }
- }
- INFO("[NOCDAPC] APC_CON: 0x%x\n", apuapc_readl(APUSYS_NOC_DAPC_CON));
- }
- static const struct APC_DOM_16 APUSYS_AO_Devices[] = {
- /* 0 */
- APUSYS_APC_AO_ATTR("apusys_ao-0",
- NO_PROTECTION, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN),
- APUSYS_APC_AO_ATTR("apusys_ao-1",
- NO_PROTECTION, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN),
- APUSYS_APC_AO_ATTR("apusys_ao-2",
- SEC_RW_ONLY, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN),
- APUSYS_APC_AO_ATTR("apusys_ao-3",
- NO_PROTECTION, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN),
- APUSYS_APC_AO_ATTR("apusys_ao-4",
- SEC_RW_ONLY, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN),
- APUSYS_APC_AO_ATTR("apusys_ao-5",
- SEC_RW_ONLY, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN),
- APUSYS_APC_AO_ATTR("md32_apb_s-0",
- NO_PROTECTION, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN),
- APUSYS_APC_AO_ATTR("md32_apb_s-1",
- NO_PROTECTION, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN),
- APUSYS_APC_AO_ATTR("md32_apb_s-2",
- NO_PROTECTION, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN),
- APUSYS_APC_AO_ATTR("md32_debug_apb",
- NO_PROTECTION, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN),
- /* 10 */
- APUSYS_APC_AO_ATTR("apu_conn_config",
- NO_PROTECTION, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN),
- APUSYS_APC_AO_ATTR("apu_sctrl_reviser",
- SEC_RW_ONLY, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN),
- APUSYS_APC_AO_ATTR("apu_sema_stimer",
- NO_PROTECTION, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN),
- APUSYS_APC_AO_ATTR("apu_emi_config",
- NO_PROTECTION, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN),
- APUSYS_APC_AO_ATTR("apu_adl",
- NO_PROTECTION, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN),
- APUSYS_APC_AO_ATTR("apu_edma_lite0",
- NO_PROTECTION, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN),
- APUSYS_APC_AO_ATTR("apu_edma_lite1",
- NO_PROTECTION, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN),
- APUSYS_APC_AO_ATTR("apu_edma0",
- NO_PROTECTION, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN),
- APUSYS_APC_AO_ATTR("apu_edma0",
- NO_PROTECTION, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN),
- APUSYS_APC_AO_ATTR("apu_dapc_ao",
- NO_PROTECTION, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN),
- /* 20 */
- APUSYS_APC_AO_ATTR("apu_dapc",
- NO_PROTECTION, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN),
- APUSYS_APC_AO_ATTR("infra_bcrm",
- NO_PROTECTION, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN),
- APUSYS_APC_AO_ATTR("apb_dbg_ctl",
- NO_PROTECTION, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN),
- APUSYS_APC_AO_ATTR("noc_dapc",
- NO_PROTECTION, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN),
- APUSYS_APC_AO_ATTR("apu_noc_bcrm",
- NO_PROTECTION, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN),
- APUSYS_APC_AO_ATTR("apu_noc_config",
- NO_PROTECTION, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN),
- APUSYS_APC_AO_ATTR("vpu_core0_config-0",
- NO_PROTECTION, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN),
- APUSYS_APC_AO_ATTR("vpu_core0_config-1",
- NO_PROTECTION, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN),
- APUSYS_APC_AO_ATTR("vpu_core1_config-0",
- NO_PROTECTION, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN),
- APUSYS_APC_AO_ATTR("vpu_core1_config-1",
- NO_PROTECTION, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN),
- /* 30 */
- APUSYS_APC_AO_ATTR("mdla0_apb-0",
- NO_PROTECTION, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN),
- APUSYS_APC_AO_ATTR("mdla0_apb-1",
- NO_PROTECTION, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN),
- APUSYS_APC_AO_ATTR("mdla0_apb-2",
- NO_PROTECTION, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN),
- APUSYS_APC_AO_ATTR("mdla0_apb-3",
- NO_PROTECTION, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN),
- APUSYS_APC_AO_ATTR("apu_iommu0_r0",
- NO_PROTECTION, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN),
- APUSYS_APC_AO_ATTR("apu_iommu0_r1",
- SEC_RW_ONLY, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN),
- APUSYS_APC_AO_ATTR("apu_iommu0_r2",
- SEC_RW_ONLY, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN),
- APUSYS_APC_AO_ATTR("apu_iommu0_r3",
- SEC_RW_ONLY, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN),
- APUSYS_APC_AO_ATTR("apu_iommu0_r4",
- SEC_RW_ONLY, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN),
- APUSYS_APC_AO_ATTR("apu_rsi2_config",
- NO_PROTECTION, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN),
- /* 40 */
- APUSYS_APC_AO_ATTR("apu_ssc2_config",
- NO_PROTECTION, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN),
- APUSYS_APC_AO_ATTR("vp6_core0_debug_apb",
- NO_PROTECTION, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN),
- APUSYS_APC_AO_ATTR("vp6_core1_debug_apb",
- NO_PROTECTION, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN,
- FORBIDDEN, FORBIDDEN, FORBIDDEN, FORBIDDEN),
- };
- static int32_t set_slave_apc(uint32_t slave,
- enum APUSYS_APC_DOMAIN_ID domain_id,
- enum APUSYS_APC_PERM_TYPE perm)
- {
- uint32_t apc_register_index;
- uint32_t apc_set_index;
- uintptr_t base;
- uint32_t clr_bit;
- uint32_t set_bit;
- int32_t ret;
- if (perm >= PERM_NUM) {
- ERROR("[APUAPC] perm type:0x%x is not supported!\n", perm);
- ret = APUSYS_APC_ERR_PERMISSION_NOT_SUPPORTED;
- goto exit;
- }
- apc_register_index = slave / APUSYS_APC_SYS0_AO_SLAVE_NUM_IN_1_DOM;
- apc_set_index = slave % APUSYS_APC_SYS0_AO_SLAVE_NUM_IN_1_DOM;
- clr_bit = 0xFFFFFFFF ^ (0x3U << (apc_set_index * 2));
- set_bit = perm << (apc_set_index * 2);
- if ((slave < APUSYS_APC_SYS0_AO_SLAVE_NUM) &&
- (domain_id < APUSYS_APC_SYS0_AO_DOM_NUM)) {
- base = APUSYS_APC_AO_BASE +
- (domain_id * 0x40) + (apc_register_index * 4);
- apuapc_writel(apuapc_readl(base) & clr_bit, base);
- apuapc_writel(apuapc_readl(base) | set_bit, base);
- ret = APUSYS_APC_OK;
- } else {
- ERROR("[APUAPC] %s: %s, %s:0x%x, %s:0x%x\n",
- __func__, "out of boundary",
- "slave", slave,
- "domain_id", domain_id);
- ret = APUSYS_APC_ERR_OUT_OF_BOUNDARY;
- }
- exit:
- return ret;
- }
- static void dump_apusys_ao_apc(void)
- {
- uint32_t reg_num;
- uint32_t d, i;
- reg_num = APUSYS_APC_SYS0_AO_SLAVE_NUM /
- APUSYS_APC_SYS0_AO_SLAVE_NUM_IN_1_DOM;
- for (d = 0U; d < APUSYS_APC_SYS0_AO_DOM_NUM; d++) {
- for (i = 0U; i <= reg_num; i++) {
- INFO("[APUAPC] D%d_APC_%d: 0x%x\n", d, i,
- apuapc_readl(APUSYS_APC_AO_BASE +
- (d * 0x40) + (i * 4)));
- }
- }
- INFO("[APUAPC] APC_CON: 0x%x\n", apuapc_readl(APUSYS_APC_CON));
- }
- static int32_t set_apusys_noc_dapc(void)
- {
- int32_t ret = 0;
- uint32_t i;
- uint32_t index;
- for (i = 0U; i < ARRAY_SIZE(APUSYS_NOC_DAPC_AO); i++) {
- if (i < APUSYS_NOC_DAPC_GAP_BOUNDARY) {
- index = i;
- } else {
- index = i + APUSYS_NOC_DAPC_JUMP_GAP;
- }
- ret += set_slave_noc_dapc(index, DOMAIN_0,
- APUSYS_NOC_DAPC_AO[i].d0_permission);
- ret += set_slave_noc_dapc(index, DOMAIN_1,
- APUSYS_NOC_DAPC_AO[i].d1_permission);
- ret += set_slave_noc_dapc(index, DOMAIN_2,
- APUSYS_NOC_DAPC_AO[i].d2_permission);
- ret += set_slave_noc_dapc(index, DOMAIN_3,
- APUSYS_NOC_DAPC_AO[i].d3_permission);
- ret += set_slave_noc_dapc(index, DOMAIN_4,
- APUSYS_NOC_DAPC_AO[i].d4_permission);
- ret += set_slave_noc_dapc(index, DOMAIN_5,
- APUSYS_NOC_DAPC_AO[i].d5_permission);
- ret += set_slave_noc_dapc(index, DOMAIN_6,
- APUSYS_NOC_DAPC_AO[i].d6_permission);
- ret += set_slave_noc_dapc(index, DOMAIN_7,
- APUSYS_NOC_DAPC_AO[i].d7_permission);
- ret += set_slave_noc_dapc(index, DOMAIN_8,
- APUSYS_NOC_DAPC_AO[i].d8_permission);
- ret += set_slave_noc_dapc(index, DOMAIN_9,
- APUSYS_NOC_DAPC_AO[i].d9_permission);
- ret += set_slave_noc_dapc(index, DOMAIN_10,
- APUSYS_NOC_DAPC_AO[i].d10_permission);
- ret += set_slave_noc_dapc(index, DOMAIN_11,
- APUSYS_NOC_DAPC_AO[i].d11_permission);
- ret += set_slave_noc_dapc(index, DOMAIN_12,
- APUSYS_NOC_DAPC_AO[i].d12_permission);
- ret += set_slave_noc_dapc(index, DOMAIN_13,
- APUSYS_NOC_DAPC_AO[i].d13_permission);
- ret += set_slave_noc_dapc(index, DOMAIN_14,
- APUSYS_NOC_DAPC_AO[i].d14_permission);
- ret += set_slave_noc_dapc(index, DOMAIN_15,
- APUSYS_NOC_DAPC_AO[i].d15_permission);
- }
- return ret;
- }
- static int32_t set_apusys_ao_apc(void)
- {
- int32_t ret = 0;
- uint32_t i;
- for (i = 0U; i < ARRAY_SIZE(APUSYS_AO_Devices); i++) {
- ret += set_slave_apc(i, DOMAIN_0,
- APUSYS_AO_Devices[i].d0_permission);
- ret += set_slave_apc(i, DOMAIN_1,
- APUSYS_AO_Devices[i].d1_permission);
- ret += set_slave_apc(i, DOMAIN_2,
- APUSYS_AO_Devices[i].d2_permission);
- ret += set_slave_apc(i, DOMAIN_3,
- APUSYS_AO_Devices[i].d3_permission);
- ret += set_slave_apc(i, DOMAIN_4,
- APUSYS_AO_Devices[i].d4_permission);
- ret += set_slave_apc(i, DOMAIN_5,
- APUSYS_AO_Devices[i].d5_permission);
- ret += set_slave_apc(i, DOMAIN_6,
- APUSYS_AO_Devices[i].d6_permission);
- ret += set_slave_apc(i, DOMAIN_7,
- APUSYS_AO_Devices[i].d7_permission);
- ret += set_slave_apc(i, DOMAIN_8,
- APUSYS_AO_Devices[i].d8_permission);
- ret += set_slave_apc(i, DOMAIN_9,
- APUSYS_AO_Devices[i].d9_permission);
- ret += set_slave_apc(i, DOMAIN_10,
- APUSYS_AO_Devices[i].d10_permission);
- ret += set_slave_apc(i, DOMAIN_11,
- APUSYS_AO_Devices[i].d11_permission);
- ret += set_slave_apc(i, DOMAIN_12,
- APUSYS_AO_Devices[i].d12_permission);
- ret += set_slave_apc(i, DOMAIN_13,
- APUSYS_AO_Devices[i].d13_permission);
- ret += set_slave_apc(i, DOMAIN_14,
- APUSYS_AO_Devices[i].d14_permission);
- ret += set_slave_apc(i, DOMAIN_15,
- APUSYS_AO_Devices[i].d15_permission);
- }
- return ret;
- }
- static void set_apusys_apc_lock(void)
- {
- uint32_t set_bit = 1U << APUSYS_APC_SYS0_LOCK_BIT_APU_SCTRL_REVISER;
- /* Lock apu_sctrl_reviser */
- set_bit = set_bit | (1U << APUSYS_APC_SYS0_LOCK_BIT_APUSYS_AO_5);
- apuapc_writel(set_bit, APUSYS_SYS0_APC_LOCK_0);
- }
- void set_apusys_apc(void)
- {
- int32_t ret = 0;
- /* Check violation status */
- INFO("[APUAPC] vio %d\n", apuapc_readl(APUSYS_APC_CON) & 0x80000000);
- /* Initial Permission */
- ret = set_apusys_ao_apc();
- INFO("[APUAPC] %s - %s!\n", "set_apusys_ao_apc",
- ret ? "FAILED" : "SUCCESS");
- /* Lock */
- set_apusys_apc_lock();
- /* Initial NoC Permission */
- ret = set_apusys_noc_dapc();
- INFO("[APUAPC] %s - %s!\n", "set_apusys_noc_dapc",
- ret ? "FAILED" : "SUCCESS");
- /* Dump Permission */
- dump_apusys_ao_apc();
- dump_apusys_noc_dapc();
- INFO("[APUAPC] %s done\n", __func__);
- }
|