EC FW - FanControl

Fan Control – System Fan Control Mechanism

EC Firmware's control of system temperature can be divided into the following three main parts:

  • Temperature sensing and reading:Read real-time temperature information from the CPU chip.

  • Fan control logic:The system determines the most accurate or highest temperature value based

                on different system architectures, and then adjusts the fan speed to achieve the purpose of
                heat dissipation.
  • Fan operation status monitoring:Regularly check whether the actual fan speed falls within the

                expected range to ensure normal hardware operation and activate the protection mechanism
                in case of abnormality.


This article will provide a detailed explanation of the logic and implementation principles of the three

parts mentioned above.


  • Read system temperature: PollingThermal function PollingThermalThe main function

                responsible for polling and monitoring CPU temperature can be further divided into the
                following three sub-stages:
  • ReadCPUTemp – Reads CPU temperature:The real-time temperature of the CPU core or the

                entire package can be read through methods such as DTS (Digital Thermal Sensor) or Thermal
                Diode.
  • Validate Temperature – Temperature value check:Verify the validity of the temperature data

                read, including overheating anomalies (such as TJ limit), outdated data, or faulty sensor
                conditions.
  • Trigger Notification – Exception or Change Handling:If the temperature change exceeds the

                preset threshold (such as upper or lower levels), the system needs to be notified and the fan
                control adjustment process needs to be triggered.


ReadCPUTemp function – Temperature reading process description

ReadCPUTempThis is the main function in EC Firmware responsible for reading CPU temperature.

Its execution logic is as follows:

  • Establishing a Thermal Diode Table:
    EC Firmware will predefine aThermal Diode TableThis table contains information on all
             supported Thermal Diode devices, such as:
    • SMBusSlave Address

    • correspondingTemperature reading command (Command)

  • Query and transmit temperature reading commands:
    Before EC reads the CPU temperature through the SMBus interface, it will determine the
                current temperature based on the current...Thermal IndexThe Thermal Diode Table is
                consulted to obtain the corresponding Address and Command, and this information is
                transmitted to the Thermal Diode device.
  • Verify that the read was successful:
    • If the groupSlave Address and Command are correct.This will allow you to successfully

                            read a valid CPU temperature value.
    • If the read fails (e.g., no response or invalid data returned), EC will automatically...

                            Thermal IndexIncrement, pointing to the next piece of table data, and attempting
                            another set of device addresses and instructions on the next read.
  • Exception handling mechanism:
    • If the system still cannot obtain the temperature by trying all the supported thermal

                              digit combinations in the table, it is determined that the system does not support the
                              thermal digits of the existing design and the EC Firmware needs to be modified to
                            include the corresponding hardware components.


Thermal Table as shown below –

model

salve addr

command

model 0: LM75

0x90

0x00

model 1: MAX6657/6648

0x98

0x01

model 2: G781

0x98

0x01

model 3: MIC280 (.05)

0x9C

0x01


Advanced processing flow for temperature monitoring and fan control

Phase Two: Verifying the Temperature Data from the Remote Thermal Diode

After the EC reads the CPU temperature via the Remote Thermal Diode, it first checks if the value is

within a valid range. According to the SMBus data format:

  • 0x00 – 0x7FIndicates a positive value (corresponding to a temperature range of 0°C to 127°C).

  • 0x80 – 0xFFThis indicates a negative value (which is not typically seen in common operating

environments).

The original settings only accepted a temperature range of 10°C to 127°C as the effective temperature

range. However,Some CPUs may have a temperature reading below 10°C when powered on at 0°C.To

ensure compatibility, most platforms adjust the effective temperature range to [specified range].

0°C to 127°C。

Overheating treatment:

  • If detectedCPU temperature exceeds the system-defined shutdown threshold.And this

                situation continuesMore than 5 seconds,but:
    • EC Firmware will execute proactively.System shutdownThis is to avoid damage caused

by overheating.


Phase 3: Temperature Change Triggers Protection Event (Q-Event)

To enable the system to respond to thermal changes in real time, EC Firmware triggers corresponding

Q-Events based on temperature fluctuations:

  • When the system temperature rises or falls above a preset threshold (e.g.)±5°CWhen this happens,

            the EC sends a Q-Event notification to the BIOS.
    • The BIOS can perform corresponding protection actions based on this event (such as

adjusting power consumption mode, reducing brightness, limiting CPU functions, etc.).
  • As the temperature continues to rise to100°CEC will then send another Q-Event, explicitly

            instructing the system to perform [the necessary actions].ThrottlingThe BIOS performs CPU
            slowdown to protect system security.


Fan control logic

EC Firmware employs a stepped fan control logic to respond to different temperature stages, as

detailed below:

  1. Read fan speed setting:

    • from EARTHQUAKEChinaFanxStep(The maximum fan speed), and use this as the

                            reference for fan speed changes.
  1. Judgment mode and temperature parameters:

    • Based on the current mode (e.g.)TJ100、TJ85、Silent Mode or Performance Mode),

                            obtain the corresponding order for each levelUpper/lower temperature limits。
  1. Controlling fan speed up/down:

    • If the current temperature is higher than the level of the stage...Upper limit

                            temperatureAnd if the fan order is not the highest, then:
      • Fan level +1

    • If the current temperature is lower than the level of the stage it belongs to.Lower limit

                            temperature And if the fan order is greater than 0, then:
      • Fan order -1


EC achieves a balance between cooling and quiet operation by precisely controlling the fan speed

through this dynamic adjustment mechanism.


  • Fan speed monitoring – using the Timer module
    EC Firmware viaMFT16 (Multi-Function Timer 16-bit) ModuleThis is used to accurately calculate

  • the actual fan speed. The principle and calculation logic are as follows:


1. Obtain the pulse width.
    • The fan speed usually passes throughTACH feedback signal(Tachometer Feedback) is

                            transmitted back to the EC in pulse mode.
    • EC uses the timing function of the Timer module to detect fromThe signal count starts

                           from HIGH → LOW.Until the next signal is fromUntil HIGH → LOWThis means completing
                            the measurement of one complete pulse cycle.
    • This pulse cycle corresponds to a portion of the fan's rotation (usually half a revolution,

                            depending on the fan design).
  • 2. Calculate the time required for one complete rotation.

    • Assuming the fan needs to complete one revolution...NTACH pulse wave, rule:
      Time required for one rotation (seconds) = Single pulse time × N

  • 3. Convert to rotational speeds per minute (RPM)

    • The unit for fan speed is RPM (Revolutions Per Minute).

    • Therefore, the "time required for one revolution (in seconds)" needs to be converted into

                            the number of revolutions per minute:

                            RPM =     60 Time required for one lap (seconds) = 60 Pulse Width × N
                            RPM =     60 Pulse Width × N 60


Fan speed calculation and control algorithm

I. Fan Speed ​​Calculation Formula

EC utilizes the built-in TimerModuleThe basic formula for calculating the actual fan speed is as follows:

1. Lap Time Calculation:

Time required for the fan to complete one revolution = Number of pulses per revolution ×

(132768 × (0xFFFF − TxCRA/B))

  • 32768Timer clock frequency (Hz)

  • TxCRA/BThe timer count value (obtained from the MFT module).

  • Required per lapPulse wave numberDepending on the fan design, a common pulse

                /revolution is 2.


2. RPM (Rotational Speed) Calculation:

RPM = 60, the time required for the fan to complete one revolution.


II. Speed ​​Range Table Mechanism

To ensure that the fan operates within the expected range, EC Firmware establishes a TxCRA/B upper

and lower limit comparison table based on the deviation range of every 100 RPM.

  • If the calculation yieldsTxCRA/BIf the value falls within the upper or lower limit range of the

                reference table, the rotation speed is considered normal.
  • If the speed deviates from this range, it indicates an abnormal fan speed, requiring voltage

                adjustment or error handling.


III. Fan Speed ​​Control Logic (func_FanSpeed ​​Algorithm)

func_FanSpeedThe core function for controlling fan speed has the following logic:

1. Control condition judgment:

  • If the system is inDOS modeAnd executePE test program(e.g., fan verification tools), then:

    • EC pauses control of fan speed, allowing PE program to manage fan adjustments.

  • Otherwise, proceed with the normal control process:

2. Normal control logic:

  • EC reads the current actual fan speed and compares it with the range in the lookup table.

  • If the rotation speed is lower than the lower limit→ Increase the fan control voltage

                (PWM duty up).
  • If the rotation speed is higher than the upper limit value→ Reduce fan control voltage

                (PWM duty down).

3. Fail-safe handling:

  • If the fanIt remains stationary for more than 60 seconds.Even if the voltage has been adjusted:

    • EC will send it directlyMaximum control voltage (maximum PWM Duty)Force the fan to

                            start.
    • If it still cannot rotate → the fan is faulty.



留言

這個網誌中的熱門文章

EC 所需知識 - SMBUS

EC Required Knowledge - KBC

EC Required Knowledge - LPC