| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: amdzentemp.c,v 1.19 2023/07/28 00:11:15 msaitoh Exp $ */ | | 1 | /* $NetBSD: amdzentemp.c,v 1.20 2023/07/28 02:05:26 msaitoh Exp $ */ |
2 | /* $OpenBSD: kate.c,v 1.2 2008/03/27 04:52:03 cnst Exp $ */ | | 2 | /* $OpenBSD: kate.c,v 1.2 2008/03/27 04:52:03 cnst Exp $ */ |
3 | | | 3 | |
4 | /* | | 4 | /* |
5 | * Copyright (c) 2008, 2020 The NetBSD Foundation, Inc. | | 5 | * Copyright (c) 2008, 2020 The NetBSD Foundation, Inc. |
6 | * All rights reserved. | | 6 | * All rights reserved. |
7 | * | | 7 | * |
8 | * Copyright (c) 2019 Conrad Meyer <cem@FreeBSD.org> | | 8 | * Copyright (c) 2019 Conrad Meyer <cem@FreeBSD.org> |
9 | * All rights reserved. | | 9 | * All rights reserved. |
10 | * | | 10 | * |
11 | * This code is derived from software contributed to The NetBSD Foundation | | 11 | * This code is derived from software contributed to The NetBSD Foundation |
12 | * by Christoph Egger. | | 12 | * by Christoph Egger. |
13 | * | | 13 | * |
14 | * NetBSD port by Ian Clark <mrrooster@gmail.com> | | 14 | * NetBSD port by Ian Clark <mrrooster@gmail.com> |
| @@ -43,27 +43,27 @@ | | | @@ -43,27 +43,27 @@ |
43 | * copyright notice and this permission notice appear in all copies. | | 43 | * copyright notice and this permission notice appear in all copies. |
44 | * | | 44 | * |
45 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | | 45 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
46 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | | 46 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
47 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | | 47 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
48 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | | 48 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
49 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | | 49 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
50 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | | 50 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
51 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | | 51 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
52 | */ | | 52 | */ |
53 | | | 53 | |
54 | | | 54 | |
55 | #include <sys/cdefs.h> | | 55 | #include <sys/cdefs.h> |
56 | __KERNEL_RCSID(0, "$NetBSD: amdzentemp.c,v 1.19 2023/07/28 00:11:15 msaitoh Exp $ "); | | 56 | __KERNEL_RCSID(0, "$NetBSD: amdzentemp.c,v 1.20 2023/07/28 02:05:26 msaitoh Exp $ "); |
57 | | | 57 | |
58 | #include <sys/param.h> | | 58 | #include <sys/param.h> |
59 | #include <sys/bus.h> | | 59 | #include <sys/bus.h> |
60 | #include <sys/cpu.h> | | 60 | #include <sys/cpu.h> |
61 | #include <sys/systm.h> | | 61 | #include <sys/systm.h> |
62 | #include <sys/device.h> | | 62 | #include <sys/device.h> |
63 | #include <sys/kmem.h> | | 63 | #include <sys/kmem.h> |
64 | #include <sys/module.h> | | 64 | #include <sys/module.h> |
65 | | | 65 | |
66 | #include <machine/specialreg.h> | | 66 | #include <machine/specialreg.h> |
67 | | | 67 | |
68 | #include <dev/pci/pcireg.h> | | 68 | #include <dev/pci/pcireg.h> |
69 | #include <dev/pci/pcivar.h> | | 69 | #include <dev/pci/pcivar.h> |
| @@ -360,35 +360,39 @@ amdzentemp_family17_refresh(struct sysmo | | | @@ -360,35 +360,39 @@ amdzentemp_family17_refresh(struct sysmo |
360 | /* From C to uK. */ | | 360 | /* From C to uK. */ |
361 | edata->value_cur = (temp * 125000) + 273150000; | | 361 | edata->value_cur = (temp * 125000) + 273150000; |
362 | /* adjust for possible offset of 49K */ | | 362 | /* adjust for possible offset of 49K */ |
363 | if (minus49) | | 363 | if (minus49) |
364 | edata->value_cur -= AMD_CURTMP_RANGE_ADJUST; | | 364 | edata->value_cur -= AMD_CURTMP_RANGE_ADJUST; |
365 | edata->value_cur += sc->sc_offset; | | 365 | edata->value_cur += sc->sc_offset; |
366 | } | | 366 | } |
367 | | | 367 | |
368 | static int | | 368 | static int |
369 | amdzentemp_probe_ccd_sensors17h(struct amdzentemp_softc *sc, int model) | | 369 | amdzentemp_probe_ccd_sensors17h(struct amdzentemp_softc *sc, int model) |
370 | { | | 370 | { |
371 | int maxreg; | | 371 | int maxreg; |
372 | | | 372 | |
373 | sc->sc_ccd_offset = 0x154; | | | |
374 | | | | |
375 | switch (model) { | | 373 | switch (model) { |
376 | case 0x00 ... 0x2f: /* Zen1, Zen+ */ | | 374 | case 0x00 ... 0x2f: /* Zen1, Zen+ */ |
| | | 375 | sc->sc_ccd_offset = 0x154; |
377 | maxreg = 4; | | 376 | maxreg = 4; |
378 | break; | | 377 | break; |
379 | case 0x30 ... 0x3f: /* Zen2 TR (Castle Peak)/EPYC (Rome) */ | | 378 | case 0x30 ... 0x3f: /* Zen2 TR (Castle Peak)/EPYC (Rome) */ |
380 | case 0x60 ... 0x7f: /* Zen2 Ryzen (Renoir APU, Matisse) */ | | 379 | case 0x60 ... 0x7f: /* Zen2 Ryzen (Renoir APU, Matisse) */ |
381 | case 0x90 ... 0x9f: /* Zen2 Ryzen (Van Gogh APU) */ | | 380 | case 0x90 ... 0x9f: /* Zen2 Ryzen (Van Gogh APU) */ |
| | | 381 | sc->sc_ccd_offset = 0x154; |
| | | 382 | maxreg = 8; |
| | | 383 | break; |
| | | 384 | case 0xa0 ... 0xaf: /* Zen2 Ryzen (Mendocino APU) */ |
| | | 385 | sc->sc_ccd_offset = 0x300; |
382 | maxreg = 8; | | 386 | maxreg = 8; |
383 | break; | | 387 | break; |
384 | default: | | 388 | default: |
385 | aprint_error_dev(sc->sc_dev, | | 389 | aprint_error_dev(sc->sc_dev, |
386 | "Unrecognized Family 17h Model: %02xh\n", model); | | 390 | "Unrecognized Family 17h Model: %02xh\n", model); |
387 | return 0; | | 391 | return 0; |
388 | } | | 392 | } |
389 | | | 393 | |
390 | return maxreg; | | 394 | return maxreg; |
391 | } | | 395 | } |
392 | | | 396 | |
393 | static int | | 397 | static int |
394 | amdzentemp_probe_ccd_sensors19h(struct amdzentemp_softc *sc, int model) | | 398 | amdzentemp_probe_ccd_sensors19h(struct amdzentemp_softc *sc, int model) |