2 * Copyright (c) 2015, The Linux Foundation. All rights reserved.
4 * This software is licensed under the terms of the GNU General Public
5 * License version 2, as published by the Free Software Foundation, and
6 * may be copied, distributed, and modified under those terms.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 #ifndef __QCOM_TSENS_H__
14 #define __QCOM_TSENS_H__
16 #define ONE_PT_CALIB 0x1
17 #define ONE_PT_CALIB2 0x2
18 #define TWO_PT_CALIB 0x3
20 #include <linux/thermal.h>
25 struct tsens_device
*tmdev
;
26 struct thermal_zone_device
*tzd
;
35 * struct tsens_ops - operations as supported by the tsens device
36 * @init: Function to initialize the tsens device
37 * @calibrate: Function to calibrate the tsens device
38 * @get_temp: Function which returns the temp in millidegC
39 * @enable: Function to enable (clocks/power) tsens device
40 * @disable: Function to disable the tsens device
41 * @suspend: Function to suspend the tsens device
42 * @resume: Function to resume the tsens device
43 * @get_trend: Function to get the thermal/temp trend
46 /* mandatory callbacks */
47 int (*init
)(struct tsens_device
*);
48 int (*calibrate
)(struct tsens_device
*);
49 int (*get_temp
)(struct tsens_device
*, int, int *);
50 /* optional callbacks */
51 int (*enable
)(struct tsens_device
*, int);
52 void (*disable
)(struct tsens_device
*);
53 int (*suspend
)(struct tsens_device
*);
54 int (*resume
)(struct tsens_device
*);
55 int (*get_trend
)(struct tsens_device
*, int, enum thermal_trend
*);
59 * struct tsens_data - tsens instance specific data
60 * @num_sensors: Max number of sensors supported by platform
61 * @ops: operations the tsens instance supports
62 * @hw_ids: Subset of sensors ids supported by platform, if not the first n
65 const u32 num_sensors
;
66 const struct tsens_ops
*ops
;
70 /* Registers to be saved/restored across a context loss */
71 struct tsens_context
{
80 struct regmap_field
*status_field
;
81 struct tsens_context ctx
;
83 const struct tsens_ops
*ops
;
84 struct tsens_sensor sensor
[0];
87 char *qfprom_read(struct device
*, const char *);
88 void compute_intercept_slope(struct tsens_device
*, u32
*, u32
*, u32
);
89 int init_common(struct tsens_device
*);
90 int get_temp_common(struct tsens_device
*, int, int *);
92 extern const struct tsens_data data_8916
, data_8974
, data_8960
, data_8996
;
94 #endif /* __QCOM_TSENS_H__ */