From 6553d7788c996c0953cea1d3c588fcce91abc03f Mon Sep 17 00:00:00 2001 From: Rem0o Date: Wed, 29 Jan 2020 03:14:05 -0500 Subject: [PATCH] NCT6797 7th fan (#202) Thanks to @Rem0o. --- .../Hardware/Motherboard/Lpc/Nct677X.cs | 44 ++++++++++++++----- 1 file changed, 33 insertions(+), 11 deletions(-) diff --git a/LibreHardwareMonitorLib/Hardware/Motherboard/Lpc/Nct677X.cs b/LibreHardwareMonitorLib/Hardware/Motherboard/Lpc/Nct677X.cs index 8b253ae..8b9c534 100644 --- a/LibreHardwareMonitorLib/Hardware/Motherboard/Lpc/Nct677X.cs +++ b/LibreHardwareMonitorLib/Hardware/Motherboard/Lpc/Nct677X.cs @@ -1,4 +1,4 @@ -// Mozilla Public License 2.0 +// Mozilla Public License 2.0 // If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. // Copyright (C) LibreHardwareMonitor and Contributors // All Rights Reserved @@ -13,15 +13,15 @@ namespace LibreHardwareMonitor.Hardware.Motherboard.Lpc internal class Nct677X : ISuperIO { private readonly ushort?[] _alternateTemperatureRegister; - private readonly ushort _fanRpmBaseRegister; - private readonly byte[] _initialFanControlMode = new byte[6]; - private readonly byte[] _initialFanPwmCommand = new byte[6]; + private readonly ushort[] _fanRpmRegister; + private readonly byte[] _initialFanControlMode = new byte[7]; + private readonly byte[] _initialFanPwmCommand = new byte[7]; private readonly bool _isNuvotonVendor; private readonly LpcPort _lpcPort; private readonly int _minFanRpm; private readonly ushort _port; - private readonly bool[] _restoreDefaultFanControlRequired = new bool[6]; + private readonly bool[] _restoreDefaultFanControlRequired = new bool[7]; private readonly byte _revision; private readonly int[] _temperatureHalfBit; private readonly ushort[] _temperatureHalfRegister; @@ -50,6 +50,17 @@ namespace LibreHardwareMonitor.Hardware.Motherboard.Lpc _vBatMonitorControlRegister = 0x0318; } + else if (chip == Chip.NCT6797D || chip == Chip.NCT6798D) + { + VENDOR_ID_HIGH_REGISTER = 0x804F; + VENDOR_ID_LOW_REGISTER = 0x004F; + + FAN_PWM_OUT_REG = new ushort[] { 0x001, 0x003, 0x011, 0x013, 0x015, 0xa09, 0xb09 }; + FAN_PWM_COMMAND_REG = new ushort[] { 0x109, 0x209, 0x309, 0x809, 0x909, 0xa09, 0xb09 }; + FAN_CONTROL_MODE_REG = new ushort[] { 0x102, 0x202, 0x302, 0x802, 0x902, 0xA02, 0xB02 }; + + _vBatMonitorControlRegister = 0x005D; + } else { VENDOR_ID_HIGH_REGISTER = 0x804F; @@ -92,7 +103,9 @@ namespace LibreHardwareMonitor.Hardware.Motherboard.Lpc _temperaturesSource = new[] { (byte)SourceNct6776F.PECI_0, (byte)SourceNct6776F.CPUTIN, (byte)SourceNct6776F.AUXTIN, (byte)SourceNct6776F.SYSTIN }; } - _fanRpmBaseRegister = 0x656; + _fanRpmRegister = new ushort[5]; + for (int i = 0; i < _fanRpmRegister.Length; i++) + _fanRpmRegister[i] = (ushort)(0x656 + (i << 1)); Controls = new float?[3]; @@ -106,6 +119,7 @@ namespace LibreHardwareMonitor.Hardware.Motherboard.Lpc _temperatureHalfBit = new[] { -1, 7, 7, 7, 7, 7, 0, 1, 2 }; _temperatureSourceRegister = new ushort[] { 0x621, 0x100, 0x200, 0x300, 0x622, 0x623, 0x624, 0x625, 0x626 }; _alternateTemperatureRegister = new ushort?[] { null, null, null, null }; + break; } case Chip.NCT6779D: @@ -122,13 +136,18 @@ namespace LibreHardwareMonitor.Hardware.Motherboard.Lpc Fans = new float?[5]; Controls = new float?[5]; } + else if (chip == Chip.NCT6797D || chip == Chip.NCT6798D) + { + Fans = new float?[7]; + Controls = new float?[7]; + } else { Fans = new float?[6]; Controls = new float?[6]; } - _fanRpmBaseRegister = 0x4C0; + _fanRpmRegister = new ushort[] { 0x4c0, 0x4c2, 0x4c4, 0x4c6, 0x4c8, 0x4ca, 0x4ce }; // min value RPM value with 13-bit fan counter _minFanRpm = (int)(1.35e6 / 0x1FFF); @@ -160,8 +179,10 @@ namespace LibreHardwareMonitor.Hardware.Motherboard.Lpc Fans = new float?[3]; Controls = new float?[3]; - _fanRpmBaseRegister = 0x030; - + _fanRpmRegister = new ushort[3]; + for (int i = 0; i < _fanRpmRegister.Length; i++) + _fanRpmRegister[i] = (ushort)(0x030 + (i << 1)); + // min value RPM value with 13-bit fan counter _minFanRpm = (int)(1.35e6 / 0x1FFF); @@ -176,6 +197,7 @@ namespace LibreHardwareMonitor.Hardware.Motherboard.Lpc _temperatureHalfBit = new[] { -1, 7, 7, 7 }; _temperatureSourceRegister = new ushort[] { 0x621, 0x100, 0x200, 0x300 }; _alternateTemperatureRegister = new ushort?[] { null, 0x018, 0x019, 0x01A }; + break; } } @@ -296,8 +318,8 @@ namespace LibreHardwareMonitor.Hardware.Motherboard.Lpc for (int i = 0; i < Fans.Length; i++) { - byte high = ReadByte((ushort)(_fanRpmBaseRegister + (i << 1))); - byte low = ReadByte((ushort)(_fanRpmBaseRegister + (i << 1) + 1)); + byte high = ReadByte((ushort)(_fanRpmRegister[i])); + byte low = ReadByte((ushort)(_fanRpmRegister[i] + 1)); int value = (high << 8) | low; Fans[i] = value > _minFanRpm ? value : 0; }