1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
/* Copyright 2022 The ChromiumOS Authors
* 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_chip.h"
#include "fan.h"
#include "hooks.h"
#include "pwm.h"
/* MFT channels. These are logically separate from pwm_channels. */
const struct mft_t mft_channels[] = {
[MFT_CH_0] = {
.module = NPCX_MFT_MODULE_1,
.clk_src = TCKC_LFCLK,
.pwm_id = PWM_CH_FAN,
},
};
BUILD_ASSERT(ARRAY_SIZE(mft_channels) == MFT_CH_COUNT);
static const struct fan_conf fan_conf_0 = {
.flags = FAN_USE_RPM_MODE,
.ch = MFT_CH_0, /* Use MFT id to control fan */
.pgood_gpio = -1,
.enable_gpio = GPIO_EN_PP5000_FAN,
};
static const struct fan_rpm fan_rpm_0 = {
.rpm_min = 1100,
.rpm_start = 2000,
.rpm_max = 5000,
};
const struct fan_t fans[FAN_CH_COUNT] = {
[FAN_CH_0] = {
.conf = &fan_conf_0,
.rpm = &fan_rpm_0,
},
};
#ifndef CONFIG_FANS
/*
* TODO(b/181271666): use static fan speeds until fan and sensors are
* tuned. for now, use:
*
* AP off: 33%
* AP on: 100%
*/
static void fan_slow(void)
{
const int duty_pct = 33;
ccprints("%s: speed %d%%", __func__, duty_pct);
pwm_enable(PWM_CH_FAN, 1);
pwm_set_duty(PWM_CH_FAN, duty_pct);
}
static void fan_max(void)
{
const int duty_pct = 100;
ccprints("%s: speed %d%%", __func__, duty_pct);
pwm_enable(PWM_CH_FAN, 1);
pwm_set_duty(PWM_CH_FAN, duty_pct);
}
DECLARE_HOOK(HOOK_INIT, fan_slow, HOOK_PRIO_DEFAULT);
DECLARE_HOOK(HOOK_CHIPSET_SUSPEND, fan_slow, HOOK_PRIO_DEFAULT);
DECLARE_HOOK(HOOK_CHIPSET_SHUTDOWN, fan_slow, HOOK_PRIO_DEFAULT);
DECLARE_HOOK(HOOK_CHIPSET_RESET, fan_max, HOOK_PRIO_FIRST);
DECLARE_HOOK(HOOK_CHIPSET_RESUME, fan_max, HOOK_PRIO_DEFAULT);
#endif /* CONFIG_FANS */
|