From 7f4018c41f875c7fbdff03ee4a489753d541b0a9 Mon Sep 17 00:00:00 2001 From: Daisuke Nojiri Date: Mon, 5 Mar 2018 09:49:40 -0800 Subject: fan: Allow board to configure fans at run time This patch splits struct fan_t into two parts: base configuration and RPM configuration. RPMs are expected to be different from model to model while a base configuration is most likely shared. BUG=b:73720175 BRANCH=none TEST=make buildall Change-Id: Iff17573f110e07e88d097dd848cf91ee98b83176 Signed-off-by: Daisuke Nojiri Reviewed-on: https://chromium-review.googlesource.com/949382 Reviewed-by: Vincent Palatin --- board/npcx_evb/board.c | 48 +++++++++++++++++++++++++++++------------------- 1 file changed, 29 insertions(+), 19 deletions(-) (limited to 'board/npcx_evb') diff --git a/board/npcx_evb/board.c b/board/npcx_evb/board.c index 9a185ada2f..d4741fbe31 100644 --- a/board/npcx_evb/board.c +++ b/board/npcx_evb/board.c @@ -55,26 +55,36 @@ BUILD_ASSERT(ARRAY_SIZE(pwm_channels) == PWM_CH_COUNT); /******************************************************************************/ /* Physical fans. These are logically separate from pwm_channels. */ -const struct fan_t fans[] = { - [FAN_CH_0] = { - .flags = FAN_USE_RPM_MODE, - .rpm_min = 1000, - .rpm_start = 1000, - .rpm_max = 5200, - .ch = 0,/* Use MFT id to control fan */ - .pgood_gpio = GPIO_PGOOD_FAN, - .enable_gpio = -1, - }, +const struct fan_conf fan_conf_0 = { + .flags = FAN_USE_RPM_MODE, + .ch = 0, /* Use MFT id to control fan */ + .pgood_gpio = GPIO_PGOOD_FAN, + .enable_gpio = -1, +}; + +const struct fan_conf fan_conf_1 = { + .flags = FAN_USE_RPM_MODE, + .ch = 1, /* Use MFT id to control fan */ + .pgood_gpio = -1, + .enable_gpio = -1, +}; + +const struct fan_rpm fan_rpm_0 = { + .rpm_min = 1000, + .rpm_start = 1000, + .rpm_max = 5200, +}; + +const struct fan_rpm fan_rpm_1 = { + .rpm_min = 1000, + .rpm_start = 1000, + .rpm_max = 4300, +}; + +struct fan_t fans[] = { + [FAN_CH_0] = { .conf = &fan_conf_0, .rpm = &fan_rpm_0, }, #if (CONFIG_FANS == 2) - [FAN_CH_1] = { - .flags = FAN_USE_RPM_MODE, - .rpm_min = 1000, - .rpm_start = 1000, - .rpm_max = 4300, - .ch = 1,/* Use MFT id to control fan */ - .pgood_gpio = -1, - .enable_gpio = -1, - }, + [FAN_CH_1] = { .conf = &fan_conf_1, .rpm = &fan_rpm_1, }, #endif }; BUILD_ASSERT(ARRAY_SIZE(fans) == FAN_CH_COUNT); -- cgit v1.2.1