summaryrefslogtreecommitdiff
path: root/board/goroh
diff options
context:
space:
mode:
authorEric Yilun Lin <yllin@chromium.org>2021-08-19 11:50:52 +0800
committerCommit Bot <commit-bot@chromium.org>2021-11-17 09:16:29 +0000
commit662b7f2a520be365c85dad67cba072f138bc6613 (patch)
tree150787b8b5de672a900f6e2bc490265129e09cef /board/goroh
parent2dec0f631c832c67f876764772492f6dc8b29dfa (diff)
downloadchrome-ec-662b7f2a520be365c85dad67cba072f138bc6613.tar.gz
goroh: enable fan
Goroh has a fan and it has TACH pin for RPM info. BUG=b:185846337 TEST=Fan is up in S0 and down in off state BRANCH=main Change-Id: I91f9f2472bec49f60c0b713e9624417254baf420 Signed-off-by: Eric Yilun Lin <yllin@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3105908 Reviewed-by: Rong Chang <rongchang@chromium.org> Reviewed-by: Ting Shen <phoenixshen@chromium.org> Commit-Queue: Eric Yilun Lin <yllin@google.com> Tested-by: Eric Yilun Lin <yllin@google.com>
Diffstat (limited to 'board/goroh')
-rw-r--r--board/goroh/board.c23
-rw-r--r--board/goroh/board.h5
-rw-r--r--board/goroh/build.mk1
-rw-r--r--board/goroh/fans.c91
-rw-r--r--board/goroh/gpio.inc2
5 files changed, 105 insertions, 17 deletions
diff --git a/board/goroh/board.c b/board/goroh/board.c
index b6ffb3e8de..49df29c490 100644
--- a/board/goroh/board.c
+++ b/board/goroh/board.c
@@ -62,37 +62,28 @@ const struct adc_t adc_channels[] = {
};
BUILD_ASSERT(ARRAY_SIZE(adc_channels) == ADC_CH_COUNT);
-/* PWM */
-
-/*
- * PWM channels. Must be in the exactly same order as in enum pwm_channel.
- * There total three 16 bits clock prescaler registers for all pwm channels,
- * so use the same frequency and prescaler register setting is required if
- * number of pwm channel greater than three.
- *
- * TODO(yllin): configure PWM
- */
+/* PWM channels. */
const struct pwm_t pwm_channels[] = {
[PWM_CH_LED1] = {
- .channel = 0,
+ .channel = PWM_HW_CH_DCR0,
.flags = PWM_CONFIG_DSLEEP | PWM_CONFIG_ACTIVE_LOW,
.freq_hz = 324, /* maximum supported frequency */
.pcfsr_sel = PWM_PRESCALER_C4
},
[PWM_CH_LED2] = {
- .channel = 1,
+ .channel = PWM_HW_CH_DCR1,
.flags = PWM_CONFIG_DSLEEP | PWM_CONFIG_ACTIVE_LOW,
.freq_hz = 324, /* maximum supported frequency */
.pcfsr_sel = PWM_PRESCALER_C4
},
[PWM_CH_FAN] = {
- .channel = 2,
- .flags = PWM_CONFIG_DSLEEP | PWM_CONFIG_ACTIVE_LOW,
- .freq_hz = 324, /* maximum supported frequency */
+ .channel = PWM_HW_CH_DCR2,
+ .flags = PWM_CONFIG_OPEN_DRAIN,
+ .freq_hz = 25000, /* maximum supported frequency */
.pcfsr_sel = PWM_PRESCALER_C4
},
[PWM_CH_KB_BL] = {
- .channel = 3,
+ .channel = PWM_HW_CH_DCR3,
.flags = PWM_CONFIG_DSLEEP | PWM_CONFIG_ACTIVE_LOW,
.freq_hz = 324, /* maximum supported frequency */
.pcfsr_sel = PWM_PRESCALER_C4
diff --git a/board/goroh/board.h b/board/goroh/board.h
index ac96d34141..7ce1b55738 100644
--- a/board/goroh/board.h
+++ b/board/goroh/board.h
@@ -106,5 +106,10 @@ enum pwm_channel {
PWM_CH_COUNT,
};
+enum fan_channel {
+ FAN_CH_0,
+ FAN_CH_COUNT
+};
+
#endif /* !__ASSEMBLER__ */
#endif /* __CROS_EC_BOARD_H */
diff --git a/board/goroh/build.mk b/board/goroh/build.mk
index 3a33f14b2e..4bc0561678 100644
--- a/board/goroh/build.mk
+++ b/board/goroh/build.mk
@@ -13,5 +13,6 @@ BASEBOARD:=goroh
board-y+=battery.o
board-y+=board.o
+board-y+=fans.o
board-y+=led.o
board-y+=sensors.o
diff --git a/board/goroh/fans.c b/board/goroh/fans.c
new file mode 100644
index 0000000000..415eb9681d
--- /dev/null
+++ b/board/goroh/fans.c
@@ -0,0 +1,91 @@
+/* Copyright 2021 The Chromium OS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/* Physical fans. These are logically separate from pwm_channels. */
+
+#include "common.h"
+#include "compile_time_macros.h"
+#include "console.h"
+#include "fan.h"
+#include "hooks.h"
+#include "pwm.h"
+#include "pwm_chip.h"
+
+const struct fan_conf fan_conf_0 = {
+ .flags = FAN_USE_RPM_MODE,
+ .ch = PWM_CH_FAN,
+ .pgood_gpio = -1,
+ .enable_gpio = GPIO_EN_PP5000_FAN_X,
+};
+
+const struct fan_rpm fan_rpm_0 = {
+ .rpm_min = 2400,
+ .rpm_start = 2400,
+ .rpm_max = 5700,
+};
+
+const struct fan_t fans[] = {
+ [FAN_CH_0] = {
+ .conf = &fan_conf_0,
+ .rpm = &fan_rpm_0,
+ },
+};
+BUILD_ASSERT(ARRAY_SIZE(fans) == CONFIG_FANS);
+/*
+ * PWM HW channelx binding tachometer channelx for fan control.
+ * Four tachometer input pins but two tachometer modules only,
+ * so always binding [TACH_CH_TACH0A | TACH_CH_TACH0B] and/or
+ * [TACH_CH_TACH1A | TACH_CH_TACH1B]
+ */
+const struct fan_tach_t fan_tach[] = {
+ [PWM_HW_CH_DCR0] = {
+ .ch_tach = TACH_CH_NULL,
+ .fan_p = -1,
+ .rpm_re = -1,
+ .s_duty = -1,
+ },
+ [PWM_HW_CH_DCR1] = {
+ .ch_tach = TACH_CH_NULL,
+ .fan_p = -1,
+ .rpm_re = -1,
+ .s_duty = -1,
+ },
+ [PWM_HW_CH_DCR2] = {
+ .ch_tach = TACH_CH_TACH0A,
+ .fan_p = 2,
+ .rpm_re = 50,
+ .s_duty = 30,
+ },
+ [PWM_HW_CH_DCR3] = {
+ .ch_tach = TACH_CH_NULL,
+ .fan_p = -1,
+ .rpm_re = -1,
+ .s_duty = -1,
+ },
+ [PWM_HW_CH_DCR4] = {
+ .ch_tach = TACH_CH_NULL,
+ .fan_p = -1,
+ .rpm_re = -1,
+ .s_duty = -1,
+ },
+ [PWM_HW_CH_DCR5] = {
+ .ch_tach = TACH_CH_NULL,
+ .fan_p = -1,
+ .rpm_re = -1,
+ .s_duty = -1,
+ },
+ [PWM_HW_CH_DCR6] = {
+ .ch_tach = TACH_CH_NULL,
+ .fan_p = -1,
+ .rpm_re = -1,
+ .s_duty = -1,
+ },
+ [PWM_HW_CH_DCR7] = {
+ .ch_tach = TACH_CH_NULL,
+ .fan_p = -1,
+ .rpm_re = -1,
+ .s_duty = -1,
+ },
+};
diff --git a/board/goroh/gpio.inc b/board/goroh/gpio.inc
index c6209f875b..1c7aa77d61 100644
--- a/board/goroh/gpio.inc
+++ b/board/goroh/gpio.inc
@@ -91,7 +91,6 @@ GPIO(USB_C0_SBU2_DC, PIN(H, 5), GPIO_OUT_LOW)
/* Misc Signals */
GPIO(EC_BATT_PRES_ODL, PIN(C, 0), GPIO_INPUT)
GPIO(ENTERING_RW, PIN(C, 5), GPIO_OUT_LOW) /* EC_ENTERING_RW */
-GPIO(FAN_SPEED_TACH_1, PIN(D, 6), GPIO_INPUT)
GPIO(EN_EC_ID_ODL, PIN(C, 3), GPIO_OUT_LOW)
GPIO(EN_PP5000_FAN_X, PIN(E, 3), GPIO_OUT_LOW)
GPIO(EN_PPVAR_KB_BL_X, PIN(H, 3), GPIO_OUT_LOW)
@@ -126,6 +125,7 @@ ALTERNATE(PIN_MASK(B, 0x03), 1, MODULE_UART, 0) /* EC to Servo */
/* PWM */
ALTERNATE(PIN_MASK(A, 0x0F), 1, MODULE_PWM, 0) /* PWM 0~3 */
+ALTERNATE(PIN_MASK(D, 0x40), 3, MODULE_PWM, GPIO_PULL_UP) /* TACH0A for FAN1 */
/* ADC */
ALTERNATE(PIN_MASK(I, 0x6E), 0, MODULE_ADC, 0) /* ADC 1,2,3,5,6 */