thermal: tsens: Enable TSENS

This snapshot is taken as of msm-3.18 commit dbdb6776f
(Merge "msm: camera: Add dummy sub module in sensor pipeline")

Commit 0b46b8a7 (clocksource: arch_timer: Fix code to use
physical timers when requested) introduces the use of
physical counters and requires clients to use api
arch_counter_get_cntvct(). Accordingly update tsens_poll()
to the new API to prevent a BUG_ON() during bootup.

Fixup TSENS to use supported int type for temperature value.

Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
This commit is contained in:
Siddartha Mohanadoss 2016-02-17 12:41:47 -08:00 committed by David Keitel
parent 31d2a03e6e
commit 2021d15137
4 changed files with 2283 additions and 290 deletions

View file

@ -20,6 +20,15 @@ Required properties:
should be "qcom,msm8994-tsens" for 8994 TSENS driver. should be "qcom,msm8994-tsens" for 8994 TSENS driver.
should be "qcom,msm8996-tsens" for 8996 TSENS driver. should be "qcom,msm8996-tsens" for 8996 TSENS driver.
should be "qcom,msm8992-tsens" for 8992 TSENS driver. should be "qcom,msm8992-tsens" for 8992 TSENS driver.
should be "qcom,msm8916-tsens" for 8916 TSENS driver.
should be "qcom,msm8939-tsens" for 8939 TSENS driver.
should be "qcom,msm8909-tsens" for 8909 TSENS driver.
should be "qcom,msm8952-tsens" for 8952 TSENS driver.
should be "qcom,msmzirc-tsens" for zirc TSENS driver.
should be "qcom,mdm9607-tsens" for 9607 TSENS driver.
should be "qcom,msmtitanium-tsens" for titanium TSENS driver.
should be "qcom,msm8937-tsens" for 8937 TSENS driver.
should be "qcom,msmgold-tsens" for gold TSENS driver.
The compatible property is used to identify the respective fusemap to use The compatible property is used to identify the respective fusemap to use
for the corresponding SoC. for the corresponding SoC.
- reg : offset and length of the TSENS registers. - reg : offset and length of the TSENS registers.
@ -54,6 +63,19 @@ Optional properties:
- qcom,sensor-id : If the flag is present map the TSENS sensors based on the - qcom,sensor-id : If the flag is present map the TSENS sensors based on the
remote sensors that are enabled in HW. Ensure the mapping is not remote sensors that are enabled in HW. Ensure the mapping is not
more than the number of supported sensors. more than the number of supported sensors.
- qcom,client-id : If the flag is present use it to identify the SW ID mapping
used to associate it with the controller and the physical sensor
mapping within the controller. The physical sensor mapping within
each controller is done using the qcom,sensor-id property. If the
property is not present the SW ID mapping with default from 0 to
total number of supported sensors with each controller instance.
- qcom,valid-status-check: If property is present, check the VALID bit is set
before reporting the temperature data.
- qcom,temp1-offset: If property is present, Use these offset values
to be added for 30 deg calib points.
- qcom,temp2-offset: If property is present, Use these offset values
to be added for 120 deg calib points.
Example: Example:
tsens@fc4a8000 { tsens@fc4a8000 {

View file

@ -50,7 +50,7 @@ obj-$(CONFIG_TEGRA_SOCTHERM) += tegra_soctherm.o
obj-$(CONFIG_HISI_THERMAL) += hisi_thermal.o obj-$(CONFIG_HISI_THERMAL) += hisi_thermal.o
obj-$(CONFIG_THERMAL_QPNP) += qpnp-temp-alarm.o obj-$(CONFIG_THERMAL_QPNP) += qpnp-temp-alarm.o
obj-$(CONFIG_THERMAL_QPNP_ADC_TM) += qpnp-adc-tm.o obj-$(CONFIG_THERMAL_QPNP_ADC_TM) += qpnp-adc-tm.o
obj-$(CONFIG_THERMAL_TSENS8974) += msm8974-tsens.o obj-$(CONFIG_THERMAL_TSENS8974) += msm-tsens.o
obj-$(CONFIG_THERMAL_MONITOR) += msm_thermal.o msm_thermal-dev.o obj-$(CONFIG_THERMAL_MONITOR) += msm_thermal.o msm_thermal-dev.o
obj-$(CONFIG_LIMITS_MONITOR) += lmh_interface.o obj-$(CONFIG_LIMITS_MONITOR) += lmh_interface.o
obj-$(CONFIG_LIMITS_LITE_HW) += lmh_lite.o obj-$(CONFIG_LIMITS_LITE_HW) += lmh_lite.o

File diff suppressed because it is too large Load diff

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2011-2014, The Linux Foundation. All rights reserved. * Copyright (c) 2011-2015, The Linux Foundation. All rights reserved.
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and * it under the terms of the GNU General Public License version 2 and
@ -18,52 +18,122 @@
#ifndef __MSM_TSENS_H #ifndef __MSM_TSENS_H
#define __MSM_TSENS_H #define __MSM_TSENS_H
enum platform_type {
MSM_8660 = 0,
MSM_8960,
MDM_9615,
APQ_8064,
MSM_TYPE
};
#define TSENS_MAX_SENSORS 11 #define TSENS_MAX_SENSORS 11
#define TSENS_MTC_ZONE_LOG_SIZE 6
struct tsens_platform_data { #define TSENS_NUM_MTC_ZONES_SUPPORT 3
int slope[TSENS_MAX_SENSORS]; #define TSENS_ZONEMASK_PARAMS 3
int tsens_factor; #define TSENS_ZONELOG_PARAMS 1
uint32_t tsens_num_sensor; #define TSENS_MTC_ZONE_HISTORY_SIZE 3
enum platform_type hw_type;
};
struct tsens_device { struct tsens_device {
uint32_t sensor_num; uint32_t sensor_num;
}; };
int32_t tsens_get_temp(struct tsens_device *dev, unsigned long *temp);
int msm_tsens_early_init(struct tsens_platform_data *pdata);
#if defined(CONFIG_THERMAL_TSENS8974) #if defined(CONFIG_THERMAL_TSENS8974)
/**
* tsens_is_ready() - Clients can use this API to check if the TSENS device
* is ready and clients can start requesting temperature reads.
* @return: Returns true if device is ready else returns -EPROBE_DEFER
* for clients to check back after a time duration.
*/
int tsens_is_ready(void); int tsens_is_ready(void);
/**
* tsens_tm_init_driver() - Early initialization for clients to read
* TSENS temperature.
*/
int __init tsens_tm_init_driver(void); int __init tsens_tm_init_driver(void);
int tsens_get_sw_id_mapping(int sensor_num, int *sensor_sw_idx); /**
* tsens_get_hw_id_mapping() - Mapping software or sensor ID with the physical
* TSENS sensor. On certain cases where there are more number of
* controllers the sensor ID is used to map the clients software ID
* with the physical HW sensors used by the driver.
* @sensors_sw_id: Client ID.
* @sensor_hw_num: Sensor client ID passed by the driver. This ID is used
* by the driver to map it to the physical HW sensor
* number.
* @return: If the device is not present returns -EPROBE_DEFER
* for clients to check back after a time duration.
* 0 on success else error code on error.
*/
int tsens_get_hw_id_mapping(int sensor_sw_id, int *sensor_hw_num); int tsens_get_hw_id_mapping(int sensor_sw_id, int *sensor_hw_num);
/**
* tsens_get_max_sensor_num() - Get the total number of active TSENS sensors.
* The total number received by the client is across multiple
* TSENS controllers if present.
* @tsens_num_sensors: Total number of sensor result to be stored.
*/
int tsens_get_max_sensor_num(uint32_t *tsens_num_sensors);
/**
* tsens_set_mtc_zone_sw_mask() - Mask the MTC threshold level of a zone.
* SW can force the MTC to stop issuing throttling commands that
* correspond to each MTC threshold level by writing the
* corresponding bit in register at any time.
* @zone: Zone ID.
* @th1_enable : Value corresponding to the threshold level.
* @th2_enable : Value corresponding to the threshold level.
*/
int tsens_set_mtc_zone_sw_mask(unsigned int zone , unsigned int th1_enable,
unsigned int th2_enable);
/**
* tsens_get_mtc_zone_log() - Get the log of last 6 commands sent to pulse
* swallower of a zone.
* zone: Zone ID
* @zone_log: Log commands result to be stored.
*/
int tsens_get_mtc_zone_log(unsigned int zone , void *zone_log);
/**
* tsens_mtc_reset_history_counter() - Reset history of throttling commands
* sent to pulse swallower. Tsens controller issues clock
* throttling commands to Pulse swallower to perform HW
* based clock throttling. Reset the history counter of a zone.
* @zone: Zone ID.
*/
int tsens_mtc_reset_history_counter(unsigned int zone);
/**
* tsens_get_mtc_zone_history() - Get the history of throttling commands sent
* to pulse swallower. Tsens controller issues clock throttling
* commands to Pulse swallower to perform HW based clock
* throttling.
* @zone: Zone ID
* @zone_hist: Commands history result to be stored.
*/
int tsens_get_mtc_zone_history(unsigned int zone , void *zone_hist);
/**
* tsens_get_temp() - Obtain the TSENS temperature for the respective sensor.
*
* @dev: Sensor number for which client wants the TSENS temperature
* reading. The ID passed by the sensor could be the sensor ID
* which the driver translates to internally to read the
* respective physical HW sensor from the controller.
* @temp: temperature result to be stored.
* @return: If the device is not present returns -EPROBE_DEFER
* for clients to check back after a time duration.
* 0 on success else error code on error.
*/
int tsens_get_temp(struct tsens_device *dev, int *temp);
#else #else
static inline int tsens_is_ready(void) static inline int tsens_is_ready(void)
{ return -ENXIO; } { return -ENXIO; }
static inline int __init tsens_tm_init_driver(void) static inline int __init tsens_tm_init_driver(void)
{ return -ENXIO; } { return -ENXIO; }
static inline int tsens_get_sw_id_mapping(
int sensor_num, int *sensor_sw_idx)
{ return -ENXIO; }
static inline int tsens_get_hw_id_mapping( static inline int tsens_get_hw_id_mapping(
int sensor_sw_id, int *sensor_hw_num) int sensor_sw_id, int *sensor_hw_num)
{ return -ENXIO; } { return -ENXIO; }
#endif
#if defined(CONFIG_THERMAL_TSENS8974)
int tsens_get_max_sensor_num(uint32_t *tsens_num_sensors);
#else
static inline int tsens_get_max_sensor_num(uint32_t *tsens_num_sensors) static inline int tsens_get_max_sensor_num(uint32_t *tsens_num_sensors)
{ return -ENXIO; } { return -ENXIO; }
static inline int tsens_set_mtc_zone_sw_mask(unsigned int zone ,
unsigned int th1_enable ,
unsigned int th2_enable)
{ return -ENXIO; }
static inline int tsens_get_mtc_zone_log(unsigned int zone , void *zone_log)
{ return -ENXIO; }
static inline int tsens_mtc_reset_history_counter(unsigned int zone)
{ return -ENXIO; }
static inline int tsens_get_temp(struct tsens_device *dev,
int *temp)
{ return -ENXIO; }
static inline int tsens_get_mtc_zone_history(unsigned int zone, void *zone_hist)
{ return -ENXIO; }
#endif #endif
#endif /*MSM_TSENS_H */ #endif /*MSM_TSENS_H */