From patchwork Wed Apr 3 10:07:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shengjiu Wang X-Patchwork-Id: 10883195 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 92383922 for ; Wed, 3 Apr 2019 10:08:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 766D028984 for ; Wed, 3 Apr 2019 10:08:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6A4EE289AA; Wed, 3 Apr 2019 10:08:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id AB15B28984 for ; Wed, 3 Apr 2019 10:08:39 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 9A690163D; Wed, 3 Apr 2019 12:07:47 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 9A690163D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1554286117; bh=gDqJ6RcD9N5XrOOhIHWObE9wTVSawXHfjhZuD/qaA+g=; h=From:To:Date:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=Rl7DJWqhvExcEDxUraE9iVlxjg+Ikh4QTe69+a4YYG6f3Jpmt5nBhmdPxAnnkkWmr Y6XRK6+mD9yMdhmcb7h/0uePYfjqt1yQmrD2AxtLPyHMNattkoQ+IqP9aZuQqcZvsM E5BOUsdJ0T829RTgSHSyqPiZvYoaNXMce2ERwSKg= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 16B8DF89615; Wed, 3 Apr 2019 12:07:47 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id 74900F8962D; Wed, 3 Apr 2019 12:07:45 +0200 (CEST) Received: from EUR02-VE1-obe.outbound.protection.outlook.com (mail-ve1eur02on0608.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe06::608]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id A9A23F8071D for ; Wed, 3 Apr 2019 12:07:42 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz A9A23F8071D Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="NGoJ0pYV" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=TCGHXORDcMH5K0hUkeI0SSotT92d7d7dY8+3F6bCfH4=; b=NGoJ0pYVm6t69CgF1mqWTvH2XMJvCdnGMDSwac/J2n/9n6fYvA+kk9BsbIY88CGcEqpAzIF3LgzDThdTXSMtEM2q8ZSWBEIWljSC0BFFS3gMOgeDwchklV7n0apuHA9cw0T1wfR5QFMiAnqYlTwep2f3VrzbtT9+ngOdX7DFzB8= Received: from VE1PR04MB6479.eurprd04.prod.outlook.com (20.179.233.80) by VE1PR04MB6605.eurprd04.prod.outlook.com (20.179.234.225) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1771.13; Wed, 3 Apr 2019 10:07:40 +0000 Received: from VE1PR04MB6479.eurprd04.prod.outlook.com ([fe80::59c9:fbfe:c41a:59ef]) by VE1PR04MB6479.eurprd04.prod.outlook.com ([fe80::59c9:fbfe:c41a:59ef%4]) with mapi id 15.20.1750.017; Wed, 3 Apr 2019 10:07:40 +0000 From: "S.j. Wang" To: "timur@kernel.org" , "nicoleotsuka@gmail.com" , "Xiubo.Lee@gmail.com" , "festevam@gmail.com" , "broonie@kernel.org" , "alsa-devel@alsa-project.org" Thread-Topic: [PATCH V2] ASoC: fsl_esai: Support synchronous mode Thread-Index: AQHU6gUSBPA5LkR8lUK0D8ynBBQe8A== Date: Wed, 3 Apr 2019 10:07:40 +0000 Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 1.9.1 x-clientproxiedby: HK0PR01CA0069.apcprd01.prod.exchangelabs.com (2603:1096:203:a6::33) To VE1PR04MB6479.eurprd04.prod.outlook.com (2603:10a6:803:11e::16) authentication-results: spf=none (sender IP is ) smtp.mailfrom=shengjiu.wang@nxp.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [119.31.174.66] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 0ac2777a-45ad-457a-8af3-08d6b81c349e x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600139)(711020)(4605104)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7193020); SRVR:VE1PR04MB6605; x-ms-traffictypediagnostic: VE1PR04MB6605: x-microsoft-antispam-prvs: x-forefront-prvs: 0996D1900D x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(346002)(376002)(396003)(366004)(136003)(39860400002)(189003)(199004)(97736004)(68736007)(8936002)(2201001)(6486002)(86362001)(25786009)(14444005)(256004)(6436002)(36756003)(305945005)(71200400001)(71190400001)(50226002)(14454004)(8676002)(81156014)(478600001)(81166006)(5660300002)(7736002)(486006)(105586002)(6116002)(106356001)(52116002)(3846002)(186003)(118296001)(4326008)(386003)(6506007)(2906002)(26005)(102836004)(2616005)(476003)(99286004)(316002)(110136005)(66066001)(2501003)(6512007)(53936002); DIR:OUT; SFP:1101; SCL:1; SRVR:VE1PR04MB6605; H:VE1PR04MB6479.eurprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: 5Uv5hukTpGtd/UFZq/UBDfpQY0UedpTEZH78Z5K+P6O02aXpTDK0JrwipHZ4Yh3fi2v1mOoTrnODsJmQfWAIYtE6l4yeLLBU7s2Nly8Vwp9aEZhVACO/YJnA+JwhGhkVBEpJDwItmVvvHYC/qLgZ1wHSqgGwyT17Euy+B7cJoG3ylxEmiGlAzk3iqYk5c4axvTt5/cd2LwGz5ShtHOut3OwfMgMrqWUewrKraPKyOCpC9Mt10DeIYXvt8A1LUxyX/IgUy7WosMh3GyWAgXVllzOMYFxQHiiFFILsVYAVM9vBZu2hLATeKyZaUlx3Qh3rpIlJXTbBQVG7M3pUQqAXNQvo9fzTk2daEGA9PF+XbNoW6EF1PCywWUMGSvx1IU0H3/Z2vALakEPA/U962/SNbGNu45QmCtNYAjgfbz7ASAY= MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0ac2777a-45ad-457a-8af3-08d6b81c349e X-MS-Exchange-CrossTenant-originalarrivaltime: 03 Apr 2019 10:07:40.4927 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB6605 Cc: "linuxppc-dev@lists.ozlabs.org" Subject: [alsa-devel] [PATCH V2] ASoC: fsl_esai: Support synchronous mode X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" X-Virus-Scanned: ClamAV using ClamSMTP In ESAI synchronous mode, the clock is generated by Tx, So we should always set registers of Tx which relate with the bit clock and frame clock generation (TCCR, TCR, ECR), even there is only Rx is working. Signed-off-by: Shengjiu Wang Acked-by: Nicolin Chen --- changes in v2 - refine the patch according Nicolin's comments - merge plain setting. sound/soc/fsl/fsl_esai.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/sound/soc/fsl/fsl_esai.c b/sound/soc/fsl/fsl_esai.c index 3623aa9a6f2e..f2e7b27f8447 100644 --- a/sound/soc/fsl/fsl_esai.c +++ b/sound/soc/fsl/fsl_esai.c @@ -218,7 +218,7 @@ static int fsl_esai_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id, { struct fsl_esai *esai_priv = snd_soc_dai_get_drvdata(dai); struct clk *clksrc = esai_priv->extalclk; - bool tx = clk_id <= ESAI_HCKT_EXTAL; + bool tx = (clk_id <= ESAI_HCKT_EXTAL || esai_priv->synchronous); bool in = dir == SND_SOC_CLOCK_IN; u32 ratio, ecr = 0; unsigned long clk_rate; @@ -253,7 +253,7 @@ static int fsl_esai_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id, ecr |= ESAI_ECR_ETI; /* fall through */ case ESAI_HCKR_EXTAL: - ecr |= ESAI_ECR_ERI; + ecr |= esai_priv->synchronous ? ESAI_ECR_ETI : ESAI_ECR_ERI; break; default: return -EINVAL; @@ -537,10 +537,18 @@ static int fsl_esai_hw_params(struct snd_pcm_substream *substream, bclk = params_rate(params) * slot_width * esai_priv->slots; - ret = fsl_esai_set_bclk(dai, tx, bclk); + ret = fsl_esai_set_bclk(dai, esai_priv->synchronous || tx, bclk); if (ret) return ret; + mask = ESAI_xCR_xSWS_MASK; + val = ESAI_xCR_xSWS(slot_width, width); + + regmap_update_bits(esai_priv->regmap, REG_ESAI_xCR(tx), mask, val); + /* Recording in synchronous mode needs to set TCR also */ + if (!tx && esai_priv->synchronous) + regmap_update_bits(esai_priv->regmap, REG_ESAI_TCR, mask, val); + /* Use Normal mode to support monaural audio */ regmap_update_bits(esai_priv->regmap, REG_ESAI_xCR(tx), ESAI_xCR_xMOD_MASK, params_channels(params) > 1 ? @@ -556,10 +564,9 @@ static int fsl_esai_hw_params(struct snd_pcm_substream *substream, regmap_update_bits(esai_priv->regmap, REG_ESAI_xFCR(tx), mask, val); - mask = ESAI_xCR_xSWS_MASK | (tx ? ESAI_xCR_PADC : 0); - val = ESAI_xCR_xSWS(slot_width, width) | (tx ? ESAI_xCR_PADC : 0); - - regmap_update_bits(esai_priv->regmap, REG_ESAI_xCR(tx), mask, val); + if (tx) + regmap_update_bits(esai_priv->regmap, REG_ESAI_TCR, + ESAI_xCR_PADC, ESAI_xCR_PADC); /* Remove ESAI personal reset by configuring ESAI_PCRC and ESAI_PRRC */ regmap_update_bits(esai_priv->regmap, REG_ESAI_PRRC,