summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--QcomModulePkg/Include/Library/PartialGoods.h38
-rw-r--r--QcomModulePkg/Library/BootLib/PartialGoods.c137
2 files changed, 150 insertions, 25 deletions
diff --git a/QcomModulePkg/Include/Library/PartialGoods.h b/QcomModulePkg/Include/Library/PartialGoods.h
index cad4d13cda..e0291e08e3 100644
--- a/QcomModulePkg/Include/Library/PartialGoods.h
+++ b/QcomModulePkg/Include/Library/PartialGoods.h
@@ -26,11 +26,47 @@
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+/*
+ * Changes from Qualcomm Innovation Center are provided under the following license:
+ *
+ * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted (subject to the limitations in the
+ * disclaimer below) provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ *
+ * * Neither the name of Qualcomm Innovation Center, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE
+ * GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT
+ * HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
#ifndef __PARTIALGOODS_H__
#define __PARTIALGOODS_H__
#include <Library/Board.h>
-#define MAX_CPU_CLUSTER 2
+#define MAX_CPU_CLUSTER 3
struct SubNodeListNew {
CONST CHAR8 *SubNodeName; /* Subnode name */
diff --git a/QcomModulePkg/Library/BootLib/PartialGoods.c b/QcomModulePkg/Library/BootLib/PartialGoods.c
index d3217c441f..6663117def 100644
--- a/QcomModulePkg/Library/BootLib/PartialGoods.c
+++ b/QcomModulePkg/Library/BootLib/PartialGoods.c
@@ -24,6 +24,43 @@
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+
+/*
+ * Changes from Qualcomm Innovation Center are provided under the following license:
+ *
+ * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted (subject to the limitations in the
+ * disclaimer below) provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ *
+ * * Neither the name of Qualcomm Innovation Center, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE
+ * GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT
+ * HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "libfdt.h"
@@ -67,10 +104,21 @@ static struct PartialGoods PartialGoodsCpuType1[] = {
{0x40, "/cpus", {"cpu@108", "enable-method", "psci", "none"}},
};
+static struct PartialGoods PartialGoodsCpuType2[] = {
+ {0x1, "/cpus", {"cpu@0", "enable-method", "psci", "none"}},
+ {0x2, "/cpus", {"cpu@1", "enable-method", "psci", "none"}},
+ {0x4, "/cpus", {"cpu@2", "enable-method", "psci", "none"}},
+ {0x8, "/cpus", {"cpu@3", "enable-method", "psci", "none"}},
+ {0x10, "/cpus", {"cpu@100", "enable-method", "psci", "none"}},
+ {0x20, "/cpus", {"cpu@101", "enable-method", "psci", "none"}},
+ {0x40, "/cpus", {"cpu@102", "enable-method", "psci", "none"}},
+ {0x80, "/cpus", {"cpu@103", "enable-method", "psci", "none"}},
+};
+
#define NUM_OF_CPUS (ARRAY_SIZE(PartialGoodsCpuType0))
STATIC struct PartialGoods *PartialGoodsCpuType[MAX_CPU_CLUSTER] = {
- PartialGoodsCpuType0, PartialGoodsCpuType1};
+ PartialGoodsCpuType0, PartialGoodsCpuType1, PartialGoodsCpuType2};
/* Look up table for multimedia partial goods */
static struct PartialGoods PartialGoodsMmType[] = {
@@ -319,6 +367,39 @@ static struct PartialGoods PartialGoodsMmType[] = {
{"qcom,mss", "status", "ok", "no"}},
};
+STATIC EFI_STATUS
+CheckCPUType (VOID *fdt,
+ UINT32 TableSz,
+ struct PartialGoods *Table)
+{
+ struct SubNodeListNew *SNode = NULL;
+ INT32 SubNodeOffset = 0;
+ INT32 ParentOffset = 0;
+ UINT32 i;
+
+ for (i = 0; i < TableSz; i++, Table++)
+ {
+ /* Find the parent node */
+ ParentOffset = fdt_path_offset (fdt, Table->ParentNode);
+ if (ParentOffset < 0) {
+ DEBUG ((EFI_D_ERROR, "Failed to Get parent node: %a\terror: %d\n",
+ Table->ParentNode, ParentOffset));
+ return EFI_NOT_FOUND;
+ }
+
+ /* Find the subnode */
+ SNode = &(Table->SubNode);
+ SubNodeOffset = fdt_subnode_offset (fdt, ParentOffset,
+ SNode->SubNodeName);
+ if (SubNodeOffset < 0) {
+ DEBUG ((EFI_D_INFO, "Subnode: %a is not present, breaking loop\n",
+ SNode->SubNodeName));
+ return EFI_NOT_FOUND;
+ }
+ }
+ return EFI_SUCCESS;
+}
+
STATIC VOID
FindNodeAndUpdateProperty (VOID *fdt,
UINT32 TableSz,
@@ -370,24 +451,18 @@ FindNodeAndUpdateProperty (VOID *fdt,
STATIC EFI_STATUS
ReadCpuPartialGoods (EFI_CHIPINFO_PROTOCOL *pChipInfoProtocol, UINT32 *Value)
{
- UINT32 i;
+ UINT32 CpuCluster = 0;
EFI_STATUS Status = EFI_SUCCESS;
- UINT32 DefectVal;
-
- for (i = 0; i < MAX_CPU_CLUSTER; i++) {
- /* Ensure to reset the Value before checking CPU part for defect */
- DefectVal = 0;
- Value[i] = 0;
- Status =
- pChipInfoProtocol->GetDefectiveCPUs (pChipInfoProtocol, i, &DefectVal);
- if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_VERBOSE, "Failed to get CPU defective[%d] part. %r\n", i,
- Status));
- continue;
- }
+ /* Ensure to reset the Value before checking CPU part for defect */
+ *Value = 0;
- Value[i] = DefectVal;
+ Status =
+ pChipInfoProtocol->GetDefectiveCPUs (pChipInfoProtocol, CpuCluster,
+ Value);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((EFI_D_VERBOSE, "Failed to get CPU defective[%d] part. %r\n",
+ CpuCluster, Status));
}
if (Status == EFI_NOT_FOUND)
@@ -430,7 +505,8 @@ UpdatePartialGoodsNode (VOID *fdt)
{
UINT32 i;
UINT32 PartialGoodsMMValue = 0;
- UINT32 PartialGoodsCpuValue[MAX_CPU_CLUSTER];
+ UINT32 PartialGoodsCpuValue;
+ UINT32 PartialGoodsCPUTypeValue = 0;
EFI_CHIPINFO_PROTOCOL *pChipInfoProtocol;
EFI_STATUS Status = EFI_SUCCESS;
@@ -457,20 +533,33 @@ UpdatePartialGoodsNode (VOID *fdt)
}
/* Read and update CPU Partial Goods nodes */
- Status = ReadCpuPartialGoods (pChipInfoProtocol, PartialGoodsCpuValue);
+ Status = ReadCpuPartialGoods (pChipInfoProtocol, &PartialGoodsCpuValue);
if (Status != EFI_SUCCESS) {
DEBUG ((EFI_D_INFO, "No partial goods for cpu ss found.\n"));
}
+ DEBUG ((EFI_D_INFO, "PartialGoods Value: 0x%x\n",
+ PartialGoodsCpuValue));
+
+ if (!PartialGoodsCpuValue) {
+ return EFI_SUCCESS;
+ }
+
for (i = 0; i < MAX_CPU_CLUSTER; i++) {
- if (PartialGoodsCpuValue[i]) {
- DEBUG ((EFI_D_INFO, "PartialGoods for Cluster[%d]: 0x%x\n", i,
- PartialGoodsCpuValue[i]));
- FindNodeAndUpdateProperty (fdt, NUM_OF_CPUS,
- &PartialGoodsCpuType[i][0],
- PartialGoodsCpuValue[i]);
+ Status = CheckCPUType (fdt, NUM_OF_CPUS, &PartialGoodsCpuType[i][0]);
+
+ if (Status == EFI_SUCCESS) {
+ PartialGoodsCPUTypeValue = i;
+ DEBUG ((EFI_D_INFO, "CPUType Match for for Cluster[%d]\n", i));
+ break;
+ } else {
+ DEBUG ((EFI_D_INFO, "CPUType Mismatch for for Cluster[%d]\n", i));
}
}
+ FindNodeAndUpdateProperty (fdt, NUM_OF_CPUS,
+ &PartialGoodsCpuType[PartialGoodsCPUTypeValue][0],
+ PartialGoodsCpuValue);
+
return EFI_SUCCESS;
}