soc/amd/stoneyridge|mb: Add Kconfig symbol for Prairie Falcon
[coreboot.git] / src / mainboard / amd / padmelon / fan_init.c
blob2c3200525d7349e078337ecff87f4dc3524d678b
1 /*
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>
23 #define CPU_FAN 1
24 #define SYSTEM_FAN 2
26 /* Boundaries in celsius, sections in percent */
27 static u8 cpu_boudaries[FINTEK_BOUNDARIES_SIZE] = {
28 80,
29 65,
30 50,
34 static u8 system_boudaries[FINTEK_BOUNDARIES_SIZE] = {
35 70,
36 55,
37 40,
41 static u8 cpu_section[FINTEK_SECTIONS_SIZE] = {
42 100,
43 85,
44 70,
45 55,
49 static u8 system_section[FINTEK_SECTIONS_SIZE] = {
50 100,
51 85,
52 70,
53 55,
57 struct fintek_fan cpu_fan = {
58 CPU_FAN,
59 IGNORE_SENSOR,
60 TEMP_SENSOR_DEFAULT,
61 FAN_TEMP_TSI,
62 FAN_TYPE_PWM_PUSH_PULL,
63 FAN_MODE_DEFAULT,
64 FAN_PWM_FREQ_23500,
65 FAN_UP_RATE_10HZ,
66 FAN_DOWN_RATE_10HZ,
67 FAN_FOLLOW_INTERPOLATION,
68 cpu_boudaries,
69 cpu_section
72 struct fintek_fan system_fan = {
73 SYSTEM_FAN,
74 EXTERNAL_SENSOR2,
75 TEMP_SENSOR_BJT,
76 FAN_TEMP_EXTERNAL_2,
77 FAN_TYPE_DAC_POWER,
78 FAN_MODE_DEFAULT,
79 FAN_PWM_FREQ_23500,
80 FAN_UP_RATE_10HZ,
81 FAN_DOWN_RATE_10HZ,
82 FAN_FOLLOW_INTERPOLATION,
83 system_boudaries,
84 system_section
87 static void init_fan_control(void *unused)
89 u32 temp;
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);
95 set_fan(&cpu_fan);
96 set_fan(&system_fan);
99 BOOT_STATE_INIT_ENTRY(BS_POST_DEVICE, BS_ON_ENTRY, init_fan_control, NULL);