public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Huaxu Wan <huaxu.wan@linux.intel.com>
To: linux-kernel@vger.kernel.org, lm-sensors@lm-sensors.org
Cc: huaxu.wan@intel.com, khali@linux-fr.org
Subject: [PATCH 2/2] hwmon: (coretemp) Get TjMax value from MSR
Date: Fri, 7 May 2010 17:59:45 +0800	[thread overview]
Message-ID: <20100507095945.GB12190@owl> (raw)


The MSR IA32_TEMPERATURE_TARGET contains the TjMax value in the newer
processers.

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

diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c
index 237c68d..7a01032 100644
--- a/drivers/hwmon/coretemp.c
+++ b/drivers/hwmon/coretemp.c
@@ -241,6 +241,49 @@ 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 of current Intel(R) processors, the
+          IA32_TEMPERATURE_TARGET(0x1a2) 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.\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_INFO DRVNAME " : The TjMax is %d C. \n", 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 +326,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

             reply	other threads:[~2010-05-07  9:50 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-07  9:59 Huaxu Wan [this message]
2010-05-07 13:29 ` [lm-sensors] [PATCH 2/2] hwmon: (coretemp) Get TjMax value from MSR Carsten Emde
2010-05-10  3:09   ` Huaxu Wan
2010-05-10  3:50 ` [PATCH 2/2 V2] " Huaxu Wan
2010-05-29  5:39 ` [PATCH 2/2] " Maxim Levitsky
2010-05-30 14:43   ` Maxim Levitsky
2010-05-31  1:39   ` Huaxu Wan
2010-06-02 16:34     ` Maxim Levitsky
2010-06-02 20:10       ` Maxim Levitsky
2010-06-12 13:03         ` Maxim Levitsky
2010-06-13  2:27           ` Wan, Huaxu
2010-07-26  8:16             ` Maxim Levitsky
2010-08-30  1:42               ` Huaxu Wan
2010-08-31 21:01                 ` Fenghua Yu
  -- strict thread matches above, loose matches on Subject: below --
2010-05-07  9:54 [PATCH 1/2] hwmon: (coretemp) Detect the thermal sensors by CPUID Huaxu Wan
2010-05-07 12:43 ` Jean Delvare
2010-05-07 13:21 ` [lm-sensors] " Carsten Emde
2010-05-10  2:35   ` Huaxu Wan
2010-05-10  3:35 ` [PATCH 1/2 V2] " Huaxu Wan
2010-05-10 12:45   ` Valdis.Kletnieks
2010-05-11  3:41     ` Huaxu Wan
2010-05-11  8:01   ` [PATCH 1/2 V3] " Huaxu Wan
2010-05-11 21:45     ` Valdis.Kletnieks
2010-05-14  3:20     ` [lm-sensors] " Henrique de Moraes Holschuh
2010-05-14  6:58       ` [PATCH 1/2 V3 minor change] " Huaxu Wan
2010-05-17  9:41         ` [PATCH 0/2] hwmon: Update coretemp to current Intel processors Carsten Emde
2010-05-17  9:41           ` [PATCH 1/2] Detect the thermal sensors by CPUID Carsten Emde
2010-05-17  9:41           ` [PATCH 2/2] Get TjMax value from MSR Carsten Emde
     [not found]           ` <AANLkTinQlH7LhCAz00WaHqbbslcSqipzVx4tDoQKSqIL@mail.gmail.com>
2010-05-18  7:01             ` [lm-sensors] [PATCH 0/2] hwmon: Update coretemp to current Intel processors Carsten Emde
2010-05-18 12:03               ` Dmitry Gromov
2010-05-19  1:27               ` Huaxu Wan
     [not found]             ` <625BA99ED14B2D499DC4E29D8138F150181F574C31@shsmsx502.ccr.corp.intel.com>
     [not found]               ` <AANLkTimQnaUvXs75rpTOcW7CODXWgUfzekY9FCDa5S8P@mail.gmail.com>
2010-05-18  7:13                 ` Carsten Emde
2010-05-19  0:50                 ` Huaxu Wan
2010-05-19  3:12                   ` Dmitry Gromov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100507095945.GB12190@owl \
    --to=huaxu.wan@linux.intel.com \
    --cc=huaxu.wan@intel.com \
    --cc=khali@linux-fr.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lm-sensors@lm-sensors.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox