Added preliminary support for Nuvoton NCT6686D chip #2 (#897)

This commit is contained in:
PhyxionNL
2022-11-18 17:27:26 +01:00
committed by GitHub
parent 54f4426b2b
commit 1cc688388d
4 changed files with 48 additions and 37 deletions
@@ -62,6 +62,7 @@ internal enum Chip : ushort
NCT6796DR = 0xD42A,
NCT6797D = 0xD451,
NCT6798D = 0xD42B,
NCT6686D = 0xD440,
NCT6687D = 0xD592,
NCT6683D = 0xC732,
NCT6799D = 0xD802,
@@ -130,6 +131,7 @@ internal class ChipName
case Chip.NCT6797D: return "Nuvoton NCT6797D";
case Chip.NCT6798D: return "Nuvoton NCT6798D";
case Chip.NCT6799D: return "Nuvoton NCT6799D";
case Chip.NCT6686D: return "Nuvoton NCT6686D";
case Chip.NCT6687D: return "Nuvoton NCT6687D";
case Chip.NCT6683D: return "Nuvoton NCT6683D";
@@ -107,8 +107,8 @@ internal class LpcIO
logicalDeviceNumber = FINTEK_HARDWARE_MONITOR_LDN;
break;
}
break;
break;
case 0x06:
switch (revision)
{
@@ -117,8 +117,8 @@ internal class LpcIO
logicalDeviceNumber = FINTEK_HARDWARE_MONITOR_LDN;
break;
}
break;
break;
case 0x07:
switch (revision)
{
@@ -127,8 +127,8 @@ internal class LpcIO
logicalDeviceNumber = FINTEK_HARDWARE_MONITOR_LDN;
break;
}
break;
break;
case 0x08:
switch (revision)
{
@@ -137,8 +137,8 @@ internal class LpcIO
logicalDeviceNumber = FINTEK_HARDWARE_MONITOR_LDN;
break;
}
break;
break;
case 0x09:
switch (revision)
{
@@ -151,8 +151,8 @@ internal class LpcIO
logicalDeviceNumber = FINTEK_HARDWARE_MONITOR_LDN;
break;
}
break;
break;
case 0x10:
switch (revision)
{
@@ -165,8 +165,8 @@ internal class LpcIO
logicalDeviceNumber = FINTEK_HARDWARE_MONITOR_LDN;
break;
}
break;
break;
case 0x11:
switch (revision)
{
@@ -179,8 +179,8 @@ internal class LpcIO
logicalDeviceNumber = FINTEK_HARDWARE_MONITOR_LDN;
break;
}
break;
break;
case 0x52:
switch (revision)
{
@@ -191,8 +191,8 @@ internal class LpcIO
logicalDeviceNumber = WINBOND_NUVOTON_HARDWARE_MONITOR_LDN;
break;
}
break;
break;
case 0x82:
switch (revision & 0xF0)
{
@@ -201,8 +201,8 @@ internal class LpcIO
logicalDeviceNumber = WINBOND_NUVOTON_HARDWARE_MONITOR_LDN;
break;
}
break;
break;
case 0x85:
switch (revision)
{
@@ -211,8 +211,8 @@ internal class LpcIO
logicalDeviceNumber = WINBOND_NUVOTON_HARDWARE_MONITOR_LDN;
break;
}
break;
break;
case 0x88:
switch (revision & 0xF0)
{
@@ -222,8 +222,8 @@ internal class LpcIO
logicalDeviceNumber = WINBOND_NUVOTON_HARDWARE_MONITOR_LDN;
break;
}
break;
break;
case 0xA0:
switch (revision & 0xF0)
{
@@ -232,8 +232,8 @@ internal class LpcIO
logicalDeviceNumber = WINBOND_NUVOTON_HARDWARE_MONITOR_LDN;
break;
}
break;
break;
case 0xA5:
switch (revision & 0xF0)
{
@@ -242,8 +242,8 @@ internal class LpcIO
logicalDeviceNumber = WINBOND_NUVOTON_HARDWARE_MONITOR_LDN;
break;
}
break;
break;
case 0xB0:
switch (revision & 0xF0)
{
@@ -252,8 +252,8 @@ internal class LpcIO
logicalDeviceNumber = WINBOND_NUVOTON_HARDWARE_MONITOR_LDN;
break;
}
break;
break;
case 0xB3:
switch (revision & 0xF0)
{
@@ -262,8 +262,8 @@ internal class LpcIO
logicalDeviceNumber = WINBOND_NUVOTON_HARDWARE_MONITOR_LDN;
break;
}
break;
break;
case 0xB4:
switch (revision & 0xF0)
{
@@ -272,8 +272,8 @@ internal class LpcIO
logicalDeviceNumber = WINBOND_NUVOTON_HARDWARE_MONITOR_LDN;
break;
}
break;
break;
case 0xC3:
switch (revision & 0xF0)
{
@@ -282,8 +282,8 @@ internal class LpcIO
logicalDeviceNumber = WINBOND_NUVOTON_HARDWARE_MONITOR_LDN;
break;
}
break;
break;
case 0xC4:
switch (revision & 0xF0)
{
@@ -292,8 +292,8 @@ internal class LpcIO
logicalDeviceNumber = WINBOND_NUVOTON_HARDWARE_MONITOR_LDN;
break;
}
break;
break;
case 0xC5:
switch (revision & 0xF0)
{
@@ -302,8 +302,8 @@ internal class LpcIO
logicalDeviceNumber = WINBOND_NUVOTON_HARDWARE_MONITOR_LDN;
break;
}
break;
break;
case 0xC7:
switch (revision)
{
@@ -312,8 +312,8 @@ internal class LpcIO
logicalDeviceNumber = WINBOND_NUVOTON_HARDWARE_MONITOR_LDN;
break;
}
break;
break;
case 0xC8:
switch (revision)
{
@@ -322,8 +322,8 @@ internal class LpcIO
logicalDeviceNumber = WINBOND_NUVOTON_HARDWARE_MONITOR_LDN;
break;
}
break;
break;
case 0xC9:
switch (revision)
{
@@ -336,8 +336,8 @@ internal class LpcIO
logicalDeviceNumber = WINBOND_NUVOTON_HARDWARE_MONITOR_LDN;
break;
}
break;
break;
case 0xD1:
switch (revision)
{
@@ -346,8 +346,8 @@ internal class LpcIO
logicalDeviceNumber = WINBOND_NUVOTON_HARDWARE_MONITOR_LDN;
break;
}
break;
break;
case 0xD3:
switch (revision)
{
@@ -356,8 +356,8 @@ internal class LpcIO
logicalDeviceNumber = WINBOND_NUVOTON_HARDWARE_MONITOR_LDN;
break;
}
break;
break;
case 0xD4:
switch (revision)
{
@@ -377,9 +377,13 @@ internal class LpcIO
chip = Chip.NCT6798D;
logicalDeviceNumber = WINBOND_NUVOTON_HARDWARE_MONITOR_LDN;
break;
case 0x40:
chip = Chip.NCT6686D;
logicalDeviceNumber = WINBOND_NUVOTON_HARDWARE_MONITOR_LDN;
break;
}
break;
break;
case 0xD5:
switch (revision)
{
@@ -388,8 +392,8 @@ internal class LpcIO
logicalDeviceNumber = WINBOND_NUVOTON_HARDWARE_MONITOR_LDN;
break;
}
break;
break;
case 0xD8:
switch (revision)
{
@@ -398,6 +402,7 @@ internal class LpcIO
logicalDeviceNumber = WINBOND_NUVOTON_HARDWARE_MONITOR_LDN;
break;
}
break;
}
@@ -483,6 +488,7 @@ internal class LpcIO
case Chip.NCT6797D:
case Chip.NCT6798D:
case Chip.NCT6799D:
case Chip.NCT6686D:
case Chip.NCT6687D:
case Chip.NCT6683D:
_superIOs.Add(new Nct677X(chip, revision, address, port));
@@ -69,7 +69,7 @@ internal class Nct677X : ISuperIO
_vBatMonitorControlRegister = 0x0318;
}
else if (chip is Chip.NCT6687D or Chip.NCT6683D)
else if (chip is Chip.NCT6683D or Chip.NCT6686D or Chip.NCT6687D)
{
FAN_PWM_OUT_REG = new ushort[] { 0x160, 0x161, 0x162, 0x163, 0x164, 0x165, 0x166, 0x167 };
FAN_PWM_COMMAND_REG = new ushort[] { 0xA28, 0xA29, 0xA2A, 0xA2B, 0xA2C, 0xA2D, 0xA2E, 0xA2F };
@@ -263,6 +263,7 @@ internal class Nct677X : ISuperIO
break;
case Chip.NCT6683D:
case Chip.NCT6686D:
case Chip.NCT6687D:
Fans = new float?[8];
Controls = new float?[8];
@@ -367,7 +368,7 @@ internal class Nct677X : ISuperIO
{
SaveDefaultFanControl(index);
if (Chip is not Chip.NCT6687D and not Chip.NCT6683D)
if (Chip is not Chip.NCT6683D and not Chip.NCT6686D and not Chip.NCT6687D)
{
// set manual mode
WriteByte(FAN_CONTROL_MODE_REG[index], 0);
@@ -420,7 +421,7 @@ internal class Nct677X : ISuperIO
for (int i = 0; i < Voltages.Length; i++)
{
if (Chip != Chip.NCT6687D)
if (Chip is not Chip.NCT6683D and not Chip.NCT6686D and not Chip.NCT6687D)
{
float value = 0.008f * ReadByte(_voltageRegisters[i]);
bool valid = value > 0;
@@ -460,6 +461,7 @@ internal class Nct677X : ISuperIO
switch (Chip)
{
case Chip.NCT6687D:
case Chip.NCT6686D:
case Chip.NCT6683D:
value = (sbyte)ReadByte(ts.Register);
int half = (ReadByte((ushort)(ts.Register + 1)) >> 7) & 0x1;
@@ -578,7 +580,7 @@ internal class Nct677X : ISuperIO
for (int i = 0; i < Fans.Length; i++)
{
if (Chip is not Chip.NCT6687D and not Chip.NCT6683D)
if (Chip is not Chip.NCT6683D and not Chip.NCT6686D and not Chip.NCT6687D)
{
if (_fanCountRegister != null)
{
@@ -619,7 +621,7 @@ internal class Nct677X : ISuperIO
for (int i = 0; i < Controls.Length; i++)
{
if (Chip is not Chip.NCT6687D and not Chip.NCT6683D)
if (Chip is not Chip.NCT6683D and not Chip.NCT6686D and not Chip.NCT6687D)
{
int value = ReadByte(FAN_PWM_OUT_REG[i]);
Controls[i] = value / 2.55f;
@@ -760,7 +762,7 @@ internal class Nct677X : ISuperIO
r.AppendLine(" 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F");
r.AppendLine();
if (Chip is not Chip.NCT6687D and not Chip.NCT6683D)
if (Chip is not Chip.NCT6683D and not Chip.NCT6686D and not Chip.NCT6687D)
{
foreach (ushort address in addresses)
{
@@ -803,7 +805,7 @@ internal class Nct677X : ISuperIO
private byte ReadByte(ushort address)
{
if (Chip is not Chip.NCT6687D and not Chip.NCT6683D)
if (Chip is not Chip.NCT6683D and not Chip.NCT6686D and not Chip.NCT6687D)
{
byte bank = (byte)(address >> 8);
byte register = (byte)(address & 0xFF);
@@ -823,7 +825,7 @@ internal class Nct677X : ISuperIO
private void WriteByte(ushort address, byte value)
{
if (Chip is not Chip.NCT6687D and not Chip.NCT6683D)
if (Chip is not Chip.NCT6683D and not Chip.NCT6686D and not Chip.NCT6687D)
{
byte bank = (byte)(address >> 8);
byte register = (byte)(address & 0xFF);
@@ -845,14 +847,14 @@ internal class Nct677X : ISuperIO
private bool IsNuvotonVendor()
{
return Chip == Chip.NCT6687D || Chip == Chip.NCT6683D || ((ReadByte(VENDOR_ID_HIGH_REGISTER) << 8) | ReadByte(VENDOR_ID_LOW_REGISTER)) == NUVOTON_VENDOR_ID;
return Chip is Chip.NCT6683D or Chip.NCT6686D or Chip.NCT6687D || ((ReadByte(VENDOR_ID_HIGH_REGISTER) << 8) | ReadByte(VENDOR_ID_LOW_REGISTER)) == NUVOTON_VENDOR_ID;
}
private void SaveDefaultFanControl(int index)
{
if (!_restoreDefaultFanControlRequired[index])
{
if (Chip is not Chip.NCT6687D and not Chip.NCT6683D)
if (Chip is not Chip.NCT6683D and not Chip.NCT6686D and not Chip.NCT6687D)
{
_initialFanControlMode[index] = ReadByte(FAN_CONTROL_MODE_REG[index]);
}
@@ -872,7 +874,7 @@ internal class Nct677X : ISuperIO
{
if (_restoreDefaultFanControlRequired[index])
{
if (Chip is not Chip.NCT6687D and not Chip.NCT6683D)
if (Chip is not Chip.NCT6683D and not Chip.NCT6686D and not Chip.NCT6687D)
{
WriteByte(FAN_CONTROL_MODE_REG[index], _initialFanControlMode[index]);
WriteByte(FAN_PWM_COMMAND_REG[index], _initialFanPwmCommand[index]);
@@ -353,6 +353,7 @@ internal sealed class SuperIOHardware : Hardware
GetNuvotonConfigurationD(superIO, manufacturer, model, v, t, f, c);
break;
case Chip.NCT6686D:
case Chip.NCT6687D:
v.Add(new Voltage("+12V", 0));
v.Add(new Voltage("+5V", 1));