Index: amd64/conf/GENERIC =================================================================== RCS file: /cvsroot/src/sys/arch/amd64/conf/GENERIC,v retrieving revision 1.352 diff -u -p -r1.352 GENERIC --- amd64/conf/GENERIC 7 Apr 2012 05:39:55 -0000 1.352 +++ amd64/conf/GENERIC 13 Apr 2012 12:58:28 -0000 @@ -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 Index: amd64/conf/XEN3_DOM0 =================================================================== RCS file: /cvsroot/src/sys/arch/amd64/conf/XEN3_DOM0,v retrieving revision 1.81 diff -u -p -r1.81 XEN3_DOM0 --- amd64/conf/XEN3_DOM0 10 Mar 2012 21:51:48 -0000 1.81 +++ amd64/conf/XEN3_DOM0 13 Apr 2012 12:58:28 -0000 @@ -296,7 +296,8 @@ lpt0 at isa? port 0x378 irq 7 # standard # 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 Index: i386/conf/ALL =================================================================== RCS file: /cvsroot/src/sys/arch/i386/conf/ALL,v retrieving revision 1.335 diff -u -p -r1.335 ALL --- i386/conf/ALL 10 Apr 2012 23:59:47 -0000 1.335 +++ i386/conf/ALL 13 Apr 2012 12:58:28 -0000 @@ -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 Index: i386/conf/GENERIC =================================================================== RCS file: /cvsroot/src/sys/arch/i386/conf/GENERIC,v retrieving revision 1.1070 diff -u -p -r1.1070 GENERIC --- i386/conf/GENERIC 8 Apr 2012 20:49:29 -0000 1.1070 +++ i386/conf/GENERIC 13 Apr 2012 12:58:28 -0000 @@ -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 Index: i386/conf/XEN3_DOM0 =================================================================== RCS file: /cvsroot/src/sys/arch/i386/conf/XEN3_DOM0,v retrieving revision 1.64 diff -u -p -r1.64 XEN3_DOM0 --- i386/conf/XEN3_DOM0 10 Mar 2012 21:51:53 -0000 1.64 +++ i386/conf/XEN3_DOM0 13 Apr 2012 12:58:28 -0000 @@ -273,7 +273,8 @@ lpt0 at isa? port 0x378 irq 7 # standard # 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 Index: x86/pci/amdnb_misc.c =================================================================== RCS file: x86/pci/amdnb_misc.c diff -N x86/pci/amdnb_misc.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ x86/pci/amdnb_misc.c 13 Apr 2012 12:58:28 -0000 @@ -0,0 +1,104 @@ +/* $NetBSD: $ */ +/* + * 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: $"); + +#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; +} Index: x86/pci/amdtemp.c =================================================================== RCS file: /cvsroot/src/sys/arch/x86/pci/amdtemp.c,v retrieving revision 1.14 diff -u -p -r1.14 amdtemp.c --- x86/pci/amdtemp.c 13 Apr 2012 12:14:41 -0000 1.14 +++ x86/pci/amdtemp.c 13 Apr 2012 12:58:28 -0000 @@ -189,19 +189,7 @@ amdtemp_match(device_t parent, cfdata_t 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 if (family > 0x15) return 0; - return 2; /* supercede pchb(4) */ + return 1; } static void Index: x86/pci/files.pci =================================================================== RCS file: /cvsroot/src/sys/arch/x86/pci/files.pci,v retrieving revision 1.13 diff -u -p -r1.13 files.pci --- x86/pci/files.pci 18 Aug 2011 20:55:20 -0000 1.13 +++ x86/pci/files.pci 13 Apr 2012 12:58:28 -0000 @@ -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_hpe 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