From sarumaru@yumi.yamayuri.org  Sun Mar  9 14:04:12 2008
Return-Path: <sarumaru@yumi.yamayuri.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 970A5106566B
	for <FreeBSD-gnats-submit@freebsd.org>; Sun,  9 Mar 2008 14:04:12 +0000 (UTC)
	(envelope-from sarumaru@yumi.yamayuri.org)
Received: from yumi.yamayuri.org (unknown [IPv6:2001:380:e02:3f:204:5fff:fe00:9621])
	by mx1.freebsd.org (Postfix) with ESMTP id 253E38FC1F
	for <FreeBSD-gnats-submit@freebsd.org>; Sun,  9 Mar 2008 14:04:11 +0000 (UTC)
	(envelope-from sarumaru@yumi.yamayuri.org)
Received: from yumi.yamayuri.org (sarumaru@localhost [127.0.0.1])
	by yumi.yamayuri.org (8.13.8/8.13.8) with ESMTP id m29E49MM008050
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO)
	for <FreeBSD-gnats-submit@freebsd.org>; Sun, 9 Mar 2008 23:04:09 +0900 (JST)
	(envelope-from sarumaru@yumi.yamayuri.org)
Received: (from sarumaru@localhost)
	by yumi.yamayuri.org (8.13.8/8.13.8/Submit) id m29E47t5008049;
	Sun, 9 Mar 2008 23:04:07 +0900 (JST)
	(envelope-from sarumaru)
Message-Id: <200803091404.m29E47t5008049@yumi.yamayuri.org>
Date: Sun, 9 Mar 2008 23:04:07 +0900 (JST)
From: Yoshihiko Sarumaru <mistral@imasy.or.jp>
Reply-To: Yoshihiko Sarumaru <mistral@imasy.or.jp>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: add VIA CX700M2 chipset to ata driver
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         121521
>Category:       kern
>Synopsis:       [ata] [patch] add VIA CX700M2 chipset to ata driver
>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 Mar 09 14:10:01 UTC 2008
>Closed-Date:    Tue Jan 19 13:45:43 UTC 2010
>Last-Modified:  Tue Jan 19 13:45:43 UTC 2010
>Originator:     Yoshihiko Sarumaru
>Release:        FreeBSD 6.3-RELEASE i386
>Organization:
>Environment:
System: FreeBSD yumi.yamayuri.org 6.2-RELEASE-p3 FreeBSD 6.2-RELEASE-p3 #0: Tue Mar 27 01:55:53 JST 2007 root@yumi.yamayuri.org:/usr/obj/usr/src/sys/YUMI i386


	
>Description:
	FreeBSD ata driver doesn't know VIA CX700M2 chipset and it fallback
	to UDMA33 mode on boot.
	This patch introduces VIA CX700M2 to FreeBSD ata driver.
	I'm not sure this chipset has AHCI feature.
	http://www.via.com.tw/en/products/chipsets/c-series/cx700m/

	before:
	atapci0: <VIA ATA controller> port 0x1f0-0x1f7,0x3f6,0x170-0x177,0x376,0xff00-0xff0f at device 15.0 on pci0
	ad2: 152627MB <Hitachi HTE541616J9AT00 SB4OA75H> at ata1-master UDMA33

	after:
	atapci0: <VIA CX700M2 SATA300 controller> port 0x1f0-0x1f7,0x3f6,0x170-0x177,0x376,0xff00-0xff0f at device 15.0 on pci0
	ad2: 152627MB <Hitachi HTE541616J9AT00 SB4OA75H> at ata1-master UDMA100
	# HTE541616J9AT00 is an UDMA100 device.

	CX700 and CX700M are also not have been added to ata driver,
	but I don't know PCI IDs of these chipsets, sorry.
>How-To-Repeat:
	
>Fix:
patch to FreeBSD 6.3-RELEASE.

--- sys/dev/ata/ata-pci.h.orig	2007-11-22 16:50:36.000000000 +0900
+++ sys/dev/ata/ata-pci.h	2008-03-09 21:41:58.000000000 +0900
@@ -374,6 +374,7 @@
 #define ATA_VIA6410             0x31641106
 #define ATA_VIA6420             0x31491106
 #define ATA_VIA6421             0x32491106
+#define ATA_VIACX700M2		0x53241106
 
 /* chipset setup related defines */
 #define AHCI            1
--- sys/dev/ata/ata-chipset.c.orig	2007-12-10 04:27:19.000000000 +0900
+++ sys/dev/ata/ata-chipset.c	2008-03-09 21:43:27.000000000 +0900
@@ -5276,6 +5276,7 @@
      { ATA_VIA8237A,  0x00, VIA133, 0x00,    ATA_UDMA6, "8237A" },
      { ATA_VIA8237S,  0x00, VIA133, 0x00,    ATA_UDMA6, "8237S" },
      { ATA_VIA8251,   0x00, VIA133, 0x00,    ATA_UDMA6, "8251" },
+     { ATA_VIACX700M2,0x00, VIA133, 0x00,    ATA_UDMA6, "CX700M2" },
      { 0, 0, 0, 0, 0, 0 }};
     static struct ata_chip_id new_ids[] =
     {{ ATA_VIA6410,   0x00, 0,      0x00,    ATA_UDMA6, "6410" },
@@ -5284,6 +5285,7 @@
      { ATA_VIA8237A,  0x00, 7,      0x00,    ATA_SA150, "8237A" },
      { ATA_VIA8237S,  0x00, 7,      0x00,    ATA_SA150, "8237S" },
      { ATA_VIA8251,   0x00, 0,      VIAAHCI, ATA_SA300, "8251" },
+     { ATA_VIACX700M2,0x00, 0,      0x00,    ATA_SA300, "CX700M2" },
      { 0, 0, 0, 0, 0, 0 }};
 
     if (pci_get_devid(dev) == ATA_VIA82C571) {
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->sos 
Responsible-Changed-By: vwe 
Responsible-Changed-When: Mon Mar 10 21:48:26 UTC 2008 
Responsible-Changed-Why:  

Over to maintainer. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=121521 
Responsible-Changed-From-To: sos->freebsd-bugs 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Tue May 12 04:48:56 UTC 2009 
Responsible-Changed-Why:  
sos@ is not actively working on ATA-related PRs. 

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

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/121521: commit references a PR
Date: Sun, 20 Dec 2009 16:23:23 +0000 (UTC)

 Author: mav
 Date: Sun Dec 20 16:23:11 2009
 New Revision: 200754
 URL: http://svn.freebsd.org/changeset/base/200754
 
 Log:
   Add VIA CX700/VX800 chipsets SATA/PATA support.
   
   PR:		kern/121521
   Tested by:	Alex Deiter
 
 Modified:
   head/sys/dev/ata/ata-pci.h
   head/sys/dev/ata/chipsets/ata-via.c
 
 Modified: head/sys/dev/ata/ata-pci.h
 ==============================================================================
 --- head/sys/dev/ata/ata-pci.h	Sun Dec 20 15:03:57 2009	(r200753)
 +++ head/sys/dev/ata/ata-pci.h	Sun Dec 20 16:23:11 2009	(r200754)
 @@ -482,6 +482,11 @@ struct ata_pci_controller {
  #define ATA_VIA6410             0x31641106
  #define ATA_VIA6420             0x31491106
  #define ATA_VIA6421             0x32491106
 +#define ATA_VIACX700IDE         0x05811106
 +#define ATA_VIACX700            0x83241106
 +#define ATA_VIASATAIDE          0x53241106
 +#define ATA_VIAVX800            0x83531106
 +#define ATA_VIAVX855            0x84091106
  
  /* global prototypes ata-pci.c */
  int ata_pci_probe(device_t dev);
 
 Modified: head/sys/dev/ata/chipsets/ata-via.c
 ==============================================================================
 --- head/sys/dev/ata/chipsets/ata-via.c	Sun Dec 20 15:03:57 2009	(r200753)
 +++ head/sys/dev/ata/chipsets/ata-via.c	Sun Dec 20 16:23:11 2009	(r200754)
 @@ -59,6 +59,9 @@ static void ata_via_reset(device_t dev);
  static int ata_via_old_setmode(device_t dev, int target, int mode);
  static void ata_via_southbridge_fixup(device_t dev);
  static int ata_via_new_setmode(device_t dev, int target, int mode);
 +static int ata_via_sata_ch_attach(device_t dev);
 +static int ata_via_sata_getrev(device_t dev, int target);
 +static int ata_via_sata_setmode(device_t dev, int target, int mode);
  
  /* misc defines */
  #define VIA33           0
 @@ -70,6 +73,7 @@ static int ata_via_new_setmode(device_t 
  #define VIABUG          0x02
  #define VIABAR          0x04
  #define VIAAHCI         0x08
 +#define VIASATA         0x10
  
  
  /*
 @@ -98,6 +102,9 @@ ata_via_probe(device_t dev)
       { ATA_VIA8237_5372, 0x00, VIA133, 0x00, ATA_UDMA6, "8237" },
       { ATA_VIA8237_7372, 0x00, VIA133, 0x00, ATA_UDMA6, "8237" },
       { ATA_VIA8251,   0x00, VIA133, 0x00,    ATA_UDMA6, "8251" },
 +     { ATA_VIACX700,  0x00, VIA133, VIASATA, ATA_SA150, "CX700" },
 +     { ATA_VIAVX800,  0x00, VIA133, VIASATA, ATA_SA150, "VX800" },
 +     { ATA_VIAVX855,  0x00, VIA133, 0x00,    ATA_UDMA6, "VX855" },
       { 0, 0, 0, 0, 0, 0 }};
      static struct ata_chip_id new_ids[] =
      {{ ATA_VIA6410,   0x00, 0,      0x00,    ATA_UDMA6, "6410" },
 @@ -113,7 +120,9 @@ ata_via_probe(device_t dev)
      if (pci_get_vendor(dev) != ATA_VIA_ID)
  	return ENXIO;
  
 -    if (pci_get_devid(dev) == ATA_VIA82C571) {
 +    if (pci_get_devid(dev) == ATA_VIA82C571 ||
 +	pci_get_devid(dev) == ATA_VIACX700IDE ||
 +	pci_get_devid(dev) == ATA_VIASATAIDE) {
  	if (!(ctlr->chip = ata_find_chip(dev, ids, -99))) 
  	    return ENXIO;
      }
 @@ -134,12 +143,21 @@ ata_via_chipinit(device_t dev)
  
      if (ata_setup_interrupt(dev, ata_generic_intr))
  	return ENXIO;
 -    
 -    if (ctlr->chip->max_dma >= ATA_SA150) {
 -	/* do we have AHCI capability ? */
 -	if ((ctlr->chip->cfg2 == VIAAHCI) && ata_ahci_chipinit(dev) != ENXIO)
 -	    return 0;
  
 +    /* AHCI SATA */
 +    if (ctlr->chip->cfg2 & VIAAHCI) {
 +	if (ata_ahci_chipinit(dev) != ENXIO)
 +	    return (0);
 +    }
 +    /* 2 SATA without SATA registers on first channel + 1 PATA on second */
 +    if (ctlr->chip->cfg2 & VIASATA) {
 +	ctlr->ch_attach = ata_via_sata_ch_attach;
 +	ctlr->setmode = ata_via_sata_setmode;
 +	ctlr->getrev = ata_via_sata_getrev;
 +	return 0;
 +    }
 +    /* Legacy SATA/SATA+PATA with SATA registers in BAR(5). */
 +    if (ctlr->chip->max_dma >= ATA_SA150) {
  	ctlr->r_type2 = SYS_RES_IOPORT;
  	ctlr->r_rid2 = PCIR_BAR(5);
  	if ((ctlr->r_res2 = bus_alloc_resource_any(dev, ctlr->r_type2,
 @@ -148,7 +166,6 @@ ata_via_chipinit(device_t dev)
  	    ctlr->ch_detach = ata_via_ch_detach;
  	    ctlr->reset = ata_via_reset;
  	}
 -
  	if (ctlr->chip->cfg2 & VIABAR) {
  	    ctlr->channels = 3;
  	    ctlr->setmode = ata_via_new_setmode;
 @@ -365,5 +382,37 @@ ata_via_southbridge_fixup(device_t dev)
      free(children, M_TEMP);
  }
  
 +static int
 +ata_via_sata_ch_attach(device_t dev)
 +{
 +	struct ata_channel *ch = device_get_softc(dev);
 +
 +	if (ata_pci_ch_attach(dev))
 +		return ENXIO;
 +	if (ch->unit == 0)
 +		ch->flags |= ATA_SATA;
 +	return (0);
 +}
 +
 +static int
 +ata_via_sata_getrev(device_t dev, int target)
 +{
 +	struct ata_channel *ch = device_get_softc(dev);
 +
 +	if (ch->unit == 0)
 +		return (1);
 +	return (0);
 +}
 +
 +static int
 +ata_via_sata_setmode(device_t dev, int target, int mode)
 +{
 +	struct ata_channel *ch = device_get_softc(dev);
 +
 +	if (ch->unit == 0)
 +		return (mode);
 +	return (ata_via_old_setmode(dev, target, mode));
 +}
 +
  ATA_DECLARE_DRIVER(ata_via);
  MODULE_DEPEND(ata_via, ata_ahci, 1, 1, 1);
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/121521: commit references a PR
Date: Tue, 19 Jan 2010 13:24:27 +0000 (UTC)

 Author: mav
 Date: Tue Jan 19 13:24:11 2010
 New Revision: 202619
 URL: http://svn.freebsd.org/changeset/base/202619
 
 Log:
   MFC r200754:
   Add VIA CX700/VX800 chipsets SATA/PATA support.
   
   PR:             kern/121521
 
 Modified:
   stable/8/sys/dev/ata/ata-pci.h
   stable/8/sys/dev/ata/chipsets/ata-via.c
 Directory Properties:
   stable/8/sys/   (props changed)
   stable/8/sys/amd64/include/xen/   (props changed)
   stable/8/sys/cddl/contrib/opensolaris/   (props changed)
   stable/8/sys/contrib/dev/acpica/   (props changed)
   stable/8/sys/contrib/pf/   (props changed)
   stable/8/sys/dev/xen/xenpci/   (props changed)
 
 Modified: stable/8/sys/dev/ata/ata-pci.h
 ==============================================================================
 --- stable/8/sys/dev/ata/ata-pci.h	Tue Jan 19 13:21:25 2010	(r202618)
 +++ stable/8/sys/dev/ata/ata-pci.h	Tue Jan 19 13:24:11 2010	(r202619)
 @@ -482,6 +482,11 @@ struct ata_pci_controller {
  #define ATA_VIA6410             0x31641106
  #define ATA_VIA6420             0x31491106
  #define ATA_VIA6421             0x32491106
 +#define ATA_VIACX700IDE         0x05811106
 +#define ATA_VIACX700            0x83241106
 +#define ATA_VIASATAIDE          0x53241106
 +#define ATA_VIAVX800            0x83531106
 +#define ATA_VIAVX855            0x84091106
  
  /* global prototypes ata-pci.c */
  int ata_pci_probe(device_t dev);
 
 Modified: stable/8/sys/dev/ata/chipsets/ata-via.c
 ==============================================================================
 --- stable/8/sys/dev/ata/chipsets/ata-via.c	Tue Jan 19 13:21:25 2010	(r202618)
 +++ stable/8/sys/dev/ata/chipsets/ata-via.c	Tue Jan 19 13:24:11 2010	(r202619)
 @@ -59,6 +59,9 @@ static void ata_via_reset(device_t dev);
  static int ata_via_old_setmode(device_t dev, int target, int mode);
  static void ata_via_southbridge_fixup(device_t dev);
  static int ata_via_new_setmode(device_t dev, int target, int mode);
 +static int ata_via_sata_ch_attach(device_t dev);
 +static int ata_via_sata_getrev(device_t dev, int target);
 +static int ata_via_sata_setmode(device_t dev, int target, int mode);
  
  /* misc defines */
  #define VIA33           0
 @@ -70,6 +73,7 @@ static int ata_via_new_setmode(device_t 
  #define VIABUG          0x02
  #define VIABAR          0x04
  #define VIAAHCI         0x08
 +#define VIASATA         0x10
  
  
  /*
 @@ -98,6 +102,9 @@ ata_via_probe(device_t dev)
       { ATA_VIA8237_5372, 0x00, VIA133, 0x00, ATA_UDMA6, "8237" },
       { ATA_VIA8237_7372, 0x00, VIA133, 0x00, ATA_UDMA6, "8237" },
       { ATA_VIA8251,   0x00, VIA133, 0x00,    ATA_UDMA6, "8251" },
 +     { ATA_VIACX700,  0x00, VIA133, VIASATA, ATA_SA150, "CX700" },
 +     { ATA_VIAVX800,  0x00, VIA133, VIASATA, ATA_SA150, "VX800" },
 +     { ATA_VIAVX855,  0x00, VIA133, 0x00,    ATA_UDMA6, "VX855" },
       { 0, 0, 0, 0, 0, 0 }};
      static struct ata_chip_id new_ids[] =
      {{ ATA_VIA6410,   0x00, 0,      0x00,    ATA_UDMA6, "6410" },
 @@ -113,7 +120,9 @@ ata_via_probe(device_t dev)
      if (pci_get_vendor(dev) != ATA_VIA_ID)
  	return ENXIO;
  
 -    if (pci_get_devid(dev) == ATA_VIA82C571) {
 +    if (pci_get_devid(dev) == ATA_VIA82C571 ||
 +	pci_get_devid(dev) == ATA_VIACX700IDE ||
 +	pci_get_devid(dev) == ATA_VIASATAIDE) {
  	if (!(ctlr->chip = ata_find_chip(dev, ids, -99))) 
  	    return ENXIO;
      }
 @@ -134,12 +143,21 @@ ata_via_chipinit(device_t dev)
  
      if (ata_setup_interrupt(dev, ata_generic_intr))
  	return ENXIO;
 -    
 -    if (ctlr->chip->max_dma >= ATA_SA150) {
 -	/* do we have AHCI capability ? */
 -	if ((ctlr->chip->cfg2 == VIAAHCI) && ata_ahci_chipinit(dev) != ENXIO)
 -	    return 0;
  
 +    /* AHCI SATA */
 +    if (ctlr->chip->cfg2 & VIAAHCI) {
 +	if (ata_ahci_chipinit(dev) != ENXIO)
 +	    return (0);
 +    }
 +    /* 2 SATA without SATA registers on first channel + 1 PATA on second */
 +    if (ctlr->chip->cfg2 & VIASATA) {
 +	ctlr->ch_attach = ata_via_sata_ch_attach;
 +	ctlr->setmode = ata_via_sata_setmode;
 +	ctlr->getrev = ata_via_sata_getrev;
 +	return 0;
 +    }
 +    /* Legacy SATA/SATA+PATA with SATA registers in BAR(5). */
 +    if (ctlr->chip->max_dma >= ATA_SA150) {
  	ctlr->r_type2 = SYS_RES_IOPORT;
  	ctlr->r_rid2 = PCIR_BAR(5);
  	if ((ctlr->r_res2 = bus_alloc_resource_any(dev, ctlr->r_type2,
 @@ -148,7 +166,6 @@ ata_via_chipinit(device_t dev)
  	    ctlr->ch_detach = ata_via_ch_detach;
  	    ctlr->reset = ata_via_reset;
  	}
 -
  	if (ctlr->chip->cfg2 & VIABAR) {
  	    ctlr->channels = 3;
  	    ctlr->setmode = ata_via_new_setmode;
 @@ -365,5 +382,37 @@ ata_via_southbridge_fixup(device_t dev)
      free(children, M_TEMP);
  }
  
 +static int
 +ata_via_sata_ch_attach(device_t dev)
 +{
 +	struct ata_channel *ch = device_get_softc(dev);
 +
 +	if (ata_pci_ch_attach(dev))
 +		return ENXIO;
 +	if (ch->unit == 0)
 +		ch->flags |= ATA_SATA;
 +	return (0);
 +}
 +
 +static int
 +ata_via_sata_getrev(device_t dev, int target)
 +{
 +	struct ata_channel *ch = device_get_softc(dev);
 +
 +	if (ch->unit == 0)
 +		return (1);
 +	return (0);
 +}
 +
 +static int
 +ata_via_sata_setmode(device_t dev, int target, int mode)
 +{
 +	struct ata_channel *ch = device_get_softc(dev);
 +
 +	if (ch->unit == 0)
 +		return (mode);
 +	return (ata_via_old_setmode(dev, target, mode));
 +}
 +
  ATA_DECLARE_DRIVER(ata_via);
  MODULE_DEPEND(ata_via, ata_ahci, 1, 1, 1);
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: open->closed 
State-Changed-By: mav 
State-Changed-When: Tue Jan 19 13:45:16 UTC 2010 
State-Changed-Why:  
Patch merged to 8-STABLE. 

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