blob: 6d234b2fc35f0dbff905a054cb91760e574e361d (
plain)
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
|
/* 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 <zephyr/devicetree.h>
#include <zephyr/drivers/gpio.h>
#include <zephyr/logging/log.h>
#include "cros_cbi.h"
#include "fan.h"
#include "gpio/gpio.h"
#include "hooks.h"
#include "nissa_common.h"
LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL);
/*
* Joxer fan support
*/
static void fan_init(void)
{
int ret;
uint32_t val;
/*
* Retrieve the fan config.
*/
ret = cros_cbi_get_fw_config(FW_FAN, &val);
if (ret != 0) {
LOG_ERR("Error retrieving CBI FW_CONFIG field %d", FW_FAN);
return;
}
if (val != FW_FAN_PRESENT) {
/* Disable the fan */
fan_set_count(0);
} else {
/* Configure the fan enable GPIO */
gpio_pin_configure_dt(GPIO_DT_FROM_NODELABEL(gpio_fan_enable),
GPIO_OUTPUT);
}
}
DECLARE_HOOK(HOOK_INIT, fan_init, HOOK_PRIO_POST_FIRST);
|