1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * int340x_thermal_zone.h
4  * Copyright (c) 2015, Intel Corporation.
5  */
6 
7 #ifndef __INT340X_THERMAL_ZONE_H__
8 #define __INT340X_THERMAL_ZONE_H__
9 
10 #include <acpi/acpi_lpat.h>
11 
12 #define INT340X_THERMAL_MAX_ACT_TRIP_COUNT	10
13 
14 struct active_trip {
15 	int temp;
16 	int id;
17 	bool valid;
18 };
19 
20 struct int34x_thermal_zone {
21 	struct acpi_device *adev;
22 	struct active_trip act_trips[INT340X_THERMAL_MAX_ACT_TRIP_COUNT];
23 	unsigned long *aux_trips;
24 	int aux_trip_nr;
25 	int psv_temp;
26 	int psv_trip_id;
27 	int crt_temp;
28 	int crt_trip_id;
29 	int hot_temp;
30 	int hot_trip_id;
31 	struct thermal_zone_device *zone;
32 	struct thermal_zone_device_ops *override_ops;
33 	void *priv_data;
34 	struct acpi_lpat_conversion_table *lpat_table;
35 	struct mutex trip_mutex;
36 };
37 
38 struct int34x_thermal_zone *int340x_thermal_zone_add(struct acpi_device *,
39 				struct thermal_zone_device_ops *override_ops);
40 void int340x_thermal_zone_remove(struct int34x_thermal_zone *);
41 int int340x_thermal_read_trips(struct int34x_thermal_zone *int34x_zone);
42 
int340x_thermal_zone_set_priv_data(struct int34x_thermal_zone * tzone,void * priv_data)43 static inline void int340x_thermal_zone_set_priv_data(
44 			struct int34x_thermal_zone *tzone, void *priv_data)
45 {
46 	tzone->priv_data = priv_data;
47 }
48 
int340x_thermal_zone_get_priv_data(struct int34x_thermal_zone * tzone)49 static inline void *int340x_thermal_zone_get_priv_data(
50 			struct int34x_thermal_zone *tzone)
51 {
52 	return tzone->priv_data;
53 }
54 
int340x_thermal_zone_device_update(struct int34x_thermal_zone * tzone,enum thermal_notify_event event)55 static inline void int340x_thermal_zone_device_update(
56 					struct int34x_thermal_zone *tzone,
57 					enum thermal_notify_event event)
58 {
59 	thermal_zone_device_update(tzone->zone, event);
60 }
61 
62 #endif
63