diff --git a/src/soc/mediatek/common/include/soc/pmif_spmi.h b/src/soc/mediatek/common/include/soc/pmif_spmi.h index 2160e9edca..cdb84c6a7c 100644 --- a/src/soc/mediatek/common/include/soc/pmif_spmi.h +++ b/src/soc/mediatek/common/include/soc/pmif_spmi.h @@ -96,4 +96,6 @@ int spmi_config_master(void); size_t spmi_dev_cnt(void); void pmif_spmi_iocfg(void); void pmif_spmi_config(struct pmif *arb); +void pmif_spmi_force_normal_mode(struct pmif *arb); + #endif /* __SOC_MEDIATEK_PMIF_SPMI_H__ */ diff --git a/src/soc/mediatek/common/pmif_spmi.c b/src/soc/mediatek/common/pmif_spmi.c index b39103aa4a..d6318eaa8c 100644 --- a/src/soc/mediatek/common/pmif_spmi.c +++ b/src/soc/mediatek/common/pmif_spmi.c @@ -12,16 +12,6 @@ DEFINE_BIT(SAMPL_CK_POL, 0) DEFINE_BITFIELD(SAMPL_CK_DLY, 3, 1) -/* PMIF, SPI_MODE_CTRL */ -DEFINE_BIT(SPI_MODE_CTRL, 7) -DEFINE_BIT(SRVOL_EN, 11) -DEFINE_BIT(SPI_MODE_EXT_CMD, 12) -DEFINE_BIT(SPI_EINT_MODE_GATING_EN, 13) - -/* PMIF, SLEEP_PROTECTION_CTRL */ -DEFINE_BITFIELD(SPM_SLEEP_REQ_SEL, 1, 0) -DEFINE_BITFIELD(SCP_SLEEP_REQ_SEL, 10, 9) - __weak void pmif_spmi_config(struct pmif *arb) { /* Do nothing. */ @@ -97,20 +87,6 @@ static int spmi_mst_init(struct pmif *pmif_arb) return 0; } -static void pmif_spmi_force_normal_mode(struct pmif *arb) -{ - /* listen srclken_0 only for entering normal or sleep mode */ - SET32_BITFIELDS(&arb->mtk_pmif->spi_mode_ctrl, - SPI_MODE_CTRL, 0, - SRVOL_EN, 0, - SPI_MODE_EXT_CMD, 1, - SPI_EINT_MODE_GATING_EN, 1); - - /* enable spm/scp sleep request */ - SET32_BITFIELDS(&arb->mtk_pmif->sleep_protection_ctrl, SPM_SLEEP_REQ_SEL, 0, - SCP_SLEEP_REQ_SEL, 0); -} - static void pmif_spmi_enable_swinf(struct pmif *arb) { write32(&arb->mtk_pmif->inf_en, PMIF_SPMI_SW_CHAN); diff --git a/src/soc/mediatek/common/pmif_spmi_v1.c b/src/soc/mediatek/common/pmif_spmi_v1.c new file mode 100644 index 0000000000..2069b604fe --- /dev/null +++ b/src/soc/mediatek/common/pmif_spmi_v1.c @@ -0,0 +1,29 @@ +/* SPDX-License-Identifier: GPL-2.0-only OR MIT */ + +#include +#include +#include + +/* PMIF, SPI_MODE_CTRL */ +DEFINE_BIT(SPI_MODE_CTRL, 7) +DEFINE_BIT(SRVOL_EN, 11) +DEFINE_BIT(SPI_MODE_EXT_CMD, 12) +DEFINE_BIT(SPI_EINT_MODE_GATING_EN, 13) + +/* PMIF, SLEEP_PROTECTION_CTRL */ +DEFINE_BITFIELD(SPM_SLEEP_REQ_SEL, 1, 0) +DEFINE_BITFIELD(SCP_SLEEP_REQ_SEL, 10, 9) + +void pmif_spmi_force_normal_mode(struct pmif *arb) +{ + /* listen srclken_0 only for entering normal or sleep mode */ + SET32_BITFIELDS(&arb->mtk_pmif->spi_mode_ctrl, + SPI_MODE_CTRL, 0, + SRVOL_EN, 0, + SPI_MODE_EXT_CMD, 1, + SPI_EINT_MODE_GATING_EN, 1); + + /* enable spm/scp sleep request */ + SET32_BITFIELDS(&arb->mtk_pmif->sleep_protection_ctrl, SPM_SLEEP_REQ_SEL, 0, + SCP_SLEEP_REQ_SEL, 0); +} diff --git a/src/soc/mediatek/common/pmif_spmi_v2.c b/src/soc/mediatek/common/pmif_spmi_v2.c new file mode 100644 index 0000000000..54ef132d33 --- /dev/null +++ b/src/soc/mediatek/common/pmif_spmi_v2.c @@ -0,0 +1,31 @@ +/* SPDX-License-Identifier: GPL-2.0-only OR MIT */ + +#include +#include +#include +#include + +/* PMIF, SPI_MODE_CTRL */ +DEFINE_BIT(VLD_SRCLK_EN_CTRL, 5) +DEFINE_BIT(SPI_MODE_CTRL_PMIF_RDY, 9) +DEFINE_BIT(SPI_MODE_CTRL_SRCLK_EN, 10) +DEFINE_BIT(SPI_MODE_CTRL_SRVOL_EN, 11) + +/* PMIF, SLEEP_PROTECTION_CTRL */ +DEFINE_BIT(SPM_SLEEP_REQ_SEL, 0) +DEFINE_BIT(SCP_SLEEP_REQ_SEL, 9) + +void pmif_spmi_force_normal_mode(struct pmif *arb) +{ + /* listen srclken_0 only for entering normal or sleep mode */ + SET32_BITFIELDS(&arb->mtk_pmif->spi_mode_ctrl, + VLD_SRCLK_EN_CTRL, 0, + SPI_MODE_CTRL_PMIF_RDY, 1, + SPI_MODE_CTRL_SRCLK_EN, 0, + SPI_MODE_CTRL_SRVOL_EN, 0); + + /* disable spm/scp sleep request */ + SET32_BITFIELDS(&arb->mtk_pmif->sleep_protection_ctrl, SPM_SLEEP_REQ_SEL, 1, + SCP_SLEEP_REQ_SEL, 1); + printk(BIOS_INFO, "%s done\n", __func__); +} diff --git a/src/soc/mediatek/mt8186/Makefile.mk b/src/soc/mediatek/mt8186/Makefile.mk index 4e0526c0e5..4ed3db42fc 100644 --- a/src/soc/mediatek/mt8186/Makefile.mk +++ b/src/soc/mediatek/mt8186/Makefile.mk @@ -30,7 +30,7 @@ romstage-y += ../common/mmu_operations.c ../common/mmu_cmops.c romstage-y += ../common/mt6315.c mt6315.c romstage-y += ../common/pmic_wrap.c pmic_wrap.c pmif.c mt6366.c romstage-y += ../common/pmif.c ../common/pmif_clk.c ../common/pmif_init.c pmif_clk.c -romstage-y += ../common/pmif_spmi.c pmif_spmi.c +romstage-y += ../common/pmif_spmi.c ../common/pmif_spmi_v1.c pmif_spmi.c romstage-y += ../common/rtc.c ../common/rtc_pwrap_ops.c ../common/rtc_osc_init.c rtc.c ramstage-y += adsp.c diff --git a/src/soc/mediatek/mt8188/Makefile.mk b/src/soc/mediatek/mt8188/Makefile.mk index 0cd05b94ce..33b41835fb 100644 --- a/src/soc/mediatek/mt8188/Makefile.mk +++ b/src/soc/mediatek/mt8188/Makefile.mk @@ -29,7 +29,7 @@ romstage-y += ../common/mt6315.c mt6315.c romstage-y += ../common/mt6359p.c mt6359p.c romstage-y += ../common/pmif.c ../common/pmif_clk.c ../common/pmif_init.c pmif_clk.c romstage-y += ../common/pmif_spi.c pmif_spi.c -romstage-y += ../common/pmif_spmi.c pmif_spmi.c +romstage-y += ../common/pmif_spmi.c ../common/pmif_spmi_v1.c pmif_spmi.c romstage-y += ../common/rtc.c ../common/rtc_osc_init.c ../common/rtc_mt6359p.c ramstage-y += ../common/auxadc.c @@ -56,7 +56,7 @@ ramstage-y += ../common/mt6359p.c mt6359p.c ramstage-y += ../common/mtcmos.c mtcmos.c ramstage-y += ../common/pmif.c ../common/pmif_clk.c ../common/pmif_init.c pmif_clk.c ramstage-y += ../common/pmif_spi.c pmif_spi.c -ramstage-y += ../common/pmif_spmi.c pmif_spmi.c +ramstage-y += ../common/pmif_spmi.c ../common/pmif_spmi_v1.c pmif_spmi.c ramstage-y += ../common/rtc.c ../common/rtc_osc_init.c ../common/rtc_mt6359p.c ramstage-y += soc.c ramstage-y += ../common/spm.c ../common/spm_v1.c spm.c diff --git a/src/soc/mediatek/mt8189/Makefile.mk b/src/soc/mediatek/mt8189/Makefile.mk index 50c576b4f1..077ee13533 100644 --- a/src/soc/mediatek/mt8189/Makefile.mk +++ b/src/soc/mediatek/mt8189/Makefile.mk @@ -28,7 +28,7 @@ romstage-y += ../common/mt6315.c mt6315.c romstage-y += ../common/mt6359p.c mt6359p.c romstage-y += ../common/pmif.c ../common/pmif_clk.c ../common/pmif_init.c pmif_clk.c romstage-y += ../common/pmif_spi.c pmif_spi.c -romstage-y += ../common/pmif_spmi.c pmif_spmi.c +romstage-y += ../common/pmif_spmi.c ../common/pmif_spmi_v1.c pmif_spmi.c romstage-y += ../common/rtc.c ../common/rtc_osc_init.c ../common/rtc_mt6359p.c ramstage-y += ../common/auxadc.c @@ -51,7 +51,7 @@ ramstage-y += ../common/mtcmos.c mtcmos.c ramstage-y += ../common/mtk_fsp.c ramstage-y += ../common/pmif.c ../common/pmif_clk.c ../common/pmif_init.c pmif_clk.c ramstage-y += ../common/pmif_spi.c pmif_spi.c -ramstage-y += ../common/pmif_spmi.c pmif_spmi.c +ramstage-y += ../common/pmif_spmi.c ../common/pmif_spmi_v1.c pmif_spmi.c ramstage-y += ../common/rtc.c ../common/rtc_mt6359p.c ../common/rtc_osc_init.c ramstage-y += soc.c ramstage-y += ../common/spm.c ../common/spm_v2.c spm.c diff --git a/src/soc/mediatek/mt8192/Makefile.mk b/src/soc/mediatek/mt8192/Makefile.mk index a92584da0b..7b88100478 100644 --- a/src/soc/mediatek/mt8192/Makefile.mk +++ b/src/soc/mediatek/mt8192/Makefile.mk @@ -27,7 +27,7 @@ romstage-y += ../common/mmu_operations.c ../common/mmu_cmops.c romstage-y += ../common/pll.c pll.c romstage-y += ../common/pmif.c ../common/pmif_clk.c ../common/pmif_init.c pmif_clk.c romstage-y += ../common/pmif_spi.c pmif_spi.c -romstage-y += ../common/pmif_spmi.c pmif_spmi.c +romstage-y += ../common/pmif_spmi.c ../common/pmif_spmi_v1.c pmif_spmi.c romstage-y += ../common/mt6315.c mt6315.c romstage-y += ../common/mt6359p.c mt6359p.c romstage-y += ../common/rtc.c ../common/rtc_osc_init.c ../common/rtc_mt6359p.c diff --git a/src/soc/mediatek/mt8195/Makefile.mk b/src/soc/mediatek/mt8195/Makefile.mk index 1f26419f02..bcbeb128db 100644 --- a/src/soc/mediatek/mt8195/Makefile.mk +++ b/src/soc/mediatek/mt8195/Makefile.mk @@ -31,7 +31,7 @@ romstage-y += ../common/pll.c pll.c romstage-y += scp.c romstage-y += ../common/pmif.c ../common/pmif_clk.c ../common/pmif_init.c pmif_clk.c romstage-y += ../common/pmif_spi.c pmif_spi.c -romstage-y += ../common/pmif_spmi.c pmif_spmi.c +romstage-y += ../common/pmif_spmi.c ../common/pmif_spmi_v1.c pmif_spmi.c romstage-y += ../common/mt6315.c mt6315.c romstage-y += ../common/mt6359p.c mt6359p.c romstage-y += mt6360.c diff --git a/src/soc/mediatek/mt8196/Makefile.mk b/src/soc/mediatek/mt8196/Makefile.mk index 3d8e50baa7..ea691e391b 100644 --- a/src/soc/mediatek/mt8196/Makefile.mk +++ b/src/soc/mediatek/mt8196/Makefile.mk @@ -49,7 +49,7 @@ romstage-y += pwrsel.c romstage-y += ../common/pmif_clk.c pmif_clk.c romstage-y += ../common/pmif.c pmif_init.c romstage-y += ../common/rtc.c ../common/rtc_osc_init.c -romstage-y += pmif_spmi.c +romstage-y += ../common/pmif_spmi_v2.c pmif_spmi.c romstage-y += srclken_rc.c romstage-y += thermal.c romstage-y += thermal_sram.c @@ -85,7 +85,7 @@ ramstage-y += ../common/spm.c ../common/spm_v2.c spm.c ramstage-y += ../common/sspm.c ../common/sspm_sram.c ramstage-y += ../common/pmif_clk.c pmif_clk.c ramstage-y += ../common/pmif.c pmif_init.c -ramstage-y += pmif_spmi.c +ramstage-y += ../common/pmif_spmi_v2.c pmif_spmi.c ramstage-y += ../common/rtc.c ../common/rtc_osc_init.c ramstage-y += ../common/usb.c usb.c diff --git a/src/soc/mediatek/mt8196/pmif_spmi.c b/src/soc/mediatek/mt8196/pmif_spmi.c index 8baff6ac99..5b395e3c23 100644 --- a/src/soc/mediatek/mt8196/pmif_spmi.c +++ b/src/soc/mediatek/mt8196/pmif_spmi.c @@ -24,16 +24,6 @@ DEFINE_BIT(SAMPL_CK_POL, 0) DEFINE_BITFIELD(SAMPL_CK_DLY, 3, 1) DEFINE_BITFIELD(SAMPL_CK_DLY_ARB, 6, 4) -/* PMIF, SPI_MODE_CTRL */ -DEFINE_BIT(VLD_SRCLK_EN_CTRL, 5) -DEFINE_BIT(SPI_MODE_CTRL_PMIF_RDY, 9) -DEFINE_BIT(SPI_MODE_CTRL_SRCLK_EN, 10) -DEFINE_BIT(SPI_MODE_CTRL_SRVOL_EN, 11) - -/* PMIF, SLEEP_PROTECTION_CTRL */ -DEFINE_BIT(SPM_SLEEP_REQ_SEL, 0) -DEFINE_BIT(SCP_SLEEP_REQ_SEL, 9) - const struct spmi_device spmi_dev[] = { { .slvid = SPMI_SLAVE_4, /* MT6363 */ @@ -264,21 +254,6 @@ static int spmi_mst_init(struct pmif *arb) return 0; } -static void pmif_spmi_force_normal_mode(struct pmif *arb) -{ - /* listen srclken_0 only for entering normal or sleep mode */ - SET32_BITFIELDS(&arb->mtk_pmif->spi_mode_ctrl, - VLD_SRCLK_EN_CTRL, 0, - SPI_MODE_CTRL_PMIF_RDY, 1, - SPI_MODE_CTRL_SRCLK_EN, 0, - SPI_MODE_CTRL_SRVOL_EN, 0); - - /* disable spm/scp sleep request */ - SET32_BITFIELDS(&arb->mtk_pmif->sleep_protection_ctrl, SPM_SLEEP_REQ_SEL, 1, - SCP_SLEEP_REQ_SEL, 1); - printk(BIOS_INFO, "%s done\n", __func__); -} - static void pmif_spmi_enable_swinf(struct pmif *arb) { write32(&arb->mtk_pmif->inf_en, PMIF_SPMI_SW_CHAN);