5 * AMD Family_10 NB Pstate Initialization
7 * Performs the action described in F3x1F0[NbPstate] as
8 * described in the BKDG.
10 * @xrefitem bom "File Content Label" "Release Content"
12 * @e sub-project: CPU/F10
13 * @e \$Revision: 35877 $ @e \$Date: 2010-08-03 12:51:46 +0800 (Tue, 03 Aug 2010) $
17 *****************************************************************************
19 * Copyright (c) 2011, 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 * ***************************************************************************
48 /*----------------------------------------------------------------------------------------
49 * M O D U L E S U S E D
50 *----------------------------------------------------------------------------------------
54 #include "cpuRegisters.h"
55 #include "cpuF10PowerMgmt.h"
56 #include "cpuApicUtilities.h"
57 #include "GeneralServices.h"
58 #include "cpuFamilyTranslation.h"
59 #include "F10PmNbPstateInit.h"
60 #include "F10PackageType.h"
63 RDATA_GROUP (G1_PEICC)
65 #define FILECODE PROC_CPU_FAMILY_0X10_F10PMNBPSTATEINIT_FILECODE
67 /*----------------------------------------------------------------------------------------
68 * D E F I N I T I O N S A N D M A C R O S
69 *----------------------------------------------------------------------------------------
72 /*----------------------------------------------------------------------------------------
73 * T Y P E D E F S A N D S T R U C T U R E S
74 *----------------------------------------------------------------------------------------
76 /// Structure used for modifying the P-state
77 /// MSRs on fuse enable CPUs.
79 UINT8 NbVid1; ///< Destination NB VID code
80 UINT8 NbPstate; ///< Status of NbVidUpdateAll
83 /*----------------------------------------------------------------------------------------
84 * 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
85 *----------------------------------------------------------------------------------------
90 IN VOID *NbPstateParams,
91 IN AMD_CONFIG_PARAMS *StdHeader
94 /*----------------------------------------------------------------------------------------
95 * E X P O R T E D F U N C T I O N S
96 *----------------------------------------------------------------------------------------
99 /*---------------------------------------------------------------------------------------*/
101 * Family 10h core 0 entry point for performing the actions described in the
102 * description of F3x1F0[NbPstate].
104 * If F3x1F0[NbPstate] is non zero, it specifies the highest performance
105 * P-state in which to enable NbDid. Each core must loop through their
106 * P-state MSRs, enabling NbDid and changing NbVid to a lower voltage.
108 * @param[in] FamilySpecificServices The current Family Specific Services.
109 * @param[in] CpuEarlyParamsPtr Service related parameters (unused).
110 * @param[in] StdHeader Config handle for library and services.
115 IN CPU_SPECIFIC_SERVICES *FamilySpecificServices,
116 IN AMD_CPU_EARLY_PARAMS *CpuEarlyParamsPtr,
117 IN AMD_CONFIG_PARAMS *StdHeader
126 AGESA_STATUS IgnoredSts;
127 NB_PSTATE_INIT ApParams;
129 if (FamilySpecificServices->IsNbPstateEnabled (FamilySpecificServices, &CpuEarlyParamsPtr->PlatformConfig, StdHeader)) {
130 if (CpuEarlyParamsPtr->PlatformConfig.PlatformProfile.PlatformPowerPolicy == BatteryLife) {
131 IdentifyCore (StdHeader, &Socket, &Module, &Core, &IgnoredSts);
133 GetPciAddress (StdHeader, Socket, Module, &PciAddress, &IgnoredSts);
134 PciAddress.Address.Function = FUNC_3;
135 PciAddress.Address.Register = 0x1F0;
136 LibAmdPciRead (AccessWidth32, PciAddress, &PciRegister, StdHeader);
137 if ((PciRegister & 0x00070000) != 0) {
138 ApParams.NbPstate = (UINT8) ((PciRegister & 0x00070000) >> 16);
139 ASSERT (ApParams.NbPstate < NM_PS_REG);
141 PciAddress.Address.Function = FUNC_4;
142 PciAddress.Address.Register = 0x1F4;
143 LibAmdPciRead (AccessWidth32, PciAddress, &PciRegister, StdHeader);
144 ApParams.NbVid1 = (UINT8) ((PciRegister & 0x00003F80) >> 7);
146 TaskPtr.FuncAddress.PfApTaskI = PmNbPstateInitCore;
147 TaskPtr.DataTransfer.DataSizeInDwords = SIZE_IN_DWORDS (NB_PSTATE_INIT);
148 TaskPtr.DataTransfer.DataPtr = &ApParams;
149 TaskPtr.DataTransfer.DataTransferFlags = 0;
150 TaskPtr.ExeFlags = WAIT_FOR_CORE;
151 ApUtilRunCodeOnAllLocalCoresAtEarly (&TaskPtr, StdHeader, CpuEarlyParamsPtr);
159 /*---------------------------------------------------------------------------------------*/
161 * Support routine for F10PmNbPstateInit.
163 * This function modifies NbVid and NbDid on each core.
165 * @param[in] NbPstateParams Appropriate NbVid1 and NbPstate as determined by core 0.
166 * @param[in] StdHeader Config handle for library and services.
172 IN VOID *NbPstateParams,
173 IN AMD_CONFIG_PARAMS *StdHeader
179 for (MsrAddress = (PS_REG_BASE + ((NB_PSTATE_INIT *) NbPstateParams)->NbPstate); MsrAddress <= PS_MAX_REG; MsrAddress++) {
180 LibAmdMsrRead (MsrAddress, &MsrRegister, StdHeader);
181 if (((PSTATE_MSR *) &MsrRegister)->PsEnable == 1) {
182 ((PSTATE_MSR *) &MsrRegister)->NbDid = 1;
183 ((PSTATE_MSR *) &MsrRegister)->NbVid = ((NB_PSTATE_INIT *) NbPstateParams)->NbVid1;
184 LibAmdMsrWrite (MsrAddress, &MsrRegister, StdHeader);