coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
BiosCallOuts.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <AGESA.h>
6 #include <FchPlatform.h>
7 
8 #include "imc.h"
9 
11 {
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 }
20 };
22 
23 /**
24  * AMD Olivehill Platform ALC272 Verb Table
25  */
26 static const CODEC_ENTRY Olivehill_Alc272_VerbTbl[] = {
27  {0x11, 0x411111F0}, // - SPDIF_OUT2
28  {0x12, 0x411111F0}, // - DMIC_1/2
29  {0x13, 0x411111F0}, // - DMIC_3/4
30  {0x14, 0x411111F0}, // Port D - LOUT1
31  {0x15, 0x411111F0}, // Port A - LOUT2
32  {0x16, 0x411111F0}, //
33  {0x17, 0x411111F0}, // Port H - MONO
34  {0x18, 0x01a19840}, // Port B - MIC1
35  {0x19, 0x411111F0}, // Port F - MIC2
36  {0x1a, 0x01813030}, // Port C - LINE1
37  {0x1b, 0x411111F0}, // Port E - LINE2
38  {0x1d, 0x40130605}, // - PCBEEP
39  {0x1e, 0x01441120}, // - SPDIF_OUT1
40  {0x21, 0x01214010}, // Port I - HPOUT
41  {0xff, 0xffffffff}
42 };
43 
44 static const CODEC_TBL_LIST OlivehillCodecTableList[] =
45 {
46  {0x10ec0272, (CODEC_ENTRY*)&Olivehill_Alc272_VerbTbl[0]},
47  {(UINT32)0x0FFFFFFFF, (CODEC_ENTRY*)0x0FFFFFFFFUL}
48 };
49 
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
58 
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)
64 
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
81 
82 /* Olivehill 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.
87  */
88 static void oem_fan_control(FCH_DATA_BLOCK *FchParams)
89 {
90  /* Enable IMC fan control, the recommended way */
91  if (CONFIG(HUDSON_IMC_FWM)) {
92  imc_reg_init();
93 
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 */
97 
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 */
101 
102  LibAmdMemFill(&(FchParams->Imc.EcStruct), 0, sizeof(FCH_EC), FchParams->StdHeader);
103 
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 = 0x4e;//6 | BIT3;
109  FchParams->Imc.EcStruct.MsgFun81Zone0MsgReg4 = 0x00;
110  FchParams->Imc.EcStruct.MsgFun81Zone0MsgReg5 = 0x04;
111  FchParams->Imc.EcStruct.MsgFun81Zone0MsgReg6 = 0x9a; /* SMBUS Address for SMBUS based temperature sensor such as SB-TSI and ADM1032 */
112  FchParams->Imc.EcStruct.MsgFun81Zone0MsgReg7 = 0x01;
113  FchParams->Imc.EcStruct.MsgFun81Zone0MsgReg8 = 0x01; /* PWM stepping rate in unit of PWM level percentage */
114  FchParams->Imc.EcStruct.MsgFun81Zone0MsgReg9 = 0x00;
115 
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;
129 
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 */
141 
142  FchParams->Imc.EcStruct.IMCFUNSupportBitMap = 0x111;//BIT0 | BIT4 |BIT8;
143 
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.
148  */
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 */
154  }
155 }
156 
157 void board_FCH_InitReset(struct sysinfo *cb_NA, FCH_RESET_DATA_BLOCK *FchParams_reset)
158 {
159 }
160 
161 void board_FCH_InitEnv(struct sysinfo *cb_NA, FCH_DATA_BLOCK *FchParams_env)
162 {
163  /* Azalia Controller OEM Codec Table Pointer */
164  FchParams_env->Azalia.AzaliaOemCodecTablePtr = (CODEC_TBL_LIST *)(&OlivehillCodecTableList[0]);
165 
166  /* Fan Control */
167  oem_fan_control(FchParams_env);
168 }
void imc_reg_init(void)
Definition: imc.c:13
#define ARRAY_SIZE(a)
Definition: helpers.h:12
AGESA_STATUS agesa_RunFuncOnAp(UINT32 Func, UINTN Data, VOID *ConfigPtr)
Definition: def_callouts.c:102
AGESA_STATUS agesa_EmptyIdsInitData(UINT32 Func, UINTN Data, VOID *ConfigPtr)
Definition: def_callouts.c:58
AGESA_STATUS agesa_NoopUnsupported(UINT32 Func, UINTN Data, VOID *ConfigPtr)
Definition: def_callouts.c:48
AGESA_STATUS agesa_NoopSuccess(UINT32 Func, UINTN Data, VOID *ConfigPtr)
Definition: def_callouts.c:53
AGESA_STATUS agesa_Reset(UINT32 Func, UINTN Data, VOID *ConfigPtr)
Definition: def_callouts.c:66
@ CONFIG
Definition: dsi_common.h:201
const int BiosCalloutsLen
Definition: BiosCallOuts.c:25
const BIOS_CALLOUT_STRUCT BiosCallouts[]
Definition: BiosCallOuts.c:13
static const CODEC_ENTRY Olivehill_Alc272_VerbTbl[]
AMD Olivehill Platform ALC272 Verb Table.
Definition: BiosCallOuts.c:26
static const CODEC_TBL_LIST OlivehillCodecTableList[]
Definition: BiosCallOuts.c:44
static void oem_fan_control(FCH_DATA_BLOCK *FchParams)
Definition: BiosCallOuts.c:88
void board_FCH_InitReset(struct sysinfo *cb_NA, FCH_RESET_DATA_BLOCK *FchParams_reset)
Definition: BiosCallOuts.c:157
void board_FCH_InitEnv(struct sysinfo *cb_NA, FCH_DATA_BLOCK *FchParams_env)
Definition: BiosCallOuts.c:161
AGESA_STATUS agesa_GfxGetVbiosImage(UINT32 Func, UINTN FchData, VOID *ConfigPrt)
AGESA_STATUS agesa_ReadSpd(uint32_t Func, uintptr_t Data, void *ConfigPtr)
Definition: BiosCallOuts.c:81