blob: d772e53a1e077bce330e39a78effbacf56833395 [file] [log] [blame]
zbao7d94cf92012-07-02 14:19:14 +08001/* $NoKeywords:$ */
2/**
3 * @file
4 *
5 * AMD AGESA CPU Hardware Thermal Control (HTC) feature support code.
6 *
7 * Contains code that declares the AGESA CPU HTC related APIs
8 *
9 * @xrefitem bom "File Content Label" "Release Content"
10 * @e project: AGESA
11 * @e sub-project: CPU/Feature
12 * @e \$Revision: 63692 $ @e \$Date: 2012-01-03 22:13:28 -0600 (Tue, 03 Jan 2012) $
13 *
14 */
15/*
16 ******************************************************************************
17 *
Siyuan Wang641f00c2013-06-08 11:50:55 +080018 * Copyright (c) 2008 - 2012, Advanced Micro Devices, Inc.
19 * All rights reserved.
zbao7d94cf92012-07-02 14:19:14 +080020 *
Siyuan Wang641f00c2013-06-08 11:50:55 +080021 * Redistribution and use in source and binary forms, with or without
22 * modification, are permitted provided that the following conditions are met:
23 * * Redistributions of source code must retain the above copyright
24 * notice, this list of conditions and the following disclaimer.
25 * * Redistributions in binary form must reproduce the above copyright
26 * notice, this list of conditions and the following disclaimer in the
27 * documentation and/or other materials provided with the distribution.
28 * * Neither the name of Advanced Micro Devices, Inc. nor the names of
29 * its contributors may be used to endorse or promote products derived
30 * from this software without specific prior written permission.
zbao7d94cf92012-07-02 14:19:14 +080031 *
Siyuan Wang641f00c2013-06-08 11:50:55 +080032 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
33 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
34 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
35 * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
36 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
37 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
38 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
39 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
40 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
41 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
zbao7d94cf92012-07-02 14:19:14 +080042 ******************************************************************************
43 */
44
45/*----------------------------------------------------------------------------------------
46 * M O D U L E S U S E D
47 *----------------------------------------------------------------------------------------
48 */
49#include "AGESA.h"
50#include "GeneralServices.h"
51#include "cpuFamilyTranslation.h"
52#include "cpuApicUtilities.h"
53#include "cpuFeatures.h"
54#include "cpuHtc.h"
55#include "OptionMultiSocket.h"
56#include "Filecode.h"
57CODE_GROUP (G1_PEICC)
58RDATA_GROUP (G1_PEICC)
59
60#define FILECODE PROC_CPU_FEATURE_CPUHTC_FILECODE
61
62/*----------------------------------------------------------------------------------------
63 * D E F I N I T I O N S A N D M A C R O S
64 *----------------------------------------------------------------------------------------
65 */
66
67/*----------------------------------------------------------------------------------------
68 * T Y P E D E F S A N D S T R U C T U R E S
69 *----------------------------------------------------------------------------------------
70 */
71
72/*----------------------------------------------------------------------------------------
73 * 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
74 *----------------------------------------------------------------------------------------
75 */
76UINT32
77STATIC
78EnableHtcOnSocket (
79 IN VOID *EntryPoint,
80 IN AMD_CONFIG_PARAMS *StdHeader,
81 IN AMD_CPU_EARLY_PARAMS *CpuEarlyParams
82 );
83
84/*----------------------------------------------------------------------------------------
85 * E X P O R T E D F U N C T I O N S
86 *----------------------------------------------------------------------------------------
87 */
88extern CPU_FAMILY_SUPPORT_TABLE HtcFamilyServiceTable;
89extern OPTION_MULTISOCKET_CONFIGURATION OptionMultiSocketConfiguration;
90
91/*---------------------------------------------------------------------------------------*/
92/**
93 * Should Hardware Thermal Control (HTC) be enabled
94 *
95 * @param[in] PlatformConfig Contains the runtime modifiable feature input data.
96 * @param[in] StdHeader Config Handle for library, services.
97 *
98 * @retval TRUE HTC is supported.
99 * @retval FALSE HTC cannot be enabled.
100 *
101 */
102BOOLEAN
103STATIC
104IsHtcFeatureEnabled (
105 IN PLATFORM_CONFIGURATION *PlatformConfig,
106 IN AMD_CONFIG_PARAMS *StdHeader
107 )
108{
109 UINT32 Socket;
110 BOOLEAN IsEnabled;
111 HTC_FAMILY_SERVICES *HtcFamilyServices;
112
113 IsEnabled = TRUE;
114
115 for (Socket = 0; Socket < GetPlatformNumberOfSockets (); Socket++) {
116 if (IsProcessorPresent (Socket, StdHeader)) {
117 GetFeatureServicesOfSocket (&HtcFamilyServiceTable, Socket, (CONST VOID **)&HtcFamilyServices, StdHeader);
118 if ((HtcFamilyServices == NULL) || (!HtcFamilyServices->IsHtcSupported (HtcFamilyServices, Socket, PlatformConfig, StdHeader))) {
119 IsEnabled = FALSE;
120 break;
121 }
122 }
123 }
124 return IsEnabled;
125}
126
127
128/*---------------------------------------------------------------------------------------*/
129/**
130 * Enable Hardware Thermal Control (HTC)
131 *
132 * @param[in] EntryPoint Timepoint designator.
133 * @param[in] PlatformConfig Contains the runtime modifiable feature input data.
134 * @param[in] StdHeader Config Handle for library, services.
135 *
136 * @retval AGESA_SUCCESS Always succeeds.
137 *
138 */
139AGESA_STATUS
140STATIC
141InitializeHtcFeature (
142 IN UINT64 EntryPoint,
143 IN PLATFORM_CONFIGURATION *PlatformConfig,
144 IN AMD_CONFIG_PARAMS *StdHeader
145 )
146{
147 AP_TASK TaskPtr;
148 AGESA_STATUS AgesaStatus;
149 AMD_CPU_EARLY_PARAMS CpuEarlyParams;
150
151 IDS_HDT_CONSOLE (CPU_TRACE, " HTC is being initialized\n");
152
153 CpuEarlyParams.PlatformConfig = *PlatformConfig;
154
155 TaskPtr.FuncAddress.PfApTaskIOC = EnableHtcOnSocket;
156 TaskPtr.DataTransfer.DataSizeInDwords = 2;
157 TaskPtr.DataTransfer.DataPtr = &EntryPoint;
158 TaskPtr.DataTransfer.DataTransferFlags = 0;
159 TaskPtr.ExeFlags = PASS_EARLY_PARAMS | TASK_HAS_OUTPUT;
160 AgesaStatus = OptionMultiSocketConfiguration.BscRunCodeOnAllSystemCore0s (&TaskPtr, StdHeader, &CpuEarlyParams);
161
162 IDS_HDT_CONSOLE (CPU_TRACE, " HTC is enabled\n");
163
164 return AgesaStatus;
165}
166
167/*---------------------------------------------------------------------------------------*/
168/**
169 * AP task to enable HTC
170 *
171 * @param[in] EntryPoint Timepoint designator.
172 * @param[in] StdHeader Config Handle for library, services.
173 * @param[in] CpuEarlyParams Service parameters.
174 *
175 */
176UINT32
177STATIC
178EnableHtcOnSocket (
179 IN VOID *EntryPoint,
180 IN AMD_CONFIG_PARAMS *StdHeader,
181 IN AMD_CPU_EARLY_PARAMS *CpuEarlyParams
182 )
183{
184 AGESA_STATUS CalledStatus;
185 HTC_FAMILY_SERVICES *HtcFamilyServices;
186
187 CalledStatus = AGESA_UNSUPPORTED;
188 GetFeatureServicesOfCurrentCore (&HtcFamilyServiceTable, (CONST VOID **)&HtcFamilyServices, StdHeader);
189 if (HtcFamilyServices != NULL) {
190 CalledStatus = HtcFamilyServices->EnableHtcOnSocket (HtcFamilyServices, *((UINT64 *) EntryPoint), &CpuEarlyParams->PlatformConfig, StdHeader);
191 }
192 return (UINT32) CalledStatus;
193}
194
195CONST CPU_FEATURE_DESCRIPTOR ROMDATA CpuFeatureHtc =
196{
197 CpuHtc,
198 (CPU_FEAT_AFTER_POST_MTRR_SYNC | CPU_FEAT_AFTER_RESUME_MTRR_SYNC),
199 IsHtcFeatureEnabled,
200 InitializeHtcFeature
201};