Index: sys/dev/amdtemp/amdtemp.c =================================================================== --- sys/dev/amdtemp/amdtemp.c +++ sys/dev/amdtemp/amdtemp.c @@ -132,6 +132,12 @@ */ #define AMDTEMP_CPUID 0xfc +/* + * AMD Family 17h range select mask + */ +#define AMDTEMP_17H_RANGE_SEL (1 << 19) +#define AMDTEMP_17H_OFFSET_VAL 490 + /* * Device methods. */ @@ -591,14 +597,16 @@ amdtemp_gettemp17h(device_t dev, amdsensor_t sensor) { struct amdtemp_softc *sc = device_get_softc(dev); - uint32_t temp; + uint32_t temp, val; int error; - error = amdsmn_read(sc->sc_smn, AMDTEMP_17H_CUR_TMP, &temp); + error = amdsmn_read(sc->sc_smn, AMDTEMP_17H_CUR_TMP, &val); KASSERT(error == 0, ("amdsmn_read")); - temp = ((temp >> 21) & 0x7ff) * 5 / 4; + temp = ((val >> 21) & 0x7ff) * 5 / 4; temp += AMDTEMP_ZERO_C_TO_K + sc->sc_offset * 10; + if (val & AMDTEMP_17H_RANGE_SEL) + temp -= AMDTEMP_17H_OFFSET_VAL; return (temp); }