2 * This file is part of the coreboot project.
4 * Copyright (C) 2019 Richard Spiegel <richard.spiegel@silverbackltd.com>
5 * Copyright (C) 2019 Silverback ltd.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 2 of the License.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
17 #include <bootstate.h>
18 #include <superio/fintek/common/fan_control.h>
19 #include <amdblocks/lpc.h>
20 #include <device/pci_ops.h>
21 #include <soc/pci_devs.h>
26 /* Boundaries in celsius, sections in percent */
27 static u8 cpu_boudaries
[FINTEK_BOUNDARIES_SIZE
] = {
34 static u8 system_boudaries
[FINTEK_BOUNDARIES_SIZE
] = {
41 static u8 cpu_section
[FINTEK_SECTIONS_SIZE
] = {
49 static u8 system_section
[FINTEK_SECTIONS_SIZE
] = {
57 struct fintek_fan cpu_fan
= {
62 FAN_TYPE_PWM_PUSH_PULL
,
67 FAN_FOLLOW_INTERPOLATION
,
72 struct fintek_fan system_fan
= {
82 FAN_FOLLOW_INTERPOLATION
,
87 static void init_fan_control(void *unused
)
90 /* Open a LPC IO access to 0x0220-0x0227 */
91 temp
= pci_read_config32(SOC_LPC_DEV
, LPC_IO_PORT_DECODE_ENABLE
);
92 temp
|= DECODE_ENABLE_SERIAL_PORT2
;
93 pci_write_config32(SOC_LPC_DEV
, LPC_IO_PORT_DECODE_ENABLE
, temp
);
99 BOOT_STATE_INIT_ENTRY(BS_POST_DEVICE
, BS_ON_ENTRY
, init_fan_control
, NULL
);