OSDN Git Service

lz4: fix wrong compress buffer size for 64-bits
[sagit-ice-cold/kernel_xiaomi_msm8998.git] / include / linux / msm_tsens.h
1 /*
2  * Copyright (c) 2011-2015, The Linux Foundation. All rights reserved.
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 and
6  * only version 2 as published by the Free Software Foundation.
7  *
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.
12  */
13 /*
14  * Qualcomm TSENS Header file
15  *
16  */
17
18 #ifndef __MSM_TSENS_H
19 #define __MSM_TSENS_H
20
21 #define TSENS_MAX_SENSORS               11
22 #define TSENS_MTC_ZONE_LOG_SIZE         6
23 #define TSENS_NUM_MTC_ZONES_SUPPORT     3
24 #define TSENS_ZONEMASK_PARAMS           3
25 #define TSENS_ZONELOG_PARAMS            1
26 #define TSENS_MTC_ZONE_HISTORY_SIZE     3
27
28 struct tsens_device {
29         uint32_t                        sensor_num;
30 };
31
32 #if defined(CONFIG_THERMAL_TSENS8974)
33 /**
34  * tsens_is_ready() - Clients can use this API to check if the TSENS device
35  *              is ready and clients can start requesting temperature reads.
36  * @return:     Returns true if device is ready else returns -EPROBE_DEFER
37  *              for clients to check back after a time duration.
38  */
39 int tsens_is_ready(void);
40 /**
41  * tsens_tm_init_driver() - Early initialization for clients to read
42  *              TSENS temperature.
43  */
44 int __init tsens_tm_init_driver(void);
45 /**
46  * tsens_get_hw_id_mapping() - Mapping software or sensor ID with the physical
47  *              TSENS sensor. On certain cases where there are more number of
48  *              controllers the sensor ID is used to map the clients software ID
49  *              with the physical HW sensors used by the driver.
50  * @sensors_sw_id:      Client ID.
51  * @sensor_hw_num:      Sensor client ID passed by the driver. This ID is used
52  *                      by the driver to map it to the physical HW sensor
53  *                      number.
54  * @return:     If the device is not present returns -EPROBE_DEFER
55  *              for clients to check back after a time duration.
56  *              0 on success else error code on error.
57  */
58 int tsens_get_hw_id_mapping(int sensor_sw_id, int *sensor_hw_num);
59 /**
60  * tsens_get_max_sensor_num() - Get the total number of active TSENS sensors.
61  *              The total number received by the client is across multiple
62  *              TSENS controllers if present.
63  * @tsens_num_sensors: Total number of sensor result to be stored.
64  */
65 int tsens_get_max_sensor_num(uint32_t *tsens_num_sensors);
66 /**
67  * tsens_set_mtc_zone_sw_mask() - Mask the MTC threshold level of a zone.
68  *              SW can force the MTC to stop issuing throttling commands that
69  *              correspond to each MTC threshold level by writing the
70  *              corresponding bit in register at any time.
71  * @zone: Zone ID.
72  * @th1_enable : Value corresponding to the threshold level.
73  * @th2_enable : Value corresponding to the threshold level.
74  */
75 int tsens_set_mtc_zone_sw_mask(unsigned int zone , unsigned int th1_enable,
76                                 unsigned int th2_enable);
77 /**
78  * tsens_get_mtc_zone_log() - Get the log of last 6 commands sent to pulse
79  *              swallower of a zone.
80  * zone: Zone ID
81  * @zone_log: Log commands result to be stored.
82  */
83 int tsens_get_mtc_zone_log(unsigned int zone , void *zone_log);
84 /**
85  * tsens_mtc_reset_history_counter() - Reset history of throttling commands
86  *              sent to pulse swallower. Tsens controller issues clock
87  *              throttling commands to Pulse swallower to perform HW
88  *              based clock throttling. Reset the history counter of a zone.
89  * @zone: Zone ID.
90  */
91 int tsens_mtc_reset_history_counter(unsigned int zone);
92 /**
93  * tsens_get_mtc_zone_history() - Get the history of throttling commands sent
94  *              to pulse swallower. Tsens controller issues clock throttling
95  *              commands to Pulse swallower to perform HW based clock
96  *              throttling.
97  * @zone: Zone ID
98  * @zone_hist: Commands history result to be stored.
99  */
100 int tsens_get_mtc_zone_history(unsigned int zone , void *zone_hist);
101 /**
102  * tsens_get_temp() - Obtain the TSENS temperature for the respective sensor.
103  *
104  * @dev:        Sensor number for which client wants the TSENS temperature
105  *              reading. The ID passed by the sensor could be the sensor ID
106  *              which the driver translates to internally to read the
107  *              respective physical HW sensor from the controller.
108  * @temp:       temperature result to be stored.
109  * @return:     If the device is not present returns -EPROBE_DEFER
110  *              for clients to check back after a time duration.
111  *              0 on success else error code on error.
112  */
113 int tsens_get_temp(struct tsens_device *dev, int *temp);
114 #else
115 static inline int tsens_is_ready(void)
116 { return -ENXIO; }
117 static inline int __init tsens_tm_init_driver(void)
118 { return -ENXIO; }
119 static inline int tsens_get_hw_id_mapping(
120                                 int sensor_sw_id, int *sensor_hw_num)
121 { return -ENXIO; }
122 static inline int tsens_get_max_sensor_num(uint32_t *tsens_num_sensors)
123 { return -ENXIO; }
124 static inline int tsens_set_mtc_zone_sw_mask(unsigned int zone ,
125                                 unsigned int th1_enable ,
126                                 unsigned int th2_enable)
127 { return -ENXIO; }
128 static inline int tsens_get_mtc_zone_log(unsigned int zone , void *zone_log)
129 { return -ENXIO; }
130 static inline int tsens_mtc_reset_history_counter(unsigned int zone)
131 { return -ENXIO; }
132 static inline int tsens_get_temp(struct tsens_device *dev,
133                                                 int *temp)
134 { return -ENXIO; }
135 static inline int tsens_get_mtc_zone_history(unsigned int zone, void *zone_hist)
136 { return -ENXIO; }
137 #endif
138
139 #endif /*MSM_TSENS_H */