From 2fc597674039e53c3396ff82f3f26e9d2d2e656f Mon Sep 17 00:00:00 2001 From: Hsin-Hsiung Wang Date: Mon, 28 Dec 2020 21:31:30 +0800 Subject: soc/mediatek/mt8192: pmic: unlock key protection before initial setting We need to write some special values to key protection registers before applying init_setting table and lp_setting table to PMIC. Otherwise, those settings won't take effect. After applying init_setting table and lp_setting table, we lock the settings by writing zero to key protection registers. Reference datasheet: MT6359_PMIC_Data_Sheet_V1.5.docx, RH-D-2018-0205. BUG=b:172636735 BRANCH=none TEST=boot asurada correctly Signed-off-by: Hsin-Hsiung Wang Change-Id: I593d4e02bf0b62ac297957caf4ae1c1837f1f38d Reviewed-on: https://review.coreboot.org/c/coreboot/+/48954 Tested-by: build bot (Jenkins) Reviewed-by: Hung-Te Lin Reviewed-by: Yu-Ping Wu --- src/soc/mediatek/mt8192/mt6359p.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src') diff --git a/src/soc/mediatek/mt8192/mt6359p.c b/src/soc/mediatek/mt8192/mt6359p.c index df8eb39e76..c93b66a426 100644 --- a/src/soc/mediatek/mt8192/mt6359p.c +++ b/src/soc/mediatek/mt8192/mt6359p.c @@ -6,6 +6,17 @@ #include #include +static const struct pmic_setting key_protect_setting[] = { + {0x3A8, 0x9CA6, 0xFFFF, 0}, + {0x44A, 0xBADE, 0xFFFF, 0}, + {0xA3A, 0x4729, 0xFFFF, 0}, + {0xC58, 0x1605, 0xFFFF, 0}, + {0xC5A, 0x1706, 0xFFFF, 0}, + {0xC5C, 0x1807, 0xFFFF, 0}, + {0xFB4, 0x6359, 0xFFFF, 0}, + {0x1432, 0x5543, 0xFFFF, 0}, +}; + static const struct pmic_setting init_setting[] = { {0x20, 0xA, 0xA, 0}, {0x24, 0x1F00, 0x1F00, 0}, @@ -318,6 +329,13 @@ static void pmic_wdt_set(void) mt6359p_write_field(PMIC_TOP_RST_MISC_SET, 0x01, 0xFFFF, 0); } +static void pmic_protect_key_setting(bool lock) +{ + for (int i = 0; i < ARRAY_SIZE(key_protect_setting); i++) + mt6359p_write(key_protect_setting[i].addr, + lock ? 0 : key_protect_setting[i].val); +} + static void pmic_init_setting(void) { for (int i = 0; i < ARRAY_SIZE(init_setting); i++) @@ -449,8 +467,10 @@ void mt6359p_init(void) init_pmif_arb(); pmic_set_power_hold(); pmic_wdt_set(); + pmic_protect_key_setting(false); pmic_init_setting(); pmic_lp_setting(); + pmic_protect_key_setting(true); pmic_wk_vs2_voter_setting(); } -- cgit v1.2.3