payloads/edk2: Disable the CPU Timer Lib unless supported
[coreboot.git] / src / mainboard / lenovo / g505s / BiosCallOuts.c
blobdd4c42b968f0d759ecd5ad97d2af7d648ed64215
1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <AGESA.h>
4 #include <northbridge/amd/agesa/BiosCallOuts.h>
5 #include <northbridge/amd/agesa/state_machine.h>
7 #include <southbridge/amd/agesa/hudson/imc.h>
8 #include <vendorcode/amd/agesa/f15tn/Proc/Fch/FchPlatform.h>
10 const BIOS_CALLOUT_STRUCT BiosCallouts[] =
12 {AGESA_DO_RESET, agesa_Reset },
13 {AGESA_READ_SPD, agesa_ReadSpd },
14 {AGESA_READ_SPD_RECOVERY, agesa_NoopUnsupported },
15 {AGESA_RUNFUNC_ONAP, agesa_RunFuncOnAp },
16 {AGESA_GET_IDS_INIT_DATA, agesa_EmptyIdsInitData },
17 {AGESA_HOOKBEFORE_DQS_TRAINING, agesa_NoopSuccess },
18 {AGESA_HOOKBEFORE_EXIT_SELF_REF, agesa_NoopSuccess },
19 {AGESA_GNB_GFX_GET_VBIOS_IMAGE, agesa_GfxGetVbiosImage }
21 const int BiosCalloutsLen = ARRAY_SIZE(BiosCallouts);
23 /**
24 * AMD Parmer Platform ALC272 Verb Table
26 static const CODEC_ENTRY Parmer_Alc272_VerbTbl[] = {
27 {0x11, 0x411111F0},
28 {0x12, 0x411111F0},
29 {0x13, 0x411111F0},
30 {0x14, 0x411111F0},
31 {0x15, 0x411111F0},
32 {0x16, 0x411111F0},
33 {0x17, 0x411111F0},
34 {0x18, 0x01a19840},
35 {0x19, 0x411111F0},
36 {0x1a, 0x01813030},
37 {0x1b, 0x411111F0},
38 {0x1d, 0x40130605},
39 {0x1e, 0x01441120},
40 {0x21, 0x01211010},
41 {0xff, 0xffffffff}
44 static const CODEC_TBL_LIST CodecTableList[] =
46 {0x10ec0272, (CODEC_ENTRY*)&Parmer_Alc272_VerbTbl[0]},
47 {(UINT32)0x0FFFFFFFF, (CODEC_ENTRY*)0x0FFFFFFFFUL}
50 #define FAN_INPUT_INTERNAL_DIODE 0
51 #define FAN_INPUT_TEMP0 1
52 #define FAN_INPUT_TEMP1 2
53 #define FAN_INPUT_TEMP2 3
54 #define FAN_INPUT_TEMP3 4
55 #define FAN_INPUT_TEMP0_FILTER 5
56 #define FAN_INPUT_ZERO 6
57 #define FAN_INPUT_DISABLED 7
59 #define FAN_AUTOMODE (1 << 0)
60 #define FAN_LINEARMODE (1 << 1)
61 #define FAN_STEPMODE ~(1 << 1)
62 #define FAN_POLARITY_HIGH (1 << 2)
63 #define FAN_POLARITY_LOW ~(1 << 2)
65 /* Normally, 4-wire fan runs at 25KHz and 3-wire fan runs at 100Hz */
66 #define FREQ_28KHZ 0x0
67 #define FREQ_25KHZ 0x1
68 #define FREQ_23KHZ 0x2
69 #define FREQ_21KHZ 0x3
70 #define FREQ_29KHZ 0x4
71 #define FREQ_18KHZ 0x5
72 #define FREQ_100HZ 0xF7
73 #define FREQ_87HZ 0xF8
74 #define FREQ_58HZ 0xF9
75 #define FREQ_44HZ 0xFA
76 #define FREQ_35HZ 0xFB
77 #define FREQ_29HZ 0xFC
78 #define FREQ_22HZ 0xFD
79 #define FREQ_14HZ 0xFE
80 #define FREQ_11HZ 0xFF
82 /* Hardware Monitor Fan Control
83 * Hardware limitation:
84 * HWM failed to read the input temperature via I2C,
85 * if other software switches the I2C switch by mistake or intention.
86 * We recommend using IMC to control Fans, instead of HWM.
88 static void oem_fan_control(FCH_DATA_BLOCK *FchParams)
90 /* Enable IMC fan control, the recommended way */
91 if (CONFIG(HUDSON_IMC_FWM)) {
92 imc_reg_init();
94 /* HwMonitorEnable = TRUE && HwmFchtsiAutoOpll ==FALSE to call FchECfancontrolservice */
95 FchParams->Hwm.HwMonitorEnable = TRUE;
96 FchParams->Hwm.HwmFchtsiAutoPoll = FALSE;/* 0 disable, 1 enable TSI Auto Polling */
98 FchParams->Imc.ImcEnable = TRUE;
99 FchParams->Hwm.HwmControl = 1; /* 1 IMC, 0 HWM */
100 FchParams->Imc.ImcEnableOverWrite = 1; /* 2 disable IMC, 1 enable IMC, 0 following hw strap setting */
102 LibAmdMemFill(&(FchParams->Imc.EcStruct), 0, sizeof(FCH_EC), FchParams->StdHeader);
104 /* Thermal Zone Parameter */
105 FchParams->Imc.EcStruct.MsgFun81Zone0MsgReg0 = 0x00;
106 FchParams->Imc.EcStruct.MsgFun81Zone0MsgReg1 = 0x00; /* Zone */
107 FchParams->Imc.EcStruct.MsgFun81Zone0MsgReg2 = 0x3d; //BIT0 | BIT2 | BIT5;
108 FchParams->Imc.EcStruct.MsgFun81Zone0MsgReg3 = 0x0e;//6 | BIT3;
109 FchParams->Imc.EcStruct.MsgFun81Zone0MsgReg4 = 0x00;
110 FchParams->Imc.EcStruct.MsgFun81Zone0MsgReg5 = 0x54;
111 FchParams->Imc.EcStruct.MsgFun81Zone0MsgReg6 = 0x98; /* SMBUS Address for SMBUS based temperature sensor such as SB-TSI and ADM1032 */
112 FchParams->Imc.EcStruct.MsgFun81Zone0MsgReg7 = 0x02;
113 FchParams->Imc.EcStruct.MsgFun81Zone0MsgReg8 = 0x01; /* PWM stepping rate in unit of PWM level percentage */
114 FchParams->Imc.EcStruct.MsgFun81Zone0MsgReg9 = 0x00;
116 /* IMC Fan Policy temperature thresholds */
117 FchParams->Imc.EcStruct.MsgFun83Zone0MsgReg0 = 0x00;
118 FchParams->Imc.EcStruct.MsgFun83Zone0MsgReg1 = 0x00; /* Zone */
119 FchParams->Imc.EcStruct.MsgFun83Zone0MsgReg2 = 0x46;///80; /*AC0 threshold in Celsius */
120 FchParams->Imc.EcStruct.MsgFun83Zone0MsgReg3 = 0x3c; /*AC1 threshold in Celsius */
121 FchParams->Imc.EcStruct.MsgFun83Zone0MsgReg4 = 0x32; /*AC2 threshold in Celsius */
122 FchParams->Imc.EcStruct.MsgFun83Zone0MsgReg5 = 0xff; /*AC3 threshold in Celsius, 0xFF is not define */
123 FchParams->Imc.EcStruct.MsgFun83Zone0MsgReg6 = 0xff; /*AC4 threshold in Celsius, 0xFF is not define */
124 FchParams->Imc.EcStruct.MsgFun83Zone0MsgReg7 = 0xff; /*AC5 threshold in Celsius, 0xFF is not define */
125 FchParams->Imc.EcStruct.MsgFun83Zone0MsgReg8 = 0xff; /*AC6 threshold in Celsius, 0xFF is not define */
126 FchParams->Imc.EcStruct.MsgFun83Zone0MsgReg9 = 0xff; /*AC7 lowest threshold in Celsius, 0xFF is not define */
127 FchParams->Imc.EcStruct.MsgFun83Zone0MsgRegA = 0x4b; /*critical threshold* in Celsius, 0xFF is not define */
128 FchParams->Imc.EcStruct.MsgFun83Zone0MsgRegB = 0x00;
130 /* IMC Fan Policy PWM Settings */
131 FchParams->Imc.EcStruct.MsgFun85Zone0MsgReg0 = 0x00;
132 FchParams->Imc.EcStruct.MsgFun85Zone0MsgReg1 = 0x00; /* Zone */
133 FchParams->Imc.EcStruct.MsgFun85Zone0MsgReg2 = 0x5a; /* AL0 percentage */
134 FchParams->Imc.EcStruct.MsgFun85Zone0MsgReg3 = 0x46; /* AL1 percentage */
135 FchParams->Imc.EcStruct.MsgFun85Zone0MsgReg4 = 0x28; /* AL2 percentage */
136 FchParams->Imc.EcStruct.MsgFun85Zone0MsgReg5 = 0xff; /* AL3 percentage */
137 FchParams->Imc.EcStruct.MsgFun85Zone0MsgReg6 = 0xff; /* AL4 percentage */
138 FchParams->Imc.EcStruct.MsgFun85Zone0MsgReg7 = 0xff; /* AL5 percentage */
139 FchParams->Imc.EcStruct.MsgFun85Zone0MsgReg8 = 0xff; /* AL6 percentage */
140 FchParams->Imc.EcStruct.MsgFun85Zone0MsgReg9 = 0xff; /* AL7 percentage */
142 FchParams->Imc.EcStruct.IMCFUNSupportBitMap = 0x111;//BIT0 | BIT4 |BIT8;
144 /* NOTE:
145 * FchInitLateHwm will overwrite the EcStruct with EcDefaultMessage,
146 * AGESA puts EcDefaultMessage as global data in ROM, so we can't overwrite it.
147 * So we remove it from AGESA code. Please See FchInitLateHwm.
149 } else {
150 /* HWM fan control, the way not recommended */
151 FchParams->Imc.ImcEnable = FALSE;
152 FchParams->Hwm.HwMonitorEnable = TRUE;
153 FchParams->Hwm.HwmFchtsiAutoPoll = TRUE;/* 1 enable, 0 disable TSI Auto Polling */
157 void board_FCH_InitReset(struct sysinfo *cb_NA, FCH_RESET_DATA_BLOCK *FchParams_reset)
159 FchParams_reset->LegacyFree = CONFIG(HUDSON_LEGACY_FREE);
162 void board_FCH_InitEnv(struct sysinfo *cb_NA, FCH_DATA_BLOCK *FchParams_env)
164 /* Azalia Controller OEM Codec Table Pointer */
165 FchParams_env->Azalia.AzaliaOemCodecTablePtr = (CODEC_TBL_LIST *)(&CodecTableList[0]);
167 /* Fan Control */
168 oem_fan_control(FchParams_env);