1 /* $NoKeywords:$ */
2 /**
3 * @file
4 *
5 * Config FCH Hwm controller
6 *
7 * Init Hwm Controller features.
8 *
9 * @xrefitem bom "File Content Label" "Release Content"
10 * @e project: AGESA
11 * @e sub-project: FCH
12 * @e \$Revision: 84150 $ @e \$Date: 2012-12-12 15:46:25 -0600 (Wed, 12 Dec 2012) $
13 *
14 */
15 /*
16 *****************************************************************************
17 *
18 * Copyright (c) 2008 - 2013, Advanced Micro Devices, Inc.
19 * All rights reserved.
20 *
21 * 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.
31 *
32 * 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.
42 ****************************************************************************
43 */
44 #include "FchPlatform.h"
45 #include "Filecode.h"
46 #define FILECODE PROC_FCH_HWM_FAMILY_YANGTZE_YANGTZEHWMLATESERVICE_FILECODE
47
48 /**
49 * Table for Function Number
50 *
51 *
52 *
53 *
54 */
55 STATIC UINT8 FunctionNumber[] =
56 {
57 Fun_81,
58 Fun_83,
59 Fun_85,
60 Fun_89,
61 };
62
63 /**
64 * Table for Max Thermal Zone
65 *
66 *
67 *
68 *
69 */
70 UINT8 MaxZone[] =
71 {
72 4,
73 4,
74 4,
75 4,
76 };
77
78
79 /**
80 * Table for Max Register
81 *
82 *
83 *
84 *
85 */
86 UINT8 MaxRegister[] =
87 {
88 MSG_REG9,
89 MSG_REGB,
90 MSG_REG9,
91 MSG_REGA,
92 };
93
94 /*-------------------------------------------------------------------------------
95 ;Procedure: IsZoneFuncEnable
96 ;
97 ;Description: This routine will check every zone support function with BitMap from user define
98 ;
99 ;
100 ;Exit: None
101 ;
102 ;Modified: None
103 ;
104 ;-----------------------------------------------------------------------------
105 */
106 STATIC BOOLEAN
IsZoneFuncEnable(IN UINT16 Flag,IN UINT8 func,IN UINT8 Zone)107 IsZoneFuncEnable (
108 IN UINT16 Flag,
109 IN UINT8 func,
110 IN UINT8 Zone
111 )
112 {
113 return (BOOLEAN) (((Flag >> (func *4)) & 0xF) & ((UINT8 )1 << Zone));
114 }
115
116 /*-------------------------------------------------------------------------------
117 ;Procedure: FchECfancontrolservice
118 ;
119 ;Description: This routine service EC fan policy
120 ;
121 ;
122 ;Exit: None
123 ;
124 ;Modified: None
125 ;
126 ;-----------------------------------------------------------------------------
127 */
128 VOID
FchECfancontrolservice(IN VOID * FchDataPtr)129 FchECfancontrolservice (
130 IN VOID *FchDataPtr
131 )
132 {
133 UINT8 ZoneNum;
134 UINT8 FunNum;
135 UINT8 RegNum;
136 UINT8 *CurPoint;
137 UINT8 FunIndex;
138 BOOLEAN IsSendEcMsg;
139 FCH_DATA_BLOCK *LocalCfgPtr;
140 AMD_CONFIG_PARAMS *StdHeader;
141
142 LocalCfgPtr = (FCH_DATA_BLOCK *) FchDataPtr;
143 StdHeader = LocalCfgPtr->StdHeader;
144
145 if (!IsImcEnabled (StdHeader)) {
146 return; //IMC is not enabled
147 }
148
149 CurPoint = &LocalCfgPtr->Imc.EcStruct.MsgFun81Zone0MsgReg0 + MaxZone[0] * (MaxRegister[0] - MSG_REG0 + 1);
150
151 for ( FunIndex = 1; FunIndex <= 3; FunIndex++ ) {
152 FunNum = FunctionNumber[FunIndex];
153 for ( ZoneNum = 0; ZoneNum < MaxZone[FunIndex]; ZoneNum++ ) {
154 IsSendEcMsg = IsZoneFuncEnable (LocalCfgPtr->Imc.EcStruct.IMCFUNSupportBitMap, FunIndex, ZoneNum);
155 if (IsSendEcMsg) {
156 for ( RegNum = MSG_REG0; RegNum <= MaxRegister[FunIndex]; RegNum++ ) {
157 WriteECmsg (RegNum, AccessWidth8, CurPoint, StdHeader);
158 CurPoint += 1;
159 }
160 WriteECmsg (MSG_SYS_TO_IMC, AccessWidth8, &FunNum, StdHeader); // function number
161 WaitForEcLDN9MailboxCmdAck (StdHeader);
162 } else {
163 CurPoint += (MaxRegister[FunIndex] - MSG_REG0 + 1);
164 }
165 }
166 }
167
168 CurPoint = &LocalCfgPtr->Imc.EcStruct.MsgFun81Zone0MsgReg0;
169 for ( FunIndex = 0; FunIndex <= 0; FunIndex++ ) {
170 FunNum = FunctionNumber[FunIndex];
171 for ( ZoneNum = 0; ZoneNum < MaxZone[FunIndex]; ZoneNum++ ) {
172 IsSendEcMsg = IsZoneFuncEnable (LocalCfgPtr->Imc.EcStruct.IMCFUNSupportBitMap, FunIndex, ZoneNum);
173 if (IsSendEcMsg) {
174 for ( RegNum = MSG_REG0; RegNum <= MaxRegister[FunIndex]; RegNum++ ) {
175 if (RegNum == MSG_REG2) {
176 *CurPoint &= 0xFE;
177 }
178 WriteECmsg (RegNum, AccessWidth8, CurPoint, StdHeader);
179 CurPoint += 1;
180 }
181 WriteECmsg (MSG_SYS_TO_IMC, AccessWidth8, &FunNum, StdHeader); // function number
182 WaitForEcLDN9MailboxCmdAck (StdHeader);
183 } else {
184 CurPoint += (MaxRegister[FunIndex] - MSG_REG0 + 1);
185 }
186 }
187 }
188 }
189
190