1 /*
2  * intel_soc_dts_iosf.h
3  * Copyright (c) 2015, Intel Corporation.
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms and conditions of the GNU General Public License,
7  * version 2, as published by the Free Software Foundation.
8  *
9  * This program is distributed in the hope it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
12  * more details.
13  *
14  */
15 
16 #ifndef _INTEL_SOC_DTS_IOSF_CORE_H
17 #define _INTEL_SOC_DTS_IOSF_CORE_H
18 
19 #include <linux/thermal.h>
20 
21 /* DTS0 and DTS 1 */
22 #define SOC_MAX_DTS_SENSORS	2
23 
24 enum intel_soc_dts_interrupt_type {
25 	INTEL_SOC_DTS_INTERRUPT_NONE,
26 	INTEL_SOC_DTS_INTERRUPT_APIC,
27 	INTEL_SOC_DTS_INTERRUPT_MSI,
28 	INTEL_SOC_DTS_INTERRUPT_SCI,
29 	INTEL_SOC_DTS_INTERRUPT_SMI,
30 };
31 
32 struct intel_soc_dts_sensors;
33 
34 struct intel_soc_dts_sensor_entry {
35 	int id;
36 	u32 temp_mask;
37 	u32 temp_shift;
38 	u32 store_status;
39 	u32 trip_mask;
40 	u32 trip_count;
41 	enum thermal_trip_type trip_types[2];
42 	struct thermal_zone_device *tzone;
43 	struct intel_soc_dts_sensors *sensors;
44 };
45 
46 struct intel_soc_dts_sensors {
47 	u32 tj_max;
48 	spinlock_t intr_notify_lock;
49 	struct mutex dts_update_lock;
50 	enum intel_soc_dts_interrupt_type intr_type;
51 	struct intel_soc_dts_sensor_entry soc_dts[SOC_MAX_DTS_SENSORS];
52 };
53 
54 struct intel_soc_dts_sensors *intel_soc_dts_iosf_init(
55 	enum intel_soc_dts_interrupt_type intr_type, int trip_count,
56 	int read_only_trip_count);
57 void intel_soc_dts_iosf_exit(struct intel_soc_dts_sensors *sensors);
58 void intel_soc_dts_iosf_interrupt_handler(
59 				struct intel_soc_dts_sensors *sensors);
60 int intel_soc_dts_iosf_add_read_only_critical_trip(
61 	struct intel_soc_dts_sensors *sensors, int critical_offset);
62 #endif
63