thermal: tsens: Refactor to use regmap_field
Subsystems (5)
cover thermal: tsens: Refactor to use regmap_field
Short term bandaid fixes to add support for more versions of the TSENS IP is not proving to be very scalable. Here is a series to finally convert the driver's core to use regmap_fields so that register addresses and bitfields can be abstracted away from the code.
This series is posted as one to give a complete view of where I'm going with this refactor. We can probably split it into smaller sets if required. Currently it consists of the following parts:
- Patch 01-06: Style changes to make code easier to read (mostly naming related). This has no functional change in the driver, it is a series of search and replace operations. Ideally this will get merged first, otherwise everything else will become painful :-)
- Patch 07-09: Merge the 8916 and 8974 source files into a single one called v0_1.c denoting the version of the IP and open up more opportunities for reuse.
- Patch 10: This is the core patch that adds IP-specific data based on two data structures: tsens_features has bit flags to identify if a certain feature is available in a version or not and an array of reg_field pointers.
regfield_ids list the important fields across IP versions and are used as an index.
This patch converts over all platforms except 8960 which currently doesn't use DT data for tsens and has custom functions for everything. We will get to it eventually, but it's conversion is not a necessity for this series to be merged.
- Patch 11-16: Clean ups and new functionality based on regmap_field
- Patch 17-19: Refactor the get_temp routine. We expect to have a single get_temp routine once all the conversion is finished.
- Patch 20-23: Introduce qcs404 support using new regmap infrastructure.
Testing
-------
Since these changes affect every platform using TSENS, it should be clarified that I have only been focussing on developing/testing this on sdm845 and qcs404. I will test this more thoroughly on msm8916, msm8996, msm8998 but it is still pending.
Future work
-----------
a. Get rid of get_temp_common in favour of get_temp_tsens_valid b. irq support
c. Convert over 8960 to use regmap_field and as a result common functions
Regards,
Amit
Amit Kucheria (24):
drivers: thermal: tsens: Document the data structures
drivers: thermal: tsens: Rename tsens_data
drivers: thermal: tsens: Rename tsens_device
drivers: thermal: tsens: Rename variable tmdev
drivers: thermal: tsens: Use consistent names for variables
drivers: thermal: tsens: Function prototypes should have argument
names
drivers: thermal: tsens: Rename tsens-8916 to prepare to merge with
tsens-8974
drivers: thermal: tsens: Rename constants to prepare to merge with
tsens-8974 drivers: thermal: tsens: Merge tsens-8974 into tsens-v0_1
drivers: thermal: tsens: Introduce reg_fields to deal with register
description
drivers: thermal: tsens: Save reference to the device pointer and use
it
drivers: thermal: tsens: Don't print error message on -EPROBE_DEFER
drivers: thermal: tsens: Print IP version
drivers: thermal: tsens: Add new operation to check if a sensor is
enabled
drivers: thermal: tsens: change data type for sensor IDs
drivers: thermal: tsens: Introduce IP-specific max_sensor count
drivers: thermal: tsens: simplify get_temp_tsens_v2 routine
drivers: thermal: tsens: Move get_temp_tsens_v2 to allow sharing
drivers: thermal: tsens: Common get_temp() learns to do ADC conversion
dt: thermal: tsens: Add bindings for qcs404
drivers: thermal: tsens: Add generic support for TSENS v1 IP
arm64: dts: qcom: qcs404: Add tsens controller
arm64: dts: qcom: qcs404: Add thermal zones for each sensor
drivers: thermal: tsens: Move calibration constants to header file
.../bindings/thermal/qcom-tsens.txt | 14 +
arch/arm64/boot/dts/qcom/qcs404.dtsi | 263 ++++++++++++++++++
drivers/thermal/qcom/Makefile | 4 +-
drivers/thermal/qcom/tsens-8916.c | 105 -------
drivers/thermal/qcom/tsens-8960.c | 84 +++---
drivers/thermal/qcom/tsens-common.c | 172 +++++++++---
.../qcom/{tsens-8974.c => tsens-v0_1.c} | 167 ++++++++++-
drivers/thermal/qcom/tsens-v1.c | 229 +++++++++++++++
drivers/thermal/qcom/tsens-v2.c | 148 ++++++----
drivers/thermal/qcom/tsens.c | 100 ++++---
drivers/thermal/qcom/tsens.h | 238 ++++++++++++++--
11 files changed, 1191 insertions(+), 333 deletions(-)
delete mode 100644 drivers/thermal/qcom/tsens-8916.c
rename drivers/thermal/qcom/{tsens-8974.c => tsens-v0_1.c} (55%)
create mode 100644 drivers/thermal/qcom/tsens-v1.cSignature · 1 line
2.17.1
PATCH 1/24 drivers: thermal: tsens: Document the data structures
Describe how the TSENS device and the various sensors connected to it are described in the driver
--- drivers/thermal/qcom/tsens.h | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-)
drivers/thermal/qcom/tsens.h +28 -3
@@ -14,6 +14,16 @@struct tsens_device ; +/** +* struct tsens_sensor - data for each sensor connected to the tsens device +* @tmdev: tsens device instance that this sensor is connected to +* @tzd: pointer to the thermal zone that this sensor is in +* @offset: offset of temperature adjustment curve +* @id: Sensor ID +* @hw_id: HW ID can be used in case of platform-specific IDs +* @slope: slope of temperature adjustment curve +* @status: 8960-specific variable to track 8960 and 8660 status register offset +*/ struct tsens_sensor {struct tsens_device *tmdev;struct thermal_zone_device *tzd;
@@ -55,8 +65,8 @@ enum reg_list { };/** -* struct tsens_data - tsens instance specific data -* @num_sensors: Max number of sensors supported by platform +* struct tsens_data - tsens platform data +* @num_sensors: Number of sensors supported by platform * @ops: operations the tsens instance supports * @hw_ids: Subset of sensors ids supported by platform, if not the first n * @reg_offsets: Register offsets for commonly used registers
@@ -68,12 +78,27 @@ struct tsens_data {unsigned int *hw_ids; }; -/* Registers to be saved/restored across a context loss */ +/** +* struct tsens_context - Registers to be saved/restored across a context loss +*/ struct tsens_context {int threshold;int control; }; +/** +* struct tsens_device - private data for each instance of the tsens IP +* @dev: pointer to struct device +* @num_sensors: number of sensors enabled on this device +* @tm_map: pointer to TM register address space +* @srot_map: pointer to SROT register address space +* @tm_offset: deal with old device trees that don't address TM and SROT +* address space separately +* @reg_offsets: array of offsets to important regs for this version of IP +* @ctx: registers to be saved and restored during suspend/resume +* @ops: pointer to list of callbacks supported by this device +* @sensor: list of sensors attached to this device +*/ struct tsens_device {struct device *dev;u32 num_sensors;
Signature · 1 line
2.17.1
PATCH 2/24 drivers: thermal: tsens: Rename tsens_data
In reply to Amit KucheriaRename to tsens_plat_data to denote that it is platform-data passed in at compile-time.
--- drivers/thermal/qcom/tsens-8916.c | 2 +- drivers/thermal/qcom/tsens-8960.c | 2 +- drivers/thermal/qcom/tsens-8974.c | 2 +- drivers/thermal/qcom/tsens-v2.c | 4 ++-- drivers/thermal/qcom/tsens.c | 2 +- drivers/thermal/qcom/tsens.h | 8 ++++---- 6 files changed, 10 insertions(+), 10 deletions(-)
drivers/thermal/qcom/tsens-8916.c +1 -1
@@ -97,7 +97,7 @@ static const struct tsens_ops ops_8916 = { .get_temp = get_temp_common, }; -const struct tsens_data data_8916 = { +const struct tsens_plat_data data_8916 = { .num_sensors =5 , .ops = &ops_8916, .reg_offsets = { [SROT_CTRL_OFFSET ] =0x0 },
drivers/thermal/qcom/tsens-8960.c +1 -1
@@ -277,7 +277,7 @@ static const struct tsens_ops ops_8960 = { .resume = resume_8960, }; -const struct tsens_data data_8960 = { +const struct tsens_plat_data data_8960 = { .num_sensors =11 , .ops = &ops_8960, };
drivers/thermal/qcom/tsens-8974.c +1 -1
@@ -229,7 +229,7 @@ static const struct tsens_ops ops_8974 = { .get_temp = get_temp_common, }; -const struct tsens_data data_8974 = { +const struct tsens_plat_data data_8974 = { .num_sensors =11 , .ops = &ops_8974, .reg_offsets = { [SROT_CTRL_OFFSET ] =0x0 },
drivers/thermal/qcom/tsens-v2.c +2 -2
@@ -66,13 +66,13 @@ static const struct tsens_ops ops_generic_v2 = { .get_temp = get_temp_tsens_v2, }; -const struct tsens_data data_tsens_v2 = { +const struct tsens_plat_data data_tsens_v2 = { .ops = &ops_generic_v2, .reg_offsets = { [SROT_CTRL_OFFSET ] =0x4 }, };/* Kept around for backward compatibility with old msm8996.dtsi */ -const struct tsens_data data_8996 = { +const struct tsens_plat_data data_8996 = { .num_sensors =13 , .ops = &ops_generic_v2, .reg_offsets = { [SROT_CTRL_OFFSET ] =0x4 },
drivers/thermal/qcom/tsens.c +1 -1
@@ -102,7 +102,7 @@ static int tsens_probe(struct platform_device *pdev)struct device *dev;struct device_node *np;struct tsens_device *tmdev; -const struct tsens_data *data; +const struct tsens_plat_data *data;const struct of_device_id *id;u32 num_sensors;
drivers/thermal/qcom/tsens.h +4 -4
@@ -65,13 +65,13 @@ enum reg_list { };/** -* struct tsens_data - tsens platform data +* struct tsens_plat_data - tsens compile-time platform data * @num_sensors: Number of sensors supported by platform * @ops: operations the tsens instance supports * @hw_ids: Subset of sensors ids supported by platform, if not the first n * @reg_offsets: Register offsets for commonly used registers */ -struct tsens_data { +struct tsens_plat_data {const u32 num_sensors;const struct tsens_ops *ops;const u16 reg_offsets[REG_ARRAY_SIZE ];
@@ -117,8 +117,8 @@ int init_common(struct tsens_device *);int get_temp_common (struct tsens_device *,int ,int *);/* TSENS v1 targets */ -extern const struct tsens_data data_8916, data_8974, data_8960; +extern const struct tsens_plat_data data_8916, data_8974, data_8960;/* TSENS v2 targets */ -extern const struct tsens_data data_8996, data_tsens_v2; +extern const struct tsens_plat_data data_8996, data_tsens_v2;#endif /* __QCOM_TSENS_H__ */
Signature · 1 line
2.17.1
PATCH 3/24 drivers: thermal: tsens: Rename tsens_device
In reply to Amit KucheriaRename to tsens_priv to denote that it is private data for each tsens instance.
--- drivers/thermal/qcom/tsens-8916.c | 2 +- drivers/thermal/qcom/tsens-8960.c | 14 +++++++------- drivers/thermal/qcom/tsens-8974.c | 2 +- drivers/thermal/qcom/tsens-common.c | 6 +++--- drivers/thermal/qcom/tsens-v2.c | 2 +- drivers/thermal/qcom/tsens.c | 14 +++++++------- drivers/thermal/qcom/tsens.h | 30 ++++++++++++++--------------- 7 files changed, 35 insertions(+), 35 deletions(-)
drivers/thermal/qcom/tsens-8916.c +1 -1
@@ -39,7 +39,7 @@#define CAL_SEL_MASK 0xe0000000#define CAL_SEL_SHIFT 29 -static int calibrate_8916 (struct tsens_device *tmdev) +static int calibrate_8916 (struct tsens_priv *tmdev) {int base0 =0 , base1 =0 , i;u32 p1[5 ], p2[5 ];
drivers/thermal/qcom/tsens-8960.c +7 -7
@@ -56,7 +56,7 @@#define TRDY_MASK BIT(7)#define TIMEOUT_US 100 -static int suspend_8960 (struct tsens_device *tmdev) +static int suspend_8960 (struct tsens_priv *tmdev) {int ret;unsigned int mask;
@@ -82,7 +82,7 @@ static int suspend_8960(struct tsens_device *tmdev)return 0 ; } -static int resume_8960 (struct tsens_device *tmdev) +static int resume_8960 (struct tsens_priv *tmdev) {int ret;struct regmap *map = tmdev->tm_map;
@@ -112,7 +112,7 @@ static int resume_8960(struct tsens_device *tmdev)return 0 ; } -static int enable_8960 (struct tsens_device *tmdev,int id) +static int enable_8960 (struct tsens_priv *tmdev,int id) {int ret;u32 reg, mask;
@@ -138,7 +138,7 @@ static int enable_8960(struct tsens_device *tmdev, int id)return 0 ; } -static void disable_8960 (struct tsens_device *tmdev) +static void disable_8960 (struct tsens_priv *tmdev) {int ret;u32 reg_cntl;
@@ -162,7 +162,7 @@ static void disable_8960(struct tsens_device *tmdev)regmap_write (tmdev->tm_map,CNTL_ADDR , reg_cntl); } -static int init_8960 (struct tsens_device *tmdev) +static int init_8960 (struct tsens_priv *tmdev) {int ret, i;u32 reg_cntl;
@@ -212,7 +212,7 @@ static int init_8960(struct tsens_device *tmdev)return 0 ; } -static int calibrate_8960 (struct tsens_device *tmdev) +static int calibrate_8960 (struct tsens_priv *tmdev) {int i;char *data;
@@ -243,7 +243,7 @@ static inline int code_to_mdegC(u32 adc_code, const struct tsens_sensor *s)return adc_code * slope + offset; } -static int get_temp_8960 (struct tsens_device *tmdev,int id,int *temp) +static int get_temp_8960 (struct tsens_priv *tmdev,int id,int *temp) {int ret;u32 code, trdy;
drivers/thermal/qcom/tsens-8974.c +1 -1
@@ -91,7 +91,7 @@#define BIT_APPEND 0x3 -static int calibrate_8974 (struct tsens_device *tmdev) +static int calibrate_8974 (struct tsens_priv *tmdev) {int base1 =0 , base2 =0 , i;u32 p1[11 ], p2[11 ];
drivers/thermal/qcom/tsens-common.c +3 -3
@@ -46,7 +46,7 @@ char *qfprom_read(struct device *dev, const char *cname)* and offset values are derived from tz->tzp->slope and tz->tzp->offset * resp. */ -void compute_intercept_slope (struct tsens_device *tmdev,u32 *p1, +void compute_intercept_slope (struct tsens_priv *tmdev,u32 *p1,u32 *p2,u32 mode) {int i;
@@ -95,7 +95,7 @@ static inline int code_to_degc(u32 adc_code, const struct tsens_sensor *s)return degc; } -int get_temp_common (struct tsens_device *tmdev,int id,int *temp) +int get_temp_common (struct tsens_priv *tmdev,int id,int *temp) {struct tsens_sensor *s = &tmdev->sensor[id];u32 code;
@@ -127,7 +127,7 @@ static const struct regmap_config tsens_srot_config = { .reg_stride = 4, }; -int __init init_common (struct tsens_device *tmdev) +int __init init_common (struct tsens_priv *tmdev) {void __iomem *tm_base, *srot_base;struct resource *res;
drivers/thermal/qcom/tsens-v2.c +1 -1
@@ -12,7 +12,7 @@#define LAST_TEMP_MASK 0xfff#define STATUS_VALID_BIT BIT(21) -static int get_temp_tsens_v2 (struct tsens_device *tmdev,int id,int *temp) +static int get_temp_tsens_v2 (struct tsens_priv *tmdev,int id,int *temp) {struct tsens_sensor *s = &tmdev->sensor[id];u32 code;
drivers/thermal/qcom/tsens.c +7 -7
@@ -15,7 +15,7 @@static int tsens_get_temp (void *data,int *temp) {const struct tsens_sensor *s = data; -struct tsens_device *tmdev = s->tmdev; +struct tsens_priv *tmdev = s->tmdev;return tmdev->ops->get_temp (tmdev, s->id, temp); }
@@ -23,7 +23,7 @@ static int tsens_get_temp(void *data, int *temp)static int tsens_get_trend (void *p,int trip,enum thermal_trend *trend) {const struct tsens_sensor *s = p; -struct tsens_device *tmdev = s->tmdev; +struct tsens_priv *tmdev = s->tmdev;if (tmdev->ops->get_trend)return tmdev->ops->get_trend (tmdev, s->id, trend);
@@ -33,7 +33,7 @@ static int tsens_get_trend(void *p, int trip, enum thermal_trend *trend)static int __maybe_unused tsens_suspend (struct device *dev) { -struct tsens_device *tmdev =dev_get_drvdata (dev); +struct tsens_priv *tmdev =dev_get_drvdata (dev);if (tmdev->ops && tmdev->ops->suspend)return tmdev->ops->suspend (tmdev);
@@ -43,7 +43,7 @@ static int __maybe_unused tsens_suspend(struct device *dev)static int __maybe_unused tsens_resume (struct device *dev) { -struct tsens_device *tmdev =dev_get_drvdata (dev); +struct tsens_priv *tmdev =dev_get_drvdata (dev);if (tmdev->ops && tmdev->ops->resume)return tmdev->ops->resume (tmdev);
@@ -76,7 +76,7 @@ static const struct thermal_zone_of_device_ops tsens_of_ops = { .get_trend = tsens_get_trend, }; -static int tsens_register (struct tsens_device *tmdev) +static int tsens_register (struct tsens_priv *tmdev) {int i;struct thermal_zone_device *tzd;
@@ -101,7 +101,7 @@ static int tsens_probe(struct platform_device *pdev)int ret, i;struct device *dev;struct device_node *np; -struct tsens_device *tmdev; +struct tsens_priv *tmdev;const struct tsens_plat_data *data;const struct of_device_id *id;u32 num_sensors;
@@ -174,7 +174,7 @@ static int tsens_probe(struct platform_device *pdev)static int tsens_remove (struct platform_device *pdev) { -struct tsens_device *tmdev =platform_get_drvdata (pdev); +struct tsens_priv *tmdev =platform_get_drvdata (pdev);if (tmdev->ops->disable) tmdev->ops->disable (tmdev);
drivers/thermal/qcom/tsens.h +15 -15
@@ -12,7 +12,7 @@#include <linux/thermal.h> -struct tsens_device ; +struct tsens_priv ;/** * struct tsens_sensor - data for each sensor connected to the tsens device
@@ -25,7 +25,7 @@ struct tsens_device;* @status: 8960-specific variable to track 8960 and 8660 status register offset */ struct tsens_sensor { -struct tsens_device *tmdev; +struct tsens_priv *tmdev;struct thermal_zone_device *tzd;int offset;int id;
@@ -47,15 +47,15 @@ struct tsens_sensor {*/ struct tsens_ops {/* mandatory callbacks */ -int (*init)(struct tsens_device *); -int (*calibrate)(struct tsens_device *); -int (*get_temp)(struct tsens_device *,int ,int *); +int (*init)(struct tsens_priv *); +int (*calibrate)(struct tsens_priv *); +int (*get_temp)(struct tsens_priv *,int ,int *);/* optional callbacks */ -int (*enable)(struct tsens_device *,int ); -void (*disable)(struct tsens_device *); -int (*suspend)(struct tsens_device *); -int (*resume)(struct tsens_device *); -int (*get_trend)(struct tsens_device *,int ,enum thermal_trend *); +int (*enable)(struct tsens_priv *,int ); +void (*disable)(struct tsens_priv *); +int (*suspend)(struct tsens_priv *); +int (*resume)(struct tsens_priv *); +int (*get_trend)(struct tsens_priv *,int ,enum thermal_trend *); };enum reg_list {
@@ -87,7 +87,7 @@ struct tsens_context { };/** -* struct tsens_device - private data for each instance of the tsens IP +* struct tsens_priv - private data for each instance of the tsens IP * @dev: pointer to struct device * @num_sensors: number of sensors enabled on this device * @tm_map: pointer to TM register address space
@@ -99,7 +99,7 @@ struct tsens_context {* @ops: pointer to list of callbacks supported by this device * @sensor: list of sensors attached to this device */ -struct tsens_device { +struct tsens_priv {struct device *dev;u32 num_sensors;struct regmap *tm_map;
@@ -112,9 +112,9 @@ struct tsens_device { };char *qfprom_read (struct device *,const char *); -void compute_intercept_slope (struct tsens_device *,u32 *,u32 *,u32 ); -int init_common (struct tsens_device *); -int get_temp_common (struct tsens_device *,int ,int *); +void compute_intercept_slope (struct tsens_priv *,u32 *,u32 *,u32 ); +int init_common (struct tsens_priv *); +int get_temp_common (struct tsens_priv *,int ,int *);/* TSENS v1 targets */ extern const struct tsens_plat_data data_8916, data_8974, data_8960;
Signature · 1 line
2.17.1
PATCH 4/24 drivers: thermal: tsens: Rename variable tmdev
In reply to Amit Kucheriatmdev seems to imply that this is a device pointer when in fact it is just private platform data for each tsens device. Rename it to priv improve code readability.
--- drivers/thermal/qcom/tsens-8916.c | 16 +++--- drivers/thermal/qcom/tsens-8960.c | 82 ++++++++++++++--------------- drivers/thermal/qcom/tsens-8974.c | 16 +++--- drivers/thermal/qcom/tsens-common.c | 52 +++++++++--------- drivers/thermal/qcom/tsens-v2.c | 12 ++--- drivers/thermal/qcom/tsens.c | 80 ++++++++++++++-------------- drivers/thermal/qcom/tsens.h | 4 +- 7 files changed, 131 insertions(+), 131 deletions(-)
drivers/thermal/qcom/tsens-8916.c +8 -8
@@ -39,23 +39,23 @@#define CAL_SEL_MASK 0xe0000000#define CAL_SEL_SHIFT 29 -static int calibrate_8916 (struct tsens_priv *tmdev) +static int calibrate_8916 (struct tsens_priv *priv) {int base0 =0 , base1 =0 , i;u32 p1[5 ], p2[5 ];int mode =0 ;u32 *qfprom_cdata, *qfprom_csel; - qfprom_cdata = (u32 *)qfprom_read (tmdev->dev,"calib" ); + qfprom_cdata = (u32 *)qfprom_read (priv->dev,"calib" );if (IS_ERR (qfprom_cdata))return PTR_ERR (qfprom_cdata); - qfprom_csel = (u32 *)qfprom_read (tmdev->dev,"calib_sel" ); + qfprom_csel = (u32 *)qfprom_read (priv->dev,"calib_sel" );if (IS_ERR (qfprom_csel))return PTR_ERR (qfprom_csel); mode = (qfprom_csel[0 ] &CAL_SEL_MASK ) >>CAL_SEL_SHIFT ; -dev_dbg (tmdev->dev,"calibration mode is %d\n" , mode); +dev_dbg (priv->dev,"calibration mode is %d\n" , mode);switch (mode) {case TWO_PT_CALIB :
@@ -65,7 +65,7 @@ static int calibrate_8916(struct tsens_priv *tmdev) p2[2 ] = (qfprom_cdata[1 ] &S2_P2_MASK ) >>S2_P2_SHIFT ; p2[3 ] = (qfprom_cdata[1 ] &S3_P2_MASK ) >>S3_P2_SHIFT ; p2[4 ] = (qfprom_cdata[1 ] &S4_P2_MASK ) >>S4_P2_SHIFT ; -for (i =0 ; i < tmdev->num_sensors; i++) +for (i =0 ; i < priv->num_sensors; i++) p2[i] = ((base1 + p2[i]) <<3 );/* Fall through */ case ONE_PT_CALIB2 :
@@ -75,18 +75,18 @@ static int calibrate_8916(struct tsens_priv *tmdev) p1[2 ] = (qfprom_cdata[0 ] &S2_P1_MASK ) >>S2_P1_SHIFT ; p1[3 ] = (qfprom_cdata[1 ] &S3_P1_MASK ) >>S3_P1_SHIFT ; p1[4 ] = (qfprom_cdata[1 ] &S4_P1_MASK ) >>S4_P1_SHIFT ; -for (i =0 ; i < tmdev->num_sensors; i++) +for (i =0 ; i < priv->num_sensors; i++) p1[i] = (((base0) + p1[i]) <<3 );break ;default : -for (i =0 ; i < tmdev->num_sensors; i++) { +for (i =0 ; i < priv->num_sensors; i++) { p1[i] =500 ; p2[i] =780 ; }break ; } -compute_intercept_slope (tmdev, p1, p2, mode); +compute_intercept_slope (priv, p1, p2, mode);return 0 ; }
drivers/thermal/qcom/tsens-8960.c +41 -41
224 lines not on this page · raw message
drivers/thermal/qcom/tsens-8974.c +8 -8
@@ -91,7 +91,7 @@#define BIT_APPEND 0x3 -static int calibrate_8974 (struct tsens_priv *tmdev) +static int calibrate_8974 (struct tsens_priv *priv) {int base1 =0 , base2 =0 , i;u32 p1[11 ], p2[11 ];
@@ -99,11 +99,11 @@ static int calibrate_8974(struct tsens_priv *tmdev)u32 *calib, *bkp;u32 calib_redun_sel; - calib = (u32 *)qfprom_read (tmdev->dev,"calib" ); + calib = (u32 *)qfprom_read (priv->dev,"calib" );if (IS_ERR (calib))return PTR_ERR (calib); - bkp = (u32 *)qfprom_read (tmdev->dev,"calib_backup" ); + bkp = (u32 *)qfprom_read (priv->dev,"calib_backup" );if (IS_ERR (bkp))return PTR_ERR (bkp);
@@ -184,25 +184,25 @@ static int calibrate_8974(struct tsens_priv *tmdev)switch (mode) {case ONE_PT_CALIB : -for (i =0 ; i < tmdev->num_sensors; i++) +for (i =0 ; i < priv->num_sensors; i++) p1[i] += (base1 <<2 ) |BIT_APPEND ;break ;case TWO_PT_CALIB : -for (i =0 ; i < tmdev->num_sensors; i++) { +for (i =0 ; i < priv->num_sensors; i++) { p2[i] += base2; p2[i] <<=2 ; p2[i] |=BIT_APPEND ; }/* Fall through */ case ONE_PT_CALIB2 : -for (i =0 ; i < tmdev->num_sensors; i++) { +for (i =0 ; i < priv->num_sensors; i++) { p1[i] += base1; p1[i] <<=2 ; p1[i] |=BIT_APPEND ; }break ;default : -for (i =0 ; i < tmdev->num_sensors; i++) +for (i =0 ; i < priv->num_sensors; i++) p2[i] =780 ; p1[0 ] =502 ; p1[1 ] =509 ;
@@ -218,7 +218,7 @@ static int calibrate_8974(struct tsens_priv *tmdev)break ; } -compute_intercept_slope (tmdev, p1, p2, mode); +compute_intercept_slope (priv, p1, p2, mode);return 0 ; }
drivers/thermal/qcom/tsens-common.c +26 -26
122 lines not on this page · raw message
drivers/thermal/qcom/tsens-v2.c +6 -6
@@ -12,16 +12,16 @@#define LAST_TEMP_MASK 0xfff#define STATUS_VALID_BIT BIT(21) -static int get_temp_tsens_v2 (struct tsens_priv *tmdev,int id,int *temp) +static int get_temp_tsens_v2 (struct tsens_priv *priv,int id,int *temp) { -struct tsens_sensor *s = &tmdev->sensor[id]; +struct tsens_sensor *s = &priv->sensor[id];u32 code;unsigned int status_reg;u32 last_temp =0 , last_temp2 =0 , last_temp3 =0 ;int ret; - status_reg = tmdev->tm_offset +STATUS_OFFSET + s->hw_id *4 ; - ret =regmap_read (tmdev->tm_map, status_reg, &code); + status_reg = priv->tm_offset +STATUS_OFFSET + s->hw_id *4 ; + ret =regmap_read (priv->tm_map, status_reg, &code);if (ret)return ret; last_temp = code &LAST_TEMP_MASK ;
@@ -29,7 +29,7 @@ static int get_temp_tsens_v2(struct tsens_priv *tmdev, int id, int *temp) goto done;/* Try a second time */ - ret =regmap_read (tmdev->tm_map, status_reg, &code); + ret =regmap_read (priv->tm_map, status_reg, &code);if (ret)return ret;if (code &STATUS_VALID_BIT ) {
@@ -40,7 +40,7 @@ static int get_temp_tsens_v2(struct tsens_priv *tmdev, int id, int *temp) }/* Try a third/last time */ - ret =regmap_read (tmdev->tm_map, status_reg, &code); + ret =regmap_read (priv->tm_map, status_reg, &code);if (ret)return ret;if (code &STATUS_VALID_BIT ) {
drivers/thermal/qcom/tsens.c +40 -40
162 lines not on this page · raw message
drivers/thermal/qcom/tsens.h +2 -2
@@ -16,7 +16,7 @@ struct tsens_priv;/** * struct tsens_sensor - data for each sensor connected to the tsens device -* @tmdev: tsens device instance that this sensor is connected to +* @priv: tsens device instance that this sensor is connected to * @tzd: pointer to the thermal zone that this sensor is in * @offset: offset of temperature adjustment curve * @id: Sensor ID
@@ -25,7 +25,7 @@ struct tsens_priv;* @status: 8960-specific variable to track 8960 and 8660 status register offset */ struct tsens_sensor { -struct tsens_priv *tmdev; +struct tsens_priv *priv;struct thermal_zone_device *tzd;int offset;int id;
Signature · 1 line
2.17.1
PATCH 5/24 drivers: thermal: tsens: Use consistent names for variables
In reply to Amit Kucheriatsens_get_temp() uses the name 'data' for the void pointer, use the same in tsens_get_trend() for consistency.
Remove a stray space while we're at it.
--- drivers/thermal/qcom/tsens.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/thermal/qcom/tsens.c +3 -3
@@ -20,13 +20,13 @@ static int tsens_get_temp(void *data, int *temp)return priv->ops->get_temp (priv, s->id, temp); } -static int tsens_get_trend (void *p,int trip,enum thermal_trend *trend) +static int tsens_get_trend (void *data,int trip,enum thermal_trend *trend) { -const struct tsens_sensor *s = p; +const struct tsens_sensor *s = data;struct tsens_priv *priv = s->priv;if (priv->ops->get_trend) -return priv->ops->get_trend (priv, s->id, trend); +return priv->ops->get_trend (priv, s->id, trend);return -ENOTSUPP ; }
Signature · 1 line
2.17.1
PATCH 6/24 drivers: thermal: tsens: Function prototypes should have argument names
In reply to Amit Kucheriacheck_patch complains a lot as follows:
WARNING: function definition argument 'struct tsens_priv *' should also have an identifier name
+ int (*init)(struct tsens_priv *);
Fix it.
--- drivers/thermal/qcom/tsens.h | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)
drivers/thermal/qcom/tsens.h +12 -12
@@ -47,15 +47,15 @@ struct tsens_sensor {*/ struct tsens_ops {/* mandatory callbacks */ -int (*init)(struct tsens_priv *); -int (*calibrate)(struct tsens_priv *); -int (*get_temp)(struct tsens_priv *,int ,int *); +int (*init)(struct tsens_priv *priv); +int (*calibrate)(struct tsens_priv *priv); +int (*get_temp)(struct tsens_priv *priv,int i,int *temp);/* optional callbacks */ -int (*enable)(struct tsens_priv *,int ); -void (*disable)(struct tsens_priv *); -int (*suspend)(struct tsens_priv *); -int (*resume)(struct tsens_priv *); -int (*get_trend)(struct tsens_priv *,int ,enum thermal_trend *); +int (*enable)(struct tsens_priv *priv,int i); +void (*disable)(struct tsens_priv *priv); +int (*suspend)(struct tsens_priv *priv); +int (*resume)(struct tsens_priv *priv); +int (*get_trend)(struct tsens_priv *priv,int i,enum thermal_trend *trend); };enum reg_list {
@@ -111,10 +111,10 @@ struct tsens_priv {struct tsens_sensor sensor[0 ]; }; -char *qfprom_read (struct device *,const char *); -void compute_intercept_slope (struct tsens_priv *,u32 *,u32 *,u32 ); -int init_common (struct tsens_priv *); -int get_temp_common (struct tsens_priv *,int ,int *); +char *qfprom_read (struct device *dev,const char *cname); +void compute_intercept_slope (struct tsens_priv *priv,u32 *pt1,u32 *pt2,u32 mode); +int init_common (struct tsens_priv *priv); +int get_temp_common (struct tsens_priv *priv,int i,int *temp);/* TSENS v1 targets */ extern const struct tsens_plat_data data_8916, data_8974, data_8960;
Signature · 1 line
2.17.1
PATCH 7/24 drivers: thermal: tsens: Rename tsens-8916 to prepare to merge with tsens-8974
In reply to Amit Kucheria8916 and 8974 use v0.1.0 of the TSENS IP. Rename tsens-8916 to prepare it for merging with tsens-8974 in a later commit.
---
drivers/thermal/qcom/Makefile | 2 +-
drivers/thermal/qcom/{tsens-8916.c => tsens-v0_1.c} | 0
2 files changed, 1 insertion(+), 1 deletion(-)
rename drivers/thermal/qcom/{tsens-8916.c => tsens-v0_1.c} (100%)drivers/thermal/qcom/Makefile +1 -1
@@ -1,3 +1,3 @@ obj-$(CONFIG_QCOM_TSENS) += qcom_tsens.o -qcom_tsens-y += tsens.o tsens-common.o tsens-8916.o tsens-8974.o tsens-8960.o tsens-v2.o +qcom_tsens-y += tsens.o tsens-common.o tsens-v0_1.o tsens-8974.o tsens-8960.o tsens-v2.o obj-$(CONFIG_QCOM_SPMI_TEMP_ALARM) += qcom-spmi-temp-alarm.o
drivers/thermal/qcom/tsens-v0_1.c renamed from drivers/thermal/qcom/tsens-8916.c +0 -0
Signature · 1 line
2.17.1
PATCH 8/24 drivers: thermal: tsens: Rename constants to prepare to merge with tsens-8974
In reply to Amit KucheriaSome #defines in tsens-v_0_1.c clash with those in tsens-8974.c. Prefix them with 8916 to avoid the clash so we can merge the two files.
--- drivers/thermal/qcom/tsens-v0_1.c | 88 +++++++++++++++---------------- 1 file changed, 44 insertions(+), 44 deletions(-)
drivers/thermal/qcom/tsens-v0_1.c +44 -44
@@ -7,37 +7,37 @@#include "tsens.h" /* eeprom layout data for 8916 */ -#define BASE0_MASK 0x0000007f -#define BASE1_MASK 0xfe000000 -#define BASE0_SHIFT 0 -#define BASE1_SHIFT 25 - -#define S0_P1_MASK 0x00000f80 -#define S1_P1_MASK 0x003e0000 -#define S2_P1_MASK 0xf8000000 -#define S3_P1_MASK 0x000003e0 -#define S4_P1_MASK 0x000f8000 - -#define S0_P2_MASK 0x0001f000 -#define S1_P2_MASK 0x07c00000 -#define S2_P2_MASK 0x0000001f -#define S3_P2_MASK 0x00007c00 -#define S4_P2_MASK 0x01f00000 - -#define S0_P1_SHIFT 7 -#define S1_P1_SHIFT 17 -#define S2_P1_SHIFT 27 -#define S3_P1_SHIFT 5 -#define S4_P1_SHIFT 15 - -#define S0_P2_SHIFT 12 -#define S1_P2_SHIFT 22 -#define S2_P2_SHIFT 0 -#define S3_P2_SHIFT 10 -#define S4_P2_SHIFT 20 - -#define CAL_SEL_MASK 0xe0000000 -#define CAL_SEL_SHIFT 29 +#define MSM8916_BASE0_MASK 0x0000007f +#define MSM8916_BASE1_MASK 0xfe000000 +#define MSM8916_BASE0_SHIFT 0 +#define MSM8916_BASE1_SHIFT 25 + +#define MSM8916_S0_P1_MASK 0x00000f80 +#define MSM8916_S1_P1_MASK 0x003e0000 +#define MSM8916_S2_P1_MASK 0xf8000000 +#define MSM8916_S3_P1_MASK 0x000003e0 +#define MSM8916_S4_P1_MASK 0x000f8000 + +#define MSM8916_S0_P2_MASK 0x0001f000 +#define MSM8916_S1_P2_MASK 0x07c00000 +#define MSM8916_S2_P2_MASK 0x0000001f +#define MSM8916_S3_P2_MASK 0x00007c00 +#define MSM8916_S4_P2_MASK 0x01f00000 + +#define MSM8916_S0_P1_SHIFT 7 +#define MSM8916_S1_P1_SHIFT 17 +#define MSM8916_S2_P1_SHIFT 27 +#define MSM8916_S3_P1_SHIFT 5 +#define MSM8916_S4_P1_SHIFT 15 + +#define MSM8916_S0_P2_SHIFT 12 +#define MSM8916_S1_P2_SHIFT 22 +#define MSM8916_S2_P2_SHIFT 0 +#define MSM8916_S3_P2_SHIFT 10 +#define MSM8916_S4_P2_SHIFT 20 + +#define MSM8916_CAL_SEL_MASK 0xe0000000 +#define MSM8916_CAL_SEL_SHIFT 29static int calibrate_8916 (struct tsens_priv *priv) {
@@ -54,27 +54,27 @@ static int calibrate_8916(struct tsens_priv *priv)if (IS_ERR (qfprom_csel))return PTR_ERR (qfprom_csel); - mode = (qfprom_csel[0 ] &CAL_SEL_MASK ) >>CAL_SEL_SHIFT ; + mode = (qfprom_csel[0 ] &MSM8916_CAL_SEL_MASK ) >>MSM8916_CAL_SEL_SHIFT ;dev_dbg (priv->dev,"calibration mode is %d\n" , mode);switch (mode) {case TWO_PT_CALIB : - base1 = (qfprom_cdata[1 ] &BASE1_MASK ) >>BASE1_SHIFT ; - p2[0 ] = (qfprom_cdata[0 ] &S0_P2_MASK ) >>S0_P2_SHIFT ; - p2[1 ] = (qfprom_cdata[0 ] &S1_P2_MASK ) >>S1_P2_SHIFT ; - p2[2 ] = (qfprom_cdata[1 ] &S2_P2_MASK ) >>S2_P2_SHIFT ; - p2[3 ] = (qfprom_cdata[1 ] &S3_P2_MASK ) >>S3_P2_SHIFT ; - p2[4 ] = (qfprom_cdata[1 ] &S4_P2_MASK ) >>S4_P2_SHIFT ; + base1 = (qfprom_cdata[1 ] &MSM8916_BASE1_MASK ) >>MSM8916_BASE1_SHIFT ; + p2[0 ] = (qfprom_cdata[0 ] &MSM8916_S0_P2_MASK ) >>MSM8916_S0_P2_SHIFT ; + p2[1 ] = (qfprom_cdata[0 ] &MSM8916_S1_P2_MASK ) >>MSM8916_S1_P2_SHIFT ; + p2[2 ] = (qfprom_cdata[1 ] &MSM8916_S2_P2_MASK ) >>MSM8916_S2_P2_SHIFT ; + p2[3 ] = (qfprom_cdata[1 ] &MSM8916_S3_P2_MASK ) >>MSM8916_S3_P2_SHIFT ; + p2[4 ] = (qfprom_cdata[1 ] &MSM8916_S4_P2_MASK ) >>MSM8916_S4_P2_SHIFT ;for (i =0 ; i < priv->num_sensors; i++) p2[i] = ((base1 + p2[i]) <<3 );/* Fall through */ case ONE_PT_CALIB2 : - base0 = (qfprom_cdata[0 ] &BASE0_MASK ); - p1[0 ] = (qfprom_cdata[0 ] &S0_P1_MASK ) >>S0_P1_SHIFT ; - p1[1 ] = (qfprom_cdata[0 ] &S1_P1_MASK ) >>S1_P1_SHIFT ; - p1[2 ] = (qfprom_cdata[0 ] &S2_P1_MASK ) >>S2_P1_SHIFT ; - p1[3 ] = (qfprom_cdata[1 ] &S3_P1_MASK ) >>S3_P1_SHIFT ; - p1[4 ] = (qfprom_cdata[1 ] &S4_P1_MASK ) >>S4_P1_SHIFT ; + base0 = (qfprom_cdata[0 ] &MSM8916_BASE0_MASK ); + p1[0 ] = (qfprom_cdata[0 ] &MSM8916_S0_P1_MASK ) >>MSM8916_S0_P1_SHIFT ; + p1[1 ] = (qfprom_cdata[0 ] &MSM8916_S1_P1_MASK ) >>MSM8916_S1_P1_SHIFT ; + p1[2 ] = (qfprom_cdata[0 ] &MSM8916_S2_P1_MASK ) >>MSM8916_S2_P1_SHIFT ; + p1[3 ] = (qfprom_cdata[1 ] &MSM8916_S3_P1_MASK ) >>MSM8916_S3_P1_SHIFT ; + p1[4 ] = (qfprom_cdata[1 ] &MSM8916_S4_P1_MASK ) >>MSM8916_S4_P1_SHIFT ;for (i =0 ; i < priv->num_sensors; i++) p1[i] = (((base0) + p1[i]) <<3 );break ;
Signature · 1 line
2.17.1
PATCH 9/24 drivers: thermal: tsens: Merge tsens-8974 into tsens-v0_1
In reply to Amit Kucheria8974 and 8916 have the same version of the TSENS IP. Merge the files to allow for better code reuse.
--- drivers/thermal/qcom/Makefile | 2 +- drivers/thermal/qcom/tsens-8974.c | 236 ------------------------------ drivers/thermal/qcom/tsens-v0_1.c | 229 +++++++++++++++++++++++++++++ drivers/thermal/qcom/tsens.h | 8 +- 4 files changed, 236 insertions(+), 239 deletions(-) delete mode 100644 drivers/thermal/qcom/tsens-8974.c
drivers/thermal/qcom/Makefile +1 -1
@@ -1,3 +1,3 @@ obj-$(CONFIG_QCOM_TSENS) += qcom_tsens.o -qcom_tsens-y += tsens.o tsens-common.o tsens-v0_1.o tsens-8974.o tsens-8960.o tsens-v2.o +qcom_tsens-y += tsens.o tsens-common.o tsens-v0_1.o tsens-8960.o tsens-v2.o obj-$(CONFIG_QCOM_SPMI_TEMP_ALARM) += qcom-spmi-temp-alarm.o
drivers/thermal/qcom/tsens-8974.c deleted +0 -236
236 lines not on this page · raw message
drivers/thermal/qcom/tsens-v0_1.c +229 -0
244 lines not on this page · raw message
drivers/thermal/qcom/tsens.h +6 -2
@@ -116,8 +116,12 @@ void compute_intercept_slope(struct tsens_priv *priv, u32 *pt1, u32 *pt2, u32 moint init_common (struct tsens_priv *priv);int get_temp_common (struct tsens_priv *priv,int i,int *temp); -/* TSENS v1 targets */ -extern const struct tsens_plat_data data_8916, data_8974, data_8960; +/* TSENS target */ +extern const struct tsens_plat_data data_8960; + +/* TSENS v0.1 targets */ +extern const struct tsens_plat_data data_8916, data_8974; +/* TSENS v2 targets */ extern const struct tsens_plat_data data_8996, data_tsens_v2;
Signature · 1 line
2.17.1
PATCH 10/24 drivers: thermal: tsens: Introduce reg_fields to deal with register description
In reply to Amit KucheriaAs we add support for newer versions of the TSENS IP, the current approach isn't scaling because registers and bitfields get moved around, requiring platform-specific hacks in the code. By moving to regmap, we can hide the register level differences away from the code.
Define a common set of registers and bit-fields that we care about across the various tsens IP versions.
--- drivers/thermal/qcom/tsens-common.c | 59 ++++++----- drivers/thermal/qcom/tsens-v0_1.c | 51 +++++++++- drivers/thermal/qcom/tsens-v2.c | 140 ++++++++++++++++++++----- drivers/thermal/qcom/tsens.c | 5 +- drivers/thermal/qcom/tsens.h | 153 ++++++++++++++++++++++++++-- 5 files changed, 348 insertions(+), 60 deletions(-)
drivers/thermal/qcom/tsens-common.c +34 -25
@@ -12,13 +12,6 @@#include <linux/regmap.h> #include "tsens.h" -/* SROT */ -#define TSENS_EN BIT(0) - -/* TM */ -#define STATUS_OFFSET 0x30 -#define SN_ADDR_OFFSET 0x4 -#define SN_ST_TEMP_MASK 0x3ff#define CAL_DEGC_PT1 30#define CAL_DEGC_PT2 120#define SLOPE_FACTOR 1000
@@ -95,18 +88,14 @@ static inline int code_to_degc(u32 adc_code, const struct tsens_sensor *s)return degc; } -int get_temp_common (struct tsens_priv *priv,int id,int *temp) +int get_temp_common (struct tsens_priv *priv,int i,int *temp) { -struct tsens_sensor *s = &priv->sensor[id]; -u32 code; -unsigned int status_reg; +struct tsens_sensor *s = &priv->sensor[i];int last_temp =0 , ret; - status_reg = priv->tm_offset +STATUS_OFFSET + s->hw_id *SN_ADDR_OFFSET ; - ret =regmap_read (priv->tm_map, status_reg, &code); + ret =regmap_field_read (priv->rf[LAST_TEMP_0 + s->hw_id], &last_temp);if (ret)return ret; - last_temp = code &SN_ST_TEMP_MASK ; *temp =code_to_degc (last_temp, s) *1000 ;
@@ -131,10 +120,9 @@ int __init init_common(struct tsens_priv *priv) {void __iomem *tm_base, *srot_base;struct resource *res; -u32 code; -int ret; +u32 enabled; +int ret, i, j;struct platform_device *op =of_find_device_by_node (priv->dev->of_node); -u16 ctrl_offset = priv->reg_offsets[SROT_CTRL_OFFSET ];if (!op)return -EINVAL ;
@@ -166,14 +154,35 @@ int __init init_common(struct tsens_priv *priv)if (IS_ERR (priv->tm_map))return PTR_ERR (priv->tm_map); -if (priv->srot_map) { - ret =regmap_read (priv->srot_map, ctrl_offset, &code); -if (ret) -return ret; -if (!(code &TSENS_EN )) { -dev_err (priv->dev,"tsens device is not enabled\n" ); -return -ENODEV ; - } + priv->rf[TSENS_EN ] =devm_regmap_field_alloc (priv->dev, priv->srot_map, + priv->fields[TSENS_EN ]); +if (IS_ERR (priv->rf[TSENS_EN ])) +return PTR_ERR (priv->rf[TSENS_EN ]); + ret =regmap_field_read (priv->rf[TSENS_EN ], &enabled); +if (ret) +return ret; +if (!enabled) { +dev_err (priv->dev,"tsens device is not enabled\n" ); +return -ENODEV ; + } + + priv->rf[SENSOR_EN ] =devm_regmap_field_alloc (priv->dev, priv->srot_map, + priv->fields[SENSOR_EN ]); +if (IS_ERR (priv->rf[SENSOR_EN ])) +return PTR_ERR (priv->rf[SENSOR_EN ]); + +/* now alloc regmap_fields in tm_map */ +for (i =0 , j =LAST_TEMP_0 ; i < priv->num_sensors; i++, j++) { + priv->rf[j] =devm_regmap_field_alloc (priv->dev, priv->tm_map, + priv->fields[j]); +if (IS_ERR (priv->rf[j])) +return PTR_ERR (priv->rf[j]); + } +for (i =0 , j =VALID_0 ; i < priv->num_sensors; i++, j++) { + priv->rf[j] =devm_regmap_field_alloc (priv->dev, priv->tm_map, + priv->fields[j]); +if (IS_ERR (priv->rf[j])) +return PTR_ERR (priv->rf[j]); }return 0 ;
drivers/thermal/qcom/tsens-v0_1.c +49 -2
74 lines not on this page · raw message
drivers/thermal/qcom/tsens-v2.c +117 -23
186 lines not on this page · raw message
drivers/thermal/qcom/tsens.c +2 -3
@@ -144,9 +144,8 @@ static int tsens_probe(struct platform_device *pdev)else priv->sensor[i].hw_id = i; } -for (i =0 ; i <REG_ARRAY_SIZE ; i++) { - priv->reg_offsets[i] = data->reg_offsets[i]; - } + priv->feat = data->feat; + priv->fields = data->fields;if (!priv->ops || !priv->ops->init || !priv->ops->get_temp)return -EINVAL ;
drivers/thermal/qcom/tsens.h +146 -7
191 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH 11/24 drivers: thermal: tsens: Save reference to the device pointer and use it
In reply to Amit KucheriaCode cleanup making it easier to read
--- drivers/thermal/qcom/tsens-common.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-)
drivers/thermal/qcom/tsens-common.c +8 -7
@@ -119,6 +119,7 @@ static const struct regmap_config tsens_srot_config = {int __init init_common (struct tsens_priv *priv) {void __iomem *tm_base, *srot_base; +struct device *dev = priv->dev;struct resource *res;u32 enabled;int ret, i, j;
@@ -135,7 +136,7 @@ int __init init_common(struct tsens_priv *priv)if (IS_ERR (srot_base))return PTR_ERR (srot_base); - priv->srot_map =devm_regmap_init_mmio (priv->dev, srot_base, + priv->srot_map =devm_regmap_init_mmio (dev, srot_base, &tsens_srot_config);if (IS_ERR (priv->srot_map))return PTR_ERR (priv->srot_map);
@@ -150,11 +151,11 @@ int __init init_common(struct tsens_priv *priv)if (IS_ERR (tm_base))return PTR_ERR (tm_base); - priv->tm_map =devm_regmap_init_mmio (priv->dev, tm_base, &tsens_config); + priv->tm_map =devm_regmap_init_mmio (dev, tm_base, &tsens_config);if (IS_ERR (priv->tm_map))return PTR_ERR (priv->tm_map); - priv->rf[TSENS_EN ] =devm_regmap_field_alloc (priv->dev, priv->srot_map, + priv->rf[TSENS_EN ] =devm_regmap_field_alloc (dev, priv->srot_map, priv->fields[TSENS_EN ]);if (IS_ERR (priv->rf[TSENS_EN ]))return PTR_ERR (priv->rf[TSENS_EN ]);
@@ -162,24 +163,24 @@ int __init init_common(struct tsens_priv *priv)if (ret)return ret;if (!enabled) { -dev_err (priv->dev,"tsens device is not enabled\n" ); +dev_err (dev,"tsens device is not enabled\n" );return -ENODEV ; } - priv->rf[SENSOR_EN ] =devm_regmap_field_alloc (priv->dev, priv->srot_map, + priv->rf[SENSOR_EN ] =devm_regmap_field_alloc (dev, priv->srot_map, priv->fields[SENSOR_EN ]);if (IS_ERR (priv->rf[SENSOR_EN ]))return PTR_ERR (priv->rf[SENSOR_EN ]);/* now alloc regmap_fields in tm_map */ for (i =0 , j =LAST_TEMP_0 ; i < priv->num_sensors; i++, j++) { - priv->rf[j] =devm_regmap_field_alloc (priv->dev, priv->tm_map, + priv->rf[j] =devm_regmap_field_alloc (dev, priv->tm_map, priv->fields[j]);if (IS_ERR (priv->rf[j]))return PTR_ERR (priv->rf[j]); }for (i =0 , j =VALID_0 ; i < priv->num_sensors; i++, j++) { - priv->rf[j] =devm_regmap_field_alloc (priv->dev, priv->tm_map, + priv->rf[j] =devm_regmap_field_alloc (dev, priv->tm_map, priv->fields[j]);if (IS_ERR (priv->rf[j]))return PTR_ERR (priv->rf[j]);
Signature · 1 line
2.17.1
PATCH 12/24 drivers: thermal: tsens: Don't print error message on -EPROBE_DEFER
In reply to Amit KucheriaWe print a calibration failure message on -EPROBE_DEFER from nvmem/qfprom as follows:
[ 3.003090] qcom-tsens 4a9000.thermal-sensor: version: 1.4 [ 3.005376] qcom-tsens 4a9000.thermal-sensor: tsens calibration failed [ 3.113248] qcom-tsens 4a9000.thermal-sensor: version: 1.4
This confuses people when, in fact, calibration succeeds later when nvmem/qfprom device is available. Don't print this message on a -EPROBE_DEFER.
--- drivers/thermal/qcom/tsens.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/thermal/qcom/tsens.c +2 -1
@@ -159,7 +159,8 @@ static int tsens_probe(struct platform_device *pdev)if (priv->ops->calibrate) { ret = priv->ops->calibrate (priv);if (ret <0 ) { -dev_err (dev,"tsens calibration failed\n" ); +if (ret != -EPROBE_DEFER ) +dev_err (dev,"tsens calibration failed\n" );return ret; } }
Signature · 1 line
2.17.1
PATCH 13/24 drivers: thermal: tsens: Print IP version
In reply to Amit KucheriaOn some TSENS IP, version is stored. Print that version at init.
--- drivers/thermal/qcom/tsens-common.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-)
drivers/thermal/qcom/tsens-common.c +22 -1
@@ -121,7 +121,7 @@ int __init init_common(struct tsens_priv *priv)void __iomem *tm_base, *srot_base;struct device *dev = priv->dev;struct resource *res; -u32 enabled; +u32 enabled, maj_ver, min_ver;int ret, i, j;struct platform_device *op =of_find_device_by_node (priv->dev->of_node);
@@ -155,6 +155,27 @@ int __init init_common(struct tsens_priv *priv)if (IS_ERR (priv->tm_map))return PTR_ERR (priv->tm_map); +for (i =0 ; i <MAX_REGFIELDS ; i++) { + priv->rf[i] =NULL ; + } + +/* alloc regmap_fields in srot_map */ +if (priv->feat->ver_info) { +for (i =0 , j =VER_MAJOR ; i <2 ; i++, j++) { + priv->rf[j] =devm_regmap_field_alloc (dev, priv->srot_map, + priv->fields[j]); +if (IS_ERR (priv->rf[j])) +return PTR_ERR (priv->rf[j]); + } + ret =regmap_field_read (priv->rf[VER_MAJOR ], &maj_ver); +if (ret) +return ret; + ret =regmap_field_read (priv->rf[VER_MINOR ], &min_ver); +if (ret) +return ret; +dev_info (dev,"version: %d.%d\n" , maj_ver, min_ver); + } + priv->rf[TSENS_EN ] =devm_regmap_field_alloc (dev, priv->srot_map, priv->fields[TSENS_EN ]);if (IS_ERR (priv->rf[TSENS_EN ]))
Signature · 1 line
2.17.1
PATCH 14/24 drivers: thermal: tsens: Add new operation to check if a sensor is enabled
In reply to Amit Kucheriais_sensor_enabled() checks if the sensors are enabled on this platform. It is possible that the SoC might choose not to enable all the sensors that the IP block is capable of supporting.
--- drivers/thermal/qcom/tsens-common.c | 14 ++++++++++++++ drivers/thermal/qcom/tsens-v0_1.c | 1 + drivers/thermal/qcom/tsens-v2.c | 1 + drivers/thermal/qcom/tsens.c | 5 +++++ drivers/thermal/qcom/tsens.h | 1 + 5 files changed, 22 insertions(+)
drivers/thermal/qcom/tsens-common.c +14 -0
@@ -69,6 +69,20 @@ void compute_intercept_slope(struct tsens_priv *priv, u32 *p1, } } +bool is_sensor_enabled (struct tsens_priv *priv,u32 hw_id) +{ +u32 val; +int ret; + +if ((hw_id > (priv->num_sensors -1 )) || (hw_id <0 )) +return -EINVAL ; + ret =regmap_field_read (priv->rf[SENSOR_EN ], &val); +if (ret) +return ret; + +return val & (1 << hw_id); +} +static inline int code_to_degc (u32 adc_code,const struct tsens_sensor *s) {int degc, num, den;
drivers/thermal/qcom/tsens-v0_1.c +1 -0
@@ -332,6 +332,7 @@ const struct reg_field tsens_v0_1_regfields[MAX_REGFIELDS] = { /* CTRL_OFFSET */ [TSENS_EN] = REG_FIELD(SROT_CTRL_OFF, 0, 0), [TSENS_SW_RST] = REG_FIELD(SROT_CTRL_OFF, 1, 1), + [SENSOR_EN] = REG_FIELD(SROT_CTRL_OFF, 3, 13),/* ----- TM ------ */ /* UPPER_LOWER_INTERRUPT_CTRL */
drivers/thermal/qcom/tsens-v2.c +1 -0
@@ -99,6 +99,7 @@ const struct reg_field tsens_v2_regfields[MAX_REGFIELDS] = { /* CTRL_OFF */ [TSENS_EN] = REG_FIELD(SROT_CTRL_OFF, 0, 0), [TSENS_SW_RST] = REG_FIELD(SROT_CTRL_OFF, 1, 1), + [SENSOR_EN] = REG_FIELD(SROT_CTRL_OFF, 3, 18),/* ----- TM ------ */ /* INTERRUPT ENABLE */
drivers/thermal/qcom/tsens.c +5 -0
@@ -82,6 +82,11 @@ static int tsens_register(struct tsens_priv *priv)struct thermal_zone_device *tzd;for (i =0 ; i < priv->num_sensors; i++) { +if (!is_sensor_enabled (priv, priv->sensor[i].hw_id)) { +dev_err (priv->dev,"sensor %d: disabled\n" , + priv->sensor[i].hw_id); +continue ; + } priv->sensor[i].priv = priv; priv->sensor[i].id = i; tzd = devm_thermal_zone_of_sensor_register(priv->dev, i,
drivers/thermal/qcom/tsens.h +1 -0
@@ -254,6 +254,7 @@ char *qfprom_read(struct device *dev, const char *cname);void compute_intercept_slope (struct tsens_priv *priv,u32 *pt1,u32 *pt2,u32 mode);int init_common (struct tsens_priv *priv);int get_temp_common (struct tsens_priv *priv,int i,int *temp); +bool is_sensor_enabled (struct tsens_priv *priv,u32 hw_id);/* TSENS target */ extern const struct tsens_plat_data data_8960;
Signature · 1 line
2.17.1
PATCH 15/24 drivers: thermal: tsens: change data type for sensor IDs
In reply to Amit KucheriaThe IDs cannot be negative, fix the data type.
--- drivers/thermal/qcom/tsens.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/thermal/qcom/tsens.h +2 -2
@@ -29,8 +29,8 @@ struct tsens_sensor {struct tsens_priv *priv;struct thermal_zone_device *tzd;int offset; -int id; -int hw_id; +unsigned int id; +unsigned int hw_id;int slope;u32 status; };
Signature · 1 line
2.17.1
PATCH 16/24 drivers: thermal: tsens: Introduce IP-specific max_sensor count
In reply to Amit KucheriaThe IP can support 'm' sensors while the platform can enable 'n' sensors of the 'm' where n <= m.
Track maximum sensors supported by the IP so that we can correctly track what subset of the sensors are supported on the platform.
--- drivers/thermal/qcom/tsens-common.c | 4 ++-- drivers/thermal/qcom/tsens-v0_1.c | 1 + drivers/thermal/qcom/tsens-v2.c | 1 + drivers/thermal/qcom/tsens.h | 2 ++ 4 files changed, 6 insertions(+), 2 deletions(-)
drivers/thermal/qcom/tsens-common.c +2 -2
@@ -208,13 +208,13 @@ int __init init_common(struct tsens_priv *priv)return PTR_ERR (priv->rf[SENSOR_EN ]);/* now alloc regmap_fields in tm_map */ -for (i =0 , j =LAST_TEMP_0 ; i < priv->num_sensors; i++, j++) { +for (i =0 , j =LAST_TEMP_0 ; i < priv->feat->max_sensors; i++, j++) { priv->rf[j] =devm_regmap_field_alloc (dev, priv->tm_map, priv->fields[j]);if (IS_ERR (priv->rf[j]))return PTR_ERR (priv->rf[j]); } -for (i =0 , j =VALID_0 ; i < priv->num_sensors; i++, j++) { +for (i =0 , j =VALID_0 ; i < priv->feat->max_sensors; i++, j++) { priv->rf[j] =devm_regmap_field_alloc (dev, priv->tm_map, priv->fields[j]);if (IS_ERR (priv->rf[j]))
drivers/thermal/qcom/tsens-v0_1.c +1 -0
@@ -324,6 +324,7 @@ const struct tsens_features tsens_v0_1_feat = { .crit_int = 0, .adc = 1, .srot_split = 1, + .max_sensors = 11, };/* v0.1: 8916, 8974 */
drivers/thermal/qcom/tsens-v2.c +1 -0
@@ -88,6 +88,7 @@ const struct tsens_features tsens_v2_feat = { .crit_int = 1, .adc = 0, .srot_split = 1, + .max_sensors = 16, };const struct reg_field tsens_v2_regfields[MAX_REGFIELDS ] = {
drivers/thermal/qcom/tsens.h +2 -0
@@ -189,12 +189,14 @@ enum regfield_ids {* @adc: do the sensors only output adc code (instead of temperature)? * @srot_split: does the IP neatly splits the register space into SROT and TM, * with SROT only being available to secure boot firmware? +* @max_sensors: maximum sensors supported by this version of the IP */ struct tsens_features {unsigned int ver_info:1 ;unsigned int crit_int:1 ;unsigned int adc:1 ;unsigned int srot_split:1 ; +unsigned int max_sensors; };/**
Signature · 1 line
2.17.1
PATCH 17/24 drivers: thermal: tsens: simplify get_temp_tsens_v2 routine
In reply to Amit KucheriaThe current implementation is based on an algorithm published in the docs. Instead of reading the temperature thrice w/o any explanation, improve the algorithm.
This will become the basis for a common get_temp routine in the future.
--- drivers/thermal/qcom/tsens-v2.c | 55 ++++++++++----------------------- 1 file changed, 17 insertions(+), 38 deletions(-)
drivers/thermal/qcom/tsens-v2.c +17 -38
@@ -25,58 +25,37 @@#define TM_Sn_STATUS_OFF 0x00a0#define TM_TRDY_OFF 0x00e4 -#define LAST_TEMP_MASK 0xfff - -static int get_temp_tsens_v2 (struct tsens_priv *priv,int id,int *temp) +static int get_temp_tsens_v2 (struct tsens_priv *priv,int i,int *temp) { -struct tsens_sensor *s = &priv->sensor[id]; +struct tsens_sensor *s = &priv->sensor[i];u32 temp_idx =LAST_TEMP_0 + s->hw_id;u32 valid_idx =VALID_0 + s->hw_id; -u32 last_temp =0 , last_temp2 =0 , last_temp3 =0 , valid; +u32 last_temp =0 , valid, mask;int ret; - ret =regmap_field_read (priv->rf[temp_idx], &last_temp); -if (ret) -return ret; - ret =regmap_field_read (priv->rf[valid_idx], &valid);if (ret)return ret; - -if (valid) - goto done; - -/* Try a second time */ - ret =regmap_field_read (priv->rf[valid_idx], &valid); -if (ret) -return ret; - ret =regmap_field_read (priv->rf[temp_idx], &last_temp2); -if (ret) -return ret; -if (valid) { - last_temp = last_temp2; - goto done; +while (!valid) { +/* Valid bit is 0 for 6 AHB clock cycles. +* At 19.2MHz, 1 AHB clock is ~60ns. +* We should enter this loop very, very rarely. +*/ +ndelay (400 ); + ret =regmap_field_read (priv->rf[valid_idx], &valid); +if (ret) +return ret; } -/* Try a third/last time */ - ret =regmap_field_read (priv->rf[valid_idx], &valid); -if (ret) -return ret; - ret =regmap_field_read (priv->rf[temp_idx], &last_temp3); +/* Valid bit is set, OK to read the temperature */ + ret =regmap_field_read (priv->rf[temp_idx], &last_temp);if (ret)return ret; -if (valid) { - last_temp = last_temp3; - goto done; - } -if (last_temp == last_temp2) - last_temp = last_temp2; -else if (last_temp2 == last_temp3) - last_temp = last_temp3; -done: + mask =GENMASK (priv->fields[LAST_TEMP_0 ].msb, + priv->fields[LAST_TEMP_0 ].lsb);/* Convert temperature from deciCelsius to milliCelsius */ - *temp =sign_extend32 (last_temp,fls (LAST_TEMP_MASK ) -1 ) *100 ; + *temp =sign_extend32 (last_temp,fls (mask) -1 ) *100 ;return 0 ; }
Signature · 1 line
2.17.1
PATCH 18/24 drivers: thermal: tsens: Move get_temp_tsens_v2 to allow sharing
In reply to Amit KucheriaJust rename the function and move it to allow code sharing with future versions of TSENS IP
--- drivers/thermal/qcom/tsens-common.c | 35 +++++++++++++++++++++++++++ drivers/thermal/qcom/tsens-v2.c | 37 +---------------------------- drivers/thermal/qcom/tsens.h | 1 + 3 files changed, 37 insertions(+), 36 deletions(-)
drivers/thermal/qcom/tsens-common.c +35 -0
@@ -102,6 +102,41 @@ static inline int code_to_degc(u32 adc_code, const struct tsens_sensor *s)return degc; } +int get_temp_tsens_valid (struct tsens_priv *priv,int i,int *temp) +{ +struct tsens_sensor *s = &priv->sensor[i]; +u32 temp_idx =LAST_TEMP_0 + s->hw_id; +u32 valid_idx =VALID_0 + s->hw_id; +u32 last_temp =0 , valid, mask; +int ret; + + ret =regmap_field_read (priv->rf[valid_idx], &valid); +if (ret) +return ret; +while (!valid) { +/* Valid bit is 0 for 6 AHB clock cycles. +* At 19.2MHz, 1 AHB clock is ~60ns. +* We should enter this loop very, very rarely. +*/ +ndelay (400 ); + ret =regmap_field_read (priv->rf[valid_idx], &valid); +if (ret) +return ret; + } + +/* Valid bit is set, OK to read the temperature */ + ret =regmap_field_read (priv->rf[temp_idx], &last_temp); +if (ret) +return ret; + + mask =GENMASK (priv->fields[LAST_TEMP_0 ].msb, + priv->fields[LAST_TEMP_0 ].lsb); +/* Convert temperature from deciCelsius to milliCelsius */ + *temp =sign_extend32 (last_temp,fls (mask) -1 ) *100 ; + +return 0 ; +} +int get_temp_common (struct tsens_priv *priv,int i,int *temp) {struct tsens_sensor *s = &priv->sensor[i];
drivers/thermal/qcom/tsens-v2.c +1 -36
@@ -25,41 +25,6 @@#define TM_Sn_STATUS_OFF 0x00a0#define TM_TRDY_OFF 0x00e4 -static int get_temp_tsens_v2 (struct tsens_priv *priv,int i,int *temp) -{ -struct tsens_sensor *s = &priv->sensor[i]; -u32 temp_idx =LAST_TEMP_0 + s->hw_id; -u32 valid_idx =VALID_0 + s->hw_id; -u32 last_temp =0 , valid, mask; -int ret; - - ret =regmap_field_read (priv->rf[valid_idx], &valid); -if (ret) -return ret; -while (!valid) { -/* Valid bit is 0 for 6 AHB clock cycles. -* At 19.2MHz, 1 AHB clock is ~60ns. -* We should enter this loop very, very rarely. -*/ -ndelay (400 ); - ret =regmap_field_read (priv->rf[valid_idx], &valid); -if (ret) -return ret; - } - -/* Valid bit is set, OK to read the temperature */ - ret =regmap_field_read (priv->rf[temp_idx], &last_temp); -if (ret) -return ret; - - mask =GENMASK (priv->fields[LAST_TEMP_0 ].msb, - priv->fields[LAST_TEMP_0 ].lsb); -/* Convert temperature from deciCelsius to milliCelsius */ - *temp =sign_extend32 (last_temp,fls (mask) -1 ) *100 ; - -return 0 ; -} -/* v2.x: 8996, 8998, sdm845 */ const struct tsens_features tsens_v2_feat = {
@@ -136,7 +101,7 @@ const struct reg_field tsens_v2_regfields[MAX_REGFIELDS] = {static const struct tsens_ops ops_generic_v2 = { .init = init_common, - .get_temp = get_temp_tsens_v2, + .get_temp = get_temp_tsens_valid, };const struct tsens_plat_data data_tsens_v2 = {
drivers/thermal/qcom/tsens.h +1 -0
@@ -255,6 +255,7 @@ struct tsens_priv {char *qfprom_read (struct device *dev,const char *cname);void compute_intercept_slope (struct tsens_priv *priv,u32 *pt1,u32 *pt2,u32 mode);int init_common (struct tsens_priv *priv); +int get_temp_tsens_valid (struct tsens_priv *priv,int i,int *temp);int get_temp_common (struct tsens_priv *priv,int i,int *temp);bool is_sensor_enabled (struct tsens_priv *priv,u32 hw_id);
Signature · 1 line
2.17.1
PATCH 19/24 drivers: thermal: tsens: Common get_temp() learns to do ADC conversion
In reply to Amit Kucheriaget_temp() learns to return temperature regardless of whether it is returned as ADC code or direct temperature.
--- drivers/thermal/qcom/tsens-common.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
drivers/thermal/qcom/tsens-common.c +9 -4
@@ -129,10 +129,15 @@ int get_temp_tsens_valid(struct tsens_priv *priv, int i, int *temp)if (ret)return ret; - mask =GENMASK (priv->fields[LAST_TEMP_0 ].msb, - priv->fields[LAST_TEMP_0 ].lsb); -/* Convert temperature from deciCelsius to milliCelsius */ - *temp =sign_extend32 (last_temp,fls (mask) -1 ) *100 ; +if (priv->feat->adc) { +/* Convert temperature from ADC code to milliCelsius */ + *temp =code_to_degc (last_temp, s) *1000 ; + }else { + mask =GENMASK (priv->fields[LAST_TEMP_0 ].msb, + priv->fields[LAST_TEMP_0 ].lsb); +/* Convert temperature from deciCelsius to milliCelsius */ + *temp =sign_extend32 (last_temp,fls (mask) -1 ) *100 ; + }return 0 ; }
Signature · 1 line
2.17.1
PATCH 20/24 dt: thermal: tsens: Add bindings for qcs404
In reply to Amit Kucheriaqcs404 uses v1 of the TSENS IP block. Create a fallback DT property "qcom,tsens-v1" to gather common code
--- .../devicetree/bindings/thermal/qcom-tsens.txt | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
Documentation/devicetree/bindings/thermal/qcom-tsens.txt +14 -0
@@ -6,11 +6,14 @@ Required properties: - "qcom,msm8916-tsens" (MSM8916) - "qcom,msm8974-tsens" (MSM8974) - "qcom,msm8996-tsens" (MSM8996) + - "qcom,qcs404-tsens", "qcom,tsens-v1" (QCS404) - "qcom,msm8998-tsens", "qcom,tsens-v2" (MSM8998) - "qcom,sdm845-tsens", "qcom,tsens-v2" (SDM845) The generic "qcom,tsens-v2" property must be used as a fallback for any SoC with version 2 of the TSENS IP. MSM8996 is the only exception because the generic property did not exist when support was added. + Similarly, the generic "qcom,tsens-v1" property must be used as a fallback for + any SoC with version 1 of the TSENS IP. - reg: Address range of the thermal registers. New platforms containing v2.x.y of the TSENS IP must specify the SROT and TM
@@ -39,3 +42,14 @@ tsens0: thermal-sensor@c263000 { #qcom,sensors = <13>; #thermal-sensor-cells = <1>; }; + +Example 3 (for any platform containing v1 of the TSENS IP): +tsens: thermal-sensor@4a9000 { + compatible = "qcom,qcs404-tsens", "qcom,tsens-v1"; + reg = <0x004a9000 0x1000>, /* TM */ + <0x004a8000 0x1000>; /* SROT */ + nvmem-cells = <&tsens_caldata>; + nvmem-cell-names = "calib"; + #qcom,sensors = <10>; + #thermal-sensor-cells = <1>; + };
Signature · 1 line
2.17.1
PATCH 21/24 drivers: thermal: tsens: Add generic support for TSENS v1 IP
In reply to Amit Kucheriaqcs404 has a single TSENS IP block with 10 sensors. It uses version 1.4 of the TSENS IP, functionality for which is encapsulated inside the qcom,tsens-v1 compatible.
--- drivers/thermal/qcom/Makefile | 4 +- drivers/thermal/qcom/tsens-v1.c | 229 ++++++++++++++++++++++++++++++++ drivers/thermal/qcom/tsens.c | 3 + drivers/thermal/qcom/tsens.h | 3 + 4 files changed, 238 insertions(+), 1 deletion(-) create mode 100644 drivers/thermal/qcom/tsens-v1.c
drivers/thermal/qcom/Makefile +3 -1
@@ -1,3 +1,5 @@ obj-$(CONFIG_QCOM_TSENS) += qcom_tsens.o -qcom_tsens-y += tsens.o tsens-common.o tsens-v0_1.o tsens-8960.o tsens-v2.o + +qcom_tsens-y += tsens.o tsens-common.o tsens-v0_1.o \ + tsens-8960.o tsens-v2.o tsens-v1.o obj-$(CONFIG_QCOM_SPMI_TEMP_ALARM) += qcom-spmi-temp-alarm.o
drivers/thermal/qcom/tsens-v1.c new file +229 -0
229 lines not on this page · raw message
drivers/thermal/qcom/tsens.c +3 -0
@@ -63,6 +63,9 @@ static const struct of_device_id tsens_table[] = { }, { .compatible = "qcom,msm8996-tsens", .data = &data_8996, + }, { + .compatible = "qcom,tsens-v1", + .data = &data_tsens_v1, }, { .compatible = "qcom,tsens-v2", .data = &data_tsens_v2,
drivers/thermal/qcom/tsens.h +3 -0
@@ -265,6 +265,9 @@ extern const struct tsens_plat_data data_8960;/* TSENS v0.1 targets */ extern const struct tsens_plat_data data_8916, data_8974; +/* TSENS v1 targets */ +extern const struct tsens_plat_data data_tsens_v1; +/* TSENS v2 targets */ extern const struct tsens_plat_data data_8996, data_tsens_v2;
Signature · 1 line
2.17.1
PATCH 22/24 arm64: dts: qcom: qcs404: Add tsens controller
In reply to Amit Kucheriaqcs404 has a single TSENS IP block with 10 sensors. The calibration data is stored in an eeprom (qfprom) that is accessed through the nvmem framework. We add the qfprom node to allow the tsens sensors to be calibrated correctly.
--- arch/arm64/boot/dts/qcom/qcs404.dtsi | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
arch/arm64/boot/dts/qcom/qcs404.dtsi +20 -0
@@ -253,6 +253,16 @@ reg = <0x00060000 0x6000>; }; + qfprom: qfprom@a4000 { + compatible = "qcom,qfprom"; + reg = <0x000a4000 0x1000>; + #address-cells = <1>; + #size-cells = <1>; + tsens_caldata: caldata@d0 { + reg = <0x1f8 0x14>; + }; + }; + rng: rng@e3000 { compatible = "qcom,prng-ee"; reg = <0x000e3000 0x1000>;
@@ -260,6 +270,16 @@ clock-names = "core"; }; + tsens: thermal-sensor@4a9000 { + compatible = "qcom,qcs404-tsens", "qcom,tsens-v1"; + reg = <0x004a9000 0x1000>, /* TM */ + <0x004a8000 0x1000>; /* SROT */ + nvmem-cells = <&tsens_caldata>; + nvmem-cell-names = "calib"; + #qcom,sensors = <10>; + #thermal-sensor-cells = <1>; + }; + tlmm: pinctrl@1000000 { compatible = "qcom,qcs404-pinctrl"; reg = <0x01000000 0x200000>,
Signature · 1 line
2.17.1
PATCH 23/24 arm64: dts: qcom: qcs404: Add thermal zones for each sensor
In reply to Amit Kucheriaqcs404 has 10 sensors connected to the single TSENS IP. Define a thermal zone for each of those sensors to expose the temperature of each zone.
--- arch/arm64/boot/dts/qcom/qcs404.dtsi | 243 +++++++++++++++++++++++++++ 1 file changed, 243 insertions(+)
arch/arm64/boot/dts/qcom/qcs404.dtsi +243 -0
@@ -3,6 +3,7 @@ #include <dt-bindings/interrupt-controller/arm-gic.h> #include <dt-bindings/clock/qcom,gcc-qcs404.h> +#include <dt-bindings/thermal/thermal.h> / { interrupt-parent = <&intc>;
@@ -30,6 +31,7 @@ reg = <0x100>; enable-method = "psci"; next-level-cache = <&L2_0>; + #cooling-cells= <2>; }; CPU1: cpu@101 {
@@ -38,6 +40,7 @@ reg = <0x101>; enable-method = "psci"; next-level-cache = <&L2_0>; + #cooling-cells= <2>; }; CPU2: cpu@102 {
@@ -46,6 +49,7 @@ reg = <0x102>; enable-method = "psci"; next-level-cache = <&L2_0>; + #cooling-cells= <2>; }; CPU3: cpu@103 {
@@ -54,6 +58,7 @@ reg = <0x103>; enable-method = "psci"; next-level-cache = <&L2_0>; + #cooling-cells= <2>; }; L2_0: l2-cache {
@@ -507,4 +512,242 @@ #interrupt-cells = <2>; }; }; + + thermal-zones { + aoss-thermal { + polling-delay-passive = <250>; + polling-delay = <1000>; + + thermal-sensors = <&tsens 0>; + + trips { + aoss_alert0: trip-point@0 { + temperature = <95000>; + hysteresis = <2000>; + type = "passive"; + }; + aoss_crit: aoss_crit { + temperature = <110000>; + hysteresis = <2000>; + type = "critical"; + }; + }; + }; + + dsp-thermal { + polling-delay-passive = <250>; + polling-delay = <1000>; + + thermal-sensors = <&tsens 1>; + + trips { + dsp_alert0: trip-point@0 { + temperature = <95000>; + hysteresis = <2000>; + type = "passive"; + }; + dsp_crit: dsp_crit { + temperature = <110000>; + hysteresis = <2000>; + type = "critical"; + }; + }; + }; + + lpass-thermal { + polling-delay-passive = <250>; + polling-delay = <1000>; + + thermal-sensors = <&tsens 2>; + + trips { + lpass_alert0: trip-point@0 { + temperature = <95000>; + hysteresis = <2000>; + type = "passive"; + }; + lpass_crit: lpass_crit { + temperature = <110000>; + hysteresis = <2000>; + type = "critical"; + }; + }; + }; + + wlan-thermal { + polling-delay-passive = <250>; + polling-delay = <1000>; + + thermal-sensors = <&tsens 3>; + + trips { + wlan_alert0: trip-point@0 { + temperature = <95000>; + hysteresis = <2000>; + type = "passive"; + }; + wlan_crit: wlan_crit { + temperature = <110000>; + hysteresis = <2000>; + type = "critical"; + }; + }; + }; + + cluster-thermal { + polling-delay-passive = <250>; + polling-delay = <1000>; + + thermal-sensors = <&tsens 4>; + + trips { + cluster_alert0: trip-point@0 { + temperature = <95000>; + hysteresis = <2000>; + type = "passive"; + }; + cluster_crit: cluster_crit { + temperature = <110000>; + hysteresis = <2000>; + type = "critical"; + }; + }; + }; + + cpu0-thermal { + polling-delay-passive = <250>; + polling-delay = <1000>; + + thermal-sensors = <&tsens 5>; + + trips { + cpu0_alert0: trip-point@0 { + temperature = <95000>; + hysteresis = <2000>; + type = "passive"; + }; + cpu0_crit: cpu_crit { + temperature = <110000>; + hysteresis = <2000>; + type = "critical"; + }; + }; + cooling-maps { + map0 { + trip = <&cpu0_alert0>; + cooling-device = <&CPU0 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&CPU1 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&CPU2 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&CPU3 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>; + }; + }; + }; + + cpu1-thermal { + polling-delay-passive = <250>; + polling-delay = <1000>; + + thermal-sensors = <&tsens 6>; + + trips { + cpu1_alert0: trip-point@0 { + temperature = <95000>; + hysteresis = <2000>; + type = "passive"; + }; + cpu1_crit: cpu_crit { + temperature = <110000>; + hysteresis = <2000>; + type = "critical"; + }; + }; + cooling-maps { + map0 { + trip = <&cpu1_alert0>; + cooling-device = <&CPU0 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&CPU1 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&CPU2 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&CPU3 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>; + }; + }; + }; + + cpu2-thermal { + polling-delay-passive = <250>; + polling-delay = <1000>; + + thermal-sensors = <&tsens 7>; + + trips { + cpu2_alert0: trip-point@0 { + temperature = <95000>; + hysteresis = <2000>; + type = "passive"; + }; + cpu2_crit: cpu_crit { + temperature = <110000>; + hysteresis = <2000>; + type = "critical"; + }; + }; + cooling-maps { + map0 { + trip = <&cpu2_alert0>; + cooling-device = <&CPU0 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&CPU1 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&CPU2 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&CPU3 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>; + }; + }; + }; + + cpu3-thermal { + polling-delay-passive = <250>; + polling-delay = <1000>; + + thermal-sensors = <&tsens 8>; + + trips { + cpu3_alert0: trip-point@0 { + temperature = <95000>; + hysteresis = <2000>; + type = "passive"; + }; + cpu3_crit: cpu_crit { + temperature = <110000>; + hysteresis = <2000>; + type = "critical"; + }; + }; + cooling-maps { + map0 { + trip = <&cpu3_alert0>; + cooling-device = <&CPU0 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&CPU1 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&CPU2 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&CPU3 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>; + }; + }; + }; + + gpu-thermal { + polling-delay-passive = <250>; + polling-delay = <1000>; + + thermal-sensors = <&tsens 9>; + + trips { + gpu_alert0: trip-point@0 { + temperature = <95000>; + hysteresis = <2000>; + type = "passive"; + }; + gpu_crit: gpu_crit { + temperature = <95000>; + hysteresis = <2000>; + type = "critical"; + }; + }; + }; + }; };
Signature · 1 line
2.17.1
PATCH 24/24 drivers: thermal: tsens: Move calibration constants to header file
In reply to Amit KucheriaThis will allow calibration routines to correctly include the constants from anywhere and allow more code sharing.
--- drivers/thermal/qcom/tsens-common.c | 5 ----- drivers/thermal/qcom/tsens.h | 5 +++++ 2 files changed, 5 insertions(+), 5 deletions(-)
drivers/thermal/qcom/tsens-common.c +0 -5
@@ -12,11 +12,6 @@#include <linux/regmap.h> #include "tsens.h" -#define CAL_DEGC_PT1 30 -#define CAL_DEGC_PT2 120 -#define SLOPE_FACTOR 1000 -#define SLOPE_DEFAULT 3200 -char *qfprom_read (struct device *dev,const char *cname) {struct nvmem_cell *cell;
drivers/thermal/qcom/tsens.h +5 -0
@@ -9,6 +9,11 @@#define ONE_PT_CALIB 0x1#define ONE_PT_CALIB2 0x2#define TWO_PT_CALIB 0x3 +#define CAL_DEGC_PT1 30 +#define CAL_DEGC_PT2 120 +#define SLOPE_FACTOR 1000 +#define SLOPE_DEFAULT 3200 +#include <linux/thermal.h> #include <linux/regmap.h>
Signature · 1 line
2.17.1
Re: [PATCH v1 23/24] arm64: dts: qcom: qcs404: Add thermal zones for each sensor
In reply to Amit KucheriaQuoted 53 lines · Amit Kucheria
qcs404 has 10 sensors connected to the single TSENS IP. Define a thermal zone for each of those sensors to expose the temperature of each zone.
Signed-off-by Amit Kucheria <[email protected]>--- arch/arm64/boot/dts/qcom/qcs404.dtsi | 243 +++++++++++++++++++++++++++ 1 file changed, 243 insertions(+)arch/arm64/boot/dts/qcom/qcs404.dtsi +5
-0@@ -3,6 +3,7 @@ #include <dt-bindings/interrupt-controller/arm-gic.h> #include <dt-bindings/clock/qcom,gcc-qcs404.h> +#include <dt-bindings/thermal/thermal.h> / { interrupt-parent = <&intc>;@@ -30,6 +31,7 @@ reg = <0x100>; enable-method = "psci"; next-level-cache = <&L2_0>; + #cooling-cells= <2>; }; CPU1: cpu@101 {@@ -38,6 +40,7 @@ reg = <0x101>; enable-method = "psci"; next-level-cache = <&L2_0>; + #cooling-cells= <2>; }; CPU2: cpu@102 {@@ -46,6 +49,7 @@ reg = <0x102>; enable-method = "psci"; next-level-cache = <&L2_0>; + #cooling-cells= <2>; }; CPU3: cpu@103 {@@ -54,6 +58,7 @@ reg = <0x103>; enable-method = "psci"; next-level-cache = <&L2_0>; + #cooling-cells= <2>; }; L2_0: l2-cache {
arch/arm64/boot/dts/qcom/qcs404.dtsi line 516
Quoted 5 lines
arch/arm64/boot/dts/qcom/qcs404.dtsi +2
-0@@ -507,4 +512,242 @@ #interrupt-cells = <2>; }; }; + + thermal-zones {
There are several zones with passive trips and no cooling maps.
Quoted 240 lines
arch/arm64/boot/dts/qcom/qcs404.dtsi +236
-0+ aoss-thermal { + polling-delay-passive = <250>; + polling-delay = <1000>; + + thermal-sensors = <&tsens 0>; + + trips { + aoss_alert0: trip-point@0 { + temperature = <95000>; + hysteresis = <2000>; + type = "passive"; + }; + aoss_crit: aoss_crit { + temperature = <110000>; + hysteresis = <2000>; + type = "critical"; + }; + }; + }; + + dsp-thermal { + polling-delay-passive = <250>; + polling-delay = <1000>; + + thermal-sensors = <&tsens 1>; + + trips { + dsp_alert0: trip-point@0 { + temperature = <95000>; + hysteresis = <2000>; + type = "passive"; + }; + dsp_crit: dsp_crit { + temperature = <110000>; + hysteresis = <2000>; + type = "critical"; + }; + }; + }; + + lpass-thermal { + polling-delay-passive = <250>; + polling-delay = <1000>; + + thermal-sensors = <&tsens 2>; + + trips { + lpass_alert0: trip-point@0 { + temperature = <95000>; + hysteresis = <2000>; + type = "passive"; + }; + lpass_crit: lpass_crit { + temperature = <110000>; + hysteresis = <2000>; + type = "critical"; + }; + }; + }; + + wlan-thermal { + polling-delay-passive = <250>; + polling-delay = <1000>; + + thermal-sensors = <&tsens 3>; + + trips { + wlan_alert0: trip-point@0 { + temperature = <95000>; + hysteresis = <2000>; + type = "passive"; + }; + wlan_crit: wlan_crit { + temperature = <110000>; + hysteresis = <2000>; + type = "critical"; + }; + }; + }; + + cluster-thermal { + polling-delay-passive = <250>; + polling-delay = <1000>; + + thermal-sensors = <&tsens 4>; + + trips { + cluster_alert0: trip-point@0 { + temperature = <95000>; + hysteresis = <2000>; + type = "passive"; + }; + cluster_crit: cluster_crit { + temperature = <110000>; + hysteresis = <2000>; + type = "critical"; + }; + }; + }; + + cpu0-thermal { + polling-delay-passive = <250>; + polling-delay = <1000>; + + thermal-sensors = <&tsens 5>; + + trips { + cpu0_alert0: trip-point@0 { + temperature = <95000>; + hysteresis = <2000>; + type = "passive"; + }; + cpu0_crit: cpu_crit { + temperature = <110000>; + hysteresis = <2000>; + type = "critical"; + }; + }; + cooling-maps { + map0 { + trip = <&cpu0_alert0>; + cooling-device = <&CPU0 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&CPU1 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&CPU2 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&CPU3 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>; + }; + }; + }; + + cpu1-thermal { + polling-delay-passive = <250>; + polling-delay = <1000>; + + thermal-sensors = <&tsens 6>; + + trips { + cpu1_alert0: trip-point@0 { + temperature = <95000>; + hysteresis = <2000>; + type = "passive"; + }; + cpu1_crit: cpu_crit { + temperature = <110000>; + hysteresis = <2000>; + type = "critical"; + }; + }; + cooling-maps { + map0 { + trip = <&cpu1_alert0>; + cooling-device = <&CPU0 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&CPU1 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&CPU2 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&CPU3 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>; + }; + }; + }; + + cpu2-thermal { + polling-delay-passive = <250>; + polling-delay = <1000>; + + thermal-sensors = <&tsens 7>; + + trips { + cpu2_alert0: trip-point@0 { + temperature = <95000>; + hysteresis = <2000>; + type = "passive"; + }; + cpu2_crit: cpu_crit { + temperature = <110000>; + hysteresis = <2000>; + type = "critical"; + }; + }; + cooling-maps { + map0 { + trip = <&cpu2_alert0>; + cooling-device = <&CPU0 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&CPU1 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&CPU2 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&CPU3 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>; + }; + }; + }; + + cpu3-thermal { + polling-delay-passive = <250>; + polling-delay = <1000>; + + thermal-sensors = <&tsens 8>; + + trips { + cpu3_alert0: trip-point@0 { + temperature = <95000>; + hysteresis = <2000>; + type = "passive"; + }; + cpu3_crit: cpu_crit { + temperature = <110000>; + hysteresis = <2000>; + type = "critical"; + }; + }; + cooling-maps { + map0 { + trip = <&cpu3_alert0>; + cooling-device = <&CPU0 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&CPU1 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&CPU2 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&CPU3 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>; + }; + }; + }; + + gpu-thermal { + polling-delay-passive = <250>; + polling-delay = <1000>; + + thermal-sensors = <&tsens 9>; + + trips { + gpu_alert0: trip-point@0 { + temperature = <95000>; + hysteresis = <2000>; + type = "passive"; + }; + gpu_crit: gpu_crit { + temperature = <95000>; + hysteresis = <2000>; + type = "critical"; + }; + }; + }; + }; };Signature · 1 line
2.17.1
Re: [PATCH v1 21/24] drivers: thermal: tsens: Add generic support for TSENS v1 IP
In reply to Amit KucheriaQuoted 97 lines · Amit Kucheria
qcs404 has a single TSENS IP block with 10 sensors. It uses version 1.4 of the TSENS IP, functionality for which is encapsulated inside the qcom,tsens-v1 compatible.
Signed-off-by Amit Kucheria <[email protected]>--- drivers/thermal/qcom/Makefile | 4 +- drivers/thermal/qcom/tsens-v1.c | 229 ++++++++++++++++++++++++++++++++ drivers/thermal/qcom/tsens.c | 3 + drivers/thermal/qcom/tsens.h | 3 + 4 files changed, 238 insertions(+), 1 deletion(-) create mode 100644 drivers/thermal/qcom/tsens-v1.cdrivers/thermal/qcom/Makefile +3
-1@@ -1,3 +1,5 @@ obj-$(CONFIG_QCOM_TSENS) += qcom_tsens.o -qcom_tsens-y += tsens.o tsens-common.o tsens-v0_1.o tsens-8960.o tsens-v2.o + +qcom_tsens-y += tsens.o tsens-common.o tsens-v0_1.o \ + tsens-8960.o tsens-v2.o tsens-v1.o obj-$(CONFIG_QCOM_SPMI_TEMP_ALARM) += qcom-spmi-temp-alarm.odrivers/thermal/qcom/tsens-v1.c new file +67
-0@@ -0,0 +1,229 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Copyright (c) 2019, Linaro Limited +*/ + +#include <linux/bitops.h> +#include <linux/regmap.h> +#include <linux/delay.h> +#include "tsens.h" + +/* ----- SROT ------ */ +#define SROT_HW_VER_OFF 0x0000 +#define SROT_CTRL_OFF 0x0004 + +/* ----- TM ------ */ +#define TM_INT_EN_OFF 0x0000 +#define TM_Sn_UPPER_LOWER_STATUS_CTRL_OFF 0x0004 +#define TM_Sn_STATUS_OFF 0x0044 +#define TM_TRDY_OFF 0x0084 + +/* eeprom layout data for qcs404/405 (v1) */ +#define BASE0_MASK 0x000007f8 +#define BASE1_MASK 0x0007f800 +#define BASE0_SHIFT 3 +#define BASE1_SHIFT 11 + +#define S0_P1_MASK 0x0000003f +#define S1_P1_MASK 0x0003f000 +#define S2_P1_MASK 0x3f000000 +#define S3_P1_MASK 0x000003f0 +#define S4_P1_MASK 0x003f0000 +#define S5_P1_MASK 0x0000003f +#define S6_P1_MASK 0x0003f000 +#define S7_P1_MASK 0x3f000000 +#define S8_P1_MASK 0x000003f0 +#define S9_P1_MASK 0x003f0000 + +#define S0_P2_MASK 0x00000fc0 +#define S1_P2_MASK 0x00fc0000 +#define S2_P2_MASK_1_0 0xc0000000 +#define S2_P2_MASK_5_2 0x0000000f +#define S3_P2_MASK 0x0000fc00 +#define S4_P2_MASK 0x0fc00000 +#define S5_P2_MASK 0x00000fc0 +#define S6_P2_MASK 0x00fc0000 +#define S7_P2_MASK_1_0 0xc0000000 +#define S7_P2_MASK_5_2 0x0000000f +#define S8_P2_MASK 0x0000fc00 +#define S9_P2_MASK 0x0fc00000 + +#define S0_P1_SHIFT 0 +#define S0_P2_SHIFT 6 +#define S1_P1_SHIFT 12 +#define S1_P2_SHIFT 18 +#define S2_P1_SHIFT 24 +#define S2_P2_SHIFT_1_0 30 + +#define S2_P2_SHIFT_5_2 0 +#define S3_P1_SHIFT 4 +#define S3_P2_SHIFT 10 +#define S4_P1_SHIFT 16 +#define S4_P2_SHIFT 22 + +#define S5_P1_SHIFT 0 +#define S5_P2_SHIFT 6 +#define S6_P1_SHIFT 12 +#define S6_P2_SHIFT 18
drivers/thermal/qcom/tsens-v1.c line 77
Quoted 10 lines
drivers/thermal/qcom/tsens-v1.c new file +10
-0+#define S7_P1_SHIFT 24 +#define S7_P2_SHIFT_1_0 30 + +#define S7_P2_SHIFT_5_2 0 +#define S8_P1_SHIFT 4 +#define S8_P2_SHIFT 10 +#define S9_P1_SHIFT 16 +#define S9_P2_SHIFT 22 + +#define CAL_SEL_MASK 7
Why not using the macros on bits.h?
Quoted 183 lines
drivers/thermal/qcom/tsens-v1.c new file +152
-0+#define CAL_SEL_SHIFT 0 + +static int calibrate_v1 (struct tsens_priv *priv) +{ +u32 base0 =0 , base1 =0 ; +u32 p1[10 ], p2[10 ]; +u32 mode =0 , lsb =0 , msb =0 ; +u32 *qfprom_cdata; +int i; + + qfprom_cdata = (u32 *)qfprom_read (priv->dev,"calib" ); +if (IS_ERR (qfprom_cdata)) +return PTR_ERR (qfprom_cdata); + + mode = (qfprom_cdata[4 ] &CAL_SEL_MASK ) >>CAL_SEL_SHIFT ; +dev_dbg (priv->dev,"calibration mode is %d\n" , mode); + +switch (mode) { +case TWO_PT_CALIB : + base1 = (qfprom_cdata[4 ] &BASE1_MASK ) >>BASE1_SHIFT ; + p2[0 ] = (qfprom_cdata[0 ] &S0_P2_MASK ) >>S0_P2_SHIFT ; + p2[1 ] = (qfprom_cdata[0 ] &S1_P2_MASK ) >>S1_P2_SHIFT ; +/* This value is split over two registers, 2 bits and 4 bits */ + lsb = (qfprom_cdata[0 ] &S2_P2_MASK_1_0 ) >>S2_P2_SHIFT_1_0 ; + msb = (qfprom_cdata[1 ] &S2_P2_MASK_5_2 ) >>S2_P2_SHIFT_5_2 ; + p2[2 ] = msb <<2 | lsb; + p2[3 ] = (qfprom_cdata[1 ] &S3_P2_MASK ) >>S3_P2_SHIFT ; + p2[4 ] = (qfprom_cdata[1 ] &S4_P2_MASK ) >>S4_P2_SHIFT ; + p2[5 ] = (qfprom_cdata[2 ] &S5_P2_MASK ) >>S5_P2_SHIFT ; + p2[6 ] = (qfprom_cdata[2 ] &S6_P2_MASK ) >>S6_P2_SHIFT ; +/* This value is split over two registers, 2 bits and 4 bits */ + lsb = (qfprom_cdata[2 ] &S7_P2_MASK_1_0 ) >>S7_P2_SHIFT_1_0 ; + msb = (qfprom_cdata[3 ] &S7_P2_MASK_5_2 ) >>S7_P2_SHIFT_5_2 ; + p2[7 ] = msb <<2 | lsb; + p2[8 ] = (qfprom_cdata[3 ] &S8_P2_MASK ) >>S8_P2_SHIFT ; + p2[9 ] = (qfprom_cdata[3 ] &S9_P2_MASK ) >>S9_P2_SHIFT ; +for (i =0 ; i < priv->num_sensors; i++) + p2[i] = ((base1 + p2[i]) <<2 ); +/* Fall through */ +case ONE_PT_CALIB2 : + base0 = (qfprom_cdata[4 ] &BASE0_MASK ) >>BASE0_SHIFT ; + p1[0 ] = (qfprom_cdata[0 ] &S0_P1_MASK ) >>S0_P1_SHIFT ; + p1[1 ] = (qfprom_cdata[0 ] &S1_P1_MASK ) >>S1_P1_SHIFT ; + p1[2 ] = (qfprom_cdata[0 ] &S2_P1_MASK ) >>S2_P1_SHIFT ; + p1[3 ] = (qfprom_cdata[1 ] &S3_P1_MASK ) >>S3_P1_SHIFT ; + p1[4 ] = (qfprom_cdata[1 ] &S4_P1_MASK ) >>S4_P1_SHIFT ; + p1[5 ] = (qfprom_cdata[2 ] &S5_P1_MASK ) >>S5_P1_SHIFT ; + p1[6 ] = (qfprom_cdata[2 ] &S6_P1_MASK ) >>S6_P1_SHIFT ; + p1[7 ] = (qfprom_cdata[2 ] &S7_P1_MASK ) >>S7_P1_SHIFT ; + p1[8 ] = (qfprom_cdata[3 ] &S8_P1_MASK ) >>S8_P1_SHIFT ; + p1[9 ] = (qfprom_cdata[3 ] &S9_P1_MASK ) >>S9_P1_SHIFT ; +for (i =0 ; i < priv->num_sensors; i++) + p1[i] = (((base0) + p1[i]) <<2 ); +break ; +default : +for (i =0 ; i < priv->num_sensors; i++) { + p1[i] =500 ; + p2[i] =780 ; + } +break ; + } + +compute_intercept_slope (priv, p1, p2, mode); + +return 0 ; +} + +/* v1.x: qcs404,405 */ + +const struct tsens_features tsens_v1_feat = { + .ver_info =1 , + .crit_int =0 , + .adc =1 , + .srot_split =1 , + .max_sensors =11 , +}; + +const struct reg_field tsens_v1_regfields[MAX_REGFIELDS ] = { +/* ----- SROT ------ */ +/* VERSION */ + [VER_MAJOR ] =REG_FIELD (SROT_HW_VER_OFF ,28 ,31 ), + [VER_MINOR ] =REG_FIELD (SROT_HW_VER_OFF ,16 ,27 ), + [VER_STEP ] =REG_FIELD (SROT_HW_VER_OFF ,0 ,15 ), +/* CTRL_OFFSET */ + [TSENS_EN ] =REG_FIELD (SROT_CTRL_OFF ,0 ,0 ), + [TSENS_SW_RST ] =REG_FIELD (SROT_CTRL_OFF ,1 ,1 ), + [SENSOR_EN ] =REG_FIELD (SROT_CTRL_OFF ,3 ,13 ), + +/* ----- TM ------ */ +/* UPPER_LOWER_INTERRUPT_CTRL */ + [INT_EN ] =REG_FIELD (TM_INT_EN_OFF ,0 ,0 ), +/* Sn_UPPER_LOWER_STATUS_CTRL */ +REG_BANK (LOW_THRESH ,0 , TM_Sn_UPPER_LOWER_STATUS_CTRL_OFF,0 ,9 ), +REG_BANK (LOW_THRESH ,1 , TM_Sn_UPPER_LOWER_STATUS_CTRL_OFF +4 ,0 ,9 ), +REG_BANK (LOW_THRESH ,2 , TM_Sn_UPPER_LOWER_STATUS_CTRL_OFF +8 ,0 ,9 ), +REG_BANK (LOW_THRESH ,3 , TM_Sn_UPPER_LOWER_STATUS_CTRL_OFF +12 ,0 ,9 ), +REG_BANK (LOW_THRESH ,4 , TM_Sn_UPPER_LOWER_STATUS_CTRL_OFF +16 ,0 ,9 ), +REG_BANK (LOW_THRESH ,5 , TM_Sn_UPPER_LOWER_STATUS_CTRL_OFF +20 ,0 ,9 ), +REG_BANK (LOW_THRESH ,6 , TM_Sn_UPPER_LOWER_STATUS_CTRL_OFF +24 ,0 ,9 ), +REG_BANK (LOW_THRESH ,7 , TM_Sn_UPPER_LOWER_STATUS_CTRL_OFF +28 ,0 ,9 ), +REG_BANK (LOW_THRESH ,8 , TM_Sn_UPPER_LOWER_STATUS_CTRL_OFF +32 ,0 ,9 ), +REG_BANK (LOW_THRESH ,9 , TM_Sn_UPPER_LOWER_STATUS_CTRL_OFF +36 ,0 ,9 ), +REG_BANK (LOW_THRESH ,10 , TM_Sn_UPPER_LOWER_STATUS_CTRL_OFF +40 ,0 ,9 ), +REG_BANK (UP_THRESH ,0 , TM_Sn_UPPER_LOWER_STATUS_CTRL_OFF,10 ,19 ), +REG_BANK (UP_THRESH ,1 , TM_Sn_UPPER_LOWER_STATUS_CTRL_OFF +4 ,10 ,19 ), +REG_BANK (UP_THRESH ,2 , TM_Sn_UPPER_LOWER_STATUS_CTRL_OFF +8 ,10 ,19 ), +REG_BANK (UP_THRESH ,3 , TM_Sn_UPPER_LOWER_STATUS_CTRL_OFF +12 ,10 ,19 ), +REG_BANK (UP_THRESH ,4 , TM_Sn_UPPER_LOWER_STATUS_CTRL_OFF +16 ,10 ,19 ), +REG_BANK (UP_THRESH ,5 , TM_Sn_UPPER_LOWER_STATUS_CTRL_OFF +20 ,10 ,19 ), +REG_BANK (UP_THRESH ,6 , TM_Sn_UPPER_LOWER_STATUS_CTRL_OFF +24 ,10 ,19 ), +REG_BANK (UP_THRESH ,7 , TM_Sn_UPPER_LOWER_STATUS_CTRL_OFF +28 ,10 ,19 ), +REG_BANK (UP_THRESH ,8 , TM_Sn_UPPER_LOWER_STATUS_CTRL_OFF +32 ,10 ,19 ), +REG_BANK (UP_THRESH ,9 , TM_Sn_UPPER_LOWER_STATUS_CTRL_OFF +36 ,10 ,19 ), +REG_BANK (UP_THRESH ,10 , TM_Sn_UPPER_LOWER_STATUS_CTRL_OFF +40 ,10 ,19 ), +/* Sn_STATUS */ +REG_BANK (LAST_TEMP ,0 , TM_Sn_STATUS_OFF,0 ,9 ), +REG_BANK (LAST_TEMP ,1 , TM_Sn_STATUS_OFF +4 ,0 ,9 ), +REG_BANK (LAST_TEMP ,2 , TM_Sn_STATUS_OFF +8 ,0 ,9 ), +REG_BANK (LAST_TEMP ,3 , TM_Sn_STATUS_OFF +12 ,0 ,9 ), +REG_BANK (LAST_TEMP ,4 , TM_Sn_STATUS_OFF +16 ,0 ,9 ), +REG_BANK (LAST_TEMP ,5 , TM_Sn_STATUS_OFF +20 ,0 ,9 ), +REG_BANK (LAST_TEMP ,6 , TM_Sn_STATUS_OFF +24 ,0 ,9 ), +REG_BANK (LAST_TEMP ,7 , TM_Sn_STATUS_OFF +28 ,0 ,9 ), +REG_BANK (LAST_TEMP ,8 , TM_Sn_STATUS_OFF +32 ,0 ,9 ), +REG_BANK (LAST_TEMP ,9 , TM_Sn_STATUS_OFF +36 ,0 ,9 ), +REG_BANK (LAST_TEMP ,10 , TM_Sn_STATUS_OFF +40 ,0 ,9 ), +REG_BANK (VALID ,0 , TM_Sn_STATUS_OFF,14 ,14 ), +REG_BANK (VALID ,1 , TM_Sn_STATUS_OFF +4 ,14 ,14 ), +REG_BANK (VALID ,2 , TM_Sn_STATUS_OFF +8 ,14 ,14 ), +REG_BANK (VALID ,3 , TM_Sn_STATUS_OFF +12 ,14 ,14 ), +REG_BANK (VALID ,4 , TM_Sn_STATUS_OFF +16 ,14 ,14 ), +REG_BANK (VALID ,5 , TM_Sn_STATUS_OFF +20 ,14 ,14 ), +REG_BANK (VALID ,6 , TM_Sn_STATUS_OFF +24 ,14 ,14 ), +REG_BANK (VALID ,7 , TM_Sn_STATUS_OFF +28 ,14 ,14 ), +REG_BANK (VALID ,8 , TM_Sn_STATUS_OFF +32 ,14 ,14 ), +REG_BANK (VALID ,9 , TM_Sn_STATUS_OFF +36 ,14 ,14 ), +REG_BANK (VALID ,10 , TM_Sn_STATUS_OFF +40 ,14 ,14 ), +/* TRDY */ + [TRDY ] =REG_FIELD (TM_TRDY_OFF ,0 ,0 ), +}; + +static const struct tsens_ops ops_generic_v1 = { + .init = init_common, + .calibrate = calibrate_v1, + .get_temp = get_temp_tsens_valid, +}; + +const struct tsens_plat_data data_tsens_v1 = { + .ops = &ops_generic_v1, + .feat = &tsens_v1_feat, + .fields = tsens_v1_regfields, +};drivers/thermal/qcom/tsens.c +3
-0@@ -63,6 +63,9 @@ static const struct of_device_id tsens_table[] = { }, { .compatible = "qcom,msm8996-tsens", .data = &data_8996, + }, { + .compatible = "qcom,tsens-v1", + .data = &data_tsens_v1, }, { .compatible = "qcom,tsens-v2", .data = &data_tsens_v2,drivers/thermal/qcom/tsens.h +3
-0@@ -265,6 +265,9 @@ extern const struct tsens_plat_data data_8960;/* TSENS v0.1 targets */ extern const struct tsens_plat_data data_8916, data_8974; +/* TSENS v1 targets */ +extern const struct tsens_plat_data data_tsens_v1; +/* TSENS v2 targets */ extern const struct tsens_plat_data data_8996, data_tsens_v2;Signature · 1 line
2.17.1
Re: [PATCH v1 13/24] drivers: thermal: tsens: Print IP version
In reply to Amit KucheriaQuoted 33 lines · Amit Kucheria
On some TSENS IP, version is stored. Print that version at init.
Signed-off-by Amit Kucheria <[email protected]>--- drivers/thermal/qcom/tsens-common.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-)drivers/thermal/qcom/tsens-common.c +10
-1@@ -121,7 +121,7 @@ int __init init_common(struct tsens_priv *priv)void __iomem *tm_base, *srot_base;struct device *dev = priv->dev;struct resource *res; -u32 enabled; +u32 enabled, maj_ver, min_ver;int ret, i, j;struct platform_device *op =of_find_device_by_node (priv->dev->of_node);@@ -155,6 +155,27 @@ int __init init_common(struct tsens_priv *priv)if (IS_ERR (priv->tm_map))return PTR_ERR (priv->tm_map); +for (i =0 ; i <MAX_REGFIELDS ; i++) { + priv->rf[i] =NULL ; + } + +/* alloc regmap_fields in srot_map */ +if (priv->feat->ver_info) { +for (i =0 , j =VER_MAJOR ; i <2 ; i++, j++) { + priv->rf[j] =devm_regmap_field_alloc (dev, priv->srot_map, + priv->fields[j]);
drivers/thermal/qcom/tsens-common.c int __init init_common(struct tsens_priv *priv) · line 176
Quoted 10 lines
drivers/thermal/qcom/tsens-common.c +10
-0+if (IS_ERR (priv->rf[j])) +return PTR_ERR (priv->rf[j]); + } + ret =regmap_field_read (priv->rf[VER_MAJOR ], &maj_ver); +if (ret) +return ret; + ret =regmap_field_read (priv->rf[VER_MINOR ], &min_ver); +if (ret) +return ret; +dev_info (dev,"version: %d.%d\n" , maj_ver, min_ver);
Is this really needed? Printing stuff into kernel log during boot can just add a lot of info that ends up just slowing down things. Besides, if this info is important shouldnt be available somewhere else as the kernel log is a circular buffer and eventually that line will get wrapped up?
Quoted 8 lines
drivers/thermal/qcom/tsens-common.c +2
-0+ } + priv->rf[TSENS_EN ] =devm_regmap_field_alloc (dev, priv->srot_map, priv->fields[TSENS_EN ]);if (IS_ERR (priv->rf[TSENS_EN ]))Signature · 1 line
2.17.1
Re: [PATCH v1 13/24] drivers: thermal: tsens: Print IP version
Quoted 43 lines · Eduardo Valentin
Quoted 41 lines · Amit Kucheria
On some TSENS IP, version is stored. Print that version at init.
Signed-off-by Amit Kucheria <[email protected]>--- drivers/thermal/qcom/tsens-common.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-)drivers/thermal/qcom/tsens-common.c +18
-1@@ -121,7 +121,7 @@ int __init init_common(struct tsens_priv *priv)void __iomem *tm_base, *srot_base;struct device *dev = priv->dev;struct resource *res; -u32 enabled; +u32 enabled, maj_ver, min_ver;int ret, i, j;struct platform_device *op =of_find_device_by_node (priv->dev->of_node);@@ -155,6 +155,27 @@ int __init init_common(struct tsens_priv *priv)if (IS_ERR (priv->tm_map))return PTR_ERR (priv->tm_map); +for (i =0 ; i <MAX_REGFIELDS ; i++) { + priv->rf[i] =NULL ; + } + +/* alloc regmap_fields in srot_map */ +if (priv->feat->ver_info) { +for (i =0 , j =VER_MAJOR ; i <2 ; i++, j++) { + priv->rf[j] =devm_regmap_field_alloc (dev, priv->srot_map, + priv->fields[j]); +if (IS_ERR (priv->rf[j])) +return PTR_ERR (priv->rf[j]); + } + ret =regmap_field_read (priv->rf[VER_MAJOR ], &maj_ver); +if (ret) +return ret; + ret =regmap_field_read (priv->rf[VER_MINOR ], &min_ver); +if (ret)
Quoted 8 lines
drivers/thermal/qcom/tsens-common.c int __init init_common(struct tsens_priv *priv) · line 176
Quoted 2 lines
drivers/thermal/qcom/tsens-common.c +2
-0+return ret; +dev_info (dev,"version: %d.%d\n" , maj_ver, min_ver);Is this really needed? Printing stuff into kernel log during boot can just add a lot of info that ends up just slowing down things. Besides, if this info is important shouldnt be available somewhere else as the kernel log is a circular buffer and eventually that line will get wrapped up?
Fair point, I'll remove this statement and dump this into debugfs for which I'll send a separate series adding debugfs support.
Re: [PATCH v1 23/24] arm64: dts: qcom: qcs404: Add thermal zones for each sensor
In reply to Eduardo ValentinQuoted 53 lines · Eduardo Valentin
Quoted 51 lines · Amit Kucheria
qcs404 has 10 sensors connected to the single TSENS IP. Define a thermal zone for each of those sensors to expose the temperature of each zone.
Signed-off-by Amit Kucheria <[email protected]>--- arch/arm64/boot/dts/qcom/qcs404.dtsi | 243 +++++++++++++++++++++++++++ 1 file changed, 243 insertions(+)arch/arm64/boot/dts/qcom/qcs404.dtsi +5
-0@@ -3,6 +3,7 @@ #include <dt-bindings/interrupt-controller/arm-gic.h> #include <dt-bindings/clock/qcom,gcc-qcs404.h> +#include <dt-bindings/thermal/thermal.h> / { interrupt-parent = <&intc>;@@ -30,6 +31,7 @@ reg = <0x100>; enable-method = "psci"; next-level-cache = <&L2_0>; + #cooling-cells= <2>; }; CPU1: cpu@101 {@@ -38,6 +40,7 @@ reg = <0x101>; enable-method = "psci"; next-level-cache = <&L2_0>; + #cooling-cells= <2>; }; CPU2: cpu@102 {@@ -46,6 +49,7 @@ reg = <0x102>; enable-method = "psci"; next-level-cache = <&L2_0>; + #cooling-cells= <2>; }; CPU3: cpu@103 {@@ -54,6 +58,7 @@ reg = <0x103>; enable-method = "psci"; next-level-cache = <&L2_0>; + #cooling-cells= <2>; };
Quoted 9 lines
arch/arm64/boot/dts/qcom/qcs404.dtsi line 516
Quoted 7 lines
arch/arm64/boot/dts/qcom/qcs404.dtsi +2
-0L2_0: l2-cache {@@ -507,4 +512,242 @@ #interrupt-cells = <2>; }; }; + + thermal-zones {There are several zones with passive trips and no cooling maps.
Indeed. The policy bits are still a WIP and in some cases the throttling is handled by someone in userspace. But I'd like to expose at least the temperatures at each of the sensors to make it easier for others to use this information. See my reply to the cover letter.
Regards,
Amit
Quoted 240 lines
Quoted 240 lines
arch/arm64/boot/dts/qcom/qcs404.dtsi +236
-1+ aoss-thermal { + polling-delay-passive = <250>; + polling-delay = <1000>; + + thermal-sensors = <&tsens 0>; + + trips { + aoss_alert0: trip-point@0 { + temperature = <95000>; + hysteresis = <2000>; + type = "passive"; + }; + aoss_crit: aoss_crit { + temperature = <110000>; + hysteresis = <2000>; + type = "critical"; + }; + }; + }; + + dsp-thermal { + polling-delay-passive = <250>; + polling-delay = <1000>; + + thermal-sensors = <&tsens 1>; + + trips { + dsp_alert0: trip-point@0 { + temperature = <95000>; + hysteresis = <2000>; + type = "passive"; + }; + dsp_crit: dsp_crit { + temperature = <110000>; + hysteresis = <2000>; + type = "critical"; + }; + }; + }; + + lpass-thermal { + polling-delay-passive = <250>; + polling-delay = <1000>; + + thermal-sensors = <&tsens 2>; + + trips { + lpass_alert0: trip-point@0 { + temperature = <95000>; + hysteresis = <2000>; + type = "passive"; + }; + lpass_crit: lpass_crit { + temperature = <110000>; + hysteresis = <2000>; + type = "critical"; + }; + }; + }; + + wlan-thermal { + polling-delay-passive = <250>; + polling-delay = <1000>; + + thermal-sensors = <&tsens 3>; + + trips { + wlan_alert0: trip-point@0 { + temperature = <95000>; + hysteresis = <2000>; + type = "passive"; + }; + wlan_crit: wlan_crit { + temperature = <110000>; + hysteresis = <2000>; + type = "critical"; + }; + }; + }; + + cluster-thermal { + polling-delay-passive = <250>; + polling-delay = <1000>; + + thermal-sensors = <&tsens 4>; + + trips { + cluster_alert0: trip-point@0 { + temperature = <95000>; + hysteresis = <2000>; + type = "passive"; + }; + cluster_crit: cluster_crit { + temperature = <110000>; + hysteresis = <2000>; + type = "critical"; + }; + }; + }; + + cpu0-thermal { + polling-delay-passive = <250>; + polling-delay = <1000>; + + thermal-sensors = <&tsens 5>; + + trips { + cpu0_alert0: trip-point@0 { + temperature = <95000>; + hysteresis = <2000>; + type = "passive"; + }; + cpu0_crit: cpu_crit { + temperature = <110000>; + hysteresis = <2000>; + type = "critical"; + }; + }; + cooling-maps { + map0 { + trip = <&cpu0_alert0>; + cooling-device = <&CPU0 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&CPU1 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&CPU2 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&CPU3 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>; + }; + }; + }; + + cpu1-thermal { + polling-delay-passive = <250>; + polling-delay = <1000>; + + thermal-sensors = <&tsens 6>; + + trips { + cpu1_alert0: trip-point@0 { + temperature = <95000>; + hysteresis = <2000>; + type = "passive"; + }; + cpu1_crit: cpu_crit { + temperature = <110000>; + hysteresis = <2000>; + type = "critical"; + }; + }; + cooling-maps { + map0 { + trip = <&cpu1_alert0>; + cooling-device = <&CPU0 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&CPU1 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&CPU2 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&CPU3 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>; + }; + }; + }; + + cpu2-thermal { + polling-delay-passive = <250>; + polling-delay = <1000>; + + thermal-sensors = <&tsens 7>; + + trips { + cpu2_alert0: trip-point@0 { + temperature = <95000>; + hysteresis = <2000>; + type = "passive"; + }; + cpu2_crit: cpu_crit { + temperature = <110000>; + hysteresis = <2000>; + type = "critical"; + }; + }; + cooling-maps { + map0 { + trip = <&cpu2_alert0>; + cooling-device = <&CPU0 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&CPU1 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&CPU2 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&CPU3 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>; + }; + }; + }; + + cpu3-thermal { + polling-delay-passive = <250>; + polling-delay = <1000>; + + thermal-sensors = <&tsens 8>; + + trips { + cpu3_alert0: trip-point@0 { + temperature = <95000>; + hysteresis = <2000>; + type = "passive"; + }; + cpu3_crit: cpu_crit { + temperature = <110000>; + hysteresis = <2000>; + type = "critical"; + }; + }; + cooling-maps { + map0 { + trip = <&cpu3_alert0>; + cooling-device = <&CPU0 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&CPU1 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&CPU2 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&CPU3 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>; + }; + }; + }; + + gpu-thermal { + polling-delay-passive = <250>; + polling-delay = <1000>; + + thermal-sensors = <&tsens 9>; + + trips { + gpu_alert0: trip-point@0 { + temperature = <95000>; + hysteresis = <2000>; + type = "passive"; + }; + gpu_crit: gpu_crit { + temperature = <95000>; + hysteresis = <2000>; + type = "critical"; + }; + }; + }; + }; }; --2.17.1
Re: [PATCH v1 20/24] dt: thermal: tsens: Add bindings for qcs404
In reply to Amit KucheriaQuoted 8 lines · Amit Kucheria
qcs404 uses v1 of the TSENS IP block. Create a fallback DT property "qcom,tsens-v1" to gather common code
Signed-off-by Amit Kucheria <[email protected]>--- .../devicetree/bindings/thermal/qcom-tsens.txt | 14 ++++++++++++++ 1 file changed, 14 insertions(+)