xref: /aosp_15_r20/external/coreboot/src/soc/samsung/common/include/soc/tmu.h (revision b9411a12aaaa7e1e6a6fb7c5e057f44ee179a49c)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 /* EXYNOS - Thermal Management Unit */
4 
5 #ifndef SOC_SAMSUNG_COMMON_INCLUDE_SOC_TMU_H
6 #define SOC_SAMSUNG_COMMON_INCLUDE_SOC_TMU_H
7 
8 struct tmu_reg {
9 	unsigned int triminfo;
10 	unsigned int rsvd1;
11 	unsigned int rsvd2;
12 	unsigned int rsvd3;
13 	unsigned int rsvd4;
14 	unsigned int triminfo_control;
15 	unsigned int rsvd5;
16 	unsigned int rsvd6;
17 	unsigned int tmu_control;
18 	unsigned int rsvd7;
19 	unsigned int tmu_status;
20 	unsigned int sampling_internal;
21 	unsigned int counter_value0;
22 	unsigned int counter_value1;
23 	unsigned int rsvd8;
24 	unsigned int rsvd9;
25 	unsigned int current_temp;
26 	unsigned int rsvd10;
27 	unsigned int rsvd11;
28 	unsigned int rsvd12;
29 	unsigned int threshold_temp_rise;
30 	unsigned int threshold_temp_fall;
31 	unsigned int rsvd13;
32 	unsigned int rsvd14;
33 	unsigned int past_temp3_0;
34 	unsigned int past_temp7_4;
35 	unsigned int past_temp11_8;
36 	unsigned int past_temp15_12;
37 	unsigned int inten;
38 	unsigned int intstat;
39 	unsigned int intclear;
40 	unsigned int rsvd15;
41 	unsigned int emul_con;
42 };
43 check_member(tmu_reg, emul_con, 0x80);
44 
45 enum tmu_status_t {
46 	TMU_STATUS_INIT = 0,
47 	TMU_STATUS_NORMAL,
48 	TMU_STATUS_WARNING,
49 	TMU_STATUS_TRIPPED,
50 };
51 
52 /* Temperature threshold values for various thermal events */
53 struct temperature_params {
54 	/* minimum value in temperature code range */
55 	unsigned int min_val;
56 	/* maximum value in temperature code range */
57 	unsigned int max_val;
58 	/* temperature threshold to start warning */
59 	unsigned int start_warning;
60 	/* temperature threshold CPU tripping */
61 	unsigned int start_tripping;
62 	/* temperature threshold for HW tripping */
63 	unsigned int hardware_tripping;
64 };
65 
66 /* Pre-defined values and thresholds for calibration of current temperature */
67 struct tmu_data {
68 	/* pre-defined temperature thresholds */
69 	struct temperature_params ts;
70 	/* pre-defined efuse range minimum value */
71 	unsigned int efuse_min_value;
72 	/* pre-defined efuse value for temperature calibration */
73 	unsigned int efuse_value;
74 	/* pre-defined efuse range maximum value */
75 	unsigned int efuse_max_value;
76 	/* current temperature sensing slope */
77 	unsigned int slope;
78 };
79 
80 /* TMU device specific details and status */
81 struct tmu_info {
82 	/* base Address for the TMU */
83 	unsigned int tmu_base;
84 	/* mux Address for the TMU */
85 	int tmu_mux;
86 	/* pre-defined values for calibration and thresholds */
87 	struct tmu_data data;
88 	/* value required for triminfo_25 calibration */
89 	unsigned int te1;
90 	/* value required for triminfo_85 calibration */
91 	unsigned int te2;
92 	/* TMU DC value for threshold calculation */
93 	int dc_value;
94 	/* enum value indicating status of the TMU */
95 	int tmu_state;
96 };
97 
98 extern struct tmu_info *tmu_info;
99 
100 /*
101  * Monitors status of the TMU device and exynos temperature
102  *
103  * @info	pointer to TMU info struct
104  * @temp	pointer to the current temperature value
105  * @return	enum tmu_status_t value, code indicating event to execute
106  *		and -1 on error
107  */
108 enum tmu_status_t tmu_monitor(struct tmu_info *info, int *temp);
109 
110 /*
111  * Initialize TMU device
112  *
113  * @info	pointer to TMU info struct
114  * @return	int value, 0 for success
115  */
116 int tmu_init(struct tmu_info *info);
117 
118 #endif	/* SOC_SAMSUNG_COMMON_INCLUDE_SOC_TMU_H */
119