Skip to content

Commit

Permalink
Merge commit 'e19faf5047ac88ea5e82b516397c15afb69c480d' into open-har…
Browse files Browse the repository at this point in the history
…dware-monitor
  • Loading branch information
hirschmann committed Nov 30, 2015
1 parent d099889 commit 1bf01ea
Show file tree
Hide file tree
Showing 5 changed files with 142 additions and 20 deletions.
18 changes: 13 additions & 5 deletions Core/Plugins/OpenHardwareMonitor/Hardware/CPU/IntelCPU.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ private enum Microarchitecture {
IvyBridge,
Haswell,
Broadwell,
Silvermont
Silvermont,
Skylake
}

private readonly Sensor[] coreTemperatures;
Expand Down Expand Up @@ -56,7 +57,6 @@ private enum Microarchitecture {
private DateTime[] lastEnergyTime;
private uint[] lastEnergyConsumed;


private float[] Floats(float f) {
float[] result = new float[coreCount];
for (int i = 0; i < coreCount; i++)
Expand Down Expand Up @@ -163,6 +163,11 @@ public IntelCPU(int processorIndex, CPUID[][] cpuid, ISettings settings)
microarchitecture = Microarchitecture.Silvermont;
tjMax = GetTjMaxFromMSR();
break;
case 0x4E:
case 0x5E: // Intel Core i5, i7 6xxxx LGA1151 (14nm)
microarchitecture = Microarchitecture.Skylake;
tjMax = GetTjMaxFromMSR();
break;
default:
microarchitecture = Microarchitecture.Unknown;
tjMax = Floats(100);
Expand Down Expand Up @@ -208,7 +213,8 @@ public IntelCPU(int processorIndex, CPUID[][] cpuid, ISettings settings)
case Microarchitecture.IvyBridge:
case Microarchitecture.Haswell:
case Microarchitecture.Broadwell:
case Microarchitecture.Silvermont: {
case Microarchitecture.Silvermont:
case Microarchitecture.Skylake: {
uint eax, edx;
if (Ring0.Rdmsr(MSR_PLATFORM_INFO, out eax, out edx)) {
timeStampCounterMultiplier = (eax >> 8) & 0xff;
Expand Down Expand Up @@ -269,6 +275,7 @@ public IntelCPU(int processorIndex, CPUID[][] cpuid, ISettings settings)
microarchitecture == Microarchitecture.IvyBridge ||
microarchitecture == Microarchitecture.Haswell ||
microarchitecture == Microarchitecture.Broadwell ||
microarchitecture == Microarchitecture.Skylake ||
microarchitecture == Microarchitecture.Silvermont)
{
powerSensors = new Sensor[energyStatusMSRs.Length];
Expand Down Expand Up @@ -372,7 +379,7 @@ public override void Update() {
for (int i = 0; i < coreClocks.Length; i++) {
System.Threading.Thread.Sleep(1);
if (Ring0.Rdmsr(IA32_PERF_STATUS, out eax, out edx,
cpuid[i][0].Thread)) {
cpuid[i][0].Thread)) {
newBusClock =
TimeStampCounterFrequency / timeStampCounterMultiplier;
switch (microarchitecture) {
Expand All @@ -384,7 +391,8 @@ public override void Update() {
case Microarchitecture.IvyBridge:
case Microarchitecture.Haswell:
case Microarchitecture.Broadwell:
case Microarchitecture.Silvermont: {
case Microarchitecture.Silvermont:
case Microarchitecture.Skylake: {
uint multiplier = (eax >> 8) & 0xff;
coreClocks[i].Value = (float)(multiplier * newBusClock);
} break;
Expand Down
3 changes: 3 additions & 0 deletions Core/Plugins/OpenHardwareMonitor/Hardware/LPC/Chip.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ internal enum Chip : ushort {

NCT6771F = 0xB470,
NCT6776F = 0xC330,
NCT610X = 0xC452,
NCT6779D = 0xC560,
NCT6791D = 0xC803,

Expand Down Expand Up @@ -80,6 +81,8 @@ public static string GetName(Chip chip) {
case Chip.IT8771E: return "ITE IT8771E";
case Chip.IT8772E: return "ITE IT8772E";

case Chip.NCT610X: return "Nuvoton NCT610X";

case Chip.NCT6771F: return "Nuvoton NCT6771F";
case Chip.NCT6776F: return "Nuvoton NCT6776F";
case Chip.NCT6779D: return "Nuvoton NCT6779D";
Expand Down
11 changes: 10 additions & 1 deletion Core/Plugins/OpenHardwareMonitor/Hardware/LPC/LPCIO.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This Source Code Form is subject to the terms of the Mozilla Public
License, v. 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) 2009-2013 Michael Möller <[email protected]>
Copyright (C) 2009-2015 Michael Möller <[email protected]>
*/

Expand Down Expand Up @@ -222,6 +222,14 @@ private bool DetectWinbondFintek() {
logicalDeviceNumber = WINBOND_NUVOTON_HARDWARE_MONITOR_LDN;
break;
} break;
case 0xC4:
switch (revision & 0xF0)
{
case 0x50:
chip = Chip.NCT610X;
logicalDeviceNumber = WINBOND_NUVOTON_HARDWARE_MONITOR_LDN;
break;
} break;
case 0xC5:
switch (revision & 0xF0) {
case 0x60:
Expand Down Expand Up @@ -307,6 +315,7 @@ private bool DetectWinbondFintek() {
case Chip.W83687THF:
superIOs.Add(new W836XX(chip, revision, address));
break;
case Chip.NCT610X:
case Chip.NCT6771F:
case Chip.NCT6776F:
case Chip.NCT6779D:
Expand Down
111 changes: 97 additions & 14 deletions Core/Plugins/OpenHardwareMonitor/Hardware/LPC/NCT677X.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ This Source Code Form is subject to the terms of the Mozilla Public
License, v. 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) 2010-2013 Michael Möller <[email protected]>
Copyright (C) 2010-2015 Michael Möller <[email protected]>
Copyright (C) 2015 Dawid Gan <[email protected]>
*/

using System;
Expand Down Expand Up @@ -54,15 +55,12 @@ private void WriteByte(ushort address, byte value) {
private const ushort NUVOTON_VENDOR_ID = 0x5CA3;

// Hardware Monitor Registers
private const ushort VENDOR_ID_HIGH_REGISTER = 0x804F;
private const ushort VENDOR_ID_LOW_REGISTER = 0x004F;
private readonly ushort VENDOR_ID_HIGH_REGISTER;
private readonly ushort VENDOR_ID_LOW_REGISTER;

private readonly ushort[] FAN_PWM_OUT_REG =
{ 0x001, 0x003, 0x011, 0x013, 0x015, 0x017 };
private readonly ushort[] FAN_PWM_COMMAND_REG =
{ 0x109, 0x209, 0x309, 0x809, 0x909, 0xA09 };
private readonly ushort[] FAN_CONTROL_MODE_REG =
{ 0x102, 0x202, 0x302, 0x802, 0x902, 0xA02 };
private readonly ushort[] FAN_PWM_OUT_REG;
private readonly ushort[] FAN_PWM_COMMAND_REG;
private readonly ushort[] FAN_CONTROL_MODE_REG;

private readonly ushort fanRpmBaseRegister;
private readonly int minFanRPM;
Expand All @@ -73,6 +71,7 @@ private void WriteByte(ushort address, byte value) {

private readonly ushort[] voltageRegisters;
private readonly ushort voltageVBatRegister;
private readonly ushort vBatMonitorControlRegister;

private readonly byte[] temperaturesSource;

Expand Down Expand Up @@ -159,6 +158,31 @@ private enum SourceNCT67XXD : byte {
BYTE_TEMP = 26
}

private enum SourceNCT610X : byte {
SYSTIN = 1,
CPUTIN = 2,
AUXTIN = 3,
SMBUSMASTER_0 = 4,
SMBUSMASTER_1 = 5,
SMBUSMASTER_2 = 6,
SMBUSMASTER_3 = 7,
SMBUSMASTER_4 = 8,
SMBUSMASTER_5 = 9,
SMBUSMASTER_6 = 10,
SMBUSMASTER_7 = 11,
PECI_0 = 12,
PECI_1 = 13,
PCH_CHIP_CPU_MAX_TEMP = 14,
PCH_CHIP_TEMP = 15,
PCH_CPU_TEMP = 16,
PCH_MCH_TEMP = 17,
PCH_DIM0_TEMP = 18,
PCH_DIM1_TEMP = 19,
PCH_DIM2_TEMP = 20,
PCH_DIM3_TEMP = 21,
BYTE_TEMP = 22
}

public NCT677X(Chip chip, byte revision, ushort port) {
this.chip = chip;
this.revision = revision;
Expand All @@ -170,6 +194,29 @@ public NCT677X(Chip chip, byte revision, ushort port) {
if (!isNuvotonVendor)
return;

if (chip == LPC.Chip.NCT610X) {
VENDOR_ID_HIGH_REGISTER = 0x80FE;
VENDOR_ID_LOW_REGISTER = 0x00FE;

FAN_PWM_OUT_REG = new ushort[] { 0x04A, 0x04B, 0x04C };
FAN_PWM_COMMAND_REG = new ushort[] { 0x119, 0x129, 0x139 };
FAN_CONTROL_MODE_REG = new ushort[] { 0x113, 0x123, 0x133 };

vBatMonitorControlRegister = 0x0318;
} else {
VENDOR_ID_HIGH_REGISTER = 0x804F;
VENDOR_ID_LOW_REGISTER = 0x004F;

FAN_PWM_OUT_REG = new ushort[] {
0x001, 0x003, 0x011, 0x013, 0x015, 0x017 };
FAN_PWM_COMMAND_REG = new ushort[] {
0x109, 0x209, 0x309, 0x809, 0x909, 0xA09 };
FAN_CONTROL_MODE_REG = new ushort[] {
0x102, 0x202, 0x302, 0x802, 0x902, 0xA02 };

vBatMonitorControlRegister = 0x005D;
}

switch (chip) {
case Chip.NCT6771F:
case Chip.NCT6776F:
Expand Down Expand Up @@ -266,6 +313,42 @@ public NCT677X(Chip chip, byte revision, ushort port) {
{null, 0x491, 0x490, 0x492, 0x493, 0x494, 0x495 };

break;
case Chip.NCT610X:

fans = new float?[3];
controls = new float?[3];

fanRpmBaseRegister = 0x030;

// min value RPM value with 13-bit fan counter
minFanRPM = (int)(1.35e6 / 0x1FFF);

voltages = new float?[9];
voltageRegisters = new ushort[]
{ 0x300, 0x301, 0x302, 0x303, 0x304, 0x305, 0x307, 0x308, 0x309 };
voltageVBatRegister = 0x308;

temperatures = new float?[4];
temperaturesSource = new byte[] {
(byte)SourceNCT610X.PECI_0,
(byte)SourceNCT610X.SYSTIN,
(byte)SourceNCT610X.CPUTIN,
(byte)SourceNCT610X.AUXTIN
};

temperatureRegister = new ushort[]
{ 0x027, 0x018, 0x019, 0x01A };
temperatureHalfRegister = new ushort[]
{ 0, 0x01B, 0x11B, 0x21B };
temperatureHalfBit = new int[]
{ -1, 7, 7, 7 };
temperatureSourceRegister = new ushort[]
{ 0x621, 0x100, 0x200, 0x300 };

alternateTemperatureRegister = new ushort?[]
{null, 0x018, 0x019, 0x01A };

break;
}
}

Expand Down Expand Up @@ -341,7 +424,7 @@ public void Update() {

// check if battery voltage monitor is enabled
if (valid && voltageRegisters[i] == voltageVBatRegister)
valid = (ReadByte(0x005D) & 0x01) > 0;
valid = (ReadByte(vBatMonitorControlRegister) & 0x01) > 0;

voltages[i] = valid ? value : (float?)null;
}
Expand Down Expand Up @@ -413,9 +496,9 @@ public string GetReport() {
return r.ToString();

ushort[] addresses = new ushort[] {
0x000, 0x010, 0x020, 0x030, 0x040, 0x050, 0x060, 0x070,
0x000, 0x010, 0x020, 0x030, 0x040, 0x050, 0x060, 0x070, 0x0F0,
0x100, 0x110, 0x120, 0x130, 0x140, 0x150,
0x200, 0x220, 0x230, 0x240, 0x250, 0x260,
0x200, 0x210, 0x220, 0x230, 0x240, 0x250, 0x260,
0x300, 0x320, 0x330, 0x340, 0x360,
0x400, 0x410, 0x420, 0x440, 0x450, 0x460, 0x480, 0x490, 0x4B0,
0x4C0, 0x4F0,
Expand All @@ -430,7 +513,7 @@ public string GetReport() {
0xD00, 0xD10, 0xD20, 0xD30, 0xD50, 0xD60,
0xE00, 0xE10, 0xE20, 0xE30,
0xF00, 0xF10, 0xF20, 0xF30,
0x8040};
0x8040, 0x80F0};

r.AppendLine("Hardware Monitor Registers");
r.AppendLine();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,25 @@ private static void GetBoardSpecificConfiguration(ISuperIO superIO,
case Chip.NCT6776F:
GetNuvotonConfigurationF(superIO, manufacturer, model, v, t, f, c);
break;
case Chip.NCT610X:
v.Add(new Voltage("CPU VCore", 0));
v.Add(new Voltage("Voltage #0", 1, true));
v.Add(new Voltage("AVCC", 2, 34, 34));
v.Add(new Voltage("3VCC", 3, 34, 34));
v.Add(new Voltage("Voltage #1", 4, true));
v.Add(new Voltage("Voltage #2", 5, true));
v.Add(new Voltage("Reserved", 6, true));
v.Add(new Voltage("3VSB", 7, 34, 34));
v.Add(new Voltage("VBAT", 8, 34, 34));
v.Add(new Voltage("Voltage #10", 9, true));
t.Add(new Temperature("SYS", 1));
t.Add(new Temperature("CPU Core", 2));
t.Add(new Temperature("AUX", 3));
for (int i = 0; i < superIO.Fans.Length; i++)
f.Add(new Fan("Fan #" + (i + 1), i));
for (int i = 0; i < superIO.Controls.Length; i++)
c.Add(new Ctrl("Fan Control #" + (i + 1), i));
break;
case Chip.NCT6779D:
case Chip.NCT6791D:
GetNuvotonConfigurationD(superIO, manufacturer, model, v, t, f, c);
Expand Down

0 comments on commit 1bf01ea

Please sign in to comment.