From olli@lurza.secnetix.de  Sun Nov 23 13:42:00 2003
Return-Path: <olli@lurza.secnetix.de>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id DA28216A4CF
	for <FreeBSD-gnats-submit@freebsd.org>; Sun, 23 Nov 2003 13:41:38 -0800 (PST)
Received: from lurza.secnetix.de (lurza.secnetix.de [195.143.231.20])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 7BB3143FBF
	for <FreeBSD-gnats-submit@freebsd.org>; Sun, 23 Nov 2003 13:41:37 -0800 (PST)
	(envelope-from olli@lurza.secnetix.de)
Received: from lurza.secnetix.de (jsbapq@localhost [127.0.0.1])
	by lurza.secnetix.de (8.12.9p2/8.12.9) with ESMTP id hANLfZb0083429;
	Sun, 23 Nov 2003 22:41:35 +0100 (CET)
	(envelope-from oliver.fromme@secnetix.de)
Received: (from olli@localhost)
	by lurza.secnetix.de (8.12.9p2/8.12.9/Submit) id hANLfZtC083428;
	Sun, 23 Nov 2003 22:41:35 +0100 (CET)
	(envelope-from olli)
Message-Id: <200311232141.hANLfZtC083428@lurza.secnetix.de>
Date: Sun, 23 Nov 2003 22:41:35 +0100 (CET)
From: Oliver Fromme <olli@secnetix.de>
Reply-To: Oliver Fromme <olli@secnetix.de>
To: FreeBSD-gnats-submit@freebsd.org
Cc: Oliver Fromme <olli@secnetix.de>
Subject: [PATCH] HightPoint HPT371 support for FreeBSD 4.9
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         59624
>Category:       kern
>Synopsis:       [ata] [patch] HightPoint HPT371 support for FreeBSD 4.9
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Sun Nov 23 13:50:19 PST 2003
>Closed-Date:    Fri Dec 29 19:43:45 GMT 2006
>Last-Modified:  Fri Dec 29 19:43:45 GMT 2006
>Originator:     Oliver Fromme
>Release:        FreeBSD 4.9-RELEASE i386
>Organization:
secnetix GmbH & Co. KG, Munich, Germany, www.secnetix.de
>Environment:
System: FreeBSD dorifer.fromme.com 4.9-RELEASE FreeBSD 4.9-RELEASE #2: Sun Nov 23 19:54:31 CET 2003 olli@dorifer.fromme.com:/usr/src/sys/compile/DORIFER i386

>Description:

Support for the HighPoint HPT371 EIDE controller has been
committed to 5-current on 2003-06-19, but so far it has not
been MFCed to -stable (because of a very different driver
structure, I guess).

However, since the HPT371 is sufficiently similar to the
HPT372, adding support is not very difficult (see the patch
below).

>How-To-Repeat:

Boot a FreeBSD 4.9 machine with a HighPoint HPT371 EIDE
controller:

   pci0: <unknown card> (vendor=0x1103, dev=0x0007) at 11.0 irq 10

And with the below patch:

   atapci0: <HighPoint HPT371 ATA133 controller> port 0xb000-0xb0ff,0xac00-0xac03,0xa800-0xa807,0xa400-0xa403,0xa000-0xa007 irq 10 at device 11.0 on pci0

>Fix:

--- src/sys/dev/ata/ata-dma.c.orig	Sun Oct 26 20:27:16 2003
+++ src/sys/dev/ata/ata-dma.c	Sun Nov 23 19:53:32 2003
@@ -1187,10 +1187,12 @@
     
     case 0x00041103:	/* HighPoint HPT366/368/370/372 controllers */
     case 0x00051103:	/* HighPoint HPT372 controllers */
+    case 0x00071103:	/* HighPoint HPT371 controllers */
     case 0x00081103:	/* HighPoint HPT374 controllers */
 	if (!ATAPI_DEVICE(atadev) && udmamode >= 6 && hpt_cable80(atadev) &&
 	    ((chiptype == 0x00041103 && chiprev >= 0x05) ||
 	     (chiptype == 0x00051103 && chiprev >= 0x01) ||
+	     (chiptype == 0x00071103 && chiprev >= 0x01) ||
 	     (chiptype == 0x00081103 && chiprev >= 0x07))) {
 	    error = ata_command(atadev, ATA_C_SETFEATURES, 0,
 				ATA_UDMA6, ATA_C_F_SETXFER, ATA_WAIT_READY);
@@ -1206,6 +1208,7 @@
 	if (!ATAPI_DEVICE(atadev) && udmamode >= 5 && hpt_cable80(atadev) &&
 	    ((chiptype == 0x00041103 && chiprev >= 0x03) ||
 	     (chiptype == 0x00051103 && chiprev >= 0x01) ||
+	     (chiptype == 0x00071103 && chiprev >= 0x01) ||
 	     (chiptype == 0x00081103 && chiprev >= 0x07))) {
 	    error = ata_command(atadev, ATA_C_SETFEATURES, 0,
 				ATA_UDMA5, ATA_C_F_SETXFER, ATA_WAIT_READY);
@@ -1532,8 +1535,9 @@
 	}
     }
     else if ((chiptype == 0x00041103 && chiprev >= 0x05) ||
-	     (chiptype == 0x00051103 && chiprev >= 0x01)) {
-	switch (mode) {						/* HPT372 */
+	     (chiptype == 0x00051103 && chiprev >= 0x01) ||
+	     (chiptype == 0x00071103 && chiprev >= 0x01)) {
+	switch (mode) {					/* HPT372, HPT371 */
 	case ATA_PIO0:	timing = 0x0d029d5e; break;
 	case ATA_PIO1:	timing = 0x0d029d26; break;
 	case ATA_PIO2:	timing = 0x0c829ca6; break;
--- src/sys/dev/ata/ata-pci.c.orig	Wed Oct 22 16:43:52 2003
+++ src/sys/dev/ata/ata-pci.c	Sun Nov 23 19:51:04 2003
@@ -315,6 +315,13 @@
 	}
 	return NULL;
 
+    case 0x00071103:
+	switch (pci_get_revid(dev)) {
+	case 0x01:
+	    return "HighPoint HPT371 ATA133 controller";
+	}
+	return NULL;
+
     case 0x00081103:
 	switch (pci_get_revid(dev)) {
 	case 0x07:
@@ -447,6 +454,7 @@
 	/* FALLTHROUGH */
 
     case 0x00051103:	/* HighPoint HPT372 */
+    case 0x00071103:	/* HighPoint HPT371 */
     case 0x00081103:	/* HighPoint HPT374 */
 	/* turn off interrupt prediction */
 	pci_write_config(dev, 0x51, (pci_read_config(dev, 0x51, 1) & ~0x03), 1);
@@ -567,6 +575,7 @@
     switch (ch->chiptype) {
     case 0x00041103:	/* HighPoint HPT366/368/370/372 */
     case 0x00051103:	/* HighPoint HPT372 */
+    case 0x00071103:	/* HighPoint HPT371 */
     case 0x00081103:	/* HighPoint HPT374 */
 	if (((dmastat = ata_dmastatus(ch)) &
 	    (ATA_BMSTAT_ACTIVE | ATA_BMSTAT_INTERRUPT)) != ATA_BMSTAT_INTERRUPT)
--- src/share/man/man4/ata.4.orig	Wed Oct 16 15:40:51 2002
+++ src/share/man/man4/ata.4	Sun Nov 23 22:22:16 2003
@@ -101,6 +101,8 @@
 Ultra DMA 66 (UDMA4), 66 MB/sec
 .It HighPoint HPT370
 Ultra DMA 100 (UDMA5), 100 MB/sec
+.It HighPoint HPT371
+Ultra DMA 133 (UDMA6), 133 MB/sec
 .It HighPoint HPT372
 Ultra DMA 133 (UDMA6), 133 MB/sec
 .It HighPoint HPT374

>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: remko 
State-Changed-When: Fri Dec 29 19:43:42 UTC 2006 
State-Changed-Why:  
I see that there is support for the HPT371 card now, not exactly the 
same as your diff, but it's there. Thanks for your willingness to 
improve FreeBSD and the patch though! 

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