amdtemp(4): Add support for Family 17h temperature sensor
The sensor value is formatted similarly to previous models (same bitfield sizes, same units), but must be read off of the internal System Management Network (SMN) from the System Management Unit (SMU) co-processor. PR: 218264 Reported and tested by: Nils Beyer <nbe AT renzel.net> Reviewed by: avg (no +1), mjoras, truckman Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D12217
This commit is contained in:
parent
907f50fe04
commit
a03d621bfa
@ -25,7 +25,7 @@
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd August 31, 2017
|
||||
.Dd September 5, 2017
|
||||
.Dt AMDTEMP 4
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -53,7 +53,7 @@ The
|
||||
driver provides support for the on-die digital thermal sensor present
|
||||
in
|
||||
.Tn AMD
|
||||
Family 0Fh, 10h, 11h, 12h, 14h, 15h, and 16h processors.
|
||||
Family 0Fh, 10h, 11h, 12h, 14h, 15h, 16h, and 17h processors.
|
||||
.Pp
|
||||
For Family 0Fh processors, the
|
||||
.Nm
|
||||
@ -64,8 +64,8 @@ The driver also creates
|
||||
in the corresponding CPU device's sysctl tree, displaying the maximum
|
||||
temperature of the two sensors located in each CPU core.
|
||||
.Pp
|
||||
For Family 10h, 11h, 12h, 14h, 15h, and 16h processors, the driver reports each
|
||||
package's temperature through a sysctl node, named
|
||||
For Family 10h, 11h, 12h, 14h, 15h, 16h, and 17h processors, the driver reports
|
||||
each package's temperature through a sysctl node, named
|
||||
.Va dev.amdtemp.%d.core0.sensor0 .
|
||||
The driver also creates
|
||||
.Va dev.cpu.%d.temperature
|
||||
|
@ -198,7 +198,7 @@ dev/agp/agp_amd64.c optional agp
|
||||
dev/agp/agp_i810.c optional agp
|
||||
dev/agp/agp_via.c optional agp
|
||||
dev/amdsbwd/amdsbwd.c optional amdsbwd
|
||||
dev/amdsmn/amdsmn.c optional amdsmn
|
||||
dev/amdsmn/amdsmn.c optional amdsmn | amdtemp
|
||||
dev/amdtemp/amdtemp.c optional amdtemp
|
||||
dev/arcmsr/arcmsr.c optional arcmsr pci
|
||||
dev/asmc/asmc.c optional asmc isa
|
||||
|
@ -152,7 +152,7 @@ dev/agp/agp_sis.c optional agp
|
||||
dev/agp/agp_via.c optional agp
|
||||
dev/aic/aic_isa.c optional aic isa
|
||||
dev/amdsbwd/amdsbwd.c optional amdsbwd
|
||||
dev/amdsmn/amdsmn.c optional amdsmn
|
||||
dev/amdsmn/amdsmn.c optional amdsmn | amdtemp
|
||||
dev/amdtemp/amdtemp.c optional amdtemp
|
||||
dev/arcmsr/arcmsr.c optional arcmsr pci
|
||||
dev/asmc/asmc.c optional asmc isa
|
||||
|
@ -49,6 +49,8 @@ __FBSDID("$FreeBSD$");
|
||||
#include <dev/pci/pcivar.h>
|
||||
#include <x86/pci_cfgreg.h>
|
||||
|
||||
#include <dev/amdsmn/amdsmn.h>
|
||||
|
||||
typedef enum {
|
||||
CORE0_SENSOR0,
|
||||
CORE0_SENSOR1,
|
||||
@ -59,7 +61,6 @@ typedef enum {
|
||||
} amdsensor_t;
|
||||
|
||||
struct amdtemp_softc {
|
||||
device_t sc_dev;
|
||||
int sc_ncores;
|
||||
int sc_ntemps;
|
||||
int sc_flags;
|
||||
@ -70,6 +71,7 @@ struct amdtemp_softc {
|
||||
int32_t (*sc_gettemp)(device_t, amdsensor_t);
|
||||
struct sysctl_oid *sc_sysctl_cpu[MAXCPU];
|
||||
struct intr_config_hook sc_ich;
|
||||
device_t sc_smn;
|
||||
};
|
||||
|
||||
#define VENDORID_AMD 0x1022
|
||||
@ -82,6 +84,7 @@ struct amdtemp_softc {
|
||||
#define DEVICEID_AMD_MISC16 0x1533
|
||||
#define DEVICEID_AMD_MISC16_M30H 0x1583
|
||||
#define DEVICEID_AMD_MISC17 0x141d
|
||||
#define DEVICEID_AMD_HOSTB17H 0x1450
|
||||
|
||||
static struct amdtemp_product {
|
||||
uint16_t amdtemp_vendorid;
|
||||
@ -96,6 +99,7 @@ static struct amdtemp_product {
|
||||
{ VENDORID_AMD, DEVICEID_AMD_MISC16 },
|
||||
{ VENDORID_AMD, DEVICEID_AMD_MISC16_M30H },
|
||||
{ VENDORID_AMD, DEVICEID_AMD_MISC17 },
|
||||
{ VENDORID_AMD, DEVICEID_AMD_HOSTB17H },
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
@ -104,6 +108,11 @@ static struct amdtemp_product {
|
||||
*/
|
||||
#define AMDTEMP_REPTMP_CTRL 0xa4
|
||||
|
||||
/*
|
||||
* Reported Temperature, Family 17h
|
||||
*/
|
||||
#define AMDTEMP_17H_CUR_TMP 0x59800
|
||||
|
||||
/*
|
||||
* Thermaltrip Status Register (Family 0Fh only)
|
||||
*/
|
||||
@ -133,6 +142,7 @@ static int amdtemp_detach(device_t dev);
|
||||
static int amdtemp_match(device_t dev);
|
||||
static int32_t amdtemp_gettemp0f(device_t dev, amdsensor_t sensor);
|
||||
static int32_t amdtemp_gettemp(device_t dev, amdsensor_t sensor);
|
||||
static int32_t amdtemp_gettemp17h(device_t dev, amdsensor_t sensor);
|
||||
static int amdtemp_sysctl(SYSCTL_HANDLER_ARGS);
|
||||
|
||||
static device_method_t amdtemp_methods[] = {
|
||||
@ -153,6 +163,8 @@ static driver_t amdtemp_driver = {
|
||||
|
||||
static devclass_t amdtemp_devclass;
|
||||
DRIVER_MODULE(amdtemp, hostb, amdtemp_driver, amdtemp_devclass, NULL, NULL);
|
||||
MODULE_VERSION(amdtemp, 1);
|
||||
MODULE_DEPEND(amdtemp, amdsmn, 1, 1, 1);
|
||||
|
||||
static int
|
||||
amdtemp_match(device_t dev)
|
||||
@ -211,6 +223,7 @@ amdtemp_probe(device_t dev)
|
||||
case 0x14:
|
||||
case 0x15:
|
||||
case 0x16:
|
||||
case 0x17:
|
||||
break;
|
||||
default:
|
||||
return (ENXIO);
|
||||
@ -240,7 +253,7 @@ amdtemp_attach(device_t dev)
|
||||
cpuid = cpu_id;
|
||||
family = CPUID_TO_FAMILY(cpuid);
|
||||
model = CPUID_TO_MODEL(cpuid);
|
||||
if (family != 0x0f || model >= 0x40) {
|
||||
if ((family != 0x0f || model >= 0x40) && family != 0x17) {
|
||||
cpuid = pci_read_config(dev, AMDTEMP_CPUID, 4);
|
||||
family = CPUID_TO_FAMILY(cpuid);
|
||||
model = CPUID_TO_MODEL(cpuid);
|
||||
@ -342,6 +355,17 @@ amdtemp_attach(device_t dev)
|
||||
|
||||
sc->sc_gettemp = amdtemp_gettemp;
|
||||
break;
|
||||
case 0x17:
|
||||
sc->sc_ntemps = 1;
|
||||
sc->sc_gettemp = amdtemp_gettemp17h;
|
||||
sc->sc_smn = device_find_child(
|
||||
device_get_parent(dev), "amdsmn", -1);
|
||||
if (sc->sc_smn == NULL) {
|
||||
if (bootverbose)
|
||||
device_printf(dev, "No SMN device found\n");
|
||||
return (ENXIO);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
/* Find number of cores per package. */
|
||||
@ -557,3 +581,19 @@ amdtemp_gettemp(device_t dev, amdsensor_t sensor)
|
||||
|
||||
return (temp);
|
||||
}
|
||||
|
||||
static int32_t
|
||||
amdtemp_gettemp17h(device_t dev, amdsensor_t sensor)
|
||||
{
|
||||
struct amdtemp_softc *sc = device_get_softc(dev);
|
||||
uint32_t temp;
|
||||
int error;
|
||||
|
||||
error = amdsmn_read(sc->sc_smn, AMDTEMP_17H_CUR_TMP, &temp);
|
||||
KASSERT(error == 0, ("amdsmn_read"));
|
||||
|
||||
temp = ((temp >> 21) & 0x7ff) * 5 / 4;
|
||||
temp += AMDTEMP_ZERO_C_TO_K + sc->sc_offset * 10;
|
||||
|
||||
return (temp);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user