2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
4 * Copyright (c) 2008, 2009 Rui Paulo <rpaulo@FreeBSD.org>
5 * Copyright (c) 2009 Norikatsu Shigemura <nork@FreeBSD.org>
6 * Copyright (c) 2009-2012 Jung-uk Kim <jkim@FreeBSD.org>
8 * Copyright (c) 2017-2019 Conrad Meyer <cem@FreeBSD.org>
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
24 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
28 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
29 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
34 * Driver for the AMD CPU on-die thermal sensors.
35 * Initially based on the k8temp Linux driver.
38 #include <sys/cdefs.h>
39 __FBSDID("$FreeBSD$");
41 #include <sys/param.h>
44 #include <sys/kernel.h>
45 #include <sys/module.h>
46 #include <sys/sysctl.h>
47 #include <sys/systm.h>
49 #include <machine/cpufunc.h>
50 #include <machine/md_var.h>
51 #include <machine/specialreg.h>
53 #include <dev/pci/pcivar.h>
54 #include <x86/pci_cfgreg.h>
56 #include <dev/amdsmn/amdsmn.h>
67 struct amdtemp_softc {
71 #define AMDTEMP_FLAG_CS_SWAP 0x01 /* ThermSenseCoreSel is inverted. */
72 #define AMDTEMP_FLAG_CT_10BIT 0x02 /* CurTmp is 10-bit wide. */
73 #define AMDTEMP_FLAG_ALT_OFFSET 0x04 /* CurTmp starts at -28C. */
75 int32_t (*sc_gettemp)(device_t, amdsensor_t);
76 struct sysctl_oid *sc_sysctl_cpu[MAXCPU];
77 struct intr_config_hook sc_ich;
82 * N.B. The numbers in macro names below are significant and represent CPU
83 * family and model numbers. Do not make up fictitious family or model numbers
84 * when adding support for new devices.
86 #define VENDORID_AMD 0x1022
87 #define DEVICEID_AMD_MISC0F 0x1103
88 #define DEVICEID_AMD_MISC10 0x1203
89 #define DEVICEID_AMD_MISC11 0x1303
90 #define DEVICEID_AMD_MISC14 0x1703
91 #define DEVICEID_AMD_MISC15 0x1603
92 #define DEVICEID_AMD_MISC15_M10H 0x1403
93 #define DEVICEID_AMD_MISC15_M30H 0x141d
94 #define DEVICEID_AMD_MISC15_M60H_ROOT 0x1576
95 #define DEVICEID_AMD_MISC16 0x1533
96 #define DEVICEID_AMD_MISC16_M30H 0x1583
97 #define DEVICEID_AMD_HOSTB17H_ROOT 0x1450
98 #define DEVICEID_AMD_HOSTB17H_M10H_ROOT 0x15d0
100 static const struct amdtemp_product {
101 uint16_t amdtemp_vendorid;
102 uint16_t amdtemp_deviceid;
104 * 0xFC register is only valid on the D18F3 PCI device; SMN temp
105 * drivers do not attach to that device.
107 bool amdtemp_has_cpuid;
108 } amdtemp_products[] = {
109 { VENDORID_AMD, DEVICEID_AMD_MISC0F, true },
110 { VENDORID_AMD, DEVICEID_AMD_MISC10, true },
111 { VENDORID_AMD, DEVICEID_AMD_MISC11, true },
112 { VENDORID_AMD, DEVICEID_AMD_MISC14, true },
113 { VENDORID_AMD, DEVICEID_AMD_MISC15, true },
114 { VENDORID_AMD, DEVICEID_AMD_MISC15_M10H, true },
115 { VENDORID_AMD, DEVICEID_AMD_MISC15_M30H, true },
116 { VENDORID_AMD, DEVICEID_AMD_MISC15_M60H_ROOT, false },
117 { VENDORID_AMD, DEVICEID_AMD_MISC16, true },
118 { VENDORID_AMD, DEVICEID_AMD_MISC16_M30H, true },
119 { VENDORID_AMD, DEVICEID_AMD_HOSTB17H_ROOT, false },
120 { VENDORID_AMD, DEVICEID_AMD_HOSTB17H_M10H_ROOT, false },
124 * Reported Temperature Control Register, family 0Fh-15h (some models), 16h.
126 #define AMDTEMP_REPTMP_CTRL 0xa4
128 #define AMDTEMP_REPTMP10H_CURTMP_MASK 0x7ff
129 #define AMDTEMP_REPTMP10H_CURTMP_SHIFT 21
130 #define AMDTEMP_REPTMP10H_TJSEL_MASK 0x3
131 #define AMDTEMP_REPTMP10H_TJSEL_SHIFT 16
134 * Reported Temperature, Family 15h, M60+
136 * Same register bit definitions as other Family 15h CPUs, but access is
137 * indirect via SMN, like Family 17h.
139 #define AMDTEMP_15H_M60H_REPTMP_CTRL 0xd8200ca4
142 * Reported Temperature, Family 17h
144 * According to AMD OSRR for 17H, section 4.2.1, bits 31-21 of this register
145 * provide the current temp. bit 19, when clear, means the temp is reported in
146 * a range 0.."225C" (probable typo for 255C), and when set changes the range
149 #define AMDTEMP_17H_CUR_TMP 0x59800
150 #define AMDTEMP_17H_CUR_TMP_RANGE_SEL (1 << 19)
153 * AMD temperature range adjustment, in deciKelvins (i.e., 49.0 Celsius).
155 #define AMDTEMP_CURTMP_RANGE_ADJUST 490
158 * Thermaltrip Status Register (Family 0Fh only)
160 #define AMDTEMP_THERMTP_STAT 0xe4
161 #define AMDTEMP_TTSR_SELCORE 0x04
162 #define AMDTEMP_TTSR_SELSENSOR 0x40
165 * DRAM Configuration High Register
167 #define AMDTEMP_DRAM_CONF_HIGH 0x94 /* Function 2 */
168 #define AMDTEMP_DRAM_MODE_DDR3 0x0100
171 * CPU Family/Model Register
173 #define AMDTEMP_CPUID 0xfc
178 static void amdtemp_identify(driver_t *driver, device_t parent);
179 static int amdtemp_probe(device_t dev);
180 static int amdtemp_attach(device_t dev);
181 static void amdtemp_intrhook(void *arg);
182 static int amdtemp_detach(device_t dev);
183 static int32_t amdtemp_gettemp0f(device_t dev, amdsensor_t sensor);
184 static int32_t amdtemp_gettemp(device_t dev, amdsensor_t sensor);
185 static int32_t amdtemp_gettemp15hm60h(device_t dev, amdsensor_t sensor);
186 static int32_t amdtemp_gettemp17h(device_t dev, amdsensor_t sensor);
187 static int amdtemp_sysctl(SYSCTL_HANDLER_ARGS);
189 static device_method_t amdtemp_methods[] = {
190 /* Device interface */
191 DEVMETHOD(device_identify, amdtemp_identify),
192 DEVMETHOD(device_probe, amdtemp_probe),
193 DEVMETHOD(device_attach, amdtemp_attach),
194 DEVMETHOD(device_detach, amdtemp_detach),
199 static driver_t amdtemp_driver = {
202 sizeof(struct amdtemp_softc),
205 static devclass_t amdtemp_devclass;
206 DRIVER_MODULE(amdtemp, hostb, amdtemp_driver, amdtemp_devclass, NULL, NULL);
207 MODULE_VERSION(amdtemp, 1);
208 MODULE_DEPEND(amdtemp, amdsmn, 1, 1, 1);
209 MODULE_PNP_INFO("U16:vendor;U16:device", pci, amdtemp, amdtemp_products,
210 nitems(amdtemp_products));
213 amdtemp_match(device_t dev, const struct amdtemp_product **product_out)
216 uint16_t vendor, devid;
218 vendor = pci_get_vendor(dev);
219 devid = pci_get_device(dev);
221 for (i = 0; i < nitems(amdtemp_products); i++) {
222 if (vendor == amdtemp_products[i].amdtemp_vendorid &&
223 devid == amdtemp_products[i].amdtemp_deviceid) {
224 if (product_out != NULL)
225 *product_out = &amdtemp_products[i];
233 amdtemp_identify(driver_t *driver, device_t parent)
237 /* Make sure we're not being doubly invoked. */
238 if (device_find_child(parent, "amdtemp", -1) != NULL)
241 if (amdtemp_match(parent, NULL)) {
242 child = device_add_child(parent, "amdtemp", -1);
244 device_printf(parent, "add amdtemp child failed\n");
249 amdtemp_probe(device_t dev)
251 uint32_t family, model;
253 if (resource_disabled("amdtemp", 0))
255 if (!amdtemp_match(device_get_parent(dev), NULL))
258 family = CPUID_TO_FAMILY(cpu_id);
259 model = CPUID_TO_MODEL(cpu_id);
263 if ((model == 0x04 && (cpu_id & CPUID_STEPPING) == 0) ||
264 (model == 0x05 && (cpu_id & CPUID_STEPPING) <= 1))
278 device_set_desc(dev, "AMD CPU On-Die Thermal Sensors");
280 return (BUS_PROBE_GENERIC);
284 amdtemp_attach(device_t dev)
288 const struct amdtemp_product *product;
289 struct amdtemp_softc *sc;
290 struct sysctl_ctx_list *sysctlctx;
291 struct sysctl_oid *sysctlnode;
292 uint32_t cpuid, family, model;
294 int erratum319, unit;
297 sc = device_get_softc(dev);
301 if (!amdtemp_match(device_get_parent(dev), &product))
305 family = CPUID_TO_FAMILY(cpuid);
306 model = CPUID_TO_MODEL(cpuid);
309 * This checks for the byzantine condition of running a heterogenous
310 * revision multi-socket system where the attach thread is potentially
311 * probing a remote socket's PCI device.
313 * Currently, such scenarios are unsupported on models using the SMN
314 * (because on those models, amdtemp(4) attaches to a different PCI
315 * device than the one that contains AMDTEMP_CPUID).
317 * The ancient 0x0F family of devices only supports this register from
320 if (product->amdtemp_has_cpuid && (family > 0x0f ||
321 (family == 0x0f && model >= 0x40))) {
322 cpuid = pci_read_config(device_get_parent(dev), AMDTEMP_CPUID,
324 family = CPUID_TO_FAMILY(cpuid);
325 model = CPUID_TO_MODEL(cpuid);
331 * Thermaltrip Status Register
333 * - ThermSenseCoreSel
335 * Revision F & G: 0 - Core1, 1 - Core0
336 * Other: 0 - Core0, 1 - Core1
340 * Revision G: bits 23-14
343 * XXX According to the BKDG, CurTmp, ThermSenseSel and
344 * ThermSenseCoreSel bits were introduced in Revision F
345 * but CurTmp seems working fine as early as Revision C.
346 * However, it is not clear whether ThermSenseSel and/or
347 * ThermSenseCoreSel work in undocumented cases as well.
348 * In fact, the Linux driver suggests it may not work but
349 * we just assume it does until we find otherwise.
351 * XXX According to Linux, CurTmp starts at -28C on
352 * Socket AM2 Revision G processors, which is not
353 * documented anywhere.
356 sc->sc_flags |= AMDTEMP_FLAG_CS_SWAP;
357 if (model >= 0x60 && model != 0xc1) {
358 do_cpuid(0x80000001, regs);
359 bid = (regs[1] >> 9) & 0x1f;
361 case 0x68: /* Socket S1g1 */
365 case 0x6b: /* Socket AM2 and ASB1 (2 cores) */
366 if (bid != 0x0b && bid != 0x0c)
368 AMDTEMP_FLAG_ALT_OFFSET;
370 case 0x6f: /* Socket AM2 and ASB1 (1 core) */
372 if (bid != 0x07 && bid != 0x09 &&
375 AMDTEMP_FLAG_ALT_OFFSET;
378 sc->sc_flags |= AMDTEMP_FLAG_ALT_OFFSET;
380 sc->sc_flags |= AMDTEMP_FLAG_CT_10BIT;
384 * There are two sensors per core.
388 sc->sc_gettemp = amdtemp_gettemp0f;
392 * Erratum 319 Inaccurate Temperature Measurement
394 * http://support.amd.com/us/Processor_TechDocs/41322.pdf
396 do_cpuid(0x80000001, regs);
397 switch ((regs[1] >> 28) & 0xf) {
398 case 0: /* Socket F */
401 case 1: /* Socket AM2+ or AM3 */
402 if ((pci_cfgregread(pci_get_bus(dev),
403 pci_get_slot(dev), 2, AMDTEMP_DRAM_CONF_HIGH, 2) &
404 AMDTEMP_DRAM_MODE_DDR3) != 0 || model > 0x04 ||
405 (model == 0x04 && (cpuid & CPUID_STEPPING) >= 3))
407 /* XXX 00100F42h (RB-C2) exists in both formats. */
419 * Some later (60h+) models of family 15h use a similar SMN
420 * network as family 17h. (However, the register index differs
421 * from 17h and the decoding matches other 10h-15h models,
422 * which differ from 17h.)
424 if (family == 0x15 && model >= 0x60) {
425 sc->sc_gettemp = amdtemp_gettemp15hm60h;
428 sc->sc_gettemp = amdtemp_gettemp;
432 sc->sc_gettemp = amdtemp_gettemp17h;
436 device_printf(dev, "Bogus family 0x%x\n", family);
441 sc->sc_smn = device_find_child(
442 device_get_parent(dev), "amdsmn", -1);
443 if (sc->sc_smn == NULL) {
445 device_printf(dev, "No SMN device found\n");
450 /* Find number of cores per package. */
451 sc->sc_ncores = (amd_feature2 & AMDID2_CMP) != 0 ?
452 (cpu_procinfo2 & AMDID_CMP_CORES) + 1 : 1;
453 if (sc->sc_ncores > MAXCPU)
458 "Erratum 319: temperature measurement may be inaccurate\n");
460 device_printf(dev, "Found %d cores and %d sensors.\n",
462 sc->sc_ntemps > 1 ? sc->sc_ntemps * sc->sc_ncores : 1);
465 * dev.amdtemp.N tree.
467 unit = device_get_unit(dev);
468 snprintf(tn, sizeof(tn), "dev.amdtemp.%d.sensor_offset", unit);
469 TUNABLE_INT_FETCH(tn, &sc->sc_offset);
471 sysctlctx = device_get_sysctl_ctx(dev);
472 SYSCTL_ADD_INT(sysctlctx,
473 SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), OID_AUTO,
474 "sensor_offset", CTLFLAG_RW, &sc->sc_offset, 0,
475 "Temperature sensor offset");
476 sysctlnode = SYSCTL_ADD_NODE(sysctlctx,
477 SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), OID_AUTO,
478 "core0", CTLFLAG_RD, 0, "Core 0");
480 SYSCTL_ADD_PROC(sysctlctx,
481 SYSCTL_CHILDREN(sysctlnode),
482 OID_AUTO, "sensor0", CTLTYPE_INT | CTLFLAG_RD,
483 dev, CORE0_SENSOR0, amdtemp_sysctl, "IK",
484 "Core 0 / Sensor 0 temperature");
486 if (sc->sc_ntemps > 1) {
487 SYSCTL_ADD_PROC(sysctlctx,
488 SYSCTL_CHILDREN(sysctlnode),
489 OID_AUTO, "sensor1", CTLTYPE_INT | CTLFLAG_RD,
490 dev, CORE0_SENSOR1, amdtemp_sysctl, "IK",
491 "Core 0 / Sensor 1 temperature");
493 if (sc->sc_ncores > 1) {
494 sysctlnode = SYSCTL_ADD_NODE(sysctlctx,
495 SYSCTL_CHILDREN(device_get_sysctl_tree(dev)),
496 OID_AUTO, "core1", CTLFLAG_RD, 0, "Core 1");
498 SYSCTL_ADD_PROC(sysctlctx,
499 SYSCTL_CHILDREN(sysctlnode),
500 OID_AUTO, "sensor0", CTLTYPE_INT | CTLFLAG_RD,
501 dev, CORE1_SENSOR0, amdtemp_sysctl, "IK",
502 "Core 1 / Sensor 0 temperature");
504 SYSCTL_ADD_PROC(sysctlctx,
505 SYSCTL_CHILDREN(sysctlnode),
506 OID_AUTO, "sensor1", CTLTYPE_INT | CTLFLAG_RD,
507 dev, CORE1_SENSOR1, amdtemp_sysctl, "IK",
508 "Core 1 / Sensor 1 temperature");
513 * Try to create dev.cpu sysctl entries and setup intrhook function.
514 * This is needed because the cpu driver may be loaded late on boot,
517 amdtemp_intrhook(dev);
518 sc->sc_ich.ich_func = amdtemp_intrhook;
519 sc->sc_ich.ich_arg = dev;
520 if (config_intrhook_establish(&sc->sc_ich) != 0) {
521 device_printf(dev, "config_intrhook_establish failed!\n");
529 amdtemp_intrhook(void *arg)
531 struct amdtemp_softc *sc;
532 struct sysctl_ctx_list *sysctlctx;
533 device_t dev = (device_t)arg;
534 device_t acpi, cpu, nexus;
538 sc = device_get_softc(dev);
541 * dev.cpu.N.temperature.
543 nexus = device_find_child(root_bus, "nexus", 0);
544 acpi = device_find_child(nexus, "acpi", 0);
546 for (i = 0; i < sc->sc_ncores; i++) {
547 if (sc->sc_sysctl_cpu[i] != NULL)
549 cpu = device_find_child(acpi, "cpu",
550 device_get_unit(dev) * sc->sc_ncores + i);
552 sysctlctx = device_get_sysctl_ctx(cpu);
554 sensor = sc->sc_ntemps > 1 ?
555 (i == 0 ? CORE0 : CORE1) : CORE0_SENSOR0;
556 sc->sc_sysctl_cpu[i] = SYSCTL_ADD_PROC(sysctlctx,
557 SYSCTL_CHILDREN(device_get_sysctl_tree(cpu)),
558 OID_AUTO, "temperature", CTLTYPE_INT | CTLFLAG_RD,
559 dev, sensor, amdtemp_sysctl, "IK",
560 "Current temparature");
563 if (sc->sc_ich.ich_arg != NULL)
564 config_intrhook_disestablish(&sc->sc_ich);
568 amdtemp_detach(device_t dev)
570 struct amdtemp_softc *sc = device_get_softc(dev);
573 for (i = 0; i < sc->sc_ncores; i++)
574 if (sc->sc_sysctl_cpu[i] != NULL)
575 sysctl_remove_oid(sc->sc_sysctl_cpu[i], 1, 0);
577 /* NewBus removes the dev.amdtemp.N tree by itself. */
583 amdtemp_sysctl(SYSCTL_HANDLER_ARGS)
585 device_t dev = (device_t)arg1;
586 struct amdtemp_softc *sc = device_get_softc(dev);
587 amdsensor_t sensor = (amdsensor_t)arg2;
588 int32_t auxtemp[2], temp;
593 auxtemp[0] = sc->sc_gettemp(dev, CORE0_SENSOR0);
594 auxtemp[1] = sc->sc_gettemp(dev, CORE0_SENSOR1);
595 temp = imax(auxtemp[0], auxtemp[1]);
598 auxtemp[0] = sc->sc_gettemp(dev, CORE1_SENSOR0);
599 auxtemp[1] = sc->sc_gettemp(dev, CORE1_SENSOR1);
600 temp = imax(auxtemp[0], auxtemp[1]);
603 temp = sc->sc_gettemp(dev, sensor);
606 error = sysctl_handle_int(oidp, &temp, 0, req);
611 #define AMDTEMP_ZERO_C_TO_K 2731
614 amdtemp_gettemp0f(device_t dev, amdsensor_t sensor)
616 struct amdtemp_softc *sc = device_get_softc(dev);
617 uint32_t mask, offset, temp;
619 /* Set Sensor/Core selector. */
620 temp = pci_read_config(dev, AMDTEMP_THERMTP_STAT, 1);
621 temp &= ~(AMDTEMP_TTSR_SELCORE | AMDTEMP_TTSR_SELSENSOR);
624 temp |= AMDTEMP_TTSR_SELSENSOR;
628 if ((sc->sc_flags & AMDTEMP_FLAG_CS_SWAP) != 0)
629 temp |= AMDTEMP_TTSR_SELCORE;
632 temp |= AMDTEMP_TTSR_SELSENSOR;
636 if ((sc->sc_flags & AMDTEMP_FLAG_CS_SWAP) == 0)
637 temp |= AMDTEMP_TTSR_SELCORE;
640 pci_write_config(dev, AMDTEMP_THERMTP_STAT, temp, 1);
642 mask = (sc->sc_flags & AMDTEMP_FLAG_CT_10BIT) != 0 ? 0x3ff : 0x3fc;
643 offset = (sc->sc_flags & AMDTEMP_FLAG_ALT_OFFSET) != 0 ? 28 : 49;
644 temp = pci_read_config(dev, AMDTEMP_THERMTP_STAT, 4);
645 temp = ((temp >> 14) & mask) * 5 / 2;
646 temp += AMDTEMP_ZERO_C_TO_K + (sc->sc_offset - offset) * 10;
652 amdtemp_decode_fam10h_to_16h(int32_t sc_offset, uint32_t val)
656 /* Convert raw register subfield units (0.125C) to units of 0.1C. */
657 temp = ((val >> AMDTEMP_REPTMP10H_CURTMP_SHIFT) &
658 AMDTEMP_REPTMP10H_CURTMP_MASK) * 5 / 4;
661 * On Family 15h and higher, if CurTmpTjSel is 11b, the range is
662 * adjusted down by 49.0 degrees Celsius. (This adjustment is not
663 * documented in BKDGs prior to family 15h model 00h.)
665 if (CPUID_TO_FAMILY(cpu_id) >= 0x15 &&
666 ((val >> AMDTEMP_REPTMP10H_TJSEL_SHIFT) &
667 AMDTEMP_REPTMP10H_TJSEL_MASK) == 0x3)
668 temp -= AMDTEMP_CURTMP_RANGE_ADJUST;
670 temp += AMDTEMP_ZERO_C_TO_K + sc_offset * 10;
675 amdtemp_gettemp(device_t dev, amdsensor_t sensor)
677 struct amdtemp_softc *sc = device_get_softc(dev);
680 temp = pci_read_config(dev, AMDTEMP_REPTMP_CTRL, 4);
681 return (amdtemp_decode_fam10h_to_16h(sc->sc_offset, temp));
685 amdtemp_gettemp15hm60h(device_t dev, amdsensor_t sensor)
687 struct amdtemp_softc *sc = device_get_softc(dev);
691 error = amdsmn_read(sc->sc_smn, AMDTEMP_15H_M60H_REPTMP_CTRL, &val);
692 KASSERT(error == 0, ("amdsmn_read"));
693 return (amdtemp_decode_fam10h_to_16h(sc->sc_offset, val));
697 amdtemp_gettemp17h(device_t dev, amdsensor_t sensor)
699 struct amdtemp_softc *sc = device_get_softc(dev);
703 error = amdsmn_read(sc->sc_smn, AMDTEMP_17H_CUR_TMP, &val);
704 KASSERT(error == 0, ("amdsmn_read"));
706 temp = ((val >> 21) & 0x7ff) * 5 / 4;
707 if ((val & AMDTEMP_17H_CUR_TMP_RANGE_SEL) != 0)
708 temp -= AMDTEMP_CURTMP_RANGE_ADJUST;
709 temp += AMDTEMP_ZERO_C_TO_K + sc->sc_offset * 10;