Integrated the patch for Fintek F71808E super I/O support developed by Andrey Mushatov.
3 This Source Code Form is subject to the terms of the Mozilla Public
4 License, v. 2.0. If a copy of the MPL was not distributed with this
5 file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 Copyright (C) 2009-2011 Michael Möller <mmoeller@openhardwaremonitor.org>
11 using System.Globalization;
14 namespace OpenHardwareMonitor.Hardware.LPC {
15 internal class F718XX : ISuperIO {
17 private readonly ushort address;
18 private readonly Chip chip;
20 private readonly float?[] voltages;
21 private readonly float?[] temperatures;
22 private readonly float?[] fans;
23 private readonly float?[] controls;
26 private const byte ADDRESS_REGISTER_OFFSET = 0x05;
27 private const byte DATA_REGISTER_OFFSET = 0x06;
29 // Hardware Monitor Registers
30 private const byte VOLTAGE_BASE_REG = 0x20;
31 private const byte TEMPERATURE_CONFIG_REG = 0x69;
32 private const byte TEMPERATURE_BASE_REG = 0x70;
33 private readonly byte[] FAN_TACHOMETER_REG =
34 new byte[] { 0xA0, 0xB0, 0xC0, 0xD0 };
36 private byte ReadByte(byte register) {
38 (ushort)(address + ADDRESS_REGISTER_OFFSET), register);
39 return Ring0.ReadIoPort((ushort)(address + DATA_REGISTER_OFFSET));
42 public byte? ReadGPIO(int index) {
46 public void WriteGPIO(int index, byte value) { }
48 public void SetControl(int index, byte? value) { }
50 public F718XX(Chip chip, ushort address) {
51 this.address = address;
54 voltages = new float?[chip == Chip.F71858 ? 3 : 9];
55 temperatures = new float?[chip == Chip.F71808E ? 2 : 3];
56 fans = new float?[chip == Chip.F71882 || chip == Chip.F71858 ? 4 : 3];
57 controls = new float?[0];
60 public Chip Chip { get { return chip; } }
61 public float?[] Voltages { get { return voltages; } }
62 public float?[] Temperatures { get { return temperatures; } }
63 public float?[] Fans { get { return fans; } }
64 public float?[] Controls { get { return controls; } }
66 public string GetReport() {
67 StringBuilder r = new StringBuilder();
69 r.AppendLine("LPC " + this.GetType().Name);
71 r.Append("Base Adress: 0x");
72 r.AppendLine(address.ToString("X4", CultureInfo.InvariantCulture));
75 if (!Ring0.WaitIsaBusMutex(100))
78 r.AppendLine("Hardware Monitor Registers");
80 r.AppendLine(" 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F");
82 for (int i = 0; i <= 0xF; i++) {
84 r.Append((i << 4).ToString("X2", CultureInfo.InvariantCulture));
86 for (int j = 0; j <= 0xF; j++) {
88 r.Append(ReadByte((byte)((i << 4) | j)).ToString("X2",
89 CultureInfo.InvariantCulture));
95 Ring0.ReleaseIsaBusMutex();
100 public void Update() {
101 if (!Ring0.WaitIsaBusMutex(10))
104 for (int i = 0; i < voltages.Length; i++) {
105 if (chip == Chip.F71808E && i == 6) {
106 // 0x26 is reserved on F71808E
109 int value = ReadByte((byte)(VOLTAGE_BASE_REG + i));
110 voltages[i] = 0.008f * value;
114 for (int i = 0; i < temperatures.Length; i++) {
117 int tableMode = 0x3 & ReadByte(TEMPERATURE_CONFIG_REG);
119 ReadByte((byte)(TEMPERATURE_BASE_REG + 2 * i));
121 ReadByte((byte)(TEMPERATURE_BASE_REG + 2 * i + 1));
122 if (high != 0xbb && high != 0xcc) {
125 case 0: bits = 0; break;
126 case 1: bits = 0; break;
127 case 2: bits = (high & 0x80) << 8; break;
128 case 3: bits = (low & 0x01) << 15; break;
131 bits |= (low & 0xe0) >> 1;
132 short value = (short)(bits & 0xfff0);
133 temperatures[i] = value / 128.0f;
135 temperatures[i] = null;
139 sbyte value = (sbyte)ReadByte((byte)(
140 TEMPERATURE_BASE_REG + 2 * (i + 1)));
141 if (value < sbyte.MaxValue && value > 0)
142 temperatures[i] = value;
144 temperatures[i] = null;
149 for (int i = 0; i < fans.Length; i++) {
150 int value = ReadByte(FAN_TACHOMETER_REG[i]) << 8;
151 value |= ReadByte((byte)(FAN_TACHOMETER_REG[i] + 1));
154 fans[i] = (value < 0x0fff) ? 1.5e6f / value : 0;
159 Ring0.ReleaseIsaBusMutex();