Hung-Te Lin has submitted this change. ( https://review.coreboot.org/c/coreboot/+/48954 )
Change subject: soc/mediatek/mt8192: pmic: unlock key protection before initial setting ......................................................................
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 hsin-hsiung.wang@mediatek.com Change-Id: I593d4e02bf0b62ac297957caf4ae1c1837f1f38d Reviewed-on: https://review.coreboot.org/c/coreboot/+/48954 Tested-by: build bot (Jenkins) no-reply@coreboot.org Reviewed-by: Hung-Te Lin hungte@chromium.org Reviewed-by: Yu-Ping Wu yupingso@google.com --- M src/soc/mediatek/mt8192/mt6359p.c 1 file changed, 20 insertions(+), 0 deletions(-)
Approvals: build bot (Jenkins): Verified Hung-Te Lin: Looks good to me, approved Yu-Ping Wu: Looks good to me, approved
diff --git a/src/soc/mediatek/mt8192/mt6359p.c b/src/soc/mediatek/mt8192/mt6359p.c index df8eb39..c93b66a 100644 --- a/src/soc/mediatek/mt8192/mt6359p.c +++ b/src/soc/mediatek/mt8192/mt6359p.c @@ -6,6 +6,17 @@ #include <soc/pmif.h> #include <soc/mt6359p.h>
+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 @@ 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 @@ 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(); }