From owner-freebsd-current@FreeBSD.ORG Fri Feb 2 01:30:12 2007 Return-Path: X-Original-To: freebsd-current@freebsd.org Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id B305E16A402; Fri, 2 Feb 2007 01:30:12 +0000 (UTC) (envelope-from a.bittau@cs.ucl.ac.uk) Received: from darkircop.org (tapir.cs.ucl.ac.uk [128.16.66.93]) by mx1.freebsd.org (Postfix) with ESMTP id 5B8E013C4AC; Fri, 2 Feb 2007 01:30:12 +0000 (UTC) (envelope-from a.bittau@cs.ucl.ac.uk) Received: by darkircop.org (Postfix, from userid 0) id 6D95F6D738; Fri, 2 Feb 2007 00:57:44 +0000 (GMT) Date: Fri, 2 Feb 2007 00:57:44 +0000 From: Andrea Bittau To: freebsd-current@freebsd.org Message-ID: <20070202005744.GA1390@shorty.sorbonet.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4.2.1i X-Echelon: Bush Bomb War KGB X-Mailman-Approved-At: Fri, 02 Feb 2007 03:26:17 +0000 Cc: sos@FreeBSD.org Subject: [PATCH] Fix VIA 6421 SATA (cardbus) controller---ignore SATA registers X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 02 Feb 2007 01:30:12 -0000 This patch makes a cardbus VIA 6421 SATA150 controller that I have work. Basically, the SATA registers on the card seemed screwed up. I don't know if it's a good idea to always try and ignore them if "bogus" [in my case, 0xFFFFFFFF] values are returned. In this patch I added a nasty quirk that does the job for me. Note, to get this particular card to work, you also need to: sysctl hw.cbb.start_32_io=0 This is needed because it uses 0xaf0 as a port. --- Index: ata-chipset.c =================================================================== RCS file: /home/ncvs/src/sys/dev/ata/ata-chipset.c,v retrieving revision 1.179 diff -u -p -r1.179 ata-chipset.c --- ata-chipset.c 4 Jan 2007 16:09:11 -0000 1.179 +++ ata-chipset.c 2 Feb 2007 00:44:20 -0000 @@ -295,6 +295,11 @@ ata_sata_connect(struct ata_channel *ch) { u_int32_t status; int timeout; + struct ata_pci_controller *ctlr; + + ctlr = device_get_softc(device_get_parent(ch->dev)); + if (ctlr->chip->chipid == ATA_VIA6421) + goto skip_sr; /* wait up to 1 second for "connect well" */ for (timeout = 0; timeout < 100 ; timeout++) { @@ -312,7 +317,7 @@ ata_sata_connect(struct ata_channel *ch) /* clear SATA error register */ ATA_IDX_OUTL(ch, ATA_SERROR, ATA_IDX_INL(ch, ATA_SERROR)); - +skip_sr: /* find out what type device we got poll for spec'd 31 seconds */ /* XXX SOS 10 secs for now as I have little patience */ ch->devices = 0; @@ -4961,8 +4966,13 @@ static void ata_via_reset(device_t dev) { struct ata_channel *ch = device_get_softc(dev); + struct ata_pci_controller *ctlr = device_get_softc(device_get_parent(dev)); - ata_sata_phy_enable(ch); + /* SATA registers are messed up on this chip---ignore them. -sorbo */ + if (ctlr->chip->chipid == ATA_VIA6421) + ata_sata_connect(ch); + else + ata_sata_phy_enable(ch); } static void