All of lore.kernel.org
 help / color / mirror / Atom feed
* [lm-sensors] [PATCH 2/2] hwmon: (coretemp) Get TjMax value from MSR
@ 2010-03-05 15:38 Huaxu Wan
  2010-03-05 16:19 ` [lm-sensors] [PATCH 2/2] hwmon: (coretemp) Get TjMax value from Luca Tettamanti
                   ` (2 more replies)
  0 siblings, 3 replies; 75+ messages in thread
From: Huaxu Wan @ 2010-03-05 15:38 UTC (permalink / raw)
  To: lm-sensors


The MSR IA32_TEMPERATURE_TARGET contains the TjMax value after the i series
processers.

Signed-off-by: Huaxu Wan <huaxu.wan@intel.com>
---
 drivers/hwmon/coretemp.c |   46 +++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 45 insertions(+), 1 deletions(-)

diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c
index 55122d8..6039ea5 100644
--- a/drivers/hwmon/coretemp.c
+++ b/drivers/hwmon/coretemp.c
@@ -241,6 +241,50 @@ static int __devinit adjust_tjmax(struct cpuinfo_x86 *c, u32 id, struct device *
 	return tjmax;
 }
 
+static int __devinit get_tjmax(struct cpuinfo_x86 *c, u32 id, struct device *dev)
+{
+	/* The 100C is default for both mobile and non mobile CPUs */
+	int err;
+	u32 eax, edx;
+	u32 val;
+
+	/* A new feature in the i series processors, the 
+	   IA32_TEMPERATURE_TARGET contains the TjMax value */
+	err = rdmsr_safe_on_cpu(id, 0x1a2, &eax, &edx);
+	if (err){
+		printk_once(KERN_WARNING DRVNAME  " : Unable to read TjMax from CPU, an"
+			" assumption value is used! \n");
+	} else {
+		val = (eax >> 16 ) & 0xff;
+		/* If the TjMax is not reasonable, an assumption value 
+		   will be used */
+		if (( val > 80) && (val < 120)){
+			printk_once(KERN_WARNING DRVNAME " : The TjMax is %d\n C", val);
+			return val * 1000;
+		}
+	}
+
+	/* For the early CPUs, an approximation is given.
+	 NOTE: the given value may not be correct. */
+	switch(c->x86_model){
+	case 0xe :
+	case 0xf :
+	case 0x16 :
+	case 0x1a :
+		printk_once(KERN_WARNING DRVNAME  " : TjMax is assumed as 100 C! \n");
+		return 100000;
+		break;
+	case 0x17 :
+	case 0x1c :		/* Atom CPUs */
+		return adjust_tjmax(c, id, dev);
+		break;
+	default :
+		printk_once(KERN_WARNING DRVNAME " : Your CPU is not support yet,"
+			"using the default TjMax: 100 C.\n");
+		return 100000;
+	}
+}
+
 static int __devinit coretemp_probe(struct platform_device *pdev)
 {
 	struct coretemp_data *data;
@@ -283,7 +327,7 @@ static int __devinit coretemp_probe(struct platform_device *pdev)
 		}
 	}
 
-	data->tjmax = adjust_tjmax(c, data->id, &pdev->dev);
+	data->tjmax = get_tjmax(c, data->id, &pdev->dev);
 	platform_set_drvdata(pdev, data);
 
 	/* read the still undocumented IA32_TEMPERATURE_TARGET it exists
-- 
1.6.3.3.363.g725cf7


_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply related	[flat|nested] 75+ messages in thread
* [lm-sensors] [PATCH 1/2] hwmon: (coretemp) Detect the thermal
@ 2010-03-05 15:28 Huaxu Wan
  2010-05-07  9:54   ` [PATCH 1/2] hwmon: (coretemp) Detect the thermal sensors by CPUID Huaxu Wan
  0 siblings, 1 reply; 75+ messages in thread
From: Huaxu Wan @ 2010-03-05 15:28 UTC (permalink / raw)
  To: lm-sensors


The thermal sensors of Intel CPUs can be detected by CPUID instruction,
indicated by CPUID.06H.EAX[0].

Signed-off-by: Huaxu Wan <huaxu.wan@intel.com>
---
 drivers/hwmon/coretemp.c |   24 +++++++-----------------
 1 files changed, 7 insertions(+), 17 deletions(-)

diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c
index 2d7bcee..55122d8 100644
--- a/drivers/hwmon/coretemp.c
+++ b/drivers/hwmon/coretemp.c
@@ -440,6 +440,7 @@ static int __init coretemp_init(void)
 {
 	int i, err = -ENODEV;
 	struct pdev_entry *p, *n;
+	u32 eax;
 
 	/* quick check if we run Intel */
 	if (cpu_data(0).x86_vendor != X86_VENDOR_INTEL)
@@ -450,23 +451,12 @@ static int __init coretemp_init(void)
 		goto exit;
 
 	for_each_online_cpu(i) {
-		struct cpuinfo_x86 *c = &cpu_data(i);
-
-		/* check if family 6, models 0xe (Pentium M DC),
-		  0xf (Core 2 DC 65nm), 0x16 (Core 2 SC 65nm),
-		  0x17 (Penryn 45nm), 0x1a (Nehalem), 0x1c (Atom),
-		  0x1e (Lynnfield) */
-		if ((c->cpuid_level < 0) || (c->x86 != 0x6) ||
-		    !((c->x86_model = 0xe) || (c->x86_model = 0xf) ||
-			(c->x86_model = 0x16) || (c->x86_model = 0x17) ||
-			(c->x86_model = 0x1a) || (c->x86_model = 0x1c) ||
-			(c->x86_model = 0x1e))) {
-
-			/* supported CPU not found, but report the unknown
-			   family 6 CPU */
-			if ((c->x86 = 0x6) && (c->x86_model > 0xf))
-				printk(KERN_WARNING DRVNAME ": Unknown CPU "
-					"model %x\n", c->x86_model);
+		/* check if the CPU has thermal sensor */
+		eax = cpuid_eax(0x06);
+		if (!(eax & 0x01)) {
+			struct cpuinfo_x86 *c = &cpu_data(i);
+			printk_once(KERN_WARNING DRVNAME ": CPU (model=0x%x)"
+				" has no thermal sensor!\n", c->x86_model);
 			continue;
 		}
 
-- 
1.6.3.3.363.g725cf7

_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply related	[flat|nested] 75+ messages in thread

end of thread, other threads:[~2010-08-31 21:10 UTC | newest]

Thread overview: 75+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-05 15:38 [lm-sensors] [PATCH 2/2] hwmon: (coretemp) Get TjMax value from MSR Huaxu Wan
2010-03-05 16:19 ` [lm-sensors] [PATCH 2/2] hwmon: (coretemp) Get TjMax value from Luca Tettamanti
2010-03-08 14:44 ` Huaxu Wan
2010-05-07  9:59 ` [lm-sensors] [PATCH 2/2] hwmon: (coretemp) Get TjMax value from MSR Huaxu Wan
2010-05-07  9:59   ` Huaxu Wan
2010-05-07 13:29   ` [lm-sensors] [PATCH 2/2] hwmon: (coretemp) Get TjMax value from Carsten Emde
2010-05-07 13:29     ` [lm-sensors] [PATCH 2/2] hwmon: (coretemp) Get TjMax value from MSR Carsten Emde
2010-05-10  3:09     ` [lm-sensors] [PATCH 2/2] hwmon: (coretemp) Get TjMax value from Huaxu Wan
2010-05-10  3:09       ` [lm-sensors] [PATCH 2/2] hwmon: (coretemp) Get TjMax value from MSR Huaxu Wan
2010-05-10  3:50   ` [lm-sensors] [PATCH 2/2 V2] hwmon: (coretemp) Get TjMax value from Huaxu Wan
2010-05-10  3:50     ` [PATCH 2/2 V2] hwmon: (coretemp) Get TjMax value from MSR Huaxu Wan
2010-05-29  5:39   ` [lm-sensors] [PATCH 2/2] hwmon: (coretemp) Get TjMax value from Maxim Levitsky
2010-05-29  5:39     ` [PATCH 2/2] hwmon: (coretemp) Get TjMax value from MSR Maxim Levitsky
2010-05-30 14:43     ` [lm-sensors] [PATCH 2/2] hwmon: (coretemp) Get TjMax value from Maxim Levitsky
2010-05-30 14:43       ` [PATCH 2/2] hwmon: (coretemp) Get TjMax value from MSR Maxim Levitsky
2010-05-31  1:39     ` [lm-sensors] [PATCH 2/2] hwmon: (coretemp) Get TjMax value from Huaxu Wan
2010-05-31  1:39       ` [PATCH 2/2] hwmon: (coretemp) Get TjMax value from MSR Huaxu Wan
2010-06-02 16:34       ` [lm-sensors] [PATCH 2/2] hwmon: (coretemp) Get TjMax value from Maxim Levitsky
2010-06-02 16:34         ` [PATCH 2/2] hwmon: (coretemp) Get TjMax value from MSR Maxim Levitsky
2010-06-02 20:10         ` [lm-sensors] [PATCH 2/2] hwmon: (coretemp) Get TjMax value from Maxim Levitsky
2010-06-02 20:10           ` [PATCH 2/2] hwmon: (coretemp) Get TjMax value from MSR Maxim Levitsky
2010-06-12 13:03           ` [lm-sensors] [PATCH 2/2] hwmon: (coretemp) Get TjMax value from Maxim Levitsky
2010-06-12 13:03             ` [PATCH 2/2] hwmon: (coretemp) Get TjMax value from MSR Maxim Levitsky
2010-06-13  2:27             ` [lm-sensors] [PATCH 2/2] hwmon: (coretemp) Get TjMax value from Wan, Huaxu
2010-06-13  2:27               ` [PATCH 2/2] hwmon: (coretemp) Get TjMax value from MSR Wan, Huaxu
2010-07-26  8:16               ` [lm-sensors] [PATCH 2/2] hwmon: (coretemp) Get TjMax value from Maxim Levitsky
2010-07-26  8:16                 ` [PATCH 2/2] hwmon: (coretemp) Get TjMax value from MSR Maxim Levitsky
2010-08-30  1:42                 ` [lm-sensors] [PATCH 2/2] hwmon: (coretemp) Get TjMax value from Huaxu Wan
2010-08-30  1:42                   ` [PATCH 2/2] hwmon: (coretemp) Get TjMax value from MSR Huaxu Wan
2010-08-31 21:01                   ` [lm-sensors] [PATCH 2/2] hwmon: (coretemp) Get TjMax value from Fenghua Yu
2010-08-31 21:01                     ` [PATCH 2/2] hwmon: (coretemp) Get TjMax value from MSR Fenghua Yu
  -- strict thread matches above, loose matches on Subject: below --
2010-03-05 15:28 [lm-sensors] [PATCH 1/2] hwmon: (coretemp) Detect the thermal Huaxu Wan
2010-05-07  9:54 ` Huaxu Wan
2010-05-07  9:54   ` [PATCH 1/2] hwmon: (coretemp) Detect the thermal sensors by CPUID Huaxu Wan
2010-05-07 12:43   ` [lm-sensors] [PATCH 1/2] hwmon: (coretemp) Detect the thermal Jean Delvare
2010-05-07 12:43     ` [PATCH 1/2] hwmon: (coretemp) Detect the thermal sensors by CPUID Jean Delvare
2010-05-07 13:21   ` [lm-sensors] [PATCH 1/2] hwmon: (coretemp) Detect the thermal Carsten Emde
2010-05-07 13:21     ` [lm-sensors] [PATCH 1/2] hwmon: (coretemp) Detect the thermal sensors by CPUID Carsten Emde
2010-05-10  2:35     ` [lm-sensors] [PATCH 1/2] hwmon: (coretemp) Detect the thermal Huaxu Wan
2010-05-10  2:35       ` [lm-sensors] [PATCH 1/2] hwmon: (coretemp) Detect the thermal sensors by CPUID Huaxu Wan
2010-05-10  3:35   ` [lm-sensors] [PATCH 1/2 V2] hwmon: (coretemp) Detect the thermal Huaxu Wan
2010-05-10  3:35     ` [PATCH 1/2 V2] hwmon: (coretemp) Detect the thermal sensors by CPUID Huaxu Wan
2010-05-10 12:45     ` [lm-sensors] [PATCH 1/2 V2] hwmon: (coretemp) Detect the Valdis.Kletnieks
2010-05-10 12:45       ` [PATCH 1/2 V2] hwmon: (coretemp) Detect the thermal sensors by CPUID Valdis.Kletnieks
2010-05-11  3:41       ` [lm-sensors] [PATCH 1/2 V2] hwmon: (coretemp) Detect the Huaxu Wan
2010-05-11  3:41         ` [PATCH 1/2 V2] hwmon: (coretemp) Detect the thermal sensors by CPUID Huaxu Wan
2010-05-11  7:55     ` [lm-sensors] [PATCH 1/2 V3] hwmon: (coretemp) Detect the thermal Huaxu Wan
2010-05-11  8:01       ` [PATCH 1/2 V3] hwmon: (coretemp) Detect the thermal sensors by CPUID Huaxu Wan
2010-05-11 21:45       ` [lm-sensors] [PATCH 1/2 V3] hwmon: (coretemp) Detect the Valdis.Kletnieks
2010-05-11 21:45         ` [PATCH 1/2 V3] hwmon: (coretemp) Detect the thermal sensors by CPUID Valdis.Kletnieks
2010-05-14  3:20       ` [lm-sensors] [PATCH 1/2 V3] hwmon: (coretemp) Detect the Henrique de Moraes Holschuh
2010-05-14  3:20         ` [lm-sensors] [PATCH 1/2 V3] hwmon: (coretemp) Detect the thermal sensors by CPUID Henrique de Moraes Holschuh
2010-05-14  6:58         ` [lm-sensors] [PATCH 1/2 V3 minor change] hwmon: (coretemp) Detect Huaxu Wan
2010-05-14  6:58           ` [PATCH 1/2 V3 minor change] hwmon: (coretemp) Detect the thermal sensors by CPUID Huaxu Wan
2010-05-17  9:41           ` [lm-sensors] [PATCH 0/2] hwmon: Update coretemp to current Intel Carsten Emde
2010-05-17  9:41             ` [PATCH 0/2] hwmon: Update coretemp to current Intel processors Carsten Emde
2010-05-17  9:41             ` [lm-sensors] [PATCH 1/2] Detect the thermal sensors by CPUID Carsten Emde
2010-05-17  9:41               ` Carsten Emde
2010-05-17  9:41             ` [lm-sensors] [PATCH 2/2] Get TjMax value from MSR Carsten Emde
2010-05-17  9:41               ` Carsten Emde
2010-05-18  4:47             ` [lm-sensors] [PATCH 0/2] hwmon: Update coretemp to current Dmitry Gromov
2010-05-18  7:01               ` Carsten Emde
2010-05-18  7:01                 ` [lm-sensors] [PATCH 0/2] hwmon: Update coretemp to current Intel processors Carsten Emde
2010-05-18 12:03                 ` [lm-sensors] [PATCH 0/2] hwmon: Update coretemp to current Dmitry Gromov
2010-05-18 12:03                   ` [lm-sensors] [PATCH 0/2] hwmon: Update coretemp to current Intel processors Dmitry Gromov
2010-05-19  1:27                 ` [lm-sensors] [PATCH 0/2] hwmon: Update coretemp to current Huaxu Wan
2010-05-19  1:27                   ` [lm-sensors] [PATCH 0/2] hwmon: Update coretemp to current Intel processors Huaxu Wan
2010-05-18  5:07             ` [lm-sensors] [PATCH 0/2] hwmon: Update coretemp to current Wan, Huaxu
2010-05-18  6:45             ` Dmitry Gromov
2010-05-18  7:13               ` Carsten Emde
2010-05-18  7:13                 ` [lm-sensors] [PATCH 0/2] hwmon: Update coretemp to current Intel processors Carsten Emde
2010-05-19  0:50               ` [lm-sensors] [PATCH 0/2] hwmon: Update coretemp to current Huaxu Wan
2010-05-19  0:50                 ` [lm-sensors] [PATCH 0/2] hwmon: Update coretemp to current Intel processors Huaxu Wan
2010-05-19  3:12                 ` [lm-sensors] [PATCH 0/2] hwmon: Update coretemp to current Dmitry Gromov
2010-05-19  3:12                   ` [lm-sensors] [PATCH 0/2] hwmon: Update coretemp to current Intel processors Dmitry Gromov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.