soc/mediatek/common: Update SPMI calibration process
The original SPMI calibration process is only suitable for pre-MT8189 SoCs. Update the flow to also support MT8189. BUG=b:379008996 BRANCH=none TEST=build pass and driver log is normal: [INFO ] [Pass] dly:1, pol:0, sampl:0x2 [INFO ] [Pass] dly:1, pol:0, sampl:0x2 Signed-off-by: Zhigang Qin <zhigang.qin@mediatek.corp-partner.google.com> Change-Id: I636b3062fc25fc1d7d39e3426602e6434be4c26a Reviewed-on: https://review.coreboot.org/c/coreboot/+/87508 Reviewed-by: Yidi Lin <yidilin@google.com> Reviewed-by: Yu-Ping Wu <yupingso@google.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
parent
f83fb11e5f
commit
e99532d99b
1 changed files with 20 additions and 17 deletions
|
|
@ -48,37 +48,40 @@ static int spmi_read_check(struct pmif *pmif_arb, int slvid)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int spmi_cali_rd_clock_polarity(struct pmif *pmif_arb, const struct spmi_device *dev)
|
||||
static int spmi_cali_rd_clock_polarity(struct pmif *pmif_arb)
|
||||
{
|
||||
int i;
|
||||
bool success = false;
|
||||
int i, j;
|
||||
const struct cali cali_data[] = {
|
||||
{SPMI_CK_DLY_1T, SPMI_CK_POL_NEG},
|
||||
{SPMI_CK_DLY_1T, SPMI_CK_POL_POS},
|
||||
{SPMI_CK_NO_DLY, SPMI_CK_POL_POS},
|
||||
{SPMI_CK_NO_DLY, SPMI_CK_POL_NEG},
|
||||
{SPMI_CK_DLY_1T, SPMI_CK_POL_NEG},
|
||||
};
|
||||
|
||||
/* Indicate sampling clock polarity, 1: Positive 0: Negative */
|
||||
for (i = 0; i < ARRAY_SIZE(cali_data); i++) {
|
||||
SET32_BITFIELDS(&mtk_spmi_mst->mst_sampl, SAMPL_CK_DLY, cali_data[i].dly,
|
||||
SAMPL_CK_POL, cali_data[i].pol);
|
||||
if (spmi_read_check(pmif_arb, dev->slvid) == 0) {
|
||||
success = true;
|
||||
break;
|
||||
bool success = true;
|
||||
SET32_BITFIELDS(&mtk_spmi_mst->mst_sampl, SAMPL_CK_DLY,
|
||||
cali_data[i].dly, SAMPL_CK_POL, cali_data[i].pol);
|
||||
for (j = 0; j < spmi_dev_cnt; j++) {
|
||||
if (spmi_read_check(pmif_arb, spmi_dev[j].slvid) != 0) {
|
||||
success = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (success) {
|
||||
printk(BIOS_INFO, "calibration success for spmi clk: "
|
||||
"cali_data[%d] dly = %u, pol = %u\n",
|
||||
i, cali_data[i].dly, cali_data[i].pol);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (!success)
|
||||
die("ERROR - calibration fail for spmi clk");
|
||||
|
||||
return 0;
|
||||
return -E_NODEV;
|
||||
}
|
||||
|
||||
static int spmi_mst_init(struct pmif *pmif_arb)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
if (!pmif_arb) {
|
||||
printk(BIOS_ERR, "%s: null pointer for pmif dev.\n", __func__);
|
||||
return -E_INVAL;
|
||||
|
|
@ -88,8 +91,8 @@ static int spmi_mst_init(struct pmif *pmif_arb)
|
|||
pmif_spmi_iocfg();
|
||||
spmi_config_master();
|
||||
|
||||
for (i = 0; i < spmi_dev_cnt; i++)
|
||||
spmi_cali_rd_clock_polarity(pmif_arb, &spmi_dev[i]);
|
||||
if (spmi_cali_rd_clock_polarity(pmif_arb) != 0)
|
||||
die("ERROR - calibration fail for spmi clk");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue