coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
fan_control.c File Reference
#include <arch/io.h>
#include <console/console.h>
#include "../common/fan_control.h"
#include "f81803a_hwm.h"
Include dependency graph for fan_control.c:

Go to the source code of this file.

Data Structures

struct  cross_ref
 

Functions

static const char * get_msg (int err)
 
static int message_invalid_1 (int err, u8 fan)
 
static int message_invalid_2 (int err, u8 fan)
 
static void write_hwm_reg (u16 address, u8 index, u8 value)
 
static u8 read_hwm_reg (u16 address, u8 index)
 
static void hwm_reg_modify (u16 address, u8 index, u8 shift, u8 mask, u8 value)
 
static void select_hwm_bank (u16 address, u8 value)
 
static int check_value_seq (u8 *values, u8 count)
 
int set_sensor_type (u16 base_address, external_sensor sensor, temp_sensor_type type)
 
int set_fan_temperature_source (u16 base_address, u8 fan, fan_temp_source source)
 
int set_fan_type_mode (u16 base_address, u8 fan, fan_type type, fan_mode mode)
 
int set_pwm_frequency (u16 base_address, u8 fan, fan_pwm_freq frequency)
 
int set_sections (u16 base_address, u8 fan, u8 *boundaries, u8 *sections)
 
int set_fan_speed_change_rate (u16 base_address, u8 fan, fan_rate_up rate_up, fan_rate_down rate_down)
 
int set_fan_follow (u16 base_address, u8 fan, fan_follow follow)
 

Variables

static const char msg_err_invalid [] = "Error: invalid"
 
static const char msg_err_wrong_order [] = "Error: wrong order,"
 
static const char msg_err_fan [] = "fan"
 
static const char msg_err_temp_source [] = "temperature source"
 
static const char msg_err_type [] = "type"
 
static const char msg_err_mode [] = "mode"
 
static const char msg_err_rate [] = "change rate"
 
static const char msg_err_frequency [] = "frequency"
 
static const char msg_err_temp_sensor [] = "temperature sensor"
 
static const char msg_err_bondary [] = "boundary"
 
static const char msg_err_section [] = "section"
 
static const char no_msg [] = ""
 
static struct cross_ref msg_table []
 

Function Documentation

◆ check_value_seq()

static int check_value_seq ( u8 values,
u8  count 
)
static

Definition at line 124 of file fan_control.c.

References count, CPU_DAMAGE_TEMP, HWM_STATUS_SUCCESS, STATUS_INVALID_ORDER, and STATUS_INVALID_VALUE.

Referenced by set_sections().

Here is the caller graph for this function:

◆ get_msg()

static const char* get_msg ( int  err)
static

Definition at line 36 of file fan_control.c.

References cross_ref::message, msg_table, no_msg, and cross_ref::selection.

Referenced by message_invalid_1().

Here is the caller graph for this function:

◆ hwm_reg_modify()

static void hwm_reg_modify ( u16  address,
u8  index,
u8  shift,
u8  mask,
u8  value 
)
static

Definition at line 97 of file fan_control.c.

References address, mask, read_hwm_reg(), value, and write_hwm_reg().

Referenced by select_hwm_bank(), set_fan_follow(), set_fan_speed_change_rate(), set_fan_temperature_source(), set_fan_type_mode(), set_pwm_frequency(), and set_sensor_type().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ message_invalid_1()

static int message_invalid_1 ( int  err,
u8  fan 
)
static

Definition at line 47 of file fan_control.c.

References BIOS_ERR, get_msg(), HWM_STATUS_INVALID_FAN, msg_err_invalid, and printk.

Referenced by set_fan_follow(), set_fan_speed_change_rate(), set_fan_temperature_source(), set_fan_type_mode(), set_pwm_frequency(), set_sections(), and set_sensor_type().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ message_invalid_2()

static int message_invalid_2 ( int  err,
u8  fan 
)
static

◆ read_hwm_reg()

static u8 read_hwm_reg ( u16  address,
u8  index 
)
static

Definition at line 88 of file fan_control.c.

References address, inb(), and outb().

Referenced by hwm_reg_modify(), set_pwm_frequency(), and set_sensor_type().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ select_hwm_bank()

static void select_hwm_bank ( u16  address,
u8  value 
)
inlinestatic

Definition at line 113 of file fan_control.c.

References address, FAN_BIT_MASK, FAN_FAULT_TIME_REG, FAN_FUNC_PROG_SEL_SHIFT, hwm_reg_modify(), and value.

Referenced by set_fan_speed_change_rate(), set_fan_temperature_source(), set_fan_type_mode(), and set_pwm_frequency().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_fan_follow()

int set_fan_follow ( u16  base_address,
u8  fan,
fan_follow  follow 
)

Definition at line 338 of file fan_control.c.

References BIOS_DEBUG, FAN_ADJUST, FAN_BIT_MASK, FAN_INTERPOLATION_SHIFT, FAN_TMP_MAPPING, FIRST_FAN, hwm_reg_modify(), HWM_STATUS_INVALID_FAN, HWM_STATUS_SUCCESS, LAST_FAN, message_invalid_1(), and printk.

Referenced by set_fan().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_fan_speed_change_rate()

◆ set_fan_temperature_source()

int set_fan_temperature_source ( u16  base_address,
u8  fan,
fan_temp_source  source 
)

◆ set_fan_type_mode()

int set_fan_type_mode ( u16  base_address,
u8  fan,
fan_type  type,
fan_mode  mode 
)

Definition at line 203 of file fan_control.c.

References BIOS_DEBUG, FAN_MODE_DEFAULT, FAN_MODE_MASK, FAN_MODE_REG, FAN_MODE_SHIFT, FAN_TYPE_MASK, FAN_TYPE_REG, FAN_TYPE_RESERVED, FAN_TYPE_SHIFT, FIRST_FAN, hwm_reg_modify(), HWM_STATUS_INVALID_FAN, HWM_STATUS_SUCCESS, LAST_FAN, message_invalid_1(), printk, select_hwm_bank(), and type.

Referenced by set_fan().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_pwm_frequency()

int set_pwm_frequency ( u16  base_address,
u8  fan,
fan_pwm_freq  frequency 
)

◆ set_sections()

◆ set_sensor_type()

◆ write_hwm_reg()

static void write_hwm_reg ( u16  address,
u8  index,
u8  value 
)
static

Definition at line 79 of file fan_control.c.

References address, outb(), and value.

Referenced by hwm_reg_modify(), and set_sections().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ msg_err_bondary

const char msg_err_bondary[] = "boundary"
static

Definition at line 17 of file fan_control.c.

Referenced by message_invalid_2().

◆ msg_err_fan

const char msg_err_fan[] = "fan"
static

Definition at line 10 of file fan_control.c.

◆ msg_err_frequency

const char msg_err_frequency[] = "frequency"
static

Definition at line 15 of file fan_control.c.

◆ msg_err_invalid

const char msg_err_invalid[] = "Error: invalid"
static

Definition at line 8 of file fan_control.c.

Referenced by message_invalid_1(), and message_invalid_2().

◆ msg_err_mode

const char msg_err_mode[] = "mode"
static

Definition at line 13 of file fan_control.c.

◆ msg_err_rate

const char msg_err_rate[] = "change rate"
static

Definition at line 14 of file fan_control.c.

◆ msg_err_section

const char msg_err_section[] = "section"
static

Definition at line 18 of file fan_control.c.

Referenced by message_invalid_2().

◆ msg_err_temp_sensor

const char msg_err_temp_sensor[] = "temperature sensor"
static

Definition at line 16 of file fan_control.c.

◆ msg_err_temp_source

const char msg_err_temp_source[] = "temperature source"
static

Definition at line 11 of file fan_control.c.

◆ msg_err_type

const char msg_err_type[] = "type"
static

Definition at line 12 of file fan_control.c.

◆ msg_err_wrong_order

const char msg_err_wrong_order[] = "Error: wrong order,"
static

Definition at line 9 of file fan_control.c.

Referenced by message_invalid_2().

◆ msg_table

struct cross_ref msg_table[]
static
Initial value:
= {
{0, NULL},
}
static const char msg_err_type[]
Definition: fan_control.c:12
static const char msg_err_temp_source[]
Definition: fan_control.c:11
static const char msg_err_frequency[]
Definition: fan_control.c:15
static const char msg_err_temp_sensor[]
Definition: fan_control.c:16
static const char msg_err_mode[]
Definition: fan_control.c:13
static const char msg_err_fan[]
Definition: fan_control.c:10
static const char msg_err_rate[]
Definition: fan_control.c:14
#define HWM_STATUS_INVALID_FAN
Definition: fan_control.h:93
#define HWM_STATUS_INVALID_RATE
Definition: fan_control.h:97
#define HWM_STATUS_INVALID_TEMP_SENSOR
Definition: fan_control.h:99
#define HWM_STATUS_INVALID_FREQUENCY
Definition: fan_control.h:98
#define HWM_STATUS_INVALID_TEMP_SOURCE
Definition: fan_control.h:94
#define HWM_STATUS_INVALID_MODE
Definition: fan_control.h:96
#define HWM_STATUS_INVALID_TYPE
Definition: fan_control.h:95
#define NULL
Definition: stddef.h:19

Definition at line 19 of file fan_control.c.

Referenced by get_msg().

◆ no_msg

const char no_msg[] = ""
static

Definition at line 19 of file fan_control.c.

Referenced by get_msg().