Subject: kern/32284: amdpm(4) support for AMD8111 chipset
To: None <kern-bug-people@netbsd.org, gnats-admin@netbsd.org,>
From: None <njoly@pasteur.fr>
List: netbsd-bugs
Date: 12/12/2005 10:10:01
>Number:         32284
>Category:       kern
>Synopsis:       amdpm(4) support for AMD8111 chipset
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Dec 12 10:10:00 +0000 2005
>Originator:     Nicolas Joly
>Release:        NetBSD 3.99.14
>Organization:
Institut Pasteur, Paris.
>Environment:
System: NetBSD lanfeust.sis.pasteur.fr 3.99.14 NetBSD 3.99.14 (LANFEUST) #5: Mon Dec 12 10:45:08 CET 2005 njoly@lanfeust.sis.pasteur.fr:/local/src/NetBSD/obj/amd64/sys/arch/amd64/compile/LANFEUST amd64
Architecture: x86_64
Machine: amd64
>Description:
The AMD8111 chipset has a `Power Management Controller' (currently named
as `ACPI Controller' in pcidevs) which is compatible with amdpm(4).

njoly@lanfeust [~]> pcictl pci0 dump -d 7 -f 3  | head
PCI configuration registers:
  Common header:
    0x00: 0x746b1022 0x02800000 0x06800005 0x00004000

    Vendor Name: Advanced Micro Devices (0x1022)
    Device Name: AMD8111 ACPI Controller (0x746b)
    Command register: 0x0000
      I/O space accesses: off
      Memory space accesses: off
      Bus mastering: off

The following patch allows use of random number generator on AMD8111 chipset.

njoly@lanfeust [~]> dmesg | grep amdpm
amdpm0 at pci0 dev 7 function 3: Advanced Micro Devices AMD8111 ACPI Controller (rev. 0x05)
amdpm0: random number generator enabled (apprx. 58ms)

njoly@lanfeust [~]> sudo rndctl -l
Source                 Bits Type      Flags
cd0                       0 disk estimate, collect
wd1                     256 disk estimate, collect
wd0                    3200 disk estimate, collect
fd0                       0 disk estimate, collect
pms0                     62 tty  estimate, collect
pckbd0                    0 tty  estimate, collect
amdpm0              3798848 rng  collect

While here, i added some missing device description.
>How-To-Repeat:
n/a
>Fix:
Index: sys/dev/pci/amdpm.c
===================================================================
RCS file: /cvsroot/src/sys/dev/pci/amdpm.c,v
retrieving revision 1.9
diff -u -r1.9 amdpm.c
--- sys/dev/pci/amdpm.c	4 Dec 2005 17:47:33 -0000	1.9
+++ sys/dev/pci/amdpm.c	12 Dec 2005 09:50:17 -0000
@@ -85,9 +85,15 @@
 {
 	struct pci_attach_args *pa = aux;
 
-	if (PCI_VENDOR(pa->pa_id) == PCI_VENDOR_AMD &&
-	    PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_AMD_PBC768_PMC)
+	if (PCI_VENDOR(pa->pa_id) != PCI_VENDOR_AMD)
+		return (0);
+
+	switch (PCI_PRODUCT(pa->pa_id)) {
+	case PCI_PRODUCT_AMD_PBC768_PMC:
+	case PCI_PRODUCT_AMD_PBC8111_ACPI:
 		return (1);
+	}
+
 	return (0);
 }
 
@@ -96,12 +102,14 @@
 {
 	struct amdpm_softc *sc = (struct amdpm_softc *) self;
 	struct pci_attach_args *pa = aux;
+	char devinfo[256];
 	pcireg_t reg;
 	u_int32_t pmreg;
 	int i;
 
 	aprint_naive("\n");
-	aprint_normal("\n");
+	pci_devinfo(pa->pa_id, pa->pa_class, 0, devinfo, sizeof(devinfo));
+	aprint_normal(": %s (rev. 0x%02x)\n", devinfo, PCI_REVISION(pa->pa_class));
 
 	sc->sc_pc = pa->pa_pc;
 	sc->sc_tag = pa->pa_tag;