Hardware/LPC/W83627.cs
changeset 34 dc276daadb2c
parent 33 800a36a1ca8e
child 35 2daf59392c88
     1.1 --- a/Hardware/LPC/W83627.cs	Sun Feb 07 20:59:13 2010 +0000
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,155 +0,0 @@
     1.4 -/*
     1.5 -  
     1.6 -  Version: MPL 1.1/GPL 2.0/LGPL 2.1
     1.7 -
     1.8 -  The contents of this file are subject to the Mozilla Public License Version
     1.9 -  1.1 (the "License"); you may not use this file except in compliance with
    1.10 -  the License. You may obtain a copy of the License at
    1.11 - 
    1.12 -  http://www.mozilla.org/MPL/
    1.13 -
    1.14 -  Software distributed under the License is distributed on an "AS IS" basis,
    1.15 -  WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
    1.16 -  for the specific language governing rights and limitations under the License.
    1.17 -
    1.18 -  The Original Code is the Open Hardware Monitor code.
    1.19 -
    1.20 -  The Initial Developer of the Original Code is 
    1.21 -  Michael Möller <m.moeller@gmx.ch>.
    1.22 -  Portions created by the Initial Developer are Copyright (C) 2009-2010
    1.23 -  the Initial Developer. All Rights Reserved.
    1.24 -
    1.25 -  Contributor(s):
    1.26 -
    1.27 -  Alternatively, the contents of this file may be used under the terms of
    1.28 -  either the GNU General Public License Version 2 or later (the "GPL"), or
    1.29 -  the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
    1.30 -  in which case the provisions of the GPL or the LGPL are applicable instead
    1.31 -  of those above. If you wish to allow use of your version of this file only
    1.32 -  under the terms of either the GPL or the LGPL, and not to allow others to
    1.33 -  use your version of this file under the terms of the MPL, indicate your
    1.34 -  decision by deleting the provisions above and replace them with the notice
    1.35 -  and other provisions required by the GPL or the LGPL. If you do not delete
    1.36 -  the provisions above, a recipient may use your version of this file under
    1.37 -  the terms of any one of the MPL, the GPL or the LGPL.
    1.38 - 
    1.39 -*/
    1.40 -
    1.41 -using System;
    1.42 -using System.Collections.Generic;
    1.43 -using System.Drawing;
    1.44 -using System.Text;
    1.45 -
    1.46 -namespace OpenHardwareMonitor.Hardware.LPC {
    1.47 -  public class W83627 : Winbond, IHardware {
    1.48 -   
    1.49 -    private Sensor[] temperatures;
    1.50 -    private Sensor[] fans;
    1.51 -    private Sensor[] voltages;
    1.52 -
    1.53 -    private float[] voltageGains;
    1.54 -    private string[] fanNames;
    1.55 -
    1.56 -    // Hardware Monitor Registers
    1.57 -    private const byte VOLTAGE_BASE_REG = 0x20;   
    1.58 -    private const byte TEMPERATURE_BASE_REG = 0x50;
    1.59 -    private const byte TEMPERATURE_SYS_REG = 0x27;
    1.60 -
    1.61 -    private byte[] FAN_TACHO_REG = new byte[] { 0x28, 0x29, 0x2A, 0x3F, 0x53 };
    1.62 -    private byte[] FAN_TACHO_BANK = new byte[] { 0, 0, 0, 0, 5 };       
    1.63 -    private byte[] FAN_BIT_REG = new byte[] { 0x47, 0x4B, 0x4C, 0x59, 0x5D };
    1.64 -    private byte[] FAN_DIV_BIT0 = new byte[] { 36, 38, 30, 8, 10 };
    1.65 -    private byte[] FAN_DIV_BIT1 = new byte[] { 37, 39, 31, 9, 11 };
    1.66 -    private byte[] FAN_DIV_BIT2 = new byte[] { 5, 6, 7, 23, 15 };
    1.67 -
    1.68 -    public W83627(Chip chip, byte revision, ushort address) 
    1.69 -      : base(chip, revision, address)
    1.70 -    {
    1.71 -     
    1.72 -      temperatures = new Sensor[3];
    1.73 -      temperatures[0] = new Sensor("CPU", 0, SensorType.Temperature, this);
    1.74 -      temperatures[1] = new Sensor("Auxiliary", 1, SensorType.Temperature, this);
    1.75 -      temperatures[2] = new Sensor("System", 2, SensorType.Temperature, this);
    1.76 -
    1.77 -      switch (chip) {
    1.78 -        case Chip.W83627DHG:
    1.79 -        case Chip.W83627DHGP: 
    1.80 -          fanNames = new string[] { "System", "CPU #1", "Auxiliary #1", 
    1.81 -            "CPU #2", "Auxiliary #2" };
    1.82 -          voltageGains = new float[] { 0.008f, 1, 1, 0.016f, 1, 1, 1, 0.016f };
    1.83 -          voltages = new Sensor[3];
    1.84 -          voltages[0] = new Sensor("CPU VCore", 0, SensorType.Voltage, this);
    1.85 -          voltages[1] = new Sensor("+3.3V", 3, SensorType.Voltage, this);
    1.86 -          voltages[2] = new Sensor("Battery", 7, SensorType.Voltage, this);
    1.87 -          break;
    1.88 -        case Chip.W83627HF: 
    1.89 -          fanNames = new string[] { "Fan #1", "Fan #2", "Fan #3" };
    1.90 -          voltageGains = new float[] { 0.016f, 1, 0.016f, 1, 1, 1, 1, 0.016f };
    1.91 -          voltages = new Sensor[3];
    1.92 -          voltages[0] = new Sensor("CPU VCore", 0, SensorType.Voltage, this);
    1.93 -          voltages[1] = new Sensor("+3.3V", 2, SensorType.Voltage, this);
    1.94 -          voltages[2] = new Sensor("Battery", 7, SensorType.Voltage, this);
    1.95 -          break;
    1.96 -        default: fanNames = new string[0];
    1.97 -          break;
    1.98 -      }
    1.99 -      
   1.100 -      fans = new Sensor[fanNames.Length];
   1.101 -      for (int i = 0; i < fanNames.Length; i++)
   1.102 -        fans[i] = new Sensor(fanNames[i], i, SensorType.Fan, this);
   1.103 -    }    
   1.104 -
   1.105 -    public void Update() {
   1.106 -      foreach (Sensor sensor in voltages) {
   1.107 -        if (sensor.Index < 7) {
   1.108 -          int value = ReadByte(0, (byte)(VOLTAGE_BASE_REG + sensor.Index));
   1.109 -          sensor.Value = voltageGains[sensor.Index] * value;
   1.110 -          if (sensor.Value > 0)
   1.111 -            ActivateSensor(sensor);
   1.112 -          else
   1.113 -            DeactivateSensor(sensor);
   1.114 -        } else {
   1.115 -          // Battery voltage
   1.116 -          bool valid = (ReadByte(0, 0x5D) & 0x01) > 0;
   1.117 -          if (valid) {
   1.118 -            sensor.Value = voltageGains[sensor.Index] * 
   1.119 -              ReadByte(5, 0x51);
   1.120 -            ActivateSensor(sensor);
   1.121 -          } else
   1.122 -            DeactivateSensor(sensor);
   1.123 -        }
   1.124 -      }
   1.125 -
   1.126 -      foreach (Sensor sensor in temperatures) {
   1.127 -        int value;
   1.128 -        if (sensor.Index < 2) {
   1.129 -          value = (sbyte)ReadByte((byte)(sensor.Index + 1), TEMPERATURE_BASE_REG);
   1.130 -          value = (value << 1) | ReadByte((byte)(sensor.Index + 1),
   1.131 -            (byte)(TEMPERATURE_BASE_REG + 1)) >> 7;
   1.132 -        } else {
   1.133 -          value = (sbyte)ReadByte(0, TEMPERATURE_SYS_REG) << 1;
   1.134 -        }
   1.135 -        sensor.Value = value / 2.0f;
   1.136 -        if (value < 0xFE)
   1.137 -          ActivateSensor(sensor);
   1.138 -        else
   1.139 -          DeactivateSensor(sensor);
   1.140 -      }
   1.141 -
   1.142 -      long bits = 0;
   1.143 -      for (int i = 0; i < FAN_BIT_REG.Length; i++)
   1.144 -        bits = (bits << 8) | ReadByte(0, FAN_BIT_REG[i]);
   1.145 -      foreach (Sensor sensor in fans) {
   1.146 -        int count = ReadByte(FAN_TACHO_BANK[sensor.Index], 
   1.147 -          FAN_TACHO_REG[sensor.Index]);
   1.148 -        int divisorBits = (int)(
   1.149 -          (((bits >> FAN_DIV_BIT2[sensor.Index]) & 1) << 2) |
   1.150 -          (((bits >> FAN_DIV_BIT1[sensor.Index]) & 1) << 1) |
   1.151 -           ((bits >> FAN_DIV_BIT0[sensor.Index]) & 1));
   1.152 -        int divisor = 1 << divisorBits;
   1.153 -        sensor.Value = (count < 0xff) ? 1.35e6f / (count * divisor) : 0;
   1.154 -        ActivateSensor(sensor);        
   1.155 -      }     
   1.156 -    }
   1.157 -  }
   1.158 -}