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
|
/* 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.
*/
#include "common.h"
#include "compile_time_macros.h"
#include "hooks.h"
#include "pwm.h"
#include "pwm_chip.h"
const struct pwm_t pwm_channels[] = {
[PWM_CH_SIDE_LED_R] = {
.channel = 0,
.flags = PWM_CONFIG_DSLEEP,
.freq = 2000,
},
[PWM_CH_SIDE_LED_G] = {
.channel = 1,
.flags = PWM_CONFIG_DSLEEP,
.freq = 2000,
},
[PWM_CH_SIDE_LED_B] = {
.channel = 2,
.flags = PWM_CONFIG_DSLEEP,
.freq = 2000,
},
[PWM_CH_KBLIGHT] = {
.channel = 3,
.flags = 0,
/*
* Set PWM frequency to multiple of 50 Hz and 60 Hz to prevent
* flicker. Higher frequencies consume similar average power to
* lower PWM frequencies, but higher frequencies record a much
* lower maximum power.
*/
.freq = 2400,
},
[PWM_CH_FAN] = {
.channel = 5,
.flags = PWM_CONFIG_OPEN_DRAIN,
.freq = 25000
},
[PWM_CH_POWER_LED_W] = {
.channel = 7,
.flags = PWM_CONFIG_DSLEEP,
.freq = 2000,
},
};
BUILD_ASSERT(ARRAY_SIZE(pwm_channels) == PWM_CH_COUNT);
static void board_pwm_init(void)
{
/*
* Turn off all the LEDs.
* Turn on the fan at 100%.
*/
pwm_enable(PWM_CH_SIDE_LED_R, 1);
pwm_set_duty(PWM_CH_SIDE_LED_R, 0);
pwm_enable(PWM_CH_SIDE_LED_G, 1);
pwm_set_duty(PWM_CH_SIDE_LED_G, 0);
pwm_enable(PWM_CH_SIDE_LED_B, 1);
pwm_set_duty(PWM_CH_SIDE_LED_B, 0);
pwm_set_duty(PWM_CH_POWER_LED_W, 0);
pwm_enable(PWM_CH_POWER_LED_W, 1);
pwm_set_duty(PWM_CH_KBLIGHT, 50);
}
DECLARE_HOOK(HOOK_INIT, board_pwm_init, HOOK_PRIO_DEFAULT);
|