[PATCH] Fix VIA 6421 SATA (cardbus) controller---ignore SATA registers

From: Andrea Bittau <a.bittau_at_cs.ucl.ac.uk>
Date: Fri, 2 Feb 2007 00:57:44 +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
_at__at_ -295,6 +295,11 _at__at_ 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++) {
_at__at_ -312,7 +317,7 _at__at_ 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;
_at__at_ -4961,8 +4966,13 _at__at_ 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
Received on Fri Feb 02 2007 - 00:30:12 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:39:05 UTC