Frank Vibrans | 2b4c831 | 2011-02-14 18:30:54 +0000 | [diff] [blame^] | 1 | /* |
| 2 | ***************************************************************************** |
| 3 | * |
| 4 | * Copyright (c) 2011, Advanced Micro Devices, Inc. |
| 5 | * All rights reserved. |
| 6 | * |
| 7 | * Redistribution and use in source and binary forms, with or without |
| 8 | * modification, are permitted provided that the following conditions are met: |
| 9 | * * Redistributions of source code must retain the above copyright |
| 10 | * notice, this list of conditions and the following disclaimer. |
| 11 | * * Redistributions in binary form must reproduce the above copyright |
| 12 | * notice, this list of conditions and the following disclaimer in the |
| 13 | * documentation and/or other materials provided with the distribution. |
| 14 | * * Neither the name of Advanced Micro Devices, Inc. nor the names of |
| 15 | * its contributors may be used to endorse or promote products derived |
| 16 | * from this software without specific prior written permission. |
| 17 | * |
| 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
| 19 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 20 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 21 | * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY |
| 22 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 23 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 24 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
| 25 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 27 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 28 | * |
| 29 | * *************************************************************************** |
| 30 | * |
| 31 | */ |
| 32 | |
| 33 | |
| 34 | #include "SBPLATFORM.h" |
| 35 | #include "ECfan.h" |
| 36 | /** |
| 37 | * Table for Function Number |
| 38 | * |
| 39 | * |
| 40 | * |
| 41 | * |
| 42 | */ |
| 43 | const static UINT8 FunctionNumber[] = |
| 44 | { |
| 45 | Fun_81, |
| 46 | Fun_83, |
| 47 | Fun_85, |
| 48 | Fun_89, |
| 49 | }; |
| 50 | |
| 51 | /** |
| 52 | * Table for Max Thermal Zone |
| 53 | * |
| 54 | * |
| 55 | * |
| 56 | * |
| 57 | */ |
| 58 | const static UINT8 MaxZone[] = |
| 59 | { |
| 60 | 4, |
| 61 | 4, |
| 62 | 4, |
| 63 | 4, |
| 64 | }; |
| 65 | |
| 66 | /** |
| 67 | * Table for Max Register |
| 68 | * |
| 69 | * |
| 70 | * |
| 71 | * |
| 72 | */ |
| 73 | const static UINT8 MaxRegister[] = |
| 74 | { |
| 75 | MSG_REG9, |
| 76 | MSG_REGB, |
| 77 | MSG_REG9, |
| 78 | MSG_REGA, |
| 79 | }; |
| 80 | |
| 81 | /*------------------------------------------------------------------------------- |
| 82 | ;Procedure: IsZoneFuncEnable |
| 83 | ; |
| 84 | ;Description: This routine will check every zone support function with BitMap from user define |
| 85 | ; |
| 86 | ; |
| 87 | ;Exit: None |
| 88 | ; |
| 89 | ;Modified: None |
| 90 | ; |
| 91 | ;----------------------------------------------------------------------------- |
| 92 | */ |
| 93 | BOOLEAN |
| 94 | IsZoneFuncEnable ( |
| 95 | UINT16 Flag, |
| 96 | UINT8 func, |
| 97 | UINT8 Zone |
| 98 | ) |
| 99 | { |
| 100 | return (BOOLEAN)(((Flag >> (func *4)) & 0xF) & ((UINT8 )1 << Zone)); |
| 101 | } |
| 102 | |
| 103 | /*------------------------------------------------------------------------------- |
| 104 | ;Procedure: sbECfancontrolservice |
| 105 | ; |
| 106 | ;Description: This routine service EC fan policy |
| 107 | ; |
| 108 | ; |
| 109 | ;Exit: None |
| 110 | ; |
| 111 | ;Modified: None |
| 112 | ; |
| 113 | ;----------------------------------------------------------------------------- |
| 114 | */ |
| 115 | VOID |
| 116 | sbECfancontrolservice ( |
| 117 | IN AMDSBCFG* pConfig |
| 118 | ) |
| 119 | { |
| 120 | UINT8 ZoneNum; |
| 121 | UINT8 FunNum; |
| 122 | UINT8 RegNum; |
| 123 | UINT8 * CurPoint; |
| 124 | UINT8 FunIndex; |
| 125 | BOOLEAN IsSendEcMsg; |
| 126 | |
| 127 | CurPoint = &pConfig->Pecstruct.MSGFun81zone0MSGREG0 + MaxZone[0] * (MaxRegister[0] - MSG_REG0 + 1); |
| 128 | for ( FunIndex = 1; FunIndex <= 3; FunIndex++ ) { |
| 129 | FunNum = FunctionNumber[FunIndex]; |
| 130 | for ( ZoneNum = 0; ZoneNum < MaxZone[FunIndex]; ZoneNum++ ) { |
| 131 | IsSendEcMsg = IsZoneFuncEnable (pConfig->Pecstruct.IMCFUNSupportBitMap, FunIndex, ZoneNum); |
| 132 | for ( RegNum = MSG_REG0; RegNum <= MaxRegister[FunIndex]; RegNum++ ) { |
| 133 | if (IsSendEcMsg) { |
| 134 | WriteECmsg (RegNum, AccWidthUint8, CurPoint); // |
| 135 | } |
| 136 | CurPoint += 1; |
| 137 | } |
| 138 | if (IsSendEcMsg) { |
| 139 | WriteECmsg (MSG_SYS_TO_IMC, AccWidthUint8, &FunNum); // function number |
| 140 | WaitForEcLDN9MailboxCmdAck (); |
| 141 | } |
| 142 | } |
| 143 | } |
| 144 | CurPoint = &pConfig->Pecstruct.MSGFun81zone0MSGREG0; |
| 145 | for ( FunIndex = 0; FunIndex <= 0; FunIndex++ ) { |
| 146 | FunNum = FunctionNumber[FunIndex]; |
| 147 | for ( ZoneNum = 0; ZoneNum < MaxZone[FunIndex]; ZoneNum++ ) { |
| 148 | IsSendEcMsg = IsZoneFuncEnable (pConfig->Pecstruct.IMCFUNSupportBitMap, FunIndex, ZoneNum); |
| 149 | for ( RegNum = MSG_REG0; RegNum <= MaxRegister[FunIndex]; RegNum++ ) { |
| 150 | if (IsSendEcMsg) { |
| 151 | WriteECmsg (RegNum, AccWidthUint8, CurPoint); // |
| 152 | } |
| 153 | CurPoint += 1; |
| 154 | } |
| 155 | if (IsSendEcMsg) { |
| 156 | WriteECmsg (MSG_SYS_TO_IMC, AccWidthUint8, &FunNum); // function number |
| 157 | WaitForEcLDN9MailboxCmdAck (); |
| 158 | } |
| 159 | } |
| 160 | } |
| 161 | } |
| 162 | |
| 163 | /*------------------------------------------------------------------------------- |
| 164 | ;Procedure: SBIMCFanInitializeS3 |
| 165 | ; |
| 166 | ;Description: This routine initialize IMC fan when S3 resume |
| 167 | ; |
| 168 | ; |
| 169 | ;Exit: None |
| 170 | ; |
| 171 | ;Modified: None |
| 172 | ; |
| 173 | ;----------------------------------------------------------------------------- |
| 174 | */ |
| 175 | VOID |
| 176 | SBIMCFanInitializeS3 (VOID) |
| 177 | { |
| 178 | UINT8 dbPortStatus,Value80,Value82,Value83,Value84; |
| 179 | |
| 180 | getChipSysMode (&dbPortStatus); |
| 181 | if ((dbPortStatus & ChipSysEcEnable) != 0) { |
| 182 | Value80 = 0x98; |
| 183 | Value82 = 0x00; |
| 184 | Value83 = 0x02; |
| 185 | Value84 = 0x00; |
| 186 | |
| 187 | // Clear MSG_REG0 to receive acknowledge byte |
| 188 | WriteECmsg (MSG_REG0, AccWidthUint8, &Value82); |
| 189 | |
| 190 | // Set MSG_REG1 |
| 191 | // 0x02 - Notify IMC that the system is waken from any sleep state |
| 192 | WriteECmsg (MSG_REG1, AccWidthUint8, &Value83); |
| 193 | |
| 194 | // Set timeout counter value to 00 which disables watchdog timer |
| 195 | WriteECmsg (MSG_REG2, AccWidthUint8, &Value84); |
| 196 | |
| 197 | // Write mailbox function number to kick off the command |
| 198 | // 0x98 - IMC System Sleep and Wake Services |
| 199 | WriteECmsg (MSG_SYS_TO_IMC, AccWidthUint8, &Value80); |
| 200 | |
| 201 | // Read acknowledge byte to make sure function is executed properly |
| 202 | WaitForEcLDN9MailboxCmdAck (); |
| 203 | } |
| 204 | } |