hsin-hsiung wang has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/48954 )
Change subject: WIP: soc/mediatek/mt8192: Unlock key protection before initial setting ......................................................................
WIP: soc/mediatek/mt8192: Unlock key protection before initial setting
We need unlock key protection so that some initial settings could be effective. After applying initial settings, we would enable the key protection again.
BUG=b:172636735 BRANCH=none TEST=boot asurada correctly
Signed-off-by: Hsin-Hsiung Wang hsin-hsiung.wang@mediatek.com Change-Id: I593d4e02bf0b62ac297957caf4ae1c1837f1f38d --- M src/soc/mediatek/mt8192/mt6359p.c 1 file changed, 33 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/54/48954/1
diff --git a/src/soc/mediatek/mt8192/mt6359p.c b/src/soc/mediatek/mt8192/mt6359p.c index a8e93ca..e6e9d36 100644 --- a/src/soc/mediatek/mt8192/mt6359p.c +++ b/src/soc/mediatek/mt8192/mt6359p.c @@ -6,6 +6,25 @@ #include <soc/pmif.h> #include <soc/mt6359p.h>
+static const struct pmic_setting lock_key_setting[] = { + /* MT6359_TOP_TMA_KEY[0x3A8], for dram */ + {0x3A8, 0x9CA6, 0xFFFF, 0}, + /* MT6359_SPISLV_KEY[0x44A], for spi */ + {0x44A, 0xBADE, 0xFFFF, 0}, + /* MT6359_CPSWKEY[0xA3A], for power-off seq. */ + {0xA3A, 0x4729, 0xFFFF, 0}, + /* MT6359_BM_WKEY0[0xC58], for fuel gauge adc */ + {0xC58, 0x1605, 0xFFFF, 0}, + /* MT6359_BM_WKEY1[0xC5A], for battery temp adc */ + {0xC5A, 0x1706, 0xFFFF, 0}, + /* MT6359_BM_WKEY2[0xC5C], for bif */ + {0xC5C, 0x1807, 0xFFFF, 0}, + /* MT6359_HK_TOP_WKEY[0xFB4], for auxadc */ + {0xFB4, 0x6359, 0xFFFF, 0}, + /* MT6359_BUCK_TOP_KEY_PROT[0x1432], for buck */ + {0x1432, 0x5543, 0xFFFF, 0}, +}; + static const struct pmic_setting init_setting[] = { {0x20, 0xA, 0xA, 0}, {0x24, 0x1F00, 0x1F00, 0}, @@ -306,6 +325,18 @@ mt6359p_write_field(PMIC_TOP_RST_MISC_SET, 0x01, 0xFFFF, 0); }
+ +static void pmic_protect_key_set(bool lock) +{ + if (lock) { + for (int i = 0; i < ARRAY_SIZE(lock_key_setting); i++) + mt6359p_write(lock_key_setting[i].addr, 0); + } else { + for (int i = 0; i < ARRAY_SIZE(lock_key_setting); i++) + mt6359p_write(lock_key_setting[i].addr, lock_key_setting[i].val); + } +} + static void pmic_init_setting(void) { for (int i = 0; i < ARRAY_SIZE(init_setting); i++) @@ -437,8 +468,10 @@ init_pmif_arb(); pmic_set_power_hold(); pmic_wdt_set(); + pmic_protect_key_set(false); pmic_init_setting(); pmic_lp_setting(); + pmic_protect_key_set(true); pmic_wk_vs2_voter_setting(); }