Added support for fan control on ITE 87XX chips and a mainboard specific configuration for the Gigabyte GA 970A UD3 (both based on a patch from Eric Hokanson).
authormoel.mich
Sun, 21 Oct 2012 14:24:03 +0000
changeset 382ba6abd47a80c
parent 381 ed5d5fc482ed
child 383 ace2c5fc4b7f
Added support for fan control on ITE 87XX chips and a mainboard specific configuration for the Gigabyte GA 970A UD3 (both based on a patch from Eric Hokanson).
Hardware/LPC/IT87XX.cs
Hardware/Mainboard/Identification.cs
Hardware/Mainboard/Model.cs
Hardware/Mainboard/SuperIOHardware.cs
Properties/AssemblyVersion.cs
     1.1 --- a/Hardware/LPC/IT87XX.cs	Mon Oct 01 17:10:09 2012 +0000
     1.2 +++ b/Hardware/LPC/IT87XX.cs	Sun Oct 21 14:24:03 2012 +0000
     1.3 @@ -10,6 +10,7 @@
     1.4  
     1.5  using System.Globalization;
     1.6  using System.Text;
     1.7 +using System;
     1.8  
     1.9  namespace OpenHardwareMonitor.Hardware.LPC {
    1.10    internal class IT87XX : ISuperIO {
    1.11 @@ -45,10 +46,14 @@
    1.12      private const byte VENDOR_ID_REGISTER = 0x58;
    1.13      private const byte FAN_TACHOMETER_DIVISOR_REGISTER = 0x0B;
    1.14      private readonly byte[] FAN_TACHOMETER_REG = 
    1.15 -      new byte[] { 0x0d, 0x0e, 0x0f, 0x80, 0x82 };
    1.16 +      { 0x0d, 0x0e, 0x0f, 0x80, 0x82 };
    1.17      private readonly byte[] FAN_TACHOMETER_EXT_REG =
    1.18 -      new byte[] { 0x18, 0x19, 0x1a, 0x81, 0x83 };
    1.19 +      { 0x18, 0x19, 0x1a, 0x81, 0x83 };
    1.20      private const byte VOLTAGE_BASE_REG = 0x20;
    1.21 +    private readonly byte[] FAN_PWM_CTRL_REG = { 0x15, 0x16, 0x17 };
    1.22 +
    1.23 +    private bool[] restoreDefaultFanPwmControlRequired = new bool[3];       
    1.24 +    private byte[] initialFanPwmControl = new byte[3];
    1.25  
    1.26      private byte ReadByte(byte register, out bool valid) {
    1.27        Ring0.WriteIoPort(addressReg, register);
    1.28 @@ -77,7 +82,40 @@
    1.29        Ring0.WriteIoPort((ushort)(gpioAddress + index), value);
    1.30      } 
    1.31  
    1.32 -    public void SetControl(int index, byte? value) { }   
    1.33 +    private void SaveDefaultFanPwmControl(int index) {
    1.34 +      bool valid;
    1.35 +      if (!restoreDefaultFanPwmControlRequired[index]) {
    1.36 +        initialFanPwmControl[index] = 
    1.37 +          ReadByte(FAN_PWM_CTRL_REG[index], out valid);
    1.38 +        restoreDefaultFanPwmControlRequired[index] = true;
    1.39 +      }
    1.40 +    }
    1.41 +
    1.42 +    private void RestoreDefaultFanPwmControl(int index) {
    1.43 +      if (restoreDefaultFanPwmControlRequired[index]) {
    1.44 +        WriteByte(FAN_PWM_CTRL_REG[index], initialFanPwmControl[index]);
    1.45 +        restoreDefaultFanPwmControlRequired[index] = false;
    1.46 +      }
    1.47 +    }
    1.48 +
    1.49 +    public void SetControl(int index, byte? value) {
    1.50 +      if (index < 0 || index >= controls.Length)
    1.51 +        throw new ArgumentOutOfRangeException("index");
    1.52 +
    1.53 +      if (!Ring0.WaitIsaBusMutex(10))
    1.54 +        return;
    1.55 +
    1.56 +      if (value.HasValue) {
    1.57 +        SaveDefaultFanPwmControl(index);
    1.58 +
    1.59 +        // set output value
    1.60 +        WriteByte(FAN_PWM_CTRL_REG[index], (byte)(value.Value >> 1));  
    1.61 +      } else {
    1.62 +        RestoreDefaultFanPwmControl(index);
    1.63 +      }
    1.64 +
    1.65 +      Ring0.ReleaseIsaBusMutex();
    1.66 +    } 
    1.67  
    1.68      public IT87XX(Chip chip, ushort address, ushort gpioAddress, byte version) {
    1.69  
    1.70 @@ -103,6 +141,7 @@
    1.71        voltages = new float?[9];
    1.72        temperatures = new float?[3];
    1.73        fans = new float?[chip == Chip.IT8705F ? 3 : 5];
    1.74 +      controls = new float?[3];
    1.75  
    1.76        // IT8721F, IT8728F and IT8772E use a 12mV resultion ADC, all others 16mV
    1.77        if (chip == Chip.IT8721F || chip == Chip.IT8728F || chip == Chip.IT8771E 
    1.78 @@ -270,6 +309,21 @@
    1.79          }
    1.80        }
    1.81  
    1.82 +      for (int i = 0; i < controls.Length; i++) {
    1.83 +        bool valid;
    1.84 +        byte value = ReadByte(FAN_PWM_CTRL_REG[i], out valid);
    1.85 +        if (!valid)
    1.86 +          continue;
    1.87 +
    1.88 +        if ((value & 0x80) > 0) {
    1.89 +          // automatic operation (value can't be read)
    1.90 +          controls[i] = null;  
    1.91 +        } else {
    1.92 +          // software operation
    1.93 +          controls[i] = (float)Math.Round((value & 0x7F) * 100.0f / 0x7F);
    1.94 +        }
    1.95 +      }
    1.96 +
    1.97        Ring0.ReleaseIsaBusMutex();
    1.98      }
    1.99    } 
     2.1 --- a/Hardware/Mainboard/Identification.cs	Mon Oct 01 17:10:09 2012 +0000
     2.2 +++ b/Hardware/Mainboard/Identification.cs	Sun Oct 21 14:24:03 2012 +0000
     2.3 @@ -132,6 +132,8 @@
     2.4            return Model.G41MT_S2;
     2.5          case "G41MT-S2P":
     2.6            return Model.G41MT_S2P;
     2.7 +        case "GA-970A-UD3":
     2.8 +          return Model.GA_970A_UD3;
     2.9          case "GA-MA770T-UD3":
    2.10            return Model.GA_MA770T_UD3;
    2.11          case "GA-MA770T-UD3P":
     3.1 --- a/Hardware/Mainboard/Model.cs	Mon Oct 01 17:10:09 2012 +0000
     3.2 +++ b/Hardware/Mainboard/Model.cs	Sun Oct 21 14:24:03 2012 +0000
     3.3 @@ -51,6 +51,7 @@
     3.4      G41M_Combo,
     3.5      G41MT_S2,
     3.6      G41MT_S2P,
     3.7 +    GA_970A_UD3,
     3.8      GA_MA770T_UD3,
     3.9      GA_MA770T_UD3P,
    3.10      GA_MA785GM_US2H,
     4.1 --- a/Hardware/Mainboard/SuperIOHardware.cs	Mon Oct 01 17:10:09 2012 +0000
     4.2 +++ b/Hardware/Mainboard/SuperIOHardware.cs	Sun Oct 21 14:24:03 2012 +0000
     4.3 @@ -352,6 +352,23 @@
     4.4                    f.Add(new Fan("CPU Fan", 0));
     4.5                    f.Add(new Fan("System Fan", 1));
     4.6                    break;
     4.7 +                case Model.GA_970A_UD3: // IT8720F
     4.8 +                  v.Add(new Voltage("CPU VCore", 0));
     4.9 +                  v.Add(new Voltage("DRAM", 1));
    4.10 +                  v.Add(new Voltage("+3.3V", 2));
    4.11 +                  v.Add(new Voltage("+5V", 3, 6.8f, 10));
    4.12 +                  v.Add(new Voltage("+12V", 4, 24.3f, 8.2f));
    4.13 +                  v.Add(new Voltage("VBat", 8));
    4.14 +                  t.Add(new Temperature("System", 0));
    4.15 +                  t.Add(new Temperature("CPU", 1));
    4.16 +                  f.Add(new Fan("CPU Fan", 0));
    4.17 +                  f.Add(new Fan("System Fan #1", 1));
    4.18 +                  f.Add(new Fan("System Fan #2", 2));
    4.19 +                  f.Add(new Fan("Power Fan", 4));
    4.20 +                  c.Add(new Ctrl("PWM 1", 0));
    4.21 +                  c.Add(new Ctrl("PWM 2", 1));
    4.22 +                  c.Add(new Ctrl("PWM 3", 2));
    4.23 +                  break;
    4.24                  case Model.GA_MA770T_UD3: // IT8720F
    4.25                  case Model.GA_MA770T_UD3P: // IT8720F                
    4.26                  case Model.GA_MA790X_UD3P: // IT8720F
     5.1 --- a/Properties/AssemblyVersion.cs	Mon Oct 01 17:10:09 2012 +0000
     5.2 +++ b/Properties/AssemblyVersion.cs	Sun Oct 21 14:24:03 2012 +0000
     5.3 @@ -10,5 +10,5 @@
     5.4  
     5.5  using System.Reflection;
     5.6  
     5.7 -[assembly: AssemblyVersion("0.5.1.4")]
     5.8 -[assembly: AssemblyInformationalVersion("0.5.1.4 Alpha")]
     5.9 \ No newline at end of file
    5.10 +[assembly: AssemblyVersion("0.5.1.5")]
    5.11 +[assembly: AssemblyInformationalVersion("0.5.1.5 Alpha")]
    5.12 \ No newline at end of file