From mike@flux.utah.edu  Tue Jan 21 11:21:07 2003
Return-Path: <mike@flux.utah.edu>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id A9A7337B401
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 21 Jan 2003 11:21:07 -0800 (PST)
Received: from bas.flux.utah.edu (bas.flux.utah.edu [155.98.60.2])
	by mx1.FreeBSD.org (Postfix) with ESMTP id D0A5C43ED8
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 21 Jan 2003 11:21:06 -0800 (PST)
	(envelope-from mike@flux.utah.edu)
Received: from bas.flux.utah.edu (localhost [127.0.0.1])
	by bas.flux.utah.edu (8.12.5/8.12.5) with ESMTP id h0LJL6pF077901
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 21 Jan 2003 12:21:06 -0700 (MST)
	(envelope-from mike@bas.flux.utah.edu)
Received: (from mike@localhost)
	by bas.flux.utah.edu (8.12.5/8.12.5/Submit) id h0LJL6iD077900;
	Tue, 21 Jan 2003 12:21:06 -0700 (MST)
Message-Id: <200301211921.h0LJL6iD077900@bas.flux.utah.edu>
Date: Tue, 21 Jan 2003 12:21:06 -0700 (MST)
From: Mike Hibler <mike@cs.utah.edu>
Reply-To: Mike Hibler <mike@cs.utah.edu>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: [PATCH] Kernel support for NVIDIA nForce2-based motherboards
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         47311
>Category:       kern
>Synopsis:       [patch] Kernel support for NVIDIA nForce2-based motherboards
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    mdodd
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Tue Jan 21 11:30:01 PST 2003
>Closed-Date:    Thu Aug 30 03:48:25 GMT 2007
>Last-Modified:  Thu Aug 30 03:48:25 GMT 2007
>Originator:     Mike Hibler
>Release:        FreeBSD 4.6-STABLE i386
>Organization:
University of Utah
>Environment:
System: FreeBSD bas.flux.utah.edu 4.6-STABLE FreeBSD 4.6-STABLE #1: Mon Sep 9 14:33:29 MDT 2002 root@bas.flux.utah.edu:/usr/src/sys/compile/BAS i386

Applies to FreeBSD-stable as of late December.

>Description:

Adds support for (or at least recognition of) various devices on NVIDIA
nForce2 motherboards: various PCI bridges, memory controller, ATA
controller, USB 1.x controller, AC97 audio.

Also adds support for 3Com NIC + Altima AC101L PHY found on ASUS A7N8X MB.

NO support for the builtin NVIDIA NIC or advanced audio capabilities.

This patch subsumes kern/46660 from <rrs@mx1.net> and also an audio patch
posted by <atrens@nortelnetworks.com> and reflects additional input and
testing from <stevelon@ntlworld.com>.

Note: the capitalization of "NVIDIA" has been changed to be consistent
with their web page.

>How-To-Repeat:

>Fix:

diff -r -u ./dev/ata/ata-dma.c /tmp/sys/dev/ata/ata-dma.c
--- ./dev/ata/ata-dma.c	Thu Oct  3 03:37:48 2002
+++ /tmp/sys/dev/ata/ata-dma.c	Sun Dec 22 15:02:46 2002
@@ -372,7 +372,8 @@
 	/* we could set PIO mode timings, but we assume the BIOS did that */
 	break;
 
-    case 0x01bc10de:	/* nVIDIA nForce */
+    case 0x01bc10de:	/* NVIDIA nForce */
+    case 0x006510de:	/* NVIDIA nForce2 */
     case 0x74411022:	/* AMD 768 */
     case 0x74111022:	/* AMD 766 */
     case 0x74091022:	/* AMD 756 */
@@ -383,7 +384,7 @@
 		{ 0x00, 0x00, 0xea, 0x00, 0xe8, 0x00, 0x00 },	/* ATA66 */
 		{ 0x00, 0x00, 0xf4, 0x00, 0xf1, 0xf0, 0x00 },	/* ATA100 */
 		{ 0x00, 0x00, 0xf6, 0x00, 0xf2, 0xf1, 0xf0 },   /* VIA ATA133 */
-		{ 0x00, 0x00, 0xc0, 0x00, 0xc5, 0xc6, 0x00 }};  /* AMD/nVIDIA */
+		{ 0x00, 0x00, 0xc0, 0x00, 0xc5, 0xc6, 0xc7 }};  /* AMD/NVIDIA */
 	    int *reg_val = NULL;
 	    char *chip = "VIA";
 
@@ -424,10 +425,15 @@
 		reg_val = via_modes[4];
 		chip = "AMD";
 	    }
-	    else if (ch->chiptype == 0x01bc10de) {		/* nVIDIA */
+	    else if (ch->chiptype == 0x01bc10de) {		/* nForce */
 		udmamode = imin(udmamode, 5);
 		reg_val = via_modes[4];
-		chip = "nVIDIA";
+		chip = "NVIDIA";
+	    }
+	    else if (ch->chiptype == 0x006510de) {		/* nForce2 */
+		udmamode = imin(udmamode, 6);
+		reg_val = via_modes[4];
+		chip = "NVIDIA";
 	    }
 	    else 
 		udmamode = 0;
diff -r -u ./dev/ata/ata-pci.c /tmp/sys/dev/ata/ata-pci.c
--- ./dev/ata/ata-pci.c	Thu Oct  3 03:37:48 2002
+++ /tmp/sys/dev/ata/ata-pci.c	Mon Dec 23 10:55:21 2002
@@ -237,7 +237,10 @@
 	return "AMD 768 ATA100 controller";
 
     case 0x01bc10de:
-	return "nVIDIA nForce ATA100 controller";
+	return "NVIDIA nForce ATA100 controller";
+
+    case 0x006510de:
+	return "NVIDIA nForce2 ATA133 controller";
 
     case 0x02111166:
 	return "ServerWorks ROSB4 ATA33 controller";
@@ -469,7 +472,8 @@
     case 0x74091022: /* AMD 756 default setup */
     case 0x74111022: /* AMD 766 default setup */
     case 0x74411022: /* AMD 768 default setup */
-    case 0x01bc10de: /* nVIDIA nForce default setup */
+    case 0x01bc10de: /* NVIDIA nForce default setup */
+    case 0x006510de: /* NVIDIA nForce2 default setup */
 	/* set prefetch, postwrite */
 	pci_write_config(dev, 0x41, pci_read_config(dev, 0x41, 1) | 0xf0, 1);
 
diff -r -u ./dev/mii/acphy.c /tmp/sys/dev/mii/acphy.c
--- ./dev/mii/acphy.c	Tue Oct 22 03:39:38 2002
+++ /tmp/sys/dev/mii/acphy.c	Mon Dec 23 11:12:03 2002
@@ -126,9 +126,17 @@
 
 	ma = device_get_ivars(dev);
 
-	if (MII_OUI(ma->mii_id1, ma->mii_id2) == MII_OUI_xxALTIMA &&
-	    MII_MODEL(ma->mii_id2) == MII_MODEL_xxALTIMA_AC101) {
-		device_set_desc(dev, MII_STR_xxALTIMA_AC101);
+	if (MII_OUI(ma->mii_id1, ma->mii_id2) == MII_OUI_xxALTIMA) {
+		switch (MII_MODEL(ma->mii_id2)) {
+		case MII_MODEL_xxALTIMA_AC101:
+			device_set_desc(dev, MII_STR_xxALTIMA_AC101);
+			break;
+		case MII_MODEL_xxALTIMA_AC101L:
+			device_set_desc(dev, MII_STR_xxALTIMA_AC101L);
+			break;
+		default:
+			return (ENXIO);
+		}
 	} else 
 		return (ENXIO);
 
@@ -279,7 +287,7 @@
 {
 	struct mii_data *mii = sc->mii_pdata;
 	struct ifmedia_entry *ife = mii->mii_media.ifm_cur;
-	int bmsr, bmcr, diag;
+	int bmsr, bmcr, diag, anlpar, id;
 
 	mii->mii_media_status = IFM_AVALID;
 	mii->mii_media_active = IFM_ETHER;
@@ -305,14 +313,51 @@
 			mii->mii_media_active |= IFM_NONE;
 			return;
 		}
-		diag = PHY_READ(sc, MII_ACPHY_DIAG);
-		if (diag & AC_DIAG_SPEED)
-			mii->mii_media_active |= IFM_100_TX;
-		else
-			mii->mii_media_active |= IFM_10_T;
 
-		if (diag & AC_DIAG_DUPLEX)
-			mii->mii_media_active |= IFM_FDX;
+		/*
+		 * AC101 has bits in the dianostic register reporting
+		 * the results of auto-negotiation.
+		 */
+		id = PHY_READ(sc, MII_PHYIDR2);
+		if (MII_MODEL(id) == MII_MODEL_xxALTIMA_AC101) {
+			diag = PHY_READ(sc, MII_ACPHY_DIAG);
+			if (diag & AC_DIAG_SPEED)
+				mii->mii_media_active |= IFM_100_TX;
+			else
+				mii->mii_media_active |= IFM_10_T;
+
+			if (diag & AC_DIAG_DUPLEX)
+				mii->mii_media_active |= IFM_FDX;
+
+			return;
+		}
+
+		/*
+		 * Have to figure it out ourselves on the 101L
+		 */
+		if (PHY_READ(sc, MII_ANER) & ANER_LPAN) {
+			anlpar = PHY_READ(sc, MII_ANAR) &
+			    PHY_READ(sc, MII_ANLPAR);
+			if (anlpar & ANLPAR_T4)
+				mii->mii_media_active |= IFM_100_T4;
+			else if (anlpar & ANLPAR_TX_FD)
+				mii->mii_media_active |= IFM_100_TX|IFM_FDX;
+			else if (anlpar & ANLPAR_TX)
+				mii->mii_media_active |= IFM_100_TX;
+			else if (anlpar & ANLPAR_10_FD)
+				mii->mii_media_active |= IFM_10_T|IFM_FDX;
+			else if (anlpar & ANLPAR_10)
+				mii->mii_media_active |= IFM_10_T;
+			else
+				mii->mii_media_active |= IFM_NONE;
+			return;
+		}
+
+		/*
+		 * Link partner is not capable of autonegotiation.
+		 */
+		mii->mii_media_active = mii_media_from_bmcr(bmcr);
+
 	} else
 		mii->mii_media_active = ife->ifm_media;
 }
diff -r -u ./dev/mii/miidevs /tmp/sys/dev/mii/miidevs
--- ./dev/mii/miidevs	Thu Dec 12 03:56:54 2002
+++ /tmp/sys/dev/mii/miidevs	Mon Dec 23 11:26:06 2002
@@ -97,6 +97,7 @@
 
 /* Altima Communications PHYs */
 model xxALTIMA AC101		0x0021 AC101 10/100 media interface
+model xxALTIMA AC101L		0x0012 AC101L 10/100 media interface
 
 /* Advanced Micro Devices PHYs */
 model xxAMD 79C873		0x0000 Am79C873 10/100 media interface
diff -r -u ./dev/mii/miidevs.h /tmp/sys/dev/mii/miidevs.h
--- ./dev/mii/miidevs.h	Thu Dec 12 03:56:54 2002
+++ /tmp/sys/dev/mii/miidevs.h	Mon Dec 23 11:26:35 2002
@@ -105,6 +105,8 @@
 /* Altima Communications PHYs */
 #define	MII_MODEL_xxALTIMA_AC101	0x0021
 #define	MII_STR_xxALTIMA_AC101	"AC101 10/100 media interface"
+#define	MII_MODEL_xxALTIMA_AC101L	0x0012
+#define	MII_STR_xxALTIMA_AC101L	"AC101L 10/100 media interface"
 
 /* Advanced Micro Devices PHYs */
 #define	MII_MODEL_xxAMD_79C873	0x0000
diff -r -u ./pci/if_xl.c /tmp/sys/pci/if_xl.c
--- ./pci/if_xl.c	Thu Nov 28 03:56:24 2002
+++ /tmp/sys/pci/if_xl.c	Mon Dec 23 11:23:18 2002
@@ -212,6 +212,8 @@
 		"3Com 3c656B Fast Etherlink XL" },
 	{ TC_VENDORID, TC_DEVICEID_TORNADO_656C,
 		"3Com 3c656C Fast Etherlink XL" },
+	{ TC_VENDORID, TC_DEVICEID_NFORCE2_10_100,
+		"3Com nForce2 integrated fast etherlink" },
 	{ 0, 0, NULL }
 };
 
@@ -1213,6 +1215,7 @@
 	case TC_DEVICEID_HURRICANE_656:		/* 3c656 */
 	case TC_DEVICEID_HURRICANE_656B:	/* 3c656B */
 	case TC_DEVICEID_TORNADO_656C:		/* 3c656C */
+	case TC_DEVICEID_NFORCE2_10_100:	/* NVIDIA nForce2 integrated */
 		sc->xl_media = XL_MEDIAOPT_MII;
 		sc->xl_xcvr = XL_XCVR_MII;
 		if (verbose)
@@ -1284,6 +1287,8 @@
 		sc->xl_flags |= XL_FLAG_8BITROM;
 	if (pci_get_device(dev) == TC_DEVICEID_HURRICANE_556B)
 		sc->xl_flags |= XL_FLAG_NO_XCVR_PWR;
+	if (pci_get_device(dev) == TC_DEVICEID_NFORCE2_10_100)
+		sc->xl_flags |= XL_FLAG_PHYOK;
 
 	if (pci_get_device(dev) == TC_DEVICEID_HURRICANE_575A ||
 	    pci_get_device(dev) == TC_DEVICEID_HURRICANE_575B ||
diff -r -u ./pci/if_xlreg.h /tmp/sys/pci/if_xlreg.h
--- ./pci/if_xlreg.h	Tue Nov 12 03:37:57 2002
+++ /tmp/sys/pci/if_xlreg.h	Mon Dec 23 11:13:33 2002
@@ -669,6 +669,7 @@
 #define TC_DEVICEID_HURRICANE_656		0x6560
 #define TC_DEVICEID_HURRICANE_656B		0x6562
 #define TC_DEVICEID_TORNADO_656C		0x6564
+#define TC_DEVICEID_NFORCE2_10_100		0x9201
 
 /*
  * PCI low memory base and low I/O base register, and
diff -r -u ./pci/ohci_pci.c /tmp/sys/pci/ohci_pci.c
--- ./pci/ohci_pci.c	Thu Aug 29 03:42:03 2002
+++ /tmp/sys/pci/ohci_pci.c	Sat Dec 21 23:26:02 2002
@@ -79,6 +79,7 @@
 #define PCI_OHCI_VENDORID_NEC		0x1033
 #define PCI_OHCI_VENDORID_OPTI		0x1045
 #define PCI_OHCI_VENDORID_SIS		0x1039
+#define PCI_OHCI_VENDORID_NVIDIA	0x10de
 
 #define PCI_OHCI_DEVICEID_ALADDIN_V	0x523710b9
 static const char *ohci_device_aladdin_v = "AcerLabs M5237 (Aladdin-V) USB controller";
@@ -107,6 +108,9 @@
 #define PCI_OHCI_DEVICEID_KEYLARGO	0x0019106b
 static const char *ohci_device_keylargo = "Apple KeyLargo USB controller";
 
+#define PCI_OHCI_DEVICEID_NVIDIANF2	0x006710de
+static const char *ohci_device_nvidianf2 = "NVIDIA nForce2 USB controller";
+
 static const char *ohci_device_generic = "OHCI (generic) USB controller";
 
 #define PCI_OHCI_BASE_REG	0x10
@@ -139,6 +143,8 @@
 		return (ohci_device_sis5571);
 	case PCI_OHCI_DEVICEID_KEYLARGO:
 		return (ohci_device_keylargo);
+	case PCI_OHCI_DEVICEID_NVIDIANF2:
+		return (ohci_device_nvidianf2);
 	default:
 		if (pci_get_class(self) == PCIC_SERIALBUS
 		    && pci_get_subclass(self) == PCIS_SERIALBUS_USB
@@ -222,6 +228,9 @@
 		break;
 	case PCI_OHCI_VENDORID_SIS:
 		sprintf(sc->sc_vendor, "SiS");
+		break;
+	case PCI_OHCI_VENDORID_NVIDIA:
+		sprintf(sc->sc_vendor, "NVIDIA");
 		break;
 	default:
 		if (bootverbose)
diff -r -u ./pci/pcisupport.c /tmp/sys/pci/pcisupport.c
--- ./pci/pcisupport.c	Thu Nov 28 03:56:25 2002
+++ /tmp/sys/pci/pcisupport.c	Mon Dec 23 11:36:13 2002
@@ -695,6 +695,13 @@
 	case 0x1a318086:
 		return ("Intel 82845 PCI-PCI (AGP) bridge");
 	
+	/* NVIDIA -- vendor 0x10de */
+	case 0x006c10de:
+	case 0x006d10de:
+		return ("NVIDIA nForce2 PCI-PCI bridge");
+	case 0x01e810de:
+		return ("NVIDIA nForce2 PCI-PCI (AGP) bridge");
+
 	/* VLSI -- vendor 0x1004 */
 	case 0x01021004:
 		return ("VLSI 82C534 Eagle II PCI Bus bridge");
@@ -906,6 +913,10 @@
 	case 0x24408086:
 		return ("Intel 82801BA/BAM (ICH2) PCI to LPC bridge");
 	
+	/* NVIDIA -- vendor 0x10de */
+	case 0x006010de:
+		return ("NVIDIA nForce2 PCI-ISA bridge");
+
 	/* VLSI -- vendor 0x1004 */
 	case 0x00061004:
 		return ("VLSI 82C593 PCI to ISA bridge");
@@ -1072,6 +1083,10 @@
 		return ("CMD Tech 670 (USB0670) USB controller");
 	case 0x06731095:
 		return ("CMD Tech 673 (USB0673) USB controller");
+
+	/* NVIDIA -- vendor 0x10de */
+	case 0x006710de:
+		return ("NVIDIA nForce2 USB controller");
 	}
 
 	if (pci_get_class(dev) == PCIC_SERIALBUS
@@ -1230,6 +1245,14 @@
 		return ("Intel 82801AA (ICH) AC'97 Audio Controller");
 	case 0x24258086:
 		return ("Intel 82801AB (ICH0) AC'97 Audio Controller");
+
+	/* NVIDIA -- vendor 0x10de */
+	case 0x01eb10de:
+	case 0x01ec10de:
+	case 0x01ed10de:
+	case 0x01ee10de:
+	case 0x01ef10de:
+		return ("NVIDIA nForce2 memory controller");
 
 	/* Sony -- vendor 0x104d */
 	case 0x8009104d:
diff -r -u ./dev/sound/pci/ich.c /tmp/dev/sound/pci/ich.c
--- ./dev/sound/pci/ich.c	Sun Dec 29 23:41:37 2002
+++ /tmp/dev/sound/pci/ich.c	Sun Dec 29 23:33:25 2002
@@ -624,7 +624,15 @@
 		return 0;
 
 	case 0x01b110de:
-		device_set_desc(dev, "Nvidia nForce AC97 controller");
+		device_set_desc(dev, "NVIDIA nForce AC97 controller");
+		return 0;
+
+	case 0x006a10de:
+		device_set_desc(dev, "NVIDIA nForce2 Audio Codec");
+		return 0;
+
+	case 0x006b10de:
+		device_set_desc(dev, "NVIDIA nForce2 MCP Audio Processing Unit");
 		return 0;
 
 	default:


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->mdodd 
Responsible-Changed-By: kris 
Responsible-Changed-When: Mon Jul 14 04:29:52 PDT 2003 
Responsible-Changed-Why:  
mdodd is interested in nvidia support 

http://www.freebsd.org/cgi/query-pr.cgi?pr=47311 

From: Gavin Atkinson <gavin.atkinson@ury.york.ac.uk>
To: bug-followup@FreeBSD.org, mike@cs.utah.edu
Cc:  
Subject: Re: kern/47311: [patch] Kernel support for NVIDIA nForce2-based
	motherboards
Date: Wed, 30 May 2007 20:17:07 +0100

 Hi,
 
 Is any of this still needed on a more recent version of FreeBSD?  From
 looking at your patch and the source, everything now seems to be
 supported apart from the network card, which I haven't been able to
 confirm as there are extra bits in your patch to what exists in the
 source.
 
 Are you able to confirm if any of this patch is still needed?
 
 Thanks,
 
 Gavin

From: Mike Hibler <mike@flux.utah.edu>
To: Gavin Atkinson <gavin.atkinson@ury.york.ac.uk>
Cc: bug-followup@FreeBSD.org, mike@cs.utah.edu
Subject: Re: kern/47311: [patch] Kernel support for NVIDIA nForce2-based motherboards
Date: Wed, 30 May 2007 13:30:40 -0600

 I don't run FreeBSD on that MB any more, but I am fairly certain that
 everything has been integrated.  Support for that nvidia network chip
 is provided via the net/nvnet port.
 
 On Wed, May 30, 2007 at 08:17:07PM +0100, Gavin Atkinson wrote:
 > Hi,
 > 
 > Is any of this still needed on a more recent version of FreeBSD?  From
 > looking at your patch and the source, everything now seems to be
 > supported apart from the network card, which I haven't been able to
 > confirm as there are extra bits in your patch to what exists in the
 > source.
 > 
 > Are you able to confirm if any of this patch is still needed?
 > 
 > Thanks,
 > 
 > Gavin
State-Changed-From-To: open->closed 
State-Changed-By: rodrigc 
State-Changed-When: Thu Aug 30 03:46:43 UTC 2007 
State-Changed-Why:  
Support for nVidia nForce2 motherboards has been integrated 
into FreeBSD 6 and higher, in slightly different ways from this patch. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=47311 
>Unformatted:
