Skip to content

Commit

Permalink
Support for IT8665E
Browse files Browse the repository at this point in the history
Support for IT8665E. Don't read fans that aren't set in the 16bit register.
  • Loading branch information
azuisleet committed May 19, 2017
1 parent 60c7f89 commit d4b763c
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 9 deletions.
2 changes: 2 additions & 0 deletions Hardware/LPC/Chip.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ internal enum Chip : ushort {

IT8620E = 0x8620,
IT8628E = 0x8628,
IT8665E = 0x8665,
IT8686E = 0x8686,
IT8705F = 0x8705,
IT8712F = 0x8712,
Expand Down Expand Up @@ -75,6 +76,7 @@ public static string GetName(Chip chip) {

case Chip.IT8620E: return "ITE IT8620E";
case Chip.IT8628E: return "ITE IT8628E";
case Chip.IT8665E: return "ITE IT8665E";
case Chip.IT8686E: return "ITE IT8686E";
case Chip.IT8705F: return "ITE IT8705F";
case Chip.IT8712F: return "ITE IT8712F";
Expand Down
52 changes: 43 additions & 9 deletions Hardware/LPC/IT87XX.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ internal class IT87XX : ISuperIO {
private readonly float?[] voltages = new float?[0];
private readonly float?[] temperatures = new float?[0];
private readonly float?[] fans = new float?[0];
private readonly bool[] fansDisabled = new bool[0];
private readonly float?[] controls = new float?[0];

private readonly float voltageGain;
Expand All @@ -45,10 +46,11 @@ internal class IT87XX : ISuperIO {
private const byte TEMPERATURE_BASE_REG = 0x29;
private const byte VENDOR_ID_REGISTER = 0x58;
private const byte FAN_TACHOMETER_DIVISOR_REGISTER = 0x0B;
private const byte FAN_TACHOMETER_16BIT_REGISTER = 0x0C;
private readonly byte[] FAN_TACHOMETER_REG =
{ 0x0d, 0x0e, 0x0f, 0x80, 0x82 };
{ 0x0d, 0x0e, 0x0f, 0x80, 0x82, 0x4c };
private readonly byte[] FAN_TACHOMETER_EXT_REG =
{ 0x18, 0x19, 0x1a, 0x81, 0x83 };
{ 0x18, 0x19, 0x1a, 0x81, 0x83, 0x4d };
private const byte VOLTAGE_BASE_REG = 0x20;
private readonly byte[] FAN_PWM_CTRL_REG = { 0x15, 0x16, 0x17 };

Expand Down Expand Up @@ -133,33 +135,43 @@ public IT87XX(Chip chip, ushort address, ushort gpioAddress, byte version) {
return;

// Bit 0x10 of the configuration register should always be 1
if ((ReadByte(CONFIGURATION_REGISTER, out valid) & 0x10) == 0)
byte config = ReadByte(CONFIGURATION_REGISTER, out valid);
if ((config & 0x10) == 0 && chip != Chip.IT8665E)
return;
if (!valid)
return;

// IT8686E has more sensors
if(chip == Chip.IT8686E)
if (chip == Chip.IT8686E)
{
voltages = new float?[10];
temperatures = new float?[5];
fans = new float?[5];
fansDisabled = new bool[5];
controls = new float?[3];
}
else
{
} else if (chip == Chip.IT8665E) {
voltages = new float?[10];
temperatures = new float?[6];
fans = new float?[6];
fansDisabled = new bool[6];
controls = new float?[3];
} else {
voltages = new float?[9];
temperatures = new float?[3];
fans = new float?[chip == Chip.IT8705F ? 3 : 5];
fansDisabled = new bool[chip == Chip.IT8705F ? 3 : 5];
controls = new float?[3];
}

// IT8620E, IT8628E, IT8721F, IT8728F, IT8772E and IT8686E use a 12mV resultion
// ADC, all others 16mV
if (chip == Chip.IT8620E || chip == Chip.IT8628E || chip == Chip.IT8721F
|| chip == Chip.IT8728F || chip == Chip.IT8771E || chip == Chip.IT8772E || chip == Chip.IT8686E)
if (chip == Chip.IT8620E || chip == Chip.IT8628E || chip == Chip.IT8721F
|| chip == Chip.IT8728F || chip == Chip.IT8771E || chip == Chip.IT8772E
|| chip == Chip.IT8686E)
{
voltageGain = 0.012f;
} else if (chip == Chip.IT8665E) {
voltageGain = 0.0109f;
} else {
voltageGain = 0.016f;
}
Expand All @@ -173,6 +185,25 @@ public IT87XX(Chip chip, ushort address, ushort gpioAddress, byte version) {
has16bitFanCounter = true;
}

// Disable any fans that aren't set with 16-bit fan counters
if (has16bitFanCounter)
{
int modes = ReadByte(FAN_TACHOMETER_16BIT_REGISTER, out valid);

if (!valid)
return;

if (fans.Length >= 5)
{
fansDisabled[3] = (modes & (1 << 4)) == 0;
fansDisabled[4] = (modes & (1 << 5)) == 0;
}
if (fans.Length >= 6)
{
fansDisabled[5] = (modes & (1 << 2)) == 0;
}
}

// Set the number of GPIO sets
switch (chip) {
case Chip.IT8712F:
Expand Down Expand Up @@ -286,6 +317,9 @@ public void Update() {

if (has16bitFanCounter) {
for (int i = 0; i < fans.Length; i++) {
if (fansDisabled[i])
continue;

bool valid;
int value = ReadByte(FAN_TACHOMETER_REG[i], out valid);
if (!valid)
Expand Down
1 change: 1 addition & 0 deletions Hardware/LPC/LPCIO.cs
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ private bool DetectIT87(LPCPort port) {
switch (chipID) {
case 0x8620: chip = Chip.IT8620E; break;
case 0x8628: chip = Chip.IT8628E; break;
case 0x8665: chip = Chip.IT8665E; break;
case 0x8686: chip = Chip.IT8686E; break;
case 0x8705: chip = Chip.IT8705F; break;
case 0x8712: chip = Chip.IT8712F; break;
Expand Down
2 changes: 2 additions & 0 deletions Hardware/Mainboard/Identification.cs
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,8 @@ public static Model GetModel(string name) {
return Model.FH67;
case "AX370-Gaming K7":
return Model.AX370_K7;
case "PRIME X370-PRO":
return Model.PRIME_X370_PRO;
case "Base Board Product Name":
case "To be filled by O.E.M.":
return Model.Unknown;
Expand Down
1 change: 1 addition & 0 deletions Hardware/Mainboard/Model.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ internal enum Model {
P9X79,
Rampage_Extreme,
Rampage_II_GENE,
PRIME_X370_PRO,

// DFI
LP_BI_P45_T2RS_Elite,
Expand Down
21 changes: 21 additions & 0 deletions Hardware/Mainboard/SuperIOHardware.cs
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ private static void GetBoardSpecificConfiguration(ISuperIO superIO,
case Chip.IT8718F:
case Chip.IT8720F:
case Chip.IT8726F:
case Chip.IT8665E:
case Chip.IT8686E:
GetITEConfigurationsA(superIO, manufacturer, model, v, t, f, c,
ref readFan, ref postUpdate, ref mutex);
Expand Down Expand Up @@ -325,6 +326,26 @@ private static void GetITEConfigurationsA(ISuperIO superIO,
f.Add(new Fan("Chassis Fan #1", 1));
f.Add(new Fan("Chassis Fan #2", 2));
break;
case Model.PRIME_X370_PRO: // IT8665E
v.Add(new Voltage("CPU VCore", 0));
v.Add(new Voltage("SB 2.5V", 1));
v.Add(new Voltage("+12V", 2, 5, 1));
v.Add(new Voltage("+5V", 3, 1.5f, 1));
v.Add(new Voltage("Voltage #4", 4, true));
v.Add(new Voltage("Voltage #6", 5, true));
v.Add(new Voltage("Voltage #7", 6, true));
v.Add(new Voltage("+3.3V", 7, 10, 10));
v.Add(new Voltage("VBAT", 8, 10, 10));
v.Add(new Voltage("Voltage #10", 9, true));
t.Add(new Temperature("CPU", 0));
t.Add(new Temperature("Motherboard", 1));
t.Add(new Temperature("PCH", 2));
for (int i = 3; i < superIO.Temperatures.Length; i++)
t.Add(new Temperature("Temperature #" + (i + 1), i));
f.Add(new Fan("CPU Fan", 0));
for (int i = 1; i < superIO.Fans.Length; i++)
f.Add(new Fan("Fan #" + (i + 1), i));
break;
default:
v.Add(new Voltage("CPU VCore", 0));
v.Add(new Voltage("Voltage #2", 1, true));
Expand Down

4 comments on commit d4b763c

@BennehBoy
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work, I was going to attempt this patch myself this evening - no need now!

@BennehBoy
Copy link

@BennehBoy BennehBoy commented on d4b763c Jul 11, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at the it87 source code -> https://github.com/groeck/it87/blob/master/it87.c

It defines alternate registers for the fans etc:

static const u8 IT87_REG_FAN[] =	{ 0x0d, 0x0e, 0x0f, 0x80, 0x82, 0x4c };
static const u8 IT87_REG_FAN_MIN[] =	{ 0x10, 0x11, 0x12, 0x84, 0x86, 0x4e };
static const u8 IT87_REG_FANX[] =	{ 0x18, 0x19, 0x1a, 0x81, 0x83, 0x4d };
static const u8 IT87_REG_FANX_MIN[] =	{ 0x1b, 0x1c, 0x1d, 0x85, 0x87, 0x4f };

static const u8 IT87_REG_FAN_8665[] =	{ 0x0d, 0x0e, 0x0f, 0x80, 0x82, 0x93 };
static const u8 IT87_REG_FAN_MIN_8665[] =
					{ 0x10, 0x11, 0x12, 0x84, 0x86, 0xb2 };
static const u8 IT87_REG_FANX_8665[] =	{ 0x18, 0x19, 0x1a, 0x81, 0x83, 0x94 };
static const u8 IT87_REG_FANX_MIN_8665[] =
					{ 0x1b, 0x1c, 0x1d, 0x85, 0x87, 0xb3 };

static const u8 IT87_REG_TEMP_OFFSET[] = { 0x56, 0x57, 0x59, 0x5a, 0x90, 0x91 };

static const u8 IT87_REG_TEMP_OFFSET_8686[] = { 0x56, 0x57, 0x59, 0x90, 0x91, 0x92 };

static const u8 IT87_REG_PWM[] =	{ 0x15, 0x16, 0x17, 0x7f, 0xa7, 0xaf };
static const u8 IT87_REG_PWM_8665[] =	{ 0x15, 0x16, 0x17, 0x1e, 0x1f, 0x92 };

Should those values be used here?

@azuisleet
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You may be correct that the extended registers should instead be from IT87_REG_FAN_8665 and friends. I didn't actually test the 6th fan slot since the first 5 are the same anyway. voltageGain is also a TODO, as I tried to match it with HWMonitor instead of checking any references.

@BennehBoy
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh right I didn't realise it was literally 6 slots for the 6 fans - makes sense.

I've been comparing the output from the compiled binary with cpuid HWMonitor, Ryzen Master, & CAM - HMMonitor & OHM show a CPU temp 10C higher than Ryzen Master, with CAM showing a further 10C higher (which indicates that CAM is reading the +20C offset temp). It looks as though the offset code in OHM needs some tweaking for Ryzen to bring it in line with Ryzen master.

I'll do some more fiddling tomorrow when I get chance.

Love to get to a point of having fan controls so that PR openhardwaremonitor#996 - fan curve control can be incorporated!

Please sign in to comment.