Skip to contentSkip to conversation

qcom: Add support for TSENS driver

PATCH Superseded Rajendra Nayak 4 participants 27 messages Jul 8, 2015 – Sep 9, 2015

Subsystems (7)

v1 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

cover qcom: Add support for TSENS driver

Changes since RFC:
* Added support for 8916 and 8084
* Based off the latest nvmem framework patches [1]
* Minor review fixes for comments mostly from Lina

** I have also added irq support using the hardware trip point support series [2]. Will post that out seperately.

This is an attempt to have a single TSENS driver for the different versions of the TSENS IP that exist, on different qcom msm/apq SoCs'
Support is added for msm8916, msm8960 and msm8974 families. Based on top of the latest nvmem framework patches [2]

A lot of the work is based of original code from Stephen Boyd and Siddartha Mohanadoss. I have also picked some of what Narendran Rajan did in his attempt to upstream the support for 8960 family. I could not keep the original authorship on any of the patches because I ended up moving the code around quite a bit in an effort to have a single driver for the various devices. I would be glad to change the authorship for any of the patches if needed.

[1] https://lkml.org/lkml/2015/6/22/609
[2] https://lkml.org/lkml/2015/5/20/472

Rajendra Nayak (8):
thermal: qcom: tsens: Add a skeletal TSENS drivers
thermal: qcom: tsens-8916: Add support for 8916 family of SoCs
thermal: qcom: tsens-8974: Add support for 8974 family of SoCs
thermal: qcom: tsens-8960: Add support for 8960 family of SoCs
arm: dts: msm8974: Add thermal zones, tsens and eeprom nodes
arm: dts: apq8064: Add thermal zones, tsens and eeprom nodes
arm: dts: apq8084: Add thermal zones, tsens and eeprom nodes
arm64: dts: msm8916: Add thermal zones, tsens and eeprom nodes

Srinivas Kandagatla (1):
clk: qcom: gcc-msm8960: add child devices support.

 .../devicetree/bindings/thermal/qcom-tsens.txt     |  37 +++
 arch/arm/boot/dts/qcom-apq8064.dtsi                | 108 ++++++++
 arch/arm/boot/dts/qcom-apq8084.dtsi                | 105 ++++++++
 arch/arm/boot/dts/qcom-msm8974.dtsi                | 105 ++++++++
 arch/arm64/boot/dts/qcom/msm8916.dtsi              |  66 +++++
 drivers/clk/qcom/gcc-msm8960.c                     |   4 +-
 drivers/thermal/Kconfig                            |   5 +
 drivers/thermal/Makefile                           |   1 +
 drivers/thermal/qcom/Kconfig                       |  10 +
 drivers/thermal/qcom/Makefile                      |   2 +
 drivers/thermal/qcom/tsens-8916.c                  | 107 ++++++++
 drivers/thermal/qcom/tsens-8960.c                  | 291 +++++++++++++++++++++
 drivers/thermal/qcom/tsens-8974.c                  | 239 +++++++++++++++++
 drivers/thermal/qcom/tsens-common.c                | 128 +++++++++
 drivers/thermal/qcom/tsens.c                       | 209 +++++++++++++++
 drivers/thermal/qcom/tsens.h                       |  69 +++++
 16 files changed, 1485 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/thermal/qcom-tsens.txt
 create mode 100644 drivers/thermal/qcom/Kconfig
 create mode 100644 drivers/thermal/qcom/Makefile
 create mode 100644 drivers/thermal/qcom/tsens-8916.c
 create mode 100644 drivers/thermal/qcom/tsens-8960.c
 create mode 100644 drivers/thermal/qcom/tsens-8974.c
 create mode 100644 drivers/thermal/qcom/tsens-common.c
 create mode 100644 drivers/thermal/qcom/tsens.c
 create mode 100644 drivers/thermal/qcom/tsens.h
Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation
#1 lore raw

PATCH 1/9 thermal: qcom: tsens: Add a skeletal TSENS drivers

TSENS is Qualcomms' thermal temperature sensor device. It supports reading temperatures from multiple thermal sensors present on various QCOM SoCs.
Calibration data is generally read from a eeprom device.

Add a skeleton driver with all the necessary abstractions so a variety of qcom device families which support TSENS can add driver extensions.

Also add the required device tree bindings which can be used to descibe the TSENS device in DT.

---
 .../devicetree/bindings/thermal/qcom-tsens.txt     |  37 ++++
 drivers/thermal/Kconfig                            |   5 +
 drivers/thermal/Makefile                           |   1 +
 drivers/thermal/qcom/Kconfig                       |  10 +
 drivers/thermal/qcom/Makefile                      |   2 +
 drivers/thermal/qcom/tsens.c                       | 207 +++++++++++++++++++++
 drivers/thermal/qcom/tsens.h                       |  58 ++++++
 7 files changed, 320 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/thermal/qcom-tsens.txt
 create mode 100644 drivers/thermal/qcom/Kconfig
 create mode 100644 drivers/thermal/qcom/Makefile
 create mode 100644 drivers/thermal/qcom/tsens.c
 create mode 100644 drivers/thermal/qcom/tsens.h
Documentation/devicetree/bindings/thermal/qcom-tsens.txt new file +37 -0
new file mode 100644
index 0000000..cfb79fc
@@ -0,0 +1,37 @@
+* QCOM SoC Temperature Sensor (TSENS)
+
+Required properties:
+- compatible :
+ - "qcom,msm8916-tsens" : For 8916 Family of SoCs
+ - "qcom,msm8974-tsens" : For 8974 Family of SoCs
+ - "qcom,msm8960-tsens" : For 8960 Family of SoCs
+
+- reg: Address range of the thermal registers
+- qcom,tsens-slopes : Must contain slope value for each of the sensors controlled
+			by this device
+- #thermal-sensor-cells : Should be 1. See ./thermal.txt for a description.
+- Refer to Documentation/devicetree/bindings/eeprom/eeprom.txt to know how to specify
+an eeprom cell
+
+Optional properties:
+- qcom,sensor-id: List of sensor instances used in a given SoC. A TSENS IP can
+		  have a fixed number of sensors (like 11) but a given SoC can
+		  use only 5 of these and they might not always the first 5. They
+		  could be sensors 0, 1, 4, 8 and 9. This property is used to
+		  describe the subset of the sensors used. If this property is
+		  missing they are assumed to be the first 'n' sensors numbered
+		  sequentially in which case the number of sensors defaults to
+		  the number of slope values.
+
+Example:
+tsens: thermal-sensor at 900000 {
+		compatible = "qcom,msm8916-tsens";
+		qcom,tsens-slopes = <1176 1176 1154 1176 1111
+				1132 1132 1199 1132 1199
+				1132>;
+		calib_data = <&tsens_caldata>;
+		calib_sel = <&tsens_calsel>;
+		qcom,tsens-slopes = <3200 3200 3200 3200 3200>;
+		qcom,sensor-id = <0 1 2 4 5>;
+		#thermal-sensor-cells = <1>;
+	};
drivers/thermal/Kconfig +5 -0
index 118938e..8f47021 100644
@@ -365,4 +365,9 @@ config QCOM_SPMI_TEMP_ALARM
 	  real time die temperature if an ADC is present or an estimate of the
 	  temperature based upon the over temperature stage value.
 
+menu "Qualcomm thermal drivers"
+depends on ARCH_QCOM && OF
+source "drivers/thermal/qcom/Kconfig"
+endmenu
+
 endif
drivers/thermal/Makefile +1 -0
index 535dfee..011fa57 100644
@@ -42,5 +42,6 @@ obj-$(CONFIG_INTEL_QUARK_DTS_THERMAL)	+= intel_quark_dts_thermal.o
 obj-$(CONFIG_TI_SOC_THERMAL)	+= ti-soc-thermal/
 obj-$(CONFIG_INT340X_THERMAL)  += int340x_thermal/
 obj-$(CONFIG_ST_THERMAL)	+= st/
+obj-$(CONFIG_QCOM_TSENS)	+= qcom/
 obj-$(CONFIG_TEGRA_SOCTHERM)	+= tegra_soctherm.o
 obj-$(CONFIG_HISI_THERMAL)     += hisi_thermal.o
drivers/thermal/qcom/Kconfig new file +10 -0
new file mode 100644
index 0000000..9bfde94e
@@ -0,0 +1,10 @@
+config QCOM_TSENS
+	tristate "Qualcomm TSENS Temperature Alarm"
+	depends on THERMAL
+	depends on QCOM_QFPROM
+	help
+	  This enables the thermal sysfs driver for the Tsens device. It shows
+	  up in Sysfs as a thermal zone with multiple trip points. Disabling the
+	  thermal zone device via the mode file results in disabling the sensor.
+	  Also able to set threshold temperature for both hot and cold and update
+	  when a threshold is reached.
drivers/thermal/qcom/Makefile new file +2 -0
new file mode 100644
index 0000000..401069b
@@ -0,0 +1,2 @@
+obj-$(CONFIG_QCOM_TSENS)	+= qcom_tsens.o
+qcom_tsens-y			+= tsens.o
drivers/thermal/qcom/tsens.c new file +207 -0

207 lines not on this page · raw message

drivers/thermal/qcom/tsens.h new file +58 -0

58 lines not on this page · raw message

Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation
#2 lore raw

PATCH 2/9 thermal: qcom: tsens-8916: Add support for 8916 family of SoCs

In reply to Rajendra Nayak

Add support to calibrate sensors on 8916 family and also add common functions to read temperature from sensors (This can be reused on other SoCs having similar TSENS device)
The calibration data is read from eeprom using the generic eeprom framework apis.

Based on the original code by Siddartha Mohanadoss and Stephen Boyd.

---
 drivers/thermal/qcom/Makefile       |   2 +-
 drivers/thermal/qcom/tsens-8916.c   | 107 ++++++++++++++++++++++++++++++
 drivers/thermal/qcom/tsens-common.c | 128 ++++++++++++++++++++++++++++++++++++
 drivers/thermal/qcom/tsens.h        |  11 ++++
 4 files changed, 247 insertions(+), 1 deletion(-)
 create mode 100644 drivers/thermal/qcom/tsens-8916.c
 create mode 100644 drivers/thermal/qcom/tsens-common.c
drivers/thermal/qcom/Makefile +1 -1
index 401069b..05c98e4 100644
@@ -1,2 +1,2 @@
 obj-$(CONFIG_QCOM_TSENS)	+= qcom_tsens.o
-qcom_tsens-y			+= tsens.o
+qcom_tsens-y			+= tsens.o tsens-common.o tsens-8916.o
drivers/thermal/qcom/tsens-8916.c new file +107 -0

107 lines not on this page · raw message

drivers/thermal/qcom/tsens-common.c new file +128 -0

128 lines not on this page · raw message

drivers/thermal/qcom/tsens.h +11 -0
index 9b274e1..81c5efb 100644
@@ -13,6 +13,10 @@
 #ifndef __QCOM_TSENS_H__
 #define __QCOM_TSENS_H__
 
+#define ONE_PT_CALIB		0x1
+#define ONE_PT_CALIB2		0x2
+#define TWO_PT_CALIB		0x3
+
 struct tsens_device;
 
 struct tsens_sensor {
@@ -55,4 +59,11 @@ struct tsens_device {
 	struct tsens_sensor		sensor[0];
 };
 
+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, long *);
+
+extern const struct tsens_ops ops_8916;
+
 #endif /* __QCOM_TSENS_H__ */
Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation
#3 lore raw

PATCH 3/9 thermal: qcom: tsens-8974: Add support for 8974 family of SoCs

In reply to Rajendra Nayak

Add .calibrate support for 8974 family as part of tsens_ops.

Based on the original code by Siddartha Mohanadoss and Stephen Boyd.

---
 drivers/thermal/qcom/Makefile     |   2 +-
 drivers/thermal/qcom/tsens-8974.c | 239 ++++++++++++++++++++++++++++++++++++++
 drivers/thermal/qcom/tsens.c      |   1 +
 drivers/thermal/qcom/tsens.h      |   2 +-
 4 files changed, 242 insertions(+), 2 deletions(-)
 create mode 100644 drivers/thermal/qcom/tsens-8974.c
drivers/thermal/qcom/Makefile +1 -1
index 05c98e4..a471100 100644
@@ -1,2 +1,2 @@
 obj-$(CONFIG_QCOM_TSENS)	+= qcom_tsens.o
-qcom_tsens-y			+= tsens.o tsens-common.o tsens-8916.o
+qcom_tsens-y			+= tsens.o tsens-common.o tsens-8916.o tsens-8974.o
drivers/thermal/qcom/tsens-8974.c new file +239 -0

239 lines not on this page · raw message

drivers/thermal/qcom/tsens.c +1 -0
index d32d278..4d65a42 100644
@@ -76,6 +76,7 @@ static const struct of_device_id tsens_table[] = {
 		.data = &ops_8916,
 	}, {
 		.compatible = "qcom,msm8974-tsens",
+		.data = &ops_8974,
 	},
 	{}
 };
drivers/thermal/qcom/tsens.h +1 -1
index 81c5efb..9ee0319 100644
@@ -64,6 +64,6 @@ void compute_intercept_slope(struct tsens_device *, u32 *, u32 *, u32);
 int init_common(struct tsens_device *);
 int get_temp_common(struct tsens_device *, int, long *);
 
-extern const struct tsens_ops ops_8916;
+extern const struct tsens_ops ops_8916, ops_8974;
 
 #endif /* __QCOM_TSENS_H__ */
Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation
#4 lore raw

PATCH 4/9 thermal: qcom: tsens-8960: Add support for 8960 family of SoCs

In reply to Rajendra Nayak

8960 family of SoCs have the TSENS device as part of a domain thats not always ON. Hence add .suspend and .resume hooks to save and restore some of the inited register context.

8960 family has TSENS as part of GCC, hence reuse the GCC regmap. Also 8960 family had some of the TSENS init sequence thats required to be done by the HLOS driver (some later versions of TSENS do not export these registers to non-secure world, and hence need these initializations to be done by secure bootloaders)

8660 from the same family has just one sensor and hence some register offset/layout differences which need special handling in the driver.

Based on the original code from Siddartha Mohanadoss, Stephen Boyd and Narendran Rajan.

---
 drivers/thermal/qcom/Makefile     |   2 +-
 drivers/thermal/qcom/tsens-8960.c | 291 ++++++++++++++++++++++++++++++++++++++
 drivers/thermal/qcom/tsens.c      |   1 +
 drivers/thermal/qcom/tsens.h      |   2 +-
 4 files changed, 294 insertions(+), 2 deletions(-)
 create mode 100644 drivers/thermal/qcom/tsens-8960.c
drivers/thermal/qcom/Makefile +1 -1
index a471100..f3cefd1 100644
@@ -1,2 +1,2 @@
 obj-$(CONFIG_QCOM_TSENS)	+= qcom_tsens.o
-qcom_tsens-y			+= tsens.o tsens-common.o tsens-8916.o tsens-8974.o
+qcom_tsens-y			+= tsens.o tsens-common.o tsens-8916.o tsens-8974.o tsens-8960.o
drivers/thermal/qcom/tsens-8960.c new file +291 -0

291 lines not on this page · raw message

drivers/thermal/qcom/tsens.c +1 -0
index 4d65a42..8d938d4 100644
@@ -71,6 +71,7 @@ static SIMPLE_DEV_PM_OPS(tsens_pm_ops, tsens_suspend, tsens_resume);
 static const struct of_device_id tsens_table[] = {
 	{
 		.compatible = "qcom,msm8960-tsens",
+		.data = &ops_8960,
 	}, {
 		.compatible = "qcom,msm8916-tsens",
 		.data = &ops_8916,
drivers/thermal/qcom/tsens.h +1 -1
index 9ee0319..f659806 100644
@@ -64,6 +64,6 @@ void compute_intercept_slope(struct tsens_device *, u32 *, u32 *, u32);
 int init_common(struct tsens_device *);
 int get_temp_common(struct tsens_device *, int, long *);
 
-extern const struct tsens_ops ops_8916, ops_8974;
+extern const struct tsens_ops ops_8960, ops_8916, ops_8974;
 
 #endif /* __QCOM_TSENS_H__ */
Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation
#5 lore raw

PATCH 5/9 clk: qcom: gcc-msm8960: add child devices support.

In reply to Rajendra Nayak

From: Srinivas Kandagatla <[email protected]>

This patch adds support to add child devices to gcc as some of the registers mapped by gcc are used by things like thermal sensors.

---
 drivers/clk/qcom/gcc-msm8960.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/clk/qcom/gcc-msm8960.c +3 -1
index eb6a4f9..2c80d03 100644
@@ -15,6 +15,7 @@
 #include <linux/bitops.h>
 #include <linux/err.h>
 #include <linux/platform_device.h>
+#include <linux/of_platform.h>
 #include <linux/module.h>
 #include <linux/of.h>
 #include <linux/of_device.h>
@@ -3520,7 +3521,8 @@ static int gcc_msm8960_probe(struct platform_device *pdev)
 	if (IS_ERR(clk))
 		return PTR_ERR(clk);
 
-	return qcom_cc_probe(pdev, match->data);
+	qcom_cc_probe(pdev, match->data);
+	return of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev);
 }
 
 static int gcc_msm8960_remove(struct platform_device *pdev)
Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation
#6 lore raw

PATCH 5/9 clk: qcom: gcc-msm8960: add child devices support.

Quoted 13 lines · Rajendra Nayak
drivers/clk/qcom/gcc-msm8960.c +1 -0
index eb6a4f9..2c80d03 100644
@@ -15,6 +15,7 @@
 #include <linux/bitops.h>
 #include <linux/err.h>
 #include <linux/platform_device.h>
+#include <linux/of_platform.h>
 #include <linux/module.h>
 #include <linux/of.h>
 #include <linux/of_device.h>

drivers/clk/qcom/gcc-msm8960.c static int gcc_msm8960_probe(struct platform_device *pdev) · line 3525

Quoted 6 lines
drivers/clk/qcom/gcc-msm8960.c +2 -1
@@ -3520,7 +3521,8 @@ static int gcc_msm8960_probe(struct platform_device *pdev)
 	if (IS_ERR(clk))
 		return PTR_ERR(clk);
 
-	return qcom_cc_probe(pdev, match->data);
+	qcom_cc_probe(pdev, match->data);
+	return of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev);

We just lost the error code from qcom_cc_probe()...

Also, I don't like having a subnode in DT. Why can't we use the same node as the GCC node and create a virtual child device here for tsens? We can assign the same of_node that this platform device has so that DT keeps working correctly.

Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
#7 lore raw

PATCH 5/9 clk: qcom: gcc-msm8960: add child devices support.

Quoted 17 lines · Stephen Boyd
Quoted 16 lines · Rajendra Nayak
drivers/clk/qcom/gcc-msm8960.c +1 -0
index eb6a4f9..2c80d03 100644
@@ -15,6 +15,7 @@
  #include <linux/bitops.h>
  #include <linux/err.h>
  #include <linux/platform_device.h>
+#include <linux/of_platform.h>
  #include <linux/module.h>
  #include <linux/of.h>
  #include <linux/of_device.h>
@@ -3520,7 +3521,8 @@ static int gcc_msm8960_probe(struct platform_device *pdev)
  	if (IS_ERR(clk))
  		return PTR_ERR(clk);
 
Quoted 6 lines

drivers/clk/qcom/gcc-msm8960.c static int gcc_msm8960_probe(struct platform_device *pdev) · line 3525

Quoted 3 lines
drivers/clk/qcom/gcc-msm8960.c +2 -1
-	return qcom_cc_probe(pdev, match->data);
+	qcom_cc_probe(pdev, match->data);
+	return of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev);

We just lost the error code from qcom_cc_probe()...

I think Rajendra picked up the wrong patch for this series, I did submit a v2 (https://patches.linaro.org/44033/) with the above fixed.

Quoted 4 lines

Also, I don't like having a subnode in DT. Why can't we use the same node as the GCC node and create a virtual child device here for tsens? We can assign the same of_node that this platform device has so that DT keeps working correctly.

I don't mind either way, if that makes things moving :-)

--srini

Quoted 1 line
#8 lore raw

PATCH 5/9 clk: qcom: gcc-msm8960: add child devices support.

Quoted 27 lines · Stephen Boyd
Quoted 19 lines · Rajendra Nayak
Quoted 18 lines
drivers/clk/qcom/gcc-msm8960.c +1 -0
index eb6a4f9..2c80d03 100644
@@ -15,6 +15,7 @@
  #include <linux/bitops.h>
  #include <linux/err.h>
  #include <linux/platform_device.h>
+#include <linux/of_platform.h>
  #include <linux/module.h>
  #include <linux/of.h>
  #include <linux/of_device.h>
@@ -3520,7 +3521,8 @@ static int gcc_msm8960_probe(struct
 platform_device *pdev)
      if (IS_ERR(clk))
          return PTR_ERR(clk);
 
Quoted 7 lines

drivers/clk/qcom/gcc-msm8960.c static int gcc_msm8960_probe(struct platform_device *pdev)

Quoted 4 lines
drivers/clk/qcom/gcc-msm8960.c +2 -1
-    return qcom_cc_probe(pdev, match->data);
+    qcom_cc_probe(pdev, match->data);
+    return of_platform_populate(pdev->dev.of_node, NULL, NULL,
 &pdev->dev);

We just lost the error code from qcom_cc_probe()...

Quoted 2 lines

I think Rajendra picked up the wrong patch for this series, I did submit a v2 (https://patches.linaro.org/44033/) with the above fixed.

ah, sorry about that.

Quoted 4 lines
Quoted 4 lines

Also, I don't like having a subnode in DT. Why can't we use the same node as the GCC node and create a virtual child device here for tsens? We can assign the same of_node that this platform device has so that DT keeps working correctly.

So the current driver looks up data based on compatible strings. So you suggesting to create a virtual child device for gcc and associate the gcc DT node to it? (And have the tsens compatible mentioned as part of the gcc DT node?)
How is this any different from creating a subnode in DT anyway?

#9 lore raw

PATCH 5/9 clk: qcom: gcc-msm8960: add child devices support.

Quoted 30 lines · Rajendra Nayak
Quoted 27 lines · Stephen Boyd
Quoted 19 lines · Rajendra Nayak
Quoted 18 lines
drivers/clk/qcom/gcc-msm8960.c +1 -0
index eb6a4f9..2c80d03 100644
@@ -15,6 +15,7 @@
 #include <linux/bitops.h>
 #include <linux/err.h>
 #include <linux/platform_device.h>
+#include <linux/of_platform.h>
 #include <linux/module.h>
 #include <linux/of.h>
 #include <linux/of_device.h>
@@ -3520,7 +3521,8 @@ static int gcc_msm8960_probe(struct
 platform_device *pdev)
     if (IS_ERR(clk))
         return PTR_ERR(clk);
 
Quoted 7 lines

drivers/clk/qcom/gcc-msm8960.c static int gcc_msm8960_probe(struct platform_device *pdev)

Quoted 4 lines
drivers/clk/qcom/gcc-msm8960.c +2 -1
-    return qcom_cc_probe(pdev, match->data);
+    qcom_cc_probe(pdev, match->data);
+    return of_platform_populate(pdev->dev.of_node, NULL, NULL,
 &pdev->dev);

We just lost the error code from qcom_cc_probe()...

Quoted 2 lines

I think Rajendra picked up the wrong patch for this series, I did submit a v2 (https://patches.linaro.org/44033/) with the above fixed.

Quoted 8 lines

ah, sorry about that.

Quoted 4 lines
Quoted 4 lines

Also, I don't like having a subnode in DT. Why can't we use the same node as the GCC node and create a virtual child device here for tsens? We can assign the same of_node that this platform device has so that DT keeps working correctly.

So the current driver looks up data based on compatible strings.

The tsens device is always the same piece of hardware. The only thing that's changing is the qfprom data and the number of sensors. So we should be looking at the qfprom compatible string to figure out how to interpret the qfprom data which would include the number of sensors and how the data is encoded.

Quoted 3 lines

So you suggesting to create a virtual child device for gcc and associate the gcc DT node to it? (And have the tsens compatible mentioned as part of the gcc DT node?)

No. The driver should work just fine without having to interrogate the device's compatible string. If we still need the compatible check for some reason, then we can always match based on qcom,gcc-msm8960, qcom,gcc-apq8064, etc. But I don't see why we need to do that when we should be looking at what type of qfprom is connected so we can correctly parse the data.

Quoted 1 line

How is this any different from creating a subnode in DT anyway?

The difference is we don't make up nodes to satisfy linux device driver design. I suspect the hardware engineers put tsens inside gcc because both blocks were written by the same person/team and they just needed some place to jam some registers and call it a day. That doesn't constitute an MFD or bus, which is what we would be expressing in DT if we made a child node, it constitutes a horrible software interface design that we have to live with.

Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
#10 lore raw

PATCH 5/9 clk: qcom: gcc-msm8960: add child devices support.

[]..

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Quoted 4 lines

Also, I don't like having a subnode in DT. Why can't we use the same node as the GCC node and create a virtual child device here for tsens? We can assign the same of_node that this platform device has so that DT keeps working correctly.

So the current driver looks up data based on compatible strings.

The tsens device is always the same piece of hardware. The only

Well, not always. The one in 8960 does need additional initializations, requires you to save/restore context as it can be powered off not being in an always powered on domain etc.

Quoted 2 lines

thing that's changing is the qfprom data and the number of sensors. So we should be looking at the qfprom compatible string

How? Tsens uses nvmem framework apis to read the qfprom atleast in this series.

Quoted 11 lines

to figure out how to interpret the qfprom data which would include the number of sensors and how the data is encoded.

Quoted 3 lines

So you suggesting to create a virtual child device for gcc and associate the gcc DT node to it? (And have the tsens compatible mentioned as part of the gcc DT node?)

No. The driver should work just fine without having to interrogate the device's compatible string. If we still need the compatible check for some reason, then we can always match based on qcom,gcc-msm8960, qcom,gcc-apq8064, etc. But I don't see why

Thats not quite possible I guess. 2 drivers (gcc and tsens) matching the same compatibles? Will it not just depend on which ends up being the first match?

Quoted 2 lines

we need to do that when we should be looking at what type of qfprom is connected so we can correctly parse the data.

#11 lore raw

PATCH 5/9 clk: qcom: gcc-msm8960: add child devices support.

Stephen,

Quoted 26 lines
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Quoted 4 lines

Also, I don't like having a subnode in DT. Why can't we use the same node as the GCC node and create a virtual child device here for tsens? We can assign the same of_node that this platform device has so that DT keeps working correctly.

So the current driver looks up data based on compatible strings.

The tsens device is always the same piece of hardware. The only

Well, not always. The one in 8960 does need additional initializations, requires you to save/restore context as it can be powered off not being in an always powered on domain etc.

Quoted 2 lines

thing that's changing is the qfprom data and the number of sensors. So we should be looking at the qfprom compatible string

How? Tsens uses nvmem framework apis to read the qfprom atleast in this series.

Quoted 7 lines

to figure out how to interpret the qfprom data which would include the number of sensors and how the data is encoded.

Quoted 3 lines

So you suggesting to create a virtual child device for gcc and associate the gcc DT node to it? (And have the tsens compatible mentioned as part of the gcc DT node?)

Quoted 8 lines
Quoted 4 lines

No. The driver should work just fine without having to interrogate the device's compatible string. If we still need the compatible check for some reason, then we can always match based on qcom,gcc-msm8960, qcom,gcc-apq8064, etc. But I don't see why

Thats not quite possible I guess. 2 drivers (gcc and tsens) matching the same compatibles? Will it not just depend on which ends up being the first match?

Any thoughts on how to move forward with this?

I tried what you were suggesting, and here's what I had to do to get things working

* Created a gcc node in DT with gcc and tsens compatibles, with gcc and tsens properties
* gcc driver probes the device/node first given gcc is registered with a core_initcall()
* creates a virtual child device attaching the same of_node (having both gcc and tsens compatibles)
* gcc ends up probing the virtual device/node _again_ (due to the gcc compatible match), fails
* At a later point, tsens driver gets registered (using module_initcall) ends up probing the virtual child node and succeeds

Is this what you had in mind, or am I at the wrong end of the stick?

regards,
Rajendra

#12 lore raw

PATCH 5/9 clk: qcom: gcc-msm8960: add child devices support.

Quoted 37 lines · Rajendra Nayak

Stephen,

Quoted 26 lines
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Quoted 4 lines

Also, I don't like having a subnode in DT. Why can't we use the same node as the GCC node and create a virtual child device here for tsens? We can assign the same of_node that this platform device has so that DT keeps working correctly.

So the current driver looks up data based on compatible strings.

The tsens device is always the same piece of hardware. The only

Well, not always. The one in 8960 does need additional initializations, requires you to save/restore context as it can be powered off not being in an always powered on domain etc.

Quoted 2 lines

thing that's changing is the qfprom data and the number of sensors. So we should be looking at the qfprom compatible string

How? Tsens uses nvmem framework apis to read the qfprom atleast in this series.

Quoted 7 lines

to figure out how to interpret the qfprom data which would include the number of sensors and how the data is encoded.

Quoted 3 lines

So you suggesting to create a virtual child device for gcc and associate the gcc DT node to it? (And have the tsens compatible mentioned as part of the gcc DT node?)

Quoted 8 lines
Quoted 4 lines

No. The driver should work just fine without having to interrogate the device's compatible string. If we still need the compatible check for some reason, then we can always match based on qcom,gcc-msm8960, qcom,gcc-apq8064, etc. But I don't see why

Thats not quite possible I guess. 2 drivers (gcc and tsens) matching the same compatibles? Will it not just depend on which ends up being the first match?

Quoted 7 lines

Any thoughts on how to move forward with this?

I tried what you were suggesting, and here's what I had to do to get things working

* Created a gcc node in DT with gcc and tsens compatibles, with gcc and tsens properties

This is not what I had in mind. This is what's should be in DT

clock-controller at f000 {

 	compatible = "qcom,gcc-msm8916";
	reg = <0xf000 ...>;
	....

};

Quoted 8 lines

* gcc driver probes the device/node first given gcc is registered with a core_initcall()
* creates a virtual child device attaching the same of_node (having both gcc and tsens compatibles)
* gcc ends up probing the virtual device/node _again_ (due to the gcc compatible match), fails
* At a later point, tsens driver gets registered (using module_initcall) ends up probing the virtual child node and succeeds

Yeah this might happen though because we've assigned the of_node pointer to the tsens device before we register it on the platform bus. The other way to pass that data down from gcc to tsens would be to not have an of_node assigned to the tsens device, and check for that case in the tsens driver. If there isn't an of_node, then we look at the parent device's of_node to figure out which gcc it is (if this even matters) and parse DT properties.

Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
#13 lore raw

PATCH 5/9 clk: qcom: gcc-msm8960: add child devices support.

[]..

Quoted 34 lines
Quoted 9 lines
Quoted 8 lines
Quoted 4 lines

No. The driver should work just fine without having to interrogate the device's compatible string. If we still need the compatible check for some reason, then we can always match based on qcom,gcc-msm8960, qcom,gcc-apq8064, etc. But I don't see why

Thats not quite possible I guess. 2 drivers (gcc and tsens) matching the same compatibles? Will it not just depend on which ends up being the first match?

Quoted 7 lines

Any thoughts on how to move forward with this?

I tried what you were suggesting, and here's what I had to do to get things working

* Created a gcc node in DT with gcc and tsens compatibles, with gcc and tsens properties

This is not what I had in mind. This is what's should be in DT

clock-controller at f000 {

  	compatible = "qcom,gcc-msm8916";
	reg = <0xf000 ...>;
	....

};

Quoted 8 lines

* gcc driver probes the device/node first given gcc is registered with a core_initcall()
* creates a virtual child device attaching the same of_node (having both gcc and tsens compatibles)
* gcc ends up probing the virtual device/node _again_ (due to the gcc compatible match), fails
* At a later point, tsens driver gets registered (using module_initcall) ends up probing the virtual child node and succeeds

Quoted 7 lines

Yeah this might happen though because we've assigned the of_node pointer to the tsens device before we register it on the platform bus. The other way to pass that data down from gcc to tsens would be to not have an of_node assigned to the tsens device, and check for that case in the tsens driver. If there isn't an of_node, then we look at the parent device's of_node to figure out which gcc it is (if this even matters) and parse DT properties.

Parsing DT properties from parent (in the tsens driver) is fine, but the nvmem apis still expect an of_node for the tsens device and hence fail.

Associating the of_node of the parent to the tsens device while being probed ends up with the same issues of gcc ending up probing the device and failing because tsens defers probe a couple times before a successful probe.

#14 lore raw

PATCH 5/9 clk: qcom: gcc-msm8960: add child devices support.

Quoted 9 lines · Rajendra Nayak
Quoted 8 lines

Yeah this might happen though because we've assigned the of_node pointer to the tsens device before we register it on the platform bus. The other way to pass that data down from gcc to tsens would be to not have an of_node assigned to the tsens device, and check for that case in the tsens driver. If there isn't an of_node, then we look at the parent device's of_node to figure out which gcc it is (if this even matters) and parse DT properties.

Quoted 3 lines

Parsing DT properties from parent (in the tsens driver) is fine, but the nvmem apis still expect an of_node for the tsens device and hence fail.

So pass the parent device to the nvmem APIs? Or adjust the nvmem APIs to look for a parent of_node if there isn't an of_node for the device being passed? Or make the nvmem APIs work without using DT, and copy over the nvmem information from the gcc node to the virtual tsens child device?

Quoted 5 lines

Associating the of_node of the parent to the tsens device while being probed ends up with the same issues of gcc ending up probing the device and failing because tsens defers probe a couple times before a successful probe.

Yeah sounds like we shouldn't do it that way.

Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
#15 lore raw

PATCH 5/9 clk: qcom: gcc-msm8960: add child devices support.

Quoted 14 lines · Stephen Boyd
Quoted 9 lines · Rajendra Nayak
Quoted 8 lines

Yeah this might happen though because we've assigned the of_node pointer to the tsens device before we register it on the platform bus. The other way to pass that data down from gcc to tsens would be to not have an of_node assigned to the tsens device, and check for that case in the tsens driver. If there isn't an of_node, then we look at the parent device's of_node to figure out which gcc it is (if this even matters) and parse DT properties.

Quoted 3 lines

Parsing DT properties from parent (in the tsens driver) is fine, but the nvmem apis still expect an of_node for the tsens device and hence fail.

Quoted 5 lines

So pass the parent device to the nvmem APIs? Or adjust the nvmem APIs to look for a parent of_node if there isn't an of_node for the device being passed? Or make the nvmem APIs work without using DT, and copy over the nvmem information from the gcc node to the virtual tsens child device?

Srini, you being the nvmem maintainer, any thoughts?

Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
hosted by The Linux Foundation
#16 lore raw

PATCH 5/9 clk: qcom: gcc-msm8960: add child devices support.

Quoted 16 lines · Rajendra Nayak
Quoted 14 lines · Stephen Boyd
Quoted 12 lines · Rajendra Nayak
Quoted 8 lines

Yeah this might happen though because we've assigned the of_node pointer to the tsens device before we register it on the platform bus. The other way to pass that data down from gcc to tsens would be to not have an of_node assigned to the tsens device, and check for that case in the tsens driver. If there isn't an of_node, then we look at the parent device's of_node to figure out which gcc it is (if this even matters) and parse DT properties.

Parsing DT properties from parent (in the tsens driver) is fine, but the nvmem apis still expect an of_node for the tsens device and hence fail.

Quoted 7 lines
Quoted 5 lines

So pass the parent device to the nvmem APIs? Or adjust the nvmem APIs to look for a parent of_node if there isn't an of_node for the device being passed? Or make the nvmem APIs work without using DT, and copy over the nvmem information from the gcc node to the virtual tsens child device?

Srini, you being the nvmem maintainer, any thoughts?

passing the parent device to nvmem APIs seems the cleanest to me, without having to change much with the nvmem APIs itself.

Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
hosted by The Linux Foundation
#17 lore raw

PATCH 5/9 clk: qcom: gcc-msm8960: add child devices support.

In reply to Rajendra Nayak
Quoted 16 lines · Rajendra Nayak
Quoted 14 lines · Stephen Boyd
Quoted 12 lines · Rajendra Nayak
Quoted 8 lines

Yeah this might happen though because we've assigned the of_node pointer to the tsens device before we register it on the platform bus. The other way to pass that data down from gcc to tsens would be to not have an of_node assigned to the tsens device, and check for that case in the tsens driver. If there isn't an of_node, then we look at the parent device's of_node to figure out which gcc it is (if this even matters) and parse DT properties.

Parsing DT properties from parent (in the tsens driver) is fine, but the nvmem apis still expect an of_node for the tsens device and hence fail.

Quoted 7 lines
Quoted 5 lines

So pass the parent device to the nvmem APIs? Or adjust the nvmem APIs to look for a parent of_node if there isn't an of_node for the device being passed? Or make the nvmem APIs work without using DT, and copy over the nvmem information from the gcc node to the virtual tsens child device?

Srini, you being the nvmem maintainer, any thoughts?

We could do either one of the below.
1> pass parent device for nvmem_get_cell as suggested by Stephen 2> use of_nvmem_get_cell() api to pass correct of_node

Both of them would work.

--srini

Quoted 1 line
#18 lore raw

PATCH 5/9 clk: qcom: gcc-msm8960: add child devices support.

In reply to Stephen Boyd
Quoted 23 lines · Stephen Boyd
Quoted 13 lines · Rajendra Nayak
drivers/clk/qcom/gcc-msm8960.c +1 -0
index eb6a4f9..2c80d03 100644
@@ -15,6 +15,7 @@
 #include <linux/bitops.h>
 #include <linux/err.h>
 #include <linux/platform_device.h>
+#include <linux/of_platform.h>
 #include <linux/module.h>
 #include <linux/of.h>
 #include <linux/of_device.h>

drivers/clk/qcom/gcc-msm8960.c static int gcc_msm8960_probe(struct platform_device *pdev) · line 3525

Quoted 6 lines
drivers/clk/qcom/gcc-msm8960.c +2 -1
@@ -3520,7 +3521,8 @@ static int gcc_msm8960_probe(struct platform_device *pdev)
 	if (IS_ERR(clk))
 		return PTR_ERR(clk);
 
-	return qcom_cc_probe(pdev, match->data);
+	qcom_cc_probe(pdev, match->data);
+	return of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev);

We just lost the error code from qcom_cc_probe()...

Quoted 5 lines

Also, I don't like having a subnode in DT. Why can't we use the same node as the GCC node and create a virtual child device here for tsens? We can assign the same of_node that this platform device has so that DT keeps working correctly.

Can't we make the gcc driver support being a child of a simple-mfd by having it attempting to acquire the regmap of the parent and falling back to creating its own mmio regmap?

That way we don't need to make tsense a child of the clock device and we're still backwards compatible.

Regards,
Bjorn

#19 lore raw

PATCH 5/9 clk: qcom: gcc-msm8960: add child devices support.

Quoted 24 lines · Bjorn Andersson
Quoted 22 lines · Stephen Boyd
Quoted 13 lines · Rajendra Nayak
drivers/clk/qcom/gcc-msm8960.c +1 -0
index eb6a4f9..2c80d03 100644
@@ -15,6 +15,7 @@
  #include <linux/bitops.h>
  #include <linux/err.h>
  #include <linux/platform_device.h>
+#include <linux/of_platform.h>
  #include <linux/module.h>
  #include <linux/of.h>
  #include <linux/of_device.h>

drivers/clk/qcom/gcc-msm8960.c static int gcc_msm8960_probe(struct platform_device *pdev) · line 3525

Quoted 6 lines
drivers/clk/qcom/gcc-msm8960.c +2 -1
@@ -3520,7 +3521,8 @@ static int gcc_msm8960_probe(struct platform_device *pdev)
  	if (IS_ERR(clk))
  		return PTR_ERR(clk);
 
-	return qcom_cc_probe(pdev, match->data);
+	qcom_cc_probe(pdev, match->data);
+	return of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev);

We just lost the error code from qcom_cc_probe()...

Quoted 8 lines
Quoted 5 lines

Also, I don't like having a subnode in DT. Why can't we use the same node as the GCC node and create a virtual child device here for tsens? We can assign the same of_node that this platform device has so that DT keeps working correctly.

Can't we make the gcc driver support being a child of a simple-mfd by having it attempting to acquire the regmap of the parent and falling back to creating its own mmio regmap?

So we would need to make a new device and driver for the simple-mfd parent? I'm confused about what you're suggesting and what benefit it has versus creating a child of the clock controller device.

Here's the patch I'm suggesting. The device name is probably wrong, but you get the idea.

----8<----

drivers/clk/qcom/gcc-msm8960.c +26 -1
index aa294b1bad34..802e9794f76e 100644
@@ -3505,7 +3505,9 @@ static int gcc_msm8960_probe(struct platform_device *pdev)
  {
  	struct clk *clk;
  	struct device *dev = &pdev->dev;
+	struct platform_device *tsens;
  	const struct of_device_id *match;
+	int ret;
  
  	match = of_match_device(gcc_msm8960_match_table, &pdev->dev);
  	if (!match)
@@ -3520,7 +3522,30 @@ static int gcc_msm8960_probe(struct platform_device *pdev)
  	if (IS_ERR(clk))
  		return PTR_ERR(clk);
  
-	return qcom_cc_probe(pdev, match->data);
+	ret = qcom_cc_probe(pdev, match->data);
+	if (ret)
+		return ret;
+
+	tsens = platform_device_alloc("tsens", -1);
+	if (!tsens) {
+		ret = -ENOMEM;
+		goto err_alloc;
+	}
+
+	tsens->dev.parent = &pdev->dev;
+	tsens->dev.of_node = pdev->dev.of_node;
+	ret = platform_device_add(tsens);
+	if (ret)
+		goto err_add;
+
+	return 0;
+
+err_add:
+	platform_device_put(tsens);
+err_alloc:
+	qcom_cc_remove(pdev);
+
+	return ret;
  }
  
  static int gcc_msm8960_remove(struct platform_device *pdev)
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
#20 lore raw

PATCH 5/9 clk: qcom: gcc-msm8960: add child devices support.

Quoted 30 lines · Stephen Boyd
Quoted 29 lines · Bjorn Andersson
Quoted 27 lines · Stephen Boyd
Quoted 13 lines · Rajendra Nayak
drivers/clk/qcom/gcc-msm8960.c +1 -0
index eb6a4f9..2c80d03 100644
@@ -15,6 +15,7 @@
  #include <linux/bitops.h>
  #include <linux/err.h>
  #include <linux/platform_device.h>
+#include <linux/of_platform.h>
  #include <linux/module.h>
  #include <linux/of.h>
  #include <linux/of_device.h>

drivers/clk/qcom/gcc-msm8960.c static int gcc_msm8960_probe(struct platform_device *pdev) · line 3525

Quoted 6 lines
drivers/clk/qcom/gcc-msm8960.c +2 -1
@@ -3520,7 +3521,8 @@ static int gcc_msm8960_probe(struct platform_device *pdev)
  	if (IS_ERR(clk))
  		return PTR_ERR(clk);
 
-	return qcom_cc_probe(pdev, match->data);
+	qcom_cc_probe(pdev, match->data);
+	return of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev);

We just lost the error code from qcom_cc_probe()...

Also, I don't like having a subnode in DT. Why can't we use the same node as the GCC node and create a virtual child device here for tsens? We can assign the same of_node that this platform device has so that DT keeps working correctly.

Quoted 6 lines
Quoted 3 lines

Can't we make the gcc driver support being a child of a simple-mfd by having it attempting to acquire the regmap of the parent and falling back to creating its own mmio regmap?

So we would need to make a new device and driver for the simple-mfd parent?

No that part is already in mainline, so my idea was that we add an early return in qcom_cc_map() like:

	 struct device *dev = &pdev->dev;

+ struct regmap *map;
+
+ map = syscon_node_to_regmap(dev->parent->of_node);
+ if (!IS_ERR(map))
+ return map;

And then just update the dts to:

	gcc {
		compatible = "syscon", "simple-mfd";
		reg = <0x00900000 0x4000>;

		gcc: clock-controller {
			compatible = "qcom,gcc-apq8064";
			#clock-cells = <1>;
			#reset-cells = <1>;
		};
	};

But as I implemented this I realized that the syscon_node_to_regmap() does not register the regmap as a devres of the parent, and as such it's not caught by the regmap lookup in devm_clk_register_regmap().

So either one would need to make the syscon throw the regmap into devres or make it possible to pass a regmap to devm_clk_register_regmap() for this to work.

Quoted 2 lines

I'm confused about what you're suggesting and what benefit it has versus creating a child of the clock controller device.

The benefit would simply be that we're using the already existing mechanism for handling multiple platform_drivers sharing a hw block.

Quoted 3 lines

Here's the patch I'm suggesting. The device name is probably wrong, but you get the idea.

Looks very much like my take on it as well, I do however have concerns that suddenly the node called "clock-controller" will have to come with tsens related properties.

Are all the tsens-in-gcc blocks the same? Or do you intend to of_match on the gcc compatible in the tsens driver?

Regards,
Bjorn

#21 lore raw

PATCH 5/9 clk: qcom: gcc-msm8960: add child devices support.

Quoted 10 lines · Bjorn Andersson
Quoted 2 lines · Stephen Boyd

Here's the patch I'm suggesting. The device name is probably wrong, but you get the idea.

Looks very much like my take on it as well, I do however have concerns that suddenly the node called "clock-controller" will have to come with tsens related properties.

Are all the tsens-in-gcc blocks the same?

Yes they're all the same, except some of them have more sensors than others. It depends on what SoC the hardware is instantiated in. They also messed up the software interface and had to add discontinuous registers for the sensors because it was never designed to have more than 4 sensors or something like that. But even that sort of change can be handled by figuring out the format of the sensor data in the qfprom.

Quoted 3 lines

Or do you intend to of_match
on the gcc compatible in the tsens driver?

I hope we don't have to of_match in the tsens driver on gcc compatible strings.

Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
#22 lore raw

PATCH 6/9 arm: dts: msm8974: Add thermal zones, tsens and eeprom nodes

In reply to Rajendra Nayak

Add thermal zones, tsens and eeprom nodes

---
 arch/arm/boot/dts/qcom-msm8974.dtsi | 105 ++++++++++++++++++++++++++++++++++++
 1 file changed, 105 insertions(+)
arch/arm/boot/dts/qcom-msm8974.dtsi +105 -0
index 37b47b5..30f3246 100644
@@ -75,6 +75,88 @@
 		};
 	};
 
+	thermal-zones {
+		cpu-thermal0 {
+			polling-delay-passive = <250>;
+			polling-delay = <1000>;
+
+			thermal-sensors = <&tsens 5>;
+
+			trips {
+				cpu_alert0: trip at 0 {
+					temperature = <75000>;
+					hysteresis = <2000>;
+					type = "passive";
+				};
+				cpu_crit0: trip at 1 {
+					temperature = <95000>;
+					hysteresis = <2000>;
+					type = "critical";
+				};
+			};
+		};
+
+		cpu-thermal1 {
+			polling-delay-passive = <250>;
+			polling-delay = <1000>;
+
+			thermal-sensors = <&tsens 6>;
+
+			trips {
+				cpu_alert1: trip at 0 {
+					temperature = <75000>;
+					hysteresis = <2000>;
+					type = "passive";
+				};
+				cpu_crit1: trip at 1 {
+					temperature = <95000>;
+					hysteresis = <2000>;
+					type = "critical";
+				};
+			};
+		};
+
+		cpu-thermal2 {
+			polling-delay-passive = <250>;
+			polling-delay = <1000>;
+
+			thermal-sensors = <&tsens 7>;
+
+			trips {
+				cpu_alert2: trip at 0 {
+					temperature = <75000>;
+					hysteresis = <2000>;
+					type = "passive";
+				};
+				cpu_crit2: trip at 1 {
+					temperature = <95000>;
+					hysteresis = <2000>;
+					type = "critical";
+				};
+			};
+		};
+
+		cpu-thermal3 {
+			polling-delay-passive = <250>;
+			polling-delay = <1000>;
+
+			thermal-sensors = <&tsens 8>;
+
+			trips {
+				cpu_alert3: trip at 0 {
+					temperature = <75000>;
+					hysteresis = <2000>;
+					type = "passive";
+				};
+				cpu_crit3: trip at 1 {
+					temperature = <95000>;
+					hysteresis = <2000>;
+					type = "critical";
+				};
+			};
+		};
+	};
+
 	cpu-pmu {
 		compatible = "qcom,krait-pmu";
 		interrupts = <1 7 0xf04>;
@@ -103,6 +185,29 @@
 			      <0xf9002000 0x1000>;
 		};
 
+		qfprom: qfprom at fc4bc000 {
+			#address-cells = <1>;
+			#size-cells = <1>;
+			compatible = "qcom,qfprom";
+			reg = <0xfc4bc000 0x1000>;
+			tsens_calib: calib at d0 {
+				reg = <0xd0 0x18>;
+			};
+			tsens_backup: backup at 440 {
+				reg = <0x440 0x10>;
+			};
+		};
+
+		tsens: thermal-sensor at fc4a8000 {
+			compatible = "qcom,msm8974-tsens";
+			reg = <0xfc4a8000 0x2000>;
+			nvmem-cell = <&tsens_calib>, <&tsens_backup>;
+			nvmem-cell-names = "calib", "calib_backup";
+			qcom,tsens-slopes = <3200 3200 3200 3200 3200 3200
+				3200 3200 3200 3200 3200>;
+			#thermal-sensor-cells = <1>;
+		};
+
 		timer at f9020000 {
 			#address-cells = <1>;
 			#size-cells = <1>;
Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation
#23 lore raw

PATCH 7/9 arm: dts: apq8064: Add thermal zones, tsens and eeprom nodes

In reply to Rajendra Nayak

Add thermal zones, tsens and eeprom nodes

---
 arch/arm/boot/dts/qcom-apq8064.dtsi | 108 ++++++++++++++++++++++++++++++++++++
 1 file changed, 108 insertions(+)
arch/arm/boot/dts/qcom-apq8064.dtsi +108 -0
index df2061e..c06e59f 100644
@@ -76,6 +76,88 @@
 		};
 	};
 
+	thermal-zones {
+		cpu-thermal0 {
+			polling-delay-passive = <250>;
+			polling-delay = <1000>;
+
+			thermal-sensors = <&tsens 7>;
+
+			trips {
+				cpu_alert0: trip at 0 {
+					temperature = <75000>;
+					hysteresis = <2000>;
+					type = "passive";
+				};
+				cpu_crit0: trip at 1 {
+					temperature = <95000>;
+					hysteresis = <2000>;
+					type = "critical";
+				};
+			};
+		};
+
+		cpu-thermal1 {
+			polling-delay-passive = <250>;
+			polling-delay = <1000>;
+
+			thermal-sensors = <&tsens 8>;
+
+			trips {
+				cpu_alert1: trip at 0 {
+					temperature = <75000>;
+					hysteresis = <2000>;
+					type = "passive";
+				};
+				cpu_crit1: trip at 1 {
+					temperature = <95000>;
+					hysteresis = <2000>;
+					type = "critical";
+				};
+			};
+		};
+
+		cpu-thermal2 {
+			polling-delay-passive = <250>;
+			polling-delay = <1000>;
+
+			thermal-sensors = <&tsens 9>;
+
+			trips {
+				cpu_alert2: trip at 0 {
+					temperature = <75000>;
+					hysteresis = <2000>;
+					type = "passive";
+				};
+				cpu_crit2: trip at 1 {
+					temperature = <95000>;
+					hysteresis = <2000>;
+					type = "critical";
+				};
+			};
+		};
+
+		cpu-thermal3 {
+			polling-delay-passive = <250>;
+			polling-delay = <1000>;
+
+			thermal-sensors = <&tsens 10>;
+
+			trips {
+				cpu_alert3: trip at 0 {
+					temperature = <75000>;
+					hysteresis = <2000>;
+					type = "passive";
+				};
+				cpu_crit3: trip at 1 {
+					temperature = <95000>;
+					hysteresis = <2000>;
+					type = "critical";
+				};
+			};
+		};
+	};
+
 	cpu-pmu {
 		compatible = "qcom,krait-pmu";
 		interrupts = <1 10 0x304>;
@@ -289,11 +371,37 @@
 			qcom,controller-type = "pmic-arbiter";
 		};
 
+		qfprom: qfprom at 00700000 {
+			compatible	= "qcom,qfprom";
+			reg		= <0x00700000 0x1000>;
+			#address-cells	= <1>;
+			#size-cells	= <1>;
+			ranges;
+			tsens_calib: calib {
+				reg = <0x404 0x10>;
+			};
+			tsens_backup: backup_calib {
+				reg = <0x414 0x10>;
+			};
+		};
+
 		gcc: clock-controller at 900000 {
 			compatible = "qcom,gcc-apq8064";
 			reg = <0x00900000 0x4000>;
 			#clock-cells = <1>;
 			#reset-cells = <1>;
+			#address-cells	= <1>;
+			#size-cells	= <1>;
+			ranges;
+
+			tsens: thermal-sensor at 900000 {
+				compatible = "qcom,msm8960-tsens";
+				nvmem-cell = <&tsens_calib>, <&tsens_backup>;
+				nvmem-cell-names = "calib", "calib_backup";
+				qcom,tsens-slopes = <1176 1176 1154 1176 1111
+					1132 1132 1199 1132 1199 1132>;
+				#thermal-sensor-cells = <1>;
+			};
 		};
 
 		lcc: clock-controller at 28000000 {
Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation
#24 lore raw

PATCH 8/9 arm: dts: apq8084: Add thermal zones, tsens and eeprom nodes

In reply to Rajendra Nayak

Add thermal zones, tsens and eeprom nodes

---
 arch/arm/boot/dts/qcom-apq8084.dtsi | 105 ++++++++++++++++++++++++++++++++++++
 1 file changed, 105 insertions(+)
arch/arm/boot/dts/qcom-apq8084.dtsi +105 -0
index 7084010..05e83ea 100644
@@ -75,6 +75,88 @@
 		};
 	};
 
+	thermal-zones {
+		cpu-thermal0 {
+			polling-delay-passive = <250>;
+			polling-delay = <1000>;
+
+			thermal-sensors = <&tsens 5>;
+
+			trips {
+				cpu_alert0: trip at 0 {
+					temperature = <75000>;
+					hysteresis = <2000>;
+					type = "passive";
+				};
+				cpu_crit0: trip at 1 {
+					temperature = <95000>;
+					hysteresis = <2000>;
+					type = "critical";
+				};
+			};
+		};
+
+		cpu-thermal1 {
+			polling-delay-passive = <250>;
+			polling-delay = <1000>;
+
+			thermal-sensors = <&tsens 6>;
+
+			trips {
+				cpu_alert1: trip at 0 {
+					temperature = <75000>;
+					hysteresis = <2000>;
+					type = "passive";
+				};
+				cpu_crit1: trip at 1 {
+					temperature = <95000>;
+					hysteresis = <2000>;
+					type = "critical";
+				};
+			};
+		};
+
+		cpu-thermal2 {
+			polling-delay-passive = <250>;
+			polling-delay = <1000>;
+
+			thermal-sensors = <&tsens 7>;
+
+			trips {
+				cpu_alert2: trip at 0 {
+					temperature = <75000>;
+					hysteresis = <2000>;
+					type = "passive";
+				};
+				cpu_crit2: trip at 1 {
+					temperature = <95000>;
+					hysteresis = <2000>;
+					type = "critical";
+				};
+			};
+		};
+
+		cpu-thermal3 {
+			polling-delay-passive = <250>;
+			polling-delay = <1000>;
+
+			thermal-sensors = <&tsens 8>;
+
+			trips {
+				cpu_alert3: trip at 0 {
+					temperature = <75000>;
+					hysteresis = <2000>;
+					type = "passive";
+				};
+				cpu_crit3: trip at 1 {
+					temperature = <95000>;
+					hysteresis = <2000>;
+					type = "critical";
+				};
+			};
+		};
+	};
+
 	cpu-pmu {
 		compatible = "qcom,krait-pmu";
 		interrupts = <1 7 0xf04>;
@@ -103,6 +185,29 @@
 			      <0xf9002000 0x1000>;
 		};
 
+		qfprom: qfprom at fc4bc000 {
+			#address-cells = <1>;
+			#size-cells = <1>;
+			compatible = "qcom,qfprom";
+			reg = <0xfc4bc000 0x1000>;
+			tsens_calib: calib at d0 {
+				reg = <0xd0 0x18>;
+			};
+			tsens_backup: backup at 440 {
+				reg = <0x440 0x10>;
+			};
+		};
+
+		tsens: thermal-sensor at fc4a8000 {
+			compatible = "qcom,msm8974-tsens";
+			reg = <0xfc4a8000 0x2000>;
+			nvmem-cell = <&tsens_calib>, <&tsens_backup>;
+			nvmem-cell-names = "calib", "calib_backup";
+			qcom,tsens-slopes = <3200 3200 3200 3200 3200 3200
+				3200 3200 3200 3200 3200>;
+			#thermal-sensor-cells = <1>;
+		};
+
 		timer at f9020000 {
 			#address-cells = <1>;
 			#size-cells = <1>;
Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation
#25 lore raw

PATCH 9/9 arm64: dts: msm8916: Add thermal zones, tsens and eeprom nodes

In reply to Rajendra Nayak

Add thermal zones, tsens and eeprom nodes

---
 arch/arm64/boot/dts/qcom/msm8916.dtsi | 66 +++++++++++++++++++++++++++++++++++
 1 file changed, 66 insertions(+)
arch/arm64/boot/dts/qcom/msm8916.dtsi +66 -0
index 0f49ebd..9ff9979 100644
@@ -63,6 +63,49 @@
 		};
 	};
 
+	thermal-zones {
+		cpu-thermal0 {
+			polling-delay-passive = <250>;
+			polling-delay = <1000>;
+
+			thermal-sensors = <&tsens 4>;
+
+			trips {
+				cpu_alert0: trip at 0 {
+					temperature = <100000>;
+					hysteresis = <2000>;
+					type = "passive";
+				};
+				cpu_crit0: trip at 1 {
+					temperature = <125000>;
+					hysteresis = <2000>;
+					type = "critical";
+				};
+			};
+		};
+
+		cpu-thermal1 {
+			polling-delay-passive = <250>;
+			polling-delay = <1000>;
+
+			thermal-sensors = <&tsens 3>;
+
+			trips {
+				cpu_alert1: trip at 0 {
+					temperature = <100000>;
+					hysteresis = <2000>;
+					type = "passive";
+				};
+				cpu_crit1: trip at 1 {
+					temperature = <125000>;
+					hysteresis = <2000>;
+					type = "critical";
+				};
+			};
+		};
+
+	};
+
 	timer {
 		compatible = "arm,armv8-timer";
 		interrupts = <GIC_PPI 2 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_LOW)>,
@@ -215,5 +258,28 @@
 			interrupt-controller;
 			#interrupt-cells = <4>;
 		};
+
+		qfprom: qfprom at 5c000 {
+			compatible = "qcom,qfprom";
+			reg = <0x5c000 0x1000>;
+			#address-cells = <1>;
+			#size-cells = <1>;
+			tsens_caldata: caldata at d0 {
+				reg = <0xd0 0x8>;
+			};
+			tsens_calsel: calsel at ec {
+				reg = <0xec 0x4>;
+			};
+		};
+
+		tsens: thermal-sensor at 4a8000 {
+			compatible = "qcom,msm8916-tsens";
+			reg = <0x4a8000 0x2000>;
+			nvmem-cell = <&tsens_caldata>, <&tsens_calsel>;
+			nvmem-cell-names = "calib", "calib_sel";
+			qcom,tsens-slopes = <3200 3200 3200 3200 3200>;
+			qcom,sensor-id = <0 1 2 4 5>;
+			#thermal-sensor-cells = <1>;
+		};
 	};
 };
Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation
#26 lore raw

cover qcom: Add support for TSENS driver

In reply to Rajendra Nayak

Hi Rajendra,

Quoted 57 lines · Rajendra Nayak

Changes since RFC:
* Added support for 8916 and 8084
* Based off the latest nvmem framework patches [1]
* Minor review fixes for comments mostly from Lina

** I have also added irq support using the hardware trip point support series [2]. Will post that out seperately.

This is an attempt to have a single TSENS driver for the different versions of the TSENS IP that exist, on different qcom msm/apq SoCs'
Support is added for msm8916, msm8960 and msm8974 families. Based on top of the latest nvmem framework patches [2]

A lot of the work is based of original code from Stephen Boyd and Siddartha Mohanadoss. I have also picked some of what Narendran Rajan did in his attempt to upstream the support for 8960 family. I could not keep the original authorship on any of the patches because I ended up moving the code around quite a bit in an effort to have a single driver for the various devices. I would be glad to change the authorship for any of the patches if needed.

[1] https://lkml.org/lkml/2015/6/22/609
[2] https://lkml.org/lkml/2015/5/20/472

Rajendra Nayak (8):
thermal: qcom: tsens: Add a skeletal TSENS drivers
thermal: qcom: tsens-8916: Add support for 8916 family of SoCs
thermal: qcom: tsens-8974: Add support for 8974 family of SoCs
thermal: qcom: tsens-8960: Add support for 8960 family of SoCs
arm: dts: msm8974: Add thermal zones, tsens and eeprom nodes
arm: dts: apq8064: Add thermal zones, tsens and eeprom nodes
arm: dts: apq8084: Add thermal zones, tsens and eeprom nodes
arm64: dts: msm8916: Add thermal zones, tsens and eeprom nodes

Srinivas Kandagatla (1):
clk: qcom: gcc-msm8960: add child devices support.

  .../devicetree/bindings/thermal/qcom-tsens.txt     |  37 +++
  arch/arm/boot/dts/qcom-apq8064.dtsi                | 108 ++++++++
  arch/arm/boot/dts/qcom-apq8084.dtsi                | 105 ++++++++
  arch/arm/boot/dts/qcom-msm8974.dtsi                | 105 ++++++++
  arch/arm64/boot/dts/qcom/msm8916.dtsi              |  66 +++++
  drivers/clk/qcom/gcc-msm8960.c                     |   4 +-
  drivers/thermal/Kconfig                            |   5 +
  drivers/thermal/Makefile                           |   1 +
  drivers/thermal/qcom/Kconfig                       |  10 +
  drivers/thermal/qcom/Makefile                      |   2 +
  drivers/thermal/qcom/tsens-8916.c                  | 107 ++++++++
  drivers/thermal/qcom/tsens-8960.c                  | 291 +++++++++++++++++++++
  drivers/thermal/qcom/tsens-8974.c                  | 239 +++++++++++++++++
  drivers/thermal/qcom/tsens-common.c                | 128 +++++++++
  drivers/thermal/qcom/tsens.c                       | 209 +++++++++++++++
  drivers/thermal/qcom/tsens.h                       |  69 +++++
  16 files changed, 1485 insertions(+), 1 deletion(-)
Quoted 10 lines

create mode 100644 Documentation/devicetree/bindings/thermal/qcom-tsens.txt create mode 100644 drivers/thermal/qcom/Kconfig
create mode 100644 drivers/thermal/qcom/Makefile
create mode 100644 drivers/thermal/qcom/tsens-8916.c
create mode 100644 drivers/thermal/qcom/tsens-8960.c
create mode 100644 drivers/thermal/qcom/tsens-8974.c
create mode 100644 drivers/thermal/qcom/tsens-common.c
create mode 100644 drivers/thermal/qcom/tsens.c
create mode 100644 drivers/thermal/qcom/tsens.h

NVMEM framework in now available in linux-next.

Do you think we can get this in v4.3?

--srini