Skip to content

Commit

Permalink
QcomModulePkg: Correct the PMIC detection in abl
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Lijuan Gao committed Mar 10, 2021
1 parent ce876d9 commit 1259da7
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 26 deletions.
4 changes: 2 additions & 2 deletions QcomModulePkg/Include/Library/Board.h
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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;

Expand Down
45 changes: 38 additions & 7 deletions QcomModulePkg/Include/Library/LocateDeviceTree.h
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -99,6 +99,30 @@ typedef enum {
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,
Expand All @@ -108,10 +132,17 @@ typedef enum {
} 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,
Expand All @@ -125,7 +156,7 @@ typedef enum {
typedef struct PmicIdInfo {
UINT32 DtPmicModel[MAX_PMIC_IDX];
UINT32 DtPmicRev[MAX_PMIC_IDX];
UINT32 DtMatchVal;
UINT64 DtMatchVal;
} PmicIdInfo;

typedef struct DtInfo {
Expand All @@ -138,7 +169,7 @@ typedef struct DtInfo {
UINT32 DtPlatformSubtype;
UINT32 DtPmicModel[MAX_PMIC_IDX];
UINT32 DtPmicRev[MAX_PMIC_IDX];
UINT32 DtMatchVal;
UINT64 DtMatchVal;
VOID *Dtb;
} DtInfo;

Expand Down
37 changes: 20 additions & 17 deletions QcomModulePkg/Library/BootLib/LocateDeviceTree.c
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -536,7 +536,7 @@ DeviceTreeAppended (VOID *kernel,
}

STATIC BOOLEAN
CheckAllBitsSet (UINT32 DtMatchVal)
CheckAllBitsSet (UINT64 DtMatchVal)
{
return (DtMatchVal & ALL_BITS_SET) == (ALL_BITS_SET);
}
Expand Down Expand Up @@ -576,22 +576,25 @@ ReadBestPmicMatch (CONST CHAR8 *PmicProp, INT32 PmicMaxIdx,
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,
Expand Down Expand Up @@ -895,8 +898,8 @@ ReadDtbFindMatch (DtInfo *CurDtbInfo, DtInfo *BestDtbInfo, UINT32 ExactMatch)
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"));
Expand Down

0 comments on commit 1259da7

Please sign in to comment.