5 * AMD Family_10 Dual-plane Only Support
7 * Performs the "BIOS Configuration for Dual-plane Only Support" as
8 * described in the BKDG.
10 * @xrefitem bom "File Content Label" "Release Content"
12 * @e sub-project: CPU/F10
13 * @e \$Revision: 56279 $ @e \$Date: 2011-07-11 13:11:28 -0600 (Mon, 11 Jul 2011) $
17 ******************************************************************************
19 * Copyright (C) 2012 Advanced Micro Devices, Inc.
20 * All rights reserved.
22 * Redistribution and use in source and binary forms, with or without
23 * modification, are permitted provided that the following conditions are met:
24 * * Redistributions of source code must retain the above copyright
25 * notice, this list of conditions and the following disclaimer.
26 * * Redistributions in binary form must reproduce the above copyright
27 * notice, this list of conditions and the following disclaimer in the
28 * documentation and/or other materials provided with the distribution.
29 * * Neither the name of Advanced Micro Devices, Inc. nor the names of
30 * its contributors may be used to endorse or promote products derived
31 * from this software without specific prior written permission.
33 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
34 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
35 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
36 * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
37 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
38 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
39 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
40 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
41 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
42 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
44 ******************************************************************************
47 /*----------------------------------------------------------------------------------------
48 * M O D U L E S U S E D
49 *----------------------------------------------------------------------------------------
53 #include "cpuRegisters.h"
54 #include "cpuApicUtilities.h"
55 #include "cpuServices.h"
56 #include "GeneralServices.h"
57 #include "cpuFamilyTranslation.h"
58 #include "cpuF10PowerMgmt.h"
59 #include "F10PmDualPlaneOnlySupport.h"
60 #include "F10PackageType.h"
61 #include "OptionMultiSocket.h"
66 #define FILECODE PROC_CPU_FAMILY_0X10_F10PMDUALPLANEONLYSUPPORT_FILECODE
68 /*----------------------------------------------------------------------------------------
69 * D E F I N I T I O N S A N D M A C R O S
70 *----------------------------------------------------------------------------------------
72 extern OPTION_MULTISOCKET_CONFIGURATION OptionMultiSocketConfiguration;
73 /*----------------------------------------------------------------------------------------
74 * T Y P E D E F S A N D S T R U C T U R E S
75 *----------------------------------------------------------------------------------------
78 /*----------------------------------------------------------------------------------------
79 * P R O T O T Y P E S O F L O C A L F U N C T I O N S
80 *----------------------------------------------------------------------------------------
86 IN AMD_CONFIG_PARAMS *StdHeader
89 /*----------------------------------------------------------------------------------------
90 * E X P O R T E D F U N C T I O N S
91 *----------------------------------------------------------------------------------------
94 /*---------------------------------------------------------------------------------------*/
96 * Family 10h core 0 entry point for performing the "Dual-plane Only Support" algorithm.
98 * The algorithm is as follows:
99 * // Determine whether algorithm applies to this processor
100 * if (CPUID Fn8000_0001_EBX[PkgType] == 0001b && (revision C or E) {
101 * // Determine whether processor is supported in this infrastructure
102 * if (((F3x1FC[DualPlaneOnly] == 1) && (this is a dual-plane platform))
103 * || ((F3x1FC[AM3r2Only] == 1) && (this is an AM3r2 platform))) {
104 * // Fixup the P-state MSRs
105 * for (each core in the system) {
106 * if (CPUID Fn8000_0007[CPB]) {
107 * Copy MSRC001_0065 as MinPstate;
108 * Copy MSRC001_0068 to MSRC001_0065;
109 * Copy MinPstate to MSRC001_0068;
111 * Copy MSRC001_0068 to MSRC001_0064;
112 * Program MSRC001_0068 = 0;
114 * for (each MSR in MSRC001_00[68:64]) {
115 * if (value in MSRC001_00[68:64][IddValue] != 0) {
116 * Set PstateEn in current MSR to 1;
120 * Set F3xDC[PstateMaxVal] = lowest-performance enabled P-state;
121 * Set F3xA8[PopDownPstate] = lowest-performance enabled P-state;
122 * Set F3x64[HtcPstateLimit] = lowest-performance enabled P-state;
126 * @param[in] FamilySpecificServices The current Family Specific Services.
127 * @param[in] CpuEarlyParamsPtr Service related parameters (unused).
128 * @param[in] StdHeader Config handle for library and services.
132 F10PmDualPlaneOnlySupport (
133 IN CPU_SPECIFIC_SERVICES *FamilySpecificServices,
134 IN AMD_CPU_EARLY_PARAMS *CpuEarlyParamsPtr,
135 IN AMD_CONFIG_PARAMS *StdHeader
143 UINT32 LocalPciRegister;
145 UINT32 ProcessorPackageType;
147 CPUID_DATA CpuidData;
148 CPU_LOGICAL_ID LogicalId;
150 OptionMultiSocketConfiguration.GetCurrPciAddr (&PciAddress, StdHeader);
152 // get the package type
153 ProcessorPackageType = LibAmdGetPackageType (StdHeader);
154 GetLogicalIdOfCurrentCore (&LogicalId, StdHeader);
155 if (((LogicalId.Revision & (AMD_F10_Cx | AMD_F10_Ex)) != 0) && ((ProcessorPackageType & PACKAGE_TYPE_AM2R2_AM3) != 0)) {
156 PciAddress.AddressValue = PRCT_INFO_PCI_ADDR;
157 LibAmdPciRead (AccessWidth32, PciAddress, &LocalPciRegister, StdHeader);
158 PciAddress.AddressValue = PW_CTL_MISC_PCI_ADDR;
159 LibAmdPciRead (AccessWidth32, PciAddress, &Pvimode, StdHeader);
160 if ((((LocalPciRegister & 0x80000000) != 0) && (((POWER_CTRL_MISC_REGISTER *) &Pvimode)->PviMode == 0))
161 || ((LocalPciRegister & 0x04000000) != 0)) {
163 LibAmdCpuidRead (AMD_CPUID_APM, &CpuidData, StdHeader);
164 if (((CpuidData.EDX_Reg & 0x00000200) >> 9) == 1) {
168 TaskPtr.FuncAddress.PfApTaskIO = SetPstateMSR;
169 TaskPtr.ExeFlags = TASK_HAS_OUTPUT | WAIT_FOR_CORE;
170 TaskPtr.DataTransfer.DataTransferFlags = 0;
171 TaskPtr.DataTransfer.DataSizeInDwords = 1;
172 TaskPtr.DataTransfer.DataPtr = &CPB;
174 GetActiveCoresInCurrentSocket (&ActiveCores, StdHeader);
175 for (Core = 1; Core < (UINT8) ActiveCores; ++Core) {
176 ApUtilRunCodeOnSocketCore ((UINT8)0, (UINT8)Core, &TaskPtr, StdHeader);
178 LowestPsEn = ApUtilTaskOnExecutingCore (&TaskPtr, StdHeader, (VOID *) CpuEarlyParamsPtr);
180 PciAddress.AddressValue = CPTC2_PCI_ADDR;
181 LibAmdPciRead (AccessWidth32, PciAddress, &LocalPciRegister, StdHeader);
182 ((CLK_PWR_TIMING_CTRL2_REGISTER *) &LocalPciRegister)->PstateMaxVal = LowestPsEn;
183 LibAmdPciWrite (AccessWidth32, PciAddress, &LocalPciRegister, StdHeader);
185 PciAddress.AddressValue = POPUP_PSTATE_PCI_ADDR;
186 LibAmdPciRead (AccessWidth32, PciAddress, &LocalPciRegister, StdHeader);
187 ((POPUP_PSTATE_REGISTER *) &LocalPciRegister)->PopDownPstate = LowestPsEn;
188 LibAmdPciWrite (AccessWidth32, PciAddress, &LocalPciRegister, StdHeader);
190 PciAddress.AddressValue = HTC_PCI_ADDR;
191 LibAmdPciRead (AccessWidth32, PciAddress, &LocalPciRegister, StdHeader);
192 ((HTC_REGISTER *) &LocalPciRegister)->HtcPstateLimit = LowestPsEn;
193 LibAmdPciWrite (AccessWidth32, PciAddress, &LocalPciRegister, StdHeader);
197 /*---------------------------------------------------------------------------------------*/
201 * This function set the P-state MSRs per each core in the system.
203 * @param[in] CPB Contains the value of Asymmetric Boost register
204 * @param[in] StdHeader Config handle for library and services
206 * @return Return the lowest-performance enabled P-state
212 IN AMD_CONFIG_PARAMS *StdHeader
220 if (*(UINT32*) CPB != 0) {
221 LibAmdMsrRead (MSR_PSTATE_1, &MinMsrValue, StdHeader);
222 LibAmdMsrRead (MSR_PSTATE_4, &MsrValue, StdHeader);
223 LibAmdMsrWrite (MSR_PSTATE_1, &MsrValue, StdHeader);
224 LibAmdMsrWrite (MSR_PSTATE_4, &MinMsrValue, StdHeader);
226 LibAmdMsrRead (MSR_PSTATE_4, &MsrValue, StdHeader);
227 LibAmdMsrWrite (MSR_PSTATE_0, &MsrValue, StdHeader);
229 LibAmdMsrWrite (MSR_PSTATE_4, &MsrValue, StdHeader);
233 for (dtemp = MSR_PSTATE_0; dtemp <= MSR_PSTATE_4; dtemp++) {
234 LibAmdMsrRead (dtemp, &MsrValue, StdHeader);
235 if (((PSTATE_MSR *) &MsrValue)->IddValue != 0) {
236 MsrValue = MsrValue | BIT63;
237 LibAmdMsrWrite (dtemp, &MsrValue, StdHeader);
238 LowestPsEn = dtemp - MSR_PSTATE_0;