Commit 258f6a2d authored by Madhukar Pappireddy's avatar Madhukar Pappireddy Committed by TrustedFirmware Code Review
Browse files

Merge changes I4bd4612a,Id13a06d4,I0ea7f610,Ie6a7063b into integration

* changes:
  mediatek: mt8192: Add Vcore DVFS driver
  mediatek: mt8192: Add SPM suspend driver
  mediatek: mt8192: supports mcusys off when system suspend
  mediatek: mt8192: Add lpm driver
parents c0f0ab53 f3febcca
/*
* Copyright (c) 2020, MediaTek Inc. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef MT_SPM_CONSERVATION_H
#define MT_SPM_CONSERVATION_H
#include <mt_spm_internal.h>
extern int spm_conservation(int state_id, unsigned int ext_opand,
struct spm_lp_scen *spm_lp,
unsigned int resource_req);
extern void spm_conservation_finish(int state_id, unsigned int ext_opand,
struct spm_lp_scen *spm_lp,
struct wake_status **status);
extern int spm_conservation_get_result(struct wake_status **res);
extern void spm_conservation_pwrctrl_init(struct pwr_ctrl *pwrctrl);
#endif /* MT_SPM_CONSERVATION_H */
/*
* Copyright (c) 2020, MediaTek Inc. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef MT_SPM_CONSTRAINT_H
#define MT_SPM_CONSTRAINT_H
#include <mt_lp_rm.h>
#define MT_RM_CONSTRAINT_ALLOW_CPU_BUCK_OFF (1U << 0)
#define MT_RM_CONSTRAINT_ALLOW_DRAM_S0 (1U << 1)
#define MT_RM_CONSTRAINT_ALLOW_DRAM_S1 (1U << 2)
#define MT_RM_CONSTRAINT_ALLOW_VCORE_LP (1U << 3)
#define MT_RM_CONSTRAINT_ALLOW_INFRA_PDN (1U << 4)
#define MT_RM_CONSTRAINT_ALLOW_BUS26M_OFF (1U << 5)
#define MT_RM_CONSTRAINT_ALLOW_AP_SUSPEND (1U << 6)
#define MT_RM_CONSTRAINT_ALLOW_BBLPM (1U << 7)
#define MT_RM_CONSTRAINT_ALLOW_XO_UFS (1U << 8)
#define MT_RM_CONSTRAINT_ALLOW_GPS_STATE (1U << 9)
#define MT_RM_CONSTRAINT_ALLOW_LVTS_STATE (1U << 10)
#define MT_SPM_RC_INVALID 0x0
#define MT_SPM_RC_VALID_SW (1U << 0)
#define MT_SPM_RC_VALID_FW (1U << 1)
#define MT_SPM_RC_VALID_RESIDNECY (1U << 2)
#define MT_SPM_RC_VALID_COND_CHECK (1U << 3)
#define MT_SPM_RC_VALID_COND_LATCH (1U << 4)
#define MT_SPM_RC_VALID_UFS_H8 (1U << 5)
#define MT_SPM_RC_VALID_FLIGHTMODE (1U << 6)
#define MT_SPM_RC_VALID_XSOC_BBLPM (1U << 7)
#define MT_SPM_RC_VALID_TRACE_EVENT (1U << 8)
#define MT_SPM_RC_VALID (MT_SPM_RC_VALID_SW)
#define IS_MT_RM_RC_READY(status) \
((status & MT_SPM_RC_VALID) == MT_SPM_RC_VALID)
#define MT_SPM_RC_BBLPM_MODE \
(MT_SPM_RC_VALID_UFS_H8 | \
MT_SPM_RC_VALID_FLIGHTMODE | \
MT_SPM_RC_VALID_XSOC_BBLPM)
#define IS_MT_SPM_RC_BBLPM_MODE(st) \
((st & (MT_SPM_RC_BBLPM_MODE)) == MT_SPM_RC_BBLPM_MODE)
struct constraint_status {
uint16_t id;
uint16_t valid;
uint32_t cond_block;
uint32_t enter_cnt;
struct mt_spm_cond_tables *cond_res;
};
enum MT_SPM_RM_RC_TYPE {
MT_RM_CONSTRAINT_ID_BUS26M,
MT_RM_CONSTRAINT_ID_SYSPLL,
MT_RM_CONSTRAINT_ID_DRAM,
MT_RM_CONSTRAINT_ID_CPU_BUCK_LDO,
MT_RM_CONSTRAINT_ID_ALL,
};
#endif /* MT_SPM_CONSTRAINT_H */
/*
* Copyright (c) 2020, MediaTek Inc. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <common/debug.h>
#include <lib/mmio.h>
#include <mt_spm.h>
#include <mt_spm_conservation.h>
#include <mt_spm_idle.h>
#include <mt_spm_internal.h>
#include <mt_spm_reg.h>
#include <mt_spm_resource_req.h>
#include <plat_pm.h>
#define __WAKE_SRC_FOR_IDLE_COMMON__ \
(R12_PCM_TIMER | \
R12_KP_IRQ_B | \
R12_APWDT_EVENT_B | \
R12_APXGPT1_EVENT_B | \
R12_CONN2AP_SPM_WAKEUP_B | \
R12_EINT_EVENT_B | \
R12_CONN_WDT_IRQ_B | \
R12_CCIF0_EVENT_B | \
R12_SSPM2SPM_WAKEUP_B | \
R12_SCP2SPM_WAKEUP_B | \
R12_ADSP2SPM_WAKEUP_B | \
R12_USBX_CDSC_B | \
R12_USBX_POWERDWN_B | \
R12_SYS_TIMER_EVENT_B | \
R12_EINT_EVENT_SECURE_B | \
R12_CCIF1_EVENT_B | \
R12_AFE_IRQ_MCU_B | \
R12_SYS_CIRQ_IRQ_B | \
R12_MD2AP_PEER_EVENT_B | \
R12_MD1_WDT_B | \
R12_CLDMA_EVENT_B | \
R12_REG_CPU_WAKEUP | \
R12_APUSYS_WAKE_HOST_B | \
R12_PCIE_BRIDGE_IRQ | \
R12_PCIE_IRQ)
#if defined(CFG_MICROTRUST_TEE_SUPPORT)
#define WAKE_SRC_FOR_IDLE (__WAKE_SRC_FOR_IDLE_COMMON__)
#else
#define WAKE_SRC_FOR_IDLE \
(__WAKE_SRC_FOR_IDLE_COMMON__ | \
R12_SEJ_EVENT_B)
#endif
static struct pwr_ctrl idle_spm_pwr = {
.timer_val = 0x28000,
.wake_src = WAKE_SRC_FOR_IDLE,
/* Auto-gen Start */
/* SPM_AP_STANDBY_CON */
.reg_wfi_op = 0,
.reg_wfi_type = 0,
.reg_mp0_cputop_idle_mask = 0,
.reg_mp1_cputop_idle_mask = 0,
.reg_mcusys_idle_mask = 0,
.reg_md_apsrc_1_sel = 0,
.reg_md_apsrc_0_sel = 0,
.reg_conn_apsrc_sel = 0,
/* SPM_SRC6_MASK */
.reg_dpmaif_srcclkena_mask_b = 1,
.reg_dpmaif_infra_req_mask_b = 1,
.reg_dpmaif_apsrc_req_mask_b = 1,
.reg_dpmaif_vrf18_req_mask_b = 1,
.reg_dpmaif_ddr_en_mask_b = 1,
/* SPM_SRC_REQ */
.reg_spm_apsrc_req = 1,
.reg_spm_f26m_req = 1,
.reg_spm_infra_req = 1,
.reg_spm_vrf18_req = 1,
.reg_spm_ddr_en_req = 1,
.reg_spm_dvfs_req = 0,
.reg_spm_sw_mailbox_req = 0,
.reg_spm_sspm_mailbox_req = 0,
.reg_spm_adsp_mailbox_req = 0,
.reg_spm_scp_mailbox_req = 0,
/* SPM_SRC_MASK */
.reg_md_srcclkena_0_mask_b = 1,
.reg_md_srcclkena2infra_req_0_mask_b = 0,
.reg_md_apsrc2infra_req_0_mask_b = 1,
.reg_md_apsrc_req_0_mask_b = 1,
.reg_md_vrf18_req_0_mask_b = 1,
.reg_md_ddr_en_0_mask_b = 1,
.reg_md_srcclkena_1_mask_b = 0,
.reg_md_srcclkena2infra_req_1_mask_b = 0,
.reg_md_apsrc2infra_req_1_mask_b = 0,
.reg_md_apsrc_req_1_mask_b = 0,
.reg_md_vrf18_req_1_mask_b = 0,
.reg_md_ddr_en_1_mask_b = 0,
.reg_conn_srcclkena_mask_b = 1,
.reg_conn_srcclkenb_mask_b = 0,
.reg_conn_infra_req_mask_b = 1,
.reg_conn_apsrc_req_mask_b = 1,
.reg_conn_vrf18_req_mask_b = 1,
.reg_conn_ddr_en_mask_b = 1,
.reg_conn_vfe28_mask_b = 0,
.reg_srcclkeni0_srcclkena_mask_b = 1,
.reg_srcclkeni0_infra_req_mask_b = 1,
.reg_srcclkeni1_srcclkena_mask_b = 0,
.reg_srcclkeni1_infra_req_mask_b = 0,
.reg_srcclkeni2_srcclkena_mask_b = 0,
.reg_srcclkeni2_infra_req_mask_b = 0,
.reg_infrasys_apsrc_req_mask_b = 0,
.reg_infrasys_ddr_en_mask_b = 1,
.reg_md32_srcclkena_mask_b = 1,
.reg_md32_infra_req_mask_b = 1,
.reg_md32_apsrc_req_mask_b = 1,
.reg_md32_vrf18_req_mask_b = 1,
.reg_md32_ddr_en_mask_b = 1,
/* SPM_SRC2_MASK */
.reg_scp_srcclkena_mask_b = 1,
.reg_scp_infra_req_mask_b = 1,
.reg_scp_apsrc_req_mask_b = 1,
.reg_scp_vrf18_req_mask_b = 1,
.reg_scp_ddr_en_mask_b = 1,
.reg_audio_dsp_srcclkena_mask_b = 1,
.reg_audio_dsp_infra_req_mask_b = 1,
.reg_audio_dsp_apsrc_req_mask_b = 1,
.reg_audio_dsp_vrf18_req_mask_b = 1,
.reg_audio_dsp_ddr_en_mask_b = 1,
.reg_ufs_srcclkena_mask_b = 1,
.reg_ufs_infra_req_mask_b = 1,
.reg_ufs_apsrc_req_mask_b = 1,
.reg_ufs_vrf18_req_mask_b = 1,
.reg_ufs_ddr_en_mask_b = 1,
.reg_disp0_apsrc_req_mask_b = 1,
.reg_disp0_ddr_en_mask_b = 1,
.reg_disp1_apsrc_req_mask_b = 1,
.reg_disp1_ddr_en_mask_b = 1,
.reg_gce_infra_req_mask_b = 1,
.reg_gce_apsrc_req_mask_b = 1,
.reg_gce_vrf18_req_mask_b = 1,
.reg_gce_ddr_en_mask_b = 1,
.reg_apu_srcclkena_mask_b = 1,
.reg_apu_infra_req_mask_b = 1,
.reg_apu_apsrc_req_mask_b = 1,
.reg_apu_vrf18_req_mask_b = 1,
.reg_apu_ddr_en_mask_b = 1,
.reg_cg_check_srcclkena_mask_b = 0,
.reg_cg_check_apsrc_req_mask_b = 0,
.reg_cg_check_vrf18_req_mask_b = 0,
.reg_cg_check_ddr_en_mask_b = 0,
/* SPM_SRC3_MASK */
.reg_dvfsrc_event_trigger_mask_b = 1,
.reg_sw2spm_int0_mask_b = 0,
.reg_sw2spm_int1_mask_b = 0,
.reg_sw2spm_int2_mask_b = 0,
.reg_sw2spm_int3_mask_b = 0,
.reg_sc_adsp2spm_wakeup_mask_b = 0,
.reg_sc_sspm2spm_wakeup_mask_b = 0,
.reg_sc_scp2spm_wakeup_mask_b = 0,
.reg_csyspwrreq_mask = 1,
.reg_spm_srcclkena_reserved_mask_b = 0,
.reg_spm_infra_req_reserved_mask_b = 0,
.reg_spm_apsrc_req_reserved_mask_b = 0,
.reg_spm_vrf18_req_reserved_mask_b = 0,
.reg_spm_ddr_en_reserved_mask_b = 0,
.reg_mcupm_srcclkena_mask_b = 1,
.reg_mcupm_infra_req_mask_b = 1,
.reg_mcupm_apsrc_req_mask_b = 1,
.reg_mcupm_vrf18_req_mask_b = 1,
.reg_mcupm_ddr_en_mask_b = 1,
.reg_msdc0_srcclkena_mask_b = 1,
.reg_msdc0_infra_req_mask_b = 1,
.reg_msdc0_apsrc_req_mask_b = 1,
.reg_msdc0_vrf18_req_mask_b = 1,
.reg_msdc0_ddr_en_mask_b = 1,
.reg_msdc1_srcclkena_mask_b = 1,
.reg_msdc1_infra_req_mask_b = 1,
.reg_msdc1_apsrc_req_mask_b = 1,
.reg_msdc1_vrf18_req_mask_b = 1,
.reg_msdc1_ddr_en_mask_b = 1,
/* SPM_SRC4_MASK */
.ccif_event_mask_b = 0xFFF,
.reg_bak_psri_srcclkena_mask_b = 0,
.reg_bak_psri_infra_req_mask_b = 0,
.reg_bak_psri_apsrc_req_mask_b = 0,
.reg_bak_psri_vrf18_req_mask_b = 0,
.reg_bak_psri_ddr_en_mask_b = 0,
.reg_dramc0_md32_infra_req_mask_b = 1,
.reg_dramc0_md32_vrf18_req_mask_b = 0,
.reg_dramc1_md32_infra_req_mask_b = 1,
.reg_dramc1_md32_vrf18_req_mask_b = 0,
.reg_conn_srcclkenb2pwrap_mask_b = 0,
.reg_dramc0_md32_wakeup_mask = 1,
.reg_dramc1_md32_wakeup_mask = 1,
/* SPM_SRC5_MASK */
.reg_mcusys_merge_apsrc_req_mask_b = 0x11,
.reg_mcusys_merge_ddr_en_mask_b = 0x11,
.reg_msdc2_srcclkena_mask_b = 1,
.reg_msdc2_infra_req_mask_b = 1,
.reg_msdc2_apsrc_req_mask_b = 1,
.reg_msdc2_vrf18_req_mask_b = 1,
.reg_msdc2_ddr_en_mask_b = 1,
.reg_pcie_srcclkena_mask_b = 1,
.reg_pcie_infra_req_mask_b = 1,
.reg_pcie_apsrc_req_mask_b = 1,
.reg_pcie_vrf18_req_mask_b = 1,
.reg_pcie_ddr_en_mask_b = 1,
/* SPM_WAKEUP_EVENT_MASK */
.reg_wakeup_event_mask = 0x01282202,
/* SPM_WAKEUP_EVENT_EXT_MASK */
.reg_ext_wakeup_event_mask = 0xFFFFFFFF,
/* Auto-gen End */
};
struct spm_lp_scen idle_spm_lp = {
.pwrctrl = &idle_spm_pwr,
};
int mt_spm_idle_generic_enter(int state_id, unsigned int ext_opand,
spm_idle_conduct fn)
{
unsigned int src_req = 0;
if (fn != NULL) {
fn(&idle_spm_lp, &src_req);
}
return spm_conservation(state_id, ext_opand, &idle_spm_lp, src_req);
}
void mt_spm_idle_generic_resume(int state_id, unsigned int ext_opand,
struct wake_status **status)
{
spm_conservation_finish(state_id, ext_opand, &idle_spm_lp, status);
}
void mt_spm_idle_generic_init(void)
{
spm_conservation_pwrctrl_init(idle_spm_lp.pwrctrl);
}
/*
* Copyright (c) 2020, MediaTek Inc. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef MT_SPM_IDLE_H
#define MT_SPM_IDLE_H
typedef void (*spm_idle_conduct)(struct spm_lp_scen *spm_lp,
unsigned int *resource_req);
int mt_spm_idle_generic_enter(int state_id, unsigned int ext_opand,
spm_idle_conduct fn);
void mt_spm_idle_generic_resume(int state_id, unsigned int ext_opand,
struct wake_status **status);
void mt_spm_idle_generic_init(void);
#endif /* MT_SPM_IDLE_H */
This diff is collapsed.
This diff is collapsed.
/*
* Copyright (c) 2020, MediaTek Inc. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <string.h>
#include <common/debug.h>
#include <lib/mmio.h>
#include <mt_spm.h>
#include <mt_spm_internal.h>
#include <mt_spm_pmic_wrap.h>
#include <mt_spm_reg.h>
#include <plat_pm.h>
#include <platform_def.h>
/* PMIC_WRAP MT6359 */
#define VCORE_BASE_UV 40000
#define VOLT_TO_PMIC_VAL(volt) (((volt) - VCORE_BASE_UV + 625 - 1) / 625)
#define PMIC_VAL_TO_VOLT(pmic) (((pmic) * 625) + VCORE_BASE_UV)
#define NR_PMIC_WRAP_CMD (NR_IDX_ALL)
#define SPM_DATA_SHIFT 16
#define BUCK_VGPU11_ELR0 0x15B4
#define TOP_SPI_CON0 0x0456
#define BUCK_TOP_CON1 0x1443
#define TOP_CON 0x0013
#define TOP_DIG_WPK 0x03a9
#define TOP_CON_LOCK 0x03a8
#define TOP_CLK_CON0 0x0134
struct pmic_wrap_cmd {
unsigned long cmd_addr;
unsigned long cmd_wdata;
};
struct pmic_wrap_setting {
enum pmic_wrap_phase_id phase;
struct pmic_wrap_cmd addr[NR_PMIC_WRAP_CMD];
struct {
struct {
unsigned long cmd_addr;
unsigned long cmd_wdata;
} _[NR_PMIC_WRAP_CMD];
const int nr_idx;
} set[NR_PMIC_WRAP_PHASE];
};
static struct pmic_wrap_setting pw = {
.phase = NR_PMIC_WRAP_PHASE, /* invalid setting for init */
.addr = { {0UL, 0UL} },
.set[PMIC_WRAP_PHASE_ALLINONE] = {
._[CMD_0] = {BUCK_VGPU11_ELR0, VOLT_TO_PMIC_VAL(72500),},
._[CMD_1] = {BUCK_VGPU11_ELR0, VOLT_TO_PMIC_VAL(65000),},
._[CMD_2] = {BUCK_VGPU11_ELR0, VOLT_TO_PMIC_VAL(60000),},
._[CMD_3] = {BUCK_VGPU11_ELR0, VOLT_TO_PMIC_VAL(57500),},
._[CMD_4] = {TOP_SPI_CON0, 0x1,},
._[CMD_5] = {TOP_SPI_CON0, 0x0,},
._[CMD_6] = {BUCK_TOP_CON1, 0x0,},
._[CMD_7] = {BUCK_TOP_CON1, 0xf,},
._[CMD_8] = {TOP_CON, 0x3,},
._[CMD_9] = {TOP_CON, 0x0,},
._[CMD_10] = {TOP_DIG_WPK, 0x63,},
._[CMD_11] = {TOP_CON_LOCK, 0x15,},
._[CMD_12] = {TOP_DIG_WPK, 0x0,},
._[CMD_13] = {TOP_CON_LOCK, 0x0,},
._[CMD_14] = {TOP_CLK_CON0, 0x40,},
._[CMD_15] = {TOP_CLK_CON0, 0x0,},
.nr_idx = NR_IDX_ALL,
},
};
void _mt_spm_pmic_table_init(void)
{
struct pmic_wrap_cmd pwrap_cmd_default[NR_PMIC_WRAP_CMD] = {
{(uint32_t)SPM_DVFS_CMD0, (uint32_t)SPM_DVFS_CMD0,},
{(uint32_t)SPM_DVFS_CMD1, (uint32_t)SPM_DVFS_CMD1,},
{(uint32_t)SPM_DVFS_CMD2, (uint32_t)SPM_DVFS_CMD2,},
{(uint32_t)SPM_DVFS_CMD3, (uint32_t)SPM_DVFS_CMD3,},
{(uint32_t)SPM_DVFS_CMD4, (uint32_t)SPM_DVFS_CMD4,},
{(uint32_t)SPM_DVFS_CMD5, (uint32_t)SPM_DVFS_CMD5,},
{(uint32_t)SPM_DVFS_CMD6, (uint32_t)SPM_DVFS_CMD6,},
{(uint32_t)SPM_DVFS_CMD7, (uint32_t)SPM_DVFS_CMD7,},
{(uint32_t)SPM_DVFS_CMD8, (uint32_t)SPM_DVFS_CMD8,},
{(uint32_t)SPM_DVFS_CMD9, (uint32_t)SPM_DVFS_CMD9,},
{(uint32_t)SPM_DVFS_CMD10, (uint32_t)SPM_DVFS_CMD10,},
{(uint32_t)SPM_DVFS_CMD11, (uint32_t)SPM_DVFS_CMD11,},
{(uint32_t)SPM_DVFS_CMD12, (uint32_t)SPM_DVFS_CMD12,},
{(uint32_t)SPM_DVFS_CMD13, (uint32_t)SPM_DVFS_CMD13,},
{(uint32_t)SPM_DVFS_CMD14, (uint32_t)SPM_DVFS_CMD14,},
{(uint32_t)SPM_DVFS_CMD15, (uint32_t)SPM_DVFS_CMD15,},
};
memcpy(pw.addr, pwrap_cmd_default, sizeof(pwrap_cmd_default));
}
void mt_spm_pmic_wrap_set_phase(enum pmic_wrap_phase_id phase)
{
uint32_t idx, addr, data;
if (phase >= NR_PMIC_WRAP_PHASE) {
return;
}
if (pw.phase == phase) {
return;
}
if (pw.addr[0].cmd_addr == 0UL) {
_mt_spm_pmic_table_init();
}
pw.phase = phase;
mmio_write_32(POWERON_CONFIG_EN, SPM_REGWR_CFG_KEY | BCLK_CG_EN_LSB);
for (idx = 0U; idx < pw.set[phase].nr_idx; idx++) {
addr = pw.set[phase]._[idx].cmd_addr << SPM_DATA_SHIFT;
data = pw.set[phase]._[idx].cmd_wdata;
mmio_write_32(pw.addr[idx].cmd_addr, addr | data);
}
}
void mt_spm_pmic_wrap_set_cmd(enum pmic_wrap_phase_id phase, uint32_t idx,
uint32_t cmd_wdata)
{
uint32_t addr;
if (phase >= NR_PMIC_WRAP_PHASE) {
return;
}
if (idx >= pw.set[phase].nr_idx) {
return;
}
pw.set[phase]._[idx].cmd_wdata = cmd_wdata;
mmio_write_32(POWERON_CONFIG_EN, SPM_REGWR_CFG_KEY | BCLK_CG_EN_LSB);
if (pw.phase == phase) {
addr = pw.set[phase]._[idx].cmd_addr << SPM_DATA_SHIFT;
mmio_write_32(pw.addr[idx].cmd_addr, addr | cmd_wdata);
}
}
uint64_t mt_spm_pmic_wrap_get_cmd(enum pmic_wrap_phase_id phase, uint32_t idx)
{
if (phase >= NR_PMIC_WRAP_PHASE) {
return 0UL;
}
if (idx >= pw.set[phase].nr_idx) {
return 0UL;
}
return pw.set[phase]._[idx].cmd_wdata;
}
/*
* Copyright (c) 2020, MediaTek Inc. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
/****************************************************************
* Auto generated by DE, please DO NOT modify this file directly.
*****************************************************************/
#ifndef MT_SPM_PMIC_WRAP_H
#define MT_SPM_PMIC_WRAP_H
enum pmic_wrap_phase_id {
PMIC_WRAP_PHASE_ALLINONE,
NR_PMIC_WRAP_PHASE,
};
/* IDX mapping, PMIC_WRAP_PHASE_ALLINONE */
enum {
CMD_0, /* 0x0 */
CMD_1, /* 0x1 */
CMD_2, /* 0x2 */
CMD_3, /* 0x3 */
CMD_4, /* 0x4 */
CMD_5, /* 0x5 */
CMD_6, /* 0x6 */
CMD_7, /* 0x7 */
CMD_8, /* 0x8 */
CMD_9, /* 0x9 */
CMD_10, /* 0xA */
CMD_11, /* 0xB */
CMD_12, /* 0xC */
CMD_13, /* 0xD */
CMD_14, /* 0xE */
CMD_15, /* 0xF */
NR_IDX_ALL,
};
/* APIs */
extern void mt_spm_pmic_wrap_set_phase(enum pmic_wrap_phase_id phase);
extern void mt_spm_pmic_wrap_set_cmd(enum pmic_wrap_phase_id phase,
uint32_t idx, uint32_t cmd_wdata);
extern uint64_t mt_spm_pmic_wrap_get_cmd(enum pmic_wrap_phase_id phase,
uint32_t idx);
#endif /* MT_SPM_PMIC_WRAP_H */
This diff is collapsed.
/*
* Copyright (c) 2020, MediaTek Inc. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef MT_SPM_RESOURCE_REQ_H
#define MT_SPM_RESOURCE_REQ_H
/* SPM resource request internal bit */
#define MT_SPM_BIT_XO_FPM 0
#define MT_SPM_BIT_26M 1
#define MT_SPM_BIT_INFRA 2
#define MT_SPM_BIT_SYSPLL 3
#define MT_SPM_BIT_DRAM_S0 4
#define MT_SPM_BIT_DRAM_S1 5
/* SPM resource request internal bit_mask */
#define MT_SPM_XO_FPM BIT(MT_SPM_BIT_XO_FPM)
#define MT_SPM_26M BIT(MT_SPM_BIT_26M)
#define MT_SPM_INFRA BIT(MT_SPM_BIT_INFRA)
#define MT_SPM_SYSPLL BIT(MT_SPM_BIT_SYSPLL)
#define MT_SPM_DRAM_S0 BIT(MT_SPM_BIT_DRAM_S0)
#define MT_SPM_DRAM_S1 BIT(MT_SPM_BIT_DRAM_S1)
#endif /* MT_SPM_RESOURCE_REQ_H */
/*
* Copyright (c) 2020, MediaTek Inc. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <common/debug.h>
#include <lib/mmio.h>
#include <mt_spm.h>
#include <mt_spm_conservation.h>
#include <mt_spm_internal.h>
#include <mt_spm_rc_internal.h>
#include <mt_spm_reg.h>
#include <mt_spm_resource_req.h>
#include <mt_spm_suspend.h>
#include <plat_pm.h>
#include <uart.h>
#define SPM_SUSPEND_SLEEP_PCM_FLAG \
(SPM_FLAG_DISABLE_INFRA_PDN | \
SPM_FLAG_DISABLE_VCORE_DVS | \
SPM_FLAG_DISABLE_VCORE_DFS | \
SPM_FLAG_KEEP_CSYSPWRACK_HIGH | \
SPM_FLAG_USE_SRCCLKENO2 | \
SPM_FLAG_ENABLE_MD_MUMTAS | \
SPM_FLAG_SRAM_SLEEP_CTRL)
#define SPM_SUSPEND_SLEEP_PCM_FLAG1 \
(SPM_FLAG1_DISABLE_MD26M_CK_OFF)
#define SPM_SUSPEND_PCM_FLAG \
(SPM_FLAG_DISABLE_VCORE_DVS | \
SPM_FLAG_DISABLE_VCORE_DFS | \
SPM_FLAG_ENABLE_TIA_WORKAROUND | \
SPM_FLAG_ENABLE_MD_MUMTAS | \
SPM_FLAG_SRAM_SLEEP_CTRL)
#define SPM_SUSPEND_PCM_FLAG1 \
(SPM_FLAG1_DISABLE_MD26M_CK_OFF)
#define __WAKE_SRC_FOR_SUSPEND_COMMON__ \
(R12_PCM_TIMER | \
R12_KP_IRQ_B | \
R12_APWDT_EVENT_B | \
R12_APXGPT1_EVENT_B | \
R12_CONN2AP_SPM_WAKEUP_B | \
R12_EINT_EVENT_B | \
R12_CONN_WDT_IRQ_B | \
R12_CCIF0_EVENT_B | \
R12_SSPM2SPM_WAKEUP_B | \
R12_SCP2SPM_WAKEUP_B | \
R12_ADSP2SPM_WAKEUP_B | \
R12_USBX_CDSC_B | \
R12_USBX_POWERDWN_B | \
R12_SYS_TIMER_EVENT_B | \
R12_EINT_EVENT_SECURE_B | \
R12_CCIF1_EVENT_B | \
R12_SYS_CIRQ_IRQ_B | \
R12_MD2AP_PEER_EVENT_B | \
R12_MD1_WDT_B | \
R12_CLDMA_EVENT_B | \
R12_REG_CPU_WAKEUP | \
R12_APUSYS_WAKE_HOST_B | \
R12_PCIE_BRIDGE_IRQ | \
R12_PCIE_IRQ)
#if defined(CFG_MICROTRUST_TEE_SUPPORT)
#define WAKE_SRC_FOR_SUSPEND (__WAKE_SRC_FOR_SUSPEND_COMMON__)
#else
#define WAKE_SRC_FOR_SUSPEND \
(__WAKE_SRC_FOR_SUSPEND_COMMON__ | \
R12_SEJ_EVENT_B)
#endif
static struct pwr_ctrl suspend_ctrl = {
.wake_src = WAKE_SRC_FOR_SUSPEND,
.pcm_flags = SPM_SUSPEND_PCM_FLAG | SPM_FLAG_DISABLE_INFRA_PDN,
.pcm_flags1 = SPM_SUSPEND_PCM_FLAG1,
/* Auto-gen Start */
/* SPM_AP_STANDBY_CON */
.reg_wfi_op = 0,
.reg_wfi_type = 0,
.reg_mp0_cputop_idle_mask = 0,
.reg_mp1_cputop_idle_mask = 0,
.reg_mcusys_idle_mask = 0,
.reg_md_apsrc_1_sel = 0,
.reg_md_apsrc_0_sel = 0,
.reg_conn_apsrc_sel = 0,
/* SPM_SRC6_MASK */
.reg_dpmaif_srcclkena_mask_b = 1,
.reg_dpmaif_infra_req_mask_b = 1,
.reg_dpmaif_apsrc_req_mask_b = 1,
.reg_dpmaif_vrf18_req_mask_b = 1,
.reg_dpmaif_ddr_en_mask_b = 1,
/* SPM_SRC_REQ */
.reg_spm_apsrc_req = 0,
.reg_spm_f26m_req = 0,
.reg_spm_infra_req = 0,
.reg_spm_vrf18_req = 0,
.reg_spm_ddr_en_req = 0,
.reg_spm_dvfs_req = 0,
.reg_spm_sw_mailbox_req = 0,
.reg_spm_sspm_mailbox_req = 0,
.reg_spm_adsp_mailbox_req = 0,
.reg_spm_scp_mailbox_req = 0,
/* SPM_SRC_MASK */
.reg_md_srcclkena_0_mask_b = 1,
.reg_md_srcclkena2infra_req_0_mask_b = 0,
.reg_md_apsrc2infra_req_0_mask_b = 1,
.reg_md_apsrc_req_0_mask_b = 1,
.reg_md_vrf18_req_0_mask_b = 1,
.reg_md_ddr_en_0_mask_b = 1,
.reg_md_srcclkena_1_mask_b = 0,
.reg_md_srcclkena2infra_req_1_mask_b = 0,
.reg_md_apsrc2infra_req_1_mask_b = 0,
.reg_md_apsrc_req_1_mask_b = 0,
.reg_md_vrf18_req_1_mask_b = 0,
.reg_md_ddr_en_1_mask_b = 0,
.reg_conn_srcclkena_mask_b = 1,
.reg_conn_srcclkenb_mask_b = 0,
.reg_conn_infra_req_mask_b = 1,
.reg_conn_apsrc_req_mask_b = 1,
.reg_conn_vrf18_req_mask_b = 1,
.reg_conn_ddr_en_mask_b = 1,
.reg_conn_vfe28_mask_b = 0,
.reg_srcclkeni0_srcclkena_mask_b = 1,
.reg_srcclkeni0_infra_req_mask_b = 1,
.reg_srcclkeni1_srcclkena_mask_b = 0,
.reg_srcclkeni1_infra_req_mask_b = 0,
.reg_srcclkeni2_srcclkena_mask_b = 0,
.reg_srcclkeni2_infra_req_mask_b = 0,
.reg_infrasys_apsrc_req_mask_b = 0,
.reg_infrasys_ddr_en_mask_b = 1,
.reg_md32_srcclkena_mask_b = 1,
.reg_md32_infra_req_mask_b = 1,
.reg_md32_apsrc_req_mask_b = 1,
.reg_md32_vrf18_req_mask_b = 1,
.reg_md32_ddr_en_mask_b = 1,
/* SPM_SRC2_MASK */
.reg_scp_srcclkena_mask_b = 1,
.reg_scp_infra_req_mask_b = 1,
.reg_scp_apsrc_req_mask_b = 1,
.reg_scp_vrf18_req_mask_b = 1,
.reg_scp_ddr_en_mask_b = 1,
.reg_audio_dsp_srcclkena_mask_b = 1,
.reg_audio_dsp_infra_req_mask_b = 1,
.reg_audio_dsp_apsrc_req_mask_b = 1,
.reg_audio_dsp_vrf18_req_mask_b = 1,
.reg_audio_dsp_ddr_en_mask_b = 1,
.reg_ufs_srcclkena_mask_b = 1,
.reg_ufs_infra_req_mask_b = 1,
.reg_ufs_apsrc_req_mask_b = 1,
.reg_ufs_vrf18_req_mask_b = 1,
.reg_ufs_ddr_en_mask_b = 1,
.reg_disp0_apsrc_req_mask_b = 1,
.reg_disp0_ddr_en_mask_b = 1,
.reg_disp1_apsrc_req_mask_b = 1,
.reg_disp1_ddr_en_mask_b = 1,
.reg_gce_infra_req_mask_b = 1,
.reg_gce_apsrc_req_mask_b = 1,
.reg_gce_vrf18_req_mask_b = 1,
.reg_gce_ddr_en_mask_b = 1,
.reg_apu_srcclkena_mask_b = 1,
.reg_apu_infra_req_mask_b = 1,
.reg_apu_apsrc_req_mask_b = 1,
.reg_apu_vrf18_req_mask_b = 1,
.reg_apu_ddr_en_mask_b = 1,
.reg_cg_check_srcclkena_mask_b = 0,
.reg_cg_check_apsrc_req_mask_b = 0,
.reg_cg_check_vrf18_req_mask_b = 0,
.reg_cg_check_ddr_en_mask_b = 0,
/* SPM_SRC3_MASK */
.reg_dvfsrc_event_trigger_mask_b = 1,
.reg_sw2spm_int0_mask_b = 0,
.reg_sw2spm_int1_mask_b = 0,
.reg_sw2spm_int2_mask_b = 0,
.reg_sw2spm_int3_mask_b = 0,
.reg_sc_adsp2spm_wakeup_mask_b = 0,
.reg_sc_sspm2spm_wakeup_mask_b = 0,
.reg_sc_scp2spm_wakeup_mask_b = 0,
.reg_csyspwrreq_mask = 1,
.reg_spm_srcclkena_reserved_mask_b = 0,
.reg_spm_infra_req_reserved_mask_b = 0,
.reg_spm_apsrc_req_reserved_mask_b = 0,
.reg_spm_vrf18_req_reserved_mask_b = 0,
.reg_spm_ddr_en_reserved_mask_b = 0,
.reg_mcupm_srcclkena_mask_b = 1,
.reg_mcupm_infra_req_mask_b = 1,
.reg_mcupm_apsrc_req_mask_b = 1,
.reg_mcupm_vrf18_req_mask_b = 1,
.reg_mcupm_ddr_en_mask_b = 1,
.reg_msdc0_srcclkena_mask_b = 1,
.reg_msdc0_infra_req_mask_b = 1,
.reg_msdc0_apsrc_req_mask_b = 1,
.reg_msdc0_vrf18_req_mask_b = 1,
.reg_msdc0_ddr_en_mask_b = 1,
.reg_msdc1_srcclkena_mask_b = 1,
.reg_msdc1_infra_req_mask_b = 1,
.reg_msdc1_apsrc_req_mask_b = 1,
.reg_msdc1_vrf18_req_mask_b = 1,
.reg_msdc1_ddr_en_mask_b = 1,
/* SPM_SRC4_MASK */
.ccif_event_mask_b = 0xFFF,
.reg_bak_psri_srcclkena_mask_b = 0,
.reg_bak_psri_infra_req_mask_b = 0,
.reg_bak_psri_apsrc_req_mask_b = 0,
.reg_bak_psri_vrf18_req_mask_b = 0,
.reg_bak_psri_ddr_en_mask_b = 0,
.reg_dramc0_md32_infra_req_mask_b = 1,
.reg_dramc0_md32_vrf18_req_mask_b = 0,
.reg_dramc1_md32_infra_req_mask_b = 1,
.reg_dramc1_md32_vrf18_req_mask_b = 0,
.reg_conn_srcclkenb2pwrap_mask_b = 0,
.reg_dramc0_md32_wakeup_mask = 1,
.reg_dramc1_md32_wakeup_mask = 1,
/* SPM_SRC5_MASK */
.reg_mcusys_merge_apsrc_req_mask_b = 0x11,
.reg_mcusys_merge_ddr_en_mask_b = 0x11,
.reg_msdc2_srcclkena_mask_b = 1,
.reg_msdc2_infra_req_mask_b = 1,
.reg_msdc2_apsrc_req_mask_b = 1,
.reg_msdc2_vrf18_req_mask_b = 1,
.reg_msdc2_ddr_en_mask_b = 1,
.reg_pcie_srcclkena_mask_b = 1,
.reg_pcie_infra_req_mask_b = 1,
.reg_pcie_apsrc_req_mask_b = 1,
.reg_pcie_vrf18_req_mask_b = 1,
.reg_pcie_ddr_en_mask_b = 1,
/* SPM_WAKEUP_EVENT_MASK */
.reg_wakeup_event_mask = 0x01382202,
/* SPM_WAKEUP_EVENT_EXT_MASK */
.reg_ext_wakeup_event_mask = 0xFFFFFFFF,
/* Auto-gen End */
};
struct spm_lp_scen __spm_suspend = {
.pwrctrl = &suspend_ctrl,
};
int mt_spm_suspend_mode_set(int mode)
{
if (mode == MT_SPM_SUSPEND_SLEEP) {
suspend_ctrl.pcm_flags = SPM_SUSPEND_SLEEP_PCM_FLAG;
suspend_ctrl.pcm_flags1 = SPM_SUSPEND_SLEEP_PCM_FLAG1;
} else {
suspend_ctrl.pcm_flags = SPM_SUSPEND_PCM_FLAG;
suspend_ctrl.pcm_flags1 = SPM_SUSPEND_PCM_FLAG1;
}
return 0;
}
int mt_spm_suspend_enter(int state_id, unsigned int ext_opand,
unsigned int resource_req)
{
/* If FMAudio / ADSP is active, change to sleep suspend mode */
if ((ext_opand & MT_SPM_EX_OP_SET_SUSPEND_MODE) != 0U) {
mt_spm_suspend_mode_set(MT_SPM_SUSPEND_SLEEP);
}
/* Notify MCUPM that device is going suspend flow */
mmio_write_32(MCUPM_MBOX_OFFSET_PDN, MCUPM_POWER_DOWN);
/* Notify UART to sleep */
mt_uart_save();
return spm_conservation(state_id, ext_opand,
&__spm_suspend, resource_req);
}
void mt_spm_suspend_resume(int state_id, unsigned int ext_opand,
struct wake_status **status)
{
spm_conservation_finish(state_id, ext_opand, &__spm_suspend, status);
/* Notify UART to wakeup */
mt_uart_restore();
/* Notify MCUPM that device leave suspend */
mmio_write_32(MCUPM_MBOX_OFFSET_PDN, 0);
/* If FMAudio / ADSP is active, change back to suspend mode */
if ((ext_opand & MT_SPM_EX_OP_SET_SUSPEND_MODE) != 0U) {
mt_spm_suspend_mode_set(MT_SPM_SUSPEND_SYSTEM_PDN);
}
}
void mt_spm_suspend_init(void)
{
spm_conservation_pwrctrl_init(__spm_suspend.pwrctrl);
}
/*
* Copyright (c) 2020, MediaTek Inc. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef MT_SPM_SUSPEND_H
#define MT_SPM_SUSPEND_H
#include <mt_spm_internal.h>
#define MCUPM_MBOX_OFFSET_PDN 0x0C55FDA8
#define MCUPM_POWER_DOWN 0x4D50444E
enum MT_SPM_SUSPEND_MODE {
MT_SPM_SUSPEND_SYSTEM_PDN,
MT_SPM_SUSPEND_SLEEP,
};
extern int mt_spm_suspend_mode_set(int mode);
extern int mt_spm_suspend_enter(int state_id, unsigned int ext_opand,
unsigned int reosuce_req);
extern void mt_spm_suspend_resume(int state_id, unsigned int ext_opand,
struct wake_status **status);
extern void mt_spm_suspend_init(void);
#endif /* MT_SPM_SUSPEND_H */
/*
* Copyright(C)2020, MediaTek Inc. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <stddef.h>
#include <stdio.h>
#include <string.h>
#include <arch_helpers.h>
#include <common/debug.h>
#include <drivers/delay_timer.h>
#include <lib/mmio.h>
#include <plat/common/platform.h>
#include <lib/utils_def.h>
#include <mtk_sip_svc.h>
#include <plat_pm.h>
#include <platform_def.h>
#include "mt_spm.h"
#include "mt_spm_internal.h"
#include "mt_spm_reg.h"
#include "mt_spm_vcorefs.h"
#include "mt_spm_pmic_wrap.h"
#define VCORE_CT_ENABLE (1U << 5)
#define SW_REQ5_INIT_VAL (6U << 12)
#define V_VMODE_SHIFT 0
#define VCORE_HV 105
#define VCORE_LV 95
#define PMIC_STEP_UV 6250
static const struct reg_config dvfsrc_init_configs[] = {
/* Setup opp table */
{ DVFSRC_LEVEL_LABEL_0_1, 0x50436053 },
{ DVFSRC_LEVEL_LABEL_2_3, 0x40335042 },
{ DVFSRC_LEVEL_LABEL_4_5, 0x40314032 },
{ DVFSRC_LEVEL_LABEL_6_7, 0x30223023 },
{ DVFSRC_LEVEL_LABEL_8_9, 0x20133021 },
{ DVFSRC_LEVEL_LABEL_10_11, 0x20112012 },
{ DVFSRC_LEVEL_LABEL_12_13, 0x10032010 },
{ DVFSRC_LEVEL_LABEL_14_15, 0x10011002 },
{ DVFSRC_LEVEL_LABEL_16_17, 0x00131000 },
{ DVFSRC_LEVEL_LABEL_18_19, 0x00110012 },
{ DVFSRC_LEVEL_LABEL_20_21, 0x00000010 },
/* Setup hw emi qos policy */
{ DVFSRC_DDR_REQUEST, 0x00004321 },
{ DVFSRC_DDR_REQUEST3, 0x00000065 },
/* Setup up for PCIe */
{ DVFSRC_PCIE_VCORE_REQ, 0x0A298001 },
/* Setup up HRT QOS policy */
{ DVFSRC_HRT_BW_BASE, 0x00000004 },
{ DVFSRC_HRT_REQ_UNIT, 0x0000001E },
{ DVFSRC_HRT_HIGH_3, 0x18A618A6 },
{ DVFSRC_HRT_HIGH_2, 0x18A61183 },
{ DVFSRC_HRT_HIGH_1, 0x0D690B80 },
{ DVFSRC_HRT_HIGH, 0x070804B0 },
{ DVFSRC_HRT_LOW_3, 0x18A518A5 },
{ DVFSRC_HRT_LOW_2, 0x18A51182 },
{ DVFSRC_HRT_LOW_1, 0x0D680B7F },
{ DVFSRC_HRT_LOW, 0x070704AF },
{ DVFSRC_HRT_REQUEST, 0x66654321 },
/* Setup up SRT QOS policy */
{ DVFSRC_QOS_EN, 0x0011007C },
{ DVFSRC_DDR_QOS0, 0x00000019 },
{ DVFSRC_DDR_QOS1, 0x00000026 },
{ DVFSRC_DDR_QOS2, 0x00000033 },
{ DVFSRC_DDR_QOS3, 0x0000003B },
{ DVFSRC_DDR_QOS4, 0x0000004C },
{ DVFSRC_DDR_QOS5, 0x00000066 },
{ DVFSRC_DDR_QOS6, 0x00000066 },
{ DVFSRC_DDR_REQUEST5, 0x54321000 },
{ DVFSRC_DDR_REQUEST7, 0x66000000 },
/* Setup up hifi request policy */
{ DVFSRC_DDR_REQUEST6, 0x66543210 },
/* Setup up hw request vcore policy */
{ DVFSRC_VCORE_USER_REQ, 0x00010A29 },
/* Setup misc*/
{ DVFSRC_TIMEOUT_NEXTREQ, 0x00000015 },
{ DVFSRC_RSRV_5, 0x00000001 },
{ DVFSRC_INT_EN, 0x00000002 },
/* Init opp and enable dvfsrc*/
{ DVFSRC_CURRENT_FORCE, 0x00000001 },
{ DVFSRC_BASIC_CONTROL, 0x0298444B },
{ DVFSRC_BASIC_CONTROL, 0x0298054B },
{ DVFSRC_CURRENT_FORCE, 0x00000000 },
};
static struct pwr_ctrl vcorefs_ctrl = {
.wake_src = R12_REG_CPU_WAKEUP,
/* default VCORE DVFS is disabled */
.pcm_flags = (SPM_FLAG_RUN_COMMON_SCENARIO |
SPM_FLAG_DISABLE_VCORE_DVS |
SPM_FLAG_DISABLE_VCORE_DFS),
/* Auto-gen Start */
/* SPM_AP_STANDBY_CON */
.reg_wfi_op = 0,
.reg_wfi_type = 0,
.reg_mp0_cputop_idle_mask = 0,
.reg_mp1_cputop_idle_mask = 0,
.reg_mcusys_idle_mask = 0,
.reg_md_apsrc_1_sel = 0,
.reg_md_apsrc_0_sel = 0,
.reg_conn_apsrc_sel = 0,
/* SPM_SRC_REQ */
.reg_spm_apsrc_req = 0,
.reg_spm_f26m_req = 0,
.reg_spm_infra_req = 0,
.reg_spm_vrf18_req = 0,
.reg_spm_ddr_en_req = 1,
.reg_spm_dvfs_req = 0,
.reg_spm_sw_mailbox_req = 0,
.reg_spm_sspm_mailbox_req = 0,
.reg_spm_adsp_mailbox_req = 0,
.reg_spm_scp_mailbox_req = 0,
/* SPM_SRC6_MASK */
.reg_dpmaif_srcclkena_mask_b = 1,
.reg_dpmaif_infra_req_mask_b = 1,
.reg_dpmaif_apsrc_req_mask_b = 1,
.reg_dpmaif_vrf18_req_mask_b = 1,
.reg_dpmaif_ddr_en_mask_b = 1,
/* SPM_SRC_MASK */
.reg_md_srcclkena_0_mask_b = 1,
.reg_md_srcclkena2infra_req_0_mask_b = 0,
.reg_md_apsrc2infra_req_0_mask_b = 1,
.reg_md_apsrc_req_0_mask_b = 1,
.reg_md_vrf18_req_0_mask_b = 1,
.reg_md_ddr_en_0_mask_b = 1,
.reg_md_srcclkena_1_mask_b = 0,
.reg_md_srcclkena2infra_req_1_mask_b = 0,
.reg_md_apsrc2infra_req_1_mask_b = 0,
.reg_md_apsrc_req_1_mask_b = 0,
.reg_md_vrf18_req_1_mask_b = 0,
.reg_md_ddr_en_1_mask_b = 0,
.reg_conn_srcclkena_mask_b = 1,
.reg_conn_srcclkenb_mask_b = 0,
.reg_conn_infra_req_mask_b = 1,
.reg_conn_apsrc_req_mask_b = 1,
.reg_conn_vrf18_req_mask_b = 1,
.reg_conn_ddr_en_mask_b = 1,
.reg_conn_vfe28_mask_b = 0,
.reg_srcclkeni0_srcclkena_mask_b = 1,
.reg_srcclkeni0_infra_req_mask_b = 1,
.reg_srcclkeni1_srcclkena_mask_b = 0,
.reg_srcclkeni1_infra_req_mask_b = 0,
.reg_srcclkeni2_srcclkena_mask_b = 0,
.reg_srcclkeni2_infra_req_mask_b = 0,
.reg_infrasys_apsrc_req_mask_b = 0,
.reg_infrasys_ddr_en_mask_b = 1,
.reg_md32_srcclkena_mask_b = 1,
.reg_md32_infra_req_mask_b = 1,
.reg_md32_apsrc_req_mask_b = 1,
.reg_md32_vrf18_req_mask_b = 1,
.reg_md32_ddr_en_mask_b = 1,
/* SPM_SRC2_MASK */
.reg_scp_srcclkena_mask_b = 1,
.reg_scp_infra_req_mask_b = 1,
.reg_scp_apsrc_req_mask_b = 1,
.reg_scp_vrf18_req_mask_b = 1,
.reg_scp_ddr_en_mask_b = 1,
.reg_audio_dsp_srcclkena_mask_b = 1,
.reg_audio_dsp_infra_req_mask_b = 1,
.reg_audio_dsp_apsrc_req_mask_b = 1,
.reg_audio_dsp_vrf18_req_mask_b = 1,
.reg_audio_dsp_ddr_en_mask_b = 1,
.reg_ufs_srcclkena_mask_b = 1,
.reg_ufs_infra_req_mask_b = 1,
.reg_ufs_apsrc_req_mask_b = 1,
.reg_ufs_vrf18_req_mask_b = 1,
.reg_ufs_ddr_en_mask_b = 1,
.reg_disp0_apsrc_req_mask_b = 1,
.reg_disp0_ddr_en_mask_b = 1,
.reg_disp1_apsrc_req_mask_b = 1,
.reg_disp1_ddr_en_mask_b = 1,
.reg_gce_infra_req_mask_b = 1,
.reg_gce_apsrc_req_mask_b = 1,
.reg_gce_vrf18_req_mask_b = 1,
.reg_gce_ddr_en_mask_b = 1,
.reg_apu_srcclkena_mask_b = 1,
.reg_apu_infra_req_mask_b = 1,
.reg_apu_apsrc_req_mask_b = 1,
.reg_apu_vrf18_req_mask_b = 1,
.reg_apu_ddr_en_mask_b = 1,
.reg_cg_check_srcclkena_mask_b = 0,
.reg_cg_check_apsrc_req_mask_b = 0,
.reg_cg_check_vrf18_req_mask_b = 0,
.reg_cg_check_ddr_en_mask_b = 0,
/* SPM_SRC3_MASK */
.reg_dvfsrc_event_trigger_mask_b = 1,
.reg_sw2spm_int0_mask_b = 0,
.reg_sw2spm_int1_mask_b = 0,
.reg_sw2spm_int2_mask_b = 0,
.reg_sw2spm_int3_mask_b = 0,
.reg_sc_adsp2spm_wakeup_mask_b = 0,
.reg_sc_sspm2spm_wakeup_mask_b = 0,
.reg_sc_scp2spm_wakeup_mask_b = 0,
.reg_csyspwrreq_mask = 1,
.reg_spm_srcclkena_reserved_mask_b = 0,
.reg_spm_infra_req_reserved_mask_b = 0,
.reg_spm_apsrc_req_reserved_mask_b = 0,
.reg_spm_vrf18_req_reserved_mask_b = 0,
.reg_spm_ddr_en_reserved_mask_b = 0,
.reg_mcupm_srcclkena_mask_b = 1,
.reg_mcupm_infra_req_mask_b = 1,
.reg_mcupm_apsrc_req_mask_b = 1,
.reg_mcupm_vrf18_req_mask_b = 1,
.reg_mcupm_ddr_en_mask_b = 1,
.reg_msdc0_srcclkena_mask_b = 1,
.reg_msdc0_infra_req_mask_b = 1,
.reg_msdc0_apsrc_req_mask_b = 1,
.reg_msdc0_vrf18_req_mask_b = 1,
.reg_msdc0_ddr_en_mask_b = 1,
.reg_msdc1_srcclkena_mask_b = 1,
.reg_msdc1_infra_req_mask_b = 1,
.reg_msdc1_apsrc_req_mask_b = 1,
.reg_msdc1_vrf18_req_mask_b = 1,
.reg_msdc1_ddr_en_mask_b = 1,
/* SPM_SRC4_MASK */
.ccif_event_mask_b = 0xFFF,
.reg_bak_psri_srcclkena_mask_b = 0,
.reg_bak_psri_infra_req_mask_b = 0,
.reg_bak_psri_apsrc_req_mask_b = 0,
.reg_bak_psri_vrf18_req_mask_b = 0,
.reg_bak_psri_ddr_en_mask_b = 0,
.reg_dramc0_md32_infra_req_mask_b = 1,
.reg_dramc0_md32_vrf18_req_mask_b = 0,
.reg_dramc1_md32_infra_req_mask_b = 1,
.reg_dramc1_md32_vrf18_req_mask_b = 0,
.reg_conn_srcclkenb2pwrap_mask_b = 0,
.reg_dramc0_md32_wakeup_mask = 1,
.reg_dramc1_md32_wakeup_mask = 1,
/* SPM_SRC5_MASK */
.reg_mcusys_merge_apsrc_req_mask_b = 0x11,
.reg_mcusys_merge_ddr_en_mask_b = 0x11,
.reg_msdc2_srcclkena_mask_b = 1,
.reg_msdc2_infra_req_mask_b = 1,
.reg_msdc2_apsrc_req_mask_b = 1,
.reg_msdc2_vrf18_req_mask_b = 1,
.reg_msdc2_ddr_en_mask_b = 1,
.reg_pcie_srcclkena_mask_b = 1,
.reg_pcie_infra_req_mask_b = 1,
.reg_pcie_apsrc_req_mask_b = 1,
.reg_pcie_vrf18_req_mask_b = 1,
.reg_pcie_ddr_en_mask_b = 1,
/* SPM_WAKEUP_EVENT_MASK */
.reg_wakeup_event_mask = 0xEFFFFFFF,
/* SPM_WAKEUP_EVENT_EXT_MASK */
.reg_ext_wakeup_event_mask = 0xFFFFFFFF,
/* Auto-gen End */
};
struct spm_lp_scen __spm_vcorefs = {
.pwrctrl = &vcorefs_ctrl,
};
static void spm_vcorefs_pwarp_cmd(uint64_t cmd, uint64_t val)
{
if (cmd < NR_IDX_ALL) {
mt_spm_pmic_wrap_set_cmd(PMIC_WRAP_PHASE_ALLINONE, cmd, val);
} else {
INFO("cmd out of range!\n");
}
}
void spm_dvfsfw_init(uint64_t boot_up_opp, uint64_t dram_issue)
{
mmio_clrsetbits_32(SPM_DVFS_MISC, SPM_DVFS_FORCE_ENABLE_LSB,
SPM_DVFSRC_ENABLE_LSB);
mmio_write_32(SPM_DVFS_LEVEL, 0x00000001);
mmio_write_32(SPM_DVS_DFS_LEVEL, 0x00010001);
}
void __spm_sync_vcore_dvfs_power_control(struct pwr_ctrl *dest_pwr_ctrl,
const struct pwr_ctrl *src_pwr_ctrl)
{
uint32_t dvfs_mask = SPM_FLAG_DISABLE_VCORE_DVS |
SPM_FLAG_DISABLE_VCORE_DFS |
SPM_FLAG_ENABLE_VOLTAGE_BIN;
dest_pwr_ctrl->pcm_flags = (dest_pwr_ctrl->pcm_flags & (~dvfs_mask)) |
(src_pwr_ctrl->pcm_flags & dvfs_mask);
if (dest_pwr_ctrl->pcm_flags_cust > 0U) {
dest_pwr_ctrl->pcm_flags_cust =
(dest_pwr_ctrl->pcm_flags_cust & (~dvfs_mask)) |
(src_pwr_ctrl->pcm_flags & dvfs_mask);
}
}
static void spm_go_to_vcorefs(void)
{
__spm_set_power_control(__spm_vcorefs.pwrctrl);
__spm_set_wakeup_event(__spm_vcorefs.pwrctrl);
__spm_set_pcm_flags(__spm_vcorefs.pwrctrl);
__spm_send_cpu_wakeup_event();
}
static void dvfsrc_init(void)
{
uint32_t i;
for (i = 0U; i < ARRAY_SIZE(dvfsrc_init_configs); i++) {
mmio_write_32(dvfsrc_init_configs[i].offset,
dvfsrc_init_configs[i].val);
}
}
static uint32_t spm_vcorefs_get_efuse_data(void)
{
return mmio_read_32(VCORE_VB_EFUSE);
}
static uint32_t is_rising_need(void)
{
return ((spm_vcorefs_get_efuse_data() & 0xF) == 11U) ? 1U : 0U;
}
static void spm_vcorefs_vcore_setting(uint64_t flag)
{
uint32_t dvfs_v_mode, dvfsrc_rsrv, i;
uint32_t opp_uv[] = {725000U, 650000U, 600000U, 575000U};
dvfsrc_rsrv = mmio_read_32(DVFSRC_RSRV_4);
dvfs_v_mode = (dvfsrc_rsrv >> V_VMODE_SHIFT) & 0x3;
if (is_rising_need() != 0U) {
opp_uv[2] = 625000U;
opp_uv[3] = 600000U;
}
for (i = 0; i < ARRAY_SIZE(opp_uv); i++) {
if (dvfs_v_mode == 3U) {
/* LV */
opp_uv[i] = round_down((opp_uv[i] * VCORE_LV) / 100U,
PMIC_STEP_UV);
} else if (dvfs_v_mode == 1U) {
/* HV */
opp_uv[i] = round_up((opp_uv[i] * VCORE_HV) / 100U,
PMIC_STEP_UV);
}
spm_vcorefs_pwarp_cmd(i, __vcore_uv_to_pmic(opp_uv[i]));
}
}
uint64_t spm_vcorefs_args(uint64_t x1, uint64_t x2, uint64_t x3, uint64_t *x4)
{
uint64_t cmd = x1;
uint64_t spm_flags;
switch (cmd) {
case VCOREFS_SMC_CMD_INIT:
/* vcore_dvfs init + kick */
mmio_write_32(DVFSRC_SW_REQ5, SW_REQ5_INIT_VAL);
spm_dvfsfw_init(0ULL, 0ULL);
spm_vcorefs_vcore_setting(x3 & 0xF);
spm_flags = SPM_FLAG_RUN_COMMON_SCENARIO;
if ((x2 & 0x1) > 0U) {
spm_flags |= SPM_FLAG_DISABLE_VCORE_DVS;
}
if ((x2 & 0x2) > 0U) {
spm_flags |= SPM_FLAG_DISABLE_VCORE_DFS;
}
if ((mmio_read_32(DVFSRC_RSRV_4) & VCORE_CT_ENABLE) > 0U) {
spm_flags |= SPM_FLAG_ENABLE_VOLTAGE_BIN;
}
set_pwrctrl_pcm_flags(__spm_vcorefs.pwrctrl, spm_flags);
spm_go_to_vcorefs();
dvfsrc_init();
*x4 = 0U;
case VCOREFS_SMC_CMD_KICK:
mmio_write_32(DVFSRC_SW_REQ5, 0U);
break;
default:
break;
}
return 0ULL;
}
/*
* Copyright(C)2020, MediaTek Inc. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef MT_SPM_VCOREFS_H
#define MT_SPM_VCOREFS_H
uint64_t spm_vcorefs_args(uint64_t x1, uint64_t x2, uint64_t x3, uint64_t *x4);
enum vcorefs_smc_cmd {
VCOREFS_SMC_CMD_0,
VCOREFS_SMC_CMD_1,
VCOREFS_SMC_CMD_2,
VCOREFS_SMC_CMD_3,
VCOREFS_SMC_CMD_4,
/* check spmfw status */
VCOREFS_SMC_CMD_5,
/* get spmfw type */
VCOREFS_SMC_CMD_6,
/* get spm reg status */
VCOREFS_SMC_CMD_7,
NUM_VCOREFS_SMC_CMD,
};
enum vcorefs_smc_cmd_new {
VCOREFS_SMC_CMD_INIT = 0,
VCOREFS_SMC_CMD_KICK = 1,
};
#define _VCORE_BASE_UV 400000
#define _VCORE_STEP_UV 6250
/* PMIC */
#define __vcore_pmic_to_uv(pmic) \
(((pmic) * _VCORE_STEP_UV) + _VCORE_BASE_UV)
#define __vcore_uv_to_pmic(uv) /* pmic >= uv */ \
((((uv) - _VCORE_BASE_UV) + (_VCORE_STEP_UV - 1)) / _VCORE_STEP_UV)
struct reg_config {
uint32_t offset;
uint32_t val;
};
#define DVFSRC_BASIC_CONTROL (DVFSRC_BASE + 0x0)
#define DVFSRC_SW_REQ5 (DVFSRC_BASE + 0x14)
#define DVFSRC_INT_EN (DVFSRC_BASE + 0xC8)
#define DVFSRC_MD_TURBO (DVFSRC_BASE + 0xDC)
#define DVFSRC_PCIE_VCORE_REQ (DVFSRC_BASE + 0xE0)
#define DVFSRC_VCORE_USER_REQ (DVFSRC_BASE + 0xE4)
#define DVFSRC_TIMEOUT_NEXTREQ (DVFSRC_BASE + 0xF8)
#define DVFSRC_LEVEL_LABEL_0_1 (DVFSRC_BASE + 0x100)
#define DVFSRC_LEVEL_LABEL_2_3 (DVFSRC_BASE + 0x104)
#define DVFSRC_LEVEL_LABEL_4_5 (DVFSRC_BASE + 0x108)
#define DVFSRC_LEVEL_LABEL_6_7 (DVFSRC_BASE + 0x10C)
#define DVFSRC_LEVEL_LABEL_8_9 (DVFSRC_BASE + 0x110)
#define DVFSRC_LEVEL_LABEL_10_11 (DVFSRC_BASE + 0x114)
#define DVFSRC_LEVEL_LABEL_12_13 (DVFSRC_BASE + 0x118)
#define DVFSRC_LEVEL_LABEL_14_15 (DVFSRC_BASE + 0x11C)
#define DVFSRC_QOS_EN (DVFSRC_BASE + 0x280)
#define DVFSRC_HRT_BW_BASE (DVFSRC_BASE + 0x294)
#define DVFSRC_RSRV_4 (DVFSRC_BASE + 0x610)
#define DVFSRC_RSRV_5 (DVFSRC_BASE + 0x614)
#define DVFSRC_DDR_REQUEST (DVFSRC_BASE + 0xA00)
#define DVFSRC_DDR_REQUEST2 (DVFSRC_BASE + 0xA04)
#define DVFSRC_DDR_REQUEST3 (DVFSRC_BASE + 0xA08)
#define DVFSRC_DDR_REQUEST4 (DVFSRC_BASE + 0xA0C)
#define DVFSRC_DDR_REQUEST5 (DVFSRC_BASE + 0xA10)
#define DVFSRC_DDR_REQUEST6 (DVFSRC_BASE + 0xA14)
#define DVFSRC_DDR_REQUEST7 (DVFSRC_BASE + 0xA18)
#define DVFSRC_DDR_QOS0 (DVFSRC_BASE + 0xA34)
#define DVFSRC_DDR_QOS1 (DVFSRC_BASE + 0xA38)
#define DVFSRC_DDR_QOS2 (DVFSRC_BASE + 0xA3C)
#define DVFSRC_DDR_QOS3 (DVFSRC_BASE + 0xA40)
#define DVFSRC_DDR_QOS4 (DVFSRC_BASE + 0xA44)
#define DVFSRC_HRT_REQ_UNIT (DVFSRC_BASE + 0xA60)
#define DVFSRC_HRT_REQUEST (DVFSRC_BASE + 0xAC4)
#define DVFSRC_HRT_HIGH_2 (DVFSRC_BASE + 0xAC8)
#define DVFSRC_HRT_HIGH_1 (DVFSRC_BASE + 0xACC)
#define DVFSRC_HRT_HIGH (DVFSRC_BASE + 0xAD0)
#define DVFSRC_HRT_LOW_2 (DVFSRC_BASE + 0xAD4)
#define DVFSRC_HRT_LOW_1 (DVFSRC_BASE + 0xAD8)
#define DVFSRC_HRT_LOW (DVFSRC_BASE + 0xADC)
#define DVFSRC_DDR_ADD_REQUEST (DVFSRC_BASE + 0xAE0)
#define DVFSRC_LAST (DVFSRC_BASE + 0xAE4)
#define DVFSRC_LAST_L (DVFSRC_BASE + 0xAE8)
#define DVFSRC_MD_SCENARIO (DVFSRC_BASE + 0xAEC)
#define DVFSRC_RECORD_0_0 (DVFSRC_BASE + 0xAF0)
#define DVFSRC_RECORD_0_1 (DVFSRC_BASE + 0xAF4)
#define DVFSRC_RECORD_0_2 (DVFSRC_BASE + 0xAF8)
#define DVFSRC_RECORD_0_3 (DVFSRC_BASE + 0xAFC)
#define DVFSRC_RECORD_0_4 (DVFSRC_BASE + 0xB00)
#define DVFSRC_RECORD_0_5 (DVFSRC_BASE + 0xB04)
#define DVFSRC_RECORD_0_6 (DVFSRC_BASE + 0xB08)
#define DVFSRC_RECORD_0_7 (DVFSRC_BASE + 0xB0C)
#define DVFSRC_RECORD_0_L_0 (DVFSRC_BASE + 0xBF0)
#define DVFSRC_RECORD_0_L_1 (DVFSRC_BASE + 0xBF4)
#define DVFSRC_RECORD_0_L_2 (DVFSRC_BASE + 0xBF8)
#define DVFSRC_RECORD_0_L_3 (DVFSRC_BASE + 0xBFC)
#define DVFSRC_RECORD_0_L_4 (DVFSRC_BASE + 0xC00)
#define DVFSRC_RECORD_0_L_5 (DVFSRC_BASE + 0xC04)
#define DVFSRC_RECORD_0_L_6 (DVFSRC_BASE + 0xC08)
#define DVFSRC_RECORD_0_L_7 (DVFSRC_BASE + 0xC0C)
#define DVFSRC_EMI_REQUEST8 (DVFSRC_BASE + 0xCF0)
#define DVFSRC_DDR_REQUEST8 (DVFSRC_BASE + 0xCF4)
#define DVFSRC_EMI_HRT_2 (DVFSRC_BASE + 0xCF8)
#define DVFSRC_EMI_HRT2_2 (DVFSRC_BASE + 0xCFC)
#define DVFSRC_EMI_HRT3_2 (DVFSRC_BASE + 0xD00)
#define DVFSRC_EMI_QOS5 (DVFSRC_BASE + 0xD04)
#define DVFSRC_EMI_QOS6 (DVFSRC_BASE + 0xD08)
#define DVFSRC_DDR_HRT_2 (DVFSRC_BASE + 0xD0C)
#define DVFSRC_DDR_HRT2_2 (DVFSRC_BASE + 0xD10)
#define DVFSRC_DDR_HRT3_2 (DVFSRC_BASE + 0xD14)
#define DVFSRC_DDR_QOS5 (DVFSRC_BASE + 0xD18)
#define DVFSRC_DDR_QOS6 (DVFSRC_BASE + 0xD1C)
#define DVFSRC_HRT_HIGH_3 (DVFSRC_BASE + 0xD38)
#define DVFSRC_HRT_LOW_3 (DVFSRC_BASE + 0xD3C)
#define DVFSRC_LEVEL_LABEL_16_17 (DVFSRC_BASE + 0xD4C)
#define DVFSRC_LEVEL_LABEL_18_19 (DVFSRC_BASE + 0xD50)
#define DVFSRC_LEVEL_LABEL_20_21 (DVFSRC_BASE + 0xD54)
#define DVFSRC_LEVEL_LABEL_22_23 (DVFSRC_BASE + 0xD58)
#define DVFSRC_LEVEL_LABEL_24_25 (DVFSRC_BASE + 0xD5C)
#define DVFSRC_LEVEL_LABEL_26_27 (DVFSRC_BASE + 0xD60)
#define DVFSRC_LEVEL_LABEL_28_29 (DVFSRC_BASE + 0xD64)
#define DVFSRC_LEVEL_LABEL_30_31 (DVFSRC_BASE + 0xD68)
#define DVFSRC_CURRENT_FORCE (DVFSRC_BASE + 0xD6C)
#define VCORE_VB_EFUSE (0x11C105E8)
#endif /* MT_SPM_VCOREFS_H */
/*
* Copyright (c) 2020, MediaTek Inc. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef MT_SPM_SSPM_NOTIFIER_H
#define MT_SPM_SSPM_NOTIFIER_H
enum MT_SPM_SSPM_NOTIFY_ID {
MT_SPM_NOTIFY_LP_ENTER,
MT_SPM_NOTIFY_LP_LEAVE,
};
int mt_spm_sspm_notify(int type, unsigned int lp_mode);
static inline int mt_spm_sspm_notify_u32(int type, unsigned int lp_mode)
{
return mt_spm_sspm_notify(type, lp_mode);
}
#endif /* MT_SPM_SSPM_NOTIFIER_H */
/*
* Copyright (c) 2020, MediaTek Inc. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef MT_SPM_SSPM_INTC_H
#define MT_SPM_SSPM_INTC_H
#include <mt_spm_reg.h>
#define MT_SPM_SSPM_INTC_SEL_0 0x10
#define MT_SPM_SSPM_INTC_SEL_1 0x20
#define MT_SPM_SSPM_INTC_SEL_2 0x40
#define MT_SPM_SSPM_INTC_SEL_3 0x80
#define MT_SPM_SSPM_INTC_TRIGGER(id, sg) \
(((0x10 << id) | (sg << id)) & 0xff)
#define MT_SPM_SSPM_INTC0_HIGH MT_SPM_SSPM_INTC_TRIGGER(0, 1)
#define MT_SPM_SSPM_INTC0_LOW MT_SPM_SSPM_INTC_TRIGGER(0, 0)
#define MT_SPM_SSPM_INTC1_HIGH MT_SPM_SSPM_INTC_TRIGGER(1, 1)
#define MT_SPM_SSPM_INTC1_LOW MT_SPM_SSPM_INTC_TRIGGER(1, 0)
#define MT_SPM_SSPM_INTC2_HIGH MT_SPM_SSPM_INTC_TRIGGER(2, 1)
#define MT_SPM_SSPM_INTC2_LOW MT_SPM_SSPM_INTC_TRIGGER(2, 0)
#define MT_SPM_SSPM_INTC3_HIGH MT_SPM_SSPM_INTC_TRIGGER(3, 1)
#define MT_SPM_SSPM_INTC3_LOW MT_SPM_SSPM_INTC_TRIGGER(3, 0)
#define DO_SPM_SSPM_LP_SUSPEND() \
mmio_write_32(SPM_MD32_IRQ, MT_SPM_SSPM_INTC0_HIGH)
#define DO_SPM_SSPM_LP_RESUME() \
mmio_write_32(SPM_MD32_IRQ, MT_SPM_SSPM_INTC0_LOW)
#endif /* MT_SPM_SSPM_INTC_H */
/*
* Copyright (c) 2020, MediaTek Inc. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <stddef.h>
#include <lib/mmio.h>
#include <mt_spm_notifier.h>
#include <mt_spm_sspm_intc.h>
#define MT_SPM_SSPM_MBOX_OFF(x) (SSPM_MBOX_BASE + x)
#define MT_SPM_MBOX(slot) MT_SPM_SSPM_MBOX_OFF((slot << 2UL))
#define SSPM_MBOX_SPM_LP_LOOKUP1 MT_SPM_MBOX(0)
#define SSPM_MBOX_SPM_LP_LOOKUP2 MT_SPM_MBOX(1)
#define SSPM_MBOX_SPM_LP1 MT_SPM_MBOX(2)
#define SSPM_MBOX_SPM_LP2 MT_SPM_MBOX(3)
#define MCUPM_MBOX_OFFSET_LP 0x0C55FDA4
#define MCUPM_MBOX_ENTER_LP 0x454e0000
#define MCUPM_MBOX_LEAVE_LP 0x4c450000
#define MCUPM_MBOX_SLEEP_MASK 0x0000FFFF
int mt_spm_sspm_notify(int type, unsigned int lp_mode)
{
switch (type) {
case MT_SPM_NOTIFY_LP_ENTER:
mmio_write_32(SSPM_MBOX_SPM_LP1, lp_mode);
mmio_write_32(MCUPM_MBOX_OFFSET_LP, MCUPM_MBOX_ENTER_LP |
(lp_mode & MCUPM_MBOX_SLEEP_MASK));
DO_SPM_SSPM_LP_SUSPEND();
break;
case MT_SPM_NOTIFY_LP_LEAVE:
mmio_write_32(SSPM_MBOX_SPM_LP1, lp_mode);
mmio_write_32(MCUPM_MBOX_OFFSET_LP, MCUPM_MBOX_LEAVE_LP |
(lp_mode & MCUPM_MBOX_SLEEP_MASK));
DO_SPM_SSPM_LP_RESUME();
break;
default:
break;
}
return 0;
}
/*
* Copyright (c) 2020, MediaTek Inc. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef PCM_DEF_H
#define PCM_DEF_H
/*
* Auto generated by DE, please DO NOT modify this file directly.
*/
/* --- R0 Define --- */
#define R0_SC_26M_CK_OFF (1U << 0)
#define R0_SC_TX_TRACK_RETRY_EN (1U << 1)
#define R0_SC_MEM_CK_OFF (1U << 2)
#define R0_SC_AXI_CK_OFF (1U << 3)
#define R0_SC_DR_SRAM_LOAD (1U << 4)
#define R0_SC_MD26M_CK_OFF (1U << 5)
#define R0_SC_DPY_MODE_SW (1U << 6)
#define R0_SC_DMSUS_OFF (1U << 7)
#define R0_SC_DPY_2ND_DLL_EN (1U << 8)
#define R0_SC_DR_SRAM_RESTORE (1U << 9)
#define R0_SC_MPLLOUT_OFF (1U << 10)
#define R0_SC_TX_TRACKING_DIS (1U << 11)
#define R0_SC_DPY_DLL_EN (1U << 12)
#define R0_SC_DPY_DLL_CK_EN (1U << 13)
#define R0_SC_DPY_VREF_EN (1U << 14)
#define R0_SC_PHYPLL_EN (1U << 15)
#define R0_SC_DDRPHY_FB_CK_EN (1U << 16)
#define R0_SC_DPY_BCLK_ENABLE (1U << 17)
#define R0_SC_MPLL_OFF (1U << 18)
#define R0_SC_SHU_RESTORE (1U << 19)
#define R0_SC_CKSQ0_OFF (1U << 20)
#define R0_SC_DR_SHU_LEVEL_SRAM_LATCH (1U << 21)
#define R0_SC_DR_SHU_EN (1U << 22)
#define R0_SC_DPHY_PRECAL_UP (1U << 23)
#define R0_SC_MPLL_S_OFF (1U << 24)
#define R0_SC_DPHY_RXDLY_TRACKING_EN (1U << 25)
#define R0_SC_PHYPLL_SHU_EN (1U << 26)
#define R0_SC_PHYPLL2_SHU_EN (1U << 27)
#define R0_SC_PHYPLL_MODE_SW (1U << 28)
#define R0_SC_PHYPLL2_MODE_SW (1U << 29)
#define R0_SC_DR_SHU_LEVEL0 (1U << 30)
#define R0_SC_DR_SHU_LEVEL1 (1U << 31)
/* --- R7 Define --- */
#define R7_PWRAP_SLEEP_REQ (1U << 0)
#define R7_EMI_CLK_OFF_REQ (1U << 1)
#define R7_PCM_BUS_PROTECT_REQ (1U << 2)
#define R7_SPM_CK_UPDATE (1U << 3)
#define R7_SPM_CK_SEL0 (1U << 4)
#define R7_SPM_CK_SEL1 (1U << 5)
#define R7_SPM_LEAVE_DEEPIDLE_REQ (1U << 6)
#define R7_SC_FHC_PAUSE_MPLL (1U << 7)
#define R7_SC_26M_CK_SEL (1U << 8)
#define R7_PCM_TIMER_SET (1U << 9)
#define R7_PCM_TIMER_CLR (1U << 10)
#define R7_SPM_LEAVE_SUSPEND_REQ (1U << 11)
#define R7_CSYSPWRUPACK (1U << 12)
#define R7_PCM_IM_SLP_EN (1U << 13)
#define R7_SRCCLKENO0 (1U << 14)
#define R7_FORCE_DDR_EN_WAKE (1U << 15)
#define R7_SPM_APSRC_INTERNAL_ACK (1U << 16)
#define R7_CPU_SYS_TIMER_CLK_SEL (1U << 17)
#define R7_SC_AXI_DCM_DIS (1U << 18)
#define R7_SC_FHC_PAUSE_MEM (1U << 19)
#define R7_SC_FHC_PAUSE_MAIN (1U << 20)
#define R7_SRCCLKENO1 (1U << 21)
#define R7_PCM_WDT_KICK_P (1U << 22)
#define R7_SPM2EMI_S1_MODE_ASYNC (1U << 23)
#define R7_SC_DDR_PST_REQ_PCM (1U << 24)
#define R7_SC_DDR_PST_ABORT_REQ_PCM (1U << 25)
#define R7_PMIC_IRQ_REQ_EN (1U << 26)
#define R7_FORCE_F26M_WAKE (1U << 27)
#define R7_FORCE_APSRC_WAKE (1U << 28)
#define R7_FORCE_INFRA_WAKE (1U << 29)
#define R7_FORCE_VRF18_WAKE (1U << 30)
#define R7_SPM_DDR_EN_INTERNAL_ACK (1U << 31)
/* --- R12 Define --- */
#define R12_PCM_TIMER (1U << 0)
#define R12_TWAM_IRQ_B (1U << 1)
#define R12_KP_IRQ_B (1U << 2)
#define R12_APWDT_EVENT_B (1U << 3)
#define R12_APXGPT1_EVENT_B (1U << 4)
#define R12_CONN2AP_SPM_WAKEUP_B (1U << 5)
#define R12_EINT_EVENT_B (1U << 6)
#define R12_CONN_WDT_IRQ_B (1U << 7)
#define R12_CCIF0_EVENT_B (1U << 8)
#define R12_LOWBATTERY_IRQ_B (1U << 9)
#define R12_SSPM2SPM_WAKEUP_B (1U << 10)
#define R12_SCP2SPM_WAKEUP_B (1U << 11)
#define R12_ADSP2SPM_WAKEUP_B (1U << 12)
#define R12_PCM_WDT_WAKEUP_B (1U << 13)
#define R12_USBX_CDSC_B (1U << 14)
#define R12_USBX_POWERDWN_B (1U << 15)
#define R12_SYS_TIMER_EVENT_B (1U << 16)
#define R12_EINT_EVENT_SECURE_B (1U << 17)
#define R12_CCIF1_EVENT_B (1U << 18)
#define R12_UART0_IRQ_B (1U << 19)
#define R12_AFE_IRQ_MCU_B (1U << 20)
#define R12_THERM_CTRL_EVENT_B (1U << 21)
#define R12_SYS_CIRQ_IRQ_B (1U << 22)
#define R12_MD2AP_PEER_EVENT_B (1U << 23)
#define R12_CSYSPWREQ_B (1U << 24)
#define R12_MD1_WDT_B (1U << 25)
#define R12_CLDMA_EVENT_B (1U << 26)
#define R12_SEJ_EVENT_B (1U << 27)
#define R12_REG_CPU_WAKEUP (1U << 28)
#define R12_APUSYS_WAKE_HOST_B (1U << 29)
#define R12_PCIE_BRIDGE_IRQ (1U << 30)
#define R12_PCIE_IRQ (1U << 31)
/* --- R12ext Define --- */
#define R12EXT_26M_WAKE (1U << 0)
#define R12EXT_26M_SLEEP (1U << 1)
#define R12EXT_INFRA_WAKE (1U << 2)
#define R12EXT_INFRA_SLEEP (1U << 3)
#define R12EXT_APSRC_WAKE (1U << 4)
#define R12EXT_APSRC_SLEEP (1U << 5)
#define R12EXT_VRF18_WAKE (1U << 6)
#define R12EXT_VRF18_SLEEP (1U << 7)
#define R12EXT_DVFS_WAKE (1U << 8)
#define R12EXT_DDREN_WAKE (1U << 9)
#define R12EXT_DDREN_SLEEP (1U << 10)
#define R12EXT_MCU_PM_WFI (1U << 11)
#define R12EXT_SSPM_IDLE (1U << 12)
#define R12EXT_CONN_SRCCLKENB (1U << 13)
#define R12EXT_DRAMC_SSPM_WFI_MERGE (1U << 14)
#define R12EXT_SW_MAILBOX_WAKE (1U << 15)
#define R12EXT_SSPM_MAILBOX_WAKE (1U << 16)
#define R12EXT_ADSP_MAILBOX_WAKE (1U << 17)
#define R12EXT_SCP_MAILBOX_WAKE (1U << 18)
#define R12EXT_SPM_LEAVE_SUSPEND_ACK (1U << 19)
#define R12EXT_SPM_LEAVE_DEEPIDLE_ACK (1U << 20)
#define R12EXT_VS1_TRIGGER (1U << 21)
#define R12EXT_VS2_TRIGGER (1U << 22)
#define R12EXT_COROSS_REQ_APU (1U << 23)
#define R12EXT_CROSS_REQ_L3 (1U << 24)
#define R12EXT_DDR_PST_ACK (1U << 25)
#define R12EXT_BIT26 (1U << 26)
#define R12EXT_BIT27 (1U << 27)
#define R12EXT_BIT28 (1U << 28)
#define R12EXT_BIT29 (1U << 29)
#define R12EXT_BIT30 (1U << 30)
#define R12EXT_BIT31 (1U << 31)
/* --- R13 Define --- */
#define R13_SRCCLKENI0 (1U << 0)
#define R13_SRCCLKENI1 (1U << 1)
#define R13_MD_SRCCLKENA_0 (1U << 2)
#define R13_MD_APSRC_REQ_0 (1U << 3)
#define R13_CONN_DDR_EN (1U << 4)
#define R13_MD_SRCCLKENA_1 (1U << 5)
#define R13_SSPM_SRCCLKENA (1U << 6)
#define R13_SSPM_APSRC_REQ (1U << 7)
#define R13_MD1_STATE (1U << 8)
#define R13_BIT9 (1U << 9)
#define R13_MM_STATE (1U << 10)
#define R13_SSPM_STATE (1U << 11)
#define R13_MD_DDR_EN_0 (1U << 12)
#define R13_CONN_STATE (1U << 13)
#define R13_CONN_SRCCLKENA (1U << 14)
#define R13_CONN_APSRC_REQ (1U << 15)
#define R13_SC_DDR_PST_ACK_ALL (1U << 16)
#define R13_SC_DDR_PST_ABORT_ACK_ALL (1U << 17)
#define R13_SCP_STATE (1U << 18)
#define R13_CSYSPWRUPREQ (1U << 19)
#define R13_PWRAP_SLEEP_ACK (1U << 20)
#define R13_SC_EMI_CLK_OFF_ACK_ALL (1U << 21)
#define R13_AUDIO_DSP_STATE (1U << 22)
#define R13_SC_DMDRAMCSHU_ACK_ALL (1U << 23)
#define R13_CONN_SRCCLKENB (1U << 24)
#define R13_SC_DR_SRAM_LOAD_ACK_ALL (1U << 25)
#define R13_SUBSYS_IDLE_SIGNALS0 (1U << 26)
#define R13_DVFS_STATE (1U << 27)
#define R13_SC_DR_SRAM_PLL_LOAD_ACK_ALL (1U << 28)
#define R13_SC_DR_SRAM_RESTORE_ACK_ALL (1U << 29)
#define R13_MD_VRF18_REQ_0 (1U << 30)
#define R13_DDR_EN_STATE (1U << 31)
#endif /* PCM_DEF_H */
/*
* Copyright (c) 2020, MediaTek Inc. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef SLEEP_DEF_H
#define SLEEP_DEF_H
/*
* Auto generated by DE, please DO NOT modify this file directly.
*/
/* --- SPM Flag Define --- */
#define SPM_FLAG_DISABLE_CPU_PDN (1U << 0)
#define SPM_FLAG_DISABLE_INFRA_PDN (1U << 1)
#define SPM_FLAG_DISABLE_DDRPHY_PDN (1U << 2)
#define SPM_FLAG_DISABLE_VCORE_DVS (1U << 3)
#define SPM_FLAG_DISABLE_VCORE_DFS (1U << 4)
#define SPM_FLAG_DISABLE_COMMON_SCENARIO (1U << 5)
#define SPM_FLAG_DISABLE_BUS_CLK_OFF (1U << 6)
#define SPM_FLAG_DISABLE_ARMPLL_OFF (1U << 7)
#define SPM_FLAG_KEEP_CSYSPWRACK_HIGH (1U << 8)
#define SPM_FLAG_ENABLE_LVTS_WORKAROUND (1U << 9)
#define SPM_FLAG_RUN_COMMON_SCENARIO (1U << 10)
#define SPM_FLAG_RESERVED_BIT11 (1U << 11)
#define SPM_FLAG_ENABLE_SPM_DBG_WDT_DUMP (1U << 12)
#define SPM_FLAG_USE_SRCCLKENO2 (1U << 13)
#define SPM_FLAG_ENABLE_6315_CTRL (1U << 14)
#define SPM_FLAG_ENABLE_TIA_WORKAROUND (1U << 15)
#define SPM_FLAG_DISABLE_SYSRAM_SLEEP (1U << 16)
#define SPM_FLAG_DISABLE_SSPM_SRAM_SLEEP (1U << 17)
#define SPM_FLAG_DISABLE_MCUPM_SRAM_SLEEP (1U << 18)
#define SPM_FLAG_ENABLE_MD_MUMTAS (1U << 19)
#define SPM_FLAG_ENABLE_VOLTAGE_BIN (1U << 20)
#define SPM_FLAG_RESERVED_BIT21 (1U << 21)
#define SPM_FLAG_DISABLE_DRAMC_MCU_SRAM_SLEEP (1U << 22)
#define SPM_FLAG_DISABLE_SRAM_EVENT (1U << 23)
#define SPM_FLAG_RESERVED_BIT24 (1U << 24)
#define SPM_FLAG_RESERVED_BIT25 (1U << 25)
#define SPM_FLAG_RESERVED_BIT26 (1U << 26)
#define SPM_FLAG_VTCXO_STATE (1U << 27)
#define SPM_FLAG_INFRA_STATE (1U << 28)
#define SPM_FLAG_APSRC_STATE (1U << 29)
#define SPM_FLAG_VRF18_STATE (1U << 30)
#define SPM_FLAG_DDREN_STATE (1U << 31)
/* --- SPM Flag1 Define --- */
#define SPM_FLAG1_DISABLE_AXI_BUS_TO_26M (1U << 0)
#define SPM_FLAG1_DISABLE_SYSPLL_OFF (1U << 1)
#define SPM_FLAG1_DISABLE_PWRAP_CLK_SWITCH (1U << 2)
#define SPM_FLAG1_DISABLE_ULPOSC_OFF (1U << 3)
#define SPM_FLAG1_FW_SET_ULPOSC_ON (1U << 4)
#define SPM_FLAG1_RESERVED_BIT5 (1U << 5)
#define SPM_FLAG1_ENABLE_REKICK (1U << 6)
#define SPM_FLAG1_DISABLE_MD26M_CK_OFF (1U << 7)
#define SPM_FLAG1_RESERVED_BIT8 (1U << 8)
#define SPM_FLAG1_RESERVED_BIT9 (1U << 9)
#define SPM_FLAG1_DISABLE_SRCLKEN_LOW (1U << 10)
#define SPM_FLAG1_DISABLE_SCP_CLK_SWITCH (1U << 11)
#define SPM_FLAG1_RESERVED_BIT12 (1U << 12)
#define SPM_FLAG1_RESERVED_BIT13 (1U << 13)
#define SPM_FLAG1_RESERVED_BIT14 (1U << 14)
#define SPM_FLAG1_RESERVED_BIT15 (1U << 15)
#define SPM_FLAG1_RESERVED_BIT16 (1U << 16)
#define SPM_FLAG1_RESERVED_BIT17 (1U << 17)
#define SPM_FLAG1_RESERVED_BIT18 (1U << 18)
#define SPM_FLAG1_RESERVED_BIT19 (1U << 19)
#define SPM_FLAG1_DISABLE_DEVAPC_SRAM_SLEEP (1U << 20)
#define SPM_FLAG1_RESERVED_BIT21 (1U << 21)
#define SPM_FLAG1_ENABLE_VS1_VOTER (1U << 22)
#define SPM_FLAG1_ENABLE_VS2_VOTER (1U << 23)
#define SPM_FLAG1_DISABLE_SCP_VREQ_MASK_CONTROL (1U << 24)
#define SPM_FLAG1_RESERVED_BIT25 (1U << 25)
#define SPM_FLAG1_RESERVED_BIT26 (1U << 26)
#define SPM_FLAG1_RESERVED_BIT27 (1U << 27)
#define SPM_FLAG1_RESERVED_BIT28 (1U << 28)
#define SPM_FLAG1_RESERVED_BIT29 (1U << 29)
#define SPM_FLAG1_RESERVED_BIT30 (1U << 30)
#define SPM_FLAG1_DISABLE_CPUEB_OFF (1U << 31)
/* --- SPM DEBUG Define --- */
#define SPM_DBG_DEBUG_IDX_26M_WAKE (1U << 0)
#define SPM_DBG_DEBUG_IDX_26M_SLEEP (1U << 1)
#define SPM_DBG_DEBUG_IDX_INFRA_WAKE (1U << 2)
#define SPM_DBG_DEBUG_IDX_INFRA_SLEEP (1U << 3)
#define SPM_DBG_DEBUG_IDX_APSRC_WAKE (1U << 4)
#define SPM_DBG_DEBUG_IDX_APSRC_SLEEP (1U << 5)
#define SPM_DBG_DEBUG_IDX_VRF18_WAKE (1U << 6)
#define SPM_DBG_DEBUG_IDX_VRF18_SLEEP (1U << 7)
#define SPM_DBG_DEBUG_IDX_DDREN_WAKE (1U << 8)
#define SPM_DBG_DEBUG_IDX_DDREN_SLEEP (1U << 9)
#define SPM_DBG_DEBUG_IDX_DRAM_SREF_ABORT_IN_APSRC (1U << 10)
#define SPM_DBG_DEBUG_IDX_MCUPM_SRAM_STATE (1U << 11)
#define SPM_DBG_DEBUG_IDX_SSPM_SRAM_STATE (1U << 12)
#define SPM_DBG_DEBUG_IDX_DRAM_SREF_ABORT_IN_DDREN (1U << 13)
#define SPM_DBG_DEBUG_IDX_DRAMC_MCU_SRAM_STATE (1U << 14)
#define SPM_DBG_DEBUG_IDX_SYSRAM_SLP (1U << 15)
#define SPM_DBG_DEBUG_IDX_SYSRAM_ON (1U << 16)
#define SPM_DBG_DEBUG_IDX_MCUPM_SRAM_SLP (1U << 17)
#define SPM_DBG_DEBUG_IDX_MCUPM_SRAM_ON (1U << 18)
#define SPM_DBG_DEBUG_IDX_SSPM_SRAM_SLP (1U << 19)
#define SPM_DBG_DEBUG_IDX_SSPM_SRAM_ON (1U << 20)
#define SPM_DBG_DEBUG_IDX_DRAMC_MCU_SRAM_SLP (1U << 21)
#define SPM_DBG_DEBUG_IDX_DRAMC_MCU_SRAM_ON (1U << 22)
#define SPM_DBG_DEBUG_IDX_SCP_VCORE_0P575V (1U << 23)
#define SPM_DBG_DEBUG_IDX_SCP_VCORE_0P600V (1U << 24)
#define SPM_DBG_DEBUG_IDX_SCP_VCORE_0P650V (1U << 25)
#define SPM_DBG_DEBUG_IDX_SCP_VCORE_0P725V (1U << 26)
#define SPM_DBG_DEBUG_IDX_SPM_GO_WAKEUP_NOW (1U << 27)
#define SPM_DBG_DEBUG_IDX_VTCXO_STATE (1U << 28)
#define SPM_DBG_DEBUG_IDX_INFRA_STATE (1U << 29)
#define SPM_DBG_DEBUG_IDX_VRR18_STATE (1U << 30)
#define SPM_DBG_DEBUG_IDX_APSRC_STATE (1U << 31)
/* --- SPM DEBUG1 Define --- */
#define SPM_DBG1_DEBUG_IDX_CURRENT_IS_LP (1U << 0)
#define SPM_DBG1_DEBUG_IDX_VCORE_DVFS_START (1U << 1)
#define SPM_DBG1_DEBUG_IDX_SYSPLL_OFF (1U << 2)
#define SPM_DBG1_DEBUG_IDX_SYSPLL_ON (1U << 3)
#define SPM_DBG1_DEBUG_IDX_CURRENT_IS_VCORE_DVFS (1U << 4)
#define SPM_DBG1_DEBUG_IDX_INFRA_MTCMOS_OFF (1U << 5)
#define SPM_DBG1_DEBUG_IDX_INFRA_MTCMOS_ON (1U << 6)
#define SPM_DBG1_DEBUG_IDX_VRCXO_SLEEP_ABORT (1U << 7)
#define SPM_DBG1_RESERVED_BIT8 (1U << 8)
#define SPM_DBG1_DEBUG_IDX_INFRA_SUB_MTCMOS_OFF (1U << 9)
#define SPM_DBG1_DEBUG_IDX_INFRA_SUB_MTCMOS_ON (1U << 10)
#define SPM_DBG1_DEBUG_IDX_PWRAP_CLK_TO_ULPOSC (1U << 11)
#define SPM_DBG1_DEBUG_IDX_PWRAP_CLK_TO_26M (1U << 12)
#define SPM_DBG1_DEBUG_IDX_SCP_CLK_TO_32K (1U << 13)
#define SPM_DBG1_DEBUG_IDX_SCP_CLK_TO_26M (1U << 14)
#define SPM_DBG1_DEBUG_IDX_BUS_CLK_OFF (1U << 15)
#define SPM_DBG1_DEBUG_IDX_BUS_CLK_ON (1U << 16)
#define SPM_DBG1_DEBUG_IDX_SRCLKEN2_LOW (1U << 17)
#define SPM_DBG1_DEBUG_IDX_SRCLKEN2_HIGH (1U << 18)
#define SPM_DBG1_RESERVED_BIT19 (1U << 19)
#define SPM_DBG1_DEBUG_IDX_ULPOSC_IS_OFF_BUT_SHOULD_ON (1U << 20)
#define SPM_DBG1_DEBUG_IDX_6315_LOW (1U << 21)
#define SPM_DBG1_DEBUG_IDX_6315_HIGH (1U << 22)
#define SPM_DBG1_DEBUG_IDX_PWRAP_SLEEP_ACK_LOW_ABORT (1U << 23)
#define SPM_DBG1_DEBUG_IDX_PWRAP_SLEEP_ACK_HIGH_ABORT (1U << 24)
#define SPM_DBG1_DEBUG_IDX_EMI_SLP_IDLE_ABORT (1U << 25)
#define SPM_DBG1_DEBUG_IDX_SCP_SLP_ACK_LOW_ABORT (1U << 26)
#define SPM_DBG1_DEBUG_IDX_SCP_SLP_ACK_HIGH_ABORT (1U << 27)
#define SPM_DBG1_DEBUG_IDX_SPM_DVFS_CMD_RDY_ABORT (1U << 28)
#define SPM_DBG1_RESERVED_BIT29 (1U << 29)
#define SPM_DBG1_RESERVED_BIT30 (1U << 30)
#define SPM_DBG1_DEBUG_DISABLE_CPUEB_OFF (1U << 31)
/* Macro and Inline */
#define is_cpu_pdn(flags) (((flags) & SPM_FLAG_DISABLE_CPU_PDN) == 0U)
#define is_infra_pdn(flags) (((flags) & SPM_FLAG_DISABLE_INFRA_PDN) == 0U)
#define is_ddrphy_pdn(flags) (((flags) & SPM_FLAG_DISABLE_DDRPHY_PDN) == 0U)
#endif /* SLEEP_DEF_H */
......@@ -10,7 +10,7 @@
#include <lib/psci/psci.h>
#include <lib/utils_def.h>
#define MT_IRQ_REMAIN_MAX U(8)
#define MT_IRQ_REMAIN_MAX U(32)
#define MT_IRQ_REMAIN_CAT_LOG BIT(31)
struct mt_irqremain {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment