1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 * tmon.h contains data structures and constants used by TMON
5 * Copyright (C) 2012 Intel Corporation. All rights reserved.
7 * Author Name Jacob Pan <jacob.jun.pan@linux.intel.com>
13 #define MAX_DISP_TEMP 125
14 #define MAX_CTRL_TEMP 105
15 #define MIN_CTRL_TEMP 40
16 #define MAX_NR_TZONE 16
17 #define MAX_NR_CDEV 32
18 #define MAX_NR_TRIP 16
19 #define MAX_NR_CDEV_TRIP 12 /* number of cooling devices that can bind
20 * to a thermal zone trip.
22 #define MAX_TEMP_KC 140000
23 /* starting char position to draw sensor data, such as tz names
24 * trip point list, etc.
26 #define DATA_LEFT_ALIGN 10
27 #define NR_LINES_TZDATA 1
28 #define TMON_LOG_FILE "/var/tmp/tmon.log"
33 extern unsigned long ticktime
;
34 extern double time_elapsed
;
35 extern unsigned long target_temp_user
;
36 extern int dialogue_on
;
37 extern char ctrl_cdev
[];
38 extern pthread_mutex_t input_lock
;
40 extern int target_thermal_zone
;
41 /* use fixed size record to simplify data processing and transfer
42 * TBD: more info to be added, e.g. programmable trip point data.
44 struct thermal_data_record
{
46 unsigned long temp
[MAX_NR_TZONE
];
53 unsigned long max_state
;
54 unsigned long cur_state
;
59 THERMAL_TRIP_CRITICAL
,
69 unsigned long hysteresis
;
70 int attribute
; /* programmability etc. */
73 /* thermal zone configuration information, binding with cooling devices could
77 char type
[256]; /* e.g. acpitz */
79 int passive
; /* active zone has passive node to force passive mode */
80 int nr_cdev
; /* number of cooling device binded */
82 struct trip_point tp
[MAX_NR_TRIP
];
83 unsigned long cdev_binding
; /* bitmap for attached cdevs */
84 /* cdev bind trip points, allow one cdev bind to multiple trips */
85 unsigned long trip_binding
[MAX_NR_CDEV
];
88 struct tmon_platform_data
{
91 /* keep track of instance ids since there might be gaps */
93 int max_cdev_instance
;
95 struct cdev_info
*cdi
;
99 void (*set_ratio
)(unsigned long ratio
);
100 unsigned long (*get_ratio
)(unsigned long ratio
);
111 /* REVISIT: the idea is to group sensors if possible, e.g. on intel mid
112 * we have "skin0", "skin1", "sys", "msicdie"
113 * on DPTF enabled systems, we might have PCH, TSKN, TAMB, etc.
121 /* limit the output of PID controller adjustment */
122 #define LIMIT_HIGH (95)
123 #define LIMIT_LOW (2)
126 double kp
; /* Controller gain from Dialog Box */
127 double ki
; /* Time-constant for I action from Dialog Box */
128 double kd
; /* Time-constant for D action from Dialog Box */
136 extern int init_thermal_controller(void);
137 extern void controller_handler(const double xk
, double *yk
);
139 extern struct tmon_platform_data ptdata
;
140 extern struct pid_params p_param
;
142 extern FILE *tmon_log
;
143 extern int cur_thermal_record
; /* index to the trec array */
144 extern struct thermal_data_record trec
[];
145 extern const char *trip_type_name
[];
146 extern unsigned long no_control
;
148 extern void initialize_curses(void);
149 extern void show_controller_stats(char *line
);
150 extern void show_title_bar(void);
151 extern void setup_windows(void);
152 extern void disable_tui(void);
153 extern void show_sensors_w(void);
154 extern void show_data_w(void);
155 extern void write_status_bar(int x
, char *line
);
156 extern void show_control_w();
158 extern void show_cooling_device(void);
159 extern void show_dialogue(void);
160 extern int update_thermal_data(void);
162 extern int probe_thermal_sysfs(void);
163 extern void free_thermal_data(void);
164 extern void resize_handler(int sig
);
165 extern void set_ctrl_state(unsigned long state
);
166 extern void get_ctrl_state(unsigned long *state
);
167 extern void *handle_tui_events(void *arg
);
168 extern int sysfs_set_ulong(char *path
, char *filename
, unsigned long val
);
169 extern int zone_instance_to_index(int zone_inst
);
170 extern void close_windows(void);
172 #define PT_COLOR_DEFAULT 1
173 #define PT_COLOR_HEADER_BAR 2
174 #define PT_COLOR_ERROR 3
175 #define PT_COLOR_RED 4
176 #define PT_COLOR_YELLOW 5
177 #define PT_COLOR_GREEN 6
178 #define PT_COLOR_BRIGHT 7
179 #define PT_COLOR_BLUE 8
181 /* each thermal zone uses 12 chars, 8 for name, 2 for instance, 2 space
182 * also used to list trip points in forms of AAAC, which represents
186 #define TZONE_RECORD_SIZE 12
187 #define TZ_LEFT_ALIGN 32
188 #define CDEV_NAME_SIZE 20
189 #define CDEV_FLAG_IN_CONTROL (1 << 0)
191 /* dialogue box starts */
194 #define THERMAL_SYSFS "/sys/class/thermal"
195 #define CDEV "cooling_device"
196 #define TZONE "thermal_zone"
197 #define TDATA_LEFT 16