From owner-freebsd-ppc@FreeBSD.ORG Sat Sep 27 11:15:38 2008 Return-Path: Delivered-To: freebsd-ppc@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A625B106574B for ; Sat, 27 Sep 2008 11:15:38 +0000 (UTC) (envelope-from marcotrillo@gmail.com) Received: from wf-out-1314.google.com (wf-out-1314.google.com [209.85.200.173]) by mx1.freebsd.org (Postfix) with ESMTP id 74BDC8FC28 for ; Sat, 27 Sep 2008 11:15:38 +0000 (UTC) (envelope-from marcotrillo@gmail.com) Received: by wf-out-1314.google.com with SMTP id 24so1407833wfg.7 for ; Sat, 27 Sep 2008 04:15:37 -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=KRmNGe2jBR/2DHV8iVl5pTuuAVlb3dBS4tPKBCk5yk0=; b=MnguznPsIWlPHE3YXrcHX7VMUgkfJbEtlmcQ4Q3nAoo1t26f3MKsM4JpCQ+iNFmtYF wVLboZCBk9PUm6FJPiqW8OUX8p/EXVD+7N5R+Z/YejHh5DNvcMVxTkWFHCVaBLG6rH3A nkpamZEw0gxcq3ptqLL0GZEZZv0SZzj7FsKUA= 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=NzOjMkULmV7HftxqarfyqnclMQDUPLW0Ov4RdcXhqLNUBp40ARRwE1iIFxW4gf7NAr iwMheJH3Hsb5C59EpeYxv29iJ3H9TVPYvovrTq2q19qr8ah6SfeHxenZh/62+7h3wIlz wIXMvuX685DdjDK2gfhzGslCEAGeOhr1on2QA= Received: by 10.142.154.20 with SMTP id b20mr1123783wfe.99.1222514137713; Sat, 27 Sep 2008 04:15:37 -0700 (PDT) Received: by 10.142.101.13 with HTTP; Sat, 27 Sep 2008 04:15:37 -0700 (PDT) Message-ID: Date: Sat, 27 Sep 2008 13:15:37 +0200 From: "Marco Trillo" To: "Nathan Whitehorn" In-Reply-To: <48DD2D9B.2070706@freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <48DD2D9B.2070706@freebsd.org> Cc: freebsd-ppc@freebsd.org Subject: Re: Onboard audio support and DBDMA API extensions. 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: Sat, 27 Sep 2008 11:15:38 -0000 Hi, On Fri, Sep 26, 2008 at 8:44 PM, Nathan Whitehorn wrote: > Marco Trillo wrote: >> I also have preliminary support for the GPIO controls, which are used >> mainly to select the output port (built-in speakers or headphones). >> What I have yet to do is to support the mixer(4) interface (to support >> changing the output volume), which needs support for the Keywest I2C >> controller in order to talk to the codec. I have in fact ported a >> Keywest I2C driver from NetBSD, but I don't use it much yet. > > I think we need to come up with a good way to handle the GPIO stuff and FCR > setting. GPIO is also needed for PMU support (my current PMU driver has ugly > hacks) and for SMU on G5 machines. I agree; I'm also using a ugly hack for accessing the GPIO space in the aoa driver (using hardcoded base address and relying on BAT mapping). > Maybe some new interfaces to macio? This is probably the best way; macio.c would map the FCR and GPIO spaces and provide accessor functions for clearing, setting and testing bits in the FCRs and writing and reading from GPIO lines. The aoa driver would also need to access the FCR1 in order to stop and reenable the I2S clock, in order to support changing the sampling rate, but this part is ifdefed-out by now (currently I have it fixed at 44100Hz). > > I would like to propose the following additions to the DBDMA API, >> >> which I'm using in the driver: >> >> void dbdma_clear_cmd_status(dbdma_channel_t *, int slot); >> Clears the cmdStatus of DBDMA command at slot 'slot'. Used for keeping >> track of completed blocks. >> >> void dbdma_control(dbdma_channel_t *, uint8_t mask, uint8_t in); >> General-purpose manipulation of the DBDMA channel control register. >> Used for setting/clearing general-purpose control bits such as S0. > > Looks good to me. I'd suggest changing the name of dbdma_control() to > dbdma_set_chan_status() to match dbdma_get_chan_status(), though. > OK. Here is patch which adds the functions dbdma_clear_cmd_status() and dbdma_set_chan_status(): Index: include/dbdma.h =================================================================== RCS file: /home/ncvs/src/sys/powerpc/include/dbdma.h,v retrieving revision 1.2 diff -u -r1.2 dbdma.h --- include/dbdma.h 23 Sep 2008 02:12:47 -0000 1.2 +++ include/dbdma.h 27 Sep 2008 11:12:25 -0000 @@ -85,6 +85,7 @@ int dbdma_free_channel(dbdma_channel_t *chan); uint16_t dbdma_get_cmd_status(dbdma_channel_t *chan, int slot); +void dbdma_clear_cmd_status(dbdma_channel_t *, int); uint16_t dbdma_get_residuals(dbdma_channel_t *chan, int slot); void dbdma_run(dbdma_channel_t *chan); @@ -104,6 +105,7 @@ uint8_t value); void dbdma_set_wait_selector(dbdma_channel_t *chan, uint8_t mask, uint8_t value); +void dbdma_set_chan_status(dbdma_channel_t *, uint8_t, uint8_t); void dbdma_insert_command(dbdma_channel_t *chan, int slot, int command, int stream, bus_addr_t data, size_t count, uint8_t interrupt, cvs diff: Diffing mpc85xx cvs diff: Diffing ofw cvs diff: Diffing powermac Index: powermac/dbdma.c =================================================================== RCS file: /home/ncvs/src/sys/powerpc/powermac/dbdma.c,v retrieving revision 1.2 diff -u -r1.2 dbdma.c --- powermac/dbdma.c 23 Sep 2008 02:12:47 -0000 1.2 +++ powermac/dbdma.c 27 Sep 2008 11:12:26 -0000 @@ -127,6 +127,12 @@ return (le16toh(chan->sc_slots[slot].resCount)); } +void +dbdma_clear_cmd_status(dbdma_channel_t *chan, int slot) +{ + chan->sc_slots[slot].resCount = 0; +} + uint16_t dbdma_get_residuals(dbdma_channel_t *chan, int slot) { @@ -241,6 +247,17 @@ } void +dbdma_set_chan_status(dbdma_channel_t *chan, uint8_t mask, uint8_t val) +{ + uint32_t x; + + x = mask; + x <<= 16; + x |= val; + dbdma_write_reg(chan, CHAN_CONTROL_REG, x); +} + +void dbdma_set_wait_selector(dbdma_channel_t *chan, uint8_t mask, uint8_t val) { uint32_t wait_select; Thanks, Marco.