Subject: VIA VT6410 IDE support
To: None <port-i386@netbsd.org>
From: Takahiro Kambe <taca@back-street.net>
List: port-i386
Date: 03/30/2007 15:31:15
Hi,

Recently, I need to install NetBSD to NEC's desktop PC which has
Intel's serial ATA and VIA's IDE connecting CD-ROM drive.

Since it was VIA's VT6410, I tried for viaide(4) to recognize it.
It seems that viaide(4) assume existence of VIA's PCI-ISA bridge if
IDE controller is VIA's one.

Anywaym here is my quick change.

-- 
Takahiro Kambe <taca@back-street.net>


cvs diff: Diffing sys/dev/pci
Index: sys/dev/pci/pcidevs
===================================================================
RCS file: /cvs/src-4/sys/dev/pci/pcidevs,v
retrieving revision 1.1.1.1.2.3
diff -u -r1.1.1.1.2.3 pcidevs
--- sys/dev/pci/pcidevs	23 Mar 2007 09:19:11 -0000	1.1.1.1.2.3
+++ sys/dev/pci/pcidevs	30 Mar 2007 01:48:13 -0000
@@ -3572,6 +3572,7 @@
 product VIATECH VT8623		0x3123	VT8623 (Apollo CLE266) CPU-PCI Bridge
 product VIATECH VT8233A		0x3147	VT8233A PCI-ISA Bridge
 product VIATECH VT8237_SATA	0x3149	VT8237 Integrated SATA Controller
+product VIATECH VT6410_IDE	0x3164	VT6410 IDE Controller
 product	VIATECH VT3314_IG	0x3344	VT3314 CN900 UniChrome Integrated Graphics
 product VIATECH VT8237R_SATA	0x3349	VT8237R Integrated SATA Controller
 product VIATECH VT6421_RAID	0x3249	VT6421 Serial RAID Controller
Index: sys/dev/pci/pcidevs.h
===================================================================
RCS file: /cvs/src-4/sys/dev/pci/pcidevs.h,v
retrieving revision 1.1.1.1.2.3
diff -u -r1.1.1.1.2.3 pcidevs.h
--- sys/dev/pci/pcidevs.h	23 Mar 2007 09:19:11 -0000	1.1.1.1.2.3
+++ sys/dev/pci/pcidevs.h	30 Mar 2007 01:48:13 -0000
@@ -3579,6 +3579,7 @@
 #define	PCI_PRODUCT_VIATECH_VT8623	0x3123		/* VT8623 (Apollo CLE266) CPU-PCI Bridge */
 #define	PCI_PRODUCT_VIATECH_VT8233A	0x3147		/* VT8233A PCI-ISA Bridge */
 #define	PCI_PRODUCT_VIATECH_VT8237_SATA	0x3149		/* VT8237 Integrated SATA Controller */
+#define	PCI_PRODUCT_VIATECH_VT6410_IDE	0x3164		/* VT6410 IDE Controller */
 #define	PCI_PRODUCT_VIATECH_VT3314_IG	0x3344		/* VT3314 CN900 UniChrome Integrated Graphics */
 #define	PCI_PRODUCT_VIATECH_VT8237R_SATA	0x3349		/* VT8237R Integrated SATA Controller */
 #define	PCI_PRODUCT_VIATECH_VT6421_RAID	0x3249		/* VT6421 Serial RAID Controller */
Index: sys/dev/pci/pcidevs_data.h
===================================================================
RCS file: /cvs/src-4/sys/dev/pci/pcidevs_data.h,v
retrieving revision 1.1.1.1.2.3
diff -u -r1.1.1.1.2.3 pcidevs_data.h
--- sys/dev/pci/pcidevs_data.h	23 Mar 2007 09:19:12 -0000	1.1.1.1.2.3
+++ sys/dev/pci/pcidevs_data.h	30 Mar 2007 01:48:13 -0000
@@ -12240,6 +12240,10 @@
 	    "VT8237 Integrated SATA Controller",
 	},
 	{
+	    PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VT6410_IDE,
+	    "VT6410 IDE Controller",
+	},
+	{
 	    PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VT3314_IG,
 	    "VT3314 CN900 UniChrome Integrated Graphics",
 	},
@@ -12836,4 +12840,4 @@
 	    "Video Controller",
 	},
 };
-const int pci_nproducts = 2615;
+const int pci_nproducts = 2616;
Index: sys/dev/pci/viaide.c
===================================================================
RCS file: /cvs/src-4/sys/dev/pci/viaide.c,v
retrieving revision 1.1.1.1.2.1
diff -u -r1.1.1.1.2.1 viaide.c
--- sys/dev/pci/viaide.c	19 Feb 2007 10:00:54 -0000	1.1.1.1.2.1
+++ sys/dev/pci/viaide.c	30 Mar 2007 01:48:13 -0000
@@ -278,6 +278,11 @@
 	  "VIA Technologies VT8237R SATA Controller",
 	  via_sata_chip_map_0,
 	},
+	{ PCI_PRODUCT_VIATECH_VT6410_IDE,
+	  0,
+	  NULL,
+	  via_chip_map,
+	},
 	{ 0,
 	  0,
 	  NULL,
@@ -353,74 +358,84 @@
 
 	switch (vendor) {
 	case PCI_VENDOR_VIATECH:
-		/*
-		 * get a PCI tag for the ISA bridge.
-		 */
-		if (pci_find_device(&pcib_pa, via_pcib_match) == 0)
-			goto unknown;
-		pcib_id = pcib_pa.pa_id;
-		pcib_class = pcib_pa.pa_class;
-		aprint_normal("%s: VIA Technologies ",
-		    sc->sc_wdcdev.sc_atac.atac_dev.dv_xname);
-		switch (PCI_PRODUCT(pcib_id)) {
-		case PCI_PRODUCT_VIATECH_VT82C586_ISA:
-			aprint_normal("VT82C586 (Apollo VP) ");
-			if(PCI_REVISION(pcib_class) >= 0x02) {
-				aprint_normal("ATA33 controller\n");
-				sc->sc_wdcdev.sc_atac.atac_udma_cap = 2;
-			} else {
-				aprint_normal("controller\n");
-				sc->sc_wdcdev.sc_atac.atac_udma_cap = 0;
-			}
-			break;
-		case PCI_PRODUCT_VIATECH_VT82C596A:
-			aprint_normal("VT82C596A (Apollo Pro) ");
-			if (PCI_REVISION(pcib_class) >= 0x12) {
-				aprint_normal("ATA66 controller\n");
-				sc->sc_wdcdev.sc_atac.atac_udma_cap = 4;
-			} else {
-				aprint_normal("ATA33 controller\n");
-				sc->sc_wdcdev.sc_atac.atac_udma_cap = 2;
-			}
+		switch (PCI_PRODUCT(pa->pa_id)) {
+		case PCI_PRODUCT_VIATECH_VT6410_IDE:
+			aprint_normal("%s: VIA Technologies %s\n",
+				      sc->sc_wdcdev.sc_atac.atac_dev.dv_xname,
+				      "VT6410 IDE controller");
+			sc->sc_wdcdev.sc_atac.atac_udma_cap = 6;
 			break;
-		case PCI_PRODUCT_VIATECH_VT82C686A_ISA:
-			aprint_normal("VT82C686A (Apollo KX133) ");
-			if (PCI_REVISION(pcib_class) >= 0x40) {
-				aprint_normal("ATA100 controller\n");
+		default:
+			/*
+			 * get a PCI tag for the ISA bridge.
+			 */
+			if (pci_find_device(&pcib_pa, via_pcib_match) == 0)
+				goto unknown;
+			pcib_id = pcib_pa.pa_id;
+			pcib_class = pcib_pa.pa_class;
+			aprint_normal("%s: VIA Technologies ",
+			    sc->sc_wdcdev.sc_atac.atac_dev.dv_xname);
+			switch (PCI_PRODUCT(pcib_id)) {
+			case PCI_PRODUCT_VIATECH_VT82C586_ISA:
+				aprint_normal("VT82C586 (Apollo VP) ");
+				if(PCI_REVISION(pcib_class) >= 0x02) {
+					aprint_normal("ATA33 controller\n");
+					sc->sc_wdcdev.sc_atac.atac_udma_cap = 2;
+				} else {
+					aprint_normal("controller\n");
+					sc->sc_wdcdev.sc_atac.atac_udma_cap = 0;
+				}
+				break;
+			case PCI_PRODUCT_VIATECH_VT82C596A:
+				aprint_normal("VT82C596A (Apollo Pro) ");
+				if (PCI_REVISION(pcib_class) >= 0x12) {
+					aprint_normal("ATA66 controller\n");
+					sc->sc_wdcdev.sc_atac.atac_udma_cap = 4;
+				} else {
+					aprint_normal("ATA33 controller\n");
+					sc->sc_wdcdev.sc_atac.atac_udma_cap = 2;
+				}
+				break;
+			case PCI_PRODUCT_VIATECH_VT82C686A_ISA:
+				aprint_normal("VT82C686A (Apollo KX133) ");
+				if (PCI_REVISION(pcib_class) >= 0x40) {
+					aprint_normal("ATA100 controller\n");
+					sc->sc_wdcdev.sc_atac.atac_udma_cap = 5;
+				} else {
+					aprint_normal("ATA66 controller\n");
+					sc->sc_wdcdev.sc_atac.atac_udma_cap = 4;
+				}
+				break;
+			case PCI_PRODUCT_VIATECH_VT8231:
+				aprint_normal("VT8231 ATA100 controller\n");
 				sc->sc_wdcdev.sc_atac.atac_udma_cap = 5;
-			} else {
-				aprint_normal("ATA66 controller\n");
-				sc->sc_wdcdev.sc_atac.atac_udma_cap = 4;
+				break;
+			case PCI_PRODUCT_VIATECH_VT8233:
+				aprint_normal("VT8233 ATA100 controller\n");
+				sc->sc_wdcdev.sc_atac.atac_udma_cap = 5;
+				break;
+			case PCI_PRODUCT_VIATECH_VT8233A:
+				aprint_normal("VT8233A ATA133 controller\n");
+				sc->sc_wdcdev.sc_atac.atac_udma_cap = 6;
+				break;
+			case PCI_PRODUCT_VIATECH_VT8235:
+				aprint_normal("VT8235 ATA133 controller\n");
+				sc->sc_wdcdev.sc_atac.atac_udma_cap = 6;
+				break;
+			case PCI_PRODUCT_VIATECH_VT8237:
+				aprint_normal("VT8237 ATA133 controller\n");
+				sc->sc_wdcdev.sc_atac.atac_udma_cap = 6;
+				break;
+			case PCI_PRODUCT_VIATECH_VT8237A_ISA:
+				aprint_normal("VT8237A ATA133 controller\n");
+				sc->sc_wdcdev.sc_atac.atac_udma_cap = 6;
+				break;
+			default:
+		unknown:
+				aprint_normal("unknown VIA ATA controller\n");
+				sc->sc_wdcdev.sc_atac.atac_udma_cap = 0;
 			}
 			break;
-		case PCI_PRODUCT_VIATECH_VT8231:
-			aprint_normal("VT8231 ATA100 controller\n");
-			sc->sc_wdcdev.sc_atac.atac_udma_cap = 5;
-			break;
-		case PCI_PRODUCT_VIATECH_VT8233:
-			aprint_normal("VT8233 ATA100 controller\n");
-			sc->sc_wdcdev.sc_atac.atac_udma_cap = 5;
-			break;
-		case PCI_PRODUCT_VIATECH_VT8233A:
-			aprint_normal("VT8233A ATA133 controller\n");
-			sc->sc_wdcdev.sc_atac.atac_udma_cap = 6;
-			break;
-		case PCI_PRODUCT_VIATECH_VT8235:
-			aprint_normal("VT8235 ATA133 controller\n");
-			sc->sc_wdcdev.sc_atac.atac_udma_cap = 6;
-			break;
-		case PCI_PRODUCT_VIATECH_VT8237:
-			aprint_normal("VT8237 ATA133 controller\n");
-			sc->sc_wdcdev.sc_atac.atac_udma_cap = 6;
-			break;
-		case PCI_PRODUCT_VIATECH_VT8237A_ISA:
-			aprint_normal("VT8237A ATA133 controller\n");
-			sc->sc_wdcdev.sc_atac.atac_udma_cap = 6;
-			break;
-		default:
-unknown:
-			aprint_normal("unknown VIA ATA controller\n");
-			sc->sc_wdcdev.sc_atac.atac_udma_cap = 0;
 		}
 		sc->sc_apo_regbase = APO_VIA_REGBASE;
 		break;
cvs diff: Diffing sys/dev/pci/bktr