| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: powernow.c,v 1.8 2013/11/15 08:47:55 msaitoh Exp $ */ | | 1 | /* $NetBSD: powernow.c,v 1.9 2016/03/30 21:16:22 christos Exp $ */ |
2 | /* $OpenBSD: powernow-k8.c,v 1.8 2006/06/16 05:58:50 gwk Exp $ */ | | 2 | /* $OpenBSD: powernow-k8.c,v 1.8 2006/06/16 05:58:50 gwk Exp $ */ |
3 | | | 3 | |
4 | /*- | | 4 | /*- |
5 | * Copyright (c) 2004, 2006, 2008 The NetBSD Foundation, Inc. | | 5 | * Copyright (c) 2004, 2006, 2008 The NetBSD Foundation, Inc. |
6 | * All rights reserved. | | 6 | * All rights reserved. |
7 | * | | 7 | * |
8 | * This code is derived from software contributed to The NetBSD Foundation | | 8 | * This code is derived from software contributed to The NetBSD Foundation |
9 | * by Juan Romero Pardines and Martin Vegiard. | | 9 | * by Juan Romero Pardines and Martin Vegiard. |
10 | * | | 10 | * |
11 | * Redistribution and use in source and binary forms, with or without | | 11 | * Redistribution and use in source and binary forms, with or without |
12 | * modification, are permitted provided that the following conditions | | 12 | * modification, are permitted provided that the following conditions |
13 | * are met: | | 13 | * are met: |
14 | * 1. Redistributions of source code must retain the above copyright | | 14 | * 1. Redistributions of source code must retain the above copyright |
| @@ -47,27 +47,27 @@ | | | @@ -47,27 +47,27 @@ |
47 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | | 47 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
48 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | | 48 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
49 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | | 49 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
50 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | | 50 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
51 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | | 51 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
52 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | | 52 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
53 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | | 53 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
54 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | | 54 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
55 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | | 55 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
56 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | | 56 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
57 | */ | | 57 | */ |
58 | | | 58 | |
59 | #include <sys/cdefs.h> | | 59 | #include <sys/cdefs.h> |
60 | __KERNEL_RCSID(0, "$NetBSD: powernow.c,v 1.8 2013/11/15 08:47:55 msaitoh Exp $"); | | 60 | __KERNEL_RCSID(0, "$NetBSD: powernow.c,v 1.9 2016/03/30 21:16:22 christos Exp $"); |
61 | | | 61 | |
62 | #include <sys/param.h> | | 62 | #include <sys/param.h> |
63 | #include <sys/device.h> | | 63 | #include <sys/device.h> |
64 | #include <sys/kmem.h> | | 64 | #include <sys/kmem.h> |
65 | #include <sys/module.h> | | 65 | #include <sys/module.h> |
66 | #include <sys/sysctl.h> | | 66 | #include <sys/sysctl.h> |
67 | #include <sys/xcall.h> | | 67 | #include <sys/xcall.h> |
68 | | | 68 | |
69 | #include <dev/isa/isareg.h> | | 69 | #include <dev/isa/isareg.h> |
70 | | | 70 | |
71 | #include <x86/cpuvar.h> | | 71 | #include <x86/cpuvar.h> |
72 | #include <x86/cputypes.h> | | 72 | #include <x86/cputypes.h> |
73 | #include <x86/cpu_msr.h> | | 73 | #include <x86/cpu_msr.h> |
| @@ -896,28 +896,30 @@ powernow_k8_setperf(device_t self, unsig | | | @@ -896,28 +896,30 @@ powernow_k8_setperf(device_t self, unsig |
896 | cfid = PN8_STA_CFID(status); | | 896 | cfid = PN8_STA_CFID(status); |
897 | COUNT_OFF_IRT(sc->sc_state->irt); | | 897 | COUNT_OFF_IRT(sc->sc_state->irt); |
898 | } | | 898 | } |
899 | | | 899 | |
900 | /* | | 900 | /* |
901 | * Phase 3: change to requested voltage. | | 901 | * Phase 3: change to requested voltage. |
902 | */ | | 902 | */ |
903 | if (cvid != vid) { | | 903 | if (cvid != vid) { |
904 | status = powernow_k8_fidvid(cfid, vid, 1ULL); | | 904 | status = powernow_k8_fidvid(cfid, vid, 1ULL); |
905 | cvid = PN8_STA_CVID(status); | | 905 | cvid = PN8_STA_CVID(status); |
906 | COUNT_OFF_VST(sc->sc_state->vst); | | 906 | COUNT_OFF_VST(sc->sc_state->vst); |
907 | } | | 907 | } |
908 | | | 908 | |
| | | 909 | #if 0 |
909 | if (cfid == fid || cvid == vid) | | 910 | if (cfid == fid || cvid == vid) |
910 | freq = sc->sc_state->state_table[i].freq; | | 911 | freq = sc->sc_state->state_table[i].freq; |
| | | 912 | #endif |
911 | | | 913 | |
912 | return 0; | | 914 | return 0; |
913 | } | | 915 | } |
914 | | | 916 | |
915 | static uint64_t | | 917 | static uint64_t |
916 | powernow_k8_fidvid(u_int fid, uint64_t vid, uint64_t ctrl) | | 918 | powernow_k8_fidvid(u_int fid, uint64_t vid, uint64_t ctrl) |
917 | { | | 919 | { |
918 | struct msr_rw_info msr; | | 920 | struct msr_rw_info msr; |
919 | uint64_t status, xc; | | 921 | uint64_t status, xc; |
920 | | | 922 | |
921 | msr.msr_read = false; | | 923 | msr.msr_read = false; |
922 | msr.msr_value = (ctrl << 32) | (1ULL << 16) | (vid << 8) | fid; | | 924 | msr.msr_value = (ctrl << 32) | (1ULL << 16) | (vid << 8) | fid; |
923 | msr.msr_type = MSR_AMDK7_FIDVID_CTL; | | 925 | msr.msr_type = MSR_AMDK7_FIDVID_CTL; |