Call for testers: Apple ATA DMA
Marco Trillo
marcotrillo at gmail.com
Wed Sep 10 10:49:04 UTC 2008
Hello,
On Tue, Sep 9, 2008 at 5:38 PM, Nathan Whitehorn <nwhitehorn at freebsd.org> wrote:
> I just finished a patch to the Apple built-in ATA drivers (ata_macio and
> ata_kauai) that adds DMA support. Due to lack of Kauai hardware (G4
> machines), it has had only minimal testing, so I'd appreciate some more.
>
> The patch can be found here:
> http://people.freebsd.org/~nwhitehorn/apple-ata-dma.patch
Regarding the Kauai mode setting:
> +static const u_int udma_timing_kauai[] = { /* 0x0000ffff */
> + 0x000070c0, /* UDMA0 */
> + 0x00005d80, /* UDMA1 */
> + 0x00004a60, /* UDMA2 */
> + 0x00003a50, /* UDMA3 */
> + 0x00002a30, /* UDMA4 */
> + 0x00002921 /* UDMA5 */
> +};
> +
> static void
> ata_kauai_setmode(device_t parent, device_t dev)
> {
> struct ata_device *atadev = device_get_softc(dev);
> + struct ata_kauai_softc *sc = device_get_softc(parent);
> + uint32_t dmaconf = 0;
> + uint32_t mode;
>
> - /* TODO bang kauai speed register */
> - atadev->mode = ATA_PIO;
> + mode = atadev->mode = ata_limit_mode(dev,atadev->mode,ATA_UDMA5);
> +
> + if ((mode & ATA_DMA_MASK) == ATA_UDMA0) {
> + dmaconf = udma_timing_kauai[mode & ATA_MODE_MASK];
> +
> + bus_write_4(sc->sc_memr, DMA_CONFIG_REG, dmaconf);
> + } else if ((mode & ATA_DMA_MASK) == ATA_WDMA0) {
> + dmaconf = dma_timing_kauai[mode & ATA_MODE_MASK];
> +
> + bus_write_4(sc->sc_memr, DMA_CONFIG_REG, dmaconf);
> + } else {
> + dmaconf = pio_timing_kauai[(mode & ATA_MODE_MASK) - ATA_PIO0];
> +
> + bus_write_4(sc->sc_memr, PIO_CONFIG_REG, dmaconf);
> + }
> }
> +
The "DMA_CONFIG_REG" register is actually only for UDMA timings, not
for DMA+UDMA. DMA mode timings are ORed with PIO mode timings in the
"PIO_CONFIG_REG" register; as indicated with the masks: 0x00fff000 for
DMA and 0xff000fff for PIO.
This can be verified by looking at Mac OS X's AppleKauaiATA.cpp
driver, in lines 985 and 986 and others [1] .
Note that the NetBSD driver also contains this error, and there is a
patch for it on NetBSD PR 39176. OpenBSD driver doesn't have this
problem.
In addition, to enable UDMA, you need to OR 1 to the UDMA timing mode.
So for example for UDMA2, you need to write 0x00004a61 and not simply
0x00004a60 .
Hope that helps.
Regards,
Marco.
More information about the freebsd-ppc
mailing list