From owner-svn-src-all@FreeBSD.ORG Tue Jan 19 13:24:12 2010 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 14051106566B; Tue, 19 Jan 2010 13:24:12 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 02B868FC12; Tue, 19 Jan 2010 13:24:12 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o0JDOBsS001277; Tue, 19 Jan 2010 13:24:11 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o0JDOBqb001274; Tue, 19 Jan 2010 13:24:11 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201001191324.o0JDOBqb001274@svn.freebsd.org> From: Alexander Motin Date: Tue, 19 Jan 2010 13:24:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r202619 - in stable/8/sys/dev/ata: . chipsets X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Jan 2010 13:24:12 -0000 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);