Subject: Re: Promise Ultra66/100 vs 48-bit LBA compliant drives
To: Takeshi Nakayama <tn@catvmics.ne.jp>
From: Alexander Yurchenko <grange@rt.mipt.ru>
List: tech-kern
Date: 07/20/2003 23:17:13
On Mon, Jul 07, 2003 at 07:57:08PM +0900, Takeshi Nakayama wrote:
> > Why you suppose that 0x20 in the FreeBSD's source means ATAPI port? More
> > likely it's General Purpose Register, PDC262_SCR_GEN_LAT. Did you try to
> > connect your LBA48 drive to the second channel?
> 
> No, I tested only the primary channel.
> 
> I saw the FreeBSD changes below, and also found the patch for Linux
> driver via google with 'promise ultra66 linux lba48'. So, I guessed
> it as ATAPI port.

Yeah, I looked at the Linux code and it's actually an ATAPI port. But
you missed operations with the UDMA control reg (0x11). Don't know how
it works for you but with my PDC20262 system hangs on boot without these
operations. I'm running this variant:

@@ -4968,6 +5043,50 @@
 			rv = 1;
 	}
 	return rv;
+}
+
+void
+pdc20262_dma_start(void *v, int channel, int drive)
+{
+	struct pciide_softc *sc = v;
+	struct pciide_dma_maps *dma_maps =
+	    &sc->pciide_channels[channel].dma_maps[drive];
+	u_int8_t clock;
+	u_int32_t count;
+
+	if (dma_maps->dma_flags & WDC_DMA_LBA48) {
+		clock = bus_space_read_1(sc->sc_dma_iot, sc->sc_dma_ioh,
+		    PDC262_U66);
+		bus_space_write_1(sc->sc_dma_iot, sc->sc_dma_ioh,
+		    PDC262_U66, clock | PDC262_U66_EN(channel));
+		count = dma_maps->dmamap_xfer->dm_mapsize >> 1;
+		count |= dma_maps->dma_flags & WDC_DMA_READ ?
+		    PDC262_ATAPI_LBA48_READ : PDC262_ATAPI_LBA48_WRITE;
+		bus_space_write_4(sc->sc_dma_iot, sc->sc_dma_ioh,
+		    PDC262_ATAPI(channel), count);
+	}
+
+	pciide_dma_start(v, channel, drive);
+}
+
+int
+pdc20262_dma_finish(void *v, int channel, int drive)
+{
+	struct pciide_softc *sc = v;
+	struct pciide_dma_maps *dma_maps =
+	    &sc->pciide_channels[channel].dma_maps[drive];
+ 	u_int8_t clock;
+
+	if (dma_maps->dma_flags & WDC_DMA_LBA48) {
+		clock = bus_space_read_1(sc->sc_dma_iot, sc->sc_dma_ioh,
+		    PDC262_U66);
+		bus_space_write_1(sc->sc_dma_iot, sc->sc_dma_ioh,
+		    PDC262_U66, clock & ~PDC262_U66_EN(channel));
+		bus_space_write_4(sc->sc_dma_iot, sc->sc_dma_ioh,
+		    PDC262_ATAPI(channel), 0);
+	}
+
+	return (pciide_dma_finish(v, channel, drive));
 }
 
 /*


> 
> Takeshi Nakayama

-- 
   Alexander Yurchenko (aka grange)