From owner-freebsd-ppc@FreeBSD.ORG Wed Sep 10 10:49:04 2008 Return-Path: Delivered-To: powerpc@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 689D41065675 for ; Wed, 10 Sep 2008 10:49:04 +0000 (UTC) (envelope-from marcotrillo@gmail.com) Received: from py-out-1112.google.com (py-out-1112.google.com [64.233.166.183]) by mx1.freebsd.org (Postfix) with ESMTP id 1F42C8FC4B for ; Wed, 10 Sep 2008 10:49:04 +0000 (UTC) (envelope-from marcotrillo@gmail.com) Received: by py-out-1112.google.com with SMTP id p76so1592123pyb.10 for ; Wed, 10 Sep 2008 03:49:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:cc:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references; bh=fIcAXZU0/iPyb0cF6rmb8Nuk1/17v7xPxW/jp9LStHQ=; b=EYyNJtEBOnsfr7rzi0ocib9XxYCZe2w1tUVLbpSUMS7hRZhw4Xj7QTORICI2EZNjmI Pp2OgrHeJTQgrzer8H0ozt9oy0sFqcUMNheGaFJOZ3X1jlNgEe1s9c08FzM9dNBsblhV kezXSU51OHnX4VLA7F2CuoGS5Qobl2bxphITU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references; b=of+tsrNysImi0xcFhCk1WzJj5Q1BBe6H6DxUefS3pOhz+a0JOOQA3lMe8qDaka3xFR JR27AqeGdeY05cc0exGBWdT7DCJy/pCaWtPtTGMh1VS6oTXMtatU0nnUAMrc2MkD+wSJ GScofbhf18SNuI3HesMHVjOXNgyiEXYwn7ONU= Received: by 10.143.37.20 with SMTP id p20mr363953wfj.236.1221042134716; Wed, 10 Sep 2008 03:22:14 -0700 (PDT) Received: by 10.142.89.18 with HTTP; Wed, 10 Sep 2008 03:22:14 -0700 (PDT) Message-ID: Date: Wed, 10 Sep 2008 12:22:14 +0200 From: "Marco Trillo" To: "Nathan Whitehorn" In-Reply-To: <48C69864.3010208@freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <48C69864.3010208@freebsd.org> Cc: powerpc@freebsd.org Subject: Re: Call for testers: Apple ATA DMA X-BeenThere: freebsd-ppc@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to the PowerPC List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 10 Sep 2008 10:49:04 -0000 Hello, On Tue, Sep 9, 2008 at 5:38 PM, Nathan Whitehorn 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.