Skip to contentSkip to conversation

thermal: add omap3 support

PATCH Superseded Pavel Machek 2 participants 14 messages Jan 3, 2015 – Mar 23, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 thermal: add omap3 support

Add support for omap3430 sensor. Tested on Nokia N900.

drivers/thermal/ti-soc-thermal/Kconfig +9 -0
index bd4c7be..a49495f 100644
@@ -21,6 +21,15 @@ config TI_THERMAL
 	  This includes trip points definitions, extrapolation rules and
 	  CPU cooling device bindings.
 
+config OMAP3_THERMAL
+	bool "Texas Instruments OMAP3 thermal support"
+	depends on TI_SOC_THERMAL
+	depends on ARCH_OMAP3
+	help
+	  If you say yes here you get thermal support for the Texas Instruments
+	  OMAP3 SoC family. The current chip supported are:
+	   - OMAP3430
+
 config OMAP4_THERMAL
 	bool "Texas Instruments OMAP4 thermal support"
 	depends on TI_SOC_THERMAL
drivers/thermal/ti-soc-thermal/Makefile +1 -0
index 1226b24..2b5b220 100644
@@ -2,5 +2,6 @@ obj-$(CONFIG_TI_SOC_THERMAL)		+= ti-soc-thermal.o
 ti-soc-thermal-y			:= ti-bandgap.o
 ti-soc-thermal-$(CONFIG_TI_THERMAL)	+= ti-thermal-common.o
 ti-soc-thermal-$(CONFIG_DRA752_THERMAL)	+= dra752-thermal-data.o
+ti-soc-thermal-$(CONFIG_OMAP3_THERMAL)	+= omap3-thermal-data.o
 ti-soc-thermal-$(CONFIG_OMAP4_THERMAL)	+= omap4-thermal-data.o
 ti-soc-thermal-$(CONFIG_OMAP5_THERMAL)	+= omap5-thermal-data.o
drivers/thermal/ti-soc-thermal/omap3-thermal-data.c new file +95 -0

95 lines not on this page · raw message

drivers/thermal/ti-soc-thermal/ti-bandgap.c +6 -0
index 634b6ce..3b4e72f 100644
@@ -1509,6 +1531,12 @@ static SIMPLE_DEV_PM_OPS(ti_bandgap_dev_pm_ops, ti_bandgap_suspend,
 #endif
 
 static const struct of_device_id of_ti_bandgap_match[] = {
+#ifdef CONFIG_OMAP3_THERMAL
+	{
+		.compatible = "ti,omap34xx-bandgap",
+		.data = (void *)&omap34xx_data,
+	},
+#endif
 #ifdef CONFIG_OMAP4_THERMAL
 	{
 		.compatible = "ti,omap4430-bandgap",
drivers/thermal/ti-soc-thermal/ti-bandgap.h +2 -0
index b3adf72..3f05386 100644
@@ -384,6 +384,8 @@ int ti_bandgap_set_sensor_data(struct ti_bandgap *bgp, int id, void *data);
 void *ti_bandgap_get_sensor_data(struct ti_bandgap *bgp, int id);
 int ti_bandgap_get_trend(struct ti_bandgap *bgp, int id, int *trend);
 
+extern const struct ti_bandgap_data omap34xx_data;
+
 #ifdef CONFIG_OMAP4_THERMAL
 extern const struct ti_bandgap_data omap4430_data;
 extern const struct ti_bandgap_data omap4460_data;
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
maintainer
#1 lore raw

Hello Pavel,

Thanks for sending your code.

Quoted 1 line · Pavel Machek

Add support for omap3430 sensor. Tested on Nokia N900.

To my understanding, and as already mentioned by Nishanth Menon (currently TIer), TI has intentionally avoided adding this support.

There is a hardware accuracy limitation in this sensor, and therefore it is not advisable to use it, specially in Dynamic Thermal Management, such as the thermal framework.

Quoted 9 lines
drivers/thermal/ti-soc-thermal/Kconfig +0 -0
index bd4c7be..a49495f 100644
@@ -21,6 +21,15 @@ config TI_THERMAL
 	  This includes trip points definitions, extrapolation rules and

drivers/thermal/ti-soc-thermal/Kconfig config TI_THERMAL · line 31

Quoted 10 lines
drivers/thermal/ti-soc-thermal/Kconfig +8 -0
 	  CPU cooling device bindings.
 
+config OMAP3_THERMAL
+	bool "Texas Instruments OMAP3 thermal support"
+	depends on TI_SOC_THERMAL
+	depends on ARCH_OMAP3
+	help
+	  If you say yes here you get thermal support for the Texas Instruments
+	  OMAP3 SoC family. The current chip supported are:
+	   - OMAP3430

But if you insist :-), I believe the user deserves at least a fair message saying this is on his / her own risk.

Quoted 47 lines
drivers/thermal/ti-soc-thermal/Kconfig +1 -0
+
 config OMAP4_THERMAL
 	bool "Texas Instruments OMAP4 thermal support"
 	depends on TI_SOC_THERMAL
drivers/thermal/ti-soc-thermal/Makefile +1 -0
index 1226b24..2b5b220 100644
@@ -2,5 +2,6 @@ obj-$(CONFIG_TI_SOC_THERMAL)		+= ti-soc-thermal.o
 ti-soc-thermal-y			:= ti-bandgap.o
 ti-soc-thermal-$(CONFIG_TI_THERMAL)	+= ti-thermal-common.o
 ti-soc-thermal-$(CONFIG_DRA752_THERMAL)	+= dra752-thermal-data.o
+ti-soc-thermal-$(CONFIG_OMAP3_THERMAL)	+= omap3-thermal-data.o
 ti-soc-thermal-$(CONFIG_OMAP4_THERMAL)	+= omap4-thermal-data.o
 ti-soc-thermal-$(CONFIG_OMAP5_THERMAL)	+= omap5-thermal-data.o
drivers/thermal/ti-soc-thermal/omap3-thermal-data.c new file +26 -0
new file mode 100644
index 0000000..7c18766
@@ -0,0 +1,95 @@
+/*
+ * OMAP3 thermal driver.
+ *
+ * Copyright (C) 2011-2012 Texas Instruments Inc.
+ * Copyright (C) 2014 Pavel Machek <[email protected]>
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#include "ti-thermal.h"
+#include "ti-bandgap.h"
+
+/*
+ * OMAP34XX has one instance of thermal sensor for MPU
+ * need to describe the individual bit fields
+ */
+static struct temp_sensor_registers
+omap34xx_mpu_temp_sensor_registers = {

drivers/thermal/ti-soc-thermal/omap3-thermal-data.c line 36

Quoted 10 lines
drivers/thermal/ti-soc-thermal/omap3-thermal-data.c new file +10 -0
+	.temp_sensor_ctrl = 0,
+	.bgap_tempsoff_mask = 0, /* Unused, we don't have POWER_SWITCH */
+	.bgap_soc_mask = BIT(8),
+	.bgap_eocz_mask = BIT(7),
+	.bgap_dtemp_mask = 0x7f,
+
+	.bgap_mode_ctrl = 0,
+	.mode_ctrl_mask = BIT(9),
+
+	.bgap_efuse = 0,

The 0'ed filed may be removed here.

Quoted 64 lines
drivers/thermal/ti-soc-thermal/omap3-thermal-data.c new file +59 -0
+};
+
+/* Thresholds and limits for OMAP34XX MPU temperature sensor */
+static struct temp_sensor_data omap34xx_mpu_temp_sensor_data = {
+	.min_freq = 32768,
+	.max_freq = 32768,
+	.max_temp = -99000,
+	.min_temp = 99000,
+	.hyst_val = 5000,
+};
+
+/*
+ * Temperature values in milli degree celsius
+ */
+static const int
+omap34xx_adc_to_temp[128] = {
+	-40000, -40000, -40000, -40000, -40000, -39000, -38000, -36000,
+	-34000, -32000, -31000,	-29000, -28000, -26000, -25000, -24000,
+	-22000, -21000, -19000, -18000, -17000, -15000,	-14000, -12000,
+	-11000, -9000, -8000, -7000, -5000, -4000, -2000, -1000, 0000,
+	1000, 3000, 4000, 5000, 7000, 8000, 10000, 11000, 13000, 14000,
+	15000, 17000, 18000, 20000, 21000, 22000, 24000, 25000, 27000,
+	28000, 30000, 31000, 32000, 34000, 35000, 37000, 38000, 39000,
+	41000, 42000, 44000, 45000, 47000, 48000, 49000, 51000, 52000,
+	53000, 55000, 56000, 58000, 59000, 60000, 62000, 63000, 65000,
+	66000, 67000, 69000, 70000, 72000, 73000, 74000, 76000, 77000,
+	79000, 80000, 81000, 83000, 84000, 85000, 87000, 88000, 89000,
+	91000, 92000, 94000, 95000, 96000, 98000, 99000, 100000,
+	102000, 103000, 105000, 106000, 107000, 109000, 110000, 111000,
+	113000, 114000, 116000, 117000, 118000, 120000, 121000, 122000,
+	124000, 124000, 125000, 125000, 125000, 125000,	125000
+};
+
+/* OMAP34XX data */
+const struct ti_bandgap_data omap34xx_data = {
+	.features = TI_BANDGAP_FEATURE_CLK_CTRL /* | TI_BANDGAP_FEATURE_MODE_CONFIG */,
+	.fclock_name = "ts_fck",
+	.div_ck_name = "ts_fck",
+	.conv_table = omap34xx_adc_to_temp,
+	.adc_start_val = 0,
+	.adc_end_val = 127,
+	.expose_sensor = ti_thermal_expose_sensor,
+	.remove_sensor = ti_thermal_remove_sensor,
+
+	.sensors = {
+		{
+		.registers = &omap34xx_mpu_temp_sensor_registers,
+		.ts_data = &omap34xx_mpu_temp_sensor_data,
+		.domain = "cpu",
+		.slope = 0,
+		.constant = 20000,
+		.slope_pcb = 0,
+		.constant_pcb = 20000,
+		.register_cooling = NULL,
+		.unregister_cooling = NULL,
+		},
+	},
+	.sensor_count = 1,
+};
drivers/thermal/ti-soc-thermal/ti-bandgap.c +0 -0
index 634b6ce..3b4e72f 100644

drivers/thermal/ti-soc-thermal/ti-bandgap.c static SIMPLE_DEV_PM_OPS(ti_bandgap_dev_pm_ops, ti_bandgap_suspend, · line 1536

Quoted 6 lines
drivers/thermal/ti-soc-thermal/ti-bandgap.c +3 -0
@@ -1509,6 +1531,12 @@ static SIMPLE_DEV_PM_OPS(ti_bandgap_dev_pm_ops, ti_bandgap_suspend,
 #endif
 
 static const struct of_device_id of_ti_bandgap_match[] = {
+#ifdef CONFIG_OMAP3_THERMAL
+	{
+		.compatible = "ti,omap34xx-bandgap",

This needs to be updated in the binding documentation. Documentation/devicetree/bindings/thermal/ti_soc_thermal.txt

drivers/thermal/ti-soc-thermal/ti-bandgap.c static SIMPLE_DEV_PM_OPS(ti_bandgap_dev_pm_ops, ti_bandgap_suspend, · line 1537

Quoted 1 line
drivers/thermal/ti-soc-thermal/ti-bandgap.c +1 -0
+		.data = (void *)&omap34xx_data,

Having a run time message intentionally advising users of the risk of using this sensor is also required.

Quoted 22 lines
drivers/thermal/ti-soc-thermal/ti-bandgap.c +2 -0
+	},
+#endif
 #ifdef CONFIG_OMAP4_THERMAL
 	{
 		.compatible = "ti,omap4430-bandgap",
drivers/thermal/ti-soc-thermal/ti-bandgap.h +2 -0
index b3adf72..3f05386 100644
@@ -384,6 +384,8 @@ int ti_bandgap_set_sensor_data(struct ti_bandgap *bgp, int id, void *data);
 void *ti_bandgap_get_sensor_data(struct ti_bandgap *bgp, int id);
 int ti_bandgap_get_trend(struct ti_bandgap *bgp, int id, int *trend);
 
+extern const struct ti_bandgap_data omap34xx_data;
+
 #ifdef CONFIG_OMAP4_THERMAL
 extern const struct ti_bandgap_data omap4430_data;
 extern const struct ti_bandgap_data omap4460_data;
Signature · 3 lines
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20150103/e40fab4a/attachment-0001.sig>

#2 lore raw

Hi!

Quoted 1 line

Thanks for sending your code.

You are welcome.

Quoted 4 lines
Quoted 1 line

Add support for omap3430 sensor. Tested on Nokia N900.

To my understanding, and as already mentioned by Nishanth Menon (currently TIer), TI has intentionally avoided adding this support.

Well, Nokia had similar code in their kernel.

Quoted 3 lines

There is a hardware accuracy limitation in this sensor, and therefore it is not advisable to use it, specially in Dynamic Thermal Management, such as the thermal framework.

We are talking cellphone here. Yes, sensor may be inacurate (but it seems to work pretty well; perhaps TI can point us to some docs that explains the details?), but it provides useful information (mostly room temperature). I don't think we'll ever run anywhere close to thermal limits where inacuracy would matter. (Battery can't really take > 60C. AFAICT CPU limit is 120C. Battery is close to the CPU.)

Quoted 10 lines
Quoted 10 lines
drivers/thermal/ti-soc-thermal/Kconfig +0 -0
index bd4c7be..a49495f 100644
@@ -21,6 +21,15 @@ config TI_THERMAL
 	  This includes trip points definitions, extrapolation rules and
 	  CPU cooling device bindings.
 
Quoted 11 lines

drivers/thermal/ti-soc-thermal/Kconfig config TI_THERMAL · line 31

Quoted 8 lines
drivers/thermal/ti-soc-thermal/Kconfig +8 -0
+config OMAP3_THERMAL
+	bool "Texas Instruments OMAP3 thermal support"
+	depends on TI_SOC_THERMAL
+	depends on ARCH_OMAP3
+	help
+	  If you say yes here you get thermal support for the Texas Instruments
+	  OMAP3 SoC family. The current chip supported are:
+	   - OMAP3430

But if you insist :-), I believe the user deserves at least a fair message saying this is on his / her own risk.

Something like this?

If you say yes here you get thermal support for the Texas Instruments OMAP3 SoC family. The current chip supported are:
- OMAP3430

OMAP3 chips normally don't need thermal management, and sensors in this generation are not very accurate, nor they are very close to the important hotspots.

Say 'N' here.

Quoted 6 lines
Quoted 6 lines
drivers/thermal/ti-soc-thermal/Kconfig +6 -0
+static struct temp_sensor_registers
+omap34xx_mpu_temp_sensor_registers = {
+	.temp_sensor_ctrl = 0,
+	.bgap_tempsoff_mask = 0, /* Unused, we don't have POWER_SWITCH */
+	.bgap_soc_mask = BIT(8),
+	.bgap_eocz_mask = BIT(7),
Quoted 8 lines

drivers/thermal/ti-soc-thermal/Kconfig

Quoted 6 lines
drivers/thermal/ti-soc-thermal/Kconfig +6 -0
+	.bgap_dtemp_mask = 0x7f,
+
+	.bgap_mode_ctrl = 0,
+	.mode_ctrl_mask = BIT(9),
+
+	.bgap_efuse = 0,

The 0'ed filed may be removed here.

Ok; I'll keep temp_sensors_ctrl / bgap_mode_ctrl, because it is actually used.

Quoted 7 lines
Quoted 7 lines
drivers/thermal/ti-soc-thermal/ti-bandgap.c +0 -0
index 634b6ce..3b4e72f 100644
@@ -1509,6 +1531,12 @@ static SIMPLE_DEV_PM_OPS(ti_bandgap_dev_pm_ops, ti_bandgap_suspend,
 #endif
 
Quoted 7 lines

drivers/thermal/ti-soc-thermal/ti-bandgap.c static SIMPLE_DEV_PM_OPS(ti_bandgap_dev_pm_ops, ti_bandgap_suspend, · line 1536

Quoted 4 lines
drivers/thermal/ti-soc-thermal/ti-bandgap.c +3 -0
 static const struct of_device_id of_ti_bandgap_match[] = {
+#ifdef CONFIG_OMAP3_THERMAL
+	{
+		.compatible = "ti,omap34xx-bandgap",

This needs to be updated in the binding documentation. Documentation/devicetree/bindings/thermal/ti_soc_thermal.txt

Ok.

Quoted 5 lines

drivers/thermal/ti-soc-thermal/ti-bandgap.c static SIMPLE_DEV_PM_OPS(ti_bandgap_dev_pm_ops, ti_bandgap_suspend, · line 1537

Quoted 1 line
drivers/thermal/ti-soc-thermal/ti-bandgap.c +1 -0
+		.data = (void *)&omap34xx_data,

Having a run time message intentionally advising users of the risk of using this sensor is also required.

Ok, what about?

    if (TI_BANDGAP_HAS(bgp, UNRELIABLE))
              dev_warn(&pdev->dev,
                         "OMAP3 thermal sensor is unreliable and normally unneccessary\n");

Will not fit in 80 columns, but keeping message on one line is more important.
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
maintainer
#3 lore raw
Quoted 13 lines · Pavel Machek

Hi!

Quoted 1 line

Thanks for sending your code.

You are welcome.

Quoted 4 lines
Quoted 1 line

Add support for omap3430 sensor. Tested on Nokia N900.

To my understanding, and as already mentioned by Nishanth Menon (currently TIer), TI has intentionally avoided adding this support.

Well, Nokia had similar code in their kernel.

Quoted 7 lines
Quoted 3 lines

There is a hardware accuracy limitation in this sensor, and therefore it is not advisable to use it, specially in Dynamic Thermal Management, such as the thermal framework.

We are talking cellphone here. Yes, sensor may be inacurate (but it seems to work pretty well; perhaps TI can point us to some docs that explains the details?), but it provides useful information (mostly

sure! you should demand TI the proper data pointers.

Quoted 3 lines

room temperature). I don't think we'll ever run anywhere close to thermal limits where inacuracy would matter. (Battery can't really take > 60C. AFAICT CPU limit is 120C. Battery is close to the CPU.)

Well, when the sensor's accuracy is +-15C and there is variance across the sample distribution, well, that means you are gonna see products behaving way different from each other, even if you are attempting to find a threshold to shutdown a device.

BTW, I am not a TIer anymore, and I don't have the exact data to provide you.

Quoted 25 lines
Quoted 11 lines
Quoted 11 lines
drivers/thermal/ti-soc-thermal/Kconfig +0 -0
index bd4c7be..a49495f 100644
@@ -21,6 +21,15 @@ config TI_THERMAL
 	  This includes trip points definitions, extrapolation rules and
 	  CPU cooling device bindings.
 
Quoted 11 lines

drivers/thermal/ti-soc-thermal/Kconfig config TI_THERMAL · line 31

Quoted 8 lines
drivers/thermal/ti-soc-thermal/Kconfig +8 -0
+config OMAP3_THERMAL
+	bool "Texas Instruments OMAP3 thermal support"
+	depends on TI_SOC_THERMAL
+	depends on ARCH_OMAP3
+	help
+	  If you say yes here you get thermal support for the Texas Instruments
+	  OMAP3 SoC family. The current chip supported are:
+	   - OMAP3430

But if you insist :-), I believe the user deserves at least a fair message saying this is on his / her own risk.

Something like this?

Quoted 7 lines

If you say yes here you get thermal support for the Texas Instruments OMAP3 SoC family. The current chip supported are:
- OMAP3430

OMAP3 chips normally don't need thermal management, and sensors in this generation are not very accurate, nor they are very close to the important hotspots.

I would be stronger and rephrase with s/very//g.

Quoted 45 lines

Say 'N' here.

Quoted 6 lines
Quoted 6 lines
drivers/thermal/ti-soc-thermal/Kconfig +6 -0
+static struct temp_sensor_registers
+omap34xx_mpu_temp_sensor_registers = {
+	.temp_sensor_ctrl = 0,
+	.bgap_tempsoff_mask = 0, /* Unused, we don't have POWER_SWITCH */
+	.bgap_soc_mask = BIT(8),
+	.bgap_eocz_mask = BIT(7),
Quoted 8 lines

drivers/thermal/ti-soc-thermal/Kconfig

Quoted 6 lines
drivers/thermal/ti-soc-thermal/Kconfig +6 -0
+	.bgap_dtemp_mask = 0x7f,
+
+	.bgap_mode_ctrl = 0,
+	.mode_ctrl_mask = BIT(9),
+
+	.bgap_efuse = 0,

The 0'ed filed may be removed here.

Ok; I'll keep temp_sensors_ctrl / bgap_mode_ctrl, because it is actually used.

Quoted 7 lines
Quoted 7 lines
drivers/thermal/ti-soc-thermal/ti-bandgap.c +0 -0
index 634b6ce..3b4e72f 100644
@@ -1509,6 +1531,12 @@ static SIMPLE_DEV_PM_OPS(ti_bandgap_dev_pm_ops, ti_bandgap_suspend,
 #endif
 
Quoted 7 lines

drivers/thermal/ti-soc-thermal/ti-bandgap.c static SIMPLE_DEV_PM_OPS(ti_bandgap_dev_pm_ops, ti_bandgap_suspend, · line 1536

Quoted 4 lines
drivers/thermal/ti-soc-thermal/ti-bandgap.c +3 -0
 static const struct of_device_id of_ti_bandgap_match[] = {
+#ifdef CONFIG_OMAP3_THERMAL
+	{
+		.compatible = "ti,omap34xx-bandgap",

This needs to be updated in the binding documentation. Documentation/devicetree/bindings/thermal/ti_soc_thermal.txt

Ok.

Quoted 5 lines

drivers/thermal/ti-soc-thermal/ti-bandgap.c static SIMPLE_DEV_PM_OPS(ti_bandgap_dev_pm_ops, ti_bandgap_suspend, · line 1537

Quoted 1 line
drivers/thermal/ti-soc-thermal/ti-bandgap.c +1 -0
+		.data = (void *)&omap34xx_data,

Having a run time message intentionally advising users of the risk of using this sensor is also required.

Quoted 6 lines

Ok, what about?

    if (TI_BANDGAP_HAS(bgp, UNRELIABLE))
              dev_warn(&pdev->dev,
                         "OMAP3 thermal sensor is unreliable and normally unneccessary\n");

works for me.

Quoted 5 lines

Will not fit in 80 columns, but keeping message on one line is more important.
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20150105/c19793a2/attachment.sig>

#4 lore raw

PATCH v2 1/1 thermal: add omap3 support

In reply to Pavel Machek

Add support for omap3430 sensor. Tested on Nokia N900.

Fix help text to be closer to english.

Ifdefs in ti-bandgap.h are not neccessary, as users have #ifdefs, already.

drivers/thermal/ti-soc-thermal/Kconfig +18 -3
index bd4c7be..65c478e 100644
@@ -21,13 +21,28 @@ config TI_THERMAL
 	  This includes trip points definitions, extrapolation rules and
 	  CPU cooling device bindings.
 
+config OMAP3_THERMAL
+	bool "Texas Instruments OMAP3 thermal support"
+	depends on TI_SOC_THERMAL
+	depends on ARCH_OMAP3
+	help
+	  If you say yes here you get thermal support for the Texas Instruments
+	  OMAP3 SoC family. The current chips supported are:
+	   - OMAP3430
+
+	  OMAP3 chips normally don't need thermal management, and sensors in
+	  this generation are not very accurate, nor they are very close to
+	  the important hotspots.
+
+	  Say 'N' here.
+
 config OMAP4_THERMAL
 	bool "Texas Instruments OMAP4 thermal support"
 	depends on TI_SOC_THERMAL
 	depends on ARCH_OMAP4
 	help
 	  If you say yes here you get thermal support for the Texas Instruments
-	  OMAP4 SoC family. The current chip supported are:
+	  OMAP4 SoC family. The current chips supported are:
 	   - OMAP4430
 	   - OMAP4460
 	   - OMAP4470
@@ -41,7 +56,7 @@ config OMAP5_THERMAL
 	depends on SOC_OMAP5
 	help
 	  If you say yes here you get thermal support for the Texas Instruments
-	  OMAP5 SoC family. The current chip supported are:
+	  OMAP5 SoC family. The current chips supported are:
 	   - OMAP5430
 
 	  This includes alert interrupts generation and also the TSHUT
@@ -53,7 +68,7 @@ config DRA752_THERMAL
 	depends on SOC_DRA7XX
 	help
 	  If you say yes here you get thermal support for the Texas Instruments
-	  DRA752 SoC family. The current chip supported are:
+	  DRA752 SoC family. The current chips supported are:
 	   - DRA752
 
 	  This includes alert interrupts generation and also the TSHUT
drivers/thermal/ti-soc-thermal/Makefile +1 -0
index 1226b24..0f89bdf 100644
@@ -2,5 +2,6 @@ obj-$(CONFIG_TI_SOC_THERMAL)		+= ti-soc-thermal.o
 ti-soc-thermal-y			:= ti-bandgap.o
 ti-soc-thermal-$(CONFIG_TI_THERMAL)	+= ti-thermal-common.o
 ti-soc-thermal-$(CONFIG_DRA752_THERMAL)	+= dra752-thermal-data.o
+ti-soc-thermal-$(CONFIG_OMAP3_THERMAL)	+= omap3-thermal-data.o
 ti-soc-thermal-$(CONFIG_OMAP4_THERMAL)	+= omap4-thermal-data.o
 ti-soc-thermal-$(CONFIG_OMAP5_THERMAL)	+= omap5-thermal-data.o
drivers/thermal/ti-soc-thermal/omap3-thermal-data.c new file +103 -0

103 lines not on this page · raw message

drivers/thermal/ti-soc-thermal/ti-bandgap.c +6 -0
index 634b6ce..2fde78c 100644
@@ -1509,6 +1510,12 @@ static SIMPLE_DEV_PM_OPS(ti_bandgap_dev_pm_ops, ti_bandgap_suspend,
 #endif
 
 static const struct of_device_id of_ti_bandgap_match[] = {
+#ifdef CONFIG_OMAP3_THERMAL
+	{
+		.compatible = "ti,omap34xx-bandgap",
+		.data = (void *)&omap34xx_data,
+	},
+#endif
 #ifdef CONFIG_OMAP4_THERMAL
 	{
 		.compatible = "ti,omap4430-bandgap",
drivers/thermal/ti-soc-thermal/ti-bandgap.h +2 -16
index b3adf72..9ba9a6b 100644
@@ -331,6 +331,7 @@ struct ti_temp_sensor {
 #define TI_BANDGAP_FEATURE_FREEZE_BIT		BIT(7)
 #define TI_BANDGAP_FEATURE_COUNTER_DELAY	BIT(8)
 #define TI_BANDGAP_FEATURE_HISTORY_BUFFER	BIT(9)
+#define TI_BANDGAP_FEATURE_UNRELIABLE		BIT(10)
 #define TI_BANDGAP_HAS(b, f)			\
 			((b)->conf->features & TI_BANDGAP_FEATURE_ ## f)
 
@@ -384,25 +385,10 @@ int ti_bandgap_set_sensor_data(struct ti_bandgap *bgp, int id, void *data);
 void *ti_bandgap_get_sensor_data(struct ti_bandgap *bgp, int id);
 int ti_bandgap_get_trend(struct ti_bandgap *bgp, int id, int *trend);
 
-#ifdef CONFIG_OMAP4_THERMAL
+extern const struct ti_bandgap_data omap34xx_data;
 extern const struct ti_bandgap_data omap4430_data;
 extern const struct ti_bandgap_data omap4460_data;
 extern const struct ti_bandgap_data omap4470_data;
-#else
-#define omap4430_data					NULL
-#define omap4460_data					NULL
-#define omap4470_data					NULL
-#endif
-
-#ifdef CONFIG_OMAP5_THERMAL
 extern const struct ti_bandgap_data omap5430_data;
-#else
-#define omap5430_data					NULL
-#endif
-
-#ifdef CONFIG_DRA752_THERMAL
 extern const struct ti_bandgap_data dra752_data;
-#else
-#define dra752_data					NULL
-#endif
 #endif
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
maintainer
#5 lore raw
Quoted 227 lines · Pavel Machek

Add support for omap3430 sensor. Tested on Nokia N900.

Fix help text to be closer to english.

Ifdefs in ti-bandgap.h are not neccessary, as users have #ifdefs, already.

drivers/thermal/ti-soc-thermal/Kconfig +18 -3
index bd4c7be..65c478e 100644
@@ -21,13 +21,28 @@ config TI_THERMAL
 	  This includes trip points definitions, extrapolation rules and
 	  CPU cooling device bindings.
 
+config OMAP3_THERMAL
+	bool "Texas Instruments OMAP3 thermal support"
+	depends on TI_SOC_THERMAL
+	depends on ARCH_OMAP3
+	help
+	  If you say yes here you get thermal support for the Texas Instruments
+	  OMAP3 SoC family. The current chips supported are:
+	   - OMAP3430
+
+	  OMAP3 chips normally don't need thermal management, and sensors in
+	  this generation are not very accurate, nor they are very close to
+	  the important hotspots.
+
+	  Say 'N' here.
+
 config OMAP4_THERMAL
 	bool "Texas Instruments OMAP4 thermal support"
 	depends on TI_SOC_THERMAL
 	depends on ARCH_OMAP4
 	help
 	  If you say yes here you get thermal support for the Texas Instruments
-	  OMAP4 SoC family. The current chip supported are:
+	  OMAP4 SoC family. The current chips supported are:
 	   - OMAP4430
 	   - OMAP4460
 	   - OMAP4470
@@ -41,7 +56,7 @@ config OMAP5_THERMAL
 	depends on SOC_OMAP5
 	help
 	  If you say yes here you get thermal support for the Texas Instruments
-	  OMAP5 SoC family. The current chip supported are:
+	  OMAP5 SoC family. The current chips supported are:
 	   - OMAP5430
 
 	  This includes alert interrupts generation and also the TSHUT
@@ -53,7 +68,7 @@ config DRA752_THERMAL
 	depends on SOC_DRA7XX
 	help
 	  If you say yes here you get thermal support for the Texas Instruments
-	  DRA752 SoC family. The current chip supported are:
+	  DRA752 SoC family. The current chips supported are:
 	   - DRA752
 
 	  This includes alert interrupts generation and also the TSHUT
drivers/thermal/ti-soc-thermal/Makefile +1 -0
index 1226b24..0f89bdf 100644
@@ -2,5 +2,6 @@ obj-$(CONFIG_TI_SOC_THERMAL)		+= ti-soc-thermal.o
 ti-soc-thermal-y			:= ti-bandgap.o
 ti-soc-thermal-$(CONFIG_TI_THERMAL)	+= ti-thermal-common.o
 ti-soc-thermal-$(CONFIG_DRA752_THERMAL)	+= dra752-thermal-data.o
+ti-soc-thermal-$(CONFIG_OMAP3_THERMAL)	+= omap3-thermal-data.o
 ti-soc-thermal-$(CONFIG_OMAP4_THERMAL)	+= omap4-thermal-data.o
 ti-soc-thermal-$(CONFIG_OMAP5_THERMAL)	+= omap5-thermal-data.o
drivers/thermal/ti-soc-thermal/omap3-thermal-data.c new file +103 -0
new file mode 100644
index 0000000..5cee2a35
@@ -0,0 +1,103 @@
+/*
+ * OMAP3 thermal driver.
+ *
+ * Copyright (C) 2011-2012 Texas Instruments Inc.
+ * Copyright (C) 2014 Pavel Machek <[email protected]>
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * Note
+ * http://www.ti.com/lit/er/sprz278f/sprz278f.pdf "Advisory
+ * 3.1.1.186 MMC OCP Clock Not Gated When Thermal Sensor Is Used"
+ *
+ * Also TI says:
+ * Just be careful when you try to make thermal policy like decisions
+ * based on this sensor. Placement of the sensor w.r.t the actual logic
+ * generating heat has to be a factor as well. If you are just looking
+ * for an approximation temperature (thermometerish kind), you might be
+ * ok with this. I am not sure we'd find any TI data around this.. just a
+ * heads up.
+ */
+
+#include "ti-thermal.h"
+#include "ti-bandgap.h"
+
+/*
+ * OMAP34XX has one instance of thermal sensor for MPU
+ * need to describe the individual bit fields
+ */
+static struct temp_sensor_registers
+omap34xx_mpu_temp_sensor_registers = {
+	.temp_sensor_ctrl = 0,
+	.bgap_soc_mask = BIT(8),
+	.bgap_eocz_mask = BIT(7),
+	.bgap_dtemp_mask = 0x7f,
+
+	.bgap_mode_ctrl = 0,
+	.mode_ctrl_mask = BIT(9),
+};
+
+/* Thresholds and limits for OMAP34XX MPU temperature sensor */
+static struct temp_sensor_data omap34xx_mpu_temp_sensor_data = {
+	.min_freq = 32768,
+	.max_freq = 32768,
+	.max_temp = -99000,
+	.min_temp = 99000,
+	.hyst_val = 5000,
+};
+
+/*
+ * Temperature values in milli degree celsius
+ */
+static const int
+omap34xx_adc_to_temp[128] = {
+	-40000, -40000, -40000, -40000, -40000, -39000, -38000, -36000,
+	-34000, -32000, -31000,	-29000, -28000, -26000, -25000, -24000,
+	-22000, -21000, -19000, -18000, -17000, -15000,	-14000, -12000,
+	-11000, -9000, -8000, -7000, -5000, -4000, -2000, -1000, 0000,
+	1000, 3000, 4000, 5000, 7000, 8000, 10000, 11000, 13000, 14000,
+	15000, 17000, 18000, 20000, 21000, 22000, 24000, 25000, 27000,
+	28000, 30000, 31000, 32000, 34000, 35000, 37000, 38000, 39000,
+	41000, 42000, 44000, 45000, 47000, 48000, 49000, 51000, 52000,
+	53000, 55000, 56000, 58000, 59000, 60000, 62000, 63000, 65000,
+	66000, 67000, 69000, 70000, 72000, 73000, 74000, 76000, 77000,
+	79000, 80000, 81000, 83000, 84000, 85000, 87000, 88000, 89000,
+	91000, 92000, 94000, 95000, 96000, 98000, 99000, 100000,
+	102000, 103000, 105000, 106000, 107000, 109000, 110000, 111000,
+	113000, 114000, 116000, 117000, 118000, 120000, 121000, 122000,
+	124000, 124000, 125000, 125000, 125000, 125000,	125000
+};
+
+/* OMAP34XX data */
+const struct ti_bandgap_data omap34xx_data = {
+	.features = TI_BANDGAP_FEATURE_CLK_CTRL /* | TI_BANDGAP_FEATURE_MODE_CONFIG */,
+	.fclock_name = "ts_fck",
+	.div_ck_name = "ts_fck",
+	.conv_table = omap34xx_adc_to_temp,
+	.adc_start_val = 0,
+	.adc_end_val = 127,
+	.expose_sensor = ti_thermal_expose_sensor,
+	.remove_sensor = ti_thermal_remove_sensor,
+
+	.sensors = {
+		{
+		.registers = &omap34xx_mpu_temp_sensor_registers,
+		.ts_data = &omap34xx_mpu_temp_sensor_data,
+		.domain = "cpu",
+		.slope = 0,
+		.constant = 20000,
+		.slope_pcb = 0,
+		.constant_pcb = 20000,
+		.register_cooling = NULL,
+		.unregister_cooling = NULL,
+		},
+	},
+	.sensor_count = 1,
+};
drivers/thermal/ti-soc-thermal/ti-bandgap.c +6 -0
index 634b6ce..2fde78c 100644
@@ -1509,6 +1510,12 @@ static SIMPLE_DEV_PM_OPS(ti_bandgap_dev_pm_ops, ti_bandgap_suspend,
 #endif
 
 static const struct of_device_id of_ti_bandgap_match[] = {
+#ifdef CONFIG_OMAP3_THERMAL
+	{
+		.compatible = "ti,omap34xx-bandgap",
+		.data = (void *)&omap34xx_data,
+	},
+#endif
 #ifdef CONFIG_OMAP4_THERMAL
 	{
 		.compatible = "ti,omap4430-bandgap",
drivers/thermal/ti-soc-thermal/ti-bandgap.h +2 -8
index b3adf72..9ba9a6b 100644
@@ -331,6 +331,7 @@ struct ti_temp_sensor {
 #define TI_BANDGAP_FEATURE_FREEZE_BIT		BIT(7)
 #define TI_BANDGAP_FEATURE_COUNTER_DELAY	BIT(8)
 #define TI_BANDGAP_FEATURE_HISTORY_BUFFER	BIT(9)
+#define TI_BANDGAP_FEATURE_UNRELIABLE		BIT(10)
 #define TI_BANDGAP_HAS(b, f)			\
 			((b)->conf->features & TI_BANDGAP_FEATURE_ ## f)
 
@@ -384,25 +385,10 @@ int ti_bandgap_set_sensor_data(struct ti_bandgap *bgp, int id, void *data);
 void *ti_bandgap_get_sensor_data(struct ti_bandgap *bgp, int id);
 int ti_bandgap_get_trend(struct ti_bandgap *bgp, int id, int *trend);
 
-#ifdef CONFIG_OMAP4_THERMAL
+extern const struct ti_bandgap_data omap34xx_data;
 extern const struct ti_bandgap_data omap4430_data;
 extern const struct ti_bandgap_data omap4460_data;
 extern const struct ti_bandgap_data omap4470_data;
-#else
-#define omap4430_data					NULL
-#define omap4460_data					NULL
-#define omap4470_data					NULL
-#endif
-
-#ifdef CONFIG_OMAP5_THERMAL

drivers/thermal/ti-soc-thermal/ti-bandgap.h int ti_bandgap_set_sensor_data(struct ti_bandgap *bgp, int id, void *data); · line 407

Quoted 10 lines
drivers/thermal/ti-soc-thermal/ti-bandgap.h +0 -8
 extern const struct ti_bandgap_data omap5430_data;
-#else
-#define omap5430_data					NULL
-#endif
-
-#ifdef CONFIG_DRA752_THERMAL
 extern const struct ti_bandgap_data dra752_data;
-#else
-#define dra752_data					NULL
-#endif

Pavel,

Why do we need to remove the existing symbols for other chips in this file to get OMAP3 support in?

BR,

Quoted 5 lines
drivers/thermal/ti-soc-thermal/ti-bandgap.h +0 -0
 #endif
Signature · 3 lines
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20150313/618efddf/attachment.sig>

#6 lore raw

Hi!

Quoted 29 lines
Quoted 16 lines
drivers/thermal/ti-soc-thermal/ti-bandgap.h +1 -8
@@ -384,25 +385,10 @@ int ti_bandgap_set_sensor_data(struct ti_bandgap *bgp, int id, void *data);
 void *ti_bandgap_get_sensor_data(struct ti_bandgap *bgp, int id);
 int ti_bandgap_get_trend(struct ti_bandgap *bgp, int id, int *trend);
 
-#ifdef CONFIG_OMAP4_THERMAL
+extern const struct ti_bandgap_data omap34xx_data;
 extern const struct ti_bandgap_data omap4430_data;
 extern const struct ti_bandgap_data omap4460_data;
 extern const struct ti_bandgap_data omap4470_data;
-#else
-#define omap4430_data					NULL
-#define omap4460_data					NULL
-#define omap4470_data					NULL
-#endif
-
-#ifdef CONFIG_OMAP5_THERMAL

drivers/thermal/ti-soc-thermal/ti-bandgap.h int ti_bandgap_set_sensor_data(struct ti_bandgap *bgp, int id, void *data); · line 407

Quoted 10 lines
drivers/thermal/ti-soc-thermal/ti-bandgap.h +0 -8
 extern const struct ti_bandgap_data omap5430_data;
-#else
-#define omap5430_data					NULL
-#endif
-
-#ifdef CONFIG_DRA752_THERMAL
 extern const struct ti_bandgap_data dra752_data;
-#else
-#define dra752_data					NULL
-#endif

Pavel,

Quoted 2 lines

Why do we need to remove the existing symbols for other chips in this file to get OMAP3 support in?

No, I don't need to remove this, and you can safely drop this hunk.

OTOH those ifdefs are unneccessary and eye-sore: extern symbol declarations do not really hurt, and .c files already contain enough #ifdefs for other reasons that the symbols will not be needed when it is not configured.

Try it, it should work ok.

Best regards,
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#7 lore raw
In reply to Pavel Machek

Hi!

I checked 4.0-rc3 and linux-next as of today, and can not see omap3 thermal support. Can you apply the patches?

Thanks,
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
maintainer
#8 lore raw

Hey Pavel,

Quoted 4 lines · Pavel Machek

Hi!

I checked 4.0-rc3 and linux-next as of today, and can not see omap3 thermal support. Can you apply the patches?

Yeah, it should be possible. Apologize, it really fell into the cracks.

There is a comment on it though. Please check my concern in you v2.

BR,

Eduardo

Quoted 6 lines

Thanks,
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20150313/f586443f/attachment.sig>

#9 lore raw
Quoted 4 lines · Eduardo Valentin

Hey Pavel,

On Fri, Mar 13, 2015 at 01:09:35PM +0100, Pavel Machek wrote:

Quoted 8 lines
Quoted 4 lines

Hi!

I checked 4.0-rc3 and linux-next as of today, and can not see omap3 thermal support. Can you apply the patches?

Yeah, it should be possible. Apologize, it really fell into the cracks.

There is a comment on it though. Please check my concern in you v2.

And there's explanation for that concern :-). Let me know what you need.

Best regards,
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#10 lore raw
Quoted 10 lines · Pavel Machek
Quoted 9 lines · Eduardo Valentin

Hey Pavel,

Quoted 4 lines · Pavel Machek

Hi!

I checked 4.0-rc3 and linux-next as of today, and can not see omap3 thermal support. Can you apply the patches?

Quoted 6 lines
Quoted 3 lines

Yeah, it should be possible. Apologize, it really fell into the cracks.

There is a comment on it though. Please check my concern in you v2.

And there's explanation for that concern :-). Let me know what you need.

...ping? It would be good to get this into 4.1.
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
maintainer
#11 lore raw
In reply to Pavel Machek
Quoted 9 lines · Pavel Machek

Add support for omap3430 sensor. Tested on Nokia N900.

Fix help text to be closer to english.

Ifdefs in ti-bandgap.h are not neccessary, as users have #ifdefs, already.

You need to update the driver device tree binding documentation. Please include an example of its usage there.

Also, a separate patch with the required DT changes is always welcome.

Quoted 45 lines
drivers/thermal/ti-soc-thermal/Kconfig +17 -2
index bd4c7be..65c478e 100644
@@ -21,13 +21,28 @@ config TI_THERMAL
 	  This includes trip points definitions, extrapolation rules and
 	  CPU cooling device bindings.
 
+config OMAP3_THERMAL
+	bool "Texas Instruments OMAP3 thermal support"
+	depends on TI_SOC_THERMAL
+	depends on ARCH_OMAP3
+	help
+	  If you say yes here you get thermal support for the Texas Instruments
+	  OMAP3 SoC family. The current chips supported are:
+	   - OMAP3430
+
+	  OMAP3 chips normally don't need thermal management, and sensors in
+	  this generation are not very accurate, nor they are very close to
+	  the important hotspots.
+
+	  Say 'N' here.
+
 config OMAP4_THERMAL
 	bool "Texas Instruments OMAP4 thermal support"
 	depends on TI_SOC_THERMAL
 	depends on ARCH_OMAP4
 	help
 	  If you say yes here you get thermal support for the Texas Instruments
-	  OMAP4 SoC family. The current chip supported are:
+	  OMAP4 SoC family. The current chips supported are:
 	   - OMAP4430
 	   - OMAP4460
 	   - OMAP4470
@@ -41,7 +56,7 @@ config OMAP5_THERMAL
 	depends on SOC_OMAP5
 	help
 	  If you say yes here you get thermal support for the Texas Instruments
-	  OMAP5 SoC family. The current chip supported are:
+	  OMAP5 SoC family. The current chips supported are:
 	   - OMAP5430
 
 	  This includes alert interrupts generation and also the TSHUT

drivers/thermal/ti-soc-thermal/Kconfig config DRA752_THERMAL · line 71

Quoted 5 lines
drivers/thermal/ti-soc-thermal/Kconfig +1 -1
@@ -53,7 +68,7 @@ config DRA752_THERMAL
 	depends on SOC_DRA7XX
 	help
 	  If you say yes here you get thermal support for the Texas Instruments
-	  DRA752 SoC family. The current chip supported are:
+	  DRA752 SoC family. The current chips supported are:

minor: I would prefer you fix this in a separate patch.

Quoted 90 lines
drivers/thermal/ti-soc-thermal/Kconfig +0 -0
 	   - DRA752
 
 	  This includes alert interrupts generation and also the TSHUT
drivers/thermal/ti-soc-thermal/Makefile +1 -0
index 1226b24..0f89bdf 100644
@@ -2,5 +2,6 @@ obj-$(CONFIG_TI_SOC_THERMAL)		+= ti-soc-thermal.o
 ti-soc-thermal-y			:= ti-bandgap.o
 ti-soc-thermal-$(CONFIG_TI_THERMAL)	+= ti-thermal-common.o
 ti-soc-thermal-$(CONFIG_DRA752_THERMAL)	+= dra752-thermal-data.o
+ti-soc-thermal-$(CONFIG_OMAP3_THERMAL)	+= omap3-thermal-data.o
 ti-soc-thermal-$(CONFIG_OMAP4_THERMAL)	+= omap4-thermal-data.o
 ti-soc-thermal-$(CONFIG_OMAP5_THERMAL)	+= omap5-thermal-data.o
drivers/thermal/ti-soc-thermal/omap3-thermal-data.c new file +70 -0
new file mode 100644
index 0000000..5cee2a35
@@ -0,0 +1,103 @@
+/*
+ * OMAP3 thermal driver.
+ *
+ * Copyright (C) 2011-2012 Texas Instruments Inc.
+ * Copyright (C) 2014 Pavel Machek <[email protected]>
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * Note
+ * http://www.ti.com/lit/er/sprz278f/sprz278f.pdf "Advisory
+ * 3.1.1.186 MMC OCP Clock Not Gated When Thermal Sensor Is Used"
+ *
+ * Also TI says:
+ * Just be careful when you try to make thermal policy like decisions
+ * based on this sensor. Placement of the sensor w.r.t the actual logic
+ * generating heat has to be a factor as well. If you are just looking
+ * for an approximation temperature (thermometerish kind), you might be
+ * ok with this. I am not sure we'd find any TI data around this.. just a
+ * heads up.
+ */
+
+#include "ti-thermal.h"
+#include "ti-bandgap.h"
+
+/*
+ * OMAP34XX has one instance of thermal sensor for MPU
+ * need to describe the individual bit fields
+ */
+static struct temp_sensor_registers
+omap34xx_mpu_temp_sensor_registers = {
+	.temp_sensor_ctrl = 0,
+	.bgap_soc_mask = BIT(8),
+	.bgap_eocz_mask = BIT(7),
+	.bgap_dtemp_mask = 0x7f,
+
+	.bgap_mode_ctrl = 0,
+	.mode_ctrl_mask = BIT(9),
+};
+
+/* Thresholds and limits for OMAP34XX MPU temperature sensor */
+static struct temp_sensor_data omap34xx_mpu_temp_sensor_data = {
+	.min_freq = 32768,
+	.max_freq = 32768,
+	.max_temp = -99000,
+	.min_temp = 99000,
+	.hyst_val = 5000,
+};
+
+/*
+ * Temperature values in milli degree celsius
+ */
+static const int
+omap34xx_adc_to_temp[128] = {
+	-40000, -40000, -40000, -40000, -40000, -39000, -38000, -36000,
+	-34000, -32000, -31000,	-29000, -28000, -26000, -25000, -24000,
+	-22000, -21000, -19000, -18000, -17000, -15000,	-14000, -12000,
+	-11000, -9000, -8000, -7000, -5000, -4000, -2000, -1000, 0000,
+	1000, 3000, 4000, 5000, 7000, 8000, 10000, 11000, 13000, 14000,
+	15000, 17000, 18000, 20000, 21000, 22000, 24000, 25000, 27000,
+	28000, 30000, 31000, 32000, 34000, 35000, 37000, 38000, 39000,
+	41000, 42000, 44000, 45000, 47000, 48000, 49000, 51000, 52000,
+	53000, 55000, 56000, 58000, 59000, 60000, 62000, 63000, 65000,
+	66000, 67000, 69000, 70000, 72000, 73000, 74000, 76000, 77000,

drivers/thermal/ti-soc-thermal/omap3-thermal-data.c line 80

Quoted 10 lines
drivers/thermal/ti-soc-thermal/omap3-thermal-data.c new file +10 -0
+	79000, 80000, 81000, 83000, 84000, 85000, 87000, 88000, 89000,
+	91000, 92000, 94000, 95000, 96000, 98000, 99000, 100000,
+	102000, 103000, 105000, 106000, 107000, 109000, 110000, 111000,
+	113000, 114000, 116000, 117000, 118000, 120000, 121000, 122000,
+	124000, 124000, 125000, 125000, 125000, 125000,	125000
+};
+
+/* OMAP34XX data */
+const struct ti_bandgap_data omap34xx_data = {
+	.features = TI_BANDGAP_FEATURE_CLK_CTRL /* | TI_BANDGAP_FEATURE_MODE_CONFIG */,

Shouldn't this be unreliable?

drivers/thermal/ti-soc-thermal/ti-bandgap.c

Quoted 24 lines
drivers/thermal/ti-soc-thermal/omap3-thermal-data.c new file +23 -0
+	.fclock_name = "ts_fck",
+	.div_ck_name = "ts_fck",
+	.conv_table = omap34xx_adc_to_temp,
+	.adc_start_val = 0,
+	.adc_end_val = 127,
+	.expose_sensor = ti_thermal_expose_sensor,
+	.remove_sensor = ti_thermal_remove_sensor,
+
+	.sensors = {
+		{
+		.registers = &omap34xx_mpu_temp_sensor_registers,
+		.ts_data = &omap34xx_mpu_temp_sensor_data,
+		.domain = "cpu",
+		.slope = 0,
+		.constant = 20000,
+		.slope_pcb = 0,
+		.constant_pcb = 20000,
+		.register_cooling = NULL,
+		.unregister_cooling = NULL,
+		},
+	},
+	.sensor_count = 1,
+};
drivers/thermal/ti-soc-thermal/ti-bandgap.c +0 -0

You did not use the bit you created to warn the user about the chip.

Quoted 21 lines

index 634b6ce..2fde78c 100644

drivers/thermal/ti-soc-thermal/ti-bandgap.c +6 -0
@@ -1509,6 +1510,12 @@ static SIMPLE_DEV_PM_OPS(ti_bandgap_dev_pm_ops, ti_bandgap_suspend,
 #endif
 
 static const struct of_device_id of_ti_bandgap_match[] = {
+#ifdef CONFIG_OMAP3_THERMAL
+	{
+		.compatible = "ti,omap34xx-bandgap",
+		.data = (void *)&omap34xx_data,
+	},
+#endif
 #ifdef CONFIG_OMAP4_THERMAL
 	{
 		.compatible = "ti,omap4430-bandgap",
drivers/thermal/ti-soc-thermal/ti-bandgap.h +0 -0
index b3adf72..9ba9a6b 100644

drivers/thermal/ti-soc-thermal/ti-bandgap.h struct ti_temp_sensor { · line 334

Quoted 4 lines
drivers/thermal/ti-soc-thermal/ti-bandgap.h +1 -0
@@ -331,6 +331,7 @@ struct ti_temp_sensor {
 #define TI_BANDGAP_FEATURE_FREEZE_BIT		BIT(7)
 #define TI_BANDGAP_FEATURE_COUNTER_DELAY	BIT(8)
 #define TI_BANDGAP_FEATURE_HISTORY_BUFFER	BIT(9)
+#define TI_BANDGAP_FEATURE_UNRELIABLE		BIT(10)

This needs to go somewhere else too in your patch.

drivers/thermal/ti-soc-thermal/ti-bandgap.h int ti_bandgap_set_sensor_data(struct ti_bandgap *bgp, int id, void *data); · line 388

Quoted 9 lines
drivers/thermal/ti-soc-thermal/ti-bandgap.h +1 -1
 #define TI_BANDGAP_HAS(b, f)			\
 			((b)->conf->features & TI_BANDGAP_FEATURE_ ## f)
 
@@ -384,25 +385,10 @@ int ti_bandgap_set_sensor_data(struct ti_bandgap *bgp, int id, void *data);
 void *ti_bandgap_get_sensor_data(struct ti_bandgap *bgp, int id);
 int ti_bandgap_get_trend(struct ti_bandgap *bgp, int id, int *trend);
 
-#ifdef CONFIG_OMAP4_THERMAL
+extern const struct ti_bandgap_data omap34xx_data;

Please, keep one change per patch. If you think it is good to remove the ifdefs here, send a separate patch. Keep in mind that, if you are removing the ifdefs, I would prefer you remove from the .c file.

Quoted 25 lines
drivers/thermal/ti-soc-thermal/ti-bandgap.h +0 -15
 extern const struct ti_bandgap_data omap4430_data;
 extern const struct ti_bandgap_data omap4460_data;
 extern const struct ti_bandgap_data omap4470_data;
-#else
-#define omap4430_data					NULL
-#define omap4460_data					NULL
-#define omap4470_data					NULL
-#endif
-
-#ifdef CONFIG_OMAP5_THERMAL
 extern const struct ti_bandgap_data omap5430_data;
-#else
-#define omap5430_data					NULL
-#endif
-
-#ifdef CONFIG_DRA752_THERMAL
 extern const struct ti_bandgap_data dra752_data;
-#else
-#define dra752_data					NULL
-#endif
 #endif
Signature · 3 lines
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20150323/cf65afd7/attachment.sig>

#12 lore raw
Quoted 9 lines · Eduardo Valentin
Quoted 8 lines · Pavel Machek

Add support for omap3430 sensor. Tested on Nokia N900.

Fix help text to be closer to english.

Ifdefs in ti-bandgap.h are not neccessary, as users have #ifdefs, already.

Quoted 7 lines
Quoted 1 line

You need to update the driver device tree binding documentation. Please include an example of its usage there.

Also, a separate patch with the required DT changes is always welcome.

I can do it, but can you merge:

Date: Sun, 18 Jan 2015 21:24:47 +0100
From: Pavel Machek <[email protected]>
Subject: [PATCHv2] ti-soc-thermal: request temperature periodically if hw can't do that itself

Date: Sun, 18 Jan 2015 21:20:51 +0100
From: Pavel Machek <[email protected]>
Subject: [PATCHv2] ti-soc-thermal: implement eocz bit to make driver useful on omap3

Date: Sun, 18 Jan 2015 21:17:10 +0100
From: Pavel Machek <[email protected]>
Subject: [PATCHv2] cleanup ti-soc-thermal

First? They are nicely split, as you requested, and I already have too many patches in flight.

Thanks for the comments, I'll fix them in my local tree.
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
maintainer
#13 lore raw
Quoted 35 lines · Pavel Machek
Quoted 9 lines · Eduardo Valentin
Quoted 8 lines · Pavel Machek

Add support for omap3430 sensor. Tested on Nokia N900.

Fix help text to be closer to english.

Ifdefs in ti-bandgap.h are not neccessary, as users have #ifdefs, already.

Quoted 7 lines
Quoted 1 line

You need to update the driver device tree binding documentation. Please include an example of its usage there.

Also, a separate patch with the required DT changes is always welcome.

I can do it, but can you merge:

Date: Sun, 18 Jan 2015 21:24:47 +0100
From: Pavel Machek <[email protected]>
Subject: [PATCHv2] ti-soc-thermal: request temperature periodically if hw can't do that itself

Date: Sun, 18 Jan 2015 21:20:51 +0100
From: Pavel Machek <[email protected]>
Subject: [PATCHv2] ti-soc-thermal: implement eocz bit to make driver useful on omap3

Date: Sun, 18 Jan 2015 21:17:10 +0100
From: Pavel Machek <[email protected]>
Subject: [PATCHv2] cleanup ti-soc-thermal

Quoted 5 lines

First? They are nicely split, as you requested, and I already have too many patches in flight.

Thanks for the comments, I'll fix them in my local tree.
Pavel

Somehow I really thought I already sent those above. I really apologize for the inconvenience. It seams like they've fallen into the cracks.

I will check those and apply accordingly.

Quoted 4 lines
Signature · 3 lines
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20150323/78c3e107/attachment.sig>