summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAmit Pundir <amit.pundir@linaro.org>2021-12-15 18:55:03 +0530
committerNicolas Dechesne <nicolas.dechesne@linaro.org>2021-12-15 15:52:20 +0100
commit08d45c55c98abe9ed553de96398c6fa1624e27fd (patch)
tree260d24be279e12578bfd03d9f6b76106b7f38ac2
parentedad5ce32a1a2436efdceed194f603d9a0782c2d (diff)
QcomModulePkg: Re-enable multiple appended DTB supportrelease/LU.UM.1.2.1.r1-23200-QRB5165.0
Now that qcom,msm-id and qcom,board-id for db845c and rb5 are merged upstream (v5.16), re-enable the multiple appended DTB suport. This patch is compatible with older kernel builds. It will fallback to the option of choosing the first appended DTB in case the qcom* IDs are missing or there is no match. Signed-off-by: Amit Pundir <amit.pundir@linaro.org> Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> Signed-off-by: Nicolas Dechesne <nicolas.dechesne@linaro.org>
-rw-r--r--QcomModulePkg/Library/BootLib/LocateDeviceTree.c29
1 files changed, 18 insertions, 11 deletions
diff --git a/QcomModulePkg/Library/BootLib/LocateDeviceTree.c b/QcomModulePkg/Library/BootLib/LocateDeviceTree.c
index cab043bfd..842f61c17 100644
--- a/QcomModulePkg/Library/BootLib/LocateDeviceTree.c
+++ b/QcomModulePkg/Library/BootLib/LocateDeviceTree.c
@@ -922,6 +922,7 @@ GetSocDtb (VOID *Kernel, UINT32 KernelSize, UINT32 DtbOffset, VOID *DtbLoadAddr)
{
uintptr_t KernelEnd = (uintptr_t)Kernel + KernelSize;
VOID *Dtb = NULL;
+ VOID *FallbackDtb = NULL;
struct fdt_header DtbHdr;
UINT32 DtbSize = 0;
INT32 DtbCount = 0;
@@ -935,7 +936,7 @@ GetSocDtb (VOID *Kernel, UINT32 KernelSize, UINT32 DtbOffset, VOID *DtbLoadAddr)
if (((uintptr_t)Kernel + (uintptr_t)DtbOffset) < (uintptr_t)Kernel) {
return NULL;
}
- Dtb = Kernel + DtbOffset;
+ FallbackDtb = Dtb = Kernel + DtbOffset;
while (((uintptr_t)Dtb + sizeof (struct fdt_header)) < (uintptr_t)KernelEnd) {
/* the DTB could be unaligned, so extract the header,
* and operate on it separately */
@@ -948,14 +949,6 @@ GetSocDtb (VOID *Kernel, UINT32 KernelSize, UINT32 DtbOffset, VOID *DtbLoadAddr)
break;
CurDtbInfo.Dtb = Dtb;
- /*
- * HACK: set Current (and only dtb in our case) as the Best match explicitly.
- * Default behaviour is to iterate thru the list of dtbs in dtb.img and pick
- * the best match based on DTMATCH_PARAMS (qcom,{msm-id/board-id/pmic-id} in
- * dts). msm-id/board-id/pmic-id are non-upstream dt properties which we do
- * not support on db845c.
- */
- BestDtbInfo.Dtb = Dtb;
if (ReadDtbFindMatch (&CurDtbInfo, &BestDtbInfo, SOC_MATCH)) {
DtbIdx = DtbCount;
}
@@ -982,8 +975,22 @@ GetSocDtb (VOID *Kernel, UINT32 KernelSize, UINT32 DtbOffset, VOID *DtbLoadAddr)
}
if (!BestDtbInfo.Dtb) {
- DEBUG ((EFI_D_ERROR, "No match found for Soc Dtb type\n"));
- return NULL;
+ if (!FallbackDtb) {
+ DEBUG ((EFI_D_ERROR, "No match found for Soc Dtb type\n"));
+ return NULL;
+ } else {
+ DEBUG ((EFI_D_INFO, "No match found for Soc Dtb type, fallback to the default Dtb\n"));
+ /*
+ * For Linux kernel builds (v5.15 and below), set the default dtb in
+ * boot.img/vendor_boot.img as the Best match explicitly.
+ * Default behaviour is to iterate thru the list of dtbs in dtb.img
+ * and pick the best match based on DTMATCH_PARAMS properties
+ * (qcom,{msm-id/board-id/pmic-id} in dts. But the msm-id and board-id
+ * of RB5 and db845c got upstreamed in v5.16 only, so this hack
+ * provides a dtb fallback to the older kernel builds.
+ */
+ BestDtbInfo.Dtb = FallbackDtb;
+ }
}
return BestDtbInfo.Dtb;