Siyuan Wang | 80cf7d5 | 2013-07-09 17:42:43 +0800 | [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. |
Siyuan Wang | 80cf7d5 | 2013-07-09 17:42:43 +0800 | [diff] [blame] | 14 | */ |
| 15 | |
Elyes HAOUAS | 19f5ba8 | 2018-10-14 14:52:06 +0200 | [diff] [blame] | 16 | #include <AGESA.h> |
Kyösti Mälkki | 26f297e | 2014-05-26 11:27:54 +0300 | [diff] [blame] | 17 | #include <northbridge/amd/agesa/BiosCallOuts.h> |
Kyösti Mälkki | 6dcd4bc | 2017-03-04 07:33:19 +0200 | [diff] [blame] | 18 | #include <northbridge/amd/agesa/state_machine.h> |
Elyes HAOUAS | 19f5ba8 | 2018-10-14 14:52:06 +0200 | [diff] [blame] | 19 | #include <FchPlatform.h> |
| 20 | #include <cbfs.h> |
WANG Siyuan | 62a3f6f | 2013-12-02 10:39:44 +0800 | [diff] [blame] | 21 | #include "imc.h" |
Kyösti Mälkki | 6025efa | 2014-05-05 13:20:56 +0300 | [diff] [blame] | 22 | #include <stdlib.h> |
Siyuan Wang | 80cf7d5 | 2013-07-09 17:42:43 +0800 | [diff] [blame] | 23 | |
Kyösti Mälkki | 6025efa | 2014-05-05 13:20:56 +0300 | [diff] [blame] | 24 | const BIOS_CALLOUT_STRUCT BiosCallouts[] = |
Siyuan Wang | 80cf7d5 | 2013-07-09 17:42:43 +0800 | [diff] [blame] | 25 | { |
Kyösti Mälkki | 83cc3b0 | 2014-05-04 23:13:08 +0300 | [diff] [blame] | 26 | {AGESA_DO_RESET, agesa_Reset }, |
Kyösti Mälkki | c5cc9f2 | 2014-10-17 22:33:22 +0300 | [diff] [blame] | 27 | {AGESA_READ_SPD, agesa_ReadSpd }, |
Kyösti Mälkki | 83cc3b0 | 2014-05-04 23:13:08 +0300 | [diff] [blame] | 28 | {AGESA_READ_SPD_RECOVERY, agesa_NoopUnsupported }, |
| 29 | {AGESA_RUNFUNC_ONAP, agesa_RunFuncOnAp }, |
| 30 | {AGESA_GET_IDS_INIT_DATA, agesa_EmptyIdsInitData }, |
| 31 | {AGESA_HOOKBEFORE_DQS_TRAINING, agesa_NoopSuccess }, |
| 32 | {AGESA_HOOKBEFORE_EXIT_SELF_REF, agesa_NoopSuccess }, |
Kyösti Mälkki | cb989f2 | 2014-05-04 23:13:08 +0300 | [diff] [blame] | 33 | {AGESA_GNB_GFX_GET_VBIOS_IMAGE, agesa_GfxGetVbiosImage } |
Siyuan Wang | 80cf7d5 | 2013-07-09 17:42:43 +0800 | [diff] [blame] | 34 | }; |
Kyösti Mälkki | 6025efa | 2014-05-05 13:20:56 +0300 | [diff] [blame] | 35 | const int BiosCalloutsLen = ARRAY_SIZE(BiosCallouts); |
Siyuan Wang | 80cf7d5 | 2013-07-09 17:42:43 +0800 | [diff] [blame] | 36 | |
| 37 | /** |
| 38 | * AMD Olivehill Platform ALC272 Verb Table |
| 39 | */ |
| 40 | static const CODEC_ENTRY Olivehill_Alc272_VerbTbl[] = { |
| 41 | {0x11, 0x411111F0}, // - SPDIF_OUT2 |
| 42 | {0x12, 0x411111F0}, // - DMIC_1/2 |
| 43 | {0x13, 0x411111F0}, // - DMIC_3/4 |
| 44 | {0x14, 0x411111F0}, // Port D - LOUT1 |
| 45 | {0x15, 0x411111F0}, // Port A - LOUT2 |
| 46 | {0x16, 0x411111F0}, // |
| 47 | {0x17, 0x411111F0}, // Port H - MONO |
| 48 | {0x18, 0x01a19840}, // Port B - MIC1 |
| 49 | {0x19, 0x411111F0}, // Port F - MIC2 |
| 50 | {0x1a, 0x01813030}, // Port C - LINE1 |
| 51 | {0x1b, 0x411111F0}, // Port E - LINE2 |
| 52 | {0x1d, 0x40130605}, // - PCBEEP |
| 53 | {0x1e, 0x01441120}, // - SPDIF_OUT1 |
| 54 | {0x21, 0x01214010}, // Port I - HPOUT |
| 55 | {0xff, 0xffffffff} |
| 56 | }; |
| 57 | |
| 58 | static const CODEC_TBL_LIST OlivehillCodecTableList[] = |
| 59 | { |
| 60 | {0x10ec0272, (CODEC_ENTRY*)&Olivehill_Alc272_VerbTbl[0]}, |
| 61 | {(UINT32)0x0FFFFFFFF, (CODEC_ENTRY*)0x0FFFFFFFFUL} |
| 62 | }; |
| 63 | |
| 64 | #define FAN_INPUT_INTERNAL_DIODE 0 |
| 65 | #define FAN_INPUT_TEMP0 1 |
| 66 | #define FAN_INPUT_TEMP1 2 |
| 67 | #define FAN_INPUT_TEMP2 3 |
| 68 | #define FAN_INPUT_TEMP3 4 |
| 69 | #define FAN_INPUT_TEMP0_FILTER 5 |
| 70 | #define FAN_INPUT_ZERO 6 |
| 71 | #define FAN_INPUT_DISABLED 7 |
| 72 | |
| 73 | #define FAN_AUTOMODE (1 << 0) |
| 74 | #define FAN_LINEARMODE (1 << 1) |
| 75 | #define FAN_STEPMODE ~(1 << 1) |
| 76 | #define FAN_POLARITY_HIGH (1 << 2) |
| 77 | #define FAN_POLARITY_LOW ~(1 << 2) |
| 78 | |
| 79 | /* Normally, 4-wire fan runs at 25KHz and 3-wire fan runs at 100Hz */ |
| 80 | #define FREQ_28KHZ 0x0 |
| 81 | #define FREQ_25KHZ 0x1 |
| 82 | #define FREQ_23KHZ 0x2 |
| 83 | #define FREQ_21KHZ 0x3 |
| 84 | #define FREQ_29KHZ 0x4 |
| 85 | #define FREQ_18KHZ 0x5 |
| 86 | #define FREQ_100HZ 0xF7 |
| 87 | #define FREQ_87HZ 0xF8 |
| 88 | #define FREQ_58HZ 0xF9 |
| 89 | #define FREQ_44HZ 0xFA |
| 90 | #define FREQ_35HZ 0xFB |
| 91 | #define FREQ_29HZ 0xFC |
| 92 | #define FREQ_22HZ 0xFD |
| 93 | #define FREQ_14HZ 0xFE |
| 94 | #define FREQ_11HZ 0xFF |
| 95 | |
| 96 | /* Olivehill Hardware Monitor Fan Control |
| 97 | * Hardware limitation: |
| 98 | * HWM failed to read the input temperture vi I2C, |
| 99 | * if other software switch the I2C switch by mistake or intention. |
| 100 | * We recommend to using IMC to control Fans, instead of HWM. |
| 101 | */ |
Siyuan Wang | 80cf7d5 | 2013-07-09 17:42:43 +0800 | [diff] [blame] | 102 | static void oem_fan_control(FCH_DATA_BLOCK *FchParams) |
| 103 | { |
Siyuan Wang | 80cf7d5 | 2013-07-09 17:42:43 +0800 | [diff] [blame] | 104 | /* Enable IMC fan control. the recommand way */ |
Marshall Dawson | 6dd620b | 2017-08-16 18:04:06 -0600 | [diff] [blame] | 105 | if (IS_ENABLED(CONFIG_HUDSON_IMC_FWM)) { |
| 106 | imc_reg_init(); |
WANG Siyuan | 62a3f6f | 2013-12-02 10:39:44 +0800 | [diff] [blame] | 107 | |
Marshall Dawson | 6dd620b | 2017-08-16 18:04:06 -0600 | [diff] [blame] | 108 | /* HwMonitorEnable = TRUE && HwmFchtsiAutoOpll ==FALSE to call FchECfancontrolservice */ |
| 109 | FchParams->Hwm.HwMonitorEnable = TRUE; |
| 110 | FchParams->Hwm.HwmFchtsiAutoPoll = FALSE;/* 0 disable, 1 enable TSI Auto Polling */ |
WANG Siyuan | 62a3f6f | 2013-12-02 10:39:44 +0800 | [diff] [blame] | 111 | |
Marshall Dawson | 6dd620b | 2017-08-16 18:04:06 -0600 | [diff] [blame] | 112 | FchParams->Imc.ImcEnable = TRUE; |
| 113 | FchParams->Hwm.HwmControl = 1; /* 1 IMC, 0 HWM */ |
Elyes HAOUAS | a342f39 | 2018-10-17 10:56:26 +0200 | [diff] [blame] | 114 | FchParams->Imc.ImcEnableOverWrite = 1; /* 2 disable IMC, 1 enable IMC, 0 following hw strap setting */ |
Siyuan Wang | 80cf7d5 | 2013-07-09 17:42:43 +0800 | [diff] [blame] | 115 | |
Marshall Dawson | 6dd620b | 2017-08-16 18:04:06 -0600 | [diff] [blame] | 116 | LibAmdMemFill(&(FchParams->Imc.EcStruct), 0, sizeof(FCH_EC), FchParams->StdHeader); |
Siyuan Wang | 80cf7d5 | 2013-07-09 17:42:43 +0800 | [diff] [blame] | 117 | |
Marshall Dawson | 6dd620b | 2017-08-16 18:04:06 -0600 | [diff] [blame] | 118 | /* Thermal Zone Parameter */ |
| 119 | FchParams->Imc.EcStruct.MsgFun81Zone0MsgReg0 = 0x00; |
| 120 | FchParams->Imc.EcStruct.MsgFun81Zone0MsgReg1 = 0x00; /* Zone */ |
| 121 | FchParams->Imc.EcStruct.MsgFun81Zone0MsgReg2 = 0x3d; //BIT0 | BIT2 | BIT5; |
| 122 | FchParams->Imc.EcStruct.MsgFun81Zone0MsgReg3 = 0x4e;//6 | BIT3; |
| 123 | FchParams->Imc.EcStruct.MsgFun81Zone0MsgReg4 = 0x00; |
| 124 | FchParams->Imc.EcStruct.MsgFun81Zone0MsgReg5 = 0x04; |
| 125 | FchParams->Imc.EcStruct.MsgFun81Zone0MsgReg6 = 0x9a; /* SMBUS Address for SMBUS based temperature sensor such as SB-TSI and ADM1032 */ |
| 126 | FchParams->Imc.EcStruct.MsgFun81Zone0MsgReg7 = 0x01; |
| 127 | FchParams->Imc.EcStruct.MsgFun81Zone0MsgReg8 = 0x01; /* PWM steping rate in unit of PWM level percentage */ |
| 128 | FchParams->Imc.EcStruct.MsgFun81Zone0MsgReg9 = 0x00; |
Siyuan Wang | 80cf7d5 | 2013-07-09 17:42:43 +0800 | [diff] [blame] | 129 | |
Marshall Dawson | 6dd620b | 2017-08-16 18:04:06 -0600 | [diff] [blame] | 130 | /* IMC Fan Policy temperature thresholds */ |
| 131 | FchParams->Imc.EcStruct.MsgFun83Zone0MsgReg0 = 0x00; |
| 132 | FchParams->Imc.EcStruct.MsgFun83Zone0MsgReg1 = 0x00; /* Zone */ |
| 133 | FchParams->Imc.EcStruct.MsgFun83Zone0MsgReg2 = 0x46;///80; /*AC0 threshold in Celsius */ |
| 134 | FchParams->Imc.EcStruct.MsgFun83Zone0MsgReg3 = 0x3c; /*AC1 threshold in Celsius */ |
| 135 | FchParams->Imc.EcStruct.MsgFun83Zone0MsgReg4 = 0x32; /*AC2 threshold in Celsius */ |
| 136 | FchParams->Imc.EcStruct.MsgFun83Zone0MsgReg5 = 0xff; /*AC3 threshold in Celsius, 0xFF is not define */ |
| 137 | FchParams->Imc.EcStruct.MsgFun83Zone0MsgReg6 = 0xff; /*AC4 threshold in Celsius, 0xFF is not define */ |
| 138 | FchParams->Imc.EcStruct.MsgFun83Zone0MsgReg7 = 0xff; /*AC5 threshold in Celsius, 0xFF is not define */ |
| 139 | FchParams->Imc.EcStruct.MsgFun83Zone0MsgReg8 = 0xff; /*AC6 threshold in Celsius, 0xFF is not define */ |
| 140 | FchParams->Imc.EcStruct.MsgFun83Zone0MsgReg9 = 0xff; /*AC7 lowest threshold in Celsius, 0xFF is not define */ |
| 141 | FchParams->Imc.EcStruct.MsgFun83Zone0MsgRegA = 0x4b; /*critical threshold* in Celsius, 0xFF is not define */ |
| 142 | FchParams->Imc.EcStruct.MsgFun83Zone0MsgRegB = 0x00; |
Siyuan Wang | 80cf7d5 | 2013-07-09 17:42:43 +0800 | [diff] [blame] | 143 | |
Marshall Dawson | 6dd620b | 2017-08-16 18:04:06 -0600 | [diff] [blame] | 144 | /* IMC Fan Policy PWM Settings */ |
| 145 | FchParams->Imc.EcStruct.MsgFun85Zone0MsgReg0 = 0x00; |
| 146 | FchParams->Imc.EcStruct.MsgFun85Zone0MsgReg1 = 0x00; /* Zone */ |
| 147 | FchParams->Imc.EcStruct.MsgFun85Zone0MsgReg2 = 0x5a; /* AL0 percentage */ |
| 148 | FchParams->Imc.EcStruct.MsgFun85Zone0MsgReg3 = 0x46; /* AL1 percentage */ |
| 149 | FchParams->Imc.EcStruct.MsgFun85Zone0MsgReg4 = 0x28; /* AL2 percentage */ |
| 150 | FchParams->Imc.EcStruct.MsgFun85Zone0MsgReg5 = 0xff; /* AL3 percentage */ |
| 151 | FchParams->Imc.EcStruct.MsgFun85Zone0MsgReg6 = 0xff; /* AL4 percentage */ |
| 152 | FchParams->Imc.EcStruct.MsgFun85Zone0MsgReg7 = 0xff; /* AL5 percentage */ |
| 153 | FchParams->Imc.EcStruct.MsgFun85Zone0MsgReg8 = 0xff; /* AL6 percentage */ |
| 154 | FchParams->Imc.EcStruct.MsgFun85Zone0MsgReg9 = 0xff; /* AL7 percentage */ |
Siyuan Wang | 80cf7d5 | 2013-07-09 17:42:43 +0800 | [diff] [blame] | 155 | |
Marshall Dawson | 6dd620b | 2017-08-16 18:04:06 -0600 | [diff] [blame] | 156 | FchParams->Imc.EcStruct.IMCFUNSupportBitMap = 0x111;//BIT0 | BIT4 |BIT8; |
Siyuan Wang | 80cf7d5 | 2013-07-09 17:42:43 +0800 | [diff] [blame] | 157 | |
Marshall Dawson | 6dd620b | 2017-08-16 18:04:06 -0600 | [diff] [blame] | 158 | /* NOTE: |
| 159 | * FchInitLateHwm will overwrite the EcStruct with EcDefaultMassege, |
| 160 | * AGESA put EcDefaultMassege as global data in ROM, so we can't overwride it. |
| 161 | * so we remove it from AGESA code. Please Seee FchInitLateHwm. |
| 162 | */ |
| 163 | } else { |
| 164 | /* HWM fan control, the way not recommand */ |
| 165 | FchParams->Imc.ImcEnable = FALSE; |
| 166 | FchParams->Hwm.HwMonitorEnable = TRUE; |
| 167 | FchParams->Hwm.HwmFchtsiAutoPoll = TRUE;/* 1 enable, 0 disable TSI Auto Polling */ |
| 168 | } |
Siyuan Wang | 80cf7d5 | 2013-07-09 17:42:43 +0800 | [diff] [blame] | 169 | } |
Siyuan Wang | 80cf7d5 | 2013-07-09 17:42:43 +0800 | [diff] [blame] | 170 | |
Kyösti Mälkki | 6dcd4bc | 2017-03-04 07:33:19 +0200 | [diff] [blame] | 171 | void board_FCH_InitReset(struct sysinfo *cb_NA, FCH_RESET_DATA_BLOCK *FchParams_reset) |
Siyuan Wang | 80cf7d5 | 2013-07-09 17:42:43 +0800 | [diff] [blame] | 172 | { |
Kyösti Mälkki | 6dcd4bc | 2017-03-04 07:33:19 +0200 | [diff] [blame] | 173 | } |
Siyuan Wang | 80cf7d5 | 2013-07-09 17:42:43 +0800 | [diff] [blame] | 174 | |
Kyösti Mälkki | 6dcd4bc | 2017-03-04 07:33:19 +0200 | [diff] [blame] | 175 | void board_FCH_InitEnv(struct sysinfo *cb_NA, FCH_DATA_BLOCK *FchParams_env) |
| 176 | { |
| 177 | /* Azalia Controller OEM Codec Table Pointer */ |
| 178 | FchParams_env->Azalia.AzaliaOemCodecTablePtr = (CODEC_TBL_LIST *)(&OlivehillCodecTableList[0]); |
Siyuan Wang | 80cf7d5 | 2013-07-09 17:42:43 +0800 | [diff] [blame] | 179 | |
Kyösti Mälkki | 6dcd4bc | 2017-03-04 07:33:19 +0200 | [diff] [blame] | 180 | /* Fan Control */ |
| 181 | oem_fan_control(FchParams_env); |
Siyuan Wang | 80cf7d5 | 2013-07-09 17:42:43 +0800 | [diff] [blame] | 182 | } |