From 44e98dbff19f1cfd3edf26618f2462aeb6c0106e Mon Sep 17 00:00:00 2001
From: Cecil Hugh Watson <knoppmyth@gmail.com>
Date: Sun, 1 Nov 2009 00:37:04 -0700
Subject: kernel26:patch for coretemp.  closes fs#534

---
 abs/core-testing/kernel26/PKGBUILD       | 10 ++--
 abs/core-testing/kernel26/coretemp.patch | 86 ++++++++++++++++++++++++++++++++
 2 files changed, 93 insertions(+), 3 deletions(-)
 create mode 100644 abs/core-testing/kernel26/coretemp.patch

diff --git a/abs/core-testing/kernel26/PKGBUILD b/abs/core-testing/kernel26/PKGBUILD
index 8248fc5..0095428 100644
--- a/abs/core-testing/kernel26/PKGBUILD
+++ b/abs/core-testing/kernel26/PKGBUILD
@@ -5,7 +5,7 @@
 pkgname=kernel26
 _basekernel=2.6.28
 pkgver=2.6.28.5
-pkgrel=4
+pkgrel=5
 _pkgrel=1
 _patchname="patch-${pkgver}-${_pkgrel}-ARCH"
 _fbpatchname="fbcondecor-0.9.5-2.6.28.patch"
@@ -35,7 +35,8 @@ source=(ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-$_basekernel.tar.bz2
         kernel26.preset
 	logo_linux_clut224.ppm
 	serial.diff
-	ext4.patch)
+	ext4.patch
+	coretemp.patch)
 optdepends=('crda: to set the correct wireless channels of your country')
 md5sums=('d351e44709c9810b85e29b877f50968a'
          '6e63a5f54c142f42de7e59fc5f75eab2'
@@ -44,7 +45,8 @@ md5sums=('d351e44709c9810b85e29b877f50968a'
          '959b317feb974d8906c5e15e7c76ad8f'
          'ceb38003807a5aa1a00c8d4b9f028893'
          '7bdfe2e1daedb324fdfdfa95ba4e2430'
-         'd66b5cc1e1c2ce40d06d77167f36dfd9')
+         'd66b5cc1e1c2ce40d06d77167f36dfd9'
+	 '695a2d6f1b0b4c7001bf665d5f667a5d')
 
 build() {
   KARCH=x86
@@ -55,6 +57,8 @@ build() {
   patch -Np1 -i ${srcdir}/${_patchname} || return 1
   patch -Np1 -i ${srcdir}/${_fbpatchname} || return 1
   patch -Np1 -i ${srcdir}/ext4.patch || return 1
+  patch -Np1 -i ${srcdir}/coretemp.patch || return 1
+#  patch -Np1 -i ${srcdir}/patch-2.6.28.5 || return 1
 #  patch -p0 < ../../serial.diff
 
   if [ "$CARCH" = "x86_64" ]; then
diff --git a/abs/core-testing/kernel26/coretemp.patch b/abs/core-testing/kernel26/coretemp.patch
new file mode 100644
index 0000000..07ce434
--- /dev/null
+++ b/abs/core-testing/kernel26/coretemp.patch
@@ -0,0 +1,86 @@
+diff -ubr orig/linux-2.6.28/Documentation/hwmon/coretemp linux-2.6.28/Documentation/hwmon/coretemp
+--- orig/linux-2.6.28/Documentation/hwmon/coretemp	2008-12-25 00:26:37.000000000 +0100
++++ linux-2.6.28/Documentation/hwmon/coretemp	2009-07-18 07:29:37.000000000 +0200
+@@ -4,7 +4,7 @@
+ Supported chips:
+   * All Intel Core family
+     Prefix: 'coretemp'
+-    CPUID: family 0x6, models 0xe, 0xf, 0x16, 0x17
++    CPUID: family 0x6, models 0xe, 0xf, 0x16, 0x17, 0x1c
+     Datasheet: Intel 64 and IA-32 Architectures Software Developer's Manual
+                Volume 3A: System Programming Guide
+                http://softwarecommunity.intel.com/Wiki/Mobility/720.htm
+@@ -14,10 +14,11 @@
+ Description
+ -----------
+ 
+-This driver permits reading temperature sensor embedded inside Intel Core CPU.
+-Temperature is measured in degrees Celsius and measurement resolution is
+-1 degree C. Valid temperatures are from 0 to TjMax degrees C, because
+-the actual value of temperature register is in fact a delta from TjMax.
++This driver permits reading temperature sensor embedded inside Intel
++Core  and Intel Atom CPUs. Temperature is measured in degrees Celsius
++and measurement resolution is 1 degree C. Valid temperatures are from 0
++to TjMax degrees C, because the actual value of temperature register is
++in fact a delta from TjMax.
+ 
+ Temperature known as TjMax is the maximum junction temperature of processor.
+ Intel defines this temperature as 85C or 100C. At this temperature, protection
+@@ -35,4 +36,5 @@
+ 
+ The TjMax temperature is set to 85 degrees C if undocumented model specific
+ register (UMSR) 0xee has bit 30 set. If not the TjMax is 100 degrees C as
+-(sometimes) documented in processor datasheet.
++(sometimes) documented in processor datasheet. The Intel Atom has TjMax 95C
++as per the specification.
+diff -ubr orig/linux-2.6.28/drivers/hwmon/coretemp.c linux-2.6.28/drivers/hwmon/coretemp.c
+--- orig/linux-2.6.28/drivers/hwmon/coretemp.c	2008-12-25 00:26:37.000000000 +0100
++++ linux-2.6.28/drivers/hwmon/coretemp.c	2009-07-18 08:12:16.000000000 +0200
+@@ -1,7 +1,7 @@
+ /*
+  * coretemp.c - Linux kernel module for hardware monitoring
+  *
+- * Copyright (C) 2007 Rudolf Marek <r.marek@assembler.cz>
++ * Copyright (C) 2007, 2008 Rudolf Marek <r.marek@assembler.cz>
+  *
+  * Inspired from many hwmon drivers
+  *
+@@ -244,8 +244,14 @@
+ 		}
+ 	}
+ 
++	/* Intel Atom has only fixed TjMax at 95C */
++
++	if (c->x86_model == 0x1c) {
++		data->tjmax = 95000;
++	} else {
++		/* Adjust the TjMax for the rest of Core2 family */
+ 	data->tjmax = adjust_tjmax(c, data->id, &pdev->dev);
+-	platform_set_drvdata(pdev, data);
++	}
+ 
+ 	/* read the still undocumented IA32_TEMPERATURE_TARGET it exists
+ 	   on older CPUs but not in this register */
+@@ -265,6 +271,8 @@
+ 		}
+ 	}
+ 
++	platform_set_drvdata(pdev, data);
++
+ 	if ((err = sysfs_create_group(&pdev->dev.kobj, &coretemp_group)))
+ 		goto exit_dev;
+ 
+@@ -413,11 +421,11 @@
+ 	for_each_online_cpu(i) {
+ 		struct cpuinfo_x86 *c = &cpu_data(i);
+ 
+-		/* check if family 6, models 0xe, 0xf, 0x16, 0x17, 0x1A */
++		/* check if family 6, models 0xe, 0xf, 0x16, 0x17, 0x1A, 0x1C */
+ 		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 == 0x1A) || (c->x86_model == 0x1C))) {
+ 
+ 			/* supported CPU not found, but report the unknown
+ 			   family 6 CPU */
-- 
cgit v0.12