From patchwork Tue Jun 15 15:55:47 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manuel Lauss X-Patchwork-Id: 106243 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o5FFu4Kb008849 for ; Tue, 15 Jun 2010 15:56:04 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752650Ab0FOP4B (ORCPT ); Tue, 15 Jun 2010 11:56:01 -0400 Received: from mail-fx0-f46.google.com ([209.85.161.46]:63423 "EHLO mail-fx0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751196Ab0FOP4B (ORCPT ); Tue, 15 Jun 2010 11:56:01 -0400 Received: by mail-fx0-f46.google.com with SMTP id 10so257696fxm.19 for ; Tue, 15 Jun 2010 08:56:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:subject:date :message-id:x-mailer:in-reply-to:references; bh=+XMolEEQNfmXy1QN2f4c8xCoZgmomtSoDykVU0r2pyk=; b=Mm3k5GMfF9CFzuRd7re+13VTEaBhc0Rdydtn98rFPz8BFLyvDuAW8N1LtWScP2PF7t gNosfRJmImk3JPo2Ik8oix8V6OYLZV4uep9Utn6obQa0HqAPeWl+DyXJA5VU4h2hZ+xr BmIhvkUB/dm6ye8hoKpzqDVUX5l/9Mb5eEQnY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; b=MQP6qd9uGCSf5nv8B3MW3kOIqWqV/oTiroxJ7cPzklISLZxqTkldrv6K5jITBm2Kro U6gsNFyaGGrEZ2LrMg3wkA+e9daj46ZnHoFC+WhhG/N0jDLwaLWqq15oRhPw/P1rrZ3F 8jktD+qSHW+dXTVX+Hte7ENlDPaCDDW/36W7Y= Received: by 10.223.45.83 with SMTP id d19mr7483447faf.65.1276617360130; Tue, 15 Jun 2010 08:56:00 -0700 (PDT) Received: from localhost.localdomain (p5496BAFC.dip.t-dialin.net [84.150.186.252]) by mx.google.com with ESMTPS id p21sm10077036fak.21.2010.06.15.08.55.58 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 15 Jun 2010 08:55:59 -0700 (PDT) From: Manuel Lauss To: alsa-devel@vger.kernel.org, Mark Brown Cc: linux-input@vger.kernel.org, Manuel Lauss Subject: [PATCH RFC 3/3] sound: asoc: au1x: implement AC97 GPIO access Date: Tue, 15 Jun 2010 17:55:47 +0200 Message-Id: <1276617347-3522-4-git-send-email-manuel.lauss@googlemail.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1276617347-3522-1-git-send-email-manuel.lauss@googlemail.com> References: <1276617347-3522-1-git-send-email-manuel.lauss@googlemail.com> Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Tue, 15 Jun 2010 15:56:04 +0000 (UTC) diff --git a/sound/soc/au1x/psc-ac97.c b/sound/soc/au1x/psc-ac97.c index a61ccd2..1da2949 100644 --- a/sound/soc/au1x/psc-ac97.c +++ b/sound/soc/au1x/psc-ac97.c @@ -56,6 +56,31 @@ /* instance data. There can be only one, MacLeod!!!! */ static struct au1xpsc_audio_data *au1xpsc_ac97_workdata; +static void au1xpsc_ac97_setgpio(struct snd_ac97 *ac97, unsigned short gpio) +{ + /* FIXME */ + struct au1xpsc_audio_data *pscdata = au1xpsc_ac97_workdata; + au_writel(gpio, AC97_GPO(pscdata)); + au_sync(); +} + +static unsigned short au1xpsc_ac97_getgpio(struct snd_ac97 *ac97) +{ + /* FIXME */ + struct au1xpsc_audio_data *pscdata = au1xpsc_ac97_workdata; + unsigned long data; + + while (!(au_readl(AC97_EVNT(pscdata)) & PSC_AC97EVNT_GR)) + cpu_relax(); + au_writel(PSC_AC97EVNT_GR, AC97_EVNT(pscdata)); + au_sync(); + + data = au_readl(AC97_GPI(pscdata)); + data = (data >> 4) & 0xffff; + + return data; +} + /* AC97 controller reads codec register */ static unsigned short au1xpsc_ac97_read(struct snd_ac97 *ac97, unsigned short reg) @@ -195,6 +220,8 @@ struct snd_ac97_bus_ops soc_ac97_ops = { .write = au1xpsc_ac97_write, .reset = au1xpsc_ac97_cold_reset, .warm_reset = au1xpsc_ac97_warm_reset, + .setgpio = au1xpsc_ac97_setgpio, + .getgpio = au1xpsc_ac97_getgpio, }; EXPORT_SYMBOL_GPL(soc_ac97_ops); @@ -229,10 +256,12 @@ static int au1xpsc_ac97_hw_params(struct snd_pcm_substream *substream, r &= ~PSC_AC97CFG_TXSLOT_MASK; r |= PSC_AC97CFG_TXSLOT_ENA(3); r |= PSC_AC97CFG_TXSLOT_ENA(4); + r |= PSC_AC97CFG_TXSLOT_ENA(12); /* GPIO */ } else { r &= ~PSC_AC97CFG_RXSLOT_MASK; r |= PSC_AC97CFG_RXSLOT_ENA(3); r |= PSC_AC97CFG_RXSLOT_ENA(4); + r |= PSC_AC97CFG_RXSLOT_ENA(12); /* GPIO */ } /* do we need to poke the hardware? */ @@ -384,9 +413,15 @@ static int __devinit au1xpsc_ac97_drvprobe(struct platform_device *pdev) if (!wd->mmio) goto out1; - /* configuration: max dma trigger threshold, enable ac97 */ + /* configuration: max dma trigger threshold, enable ac97, + * enable GPIO regs, enable GPIO slots, 16bit len default + * so it clocks out all GPIO info. + */ wd->cfg = PSC_AC97CFG_RT_FIFO8 | PSC_AC97CFG_TT_FIFO8 | - PSC_AC97CFG_DE_ENABLE; + PSC_AC97CFG_DE_ENABLE | PSC_AC97CFG_GE_ENABLE | + PSC_AC97CFG_TXSLOT_ENA(12) | + PSC_AC97CFG_RXSLOT_ENA(12) | + PSC_AC97CFG_SET_LEN(16); /* preserve PSC clock source set up by platform */ sel = au_readl(PSC_SEL(wd)) & PSC_SEL_CLK_MASK; diff --git a/sound/soc/au1x/psc.h b/sound/soc/au1x/psc.h index 32d3807..915c3de 100644 --- a/sound/soc/au1x/psc.h +++ b/sound/soc/au1x/psc.h @@ -55,5 +55,7 @@ struct au1xpsc_audio_data { #define AC97_PCR(x) ((unsigned long)((x)->mmio) + PSC_AC97PCR_OFFSET) #define AC97_RST(x) ((unsigned long)((x)->mmio) + PSC_AC97RST_OFFSET) #define AC97_STAT(x) ((unsigned long)((x)->mmio) + PSC_AC97STAT_OFFSET) +#define AC97_GPO(x) ((unsigned long)((x)->mmio) + PSC_AC97GPO_OFFSET) +#define AC97_GPI(x) ((unsigned long)((x)->mmio) + PSC_AC97GPI_OFFSET) #endif