Skip to content

Commit

Permalink
QcomModulePkg: Skip current pmic-id selection in case of none match
Browse files Browse the repository at this point in the history
In case pmic-id property is defined for one of the platform
variant and none of the pmic is matches NONE_MATCH bit get set
in DtMatchVal. DtMatchVal with NONE_MATCH is greater
than DtMatchVal for dtb with no pmic-id field defined.
pmic-id with NONE_MATCH should not be picked.
Also, in case pmic revision is none match skip the current
pmic-id.

Change-Id: Ia96bc2ecb7c0b542d6cd8b21710e0f2d96496ed9
  • Loading branch information
Mayank Grover committed May 10, 2021
1 parent 1259da7 commit b007693
Showing 1 changed file with 19 additions and 13 deletions.
32 changes: 19 additions & 13 deletions QcomModulePkg/Library/BootLib/LocateDeviceTree.c
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,8 @@ ReadBestPmicMatch (CONST CHAR8 *PmicProp, INT32 PmicMaxIdx,
UINT32 Idx;
PmicIdInfo CurPmicInfo;

memset (BestPmicInfo, 0, sizeof (PmicIdInfo));
/* Initialize with NONE_MATCH */
BestPmicInfo->DtMatchVal = BIT (NONE_MATCH);
for (PmicEntIdx = 0; PmicEntIdx < PmicEntCount; PmicEntIdx++) {
memset (&CurPmicInfo, 0, sizeof (PmicIdInfo));
for (Idx = 0; Idx < PmicMaxIdx; Idx++) {
Expand All @@ -572,8 +573,8 @@ ReadBestPmicMatch (CONST CHAR8 *PmicProp, INT32 PmicMaxIdx,
BIT ((PMIC_MATCH_DEFAULT_MODEL_IDX0 + Idx * PMIC_SHIFT_IDX));
} else {
CurPmicInfo.DtMatchVal = BIT (NONE_MATCH);
DEBUG ((EFI_D_VERBOSE, "Pmic model does not match\n"));
break;
DEBUG ((EFI_D_VERBOSE, "Pmic model does not match Idx(%u)\n", Idx));
goto next;
}

/* first match the first four pmic revision */
Expand All @@ -588,7 +589,7 @@ ReadBestPmicMatch (CONST CHAR8 *PmicProp, INT32 PmicMaxIdx,
Idx * PMIC_SHIFT_IDX));
} else {
DEBUG ((EFI_D_VERBOSE, "Pmic revision does not match\n"));
break;
goto next;
}
}
}
Expand All @@ -607,7 +608,7 @@ ReadBestPmicMatch (CONST CHAR8 *PmicProp, INT32 PmicMaxIdx,
}
}
}

next:
PmicProp += sizeof (UINT32) * PmicMaxIdx;
}
}
Expand Down Expand Up @@ -892,15 +893,20 @@ ReadDtbFindMatch (DtInfo *CurDtbInfo, DtInfo *BestDtbInfo, UINT32 ExactMatch)
PmicEntCount = LenPmicId / PmicEntSz;
/* Get the best match pmic */
ReadBestPmicMatch (PmicProp, PmicMaxIdx, PmicEntCount, &BestPmicInfo);
CurDtbInfo->DtMatchVal |= BestPmicInfo.DtMatchVal;
for (Idx = 0; Idx < PmicMaxIdx; Idx++) {
CurDtbInfo->DtPmicModel[Idx] = BestPmicInfo.DtPmicModel[Idx];
CurDtbInfo->DtPmicRev[Idx] = BestPmicInfo.DtPmicRev[Idx];
}
if (BestPmicInfo.DtMatchVal == BIT (NONE_MATCH)) {
CurDtbInfo->DtMatchVal = NONE_MATCH;
} else {
CurDtbInfo->DtMatchVal |= BestPmicInfo.DtMatchVal;

DEBUG ((EFI_D_VERBOSE, "CurDtbInfo->DtMatchVal : 0x%llx "
"BestPmicInfo.DtMatchVal :0x%llx\n", CurDtbInfo->DtMatchVal,
BestPmicInfo.DtMatchVal));
for (Idx = 0; Idx < PmicMaxIdx; Idx++) {
CurDtbInfo->DtPmicModel[Idx] = BestPmicInfo.DtPmicModel[Idx];
CurDtbInfo->DtPmicRev[Idx] = BestPmicInfo.DtPmicRev[Idx];
}

DEBUG ((EFI_D_VERBOSE, "CurDtbInfo->DtMatchVal : 0x%llx "
"BestPmicInfo.DtMatchVal :0x%llx\n", CurDtbInfo->DtMatchVal,
BestPmicInfo.DtMatchVal));
}
} else {
DEBUG ((EFI_D_VERBOSE, "qcom,pmic-id does not exit\n"));
}
Expand Down

0 comments on commit b007693

Please sign in to comment.