@@ -66,6 +66,10 @@ private void WriteByte(ushort address, byte value) {
6666 private readonly ushort [ ] fanRpmBaseRegister ;
6767 private readonly int minFanRPM ;
6868
69+ private readonly ushort [ ] fanCountRegister ;
70+ private readonly int maxFanCount ;
71+ private readonly int minFanCount ;
72+
6973 private bool [ ] restoreDefaultFanControlRequired = new bool [ 7 ] ;
7074 private byte [ ] initialFanControlMode = new byte [ 7 ] ;
7175 private byte [ ] initialFanPwmCommand = new byte [ 7 ] ;
@@ -303,11 +307,14 @@ public NCT677X(Chip chip, byte revision, ushort port, LPCPort lpcPort)
303307 break ;
304308 }
305309
306- fanRpmBaseRegister = new ushort [ ]
307- { 0x4C0 , 0x4C2 , 0x4C4 , 0x4C6 , 0x4C8 , 0x4CA , 0x4CE } ;
310+ fanCountRegister = new ushort [ ]
311+ { 0x4B0 , 0x4B2 , 0x4B4 , 0x4B6 , 0x4B8 , 0x4BA , 0x4CC } ;
308312
309- // min RPM value with 13-bit fan counter
310- minFanRPM = ( int ) ( 1.35e6 / 0x1FFF ) ;
313+ // max value for 13-bit fan counter
314+ maxFanCount = 0x1FFF ;
315+
316+ // min value that could be transfered to 16-bit RPM registers
317+ minFanCount = 0x15 ;
311318
312319 voltages = new float ? [ 15 ] ;
313320 voltageRegisters = new ushort [ ]
@@ -514,11 +521,26 @@ public void Update() {
514521 }
515522
516523 for ( int i = 0 ; i < fans . Length ; i ++ ) {
517- byte high = ReadByte ( fanRpmBaseRegister [ i ] ) ;
518- byte low = ReadByte ( ( ushort ) ( fanRpmBaseRegister [ i ] + 1 ) ) ;
519- int value = ( high << 8 ) | low ;
524+ if ( fanCountRegister != null ) {
525+ byte high = ReadByte ( fanCountRegister [ i ] ) ;
526+ byte low = ReadByte ( ( ushort ) ( fanCountRegister [ i ] + 1 ) ) ;
527+ int count = ( high << 5 ) | ( low & 0x1F ) ;
528+ if ( count < maxFanCount ) {
529+ if ( count >= minFanCount ) {
530+ fans [ i ] = 1.35e6f / count ;
531+ } else {
532+ fans [ i ] = null ;
533+ }
534+ } else {
535+ fans [ i ] = 0 ;
536+ }
537+ } else {
538+ byte high = ReadByte ( fanRpmBaseRegister [ i ] ) ;
539+ byte low = ReadByte ( ( ushort ) ( fanRpmBaseRegister [ i ] + 1 ) ) ;
540+ int value = ( high << 8 ) | low ;
520541
521- fans [ i ] = value > minFanRPM ? value : 0 ;
542+ fans [ i ] = value > minFanRPM ? value : 0 ;
543+ }
522544 }
523545
524546 for ( int i = 0 ; i < controls . Length ; i ++ ) {
0 commit comments