[coreboot-gerrit] New patch to review for coreboot: 1bdaa70 Add imc fan control to Olive Hill

WANG Siyuan (wangsiyuanbuaa@gmail.com) gerrit at coreboot.org
Mon Nov 4 11:30:55 CET 2013


WANG Siyuan (wangsiyuanbuaa at gmail.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/4024

-gerrit

commit 1bdaa7074c243d6e44e3270ce4184840ab655a33
Author: WANG Siyuan <wangsiyuanbuaa at gmail.com>
Date:   Mon Nov 4 17:57:37 2013 +0800

    Add imc fan control to Olive Hill
    
    imc can control fan automatically on Olive Hill.
    
    Change-Id: I36c7ded4cd9ac0f3ffd75d3f08f94492eb0050ce
    Signed-off-by: WANG Siyuan <SiYuan.Wang at amd.com>
    Signed-off-by: WANG Siyuan <wangsiyuanbuaa at gmail.com>
---
 src/mainboard/amd/olivehill/BiosCallOuts.c    | 122 +-------------------------
 src/mainboard/amd/olivehill/Makefile.inc      |   1 +
 src/mainboard/amd/olivehill/get_bus_conf.c    |   5 ++
 src/mainboard/amd/olivehill/imc_fan_control.c |  57 ++++++++++++
 4 files changed, 64 insertions(+), 121 deletions(-)

diff --git a/src/mainboard/amd/olivehill/BiosCallOuts.c b/src/mainboard/amd/olivehill/BiosCallOuts.c
index 3fd3684..c142023 100644
--- a/src/mainboard/amd/olivehill/BiosCallOuts.c
+++ b/src/mainboard/amd/olivehill/BiosCallOuts.c
@@ -127,21 +127,8 @@ static const CODEC_TBL_LIST OlivehillCodecTableList[] =
  *  if other software switch the I2C switch by mistake or intention.
  *  We recommend to using IMC to control Fans, instead of HWM.
  */
-#if 0
 static void oem_fan_control(FCH_DATA_BLOCK *FchParams)
 {
-	FCH_HWM_FAN_CTR oem_factl[5] = {
-		/*temperatuer input, fan mode, frequency, low_duty, med_duty, multiplier, lowtemp, medtemp, hightemp, LinearRange, LinearHoldCount */
-		/* Olivehill FanOUT0 Fan header J32 */
-		{FAN_INPUT_INTERNAL_DIODE, (FAN_STEPMODE | FAN_POLARITY_HIGH), FREQ_100HZ, 40, 60,  0, 40, 65, 85, 0, 0},
-		/* Olivehill FanOUT1 Fan header J31*/
-		{FAN_INPUT_INTERNAL_DIODE, (FAN_STEPMODE | FAN_POLARITY_HIGH), FREQ_100HZ, 40, 60,  0, 40, 65, 85, 0, 0},
-		{FAN_INPUT_INTERNAL_DIODE, (FAN_STEPMODE | FAN_POLARITY_HIGH), FREQ_100HZ, 40, 60,  0, 40, 65, 85, 0, 0},
-		{FAN_INPUT_INTERNAL_DIODE, (FAN_STEPMODE | FAN_POLARITY_HIGH), FREQ_100HZ, 40, 60,  0, 40, 65, 85, 0, 0},
-		{FAN_INPUT_INTERNAL_DIODE, (FAN_STEPMODE | FAN_POLARITY_HIGH), FREQ_100HZ, 40, 60,  0, 40, 65, 85, 0, 0},
-	};
-	LibAmdMemCopy ((VOID *)(FchParams->Hwm.HwmFanControl), &oem_factl, (sizeof (FCH_HWM_FAN_CTR) * 5), FchParams->StdHeader);
-
 	/* Enable IMC fan control. the recommand way */
 #if defined CONFIG_HUDSON_IMC_FWM && (CONFIG_HUDSON_IMC_FWM == 1)
 	/* HwMonitorEnable = TRUE &&  HwmFchtsiAutoOpll ==FALSE to call FchECfancontrolservice */
@@ -152,112 +139,6 @@ static void oem_fan_control(FCH_DATA_BLOCK *FchParams)
 	FchParams->Hwm.HwmControl = 1;	/* 1 IMC, 0 HWM */
 	FchParams->Imc.ImcEnableOverWrite = 1; /* 2 disable IMC , 1 enable IMC, 0 following hw strap setting */
 
-	LibAmdMemFill(&(FchParams->Imc.EcStruct), 0, sizeof(FCH_EC), FchParams->StdHeader);
-
-	/* Thermal Zone Parameter */
-	FchParams->Imc.EcStruct.MsgFun81Zone0MsgReg0 = 0x00;
-	FchParams->Imc.EcStruct.MsgFun81Zone0MsgReg1 = 0x00;	/* Zone */
-	FchParams->Imc.EcStruct.MsgFun81Zone0MsgReg2 = 0x00; //BIT0 | BIT2 | BIT5;
-	FchParams->Imc.EcStruct.MsgFun81Zone0MsgReg3 = 0x00;//6 | BIT3;
-	FchParams->Imc.EcStruct.MsgFun81Zone0MsgReg4 = 0x00;
-	FchParams->Imc.EcStruct.MsgFun81Zone0MsgReg5 = 0x00;
-	FchParams->Imc.EcStruct.MsgFun81Zone0MsgReg6 = 0x98;	/* SMBUS Address for SMBUS based temperature sensor such as SB-TSI and ADM1032 */
-	FchParams->Imc.EcStruct.MsgFun81Zone0MsgReg7 = 2;
-	FchParams->Imc.EcStruct.MsgFun81Zone0MsgReg8 = 0;	/* PWM steping rate in unit of PWM level percentage */
-	FchParams->Imc.EcStruct.MsgFun81Zone0MsgReg9 = 0;
-
-	/* IMC Fan Policy temperature thresholds */
-	FchParams->Imc.EcStruct.MsgFun83Zone0MsgReg0 = 0x00;
-	FchParams->Imc.EcStruct.MsgFun83Zone0MsgReg1 = 0x00;	/* Zone */
-	FchParams->Imc.EcStruct.MsgFun83Zone0MsgReg2 = 0;///80;	/*AC0 threshold in Celsius */
-	FchParams->Imc.EcStruct.MsgFun83Zone0MsgReg3 = 0;	/*AC1 threshold in Celsius */
-	FchParams->Imc.EcStruct.MsgFun83Zone0MsgReg4 = 0;	/*AC2 threshold in Celsius */
-	FchParams->Imc.EcStruct.MsgFun83Zone0MsgReg5 = 0;	/*AC3 threshold in Celsius, 0xFF is not define */
-	FchParams->Imc.EcStruct.MsgFun83Zone0MsgReg6 = 0;	/*AC4 threshold in Celsius, 0xFF is not define */
-	FchParams->Imc.EcStruct.MsgFun83Zone0MsgReg7 = 0;	/*AC5 threshold in Celsius, 0xFF is not define */
-	FchParams->Imc.EcStruct.MsgFun83Zone0MsgReg8 = 0;	/*AC6 threshold in Celsius, 0xFF is not define */
-	FchParams->Imc.EcStruct.MsgFun83Zone0MsgReg9 = 0;	/*AC7 lowest threshold in Celsius, 0xFF is not define */
-	FchParams->Imc.EcStruct.MsgFun83Zone0MsgRegA = 0;	/*critical threshold* in Celsius, 0xFF is not define */
-	FchParams->Imc.EcStruct.MsgFun83Zone0MsgRegB = 0x00;
-
-	/* IMC Fan Policy PWM Settings */
-	FchParams->Imc.EcStruct.MsgFun85Zone0MsgReg0 = 0x00;
-	FchParams->Imc.EcStruct.MsgFun85Zone0MsgReg1 = 0x00;	/* Zone */
-	FchParams->Imc.EcStruct.MsgFun85Zone0MsgReg2 = 0;	/* AL0 percentage */
-	FchParams->Imc.EcStruct.MsgFun85Zone0MsgReg3 = 0;	/* AL1 percentage */
-	FchParams->Imc.EcStruct.MsgFun85Zone0MsgReg4 = 0;	/* AL2 percentage */
-	FchParams->Imc.EcStruct.MsgFun85Zone0MsgReg5 = 0x00;	/* AL3 percentage */
-	FchParams->Imc.EcStruct.MsgFun85Zone0MsgReg6 = 0x00;	/* AL4 percentage */
-	FchParams->Imc.EcStruct.MsgFun85Zone0MsgReg7 = 0x00;	/* AL5 percentage */
-	FchParams->Imc.EcStruct.MsgFun85Zone0MsgReg8 = 0x00;	/* AL6 percentage */
-	FchParams->Imc.EcStruct.MsgFun85Zone0MsgReg9 = 0x00;	/* AL7 percentage */
-
-	FchParams->Imc.EcStruct.MsgFun81Zone1MsgReg0 = 0x00;
-	FchParams->Imc.EcStruct.MsgFun81Zone1MsgReg1 = 0x01;	/* Zone */
-	FchParams->Imc.EcStruct.MsgFun81Zone1MsgReg2 = 0x55;//BIT0 | BIT2 | BIT5;
-	FchParams->Imc.EcStruct.MsgFun81Zone1MsgReg3 = 0x17;
-	FchParams->Imc.EcStruct.MsgFun81Zone1MsgReg4 = 0x00;
-	FchParams->Imc.EcStruct.MsgFun81Zone1MsgReg5 = 0x00;
-	FchParams->Imc.EcStruct.MsgFun81Zone1MsgReg6 = 0x90;	/* SMBUS Address for SMBUS based temperature sensor such as SB-TSI and ADM1032 */
-	FchParams->Imc.EcStruct.MsgFun81Zone1MsgReg7 = 0;
-	FchParams->Imc.EcStruct.MsgFun81Zone1MsgReg8 = 0;	/* PWM steping rate in unit of PWM level percentage */
-	FchParams->Imc.EcStruct.MsgFun81Zone1MsgReg9 = 0;
-
-	FchParams->Imc.EcStruct.MsgFun83Zone1MsgReg0 = 0x00;
-	FchParams->Imc.EcStruct.MsgFun83Zone1MsgReg1 = 0x01;	/* zone */
-	FchParams->Imc.EcStruct.MsgFun83Zone1MsgReg2 = 60;	/*AC0 threshold in Celsius */
-	FchParams->Imc.EcStruct.MsgFun83Zone1MsgReg3 = 40;	/*AC1 threshold in Celsius */
-	FchParams->Imc.EcStruct.MsgFun83Zone1MsgReg4 = 0;	/*AC2 threshold in Celsius */
-	FchParams->Imc.EcStruct.MsgFun83Zone1MsgReg5 = 0;	/*AC3 threshold in Celsius, 0xFF is not define */
-	FchParams->Imc.EcStruct.MsgFun83Zone1MsgReg6 = 0;	/*AC4 threshold in Celsius, 0xFF is not define */
-	FchParams->Imc.EcStruct.MsgFun83Zone1MsgReg7 = 0;	/*AC5 threshold in Celsius, 0xFF is not define */
-	FchParams->Imc.EcStruct.MsgFun83Zone1MsgReg8 = 0;	/*AC6 threshold in Celsius, 0xFF is not define */
-	FchParams->Imc.EcStruct.MsgFun83Zone1MsgReg9 = 0;	/*AC7 lowest threshold in Celsius, 0xFF is not define */
-	FchParams->Imc.EcStruct.MsgFun83Zone1MsgRegA = 0;	/*critical threshold* in Celsius, 0xFF is not define */
-	FchParams->Imc.EcStruct.MsgFun83Zone1MsgRegB = 0x00;
-
-	FchParams->Imc.EcStruct.MsgFun85Zone1MsgReg0 = 0x00;
-	FchParams->Imc.EcStruct.MsgFun85Zone1MsgReg1 = 0x01;	/*Zone */
-	FchParams->Imc.EcStruct.MsgFun85Zone1MsgReg2 = 0;	/* AL0 percentage */
-	FchParams->Imc.EcStruct.MsgFun85Zone1MsgReg3 = 0;	/* AL1 percentage */
-	FchParams->Imc.EcStruct.MsgFun85Zone1MsgReg4 = 0;	/* AL2 percentage */
-	FchParams->Imc.EcStruct.MsgFun85Zone1MsgReg5 = 0x00;	/* AL3 percentage */
-	FchParams->Imc.EcStruct.MsgFun85Zone1MsgReg6 = 0x00;	/* AL4 percentage */
-	FchParams->Imc.EcStruct.MsgFun85Zone1MsgReg7 = 0x00;	/* AL5 percentage */
-	FchParams->Imc.EcStruct.MsgFun85Zone1MsgReg8 = 0x00;	/* AL6 percentage */
-	FchParams->Imc.EcStruct.MsgFun85Zone1MsgReg9 = 0x00;	/* AL7 percentage */
-
-	FchParams->Imc.EcStruct.MsgFun81Zone2MsgReg0 = 0x00;
-	FchParams->Imc.EcStruct.MsgFun81Zone2MsgReg1 = 0x2;	/* Zone */
-	FchParams->Imc.EcStruct.MsgFun81Zone2MsgReg2 = 0x0;//BIT0 | BIT2 | BIT5;
-	FchParams->Imc.EcStruct.MsgFun81Zone2MsgReg3 = 0x0;
-	FchParams->Imc.EcStruct.MsgFun81Zone2MsgReg4 = 0x00;
-	FchParams->Imc.EcStruct.MsgFun81Zone2MsgReg5 = 0x00;
-	FchParams->Imc.EcStruct.MsgFun81Zone2MsgReg6 = 0x98;	/* SMBUS Address for SMBUS based temperature sensor such as SB-TSI and ADM1032 */
-	FchParams->Imc.EcStruct.MsgFun81Zone2MsgReg7 = 2;
-	FchParams->Imc.EcStruct.MsgFun81Zone2MsgReg8 = 5;	/* PWM steping rate in unit of PWM level percentage */
-	FchParams->Imc.EcStruct.MsgFun81Zone2MsgReg9 = 0;
-
-	FchParams->Imc.EcStruct.MsgFun81Zone3MsgReg0 = 0x00;
-	FchParams->Imc.EcStruct.MsgFun81Zone3MsgReg1 = 0x3;	/* Zone */
-	FchParams->Imc.EcStruct.MsgFun81Zone3MsgReg2 = 0x0;//BIT0 | BIT2 | BIT5;
-	FchParams->Imc.EcStruct.MsgFun81Zone3MsgReg3 = 0x0;
-	FchParams->Imc.EcStruct.MsgFun81Zone3MsgReg4 = 0x00;
-	FchParams->Imc.EcStruct.MsgFun81Zone3MsgReg5 = 0x00;
-	FchParams->Imc.EcStruct.MsgFun81Zone3MsgReg6 = 0x0;	/* SMBUS Address for SMBUS based temperature sensor such as SB-TSI and ADM1032 */
-	FchParams->Imc.EcStruct.MsgFun81Zone3MsgReg7 = 0;
-	FchParams->Imc.EcStruct.MsgFun81Zone3MsgReg8 = 0;	/* PWM steping rate in unit of PWM level percentage */
-	FchParams->Imc.EcStruct.MsgFun81Zone3MsgReg9 = 0;
-
-	/* IMC Function */
-	FchParams->Imc.EcStruct.IMCFUNSupportBitMap = 0x333;//BIT0 | BIT4 |BIT8;
-
-	/* NOTE:
-	 * FchInitLateHwm will overwrite the EcStruct with EcDefaultMassege,
-	 * AGESA put EcDefaultMassege as global data in ROM, so we can't overwride it.
-	 * so we remove it from AGESA code. Please Seee FchInitLateHwm.
-	 */
-
 #else /* HWM fan control, the way not recommand */
 	FchParams->Imc.ImcEnable = FALSE;
 	FchParams->Hwm.HwMonitorEnable = TRUE;
@@ -265,7 +146,6 @@ static void oem_fan_control(FCH_DATA_BLOCK *FchParams)
 
 #endif /* CONFIG_HUDSON_IMC_FWM */
 }
-#endif
 
 /**
  * Fch Oem setting callback
@@ -290,7 +170,7 @@ AGESA_STATUS Fch_Oem_config(UINT32 Func, UINT32 FchData, VOID *ConfigPtr)
 		/* Azalia Controller Front Panel OEM Table Pointer */
 
 		/* Fan Control */
-		//oem_fan_control(FchParams_env);
+		oem_fan_control(FchParams_env);
 
 		/* XHCI configuration */
 #if CONFIG_HUDSON_XHCI_ENABLE
diff --git a/src/mainboard/amd/olivehill/Makefile.inc b/src/mainboard/amd/olivehill/Makefile.inc
index a83297a..fc4b335 100644
--- a/src/mainboard/amd/olivehill/Makefile.inc
+++ b/src/mainboard/amd/olivehill/Makefile.inc
@@ -26,3 +26,4 @@ ramstage-y += buildOpts.c
 ramstage-y += agesawrapper.c
 ramstage-y += BiosCallOuts.c
 ramstage-y += PlatformGnbPcie.c
+ramstage-y += imc_fan_control.c
diff --git a/src/mainboard/amd/olivehill/get_bus_conf.c b/src/mainboard/amd/olivehill/get_bus_conf.c
index a380872..aec8b02 100644
--- a/src/mainboard/amd/olivehill/get_bus_conf.c
+++ b/src/mainboard/amd/olivehill/get_bus_conf.c
@@ -25,6 +25,7 @@
 #include <stdlib.h>
 #include <cpu/amd/amdfam14.h>
 #include "agesawrapper.h"
+#include "imc.h"
 
 /* Global variables for MB layouts and these will be shared by irqtable mptable
  * and acpi_tables busnum is default.
@@ -145,4 +146,8 @@ void get_bus_conf(void)
 	bus_isa = 10;
 	apicid_base = CONFIG_MAX_CPUS;
 	apicid_yangtze = apicid_base;
+
+#if defined CONFIG_HUDSON_IMC_FWM && (CONFIG_HUDSON_IMC_FWM == 1)
+	imc_fan_control();
+#endif
 }
diff --git a/src/mainboard/amd/olivehill/imc_fan_control.c b/src/mainboard/amd/olivehill/imc_fan_control.c
new file mode 100644
index 0000000..85735ba
--- /dev/null
+++ b/src/mainboard/amd/olivehill/imc_fan_control.c
@@ -0,0 +1,57 @@
+#include <delay.h>
+#include "imc.h"
+
+void imc_func_0x81(void)
+{
+	write_imc_msg(MSG_REG0, 0x00);
+	write_imc_msg(MSG_REG1, 0x00);
+	write_imc_msg(MSG_REG2, 0x3d);
+	write_imc_msg(MSG_REG3, 0x4e);
+	write_imc_msg(MSG_REG4, 0x00);
+	write_imc_msg(MSG_REG5, 0x04);
+	write_imc_msg(MSG_REG6, 0x9a);
+	write_imc_msg(MSG_REG7, 0x01);
+	write_imc_msg(MSG_REG8, 0x01);
+	write_imc_msg(MSG_REG9, 0x00);
+	write_imc_msg(MSG_SYS_TO_IMC, Fun_81);
+	mdelay(50);
+}
+
+void imc_func_0x83(void)
+{
+	write_imc_msg(MSG_REG0, 0x00);
+	write_imc_msg(MSG_REG1, 0x00);
+	write_imc_msg(MSG_REG2, 0x46);
+	write_imc_msg(MSG_REG3, 0x3c);
+	write_imc_msg(MSG_REG4, 0x32);
+	write_imc_msg(MSG_REG5, 0xff);
+	write_imc_msg(MSG_REG6, 0xff);
+	write_imc_msg(MSG_REG7, 0xff);
+	write_imc_msg(MSG_REG8, 0xff);
+	write_imc_msg(MSG_REG9, 0xff);
+	write_imc_msg(MSG_REGA, 0x4b);
+	write_imc_msg(MSG_REGB, 0x00);
+	write_imc_msg(MSG_SYS_TO_IMC, Fun_83);
+	mdelay(50);
+}
+
+void imc_func_0x85(void)
+{
+	write_imc_msg(MSG_REG0, 0x00);
+	write_imc_msg(MSG_REG1, 0x00);
+	write_imc_msg(MSG_REG2, 0x5a);
+	write_imc_msg(MSG_REG3, 0x46);
+	write_imc_msg(MSG_REG4, 0x28);
+	write_imc_msg(MSG_REG5, 0xff);
+	write_imc_msg(MSG_REG6, 0xff);
+	write_imc_msg(MSG_REG7, 0xff);
+	write_imc_msg(MSG_REG8, 0xff);
+	write_imc_msg(MSG_REG9, 0xff);
+	write_imc_msg(MSG_SYS_TO_IMC, Fun_85);
+	mdelay(50);
+}
+
+void imc_func_0x89(void)
+{
+	/* not use */
+}



More information about the coreboot-gerrit mailing list