diff options
author | Bill Richardson <wfrichar@chromium.org> | 2013-10-30 10:38:31 -0700 |
---|---|---|
committer | chrome-internal-fetch <chrome-internal-fetch@google.com> | 2013-10-30 23:10:10 +0000 |
commit | e48a9d9c2143695cdd7a35ab06d6a6d5820efd9b (patch) | |
tree | e7a3a92ac80fadf61dd1b7df16e62c9f48fcd9c0 /board | |
parent | 034e96c128d0e1ee7c100c47456c2159a133288c (diff) | |
download | chrome-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
Diffstat (limited to 'board')
-rw-r--r-- | board/bolt/board.c | 14 | ||||
-rw-r--r-- | board/bolt/board.h | 5 | ||||
-rw-r--r-- | board/falco/board.c | 16 | ||||
-rw-r--r-- | board/falco/board.h | 12 | ||||
-rw-r--r-- | board/host/board.h | 6 | ||||
-rw-r--r-- | board/host/fan.c | 12 | ||||
-rw-r--r-- | board/link/board.c | 14 | ||||
-rw-r--r-- | board/link/board.h | 5 | ||||
-rw-r--r-- | board/peppy/board.c | 17 | ||||
-rw-r--r-- | board/peppy/board.h | 13 | ||||
-rw-r--r-- | board/samus/board.c | 14 | ||||
-rw-r--r-- | board/samus/board.h | 6 | ||||
-rw-r--r-- | board/slippy/board.c | 17 | ||||
-rw-r--r-- | board/slippy/board.h | 13 |
14 files changed, 84 insertions, 80 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, |