Fix GL518SM hardware monitor and add it to AM-BX133
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
*
|
||||
* Copyright 2020 RichardG.
|
||||
*/
|
||||
#include <math.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
@@ -28,10 +29,12 @@
|
||||
#include <86box/hwm.h>
|
||||
|
||||
|
||||
#define CLAMP(a, min, max) (((a)< (min)) ? (min) : (((a) > (max)) ? (max) : (a)))
|
||||
#define GL518SM_RPM_TO_REG(r, d) ((r) ? CLAMP(480000 / (r * d), 1, 255) : 0)
|
||||
#define GL518SM_VOLTAGE_TO_REG(v) (((v) / 19) & 0xff)
|
||||
#define GL518SM_VDD_TO_REG(v) ((((v) * 4) / 95) & 0xff)
|
||||
#define CLAMP(a, min, max) (((a) < (min)) ? (min) : (((a) > (max)) ? (max) : (a)))
|
||||
/* Formulas and factors derived from Linux's gl518sm.c driver. */
|
||||
#define GL518SM_RPMDIV(r, d) (CLAMP((r), 1, 960000) * (d))
|
||||
#define GL518SM_RPM_TO_REG(r, d) ((r) ? CLAMP((480000 + GL518SM_RPMDIV(r, d) / 2) / GL518SM_RPMDIV(r, d), 1, 255) : 0)
|
||||
#define GL518SM_VOLTAGE_TO_REG(v) ((uint8_t) round((v) / 19.0))
|
||||
#define GL518SM_VDD_TO_REG(v) ((uint8_t) (((v) * 4) / 95.0))
|
||||
|
||||
|
||||
typedef struct {
|
||||
@@ -139,20 +142,20 @@ gl518sm_read(gl518sm_t *dev, uint8_t reg)
|
||||
ret |= GL518SM_RPM_TO_REG(dev->values->fans[1], 1 << ((dev->regs[0x0f] >> 4) & 0x3));
|
||||
break;
|
||||
|
||||
case 0x0d: /* VIN3 - AOpen System Monitor requires an approximate voltage offset of 13 at least here */
|
||||
ret = 13 + GL518SM_VOLTAGE_TO_REG(dev->values->voltages[2]);
|
||||
case 0x0d: /* VIN3 */
|
||||
ret = GL518SM_VOLTAGE_TO_REG(dev->values->voltages[2]);
|
||||
break;
|
||||
|
||||
case 0x13: /* VIN2 */
|
||||
ret = 13 + GL518SM_VOLTAGE_TO_REG(dev->values->voltages[1]);
|
||||
ret = GL518SM_VOLTAGE_TO_REG(dev->values->voltages[1]);
|
||||
break;
|
||||
|
||||
case 0x14: /* VIN1 */
|
||||
ret = 13 + GL518SM_VOLTAGE_TO_REG(dev->values->voltages[0]);
|
||||
ret = GL518SM_VOLTAGE_TO_REG(dev->values->voltages[0]);
|
||||
break;
|
||||
|
||||
case 0x15: /* VDD */
|
||||
ret = 13 + GL518SM_VDD_TO_REG(dev->values->voltages[3]);
|
||||
ret = GL518SM_VDD_TO_REG(dev->values->voltages[3]);
|
||||
break;
|
||||
|
||||
default: /* other registers */
|
||||
@@ -245,7 +248,7 @@ gl518sm_reset(gl518sm_t *dev)
|
||||
dev->regs[0x0a] = 0xdac5;
|
||||
dev->regs[0x0b] = 0xdac5;
|
||||
dev->regs[0x0c] = 0xdac5;
|
||||
dev->regs[0x0f] = 0xf8;
|
||||
dev->regs[0x0f] = 0x00;
|
||||
|
||||
gl518sm_remap(dev, dev->i2c_addr | (dev->i2c_enabled ? 0x00 : 0x80));
|
||||
}
|
||||
|
@@ -28,8 +28,8 @@
|
||||
|
||||
|
||||
#define CLAMP(a, min, max) (((a) < (min)) ? (min) : (((a) > (max)) ? (max) : (a)))
|
||||
/* Formulas and factors derived from Linux's via686a.c driver. */
|
||||
#define VT82C686_RPM_TO_REG(r, d) ((r) ? CLAMP(1350000 / (r * d), 1, 255) : 0)
|
||||
/* Temperature/voltage formulas and factors derived from Linux's via686a.c driver. */
|
||||
#define VT82C686_TEMP_TO_REG(t) (-1.160370e-10*(t*t*t*t*t*t) + 3.193693e-08*(t*t*t*t*t) - 1.464447e-06*(t*t*t*t) - 2.525453e-04*(t*t*t) + 1.424593e-02*(t*t) + 2.148941e+00*t + 7.275808e+01)
|
||||
#define VT82C686_VOLTAGE_TO_REG(v, f) CLAMP((((v) * (2.628 / (f))) - 120.5) / 25, 0, 255)
|
||||
|
||||
|
@@ -246,6 +246,10 @@ machine_at_ambx133_init(const machine_t *model)
|
||||
device_add(&keyboard_ps2_ami_pci_device);
|
||||
device_add(&sst_flash_39sf020_device);
|
||||
spd_register(SPD_TYPE_SDRAM, 0x7, 256);
|
||||
device_add(&gl518sm_2d_device); /* fans: CPUFAN1, CPUFAN2; temperature: CPU */
|
||||
hwm_values.fans[1] += 500;
|
||||
hwm_values.temperatures[0] += 4; /* CPU offset */
|
||||
hwm_values.voltages[1] = RESISTOR_DIVIDER(12000, 10, 2); /* different 12V divider in BIOS (10K/2K?) */
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
Reference in New Issue
Block a user