1 /* 2 * Copyright (c) 2024, MediaTek Inc. All rights reserved. 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 7 #ifndef APUSYS_RV_PWR_CTL_H 8 #define APUSYS_RV_PWR_CTL_H 9 10 #include <platform_def.h> 11 12 #include "apusys_rv.h" 13 14 #define SUPPORT_APU_CLEAR_MBOX_DUMMY (1) 15 16 enum apu_hw_sem_sys_id { 17 APU_HW_SEM_SYS_APU = 0UL, /* mbox0 */ 18 APU_HW_SEM_SYS_GZ = 1UL, /* mbox1 */ 19 APU_HW_SEM_SYS_SCP = 3UL, /* mbox3 */ 20 APU_HW_SEM_SYS_APMCU = 11UL, /* mbox11 */ 21 }; 22 23 int apusys_rv_pwr_ctrl(enum APU_PWR_OP op); 24 int rv_iommu_hw_sem_unlock(void); 25 int rv_iommu_hw_sem_trylock(void); 26 int apu_hw_sema_ctl(uint32_t sem_addr, uint8_t usr_bit, uint8_t ctl, uint32_t timeout, 27 uint8_t bypass); 28 29 #define HW_SEM_TIMEOUT (300) /* 300 us */ 30 #define HW_SEM_NO_WAIT (0) /* no wait */ 31 32 /* APU MBOX */ 33 #define MBOX_WKUP_CFG (0x80) 34 #define MBOX_WKUP_MASK (0x84) 35 #define MBOX_FUNC_CFG (0xb0) 36 #define MBOX_DOMAIN_CFG (0xe0) 37 38 #define MBOX_CTRL_LOCK BIT(0) 39 #define MBOX_NO_MPU_SHIFT (16) 40 #define MBOX_RC_SHIFT (24) 41 42 #define MBOX_RX_NS_SHIFT (16) 43 #define MBOX_RX_DOMAIN_SHIFT (17) 44 #define MBOX_TX_NS_SHIFT (24) 45 #define MBOX_TX_DOMAIN_SHIFT (25) 46 47 #define APU_REG_AO_GLUE_CONFG (APU_AO_CTRL + 0x20) 48 49 #define ENABLE_INFRA_WA 50 51 enum apu_infra_bit_id { 52 APU_INFRA_SYS_APMCU = 1UL, 53 APU_INFRA_SYS_GZ = 2UL, 54 APU_INFRA_SYS_SCP = 3UL, 55 }; 56 57 #define APU_MBOX(i) (APU_MBOX0 + 0x10000 * i) 58 59 #define APU_MBOX_FUNC_CFG(i) (APU_MBOX(i) + MBOX_FUNC_CFG) 60 #define APU_MBOX_DOMAIN_CFG(i) (APU_MBOX(i) + MBOX_DOMAIN_CFG) 61 #define APU_MBOX_WKUP_CFG(i) (APU_MBOX(i) + MBOX_WKUP_CFG) 62 63 enum apu_hw_sem_op { 64 HW_SEM_PUT = 0, 65 HW_SEM_GET = 1, 66 }; 67 68 #define HW_SEM_PUT_BIT_SHIFT (16) 69 70 /* bypass mbox register Dump for secure master */ 71 #define APU_MBOX_DBG_EN (0x190f2380) 72 73 /* apu_mbox register definition for mbox addr change*/ 74 #define APU_MBOX_SEMA0_CTRL (0x090) 75 #define APU_MBOX_SEMA0_RST (0x094) 76 #define APU_MBOX_SEMA0_STA (0x098) 77 #define APU_MBOX_SEMA1_CTRL (0x0A0) 78 #define APU_MBOX_SEMA1_RST (0x0A4) 79 #define APU_MBOX_SEMA1_STA (0x0A8) 80 #define APU_MBOX_DUMMY (0x040) 81 #define APU_MBOX_OFFSET(i) (0x10000 * i) 82 83 /* apu infra workaround */ 84 #define APU_INFRA_DISABLE (APU_INFRA_BASE + 0xC18) 85 #define APU_INFRA_ENABLE (APU_INFRA_BASE + 0xC14) 86 #define APU_INFRA_STATUS (APU_INFRA_BASE + 0xC10) 87 #define APU_INFRA_STATUS_MASK (0x1fffe) 88 #define APU_INFRA_HW_SEM (APUSYS_CE_BASE + 0xE00) 89 #define APU_RPC_STATUS (0x190f0044) 90 91 #define APU_INFRA_BIT_OFF (16) 92 #define APU_RPC_STATUS_BIT BIT(0) 93 94 #endif /* APUSYS_RV_PWR_CTL_H */ 95