2 * Copyright (c) 2011-2015, The Linux Foundation. All rights reserved.
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.
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.
14 * Qualcomm TSENS Header file
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
32 #if defined(CONFIG_THERMAL_TSENS8974)
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.
39 int tsens_is_ready(void);
41 * tsens_tm_init_driver() - Early initialization for clients to read
44 int __init tsens_tm_init_driver(void);
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
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.
58 int tsens_get_hw_id_mapping(int sensor_sw_id, int *sensor_hw_num);
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.
65 int tsens_get_max_sensor_num(uint32_t *tsens_num_sensors);
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.
72 * @th1_enable : Value corresponding to the threshold level.
73 * @th2_enable : Value corresponding to the threshold level.
75 int tsens_set_mtc_zone_sw_mask(unsigned int zone , unsigned int th1_enable,
76 unsigned int th2_enable);
78 * tsens_get_mtc_zone_log() - Get the log of last 6 commands sent to pulse
79 * swallower of a zone.
81 * @zone_log: Log commands result to be stored.
83 int tsens_get_mtc_zone_log(unsigned int zone , void *zone_log);
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.
91 int tsens_mtc_reset_history_counter(unsigned int zone);
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
98 * @zone_hist: Commands history result to be stored.
100 int tsens_get_mtc_zone_history(unsigned int zone , void *zone_hist);
102 * tsens_get_temp() - Obtain the TSENS temperature for the respective sensor.
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.
113 int tsens_get_temp(struct tsens_device *dev, int *temp);
115 static inline int tsens_is_ready(void)
117 static inline int __init tsens_tm_init_driver(void)
119 static inline int tsens_get_hw_id_mapping(
120 int sensor_sw_id, int *sensor_hw_num)
122 static inline int tsens_get_max_sensor_num(uint32_t *tsens_num_sensors)
124 static inline int tsens_set_mtc_zone_sw_mask(unsigned int zone ,
125 unsigned int th1_enable ,
126 unsigned int th2_enable)
128 static inline int tsens_get_mtc_zone_log(unsigned int zone , void *zone_log)
130 static inline int tsens_mtc_reset_history_counter(unsigned int zone)
132 static inline int tsens_get_temp(struct tsens_device *dev,
135 static inline int tsens_get_mtc_zone_history(unsigned int zone, void *zone_hist)
139 #endif /*MSM_TSENS_H */