summaryrefslogtreecommitdiff
path: root/src/superio/ite/common/env_ctrl_chip.h
blob: 6d716bb8459523c1ef63034f44437a6518972205 (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
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
/* SPDX-License-Identifier: GPL-2.0-or-later */

#ifndef SUPERIO_ITE_ENV_CTRL_CHIP_H
#define SUPERIO_ITE_ENV_CTRL_CHIP_H

#define ITE_EC_TMPIN_CNT	3

#if CONFIG(SUPERIO_ITE_ENV_CTRL_5FANS)
#define ITE_EC_FAN_CNT		5
#else
#define ITE_EC_FAN_CNT		3
#endif

#define ITE_EC_FAN_VECTOR_CNT	2 /* A, B */

/* Supported thermal mode on TMPINx */
enum ite_ec_thermal_mode {
	THERMAL_MODE_DISABLED = 0,
	THERMAL_DIODE,
	THERMAL_RESISTOR,
	THERMAL_PECI,
};

struct ite_ec_thermal_config {
	enum ite_ec_thermal_mode mode;
	/* Offset is used for diode sensors and PECI */
	u8 offset;
	/* Limits */
	u8 min;
	u8 max;
};

/* Bit mask for voltage pins VINx */
enum ite_ec_voltage_pin {
	VIN0 = 0x01,
	VIN1 = 0x02,
	VIN2 = 0x04,
	VIN3 = 0x08,
	VIN4 = 0x10,
	VIN5 = 0x20,
	VIN6 = 0x40,
	VIN7 = 0x80,
	VIN_ALL = 0xff
};

enum ite_ec_fan_mode {
	FAN_IGNORE = 0,
	FAN_MODE_ON,
	FAN_MODE_OFF,
	FAN_SMART_SOFTWARE,
	FAN_SMART_AUTOMATIC,
};

struct ite_ec_fan_smartconfig {
	u8 tmpin;	/* select TMPINx (1, 2 or 3)			*/
	u8 tmp_off;	/* turn fan off below (°C)			*/
	u8 tmp_start;	/* turn fan on above (°C)			*/
	u8 tmp_full;	/* 100% duty cycle above (°C)			*/
	u8 tmp_delta;	/* adapt fan speed when temperature changed by
			   at least `tmp_delta`°C			*/
	u8 full_lmt;	/* force fan to full PWM at thermal limit	*/
	u8 smoothing;	/* enable smoothing				*/
	u8 pwm_start;	/* start at this duty cycle (%)			*/
	u8 slope;	/* increase duty cycle by `slope`%/°C		*/
	u8 clsd_loop;	/* tachometer closed-loop mode enable		*/
	u16 rpm_start;	/* start at this RPM (clsd_loop = 1)		*/
};

struct ite_ec_fan_config {
	enum ite_ec_fan_mode mode;
	struct ite_ec_fan_smartconfig smart;
};

/* Special fan control modes that will assist smart control */
struct ite_ec_fan_vector_config {
	u8 tmpin;	/* select TMPINx (1, 2 or 3)			*/
	u8 fanout;	/* select FANx (1, 2 or 3)			*/
	u8 tmp_start;
	u8 tmp_delta;
	u8 tmp_range;	/* restrict the range of the vector function,
			   0x00 to disable				*/
	s8 slope;
};

struct ite_ec_config {
	/*
	 * Enable reading of voltage pins VINx.
	 */
	enum ite_ec_voltage_pin vin_mask;

	/*
	 * Enable temperature sensors in given mode.
	 */
	struct ite_ec_thermal_config tmpin[ITE_EC_TMPIN_CNT];

	/*
	 * Enable a FAN in given mode.
	 */
	struct ite_ec_fan_config fan[ITE_EC_FAN_CNT];

	/*
	 * Enable special FAN vector control.
	 */
	struct ite_ec_fan_vector_config fan_vector[ITE_EC_FAN_VECTOR_CNT];

	bool tmpin_beep;
	bool fan_beep;
	bool vin_beep;

	/*
	 * Enable SMBus for external thermal sensor.
	 */
	bool smbus_en;
	/*
	 * Select 24 MHz clock for external host instead of an
	 * internally generated 32 MHz clock.
	 */
	bool smbus_24mhz;
};

/* Some shorthands for device trees */
#define TMPIN1	ec.tmpin[0]
#define TMPIN2	ec.tmpin[1]
#define TMPIN3	ec.tmpin[2]

#define FAN1	ec.fan[0]
#define FAN2	ec.fan[1]
#define FAN3	ec.fan[2]
#define FAN4	ec.fan[3]
#define FAN5	ec.fan[4]

#define FAN_VECA ec.fan_vector[0]
#define FAN_VECB ec.fan_vector[1]

#endif /* SUPERIO_ITE_ENV_CTRL_CHIP_H */