Alexandru Gagniuc | fccfee3 | 2014-03-26 18:51:08 -0500 | [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 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program; if not, write to the Free Software |
| 17 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 18 | */ |
| 19 | |
Kyösti Mälkki | 526c2fb | 2014-07-10 22:16:58 +0300 | [diff] [blame] | 20 | #include "AGESA.h" |
Kyösti Mälkki | 26f297e | 2014-05-26 11:27:54 +0300 | [diff] [blame^] | 21 | #include <northbridge/amd/agesa/BiosCallOuts.h> |
Alexandru Gagniuc | fccfee3 | 2014-03-26 18:51:08 -0500 | [diff] [blame] | 22 | #include "OptionsIds.h" |
Alexandru Gagniuc | 1d87dac | 2014-03-28 14:48:13 -0500 | [diff] [blame] | 23 | |
| 24 | #include <cbfs.h> |
| 25 | #include <southbridge/amd/agesa/hudson/imc.h> |
| 26 | #include <vendorcode/amd/agesa/f15tn/Proc/Fch/FchPlatform.h> |
Kyösti Mälkki | 6025efa | 2014-05-05 13:20:56 +0300 | [diff] [blame] | 27 | #include <stdlib.h> |
Alexandru Gagniuc | fccfee3 | 2014-03-26 18:51:08 -0500 | [diff] [blame] | 28 | |
Kyösti Mälkki | f5f9e38 | 2014-10-17 23:21:01 +0300 | [diff] [blame] | 29 | static AGESA_STATUS Fch_Oem_config(UINT32 Func, UINT32 FchData, VOID *ConfigPtr); |
| 30 | |
Kyösti Mälkki | 6025efa | 2014-05-05 13:20:56 +0300 | [diff] [blame] | 31 | const BIOS_CALLOUT_STRUCT BiosCallouts[] = |
Alexandru Gagniuc | fccfee3 | 2014-03-26 18:51:08 -0500 | [diff] [blame] | 32 | { |
Kyösti Mälkki | ef9343c | 2014-05-04 11:42:55 +0300 | [diff] [blame] | 33 | {AGESA_ALLOCATE_BUFFER, agesa_AllocateBuffer }, |
| 34 | {AGESA_DEALLOCATE_BUFFER, agesa_DeallocateBuffer }, |
| 35 | {AGESA_LOCATE_BUFFER, agesa_LocateBuffer }, |
Kyösti Mälkki | 83cc3b0 | 2014-05-04 23:13:08 +0300 | [diff] [blame] | 36 | {AGESA_DO_RESET, agesa_Reset }, |
Kyösti Mälkki | c5cc9f2 | 2014-10-17 22:33:22 +0300 | [diff] [blame] | 37 | {AGESA_READ_SPD, agesa_ReadSpd }, |
Kyösti Mälkki | 83cc3b0 | 2014-05-04 23:13:08 +0300 | [diff] [blame] | 38 | {AGESA_READ_SPD_RECOVERY, agesa_NoopUnsupported }, |
| 39 | {AGESA_RUNFUNC_ONAP, agesa_RunFuncOnAp }, |
| 40 | {AGESA_GET_IDS_INIT_DATA, agesa_EmptyIdsInitData }, |
| 41 | {AGESA_HOOKBEFORE_DQS_TRAINING, agesa_NoopSuccess }, |
| 42 | {AGESA_HOOKBEFORE_EXIT_SELF_REF, agesa_NoopSuccess }, |
Alexandru Gagniuc | fccfee3 | 2014-03-26 18:51:08 -0500 | [diff] [blame] | 43 | {AGESA_FCH_OEM_CALLOUT, Fch_Oem_config }, |
Kyösti Mälkki | cb989f2 | 2014-05-04 23:13:08 +0300 | [diff] [blame] | 44 | {AGESA_GNB_GFX_GET_VBIOS_IMAGE, agesa_GfxGetVbiosImage } |
Alexandru Gagniuc | fccfee3 | 2014-03-26 18:51:08 -0500 | [diff] [blame] | 45 | }; |
Kyösti Mälkki | 6025efa | 2014-05-05 13:20:56 +0300 | [diff] [blame] | 46 | const int BiosCalloutsLen = ARRAY_SIZE(BiosCallouts); |
Alexandru Gagniuc | fccfee3 | 2014-03-26 18:51:08 -0500 | [diff] [blame] | 47 | |
| 48 | /** |
| 49 | * AMD Parmer Platform ALC272 Verb Table |
| 50 | */ |
| 51 | static const CODEC_ENTRY Parmer_Alc272_VerbTbl[] = { |
| 52 | {0x11, 0x411111F0}, |
| 53 | {0x12, 0x411111F0}, |
| 54 | {0x13, 0x411111F0}, |
| 55 | {0x14, 0x411111F0}, |
| 56 | {0x15, 0x411111F0}, |
| 57 | {0x16, 0x411111F0}, |
| 58 | {0x17, 0x411111F0}, |
| 59 | {0x18, 0x01a19840}, |
| 60 | {0x19, 0x411111F0}, |
| 61 | {0x1a, 0x01813030}, |
| 62 | {0x1b, 0x411111F0}, |
| 63 | {0x1d, 0x40130605}, |
| 64 | {0x1e, 0x01441120}, |
| 65 | {0x21, 0x01211010}, |
| 66 | {0xff, 0xffffffff} |
| 67 | }; |
| 68 | |
| 69 | static const CODEC_TBL_LIST CodecTableList[] = |
| 70 | { |
| 71 | {0x10ec0272, (CODEC_ENTRY*)&Parmer_Alc272_VerbTbl[0]}, |
| 72 | {(UINT32)0x0FFFFFFFF, (CODEC_ENTRY*)0x0FFFFFFFFUL} |
| 73 | }; |
| 74 | |
| 75 | #define FAN_INPUT_INTERNAL_DIODE 0 |
| 76 | #define FAN_INPUT_TEMP0 1 |
| 77 | #define FAN_INPUT_TEMP1 2 |
| 78 | #define FAN_INPUT_TEMP2 3 |
| 79 | #define FAN_INPUT_TEMP3 4 |
| 80 | #define FAN_INPUT_TEMP0_FILTER 5 |
| 81 | #define FAN_INPUT_ZERO 6 |
| 82 | #define FAN_INPUT_DISABLED 7 |
| 83 | |
| 84 | #define FAN_AUTOMODE (1 << 0) |
| 85 | #define FAN_LINEARMODE (1 << 1) |
| 86 | #define FAN_STEPMODE ~(1 << 1) |
| 87 | #define FAN_POLARITY_HIGH (1 << 2) |
| 88 | #define FAN_POLARITY_LOW ~(1 << 2) |
| 89 | |
| 90 | /* Normally, 4-wire fan runs at 25KHz and 3-wire fan runs at 100Hz */ |
| 91 | #define FREQ_28KHZ 0x0 |
| 92 | #define FREQ_25KHZ 0x1 |
| 93 | #define FREQ_23KHZ 0x2 |
| 94 | #define FREQ_21KHZ 0x3 |
| 95 | #define FREQ_29KHZ 0x4 |
| 96 | #define FREQ_18KHZ 0x5 |
| 97 | #define FREQ_100HZ 0xF7 |
| 98 | #define FREQ_87HZ 0xF8 |
| 99 | #define FREQ_58HZ 0xF9 |
| 100 | #define FREQ_44HZ 0xFA |
| 101 | #define FREQ_35HZ 0xFB |
| 102 | #define FREQ_29HZ 0xFC |
| 103 | #define FREQ_22HZ 0xFD |
| 104 | #define FREQ_14HZ 0xFE |
| 105 | #define FREQ_11HZ 0xFF |
| 106 | |
| 107 | /* Parmer Hardware Monitor Fan Control |
| 108 | * Hardware limitation: |
| 109 | * HWM failed to read the input temperture vi I2C, |
| 110 | * if other software switch the I2C switch by mistake or intention. |
| 111 | * We recommend to using IMC to control Fans, instead of HWM. |
| 112 | */ |
| 113 | static void oem_fan_control(FCH_DATA_BLOCK *FchParams) |
| 114 | { |
| 115 | /* Enable IMC fan control. the recommand way */ |
| 116 | #if IS_ENABLED(CONFIG_HUDSON_IMC_FWM) |
| 117 | |
| 118 | imc_reg_init(); |
| 119 | |
| 120 | /* HwMonitorEnable = TRUE && HwmFchtsiAutoOpll ==FALSE to call FchECfancontrolservice */ |
| 121 | FchParams->Hwm.HwMonitorEnable = TRUE; |
| 122 | FchParams->Hwm.HwmFchtsiAutoPoll = FALSE;/* 0 disable, 1 enable TSI Auto Polling */ |
| 123 | |
| 124 | FchParams->Imc.ImcEnable = TRUE; |
| 125 | FchParams->Hwm.HwmControl = 1; /* 1 IMC, 0 HWM */ |
| 126 | FchParams->Imc.ImcEnableOverWrite = 1; /* 2 disable IMC , 1 enable IMC, 0 following hw strap setting */ |
| 127 | |
| 128 | LibAmdMemFill(&(FchParams->Imc.EcStruct), 0, sizeof(FCH_EC), FchParams->StdHeader); |
| 129 | |
| 130 | /* Thermal Zone Parameter */ |
| 131 | FchParams->Imc.EcStruct.MsgFun81Zone0MsgReg0 = 0x00; |
| 132 | FchParams->Imc.EcStruct.MsgFun81Zone0MsgReg1 = 0x00; /* Zone */ |
| 133 | FchParams->Imc.EcStruct.MsgFun81Zone0MsgReg2 = 0x3d; //BIT0 | BIT2 | BIT5; |
| 134 | FchParams->Imc.EcStruct.MsgFun81Zone0MsgReg3 = 0x0e;//6 | BIT3; |
| 135 | FchParams->Imc.EcStruct.MsgFun81Zone0MsgReg4 = 0x00; |
| 136 | FchParams->Imc.EcStruct.MsgFun81Zone0MsgReg5 = 0x54; |
| 137 | FchParams->Imc.EcStruct.MsgFun81Zone0MsgReg6 = 0x98; /* SMBUS Address for SMBUS based temperature sensor such as SB-TSI and ADM1032 */ |
| 138 | FchParams->Imc.EcStruct.MsgFun81Zone0MsgReg7 = 0x02; |
| 139 | FchParams->Imc.EcStruct.MsgFun81Zone0MsgReg8 = 0x01; /* PWM steping rate in unit of PWM level percentage */ |
| 140 | FchParams->Imc.EcStruct.MsgFun81Zone0MsgReg9 = 0x00; |
| 141 | |
| 142 | /* IMC Fan Policy temperature thresholds */ |
| 143 | FchParams->Imc.EcStruct.MsgFun83Zone0MsgReg0 = 0x00; |
| 144 | FchParams->Imc.EcStruct.MsgFun83Zone0MsgReg1 = 0x00; /* Zone */ |
| 145 | FchParams->Imc.EcStruct.MsgFun83Zone0MsgReg2 = 0x46;///80; /*AC0 threshold in Celsius */ |
| 146 | FchParams->Imc.EcStruct.MsgFun83Zone0MsgReg3 = 0x3c; /*AC1 threshold in Celsius */ |
| 147 | FchParams->Imc.EcStruct.MsgFun83Zone0MsgReg4 = 0x32; /*AC2 threshold in Celsius */ |
| 148 | FchParams->Imc.EcStruct.MsgFun83Zone0MsgReg5 = 0xff; /*AC3 threshold in Celsius, 0xFF is not define */ |
| 149 | FchParams->Imc.EcStruct.MsgFun83Zone0MsgReg6 = 0xff; /*AC4 threshold in Celsius, 0xFF is not define */ |
| 150 | FchParams->Imc.EcStruct.MsgFun83Zone0MsgReg7 = 0xff; /*AC5 threshold in Celsius, 0xFF is not define */ |
| 151 | FchParams->Imc.EcStruct.MsgFun83Zone0MsgReg8 = 0xff; /*AC6 threshold in Celsius, 0xFF is not define */ |
| 152 | FchParams->Imc.EcStruct.MsgFun83Zone0MsgReg9 = 0xff; /*AC7 lowest threshold in Celsius, 0xFF is not define */ |
| 153 | FchParams->Imc.EcStruct.MsgFun83Zone0MsgRegA = 0x4b; /*critical threshold* in Celsius, 0xFF is not define */ |
| 154 | FchParams->Imc.EcStruct.MsgFun83Zone0MsgRegB = 0x00; |
| 155 | |
| 156 | /* IMC Fan Policy PWM Settings */ |
| 157 | FchParams->Imc.EcStruct.MsgFun85Zone0MsgReg0 = 0x00; |
| 158 | FchParams->Imc.EcStruct.MsgFun85Zone0MsgReg1 = 0x00; /* Zone */ |
| 159 | FchParams->Imc.EcStruct.MsgFun85Zone0MsgReg2 = 0x5a; /* AL0 percentage */ |
| 160 | FchParams->Imc.EcStruct.MsgFun85Zone0MsgReg3 = 0x46; /* AL1 percentage */ |
| 161 | FchParams->Imc.EcStruct.MsgFun85Zone0MsgReg4 = 0x28; /* AL2 percentage */ |
| 162 | FchParams->Imc.EcStruct.MsgFun85Zone0MsgReg5 = 0xff; /* AL3 percentage */ |
| 163 | FchParams->Imc.EcStruct.MsgFun85Zone0MsgReg6 = 0xff; /* AL4 percentage */ |
| 164 | FchParams->Imc.EcStruct.MsgFun85Zone0MsgReg7 = 0xff; /* AL5 percentage */ |
| 165 | FchParams->Imc.EcStruct.MsgFun85Zone0MsgReg8 = 0xff; /* AL6 percentage */ |
| 166 | FchParams->Imc.EcStruct.MsgFun85Zone0MsgReg9 = 0xff; /* AL7 percentage */ |
| 167 | |
| 168 | FchParams->Imc.EcStruct.IMCFUNSupportBitMap = 0x111;//BIT0 | BIT4 |BIT8; |
| 169 | |
| 170 | /* NOTE: |
| 171 | * FchInitLateHwm will overwrite the EcStruct with EcDefaultMassege, |
| 172 | * AGESA put EcDefaultMassege as global data in ROM, so we can't overwride it. |
| 173 | * so we remove it from AGESA code. Please Seee FchInitLateHwm. |
| 174 | */ |
| 175 | |
| 176 | #else /* HWM fan control, the way not recommand */ |
| 177 | FchParams->Imc.ImcEnable = FALSE; |
| 178 | FchParams->Hwm.HwMonitorEnable = TRUE; |
| 179 | FchParams->Hwm.HwmFchtsiAutoPoll = TRUE;/* 1 enable, 0 disable TSI Auto Polling */ |
| 180 | |
| 181 | #endif /* CONFIG_HUDSON_IMC_FWM */ |
| 182 | } |
| 183 | |
| 184 | /** |
| 185 | * Fch Oem setting callback |
| 186 | * |
| 187 | * Configure platform specific Hudson device, |
| 188 | * such Azalia, SATA, IMC etc. |
| 189 | */ |
Kyösti Mälkki | f5f9e38 | 2014-10-17 23:21:01 +0300 | [diff] [blame] | 190 | static AGESA_STATUS Fch_Oem_config(UINT32 Func, UINT32 FchData, VOID *ConfigPtr) |
Alexandru Gagniuc | fccfee3 | 2014-03-26 18:51:08 -0500 | [diff] [blame] | 191 | { |
Kyösti Mälkki | dfad070 | 2014-07-10 06:32:36 +0300 | [diff] [blame] | 192 | AMD_CONFIG_PARAMS *StdHeader = ConfigPtr; |
Alexandru Gagniuc | fccfee3 | 2014-03-26 18:51:08 -0500 | [diff] [blame] | 193 | |
Kyösti Mälkki | dfad070 | 2014-07-10 06:32:36 +0300 | [diff] [blame] | 194 | if (StdHeader->Func == AMD_INIT_RESET) { |
Kyösti Mälkki | b166628 | 2014-07-06 22:40:15 +0300 | [diff] [blame] | 195 | FCH_RESET_DATA_BLOCK *FchParams_reset = (FCH_RESET_DATA_BLOCK *)FchData; |
Alexandru Gagniuc | fccfee3 | 2014-03-26 18:51:08 -0500 | [diff] [blame] | 196 | printk(BIOS_DEBUG, "Fch OEM config in INIT RESET "); |
| 197 | //FchParams_reset->EcChannel0 = TRUE; /* logical devicd 3 */ |
Kyösti Mälkki | 37ab729 | 2014-07-10 06:43:44 +0300 | [diff] [blame] | 198 | FchParams_reset->LegacyFree = IS_ENABLED(CONFIG_HUDSON_LEGACY_FREE); |
Kyösti Mälkki | b166628 | 2014-07-06 22:40:15 +0300 | [diff] [blame] | 199 | FchParams_reset->FchReset.Xhci0Enable = IS_ENABLED(CONFIG_HUDSON_XHCI_ENABLE); |
| 200 | FchParams_reset->FchReset.Xhci1Enable = FALSE; |
Kyösti Mälkki | dfad070 | 2014-07-10 06:32:36 +0300 | [diff] [blame] | 201 | } else if (StdHeader->Func == AMD_INIT_ENV) { |
Alexandru Gagniuc | fccfee3 | 2014-03-26 18:51:08 -0500 | [diff] [blame] | 202 | FCH_DATA_BLOCK *FchParams_env = (FCH_DATA_BLOCK *)FchData; |
| 203 | printk(BIOS_DEBUG, "Fch OEM config in INIT ENV "); |
| 204 | |
| 205 | /* Azalia Controller OEM Codec Table Pointer */ |
| 206 | FchParams_env->Azalia.AzaliaOemCodecTablePtr = (CODEC_TBL_LIST *)(&CodecTableList[0]); |
| 207 | /* Azalia Controller Front Panel OEM Table Pointer */ |
| 208 | |
| 209 | /* Fan Control */ |
| 210 | oem_fan_control(FchParams_env); |
| 211 | |
| 212 | /* XHCI configuration */ |
Kyösti Mälkki | b166628 | 2014-07-06 22:40:15 +0300 | [diff] [blame] | 213 | FchParams_env->Usb.Xhci0Enable = IS_ENABLED(CONFIG_HUDSON_XHCI_ENABLE); |
Alexandru Gagniuc | fccfee3 | 2014-03-26 18:51:08 -0500 | [diff] [blame] | 214 | FchParams_env->Usb.Xhci1Enable = FALSE; |
| 215 | |
| 216 | /* sata configuration */ |
| 217 | } |
| 218 | printk(BIOS_DEBUG, "Done\n"); |
| 219 | |
| 220 | return AGESA_SUCCESS; |
| 221 | } |