From 1891e110c1df5116ed13bbe6c0e93cc2222686ce Mon Sep 17 00:00:00 2001 From: RichardG867 Date: Mon, 23 Oct 2023 19:33:24 -0300 Subject: [PATCH] Genesys Logic hardware monitor fixes --- src/device/hwm_gl518sm.c | 12 ++++++------ src/machine/m_at_socket370.c | 6 ++++-- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/device/hwm_gl518sm.c b/src/device/hwm_gl518sm.c index 855c61762..6ba1083d9 100644 --- a/src/device/hwm_gl518sm.c +++ b/src/device/hwm_gl518sm.c @@ -31,8 +31,8 @@ #define CLAMP(a, min, max) (((a) < (min)) ? (min) : (((a) > (max)) ? (max) : (a))) -/* Formulas and factors derived from Linux's gl518sm.c driver. */ -#define GL518SM_RPM_TO_REG(r, d) ((r) ? CLAMP((480000 + (r) * (d) / 2) / (r) * (d), 1, 255) : 0) +/* Formulas and factors derived from Linux's gl518sm.c and gl520sm.c drivers. */ +#define GL518SM_RPM_TO_REG(r, d) ((r) ? (480000 / (CLAMP((r), (480000 >> (d)) / 255, (480000 >> (d))) << (d))) : 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)) @@ -134,8 +134,8 @@ gl518sm_read(gl518sm_t *dev, uint8_t reg) break; case 0x07: /* fan speeds */ - ret = GL518SM_RPM_TO_REG(dev->values->fans[0], 1 << ((dev->regs[0x0f] >> 6) & 0x3)) << 8; - ret |= GL518SM_RPM_TO_REG(dev->values->fans[1], 1 << ((dev->regs[0x0f] >> 4) & 0x3)); + ret = GL518SM_RPM_TO_REG(dev->values->fans[0], (dev->regs[0x0f] >> 6) & 0x3) << 8; + ret |= GL518SM_RPM_TO_REG(dev->values->fans[1], (dev->regs[0x0f] >> 4) & 0x3); break; case 0x0d: /* VIN3 */ @@ -256,9 +256,9 @@ gl518sm_reset(gl518sm_t *dev) } else { dev->regs[0x00] = 0x80; dev->regs[0x01] = 0x80; /* revision 0x80 can read all voltages */ + dev->regs[0x05] = 0xc7; + dev->regs[0x06] = 0xc2; } - dev->regs[0x05] = 0xc7; - dev->regs[0x06] = 0xc2; dev->regs[0x08] = 0x6464; dev->regs[0x09] = 0xdac5; dev->regs[0x0a] = 0xdac5; diff --git a/src/machine/m_at_socket370.c b/src/machine/m_at_socket370.c index 4e2284f80..2b2615422 100644 --- a/src/machine/m_at_socket370.c +++ b/src/machine/m_at_socket370.c @@ -275,8 +275,10 @@ machine_at_m773_init(const machine_t *model) device_add(&it8671f_device); device_add(&sst_flash_39sf020_device); spd_register(SPD_TYPE_SDRAM, 0x3, 256); - device_add(&gl520sm_2d_device); /* fans: CPU, Chassis; temperature: System */ - hwm_values.voltages[0] = 3300; /* Vcore and 3.3V are swapped */ + device_add(&gl520sm_2d_device); /* fans: CPU, Chassis; temperature: System */ + hwm_values.temperatures[0] += 2; /* System offset */ + hwm_values.temperatures[1] += 2; /* CPU offset */ + hwm_values.voltages[0] = 3300; /* Vcore and 3.3V are swapped */ hwm_values.voltages[2] = hwm_get_vcore(); if (sound_card_current[0] == SOUND_INTERNAL)