diff --git a/sys/arch/amd64/conf/GENERIC b/sys/arch/amd64/conf/GENERIC index 7e8e13fcc3aa..bfda31515f23 100644 --- a/sys/arch/amd64/conf/GENERIC +++ b/sys/arch/amd64/conf/GENERIC @@ -1,4 +1,4 @@ -# $NetBSD: GENERIC,v 1.352 2012/04/07 05:39:55 christos Exp $ +# $NetBSD: GENERIC,v 1.353 2012/04/13 13:11:16 cegger Exp $ # # GENERIC machine description file # @@ -22,7 +22,7 @@ include "arch/amd64/conf/std.amd64" options INCLUDE_CONFIG_FILE # embed config file in kernel binary -#ident "GENERIC-$Revision: 1.352 $" +#ident "GENERIC-$Revision: 1.353 $" maxusers 64 # estimated number of users @@ -440,7 +440,8 @@ lpt1 at isa? port 0x278 # Hardware monitors -amdtemp* at pchb? # AMD CPU Temperature sensors +amdnb_misc* at pci? # AMD NB Misc Configuration +amdtemp* at amdnb_misc? # AMD CPU Temperature sensors # Winbond LPC Super I/O #wbsio* at isa? port 0x2e diff --git a/sys/arch/amd64/conf/XEN3_DOM0 b/sys/arch/amd64/conf/XEN3_DOM0 index 143991fb639e..ec9821a31549 100644 --- a/sys/arch/amd64/conf/XEN3_DOM0 +++ b/sys/arch/amd64/conf/XEN3_DOM0 @@ -1,4 +1,4 @@ -# $NetBSD: XEN3_DOM0,v 1.81 2012/03/10 21:51:48 joerg Exp $ +# $NetBSD: XEN3_DOM0,v 1.82 2012/04/13 13:11:16 cegger Exp $ include "arch/amd64/conf/std.xen" @@ -296,7 +296,8 @@ lpt0 at isa? port 0x378 irq 7 # standard PC parallel ports # Hardware monitors -amdtemp* at pchb? # AMD CPU Temperature sensors +amdnb_misc* at pci? # AMD NB Misc Configuration +amdtemp* at amdnb_misc? # AMD CPU Temperature sensors # AMD 768 and 8111 power/ACPI controllers amdpm* at pci? dev ? function ? # RNG and SMBus 1.0 interface diff --git a/sys/arch/i386/conf/ALL b/sys/arch/i386/conf/ALL index 1c77f56a04a5..b1373d702207 100644 --- a/sys/arch/i386/conf/ALL +++ b/sys/arch/i386/conf/ALL @@ -1,4 +1,4 @@ -# $NetBSD: ALL,v 1.335 2012/04/10 23:59:47 christos Exp $ +# $NetBSD: ALL,v 1.336 2012/04/13 13:11:16 cegger Exp $ # From NetBSD: GENERIC,v 1.787 2006/10/01 18:37:54 bouyer Exp # # ALL machine description file @@ -17,7 +17,7 @@ include "arch/i386/conf/std.i386" options INCLUDE_CONFIG_FILE # embed config file in kernel binary -#ident "ALL-$Revision: 1.335 $" +#ident "ALL-$Revision: 1.336 $" maxusers 64 # estimated number of users @@ -470,7 +470,8 @@ elanpar* at elansc? elanpex* at elansc? # Temperatures -amdtemp* at pchb? # AMD CPU Temperature sensors +amdnb_misc* at pci? # AMD NB Misc Configuration +amdtemp* at amdnb_misc? # AMD CPU Temperature sensors # PCI bridges amdpcib* at pci? dev ? function ? # AMD 8111 PCI-ISA w/ HPET diff --git a/sys/arch/i386/conf/GENERIC b/sys/arch/i386/conf/GENERIC index 73720bcb9883..3e1882d512d3 100644 --- a/sys/arch/i386/conf/GENERIC +++ b/sys/arch/i386/conf/GENERIC @@ -1,4 +1,4 @@ -# $NetBSD: GENERIC,v 1.1070 2012/04/08 20:49:29 christos Exp $ +# $NetBSD: GENERIC,v 1.1071 2012/04/13 13:11:16 cegger Exp $ # # GENERIC machine description file # @@ -22,7 +22,7 @@ include "arch/i386/conf/std.i386" options INCLUDE_CONFIG_FILE # embed config file in kernel binary -#ident "GENERIC-$Revision: 1.1070 $" +#ident "GENERIC-$Revision: 1.1071 $" maxusers 64 # estimated number of users @@ -446,7 +446,8 @@ pci* at elansc? bus ? elansc* at mainbus? bus ? # AMD Elan SC520 System Controller # Temperatures -amdtemp* at pchb? # AMD CPU Temperature sensors +amdnb_misc* at pci? # AMD NB Misc Configuration +amdtemp* at amdnb_misc? # AMD CPU Temperature sensors # PCI bridges #amdpcib* at pci? dev ? function ? # AMD 8111 PCI-ISA w/ HPET diff --git a/sys/arch/i386/conf/XEN3_DOM0 b/sys/arch/i386/conf/XEN3_DOM0 index ae7d1ba38679..80a060f533cf 100644 --- a/sys/arch/i386/conf/XEN3_DOM0 +++ b/sys/arch/i386/conf/XEN3_DOM0 @@ -1,4 +1,4 @@ -# $NetBSD: XEN3_DOM0,v 1.64 2012/03/10 21:51:53 joerg Exp $ +# $NetBSD: XEN3_DOM0,v 1.65 2012/04/13 13:11:16 cegger Exp $ # # XEN3_0: Xen 3.0 domain0 kernel @@ -273,7 +273,8 @@ lpt0 at isa? port 0x378 irq 7 # standard PC parallel ports # Hardware monitors -amdtemp* at pchb? # AMD CPU Temperature sensors +amdnb_misc* at pci? # AMD NB Misc Configuration +amdtemp* at amdnb_misc? # AMD CPU Temperature sensors # AMD 768 and 8111 power/ACPI controllers amdpm* at pci? dev ? function ? # RNG and SMBus 1.0 interface diff --git a/sys/arch/x86/pci/amdnb_misc.c b/sys/arch/x86/pci/amdnb_misc.c new file mode 100644 index 000000000000..a7e14449b908 --- /dev/null +++ b/sys/arch/x86/pci/amdnb_misc.c @@ -0,0 +1,104 @@ +/* $NetBSD: amdnb_misc.c,v 1.1 2012/04/13 13:11:17 cegger Exp $ */ +/* + * Copyright (c) 2012 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Christoph Egger. + * + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``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 FOUNDATION OR CONTRIBUTORS + * 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. + */ + +#include +__KERNEL_RCSID(0, "$NetBSD: amdnb_misc.c,v 1.1 2012/04/13 13:11:17 cegger Exp $"); + +#include +#include + +#include +#include +#include + +static int amdnb_misc_match(device_t, cfdata_t match, void *); +static void amdnb_misc_attach(device_t, device_t, void *); +static int amdnb_misc_detach(device_t, int); + +CFATTACH_DECL_NEW(amdnb_misc, 0, + amdnb_misc_match, amdnb_misc_attach, amdnb_misc_detach, NULL); + + +static int +amdnb_misc_match(device_t parent, cfdata_t match, void *aux) +{ + struct pci_attach_args *pa = aux; + + if (PCI_VENDOR(pa->pa_id) != PCI_VENDOR_AMD) + return 0; + + switch (PCI_PRODUCT(pa->pa_id)) { + case PCI_PRODUCT_AMD_AMD64_MISC: + case PCI_PRODUCT_AMD_AMD64_F10_MISC: + case PCI_PRODUCT_AMD_AMD64_F11_MISC: + case PCI_PRODUCT_AMD_F14_NB: /* Family 12h, too */ + case PCI_PRODUCT_AMD_F15_MISC: + break; + default: + return 0; + } + + return 2; /* supercede pchb(4) */ +} + +static int +amdnb_misc_search(device_t parent, cfdata_t cf, const int *locs, void *aux) +{ + if (config_match(parent, cf, aux)) + config_attach_loc(parent, cf, locs, aux, NULL); + + return 0; +} + +static void +amdnb_misc_attach(device_t parent, device_t self, void *aux) +{ + aprint_naive("\n"); + aprint_normal(": AMD NB Misc Configuration\n"); + + if (!pmf_device_register(self, NULL, NULL)) + aprint_error_dev(self, "couldn't establish power handler\n"); + + config_search_loc(amdnb_misc_search, self, "amdnb_miscbus", NULL, aux); + return; +} + +static int +amdnb_misc_detach(device_t self, int flags) +{ + int rv; + + rv = config_detach_children(self, flags); + if (rv != 0) + return rv; + + pmf_device_deregister(self); + return rv; +} diff --git a/sys/arch/x86/pci/amdtemp.c b/sys/arch/x86/pci/amdtemp.c index b84382e3aaea..e35ab531930a 100644 --- a/sys/arch/x86/pci/amdtemp.c +++ b/sys/arch/x86/pci/amdtemp.c @@ -1,4 +1,4 @@ -/* $NetBSD: amdtemp.c,v 1.14 2012/04/13 12:14:41 cegger Exp $ */ +/* $NetBSD: amdtemp.c,v 1.15 2012/04/13 13:11:17 cegger Exp $ */ /* $OpenBSD: kate.c,v 1.2 2008/03/27 04:52:03 cnst Exp $ */ /* @@ -48,7 +48,7 @@ #include -__KERNEL_RCSID(0, "$NetBSD: amdtemp.c,v 1.14 2012/04/13 12:14:41 cegger Exp $ "); +__KERNEL_RCSID(0, "$NetBSD: amdtemp.c,v 1.15 2012/04/13 13:11:17 cegger Exp $ "); #include #include @@ -189,19 +189,7 @@ amdtemp_match(device_t parent, cfdata_t match, void *aux) pcireg_t cpu_signature; uint32_t family; - if (PCI_VENDOR(pa->pa_id) != PCI_VENDOR_AMD) - return 0; - - switch (PCI_PRODUCT(pa->pa_id)) { - case PCI_PRODUCT_AMD_AMD64_MISC: - case PCI_PRODUCT_AMD_AMD64_F10_MISC: - case PCI_PRODUCT_AMD_AMD64_F11_MISC: - case PCI_PRODUCT_AMD_F14_NB: /* Family12h too */ - case PCI_PRODUCT_AMD_F15_MISC: - break; - default: - return 0; - } + KASSERT(PCI_VENDOR(pa->pa_id) == PCI_VENDOR_AMD); cpu_signature = pci_conf_read(pa->pa_pc, pa->pa_tag, CPUID_FAMILY_MODEL_R); @@ -229,7 +217,7 @@ amdtemp_match(device_t parent, cfdata_t match, void *aux) if (family > 0x15) return 0; - return 2; /* supercede pchb(4) */ + return 1; } static void diff --git a/sys/arch/x86/pci/files.pci b/sys/arch/x86/pci/files.pci index 6bf1883b4851..7e5cefa0b5e2 100644 --- a/sys/arch/x86/pci/files.pci +++ b/sys/arch/x86/pci/files.pci @@ -1,4 +1,4 @@ -# $NetBSD: files.pci,v 1.13 2011/08/18 20:55:20 jakllsch Exp $ +# $NetBSD: files.pci,v 1.14 2012/04/13 13:11:17 cegger Exp $ device aapic attach aapic at pci @@ -6,9 +6,10 @@ file arch/x86/pci/aapic.c aapic file arch/x86/pci/agp_machdep.c agp +define amdnb_miscbus {} + # PCI-Host bridge chipsets -define amdtempbus {} -device pchb: pcibus, agpbus, amdtempbus, +device pchb: pcibus, agpbus, agp_ali, agp_amd, agp_amd64, agp_i810, agp_intel, agp_sis, agp_via attach pchb at pci @@ -28,8 +29,12 @@ attach hpet at amdpcib with amdpcib_hpet file arch/x86/pci/amdpcib_hpet.c amdpcib_hpet # AMD Processors -- Miscellaneous Control +device amdnb_misc: amdnb_miscbus +attach amdnb_misc at pci +file arch/x86/pci/amdnb_misc.c amdnb_misc + device amdtemp: sysmon_envsys -attach amdtemp at amdtempbus +attach amdtemp at amdnb_miscbus file arch/x86/pci/amdtemp.c amdtemp # PCI-LPC bridges