blob: 68bf5a035fac49358c21f22f768e2ec1139fcf3b [file] [log] [blame]
Nico Hubere34e1782016-09-29 12:33:01 +02001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2011 The ChromiumOS Authors. All rights reserved.
5 * Copyright (C) 2016 secunet Security Networks AG
Krystian Hebel97445f22019-02-26 11:19:58 +01006 * Copyright (C) 2019 Protectli
Nico Hubere34e1782016-09-29 12:33:01 +02007 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 */
18
19#ifndef SUPERIO_ITE_ENV_CTRL_CHIP_H
20#define SUPERIO_ITE_ENV_CTRL_CHIP_H
21
22#define ITE_EC_TMPIN_CNT 3
Krystian Hebel97445f22019-02-26 11:19:58 +010023
24#if IS_ENABLED(CONFIG_SUPERIO_ITE_ENV_CTRL_5FANS)
25#define ITE_EC_FAN_CNT 5
26#else
Nico Hubere34e1782016-09-29 12:33:01 +020027#define ITE_EC_FAN_CNT 3
Krystian Hebel97445f22019-02-26 11:19:58 +010028#endif
Nico Hubere34e1782016-09-29 12:33:01 +020029
30/* Supported thermal mode on TMPINx */
31enum ite_ec_thermal_mode {
32 THERMAL_MODE_DISABLED = 0,
33 THERMAL_DIODE,
34 THERMAL_RESISTOR,
Vagiz Trakhanov177f7732017-10-17 18:04:55 +000035 THERMAL_PECI,
Nico Hubere34e1782016-09-29 12:33:01 +020036};
37
Vagiz Trakhanov17c57712017-09-28 14:21:54 +000038struct ite_ec_thermal_config {
39 enum ite_ec_thermal_mode mode;
40 /* Offset is used for diode sensors and PECI */
41 u8 offset;
Vagiz Trakhanovcc9c0cb2017-09-28 14:25:59 +000042 /* Limits */
43 u8 min;
44 u8 max;
Vagiz Trakhanov17c57712017-09-28 14:21:54 +000045};
46
Nico Hubere34e1782016-09-29 12:33:01 +020047/* Bit mask for voltage pins VINx */
48enum ite_ec_voltage_pin {
49 VIN0 = 0x01,
50 VIN1 = 0x02,
51 VIN2 = 0x04,
52 VIN3 = 0x08,
53 VIN4 = 0x10,
54 VIN5 = 0x20,
55 VIN6 = 0x40,
56 VIN7 = 0x80,
57 VIN_ALL = 0xff
58};
59
60enum ite_ec_fan_mode {
61 FAN_IGNORE = 0,
62 FAN_MODE_ON,
63 FAN_MODE_OFF,
64 FAN_SMART_SOFTWARE,
65 FAN_SMART_AUTOMATIC,
66};
67
68struct ite_ec_fan_smartconfig {
69 u8 tmpin; /* select TMPINx (1, 2 or 3) */
70 u8 tmp_off; /* turn fan off below (°C) */
71 u8 tmp_start; /* turn fan on above (°C) */
72 u8 tmp_full; /* 100% duty cycle above (°C) */
73 u8 tmp_delta; /* adapt fan speed when temperature
74 changed by at least `tmp_delta`°C */
75 u8 smoothing; /* enable smoothing */
76 u8 pwm_start; /* start at this duty cycle (%) */
77 u8 slope; /* increase duty cycle by `slope`%/°C */
78};
79
80struct ite_ec_fan_config {
81 enum ite_ec_fan_mode mode;
82 struct ite_ec_fan_smartconfig smart;
83};
84
85struct ite_ec_config {
86 /*
Nico Hubere34e1782016-09-29 12:33:01 +020087 * Enable reading of voltage pins VINx.
88 */
89 enum ite_ec_voltage_pin vin_mask;
90
91 /*
Vagiz Trakhanov17c57712017-09-28 14:21:54 +000092 * Enable temperature sensors in given mode.
93 */
94 struct ite_ec_thermal_config tmpin[ITE_EC_TMPIN_CNT];
95
96 /*
Nico Hubere34e1782016-09-29 12:33:01 +020097 * Enable a FAN in given mode.
98 */
99 struct ite_ec_fan_config fan[ITE_EC_FAN_CNT];
Vagiz Trakhanov17c57712017-09-28 14:21:54 +0000100
Vagiz Trakhanov41aa5ec2017-10-23 13:17:44 +0000101 bool tmpin_beep;
102 bool fan_beep;
103 bool vin_beep;
Nico Hubere34e1782016-09-29 12:33:01 +0200104};
105
106/* Some shorthands for device trees */
Vagiz Trakhanov17c57712017-09-28 14:21:54 +0000107#define TMPIN1 ec.tmpin[0]
108#define TMPIN2 ec.tmpin[1]
109#define TMPIN3 ec.tmpin[2]
110
Nico Hubere34e1782016-09-29 12:33:01 +0200111#define FAN1 ec.fan[0]
112#define FAN2 ec.fan[1]
113#define FAN3 ec.fan[2]
Krystian Hebel97445f22019-02-26 11:19:58 +0100114#define FAN4 ec.fan[3]
115#define FAN5 ec.fan[4]
Nico Hubere34e1782016-09-29 12:33:01 +0200116
117#endif /* SUPERIO_ITE_ENV_CTRL_CHIP_H */