Fabian Kunkel | 171e2c9 | 2016-07-27 17:30:49 +0200 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2012 Advanced Micro Devices, Inc. |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; version 2 of the License. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | */ |
| 15 | |
Elyes HAOUAS | 19f5ba8 | 2018-10-14 14:52:06 +0200 | [diff] [blame] | 16 | #include <AGESA.h> |
Kyösti Mälkki | 9de8261 | 2017-04-13 16:56:07 +0300 | [diff] [blame] | 17 | #include <northbridge/amd/agesa/BiosCallOuts.h> |
Elyes HAOUAS | 19f5ba8 | 2018-10-14 14:52:06 +0200 | [diff] [blame] | 18 | #include <FchPlatform.h> |
| 19 | #include <cbfs.h> |
Fabian Kunkel | 171e2c9 | 2016-07-27 17:30:49 +0200 | [diff] [blame] | 20 | #include "imc.h" |
Fabian Kunkel | 171e2c9 | 2016-07-27 17:30:49 +0200 | [diff] [blame] | 21 | #include "hudson.h" |
| 22 | #include <stdlib.h> |
Patrick Georgi | 0e3c59e | 2017-01-28 15:59:25 +0100 | [diff] [blame] | 23 | #include <spd_bin.h> |
Fabian Kunkel | 171e2c9 | 2016-07-27 17:30:49 +0200 | [diff] [blame] | 24 | |
Stefan Reinauer | 8d29dd1 | 2017-06-26 14:30:39 -0700 | [diff] [blame] | 25 | static AGESA_STATUS Fch_Oem_config(UINT32 Func, UINTN FchData, VOID *ConfigPtr); |
Fabian Kunkel | cf05183 | 2016-07-27 17:42:39 +0200 | [diff] [blame] | 26 | static AGESA_STATUS board_ReadSpd_from_cbfs(UINT32 Func, UINTN Data, VOID *ConfigPtr); |
Fabian Kunkel | 171e2c9 | 2016-07-27 17:30:49 +0200 | [diff] [blame] | 27 | |
| 28 | const BIOS_CALLOUT_STRUCT BiosCallouts[] = |
| 29 | { |
Fabian Kunkel | cf05183 | 2016-07-27 17:42:39 +0200 | [diff] [blame] | 30 | {AGESA_READ_SPD, board_ReadSpd_from_cbfs }, |
Fabian Kunkel | 171e2c9 | 2016-07-27 17:30:49 +0200 | [diff] [blame] | 31 | {AGESA_DO_RESET, agesa_Reset }, |
| 32 | {AGESA_READ_SPD_RECOVERY, agesa_NoopUnsupported }, |
| 33 | {AGESA_RUNFUNC_ONAP, agesa_RunFuncOnAp }, |
| 34 | {AGESA_GET_IDS_INIT_DATA, agesa_EmptyIdsInitData }, |
| 35 | {AGESA_HOOKBEFORE_DQS_TRAINING, agesa_NoopSuccess }, |
| 36 | {AGESA_HOOKBEFORE_EXIT_SELF_REF, agesa_NoopSuccess }, |
| 37 | {AGESA_FCH_OEM_CALLOUT, Fch_Oem_config }, |
| 38 | {AGESA_GNB_GFX_GET_VBIOS_IMAGE, agesa_GfxGetVbiosImage } |
| 39 | }; |
| 40 | const int BiosCalloutsLen = ARRAY_SIZE(BiosCallouts); |
| 41 | |
| 42 | /** |
| 43 | * Realtek ALC272 CODEC Verb Table |
| 44 | */ |
| 45 | static const CODEC_ENTRY Alc272_VerbTbl[] = { |
| 46 | {0x11, 0x411111F0}, // - SPDIF_OUT2 |
| 47 | {0x12, 0x411111F0}, // - DMIC_1/2 |
| 48 | {0x13, 0x411111F0}, // - DMIC_3/4 |
| 49 | {0x14, 0x411111F0}, // Port D - LOUT1 |
| 50 | {0x15, 0x411111F0}, // Port A - LOUT2 |
| 51 | {0x16, 0x411111F0}, // |
| 52 | {0x17, 0x411111F0}, // Port H - MONO |
| 53 | {0x18, 0x01a19840}, // Port B - MIC1 |
| 54 | {0x19, 0x411111F0}, // Port F - MIC2 |
| 55 | {0x1a, 0x01813030}, // Port C - LINE1 |
| 56 | {0x1b, 0x411111F0}, // Port E - LINE2 |
| 57 | {0x1d, 0x40251E05}, // - PCBEEP |
| 58 | {0x1e, 0x01441120}, // - SPDIF_OUT1 |
| 59 | {0x21, 0x01214010}, // Port I - HPOUT |
| 60 | {0xff, 0xffffffff} |
| 61 | }; |
| 62 | |
| 63 | static const CODEC_TBL_LIST CodecTableList[] = |
| 64 | { |
| 65 | {0x10ec0272, (CODEC_ENTRY*)&Alc272_VerbTbl[0]}, |
| 66 | {(UINT32)0x0FFFFFFFF, (CODEC_ENTRY*)0x0FFFFFFFFUL} |
| 67 | }; |
| 68 | |
| 69 | #define FAN_INPUT_INTERNAL_DIODE 0 |
| 70 | #define FAN_INPUT_TEMP0 1 |
| 71 | #define FAN_INPUT_TEMP1 2 |
| 72 | #define FAN_INPUT_TEMP2 3 |
| 73 | #define FAN_INPUT_TEMP3 4 |
| 74 | #define FAN_INPUT_TEMP0_FILTER 5 |
| 75 | #define FAN_INPUT_ZERO 6 |
| 76 | #define FAN_INPUT_DISABLED 7 |
| 77 | |
| 78 | #define FAN_AUTOMODE (1 << 0) |
| 79 | #define FAN_LINEARMODE (1 << 1) |
| 80 | #define FAN_STEPMODE ~(1 << 1) |
| 81 | #define FAN_POLARITY_HIGH (1 << 2) |
| 82 | #define FAN_POLARITY_LOW ~(1 << 2) |
| 83 | |
| 84 | /* Normally, 4-wire fan runs at 25KHz and 3-wire fan runs at 100Hz */ |
| 85 | #define FREQ_28KHZ 0x0 |
| 86 | #define FREQ_25KHZ 0x1 |
| 87 | #define FREQ_23KHZ 0x2 |
| 88 | #define FREQ_21KHZ 0x3 |
| 89 | #define FREQ_29KHZ 0x4 |
| 90 | #define FREQ_18KHZ 0x5 |
| 91 | #define FREQ_100HZ 0xF7 |
| 92 | #define FREQ_87HZ 0xF8 |
| 93 | #define FREQ_58HZ 0xF9 |
| 94 | #define FREQ_44HZ 0xFA |
| 95 | #define FREQ_35HZ 0xFB |
| 96 | #define FREQ_29HZ 0xFC |
| 97 | #define FREQ_22HZ 0xFD |
| 98 | #define FREQ_14HZ 0xFE |
| 99 | #define FREQ_11HZ 0xFF |
| 100 | |
| 101 | /* |
| 102 | * Hardware Monitor Fan Control |
| 103 | * Hardware limitation: |
| 104 | * HWM will fail to read the input temperature via I2C if other |
| 105 | * software switches the I2C address. AMD recommends using IMC |
| 106 | * to control fans, instead of HWM. |
| 107 | */ |
Martin Roth | 0ff2e01 | 2017-07-20 20:54:36 -0600 | [diff] [blame] | 108 | static void oem_fan_control(FCH_DATA_BLOCK *FchParams) |
Fabian Kunkel | 171e2c9 | 2016-07-27 17:30:49 +0200 | [diff] [blame] | 109 | { |
| 110 | FCH_HWM_FAN_CTR oem_factl[5] = { |
| 111 | /*temperature input, fan mode, frequency, low_duty, med_duty, multiplier, lowtemp, medtemp, hightemp, LinearRange, LinearHoldCount */ |
| 112 | /* DB-FT3 FanOUT0 Fan header J32 */ |
| 113 | {FAN_INPUT_INTERNAL_DIODE, (FAN_STEPMODE | FAN_POLARITY_HIGH), FREQ_100HZ, 40, 60, 0, 40, 65, 85, 0, 0}, |
| 114 | /* DB-FT3 FanOUT1 Fan header J31*/ |
| 115 | {FAN_INPUT_INTERNAL_DIODE, (FAN_STEPMODE | FAN_POLARITY_HIGH), FREQ_100HZ, 40, 60, 0, 40, 65, 85, 0, 0}, |
| 116 | {FAN_INPUT_INTERNAL_DIODE, (FAN_STEPMODE | FAN_POLARITY_HIGH), FREQ_100HZ, 40, 60, 0, 40, 65, 85, 0, 0}, |
| 117 | {FAN_INPUT_INTERNAL_DIODE, (FAN_STEPMODE | FAN_POLARITY_HIGH), FREQ_100HZ, 40, 60, 0, 40, 65, 85, 0, 0}, |
| 118 | {FAN_INPUT_INTERNAL_DIODE, (FAN_STEPMODE | FAN_POLARITY_HIGH), FREQ_100HZ, 40, 60, 0, 40, 65, 85, 0, 0}, |
| 119 | }; |
Elyes HAOUAS | ec28aad | 2016-10-03 21:32:58 +0200 | [diff] [blame] | 120 | LibAmdMemCopy ((VOID *)(FchParams->Hwm.HwmFanControl), &oem_factl, (sizeof(FCH_HWM_FAN_CTR) * 5), FchParams->StdHeader); |
Fabian Kunkel | 171e2c9 | 2016-07-27 17:30:49 +0200 | [diff] [blame] | 121 | |
| 122 | /* Enable IMC fan control. the recommended way */ |
Marshall Dawson | 23e5ba9 | 2017-08-16 17:21:41 -0600 | [diff] [blame] | 123 | if (IS_ENABLED(CONFIG_HUDSON_IMC_FWM)) { |
| 124 | /* HwMonitorEnable = TRUE && HwmFchtsiAutoOpll ==FALSE to call FchECfancontrolservice */ |
| 125 | FchParams->Hwm.HwMonitorEnable = TRUE; |
| 126 | FchParams->Hwm.HwmFchtsiAutoPoll = FALSE; /* 0 disable, 1 enable TSI Auto Polling */ |
Fabian Kunkel | 171e2c9 | 2016-07-27 17:30:49 +0200 | [diff] [blame] | 127 | |
Marshall Dawson | 23e5ba9 | 2017-08-16 17:21:41 -0600 | [diff] [blame] | 128 | FchParams->Imc.ImcEnable = TRUE; |
| 129 | FchParams->Hwm.HwmControl = 1; /* 1 IMC, 0 HWM */ |
Elyes HAOUAS | a342f39 | 2018-10-17 10:56:26 +0200 | [diff] [blame] | 130 | FchParams->Imc.ImcEnableOverWrite = 1; /* 2 disable IMC, 1 enable IMC, 0 following hw strap setting */ |
Fabian Kunkel | 171e2c9 | 2016-07-27 17:30:49 +0200 | [diff] [blame] | 131 | |
Marshall Dawson | 23e5ba9 | 2017-08-16 17:21:41 -0600 | [diff] [blame] | 132 | LibAmdMemFill(&(FchParams->Imc.EcStruct), 0, sizeof(FCH_EC), FchParams->StdHeader); |
Fabian Kunkel | 171e2c9 | 2016-07-27 17:30:49 +0200 | [diff] [blame] | 133 | |
Marshall Dawson | 23e5ba9 | 2017-08-16 17:21:41 -0600 | [diff] [blame] | 134 | /* Thermal Zone Parameter */ |
| 135 | FchParams->Imc.EcStruct.MsgFun81Zone0MsgReg0 = 0x00; |
| 136 | FchParams->Imc.EcStruct.MsgFun81Zone0MsgReg1 = 0x00; /* Zone */ |
| 137 | FchParams->Imc.EcStruct.MsgFun81Zone0MsgReg2 = 0x3d; //BIT0 | BIT2 | BIT5; |
| 138 | FchParams->Imc.EcStruct.MsgFun81Zone0MsgReg3 = 0x4e; //6 | BIT3; |
| 139 | FchParams->Imc.EcStruct.MsgFun81Zone0MsgReg4 = 0x00; |
| 140 | FchParams->Imc.EcStruct.MsgFun81Zone0MsgReg5 = 0x04; |
| 141 | FchParams->Imc.EcStruct.MsgFun81Zone0MsgReg6 = 0x9a; /* SMBUS Address for SMBUS based temperature sensor such as SB-TSI and ADM1032 */ |
| 142 | FchParams->Imc.EcStruct.MsgFun81Zone0MsgReg7 = 0x01; |
| 143 | FchParams->Imc.EcStruct.MsgFun81Zone0MsgReg8 = 0x01; /* PWM steping rate in unit of PWM level percentage */ |
| 144 | FchParams->Imc.EcStruct.MsgFun81Zone0MsgReg9 = 0x00; |
Fabian Kunkel | 171e2c9 | 2016-07-27 17:30:49 +0200 | [diff] [blame] | 145 | |
Marshall Dawson | 23e5ba9 | 2017-08-16 17:21:41 -0600 | [diff] [blame] | 146 | /* IMC Fan Policy temperature thresholds */ |
| 147 | FchParams->Imc.EcStruct.MsgFun83Zone0MsgReg0 = 0x00; |
| 148 | FchParams->Imc.EcStruct.MsgFun83Zone0MsgReg1 = 0x00; /* Zone */ |
| 149 | FchParams->Imc.EcStruct.MsgFun83Zone0MsgReg2 = 0x46; /*AC0 threshold in Celsius */ |
| 150 | FchParams->Imc.EcStruct.MsgFun83Zone0MsgReg3 = 0x3c; /*AC1 threshold in Celsius */ |
| 151 | FchParams->Imc.EcStruct.MsgFun83Zone0MsgReg4 = 0x32; /*AC2 threshold in Celsius */ |
| 152 | FchParams->Imc.EcStruct.MsgFun83Zone0MsgReg5 = 0xff; /*AC3 threshold in Celsius, 0xFF is not define */ |
| 153 | FchParams->Imc.EcStruct.MsgFun83Zone0MsgReg6 = 0xff; /*AC4 threshold in Celsius, 0xFF is not define */ |
| 154 | FchParams->Imc.EcStruct.MsgFun83Zone0MsgReg7 = 0xff; /*AC5 threshold in Celsius, 0xFF is not define */ |
| 155 | FchParams->Imc.EcStruct.MsgFun83Zone0MsgReg8 = 0xff; /*AC6 threshold in Celsius, 0xFF is not define */ |
| 156 | FchParams->Imc.EcStruct.MsgFun83Zone0MsgReg9 = 0xff; /*AC7 lowest threshold in Celsius, 0xFF is not define */ |
| 157 | FchParams->Imc.EcStruct.MsgFun83Zone0MsgRegA = 0x4b; /*critical threshold* in Celsius, 0xFF is not define */ |
| 158 | FchParams->Imc.EcStruct.MsgFun83Zone0MsgRegB = 0x00; |
Fabian Kunkel | 171e2c9 | 2016-07-27 17:30:49 +0200 | [diff] [blame] | 159 | |
Marshall Dawson | 23e5ba9 | 2017-08-16 17:21:41 -0600 | [diff] [blame] | 160 | /* IMC Fan Policy PWM Settings */ |
| 161 | FchParams->Imc.EcStruct.MsgFun85Zone0MsgReg0 = 0x00; |
| 162 | FchParams->Imc.EcStruct.MsgFun85Zone0MsgReg1 = 0x00; /* Zone */ |
| 163 | FchParams->Imc.EcStruct.MsgFun85Zone0MsgReg2 = 0x5a; /* AL0 percentage */ |
| 164 | FchParams->Imc.EcStruct.MsgFun85Zone0MsgReg3 = 0x46; /* AL1 percentage */ |
| 165 | FchParams->Imc.EcStruct.MsgFun85Zone0MsgReg4 = 0x28; /* AL2 percentage */ |
| 166 | FchParams->Imc.EcStruct.MsgFun85Zone0MsgReg5 = 0xff; /* AL3 percentage */ |
| 167 | FchParams->Imc.EcStruct.MsgFun85Zone0MsgReg6 = 0xff; /* AL4 percentage */ |
| 168 | FchParams->Imc.EcStruct.MsgFun85Zone0MsgReg7 = 0xff; /* AL5 percentage */ |
| 169 | FchParams->Imc.EcStruct.MsgFun85Zone0MsgReg8 = 0xff; /* AL6 percentage */ |
| 170 | FchParams->Imc.EcStruct.MsgFun85Zone0MsgReg9 = 0xff; /* AL7 percentage */ |
Fabian Kunkel | 171e2c9 | 2016-07-27 17:30:49 +0200 | [diff] [blame] | 171 | |
Marshall Dawson | 23e5ba9 | 2017-08-16 17:21:41 -0600 | [diff] [blame] | 172 | FchParams->Imc.EcStruct.MsgFun81Zone1MsgReg0 = 0x00; |
| 173 | FchParams->Imc.EcStruct.MsgFun81Zone1MsgReg1 = 0x01; /* Zone */ |
| 174 | FchParams->Imc.EcStruct.MsgFun81Zone1MsgReg2 = 0x55; //BIT0 | BIT2 | BIT5; |
| 175 | FchParams->Imc.EcStruct.MsgFun81Zone1MsgReg3 = 0x17; |
| 176 | FchParams->Imc.EcStruct.MsgFun81Zone1MsgReg4 = 0x00; |
| 177 | FchParams->Imc.EcStruct.MsgFun81Zone1MsgReg5 = 0x00; |
| 178 | FchParams->Imc.EcStruct.MsgFun81Zone1MsgReg6 = 0x90; /* SMBUS Address for SMBUS based temperature sensor such as SB-TSI and ADM1032 */ |
| 179 | FchParams->Imc.EcStruct.MsgFun81Zone1MsgReg7 = 0; |
| 180 | FchParams->Imc.EcStruct.MsgFun81Zone1MsgReg8 = 0; /* PWM steping rate in unit of PWM level percentage */ |
| 181 | FchParams->Imc.EcStruct.MsgFun81Zone1MsgReg9 = 0; |
Fabian Kunkel | 171e2c9 | 2016-07-27 17:30:49 +0200 | [diff] [blame] | 182 | |
Marshall Dawson | 23e5ba9 | 2017-08-16 17:21:41 -0600 | [diff] [blame] | 183 | FchParams->Imc.EcStruct.MsgFun83Zone1MsgReg0 = 0x00; |
| 184 | FchParams->Imc.EcStruct.MsgFun83Zone1MsgReg1 = 0x01; /* zone */ |
| 185 | FchParams->Imc.EcStruct.MsgFun83Zone1MsgReg2 = 60; /*AC0 threshold in Celsius */ |
| 186 | FchParams->Imc.EcStruct.MsgFun83Zone1MsgReg3 = 40; /*AC1 threshold in Celsius */ |
| 187 | FchParams->Imc.EcStruct.MsgFun83Zone1MsgReg4 = 0; /*AC2 threshold in Celsius */ |
| 188 | FchParams->Imc.EcStruct.MsgFun83Zone1MsgReg5 = 0; /*AC3 threshold in Celsius, 0xFF is not define */ |
| 189 | FchParams->Imc.EcStruct.MsgFun83Zone1MsgReg6 = 0; /*AC4 threshold in Celsius, 0xFF is not define */ |
| 190 | FchParams->Imc.EcStruct.MsgFun83Zone1MsgReg7 = 0; /*AC5 threshold in Celsius, 0xFF is not define */ |
| 191 | FchParams->Imc.EcStruct.MsgFun83Zone1MsgReg8 = 0; /*AC6 threshold in Celsius, 0xFF is not define */ |
| 192 | FchParams->Imc.EcStruct.MsgFun83Zone1MsgReg9 = 0; /*AC7 lowest threshold in Celsius, 0xFF is not define */ |
| 193 | FchParams->Imc.EcStruct.MsgFun83Zone1MsgRegA = 0; /*critical threshold* in Celsius, 0xFF is not define */ |
| 194 | FchParams->Imc.EcStruct.MsgFun83Zone1MsgRegB = 0x00; |
Fabian Kunkel | 171e2c9 | 2016-07-27 17:30:49 +0200 | [diff] [blame] | 195 | |
Marshall Dawson | 23e5ba9 | 2017-08-16 17:21:41 -0600 | [diff] [blame] | 196 | FchParams->Imc.EcStruct.MsgFun85Zone1MsgReg0 = 0x00; |
| 197 | FchParams->Imc.EcStruct.MsgFun85Zone1MsgReg1 = 0x01; /*Zone */ |
| 198 | FchParams->Imc.EcStruct.MsgFun85Zone1MsgReg2 = 0; /* AL0 percentage */ |
| 199 | FchParams->Imc.EcStruct.MsgFun85Zone1MsgReg3 = 0; /* AL1 percentage */ |
| 200 | FchParams->Imc.EcStruct.MsgFun85Zone1MsgReg4 = 0; /* AL2 percentage */ |
| 201 | FchParams->Imc.EcStruct.MsgFun85Zone1MsgReg5 = 0x00; /* AL3 percentage */ |
| 202 | FchParams->Imc.EcStruct.MsgFun85Zone1MsgReg6 = 0x00; /* AL4 percentage */ |
| 203 | FchParams->Imc.EcStruct.MsgFun85Zone1MsgReg7 = 0x00; /* AL5 percentage */ |
| 204 | FchParams->Imc.EcStruct.MsgFun85Zone1MsgReg8 = 0x00; /* AL6 percentage */ |
| 205 | FchParams->Imc.EcStruct.MsgFun85Zone1MsgReg9 = 0x00; /* AL7 percentage */ |
Fabian Kunkel | 171e2c9 | 2016-07-27 17:30:49 +0200 | [diff] [blame] | 206 | |
Marshall Dawson | 23e5ba9 | 2017-08-16 17:21:41 -0600 | [diff] [blame] | 207 | FchParams->Imc.EcStruct.MsgFun81Zone2MsgReg0 = 0x00; |
| 208 | FchParams->Imc.EcStruct.MsgFun81Zone2MsgReg1 = 0x2; /* Zone */ |
| 209 | FchParams->Imc.EcStruct.MsgFun81Zone2MsgReg2 = 0x0; //BIT0 | BIT2 | BIT5; |
| 210 | FchParams->Imc.EcStruct.MsgFun81Zone2MsgReg3 = 0x0; |
| 211 | FchParams->Imc.EcStruct.MsgFun81Zone2MsgReg4 = 0x00; |
| 212 | FchParams->Imc.EcStruct.MsgFun81Zone2MsgReg5 = 0x00; |
| 213 | FchParams->Imc.EcStruct.MsgFun81Zone2MsgReg6 = 0x98; /* SMBUS Address for SMBUS based temperature sensor such as SB-TSI and ADM1032 */ |
| 214 | FchParams->Imc.EcStruct.MsgFun81Zone2MsgReg7 = 2; |
| 215 | FchParams->Imc.EcStruct.MsgFun81Zone2MsgReg8 = 5; /* PWM steping rate in unit of PWM level percentage */ |
| 216 | FchParams->Imc.EcStruct.MsgFun81Zone2MsgReg9 = 0; |
Fabian Kunkel | 171e2c9 | 2016-07-27 17:30:49 +0200 | [diff] [blame] | 217 | |
Marshall Dawson | 23e5ba9 | 2017-08-16 17:21:41 -0600 | [diff] [blame] | 218 | FchParams->Imc.EcStruct.MsgFun81Zone3MsgReg0 = 0x00; |
| 219 | FchParams->Imc.EcStruct.MsgFun81Zone3MsgReg1 = 0x3; /* Zone */ |
| 220 | FchParams->Imc.EcStruct.MsgFun81Zone3MsgReg2 = 0x0; //BIT0 | BIT2 | BIT5; |
| 221 | FchParams->Imc.EcStruct.MsgFun81Zone3MsgReg3 = 0x0; |
| 222 | FchParams->Imc.EcStruct.MsgFun81Zone3MsgReg4 = 0x00; |
| 223 | FchParams->Imc.EcStruct.MsgFun81Zone3MsgReg5 = 0x00; |
| 224 | FchParams->Imc.EcStruct.MsgFun81Zone3MsgReg6 = 0x0; /* SMBUS Address for SMBUS based temperature sensor such as SB-TSI and ADM1032 */ |
| 225 | FchParams->Imc.EcStruct.MsgFun81Zone3MsgReg7 = 0; |
| 226 | FchParams->Imc.EcStruct.MsgFun81Zone3MsgReg8 = 0; /* PWM steping rate in unit of PWM level percentage */ |
| 227 | FchParams->Imc.EcStruct.MsgFun81Zone3MsgReg9 = 0; |
Fabian Kunkel | 171e2c9 | 2016-07-27 17:30:49 +0200 | [diff] [blame] | 228 | |
Marshall Dawson | 23e5ba9 | 2017-08-16 17:21:41 -0600 | [diff] [blame] | 229 | /* IMC Function */ |
| 230 | FchParams->Imc.EcStruct.IMCFUNSupportBitMap = 0x333; //BIT0 | BIT4 |BIT8; |
Fabian Kunkel | 171e2c9 | 2016-07-27 17:30:49 +0200 | [diff] [blame] | 231 | |
Marshall Dawson | 23e5ba9 | 2017-08-16 17:21:41 -0600 | [diff] [blame] | 232 | /* NOTE: |
| 233 | * FchInitLateHwm will overwrite the EcStruct with EcDefaultMessage, |
| 234 | * AGESA put EcDefaultMessage as global data in ROM, so we can't override it. |
| 235 | * so we remove it from AGESA code. Please See FchInitLateHwm. |
| 236 | */ |
| 237 | } else { |
| 238 | /* HWM fan control, using the alternative method */ |
| 239 | FchParams->Imc.ImcEnable = FALSE; |
| 240 | FchParams->Hwm.HwMonitorEnable = TRUE; |
| 241 | FchParams->Hwm.HwmFchtsiAutoPoll = TRUE; /* 1 enable, 0 disable TSI Auto Polling */ |
| 242 | } |
Fabian Kunkel | 171e2c9 | 2016-07-27 17:30:49 +0200 | [diff] [blame] | 243 | } |
| 244 | |
| 245 | /** |
| 246 | * Fch Oem setting callback |
| 247 | * |
| 248 | * Configure platform specific Hudson device, |
| 249 | * such Azalia, SATA, IMC etc. |
| 250 | */ |
Stefan Reinauer | 8d29dd1 | 2017-06-26 14:30:39 -0700 | [diff] [blame] | 251 | static AGESA_STATUS Fch_Oem_config(UINT32 Func, UINTN FchData, VOID *ConfigPtr) |
Fabian Kunkel | 171e2c9 | 2016-07-27 17:30:49 +0200 | [diff] [blame] | 252 | { |
| 253 | AMD_CONFIG_PARAMS *StdHeader = (AMD_CONFIG_PARAMS *)ConfigPtr; |
| 254 | if (StdHeader->Func == AMD_INIT_RESET) { |
| 255 | FCH_RESET_DATA_BLOCK *FchParams = (FCH_RESET_DATA_BLOCK *) FchData; |
| 256 | printk(BIOS_DEBUG, "Fch OEM config in INIT RESET "); |
| 257 | //FchParams_reset->EcChannel0 = TRUE; /* logical devicd 3 */ |
| 258 | FchParams->LegacyFree = CONFIG_HUDSON_LEGACY_FREE; |
| 259 | FchParams->FchReset.SataEnable = hudson_sata_enable(); |
| 260 | FchParams->FchReset.IdeEnable = hudson_ide_enable(); |
| 261 | FchParams->FchReset.Xhci0Enable = IS_ENABLED(CONFIG_HUDSON_XHCI_ENABLE); |
| 262 | FchParams->FchReset.Xhci1Enable = FALSE; |
| 263 | } else if (StdHeader->Func == AMD_INIT_ENV) { |
| 264 | FCH_DATA_BLOCK *FchParams = (FCH_DATA_BLOCK *)FchData; |
| 265 | printk(BIOS_DEBUG, "Fch OEM config in INIT ENV "); |
| 266 | |
| 267 | /* Azalia Controller OEM Codec Table Pointer */ |
| 268 | FchParams->Azalia.AzaliaOemCodecTablePtr = (CODEC_TBL_LIST *)(&CodecTableList[0]); |
| 269 | /* Azalia Controller Front Panel OEM Table Pointer */ |
| 270 | |
| 271 | /* Fan Control */ |
| 272 | oem_fan_control(FchParams); |
| 273 | |
| 274 | /* XHCI configuration */ |
| 275 | FchParams->Usb.Xhci0Enable = IS_ENABLED(CONFIG_HUDSON_XHCI_ENABLE); |
| 276 | FchParams->Usb.Xhci1Enable = FALSE; |
| 277 | |
| 278 | /* sata configuration */ |
| 279 | FchParams->Sata.SataClass = CONFIG_HUDSON_SATA_MODE; |
| 280 | switch ((SATA_CLASS)CONFIG_HUDSON_SATA_MODE) { |
| 281 | case SataRaid: |
| 282 | case SataAhci: |
| 283 | case SataAhci7804: |
| 284 | case SataLegacyIde: |
| 285 | FchParams->Sata.SataIdeMode = FALSE; |
| 286 | break; |
| 287 | case SataIde2Ahci: |
| 288 | case SataIde2Ahci7804: |
| 289 | default: /* SataNativeIde */ |
| 290 | FchParams->Sata.SataIdeMode = TRUE; |
| 291 | break; |
| 292 | } |
| 293 | } |
| 294 | printk(BIOS_DEBUG, "Done\n"); |
| 295 | |
| 296 | return AGESA_SUCCESS; |
| 297 | } |
Fabian Kunkel | cf05183 | 2016-07-27 17:42:39 +0200 | [diff] [blame] | 298 | |
| 299 | static AGESA_STATUS board_ReadSpd_from_cbfs(UINT32 Func, UINTN Data, VOID *ConfigPtr) |
| 300 | { |
| 301 | AGESA_STATUS Status = AGESA_UNSUPPORTED; |
| 302 | #ifdef __PRE_RAM__ |
| 303 | AGESA_READ_SPD_PARAMS *info = ConfigPtr; |
| 304 | u8 index; |
| 305 | |
| 306 | if (IS_ENABLED(CONFIG_BAP_E21_DDR3_1066)) |
| 307 | index = 1; |
| 308 | else if (IS_ENABLED(CONFIG_BAP_E21_DDR3_1333)) |
| 309 | index = 2; |
| 310 | else /* CONFIG_BAP_E21_DDR3_800 */ |
| 311 | index = 0; |
| 312 | |
| 313 | if (info->MemChannelId > 0) |
| 314 | return AGESA_UNSUPPORTED; |
| 315 | if (info->SocketId != 0) |
| 316 | return AGESA_UNSUPPORTED; |
| 317 | if (info->DimmId != 0) |
| 318 | return AGESA_UNSUPPORTED; |
| 319 | |
| 320 | /* Read index 0, first SPD_SIZE bytes of spd.bin file. */ |
Patrick Georgi | 2e08b59 | 2017-01-28 15:26:43 +0100 | [diff] [blame] | 321 | if (read_ddr3_spd_from_cbfs((u8 *)info->Buffer, index) < 0) |
Fabian Kunkel | cf05183 | 2016-07-27 17:42:39 +0200 | [diff] [blame] | 322 | die("No SPD data\n"); |
| 323 | |
| 324 | Status = AGESA_SUCCESS; |
| 325 | #endif |
| 326 | return Status; |
| 327 | } |