xref: /OK3568_Linux_fs/kernel/drivers/net/wireless/ath/ath11k/thermal.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* SPDX-License-Identifier: BSD-3-Clause-Clear */
2*4882a593Smuzhiyun /*
3*4882a593Smuzhiyun  * Copyright (c) 2020 The Linux Foundation. All rights reserved.
4*4882a593Smuzhiyun  */
5*4882a593Smuzhiyun 
6*4882a593Smuzhiyun #ifndef _ATH11K_THERMAL_
7*4882a593Smuzhiyun #define _ATH11K_THERMAL_
8*4882a593Smuzhiyun 
9*4882a593Smuzhiyun #define ATH11K_THERMAL_TEMP_LOW_MARK -100
10*4882a593Smuzhiyun #define ATH11K_THERMAL_TEMP_HIGH_MARK 150
11*4882a593Smuzhiyun #define ATH11K_THERMAL_THROTTLE_MAX     100
12*4882a593Smuzhiyun #define ATH11K_THERMAL_DEFAULT_DUTY_CYCLE 100
13*4882a593Smuzhiyun #define ATH11K_HWMON_NAME_LEN           15
14*4882a593Smuzhiyun #define ATH11K_THERMAL_SYNC_TIMEOUT_HZ (5 * HZ)
15*4882a593Smuzhiyun 
16*4882a593Smuzhiyun struct ath11k_thermal {
17*4882a593Smuzhiyun 	struct thermal_cooling_device *cdev;
18*4882a593Smuzhiyun 	struct completion wmi_sync;
19*4882a593Smuzhiyun 
20*4882a593Smuzhiyun 	/* protected by conf_mutex */
21*4882a593Smuzhiyun 	u32 throttle_state;
22*4882a593Smuzhiyun 	/* temperature value in Celcius degree
23*4882a593Smuzhiyun 	 * protected by data_lock
24*4882a593Smuzhiyun 	 */
25*4882a593Smuzhiyun 	int temperature;
26*4882a593Smuzhiyun };
27*4882a593Smuzhiyun 
28*4882a593Smuzhiyun #if IS_REACHABLE(CONFIG_THERMAL)
29*4882a593Smuzhiyun int ath11k_thermal_register(struct ath11k_base *sc);
30*4882a593Smuzhiyun void ath11k_thermal_unregister(struct ath11k_base *sc);
31*4882a593Smuzhiyun int ath11k_thermal_set_throttling(struct ath11k *ar, u32 throttle_state);
32*4882a593Smuzhiyun void ath11k_thermal_event_temperature(struct ath11k *ar, int temperature);
33*4882a593Smuzhiyun #else
ath11k_thermal_register(struct ath11k_base * sc)34*4882a593Smuzhiyun static inline int ath11k_thermal_register(struct ath11k_base *sc)
35*4882a593Smuzhiyun {
36*4882a593Smuzhiyun 	return 0;
37*4882a593Smuzhiyun }
38*4882a593Smuzhiyun 
ath11k_thermal_unregister(struct ath11k_base * sc)39*4882a593Smuzhiyun static inline void ath11k_thermal_unregister(struct ath11k_base *sc)
40*4882a593Smuzhiyun {
41*4882a593Smuzhiyun }
42*4882a593Smuzhiyun 
ath11k_thermal_set_throttling(struct ath11k * ar,u32 throttle_state)43*4882a593Smuzhiyun static inline int ath11k_thermal_set_throttling(struct ath11k *ar, u32 throttle_state)
44*4882a593Smuzhiyun {
45*4882a593Smuzhiyun 	return 0;
46*4882a593Smuzhiyun }
47*4882a593Smuzhiyun 
ath11k_thermal_event_temperature(struct ath11k * ar,int temperature)48*4882a593Smuzhiyun static inline void ath11k_thermal_event_temperature(struct ath11k *ar,
49*4882a593Smuzhiyun 						    int temperature)
50*4882a593Smuzhiyun {
51*4882a593Smuzhiyun }
52*4882a593Smuzhiyun 
53*4882a593Smuzhiyun #endif
54*4882a593Smuzhiyun #endif /* _ATH11K_THERMAL_ */
55