QcomModulePkg: Correct the PMIC detection in abl
As PMIC detection maxinum supported in bootloader is enhanced from
4 to 0xf, so need to add match value support for the additional PMIC,
otherwise it will override subtype, ddr, variant and soc's match value.
Change-Id: I9d9e40023d2255c2e1d620b8b232417c1d87303d
diff --git a/QcomModulePkg/Include/Library/Board.h b/QcomModulePkg/Include/Library/Board.h
index 62e30e6..a5c5ee1 100644
--- a/QcomModulePkg/Include/Library/Board.h
+++ b/QcomModulePkg/Include/Library/Board.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2015-2018, 2020, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2015-2018, 2020-2021, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -45,7 +45,7 @@
#define CHIP_BASE_BAND_APQ "apq"
#define CHIP_BASE_BAND_MDM "mdm"
-#define BIT(x) (1UL << x)
+#define BIT(x) (1ULL << x)
extern RamPartitionEntry *RamPartitionEntries;
diff --git a/QcomModulePkg/Include/Library/LocateDeviceTree.h b/QcomModulePkg/Include/Library/LocateDeviceTree.h
index 4a84a64..35ce8b9 100644
--- a/QcomModulePkg/Include/Library/LocateDeviceTree.h
+++ b/QcomModulePkg/Include/Library/LocateDeviceTree.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2015, 2017-2020, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2015, 2017-2021, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -99,6 +99,30 @@
PMIC_MATCH_EXACT_MODEL_IDX2,
PMIC_MATCH_DEFAULT_MODEL_IDX3,
PMIC_MATCH_EXACT_MODEL_IDX3,
+ PMIC_MATCH_DEFAULT_MODEL_IDX4,
+ PMIC_MATCH_EXACT_MODEL_IDX4,
+ PMIC_MATCH_DEFAULT_MODEL_IDX5,
+ PMIC_MATCH_EXACT_MODEL_IDX5,
+ PMIC_MATCH_DEFAULT_MODEL_IDX6,
+ PMIC_MATCH_EXACT_MODEL_IDX6,
+ PMIC_MATCH_DEFAULT_MODEL_IDX7,
+ PMIC_MATCH_EXACT_MODEL_IDX7,
+ PMIC_MATCH_DEFAULT_MODEL_IDX8,
+ PMIC_MATCH_EXACT_MODEL_IDX8,
+ PMIC_MATCH_DEFAULT_MODEL_IDX9,
+ PMIC_MATCH_EXACT_MODEL_IDX9,
+ PMIC_MATCH_DEFAULT_MODEL_IDXA,
+ PMIC_MATCH_EXACT_MODEL_IDXA,
+ PMIC_MATCH_DEFAULT_MODEL_IDXB,
+ PMIC_MATCH_EXACT_MODEL_IDXB,
+ PMIC_MATCH_DEFAULT_MODEL_IDXC,
+ PMIC_MATCH_EXACT_MODEL_IDXC,
+ PMIC_MATCH_DEFAULT_MODEL_IDXD,
+ PMIC_MATCH_EXACT_MODEL_IDXD,
+ PMIC_MATCH_DEFAULT_MODEL_IDXE,
+ PMIC_MATCH_EXACT_MODEL_IDXE,
+ PMIC_MATCH_DEFAULT_MODEL_IDXF,
+ PMIC_MATCH_EXACT_MODEL_IDXF,
SUBTYPE_DEFAULT_MATCH,
SUBTYPE_EXACT_MATCH,
DDR_MATCH,
@@ -108,10 +132,17 @@
} DTMATCH_PARAMS;
#define TOTAL_MATCH_BITS 6
-#define ALL_BITS_SET \
- (BIT (SOC_MATCH) | BIT (VARIANT_MATCH) | BIT (SUBTYPE_EXACT_MATCH) | \
- BIT (FOUNDRYID_EXACT_MATCH) | BIT (PMIC_MATCH_EXACT_MODEL_IDX0) | \
- BIT (PMIC_MATCH_EXACT_MODEL_IDX1))
+#define ALL_BITS_SET \
+ (BIT (SOC_MATCH) | BIT (VARIANT_MATCH) | BIT (SUBTYPE_EXACT_MATCH) | \
+ BIT (FOUNDRYID_EXACT_MATCH) | BIT (PMIC_MATCH_EXACT_MODEL_IDX0) | \
+ BIT (PMIC_MATCH_EXACT_MODEL_IDX1) | BIT (PMIC_MATCH_EXACT_MODEL_IDX2) | \
+ BIT (PMIC_MATCH_EXACT_MODEL_IDX3) | BIT (PMIC_MATCH_EXACT_MODEL_IDX4) | \
+ BIT (PMIC_MATCH_EXACT_MODEL_IDX5) | BIT (PMIC_MATCH_EXACT_MODEL_IDX6) | \
+ BIT (PMIC_MATCH_EXACT_MODEL_IDX7) | BIT (PMIC_MATCH_EXACT_MODEL_IDX8) | \
+ BIT (PMIC_MATCH_EXACT_MODEL_IDX9) | BIT (PMIC_MATCH_EXACT_MODEL_IDXA) | \
+ BIT (PMIC_MATCH_EXACT_MODEL_IDXB) | BIT (PMIC_MATCH_EXACT_MODEL_IDXC) | \
+ BIT (PMIC_MATCH_EXACT_MODEL_IDXD) | BIT (PMIC_MATCH_EXACT_MODEL_IDXE) | \
+ BIT (PMIC_MATCH_EXACT_MODEL_IDXF))
typedef enum {
PMIC_IDX0,
@@ -125,7 +156,7 @@
typedef struct PmicIdInfo {
UINT32 DtPmicModel[MAX_PMIC_IDX];
UINT32 DtPmicRev[MAX_PMIC_IDX];
- UINT32 DtMatchVal;
+ UINT64 DtMatchVal;
} PmicIdInfo;
typedef struct DtInfo {
@@ -138,7 +169,7 @@
UINT32 DtPlatformSubtype;
UINT32 DtPmicModel[MAX_PMIC_IDX];
UINT32 DtPmicRev[MAX_PMIC_IDX];
- UINT32 DtMatchVal;
+ UINT64 DtMatchVal;
VOID *Dtb;
} DtInfo;
diff --git a/QcomModulePkg/Library/BootLib/LocateDeviceTree.c b/QcomModulePkg/Library/BootLib/LocateDeviceTree.c
index 73a5b24..7ddb924 100644
--- a/QcomModulePkg/Library/BootLib/LocateDeviceTree.c
+++ b/QcomModulePkg/Library/BootLib/LocateDeviceTree.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2020, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2012-2021, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -536,7 +536,7 @@
}
STATIC BOOLEAN
-CheckAllBitsSet (UINT32 DtMatchVal)
+CheckAllBitsSet (UINT64 DtMatchVal)
{
return (DtMatchVal & ALL_BITS_SET) == (ALL_BITS_SET);
}
@@ -576,22 +576,25 @@
break;
}
- if (CurPmicInfo.DtPmicRev[Idx] == (BoardPmicTarget (Idx)
- & PMIC_REV_MASK)) {
- CurPmicInfo.DtMatchVal |=
- BIT ((PMIC_MATCH_EXACT_REV_IDX0 + Idx * PMIC_SHIFT_IDX));
- } else if (CurPmicInfo.DtPmicRev[Idx] <
- (BoardPmicTarget (Idx) & PMIC_REV_MASK)) {
- CurPmicInfo.DtMatchVal |= BIT ((PMIC_MATCH_BEST_REV_IDX0 +
- Idx * PMIC_SHIFT_IDX));
- } else {
- DEBUG ((EFI_D_VERBOSE, "Pmic revision does not match\n"));
- break;
+ /* first match the first four pmic revision */
+ if (Idx < PMIC_IDX4) {
+ if (CurPmicInfo.DtPmicRev[Idx] == (BoardPmicTarget (Idx)
+ & PMIC_REV_MASK)) {
+ CurPmicInfo.DtMatchVal |=
+ BIT ((PMIC_MATCH_EXACT_REV_IDX0 + Idx * PMIC_SHIFT_IDX));
+ } else if (CurPmicInfo.DtPmicRev[Idx] <
+ (BoardPmicTarget (Idx) & PMIC_REV_MASK)) {
+ CurPmicInfo.DtMatchVal |= BIT ((PMIC_MATCH_BEST_REV_IDX0 +
+ Idx * PMIC_SHIFT_IDX));
+ } else {
+ DEBUG ((EFI_D_VERBOSE, "Pmic revision does not match\n"));
+ break;
+ }
}
}
- DEBUG ((EFI_D_VERBOSE, "BestPmicInfo.DtMatchVal : %x"
- " CurPmicInfo[%u]->DtMatchVal : %x\n", BestPmicInfo->DtMatchVal,
+ DEBUG ((EFI_D_VERBOSE, "BestPmicInfo.DtMatchVal : 0x%llx"
+ " CurPmicInfo[%u]->DtMatchVal : 0x%llx\n", BestPmicInfo->DtMatchVal,
PmicEntIdx, CurPmicInfo.DtMatchVal));
if (BestPmicInfo->DtMatchVal < CurPmicInfo.DtMatchVal) {
gBS->CopyMem (BestPmicInfo, &CurPmicInfo,
@@ -895,8 +898,8 @@
CurDtbInfo->DtPmicRev[Idx] = BestPmicInfo.DtPmicRev[Idx];
}
- DEBUG ((EFI_D_VERBOSE, "CurDtbInfo->DtMatchVal : %x "
- "BestPmicInfo.DtMatchVal :%x\n", CurDtbInfo->DtMatchVal,
+ 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"));