From owner-svn-src-all@FreeBSD.ORG Sun Dec 20 16:23:12 2009 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 0167D106566C; Sun, 20 Dec 2009 16:23: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 E468C8FC0C; Sun, 20 Dec 2009 16:23:11 +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 nBKGNBWf069251; Sun, 20 Dec 2009 16:23:11 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id nBKGNBpZ069248; Sun, 20 Dec 2009 16:23:11 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <200912201623.nBKGNBpZ069248@svn.freebsd.org> From: Alexander Motin Date: Sun, 20 Dec 2009 16:23:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r200754 - in head/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: Sun, 20 Dec 2009 16:23:12 -0000 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);