Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src AMD PowerNow K7 driver written by Martin Vegiard via PR port...



details:   https://anonhg.NetBSD.org/src/rev/a202be70299c
branches:  trunk
changeset: 586773:a202be70299c
user:      xtraeme <xtraeme%NetBSD.org@localhost>
date:      Sat Dec 31 17:55:55 2005 +0000

description:
AMD PowerNow K7 driver written by Martin Vegiard via PR port-i386/26239.

Enabled by default on GENERIC and GENERIC_LAPTOP.

Imported 1 year later... but it's here finally.

diffstat:

 doc/CHANGES                       |    4 +-
 share/man/man4/options.4          |    8 +-
 sys/arch/i386/conf/GENERIC        |    7 +-
 sys/arch/i386/conf/GENERIC_LAPTOP |    7 +-
 sys/arch/i386/conf/files.i386     |    8 +-
 sys/arch/i386/i386/est.c          |    7 +-
 sys/arch/i386/i386/identcpu.c     |   26 ++-
 sys/arch/i386/i386/powernow_k7.c  |  338 ++++++++++++++++++++++++++++++++++++++
 sys/arch/i386/include/cpu.h       |    5 +-
 9 files changed, 394 insertions(+), 16 deletions(-)

diffs (truncated from 580 to 300 lines):

diff -r b10a82702954 -r a202be70299c doc/CHANGES
--- a/doc/CHANGES       Sat Dec 31 16:23:59 2005 +0000
+++ b/doc/CHANGES       Sat Dec 31 17:55:55 2005 +0000
@@ -1,4 +1,4 @@
-LIST OF CHANGES FROM LAST RELEASE:                     <$Revision: 1.556 $>
+LIST OF CHANGES FROM LAST RELEASE:                     <$Revision: 1.557 $>
 
 
 [Note: This file does not mention every change made to the NetBSD source tree.
@@ -158,3 +158,5 @@
                was done by UCHIYAMA Yasushi. [tsutsui 20051229]
        rtw(4): Add support for GCT Semiconductor GRF5101
                transceiver/synthesizer.  [dyoung 20051229]
+       i386:   Add support for AMD PowerNow technology.
+               Written by Martin Vegiard. [xtraeme 20051231]
diff -r b10a82702954 -r a202be70299c share/man/man4/options.4
--- a/share/man/man4/options.4  Sat Dec 31 16:23:59 2005 +0000
+++ b/share/man/man4/options.4  Sat Dec 31 17:55:55 2005 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: options.4,v 1.299 2005/12/20 18:15:30 elad Exp $
+.\"    $NetBSD: options.4,v 1.300 2005/12/31 17:55:55 xtraeme Exp $
 .\"
 .\" Copyright (c) 1996
 .\"    Perry E. Metzger.  All rights reserved.
@@ -30,7 +30,7 @@
 .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 .\"
 .\"
-.Dd December 20, 2005
+.Dd December 31, 2005
 .Os
 .Dt OPTIONS 4
 .Sh NAME
@@ -2290,6 +2290,10 @@
 .Tn Enhanced SpeedStep Technology
 capable
 .Tn CPU .
+.It Cd options POWERNOW_K7
+Include support for the AMD
+.Tn PowerNow! Technology
+present in AMD Athlon Mobile processors.
 .It Cd options CPURESET_DELAY=value
 Specifies the time (in millisecond) to wait before doing a hardware reset
 in the last phase of a reboot.
diff -r b10a82702954 -r a202be70299c sys/arch/i386/conf/GENERIC
--- a/sys/arch/i386/conf/GENERIC        Sat Dec 31 16:23:59 2005 +0000
+++ b/sys/arch/i386/conf/GENERIC        Sat Dec 31 17:55:55 2005 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.714 2005/12/20 05:35:28 thorpej Exp $
+# $NetBSD: GENERIC,v 1.715 2005/12/31 17:55:55 xtraeme Exp $
 #
 # GENERIC machine description file
 #
@@ -22,7 +22,7 @@
 
 options        INCLUDE_CONFIG_FILE     # embed config file in kernel binary
 
-#ident                 "GENERIC-$Revision: 1.714 $"
+#ident                 "GENERIC-$Revision: 1.715 $"
 
 maxusers       32              # estimated number of users
 
@@ -43,6 +43,9 @@
 options        ENHANCED_SPEEDSTEP
 #options       EST_FREQ_USERWRITE      # any user can set frequency
 
+# AMD PowerNow! K7
+options                POWERNOW_K7
+
 options        MTRR            # memory-type range register syscall support
 # doesn't work with MP just yet..
 #options       PERFCTRS        # performance-monitoring counters support
diff -r b10a82702954 -r a202be70299c sys/arch/i386/conf/GENERIC_LAPTOP
--- a/sys/arch/i386/conf/GENERIC_LAPTOP Sat Dec 31 16:23:59 2005 +0000
+++ b/sys/arch/i386/conf/GENERIC_LAPTOP Sat Dec 31 17:55:55 2005 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: GENERIC_LAPTOP,v 1.161 2005/12/20 05:35:28 thorpej Exp $
+#      $NetBSD: GENERIC_LAPTOP,v 1.162 2005/12/31 17:55:55 xtraeme Exp $
 #      From: NetBSD: GENERIC,v 1.414 2001/07/30 19:59:05 ad Exp
 #
 #      GENERIC_LAPTOP -- GENERIC with cardbus and some USB devices enabled
@@ -8,7 +8,7 @@
 
 #options       INCLUDE_CONFIG_FILE     # embed config file in kernel binary
 
-#ident                 "GENERIC-$Revision: 1.161 $"
+#ident                 "GENERIC-$Revision: 1.162 $"
 
 maxusers       32              # estimated number of users
 
@@ -27,6 +27,9 @@
 options        ENHANCED_SPEEDSTEP
 #options       EST_FREQ_USERWRITE      # any user can set frequency
 
+# AMD PowerNow! K7
+options                POWERNOW_K7
+
 options        MTRR            # memory-type range register syscall support
 #options       PERFCTRS        # performance-monitoring counters support
 
diff -r b10a82702954 -r a202be70299c sys/arch/i386/conf/files.i386
--- a/sys/arch/i386/conf/files.i386     Sat Dec 31 16:23:59 2005 +0000
+++ b/sys/arch/i386/conf/files.i386     Sat Dec 31 17:55:55 2005 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.i386,v 1.274 2005/12/11 02:11:50 christos Exp $
+#      $NetBSD: files.i386,v 1.275 2005/12/31 17:55:55 xtraeme Exp $
 #
 # new style config file for i386 architecture
 #
@@ -64,6 +64,9 @@
 # Enhanced SpeedStep
 defflag                        ENHANCED_SPEEDSTEP
 
+# PowerNow K7
+defflag                        POWERNOW_K7
+
 file   arch/i386/i386/autoconf.c
 file   arch/i386/i386/db_dbgreg.S      ddb | kstack_check_dr0
 file   arch/i386/i386/db_disasm.c      ddb
@@ -486,6 +489,9 @@
 file   arch/i386/i386/est.c            enhanced_speedstep
 defflag        opt_est.h       EST_FREQ_USERWRITE
 
+# AMD PowerNow K7
+file   arch/i386/i386/powernow_k7.c    powernow_k7
+
 # Atheros 5210/5211/5212 Hardware Abstraction Layer (HAL)
 object /athhal-i386-elf.hal.o  ath
 
diff -r b10a82702954 -r a202be70299c sys/arch/i386/i386/est.c
--- a/sys/arch/i386/i386/est.c  Sat Dec 31 16:23:59 2005 +0000
+++ b/sys/arch/i386/i386/est.c  Sat Dec 31 17:55:55 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: est.c,v 1.13 2005/12/31 09:52:46 xtraeme Exp $ */
+/*     $NetBSD: est.c,v 1.14 2005/12/31 17:55:55 xtraeme Exp $ */
 /*
  * Copyright (c) 2003 Michael Eriksson.
  * All rights reserved.
@@ -84,7 +84,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: est.c,v 1.13 2005/12/31 09:52:46 xtraeme Exp $");
+__KERNEL_RCSID(0, "$NetBSD: est.c,v 1.14 2005/12/31 17:55:55 xtraeme Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -353,9 +353,6 @@
        ENTRY("2.00", pentium_m_n755),
        ENTRY("2.10", pentium_m_n765),
        ENTRY("2.13", pentium_m_n770),
-       ENTRY("1.00", pentium_m_n723),
-       ENTRY("1.10", pentium_m_n733),
-       ENTRY("1.40", pentium_m_n738),
 };
 #undef ENTRY
 
diff -r b10a82702954 -r a202be70299c sys/arch/i386/i386/identcpu.c
--- a/sys/arch/i386/i386/identcpu.c     Sat Dec 31 16:23:59 2005 +0000
+++ b/sys/arch/i386/i386/identcpu.c     Sat Dec 31 17:55:55 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: identcpu.c,v 1.24 2005/12/26 19:23:59 perry Exp $      */
+/*     $NetBSD: identcpu.c,v 1.25 2005/12/31 17:55:55 xtraeme Exp $    */
 
 /*-
  * Copyright (c) 1999, 2000, 2001 The NetBSD Foundation, Inc.
@@ -37,10 +37,11 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: identcpu.c,v 1.24 2005/12/26 19:23:59 perry Exp $");
+__KERNEL_RCSID(0, "$NetBSD: identcpu.c,v 1.25 2005/12/31 17:55:55 xtraeme Exp $");
 
 #include "opt_cputype.h"
 #include "opt_enhanced_speedstep.h"
+#include "opt_powernow_k7.h"
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -130,6 +131,7 @@
 };
 
 u_int cpu_serial[3];
+u_int amd_powernow_probe(struct cpu_info *);
 char cpu_brand_string[49];
 static char amd_brand_name[48];
 
@@ -913,6 +915,20 @@
        }
 }
 
+u_int
+amd_powernow_probe(struct cpu_info *ci)
+{
+       u_int32_t       eax, ebx, ecx, edx;
+
+       CPUID(0x80000007, eax, ebx, ecx, edx);
+
+       /* checking for Freq ID control (FID) and Voltage ID control (VID) */
+       if ((edx & (0x2 | 0x4)) > 0)
+               return 1;
+
+       return 0;
+}
+
 /*
  * Transmeta Crusoe LongRun Support by Tamotsu Hattori.
  * Port from FreeBSD-current(August, 2001) to NetBSD by tshiozak.
@@ -1430,4 +1446,10 @@
        }
 #endif /* ENHANCED_SPEEDSTEP */
 
+#ifdef POWERNOW_K7
+       if (amd_powernow_probe (ci)) {
+               pnowk7_init(ci);
+       }
+#endif /* POWERNOW_K7 */
+
 }
diff -r b10a82702954 -r a202be70299c sys/arch/i386/i386/powernow_k7.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/i386/i386/powernow_k7.c  Sat Dec 31 17:55:55 2005 +0000
@@ -0,0 +1,338 @@
+/* $NetBSD: powernow_k7.c,v 1.1 2005/12/31 17:55:55 xtraeme Exp $ */
+
+/*
+ * Copyright (c) 2004 Martin Végiard.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/* AMD PowerNow! K7 driver */
+
+/* Sysctl related code was adapted from NetBSD's i386/est.c for compatibility */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: powernow_k7.c,v 1.1 2005/12/31 17:55:55 xtraeme Exp $");
+
+#include <sys/types.h>
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/malloc.h>
+#include <sys/sysctl.h>
+
+#include <dev/isa/isareg.h>
+
+#include <machine/cpu.h>
+#include <machine/isa_machdep.h>
+
+#define BIOS_START     0xe0000
+#define BIOS_END       0x20000
+#define BIOS_LEN       BIOS_END - BIOS_START
+
+#define MSR_K7_CTL     0xC0010041
+#define CTL_SET_FID    0x0000000000010000ULL
+#define CTL_SET_VID    0x0000000000020000ULL
+
+#define cpufreq(x)     fsb * fid_codes[x] / 10
+
+struct psb_s {
+       char signature[10];     /* AMDK7PNOW! */
+       uint8_t version;
+       uint8_t flags;
+       uint16_t ttime;         /* Min Settling time */
+       uint8_t reserved;
+       uint8_t n_pst;
+};
+
+struct pst_s {
+       cpuid_t cpuid;
+       uint8_t fsb;            /* Front Side Bus frequency (Mhz) */
+       uint8_t fid;            /* Max Frequency code */
+       uint8_t vid;            /* Max Voltage code */
+       uint8_t n_states;       /* Number of states */
+};     
+
+struct state_s {
+       uint8_t fid;            /* Frequency code */
+       uint8_t vid;            /* Voltage code */



Home | Main Index | Thread Index | Old Index