1.1 --- a/Hardware/LPC/IT87XX.cs Sat May 29 13:49:20 2010 +0000
1.2 +++ b/Hardware/LPC/IT87XX.cs Thu Jun 03 22:40:18 2010 +0000
1.3 @@ -41,17 +41,17 @@
1.4 using System.Text;
1.5
1.6 namespace OpenHardwareMonitor.Hardware.LPC {
1.7 - public class IT87XX : LPCHardware, IHardware {
1.8 -
1.9 - private bool available = false;
1.10 + public class IT87XX : ISuperIO {
1.11 +
1.12 private ushort address;
1.13 + private Chip chip;
1.14
1.15 private readonly ushort addressReg;
1.16 private readonly ushort dataReg;
1.17
1.18 - private List<Sensor> voltages = new List<Sensor>(9);
1.19 - private List<Sensor> temperatures = new List<Sensor>(3);
1.20 - private Sensor[] fans;
1.21 + private float?[] voltages = new float?[0];
1.22 + private float?[] temperatures = new float?[0];
1.23 + private float?[] fans = new float?[0];
1.24
1.25 // Consts
1.26 private const byte ITE_VENDOR_ID = 0x90;
1.27 @@ -78,10 +78,10 @@
1.28 return value;
1.29 }
1.30
1.31 - public IT87XX(Chip chip, ushort address, Mainboard.Manufacturer
1.32 - mainboardManufacturer, Mainboard.Model mainboardModel) : base (chip) {
1.33 + public IT87XX(Chip chip, ushort address) {
1.34
1.35 this.address = address;
1.36 + this.chip = chip;
1.37 this.addressReg = (ushort)(address + ADDRESS_REGISTER_OFFSET);
1.38 this.dataReg = (ushort)(address + DATA_REGISTER_OFFSET);
1.39
1.40 @@ -97,140 +97,22 @@
1.41 if (!valid)
1.42 return;
1.43
1.44 - string[] temperatureLabels;
1.45 - List<Voltage> voltageConfigs = new List<Voltage>();
1.46 - switch (mainboardManufacturer) {
1.47 - case Mainboard.Manufacturer.DFI:
1.48 - switch (mainboardModel) {
1.49 - case Mainboard.Model.LP_BI_P45_T2RS_Elite:
1.50 - voltageConfigs.Add(new Voltage("CPU VCore", 0));
1.51 - voltageConfigs.Add(new Voltage("FSB VTT", 1));
1.52 - voltageConfigs.Add(new Voltage("+3.3V", 2));
1.53 - voltageConfigs.Add(new Voltage("+5V", 3, 6.8f, 10, 0));
1.54 - voltageConfigs.Add(new Voltage("+12V", 4, 30, 10, 0));
1.55 - voltageConfigs.Add(new Voltage("NB Core", 5));
1.56 - voltageConfigs.Add(new Voltage("VDIMM", 6));
1.57 - voltageConfigs.Add(new Voltage("+5VSB", 7, 6.8f, 10, 0));
1.58 - voltageConfigs.Add(new Voltage("VBat", 8));
1.59 - temperatureLabels = new string[] {
1.60 - "CPU", "System", "Chipset" };
1.61 - break;
1.62 - case Mainboard.Model.LP_DK_P55_T3eH9:
1.63 - voltageConfigs.Add(new Voltage("CPU VCore", 0));
1.64 - voltageConfigs.Add(new Voltage("VTT", 1));
1.65 - voltageConfigs.Add(new Voltage("+3.3V", 2));
1.66 - voltageConfigs.Add(new Voltage("+5V", 3, 6.8f, 10, 0));
1.67 - voltageConfigs.Add(new Voltage("+12V", 4, 30, 10, 0));
1.68 - voltageConfigs.Add(new Voltage("CPU PLL", 5));
1.69 - voltageConfigs.Add(new Voltage("DRAM", 6));
1.70 - voltageConfigs.Add(new Voltage("+5VSB", 7, 6.8f, 10, 0));
1.71 - voltageConfigs.Add(new Voltage("VBat", 8));
1.72 - temperatureLabels = new string[] {
1.73 - "Chipset", "CPU PWM", "CPU" };
1.74 - break;
1.75 - default:
1.76 - voltageConfigs.Add(new Voltage("CPU VCore", 0));
1.77 - voltageConfigs.Add(new Voltage("VTT", 1, true));
1.78 - voltageConfigs.Add(new Voltage("+3.3V", 2, true));
1.79 - voltageConfigs.Add(new Voltage("+5V", 3, 6.8f, 10, 0, true));
1.80 - voltageConfigs.Add(new Voltage("+12V", 4, 30, 10, 0, true));
1.81 - voltageConfigs.Add(new Voltage("Voltage #6", 5, true));
1.82 - voltageConfigs.Add(new Voltage("DRAM", 6, true));
1.83 - voltageConfigs.Add(new Voltage("+5VSB", 7, 6.8f, 10, 0, true));
1.84 - voltageConfigs.Add(new Voltage("VBat", 8));
1.85 - temperatureLabels = new string[] {
1.86 - "Temperature #1", "Temperature #2", "Temperature #3" };
1.87 - break;
1.88 - }
1.89 - break;
1.90 -
1.91 - case Mainboard.Manufacturer.Gigabyte:
1.92 - switch (mainboardModel) {
1.93 - case Mainboard.Model.EP45_DS3R:
1.94 - case Mainboard.Model.P35_DS3:
1.95 - voltageConfigs.Add(new Voltage("CPU VCore", 0));
1.96 - voltageConfigs.Add(new Voltage("DRAM", 1));
1.97 - voltageConfigs.Add(new Voltage("+3.3V", 2));
1.98 - voltageConfigs.Add(new Voltage("+5V", 3, 6.8f, 10, 0));
1.99 - voltageConfigs.Add(new Voltage("+12V", 7, 27, 9.1f, 0));
1.100 - voltageConfigs.Add(new Voltage("VBat", 8));
1.101 - break;
1.102 - case Mainboard.Model.GA_MA785GMT_UD2H:
1.103 - voltageConfigs.Add(new Voltage("CPU VCore", 0));
1.104 - voltageConfigs.Add(new Voltage("DRAM", 1));
1.105 - voltageConfigs.Add(new Voltage("+3.3V", 2));
1.106 - voltageConfigs.Add(new Voltage("+5V", 3, 6.8f, 10, 0));
1.107 - voltageConfigs.Add(new Voltage("+12V", 4, 27, 9.1f, 0));
1.108 - voltageConfigs.Add(new Voltage("VBat", 8));
1.109 - break;
1.110 - default:
1.111 - voltageConfigs.Add(new Voltage("CPU VCore", 0));
1.112 - voltageConfigs.Add(new Voltage("DRAM", 1, true));
1.113 - voltageConfigs.Add(new Voltage("+3.3V", 2, true));
1.114 - voltageConfigs.Add(new Voltage("+5V", 3, 6.8f, 10, 0, true));
1.115 - voltageConfigs.Add(new Voltage("Voltage #5", 4, true));
1.116 - voltageConfigs.Add(new Voltage("Voltage #6", 5, true));
1.117 - voltageConfigs.Add(new Voltage("Voltage #7", 6, true));
1.118 - voltageConfigs.Add(new Voltage("+12V", 7, 27, 9.1f, 0, true));
1.119 - voltageConfigs.Add(new Voltage("VBat", 8));
1.120 - break;
1.121 - }
1.122 - temperatureLabels = new string[] { "System", "CPU" };
1.123 - break;
1.124 -
1.125 - default:
1.126 - voltageConfigs.Add(new Voltage("CPU VCore", 0));
1.127 - voltageConfigs.Add(new Voltage("Voltage #2", 1, true));
1.128 - voltageConfigs.Add(new Voltage("Voltage #3", 2, true));
1.129 - voltageConfigs.Add(new Voltage("Voltage #4", 3, true));
1.130 - voltageConfigs.Add(new Voltage("Voltage #5", 4, true));
1.131 - voltageConfigs.Add(new Voltage("Voltage #6", 5, true));
1.132 - voltageConfigs.Add(new Voltage("Voltage #7", 6, true));
1.133 - voltageConfigs.Add(new Voltage("Voltage #8", 7, true));
1.134 - voltageConfigs.Add(new Voltage("VBat", 8));
1.135 - temperatureLabels = new string[] {
1.136 - "Temperature #1", "Temperature #2", "Temperature #3" };
1.137 - break;
1.138 - }
1.139 -
1.140 - string formula = "Voltage = value + (value - Vf) * Ri / Rf.";
1.141 - foreach (Voltage voltage in voltageConfigs)
1.142 - voltages.Add(new Sensor(voltage.Name, voltage.Index, voltage.Hidden,
1.143 - null, SensorType.Voltage, this, new ParameterDescription[] {
1.144 - new ParameterDescription("Ri [kΩ]", "Input resistance.\n" +
1.145 - formula, voltage.Ri),
1.146 - new ParameterDescription("Rf [kΩ]", "Reference resistance.\n" +
1.147 - formula, voltage.Rf),
1.148 - new ParameterDescription("Vf [V]", "Reference voltage.\n" +
1.149 - formula, voltage.Vf)
1.150 - }));
1.151 -
1.152 - for (int i = 0; i < temperatureLabels.Length; i++)
1.153 - if (temperatureLabels[i] != null) {
1.154 - temperatures.Add(new Sensor(temperatureLabels[i], i, null,
1.155 - SensorType.Temperature, this, new ParameterDescription[] {
1.156 - new ParameterDescription("Offset [°C]", "Temperature offset.", 0)
1.157 - }));
1.158 - }
1.159 -
1.160 - fans = new Sensor[5];
1.161 - for (int i = 0; i < fans.Length; i++)
1.162 - fans[i] = new Sensor("Fan #" + (i + 1), i, SensorType.Fan, this);
1.163 -
1.164 - available = true;
1.165 + voltages = new float?[9];
1.166 + temperatures = new float?[3];
1.167 + fans = new float?[5];
1.168 }
1.169
1.170 - public bool IsAvailable {
1.171 - get { return available; }
1.172 - }
1.173 + public Chip Chip { get { return chip; } }
1.174 + public float?[] Voltages { get { return voltages; } }
1.175 + public float?[] Temperatures { get { return temperatures; } }
1.176 + public float?[] Fans { get { return fans; } }
1.177
1.178 - public override string GetReport() {
1.179 + public string GetReport() {
1.180 StringBuilder r = new StringBuilder();
1.181
1.182 r.AppendLine("LPC " + this.GetType().Name);
1.183 r.AppendLine();
1.184 r.Append("Chip ID: 0x"); r.AppendLine(chip.ToString("X"));
1.185 - r.Append("Chip Name: "); r.AppendLine(name);
1.186 r.Append("Base Address: 0x"); r.AppendLine(address.ToString("X4"));
1.187 r.AppendLine();
1.188 r.AppendLine("Environment Controller Registers");
1.189 @@ -256,79 +138,48 @@
1.190 return r.ToString();
1.191 }
1.192
1.193 - public override void Update() {
1.194 + public void Update() {
1.195
1.196 - foreach (Sensor sensor in voltages) {
1.197 + for (int i = 0; i < voltages.Length; i++) {
1.198 bool valid;
1.199 float value = 0.001f * ((int)ReadByte(
1.200 - (byte)(VOLTAGE_BASE_REG + sensor.Index), out valid) << 4);
1.201 + (byte)(VOLTAGE_BASE_REG + i), out valid) << 4);
1.202 + if (!valid)
1.203 + continue;
1.204 + if (value > 0)
1.205 + voltages[i] = value;
1.206 + else
1.207 + voltages[i] = null;
1.208 + }
1.209 +
1.210 + for (int i = 0; i < temperatures.Length; i++) {
1.211 + bool valid;
1.212 + sbyte value = (sbyte)ReadByte(
1.213 + (byte)(TEMPERATURE_BASE_REG + i), out valid);
1.214 if (!valid)
1.215 continue;
1.216
1.217 - sensor.Value = value + (value - sensor.Parameters[2].Value) *
1.218 - sensor.Parameters[0].Value / sensor.Parameters[1].Value;
1.219 - if (value > 0)
1.220 - ActivateSensor(sensor);
1.221 + if (value < sbyte.MaxValue && value > 0)
1.222 + temperatures[i] = value;
1.223 + else
1.224 + temperatures[i] = null;
1.225 }
1.226
1.227 - foreach (Sensor sensor in temperatures) {
1.228 + for (int i = 0; i < fans.Length; i++) {
1.229 bool valid;
1.230 - sbyte value = (sbyte)ReadByte(
1.231 - (byte)(TEMPERATURE_BASE_REG + sensor.Index), out valid);
1.232 - if (!valid)
1.233 - continue;
1.234 -
1.235 - sensor.Value = value + sensor.Parameters[0].Value;
1.236 - if (value < sbyte.MaxValue && value > 0)
1.237 - ActivateSensor(sensor);
1.238 - }
1.239 -
1.240 - foreach (Sensor sensor in fans) {
1.241 - bool valid;
1.242 - int value = ReadByte(FAN_TACHOMETER_REG[sensor.Index], out valid);
1.243 + int value = ReadByte(FAN_TACHOMETER_REG[i], out valid);
1.244 if (!valid)
1.245 continue;
1.246 - value |= ReadByte(FAN_TACHOMETER_EXT_REG[sensor.Index], out valid) << 8;
1.247 + value |= ReadByte(FAN_TACHOMETER_EXT_REG[i], out valid) << 8;
1.248 if (!valid)
1.249 continue;
1.250
1.251 if (value > 0x3f) {
1.252 - sensor.Value = (value < 0xffff) ? 1.35e6f / ((value) * 2) : 0;
1.253 - if (sensor.Value > 0)
1.254 - ActivateSensor(sensor);
1.255 + fans[i] = (value < 0xffff) ? 1.35e6f / ((value) * 2) : 0;
1.256 } else {
1.257 - sensor.Value = null;
1.258 + fans[i] = null;
1.259 }
1.260 }
1.261 }
1.262 -
1.263 - private class Voltage {
1.264 - public readonly string Name;
1.265 - public readonly int Index;
1.266 - public readonly float Ri;
1.267 - public readonly float Rf;
1.268 - public readonly float Vf;
1.269 - public readonly bool Hidden;
1.270 -
1.271 - public Voltage(string name, int index) :
1.272 - this(name, index, 0, 1, 0, false) { }
1.273 -
1.274 - public Voltage(string name, int index, bool hidden) :
1.275 - this(name, index, 0, 1, 0, hidden) { }
1.276 -
1.277 - public Voltage(string name, int index, float ri, float rf, float vf) :
1.278 - this(name, index, ri, rf, vf, false) { }
1.279 -
1.280 - public Voltage(string name, int index, float ri, float rf, float vf,
1.281 - bool hidden)
1.282 - {
1.283 - this.Name = name;
1.284 - this.Index = index;
1.285 - this.Ri = ri;
1.286 - this.Rf = rf;
1.287 - this.Vf = vf;
1.288 - this.Hidden = hidden;
1.289 - }
1.290 - }
1.291 - }
1.292 + }
1.293 }