Skip to content

Commit

Permalink
amdtemp: add support for AMD Family 1Ah Models 40h-4Fh
Browse files Browse the repository at this point in the history
Tested with 9900X CPU.
  • Loading branch information
yuripv committed Dec 28, 2024
1 parent 3e8f4a3 commit e7b3541
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 31 deletions.
10 changes: 3 additions & 7 deletions share/man/man4/amdsmn.4
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,12 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.Dd September 5, 2017
.Dd December 27, 2024
.Dt AMDSMN 4
.Os
.Sh NAME
.Nm amdsmn
.Nd device driver for
.Tn AMD
processor System Management Network
.Nd device driver for AMD processor System Management Network
.Sh SYNOPSIS
To compile this driver into the kernel, place the following line in your
kernel configuration file:
Expand All @@ -48,9 +46,7 @@ amdsmn_load="YES"
The
.Nm
driver provides support for resources on the System Management Network bus
in
.Tn AMD
Family 17h processors.
in AMD Family 17h, 19h, and 1Ah processors.
.Sh SEE ALSO
.Xr loader 8
.Sh HISTORY
Expand Down
14 changes: 5 additions & 9 deletions share/man/man4/amdtemp.4
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,12 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.Dd September 5, 2017
.Dd December 27, 2024
.Dt AMDTEMP 4
.Os
.Sh NAME
.Nm amdtemp
.Nd device driver for
.Tn AMD
processor on-die digital thermal sensor
.Nd device driver for AMD processor on-die digital thermal sensor
.Sh SYNOPSIS
To compile this driver into the kernel,
place the following line in your
Expand All @@ -49,9 +47,7 @@ amdtemp_load="YES"
The
.Nm
driver provides support for the on-die digital thermal sensor present
in
.Tn AMD
Family 0Fh, 10h, 11h, 12h, 14h, 15h, 16h, and 17h processors.
in AMD Family 0Fh, 10h, 11h, 12h, 14h, 15h, 16h, 17h, 19h, and 1Ah processors.
.Pp
For Family 0Fh processors, the
.Nm
Expand All @@ -62,8 +58,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, 16h, and 17h processors, the driver reports
each package's temperature through a sysctl node, named
For Family 10h, 11h, 12h, 14h, 15h, 16h, 17h, 19h, and 1Ah 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
Expand Down
24 changes: 13 additions & 11 deletions sys/dev/amdsmn/amdsmn.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
*/

/*
* Driver for the AMD Family 15h and 17h CPU System Management Network.
* Driver for the AMD Family 15h, 17h, 19h, and 1Ah CPU System Management
* Network.
*/

#include <sys/param.h>
Expand Down Expand Up @@ -53,15 +54,15 @@
#define F17H_SMN_ADDR_REG 0x60
#define F17H_SMN_DATA_REG 0x64

#define PCI_DEVICE_ID_AMD_15H_M60H_ROOT 0x1576
#define PCI_DEVICE_ID_AMD_17H_ROOT 0x1450
#define PCI_DEVICE_ID_AMD_17H_M10H_ROOT 0x15d0
#define PCI_DEVICE_ID_AMD_17H_M30H_ROOT 0x1480 /* Also M70H, F19H M00H/M20H */
#define PCI_DEVICE_ID_AMD_17H_M60H_ROOT 0x1630
#define PCI_DEVICE_ID_AMD_19H_M10H_ROOT 0x14a4
#define PCI_DEVICE_ID_AMD_19H_M40H_ROOT 0x14b5
#define PCI_DEVICE_ID_AMD_19H_M60H_ROOT 0x14d8
#define PCI_DEVICE_ID_AMD_19H_M70H_ROOT 0x14e8
#define PCI_DEVICE_ID_AMD_15H_M60H_ROOT 0x1576
#define PCI_DEVICE_ID_AMD_17H_ROOT 0x1450
#define PCI_DEVICE_ID_AMD_17H_M10H_ROOT 0x15d0
#define PCI_DEVICE_ID_AMD_17H_M30H_ROOT 0x1480 /* Also M70H, F19H M00H/M20H */
#define PCI_DEVICE_ID_AMD_17H_M60H_ROOT 0x1630
#define PCI_DEVICE_ID_AMD_19H_M10H_ROOT 0x14a4
#define PCI_DEVICE_ID_AMD_19H_M40H_ROOT 0x14b5
#define PCI_DEVICE_ID_AMD_19H_M60H_ROOT 0x14d8 /* Also 1AH M40H */
#define PCI_DEVICE_ID_AMD_19H_M70H_ROOT 0x14e8

struct pciid;
struct amdsmn_softc {
Expand Down Expand Up @@ -211,11 +212,12 @@ amdsmn_probe(device_t dev)
case 0x15:
case 0x17:
case 0x19:
case 0x1a:
break;
default:
return (ENXIO);
}
device_set_descf(dev, "AMD Family %xh System Management Network",
device_set_descf(dev, "AMD Family %Xh System Management Network",
family);

return (BUS_PROBE_GENERIC);
Expand Down
36 changes: 32 additions & 4 deletions sys/dev/amdtemp/amdtemp.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,15 @@ struct amdtemp_softc {
#define DEVICEID_AMD_MISC15_M10H 0x1403
#define DEVICEID_AMD_MISC15_M30H 0x141d
#define DEVICEID_AMD_MISC15_M60H_ROOT 0x1576
#define DEVICEID_AMD_MISC16 0x1533
#define DEVICEID_AMD_MISC16 0x1533
#define DEVICEID_AMD_MISC16_M30H 0x1583
#define DEVICEID_AMD_HOSTB17H_ROOT 0x1450
#define DEVICEID_AMD_HOSTB17H_M10H_ROOT 0x15d0
#define DEVICEID_AMD_HOSTB17H_M30H_ROOT 0x1480 /* Also M70H, F19H M00H/M20H */
#define DEVICEID_AMD_HOSTB17H_M60H_ROOT 0x1630
#define DEVICEID_AMD_HOSTB19H_M10H_ROOT 0x14a4
#define DEVICEID_AMD_HOSTB19H_M40H_ROOT 0x14b5
#define DEVICEID_AMD_HOSTB19H_M60H_ROOT 0x14d8
#define DEVICEID_AMD_HOSTB19H_M60H_ROOT 0x14d8 /* Also F1AH M40H */
#define DEVICEID_AMD_HOSTB19H_M70H_ROOT 0x14e8

static const struct amdtemp_product {
Expand Down Expand Up @@ -193,6 +193,8 @@ static const struct amdtemp_product {
#define AMDTEMP_ZEN4_10H_CCD_TMP_BASE 0x59b00
#define AMDTEMP_ZEN4_CCD_TMP_BASE 0x59b08

#define AMDTEMP_ZEN5_CCD_TMP_BASE 0x59b08

/*
* AMD temperature range adjustment, in deciKelvins (i.e., 49.0 Celsius).
*/
Expand Down Expand Up @@ -230,6 +232,7 @@ static int32_t amdtemp_gettemp15hm60h(device_t dev, amdsensor_t sensor);
static int32_t amdtemp_gettemp17h(device_t dev, amdsensor_t sensor);
static void amdtemp_probe_ccd_sensors17h(device_t dev, uint32_t model);
static void amdtemp_probe_ccd_sensors19h(device_t dev, uint32_t model);
static void amdtemp_probe_ccd_sensors1ah(device_t dev, uint32_t model);
static int amdtemp_sysctl(SYSCTL_HANDLER_ARGS);

static device_method_t amdtemp_methods[] = {
Expand Down Expand Up @@ -317,6 +320,7 @@ amdtemp_probe(device_t dev)
case 0x16:
case 0x17:
case 0x19:
case 0x1a:
break;
default:
return (ENXIO);
Expand Down Expand Up @@ -476,6 +480,7 @@ amdtemp_attach(device_t dev)
break;
case 0x17:
case 0x19:
case 0x1a:
sc->sc_ntemps = 1;
sc->sc_gettemp = amdtemp_gettemp17h;
needsmn = true;
Expand Down Expand Up @@ -539,6 +544,8 @@ amdtemp_attach(device_t dev)
amdtemp_probe_ccd_sensors17h(dev, model);
else if (family == 0x19)
amdtemp_probe_ccd_sensors19h(dev, model);
else if (family == 0x1a)
amdtemp_probe_ccd_sensors1ah(dev, model);
else if (sc->sc_ntemps > 1) {
SYSCTL_ADD_PROC(sysctlctx,
SYSCTL_CHILDREN(sysctlnode),
Expand Down Expand Up @@ -852,7 +859,7 @@ amdtemp_probe_ccd_sensors17h(device_t dev, uint32_t model)
break;
default:
device_printf(dev,
"Unrecognized Family 17h Model: %02xh\n", model);
"Unrecognized Family 17h Model: %02Xh\n", model);
return;
}

Expand Down Expand Up @@ -885,7 +892,28 @@ amdtemp_probe_ccd_sensors19h(device_t dev, uint32_t model)
break;
default:
device_printf(dev,
"Unrecognized Family 19h Model: %02xh\n", model);
"Unrecognized Family 19h Model: %02Xh\n", model);
return;
}

amdtemp_probe_ccd_sensors(dev, maxreg);
}

static void
amdtemp_probe_ccd_sensors1ah(device_t dev, uint32_t model)
{
struct amdtemp_softc *sc = device_get_softc(dev);
uint32_t maxreg;

switch (model) {
case 0x40 ... 0x4f: /* Zen5 Ryzen "Granite Ridge" */
sc->sc_temp_base = AMDTEMP_ZEN5_CCD_TMP_BASE;
maxreg = 8;
_Static_assert((int)NUM_CCDS >= 8, "");
break;
default:
device_printf(dev,
"Unrecognized Family 1Ah Model: %02Xh\n", model);
return;
}

Expand Down

0 comments on commit e7b3541

Please sign in to comment.