Current-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: viaide SATA DVD support



hi

At Thu, 17 Sep 2009 02:33:33 -0500,
David Huang wrote:
> I recently installed a SATA DVD burner in my -current (5.99.17 from  
> 2009/09/15) amd64 system, and NetBSD probes it as a wd0 ST506:
  :
> Anything I can do to help debug/fix this? I notice it initially says  
> "viaide1: port 0: scnt=0x3 sn=0x1 cl=0x0 ch=0x8", but later says  
> "viaide1:0:0: after reset, sc=0x1 sn=0x1 cl=0x14 ch=0xeb", which looks  
> better (it has the 0xeb14 ATAPI signature, at least). However, it  
> still didn't attach to atapibus...

how about attached patch?
(same patch filed in kern/41926)

--
FUKAUMI Naoki
Index: sys/dev/ic/wdc.c
===================================================================
RCS file: /home/fun/cvsroot/NetBSD/src/sys/dev/ic/wdc.c,v
retrieving revision 1.255.4.1
diff -u -p -r1.255.4.1 wdc.c
--- sys/dev/ic/wdc.c    20 Nov 2008 02:45:36 -0000      1.255.4.1
+++ sys/dev/ic/wdc.c    17 Aug 2009 18:16:31 -0000
@@ -209,7 +209,7 @@ void
 wdc_sataprobe(struct ata_channel *chp)
 {
        struct wdc_regs *wdr = CHAN_TO_WDC_REGS(chp);
-       uint16_t scnt, sn, cl, ch;
+       uint8_t st = 0, sc, sn, cl, ch;
        int i, s;
 
        /* XXX This should be done by other code. */
@@ -222,23 +222,34 @@ wdc_sataprobe(struct ata_channel *chp)
        switch (sata_reset_interface(chp, wdr->sata_iot, wdr->sata_control,
            wdr->sata_status)) {
        case SStatus_DET_DEV:
-               bus_space_write_1(wdr->cmd_iot, wdr->cmd_iohs[wd_sdh], 0,
-                   WDSD_IBM);
-               delay(10);      /* 400ns delay */
-               scnt = bus_space_read_2(wdr->cmd_iot,
+               /* wait 5s for BSY to clear */
+               for (i = 0; i < WDC_PROBE_WAIT * hz; i++) {
+                       bus_space_write_1(wdr->cmd_iot,
+                           wdr->cmd_iohs[wd_sdh], 0, WDSD_IBM);
+                       delay(10);      /* 400ns delay */
+                       st = bus_space_read_1(wdr->cmd_iot,
+                           wdr->cmd_iohs[wd_status], 0);
+                       if ((st & WDCS_BSY) == 0)
+                               break;
+                       tsleep(&chp, PRIBIO, "sataprb", 1);
+               }
+               if (i == WDC_PROBE_WAIT * hz)
+                       aprint_error_dev(chp->ch_atac->atac_dev,
+                           "BSY never cleared, status 0x%02x\n", st);
+               sc = bus_space_read_1(wdr->cmd_iot,
                    wdr->cmd_iohs[wd_seccnt], 0);
-               sn = bus_space_read_2(wdr->cmd_iot,
+               sn = bus_space_read_1(wdr->cmd_iot,
                    wdr->cmd_iohs[wd_sector], 0);
-               cl = bus_space_read_2(wdr->cmd_iot,
+               cl = bus_space_read_1(wdr->cmd_iot,
                    wdr->cmd_iohs[wd_cyl_lo], 0);
-               ch = bus_space_read_2(wdr->cmd_iot,
+               ch = bus_space_read_1(wdr->cmd_iot,
                    wdr->cmd_iohs[wd_cyl_hi], 0);
-               ATADEBUG_PRINT(("%s: port %d: scnt=0x%x sn=0x%x "
+               ATADEBUG_PRINT(("%s: port %d: sc=0x%x sn=0x%x "
                    "cl=0x%x ch=0x%x\n",
                    device_xname(chp->ch_atac->atac_dev), chp->ch_channel,
-                   scnt, sn, cl, ch), DEBUG_PROBE);
+                   sc, sn, cl, ch), DEBUG_PROBE);
                /*
-                * scnt and sn are supposed to be 0x1 for ATAPI, but in some
+                * sc and sn are supposed to be 0x1 for ATAPI, but in some
                 * cases we get wrong values here, so ignore it.
                 */
                s = splbio();


Home | Main Index | Thread Index | Old Index