2 *****************************************************************************
\r
4 * This file is part of the coreboot project.
\r
6 * Copyright (C) 2010 Advanced Micro Devices, Inc.
\r
8 * This program is free software; you can redistribute it and/or modify
\r
9 * it under the terms of the GNU General Public License as published by
\r
10 * the Free Software Foundation; version 2 of the License.
\r
12 * This program is distributed in the hope that it will be useful,
\r
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
15 * GNU General Public License for more details.
\r
17 * You should have received a copy of the GNU General Public License
\r
18 * along with this program; if not, write to the Free Software
\r
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\r
20 * ***************************************************************************
\r
25 #include "SBPLATFORM.h"
\r
28 * Table for Function Number
\r
34 UINT8 FunctionNumber[] =
\r
43 * Table for Max Thermal Zone
\r
58 * Table for Max Register
\r
64 UINT8 MaxRegister[] =
\r
72 /*-------------------------------------------------------------------------------
\r
73 ;Procedure: IsZoneFuncEnable
\r
75 ;Description: This routine will check every zone support function with BitMap from user define
\r
82 ;-----------------------------------------------------------------------------
\r
91 return (BOOLEAN)(((Flag >> (func *4)) & 0xF) & ((UINT8 )1 << Zone));
\r
94 /*-------------------------------------------------------------------------------
\r
95 ;Procedure: sbECfancontrolservice
\r
97 ;Description: This routine service EC fan policy
\r
104 ;-----------------------------------------------------------------------------
\r
107 sbECfancontrolservice (
\r
108 IN AMDSBCFG* pConfig
\r
116 BOOLEAN IsSendEcMsg;
\r
118 CurPoint = &pConfig->Pecstruct.MSGFun81zone0MSGREG0 + MaxZone[0] * (MaxRegister[0] - MSG_REG0 + 1);
\r
119 for ( FunIndex = 1; FunIndex <= 3; FunIndex++ ) {
\r
120 FunNum = FunctionNumber[FunIndex];
\r
121 for ( ZoneNum = 0; ZoneNum < MaxZone[FunIndex]; ZoneNum++ ) {
\r
122 IsSendEcMsg = IsZoneFuncEnable (pConfig->Pecstruct.IMCFUNSupportBitMap, FunIndex, ZoneNum);
\r
123 for ( RegNum = MSG_REG0; RegNum <= MaxRegister[FunIndex]; RegNum++ ) {
\r
125 WriteECmsg (RegNum, AccWidthUint8, CurPoint); //
\r
130 WriteECmsg (MSG_SYS_TO_IMC, AccWidthUint8, &FunNum); // function number
\r
131 WaitForEcLDN9MailboxCmdAck ();
\r
135 CurPoint = &pConfig->Pecstruct.MSGFun81zone0MSGREG0;
\r
136 for ( FunIndex = 0; FunIndex <= 0; FunIndex++ ) {
\r
137 FunNum = FunctionNumber[FunIndex];
\r
138 for ( ZoneNum = 0; ZoneNum < MaxZone[FunIndex]; ZoneNum++ ) {
\r
139 IsSendEcMsg = IsZoneFuncEnable (pConfig->Pecstruct.IMCFUNSupportBitMap, FunIndex, ZoneNum);
\r
140 for ( RegNum = MSG_REG0; RegNum <= MaxRegister[FunIndex]; RegNum++ ) {
\r
142 WriteECmsg (RegNum, AccWidthUint8, CurPoint); //
\r
147 WriteECmsg (MSG_SYS_TO_IMC, AccWidthUint8, &FunNum); // function number
\r
148 WaitForEcLDN9MailboxCmdAck ();
\r
154 /*-------------------------------------------------------------------------------
\r
155 ;Procedure: SBIMCFanInitializeS3
\r
157 ;Description: This routine initialize IMC fan when S3 resume
\r
164 ;-----------------------------------------------------------------------------
\r
167 SBIMCFanInitializeS3 (VOID)
\r
169 UINT8 dbPortStatus,Value80,Value82,Value83,Value84;
\r
171 getChipSysMode (&dbPortStatus);
\r
172 if ((dbPortStatus & ChipSysEcEnable) != 0) {
\r
178 // Clear MSG_REG0 to receive acknowledge byte
\r
179 WriteECmsg (MSG_REG0, AccWidthUint8, &Value82);
\r
182 // 0x02 - Notify IMC that the system is waken from any sleep state
\r
183 WriteECmsg (MSG_REG1, AccWidthUint8, &Value83);
\r
185 // Set timeout counter value to 00 which disables watchdog timer
\r
186 WriteECmsg (MSG_REG2, AccWidthUint8, &Value84);
\r
188 // Write mailbox function number to kick off the command
\r
189 // 0x98 - IMC System Sleep and Wake Services
\r
190 WriteECmsg (MSG_SYS_TO_IMC, AccWidthUint8, &Value80);
\r
192 // Read acknowledge byte to make sure function is executed properly
\r
193 WaitForEcLDN9MailboxCmdAck ();
\r