summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBill Richardson <wfrichar@chromium.org>2013-10-30 10:38:31 -0700
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2013-10-30 23:10:10 +0000
commite48a9d9c2143695cdd7a35ab06d6a6d5820efd9b (patch)
treee7a3a92ac80fadf61dd1b7df16e62c9f48fcd9c0
parent034e96c128d0e1ee7c100c47456c2159a133288c (diff)
downloadchrome-ec-e48a9d9c2143695cdd7a35ab06d6a6d5820efd9b.tar.gz
Separate fan_t from pwm_t
There is a logical difference between PWM controls for things like backlights and fan controls for actual fans. This change separates them into two different data structures, for better abstraction. BUG=chrome-os-partner:23530 BRANCH=none TEST=manual make runtests, make all boards, test on Link and Falco. Change-Id: Ib63f2d1518fcc2ee367f81bf5d803360c1aa5c76 Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/175151
-rw-r--r--board/bolt/board.c14
-rw-r--r--board/bolt/board.h5
-rw-r--r--board/falco/board.c16
-rw-r--r--board/falco/board.h12
-rw-r--r--board/host/board.h6
-rw-r--r--board/host/fan.c12
-rw-r--r--board/link/board.c14
-rw-r--r--board/link/board.h5
-rw-r--r--board/peppy/board.c17
-rw-r--r--board/peppy/board.h13
-rw-r--r--board/samus/board.c14
-rw-r--r--board/samus/board.h6
-rw-r--r--board/slippy/board.c17
-rw-r--r--board/slippy/board.h13
-rw-r--r--common/fan.c44
-rw-r--r--include/config.h22
-rw-r--r--include/fan.h24
-rw-r--r--include/pwm.h3
-rw-r--r--test/test_config.h6
19 files changed, 139 insertions, 124 deletions
diff --git a/board/bolt/board.c b/board/bolt/board.c
index 42df5f86da..0bf1271253 100644
--- a/board/bolt/board.c
+++ b/board/bolt/board.c
@@ -12,6 +12,7 @@
#include "common.h"
#include "driver/temp_sensor/tmp006.h"
#include "extpower.h"
+#include "fan.h"
#include "gpio.h"
#include "host_command.h"
#include "i2c.h"
@@ -184,11 +185,22 @@ BUILD_ASSERT(ARRAY_SIZE(adc_channels) == ADC_CH_COUNT);
/* PWM channels. Must be in the exactly same order as in enum pwm_channel. */
const struct pwm_t pwm_channels[] = {
- {CONFIG_FAN_CH_CPU, PWM_CONFIG_HAS_RPM_MODE},
{4, 0},
};
BUILD_ASSERT(ARRAY_SIZE(pwm_channels) == PWM_CH_COUNT);
+/* Physical fans. These are logically separate from pwm_channels. */
+const struct fan_t fans[] = {
+ {.flags = FAN_USE_RPM_MODE,
+ .rpm_min = 1500,
+ .rpm_max = 9300,
+ .ch = 2,
+ .pgood_gpio = GPIO_PP5000_PGOOD,
+ .enable_gpio = -1,
+ },
+};
+BUILD_ASSERT(ARRAY_SIZE(fans) == CONFIG_FANS);
+
/* I2C ports */
const struct i2c_port_t i2c_ports[] = {
/* Note: battery and charger share a port. Only include it once in
diff --git a/board/bolt/board.h b/board/bolt/board.h
index 0fbcb5cdcd..0ab6ea67a0 100644
--- a/board/bolt/board.h
+++ b/board/bolt/board.h
@@ -37,10 +37,6 @@
/* External Charger maximum current. */
#define CONFIG_CHARGER_INPUT_CURRENT 5000
#define CONFIG_FANS 1
-#define CONFIG_FAN_CH_CPU 2
-#define CONFIG_FAN_PGOOD_GPIO GPIO_PP5000_PGOOD
-#define CONFIG_FAN_RPM_MIN 1500
-#define CONFIG_FAN_RPM_MAX 9300
#define CONFIG_PWM
#define CONFIG_PWM_KBLIGHT
#define CONFIG_SWITCH_DEDICATED_RECOVERY
@@ -176,7 +172,6 @@ enum adc_channel {
};
enum pwm_channel {
- PWM_CH_FAN,
PWM_CH_KBLIGHT,
/* Number of PWM channels */
diff --git a/board/falco/board.c b/board/falco/board.c
index 3e8b88da69..b0a8ece31d 100644
--- a/board/falco/board.c
+++ b/board/falco/board.c
@@ -22,8 +22,6 @@
#include "lid_switch.h"
#include "peci.h"
#include "power_button.h"
-#include "pwm.h"
-#include "pwm_chip.h"
#include "registers.h"
#include "switch.h"
#include "temp_sensor.h"
@@ -190,11 +188,17 @@ const struct adc_t adc_channels[] = {
};
BUILD_ASSERT(ARRAY_SIZE(adc_channels) == ADC_CH_COUNT);
-/* PWM channels. Must be in the exactly same order as in enum pwm_channel. */
-const struct pwm_t pwm_channels[] = {
- {CONFIG_FAN_CH_CPU, PWM_CONFIG_HAS_RPM_MODE},
+/* Physical fans. These are logically separate from pwm_channels. */
+const struct fan_t fans[] = {
+ {.flags = FAN_USE_RPM_MODE,
+ .rpm_min = 1000,
+ .rpm_max = 5050,
+ .ch = 2,
+ .pgood_gpio = GPIO_PP5000_PGOOD,
+ .enable_gpio = -1,
+ },
};
-BUILD_ASSERT(ARRAY_SIZE(pwm_channels) == PWM_CH_COUNT);
+BUILD_ASSERT(ARRAY_SIZE(fans) == CONFIG_FANS);
/* I2C ports */
const struct i2c_port_t i2c_ports[] = {
diff --git a/board/falco/board.h b/board/falco/board.h
index 861209f259..a9af0ddef3 100644
--- a/board/falco/board.h
+++ b/board/falco/board.h
@@ -22,16 +22,11 @@
#define CONFIG_EXTPOWER_FALCO
#define CONFIG_EXTPOWER_GPIO
#define CONFIG_FANS 1
-#define CONFIG_FAN_CH_CPU 2
-#define CONFIG_FAN_PGOOD_GPIO GPIO_PP5000_PGOOD
-#define CONFIG_FAN_RPM_MIN 1000
-#define CONFIG_FAN_RPM_MAX 5050
#define CONFIG_KEYBOARD_BOARD_CONFIG
#define CONFIG_KEYBOARD_PROTOCOL_8042
#define CONFIG_LOW_POWER_IDLE
#define CONFIG_POWER_BUTTON
#define CONFIG_POWER_BUTTON_X86
-#define CONFIG_PWM
#define CONFIG_SWITCH_DEDICATED_RECOVERY
#define CONFIG_TEMP_SENSOR
#define CONFIG_TEMP_SENSOR_G781
@@ -171,13 +166,6 @@ enum adc_channel {
ADC_CH_COUNT
};
-enum pwm_channel {
- PWM_CH_FAN,
-
- /* Number of PWM channels */
- PWM_CH_COUNT
-};
-
enum temp_sensor_id {
/* CPU die temperature via PECI */
TEMP_SENSOR_CPU_PECI = 0,
diff --git a/board/host/board.h b/board/host/board.h
index 9d2a8f88fe..ab67e8d67b 100644
--- a/board/host/board.h
+++ b/board/host/board.h
@@ -50,10 +50,4 @@ enum adc_channel {
ADC_CH_COUNT
};
-enum pwm_channel {
- PWM_CH_FAN,
-
- PWM_CH_COUNT
-};
-
#endif /* __BOARD_H */
diff --git a/board/host/fan.c b/board/host/fan.c
index b7a10de05c..18127b9eb0 100644
--- a/board/host/fan.c
+++ b/board/host/fan.c
@@ -6,6 +6,18 @@
/* Mocked fan implementation for tests */
#include "fan.h"
+#include "util.h"
+
+const struct fan_t fans[] = {
+ {.flags = FAN_USE_RPM_MODE,
+ .rpm_min = 1000,
+ .rpm_max = 5000,
+ .ch = 0,
+ .pgood_gpio = -1,
+ .enable_gpio = -1,
+ },
+};
+BUILD_ASSERT(ARRAY_SIZE(fans) == CONFIG_FANS);
static int mock_enabled;
void fan_set_enabled(int ch, int enabled)
diff --git a/board/link/board.c b/board/link/board.c
index 0a43498c1c..0012a7bf7e 100644
--- a/board/link/board.c
+++ b/board/link/board.c
@@ -12,6 +12,7 @@
#include "common.h"
#include "driver/temp_sensor/tmp006.h"
#include "extpower.h"
+#include "fan.h"
#include "gpio.h"
#include "i2c.h"
#include "keyboard_scan.h"
@@ -183,11 +184,22 @@ BUILD_ASSERT(ARRAY_SIZE(adc_channels) == ADC_CH_COUNT);
/* PWM channels. Must be in the exactly same order as in enum pwm_channel. */
const struct pwm_t pwm_channels[] = {
- {CONFIG_FAN_CH_CPU, PWM_CONFIG_HAS_RPM_MODE},
{1, 0},
};
BUILD_ASSERT(ARRAY_SIZE(pwm_channels) == PWM_CH_COUNT);
+/* Physical fans. These are logically separate from pwm_channels. */
+const struct fan_t fans[] = {
+ {.flags = FAN_USE_RPM_MODE,
+ .rpm_min = 1500,
+ .rpm_max = 9300,
+ .ch = 0,
+ .pgood_gpio = GPIO_PGOOD_5VALW,
+ .enable_gpio = -1,
+ },
+};
+BUILD_ASSERT(ARRAY_SIZE(fans) == CONFIG_FANS);
+
/* I2C ports */
const struct i2c_port_t i2c_ports[] = {
/* Note: battery and charger share a port. Only include it once in
diff --git a/board/link/board.h b/board/link/board.h
index 58bec5d2ea..1443154247 100644
--- a/board/link/board.h
+++ b/board/link/board.h
@@ -22,10 +22,6 @@
#define CONFIG_CHIPSET_X86
#define CONFIG_EXTPOWER_GPIO
#define CONFIG_FANS 1
-#define CONFIG_FAN_CH_CPU 0
-#define CONFIG_FAN_PGOOD_GPIO GPIO_PGOOD_5VALW
-#define CONFIG_FAN_RPM_MIN 1500
-#define CONFIG_FAN_RPM_MAX 9300
#define CONFIG_I2C_PASSTHRU_RESTRICTED
#define CONFIG_KEYBOARD_BOARD_CONFIG
#define CONFIG_KEYBOARD_PROTOCOL_8042
@@ -56,7 +52,6 @@ enum adc_channel {
};
enum pwm_channel {
- PWM_CH_FAN,
PWM_CH_KBLIGHT,
/* Number of PWM channels */
diff --git a/board/peppy/board.c b/board/peppy/board.c
index 6e3db562a6..e6205e521b 100644
--- a/board/peppy/board.c
+++ b/board/peppy/board.c
@@ -12,6 +12,7 @@
#include "common.h"
#include "driver/temp_sensor/g781.h"
#include "extpower.h"
+#include "fan.h"
#include "gpio.h"
#include "host_command.h"
#include "i2c.h"
@@ -20,8 +21,6 @@
#include "lid_switch.h"
#include "peci.h"
#include "power_button.h"
-#include "pwm.h"
-#include "pwm_chip.h"
#include "registers.h"
#include "switch.h"
#include "temp_sensor.h"
@@ -183,11 +182,17 @@ const struct adc_t adc_channels[] = {
};
BUILD_ASSERT(ARRAY_SIZE(adc_channels) == ADC_CH_COUNT);
-/* PWM channels. Must be in the exactly same order as in enum pwm_channel. */
-const struct pwm_t pwm_channels[] = {
- {CONFIG_FAN_CH_CPU, PWM_CONFIG_HAS_RPM_MODE},
+/* Physical fans. These are logically separate from pwm_channels. */
+const struct fan_t fans[] = {
+ {.flags = FAN_USE_RPM_MODE,
+ .rpm_min = 1000,
+ .rpm_max = 5050,
+ .ch = 2,
+ .pgood_gpio = GPIO_PP5000_PGOOD,
+ .enable_gpio = GPIO_PP5000_FAN_EN,
+ },
};
-BUILD_ASSERT(ARRAY_SIZE(pwm_channels) == PWM_CH_COUNT);
+BUILD_ASSERT(ARRAY_SIZE(fans) == CONFIG_FANS);
/* I2C ports */
const struct i2c_port_t i2c_ports[] = {
diff --git a/board/peppy/board.h b/board/peppy/board.h
index 4ccc7ba465..61b79b320d 100644
--- a/board/peppy/board.h
+++ b/board/peppy/board.h
@@ -23,18 +23,12 @@
#define CONFIG_CMD_GSV
#define CONFIG_EXTPOWER_GPIO
#define CONFIG_FANS 1
-#define CONFIG_FAN_CH_CPU 2
-#define CONFIG_FAN_EN_GPIO GPIO_PP5000_FAN_EN
-#define CONFIG_FAN_PGOOD_GPIO GPIO_PP5000_PGOOD
-#define CONFIG_FAN_RPM_MIN 1000
-#define CONFIG_FAN_RPM_MAX 5050
#define CONFIG_KEYBOARD_BOARD_CONFIG
#define CONFIG_KEYBOARD_PROTOCOL_8042
#define CONFIG_LED_COMMON
#define CONFIG_LOW_POWER_IDLE
#define CONFIG_POWER_BUTTON
#define CONFIG_POWER_BUTTON_X86
-#define CONFIG_PWM
#define CONFIG_SWITCH_DEDICATED_RECOVERY
#define CONFIG_TEMP_SENSOR
#define CONFIG_TEMP_SENSOR_G781
@@ -170,13 +164,6 @@ enum adc_channel {
ADC_CH_COUNT
};
-enum pwm_channel {
- PWM_CH_FAN,
-
- /* Number of PWM channels */
- PWM_CH_COUNT
-};
-
enum temp_sensor_id {
/* CPU die temperature via PECI */
TEMP_SENSOR_CPU_PECI = 0,
diff --git a/board/samus/board.c b/board/samus/board.c
index c9aed7b46a..9e6b039715 100644
--- a/board/samus/board.c
+++ b/board/samus/board.c
@@ -11,6 +11,7 @@
#include "common.h"
#include "driver/temp_sensor/tmp006.h"
#include "extpower.h"
+#include "fan.h"
#include "gpio.h"
#include "host_command.h"
#include "i2c.h"
@@ -185,11 +186,22 @@ BUILD_ASSERT(ARRAY_SIZE(adc_channels) == ADC_CH_COUNT);
/* PWM channels. Must be in the exactly same order as in enum pwm_channel. */
const struct pwm_t pwm_channels[] = {
- {CONFIG_FAN_CH_CPU, PWM_CONFIG_HAS_RPM_MODE},
{4, 0},
};
BUILD_ASSERT(ARRAY_SIZE(pwm_channels) == PWM_CH_COUNT);
+/* Physical fans. These are logically separate from pwm_channels. */
+const struct fan_t fans[] = {
+ {.flags = FAN_USE_RPM_MODE,
+ .rpm_min = 1000,
+ .rpm_max = 5050,
+ .ch = 2,
+ .pgood_gpio = -1, /* HEY */
+ .enable_gpio = -1, /* HEY */
+ },
+};
+BUILD_ASSERT(ARRAY_SIZE(fans) == CONFIG_FANS);
+
/* I2C ports */
const struct i2c_port_t i2c_ports[] = {
/* Note: battery and charger share a port. Only include it once in
diff --git a/board/samus/board.h b/board/samus/board.h
index 6105f61d0f..ba2d7c7555 100644
--- a/board/samus/board.h
+++ b/board/samus/board.h
@@ -35,10 +35,7 @@
#define CONFIG_CHARGER_SENSE_RESISTOR 10
#define CONFIG_CHARGER_SENSE_RESISTOR_AC 10
#define CONFIG_CHARGER_INPUT_CURRENT 2000
-#define CONFIG_FANS 1
-#define CONFIG_FAN_CH_CPU 2
-#define CONFIG_FAN_RPM_MIN 1000
-#define CONFIG_FAN_RPM_MAX 5050
+#define CONFIG_FANS 1 /* HEY */
#define CONFIG_PWM
#define CONFIG_PWM_KBLIGHT
#define CONFIG_SWITCH_DEDICATED_RECOVERY
@@ -180,7 +177,6 @@ enum adc_channel {
};
enum pwm_channel {
- PWM_CH_FAN,
PWM_CH_KBLIGHT,
/* Number of PWM channels */
diff --git a/board/slippy/board.c b/board/slippy/board.c
index 9ef0fc02b1..25ecb016aa 100644
--- a/board/slippy/board.c
+++ b/board/slippy/board.c
@@ -12,6 +12,7 @@
#include "common.h"
#include "driver/temp_sensor/g781.h"
#include "extpower.h"
+#include "fan.h"
#include "gpio.h"
#include "host_command.h"
#include "i2c.h"
@@ -20,8 +21,6 @@
#include "lid_switch.h"
#include "peci.h"
#include "power_button.h"
-#include "pwm.h"
-#include "pwm_chip.h"
#include "registers.h"
#include "switch.h"
#include "temp_sensor.h"
@@ -181,11 +180,17 @@ const struct adc_t adc_channels[] = {
};
BUILD_ASSERT(ARRAY_SIZE(adc_channels) == ADC_CH_COUNT);
-/* PWM channels. Must be in the exactly same order as in enum pwm_channel. */
-const struct pwm_t pwm_channels[] = {
- {CONFIG_FAN_CH_CPU, PWM_CONFIG_HAS_RPM_MODE},
+/* Physical fans. These are logically separate from pwm_channels. */
+const struct fan_t fans[] = {
+ {.flags = FAN_USE_RPM_MODE,
+ .rpm_min = 1000,
+ .rpm_max = 5050,
+ .ch = 2,
+ .pgood_gpio = GPIO_PP5000_PGOOD,
+ .enable_gpio = -1,
+ },
};
-BUILD_ASSERT(ARRAY_SIZE(pwm_channels) == PWM_CH_COUNT);
+BUILD_ASSERT(ARRAY_SIZE(fans) == CONFIG_FANS);
/* I2C ports */
const struct i2c_port_t i2c_ports[] = {
diff --git a/board/slippy/board.h b/board/slippy/board.h
index e44ca261fb..4c73481eca 100644
--- a/board/slippy/board.h
+++ b/board/slippy/board.h
@@ -23,16 +23,11 @@
#define CONFIG_CMD_GSV
#define CONFIG_EXTPOWER_GPIO
#define CONFIG_FANS 1
-#define CONFIG_FAN_CH_CPU 2
-#define CONFIG_FAN_PGOOD_GPIO GPIO_PP5000_PGOOD
-#define CONFIG_FAN_RPM_MIN 1000
-#define CONFIG_FAN_RPM_MAX 5050
#define CONFIG_KEYBOARD_BOARD_CONFIG
#define CONFIG_KEYBOARD_PROTOCOL_8042
#define CONFIG_LOW_POWER_IDLE
#define CONFIG_POWER_BUTTON
#define CONFIG_POWER_BUTTON_X86
-#define CONFIG_PWM
#define CONFIG_SWITCH_DEDICATED_RECOVERY
#define CONFIG_TEMP_SENSOR
#define CONFIG_TEMP_SENSOR_G781
@@ -161,20 +156,12 @@ enum adc_channel {
/* EC internal die temperature in degrees K. */
ADC_CH_EC_TEMP = 0,
- /* HEY: Be prepared to read this (ICMNT). */
/* Charger current in mA. */
ADC_CH_CHARGER_CURRENT,
ADC_CH_COUNT
};
-enum pwm_channel {
- PWM_CH_FAN,
-
- /* Number of PWM channels */
- PWM_CH_COUNT
-};
-
enum temp_sensor_id {
/* CPU die temperature via PECI */
TEMP_SENSOR_CPU_PECI = 0,
diff --git a/common/fan.c b/common/fan.c
index 635f541e02..209953f342 100644
--- a/common/fan.c
+++ b/common/fan.c
@@ -14,6 +14,10 @@
#include "system.h"
#include "util.h"
+/* HEY - this is temporary! (crosbug.com/p/23530) */
+#define CONFIG_FAN_CH_CPU (fans[0].ch)
+#define HEY0 0
+
/* True if we're listening to the thermal control task. False if we're setting
* things manually. */
static int thermal_control_enabled;
@@ -26,13 +30,15 @@ static int thermal_control_enabled;
*/
int fan_percent_to_rpm(int pct)
{
- int rpm;
+ int rpm, max, min;
- if (!pct)
+ if (!pct) {
rpm = 0;
- else
- rpm = ((pct - 1) * CONFIG_FAN_RPM_MAX +
- (100 - pct) * CONFIG_FAN_RPM_MIN) / 99;
+ } else {
+ min = fans[HEY0].rpm_min;
+ max = fans[HEY0].rpm_max;
+ rpm = ((pct - 1) * max + (100 - pct) * min) / 99;
+ }
return rpm;
}
@@ -55,9 +61,8 @@ static void set_enabled(int enable)
{
fan_set_enabled(CONFIG_FAN_CH_CPU, enable);
-#ifdef CONFIG_FAN_EN_GPIO
- gpio_set_level(CONFIG_FAN_EN_GPIO, enable);
-#endif /* CONFIG_FAN_EN_GPIO */
+ if (fans[HEY0].enable_gpio >= 0)
+ gpio_set_level(fans[HEY0].enable_gpio, enable);
}
static void set_thermal_control_enabled(int enable)
@@ -102,7 +107,7 @@ static int cc_faninfo(int argc, char **argv)
static const char * const human_status[] = {
"not spinning", "changing", "locked", "frustrated"
};
- int tmp;
+ int tmp, is_pgood;
ccprintf("Actual: %4d rpm\n",
fan_get_rpm_actual(CONFIG_FAN_CH_CPU));
@@ -117,14 +122,18 @@ static int cc_faninfo(int argc, char **argv)
ccprintf("Auto: %s\n", thermal_control_enabled ? "yes" : "no");
ccprintf("Enable: %s\n",
fan_get_enabled(CONFIG_FAN_CH_CPU) ? "yes" : "no");
-#ifdef CONFIG_FAN_PGOOD_GPIO
- ccprintf("Power: %s\n",
-#ifdef CONFIG_FAN_EN_GPIO
- gpio_get_level(CONFIG_FAN_EN_GPIO) &&
-#endif
- gpio_get_level(CONFIG_FAN_PGOOD_GPIO) ? "yes" : "no");
-#endif
+ /* Assume we don't know */
+ is_pgood = -1;
+ /* If we have an enable output, see if it's on or off. */
+ if (fans[HEY0].enable_gpio >= 0)
+ is_pgood = gpio_get_level(fans[HEY0].enable_gpio);
+ /* If we have a pgood input, it overrides any enable output. */
+ if (fans[HEY0].pgood_gpio >= 0)
+ is_pgood = gpio_get_level(fans[HEY0].pgood_gpio);
+ /* If we think we know, say so */
+ if (is_pgood >= 0)
+ ccprintf("Power: %s\n", is_pgood ? "yes" : "no");
return EC_SUCCESS;
}
@@ -267,6 +276,9 @@ static void pwm_fan_init(void)
gpio_config_module(MODULE_PWM_FAN, 1);
+ for (i = 0; i < CONFIG_FANS; i++)
+ fan_channel_setup(fans[i].ch, fans[i].flags);
+
prev = (const struct pwm_fan_state *)
system_get_jump_tag(PWMFAN_SYSJUMP_TAG, &version, &size);
if (prev && version == PWM_HOOK_VERSION && size == sizeof(*prev)) {
diff --git a/include/config.h b/include/config.h
index 1d7758d7e1..05f085f180 100644
--- a/include/config.h
+++ b/include/config.h
@@ -332,27 +332,9 @@
/* Number of cooling fans. Undef if none. */
#undef CONFIG_FANS
-/* Fan channel (not PWM channel) for the CPU fan */
-#undef CONFIG_FAN_CH_CPU
-
-/* Name of active high GPIO to control power to the cooling fan */
-#undef CONFIG_FAN_EN_GPIO
-
-/*
- * GPIO which indicates power-good on the fan power rail. If defined, the
- * faninfo console command will display the fan power state.
- */
-#undef CONFIG_FAN_PGOOD_GPIO
-
-/* Fan speeds corresponding to 1% and 100% cooling (0% == off). */
-#undef CONFIG_FAN_RPM_MIN
-#undef CONFIG_FAN_RPM_MAX
-
/*
- * Replace the default fan mapping with a board-specific function in board.c:
- *
- * int fan_percent_to_rpm(int pct);
- *
+ * Replace the default fan_percent_to_rpm() function with a board-specific
+ * implementation in board.c
*/
#undef CONFIG_FAN_RPM_CUSTOM
diff --git a/include/fan.h b/include/fan.h
index 781bfc9951..4c41f2c175 100644
--- a/include/fan.h
+++ b/include/fan.h
@@ -8,13 +8,33 @@
#ifndef __CROS_EC_FAN_H
#define __CROS_EC_FAN_H
+/* Characteristic of each physical fan */
+struct fan_t {
+ unsigned int flags;
+ int rpm_min;
+ int rpm_max;
+ /* Hardware channel number (the meaning is chip-specific) */
+ int ch;
+ /* Active-high power_good input GPIO, or -1 if none */
+ int pgood_gpio;
+ /* Active-high power_enable output GPIO, or -1 if none */
+ int enable_gpio;
+};
+
+/* Values for the flags field */
+#define FAN_USE_RPM_MODE (1 << 0)
+
+/* The list of fans is instantiated in board.c. */
+extern const struct fan_t fans[];
+
+
/**
* Set the amount of active cooling needed. The thermal control task will call
* this frequently, and the fan control logic will attempt to provide it.
*
* @param pct Percentage of cooling effort needed (0 - 100)
*/
-void fan_set_percent_needed(int pct);
+void fan_set_percent_needed(int pct); /* HEY: need fan arg */
/**
* This function translates the percentage of cooling needed into a target RPM.
@@ -24,7 +44,7 @@ void fan_set_percent_needed(int pct);
* @param pct Percentage of cooling effort needed (always in [0,100])
* Return Target RPM for fan
*/
-int fan_percent_to_rpm(int pct);
+int fan_percent_to_rpm(int pct); /* HEY: need fan arg */
/**
diff --git a/include/pwm.h b/include/pwm.h
index cb0f961713..c4ae331b1c 100644
--- a/include/pwm.h
+++ b/include/pwm.h
@@ -6,6 +6,9 @@
#ifndef __CROS_EC_PWM_H
#define __CROS_EC_PWM_H
+/* The values are defined in board.h */
+enum pwm_channel;
+
/**
* Enable/disable a PWM channel.
*/
diff --git a/test/test_config.h b/test/test_config.h
index 3a97ed50f9..1273a4c4aa 100644
--- a/test/test_config.h
+++ b/test/test_config.h
@@ -52,9 +52,6 @@ int board_discharge_on_ac(int enabled);
#ifdef TEST_thermal
#define CONFIG_CHIPSET_CAN_THROTTLE
#define CONFIG_FANS 1
-#define CONFIG_FAN_CH_CPU 0
-#define CONFIG_FAN_RPM_MAX 5000
-#define CONFIG_FAN_RPM_MIN 1000
#define CONFIG_TEMP_SENSOR
#endif
@@ -66,9 +63,6 @@ int board_discharge_on_ac(int enabled);
#define CONFIG_CHIPSET_CAN_THROTTLE
#define CONFIG_EXTPOWER_FALCO
#define CONFIG_FANS 1
-#define CONFIG_FAN_CH_CPU 0
-#define CONFIG_FAN_RPM_MAX 5000
-#define CONFIG_FAN_RPM_MIN 1000
#define CONFIG_TEMP_SENSOR
#define I2C_PORT_BATTERY 1
#define I2C_PORT_CHARGER 1