# HG changeset patch
# User moel.mich
# Date 1267481549 0
# Node ID bb5696abab23ae4257c195720239cc0fc49c84a6
# Parent  2b537d442924ceacb05ca78c634f9bc2ffa5cacb
Added support for Winbond W83687THF and improved report output for LPC detection.

diff -r 2b537d442924 -r bb5696abab23 Hardware/LPC/Chip.cs
--- a/Hardware/LPC/Chip.cs	Sun Feb 28 16:12:55 2010 +0000
+++ b/Hardware/LPC/Chip.cs	Mon Mar 01 22:12:29 2010 +0000
@@ -18,6 +18,7 @@
     W83627THF = 0x8283,
     W83667HG = 0xA510,
     W83667HGB = 0xB350,
+    W83687THF = 0x8541,
     F71862 = 0x0601, 
     F71869 = 0x0814,
     F71882 = 0x0541,
diff -r 2b537d442924 -r bb5696abab23 Hardware/LPC/LPCGroup.cs
--- a/Hardware/LPC/LPCGroup.cs	Sun Feb 28 16:12:55 2010 +0000
+++ b/Hardware/LPC/LPCGroup.cs	Mon Mar 01 22:12:29 2010 +0000
@@ -42,7 +42,9 @@
 
 namespace OpenHardwareMonitor.Hardware.LPC {
   public class LPCGroup : IGroup {
+
     private List<IHardware> hardware = new List<IHardware>();
+    private StringBuilder report = new StringBuilder();
 
     private Chip chip = Chip.Unknown;
 
@@ -108,6 +110,15 @@
       WinRing0.WriteIoPortByte(registerPort, 0xAA);      
     }
 
+    // SMSC
+    private void SMSCEnter() {
+      WinRing0.WriteIoPortByte(registerPort, 0x55);
+    }
+
+    private void SMSCExit() {
+      WinRing0.WriteIoPortByte(registerPort, 0xAA);
+    }
+
     public LPCGroup() {
       if (!WinRing0.IsAvailable)
         return;
@@ -167,6 +178,13 @@
                 logicalDeviceNumber = WINBOND_HARDWARE_MONITOR_LDN;
                 break;
             } break;
+          case 0x85:
+            switch (revision) {
+              case 0x41:
+                chip = Chip.W83687THF;
+                logicalDeviceNumber = WINBOND_HARDWARE_MONITOR_LDN;
+                break;
+            } break;
           case 0x88:
             switch (revision & 0xF0) {
               case 0x60:
@@ -203,7 +221,15 @@
                 break;
             } break; 
         }
-        if (chip != Chip.Unknown) {
+        if (chip == Chip.Unknown) {
+          if (id != 0 && id != 0xff) {
+            WinbondFintekExit();
+
+            report.Append("Chip ID: Unknown Winbond / Fintek with ID 0x"); 
+            report.AppendLine(((id << 8) | revision).ToString("X"));
+            report.AppendLine();
+          }
+        } else {
 
           Select(logicalDeviceNumber);
           ushort address = ReadWord(BASE_ADDRESS_REGISTER);          
@@ -216,16 +242,31 @@
 
           WinbondFintekExit();
 
-          if (address != verify)
+          if (address != verify) {            
+            report.Append("Chip ID: 0x"); 
+            report.AppendLine(chip.ToString("X"));
+            report.Append("Chip revision: 0x"); 
+            report.AppendLine(revision.ToString("X"));
+            report.AppendLine("Error: Address verification failed");
+            report.AppendLine();
             return;
+          }
 
           // some Fintek chips have address register offset 0x05 added already
           if ((address & 0x07) == 0x05)
             address &= 0xFFF8;
 
-          if (address < 0x100 || (address & 0xF007) != 0)
+          if (address < 0x100 || (address & 0xF007) != 0) {            
+            report.Append("Chip ID: 0x");
+            report.AppendLine(chip.ToString("X"));
+            report.Append("Chip revision: 0x");
+            report.AppendLine(revision.ToString("X"));
+            report.Append("Error: Invalid address 0x");
+            report.AppendLine(address.ToString("X"));
+            report.AppendLine();
             return;
-          
+          }
+
           switch (chip) {
             case Chip.W83627DHG:
             case Chip.W83627DHGP:
@@ -234,6 +275,7 @@
             case Chip.W83627THF:
             case Chip.W83667HG:
             case Chip.W83667HGB:
+            case Chip.W83687THF:
               W836XX w836XX = new W836XX(chip, revision, address);
               if (w836XX.IsAvailable)
                 hardware.Add(w836XX);
@@ -255,15 +297,23 @@
 
         IT87Enter();
 
-        switch (ReadWord(CHIP_ID_REGISTER)) {
+        ushort chipID = ReadWord(CHIP_ID_REGISTER);
+        switch (chipID) {
           case 0x8716: chip = Chip.IT8716F; break;
           case 0x8718: chip = Chip.IT8718F; break;
           case 0x8720: chip = Chip.IT8720F; break;
-          case 0x8726: chip = Chip.IT8726F; break;
+          case 0x8726: chip = Chip.IT8726F; break; 
           default: chip = Chip.Unknown; break;
         }
+        if (chip == Chip.Unknown) {
+          if (chipID != 0 && chipID != 0xffff) {
+            IT87Exit();
 
-        if (chip != Chip.Unknown) {
+            report.Append("Chip ID: Unknown ITE with ID 0x");
+            report.AppendLine(chipID.ToString("X"));
+            report.AppendLine();
+          }
+        } else {
           Select(IT87_ENVIRONMENT_CONTROLLER_LDN);
           ushort address = ReadWord(BASE_ADDRESS_REGISTER);
           Thread.Sleep(1);
@@ -271,8 +321,14 @@
 
           IT87Exit();
 
-          if (address != verify || address < 0x100 || (address & 0xF007) != 0)
+          if (address != verify || address < 0x100 || (address & 0xF007) != 0) {
+            report.Append("Chip ID: 0x");
+            report.AppendLine(chip.ToString("X"));            
+            report.Append("Error: Invalid address 0x");
+            report.AppendLine(address.ToString("X"));
+            report.AppendLine();
             return;
+          }
 
           IT87XX it87 = new IT87XX(chip, address);
           if (it87.IsAvailable)
@@ -280,6 +336,26 @@
 
           return;
         }
+
+        SMSCEnter();
+
+        chipID = ReadWord(CHIP_ID_REGISTER);
+        switch (chipID) {
+          default: chip = Chip.Unknown; break;
+        }
+        if (chip == Chip.Unknown) {
+          if (chipID != 0 && chipID != 0xffff) {
+            SMSCExit();
+
+            report.Append("Chip ID: Unknown SMSC with ID 0x");
+            report.AppendLine(chipID.ToString("X"));
+            report.AppendLine();
+          }
+        } else {
+          SMSCExit();
+
+          return;
+        }
       }   
     }
 
@@ -290,7 +366,12 @@
     }
 
     public string GetReport() {
-      return null;
+      if (report.Length > 0) {
+        report.Insert(0, "LPCIO" + Environment.NewLine +
+          Environment.NewLine);        
+        return report.ToString();
+      } else
+        return null;
     }
 
     public void Close() { }
diff -r 2b537d442924 -r bb5696abab23 Hardware/LPC/LPCHardware.cs
--- a/Hardware/LPC/LPCHardware.cs	Sun Feb 28 16:12:55 2010 +0000
+++ b/Hardware/LPC/LPCHardware.cs	Mon Mar 01 22:12:29 2010 +0000
@@ -66,6 +66,7 @@
         case Chip.W83627THF: this.name = "Winbond W83627THF"; break;
         case Chip.W83667HG: this.name = "Winbond W83667HG"; break;
         case Chip.W83667HGB: this.name = "Winbond W83667HG-B"; break;
+        case Chip.W83687THF: this.name = "Winbond W83687THF"; break;
       }
     }
 
diff -r 2b537d442924 -r bb5696abab23 Hardware/LPC/W836XX.cs
--- a/Hardware/LPC/W836XX.cs	Sun Feb 28 16:12:55 2010 +0000
+++ b/Hardware/LPC/W836XX.cs	Mon Mar 01 22:12:29 2010 +0000
@@ -167,6 +167,7 @@
           break;
         case Chip.W83627HF:
         case Chip.W83627THF:
+        case Chip.W83687THF:
           fanNames = new string[] { "System", "CPU", "Auxiliary" };
           voltageGains = new float[] { 2, 1, 2, 1, 1, 1, 1, 2 };
           voltages = new Sensor[3];
@@ -199,7 +200,9 @@
       foreach (Sensor sensor in voltages) {
         if (sensor.Index < 7) {
           // two special VCore measurement modes for W83627THF
-          if (chip == Chip.W83627THF && sensor.Index == 0) {
+          if ((chip == Chip.W83627HF || chip == Chip.W83627THF || 
+            chip == Chip.W83687THF) && sensor.Index == 0) 
+          {
             byte vrmConfiguration = ReadByte(0, 0x18);
             int value = ReadByte(0, VOLTAGE_BASE_REG);
             if ((vrmConfiguration & 0x01) == 0)
diff -r 2b537d442924 -r bb5696abab23 Hardware/Mainboard/Mainboard.cs
--- a/Hardware/Mainboard/Mainboard.cs	Sun Feb 28 16:12:55 2010 +0000
+++ b/Hardware/Mainboard/Mainboard.cs	Mon Mar 01 22:12:29 2010 +0000
@@ -84,6 +84,8 @@
       r.AppendLine();           
       r.Append(smbios.GetReport());
 
+      r.Append(lpcGroup.GetReport());
+
       return r.ToString();
     }
 
diff -r 2b537d442924 -r bb5696abab23 Properties/AssemblyInfo.cs
--- a/Properties/AssemblyInfo.cs	Sun Feb 28 16:12:55 2010 +0000
+++ b/Properties/AssemblyInfo.cs	Mon Mar 01 22:12:29 2010 +0000
@@ -69,5 +69,5 @@
 // You can specify all the values or you can default the Build and Revision Numbers 
 // by using the '*' as shown below:
 // [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("0.1.24.1")]
-[assembly: AssemblyFileVersion("0.1.24.1")]
+[assembly: AssemblyVersion("0.1.24.3")]
+[assembly: AssemblyFileVersion("0.1.24.3")]