From patchwork Thu Apr 4 09:40:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shengjiu Wang X-Patchwork-Id: 10885319 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 980BB1390 for ; Thu, 4 Apr 2019 09:41:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 71FEB289E5 for ; Thu, 4 Apr 2019 09:41:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6588528A1F; Thu, 4 Apr 2019 09:41:58 +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 44C02289E5 for ; Thu, 4 Apr 2019 09:41:56 +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 0BAF715DA; Thu, 4 Apr 2019 11:41:05 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 0BAF715DA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1554370915; bh=YBYjDj7fk1LAZwGGOcRyTRzFOCmccuyIsBnsVqU4/8Q=; h=From:To:Date:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=PN5bh/r7m2sxaOkBlDzh2tmLZNEuTpOE4ZZDKZTQ5ntrcxsWQ7w20DBoXFt2Hj03B NdrIsSDscrW3+6Qhvq0fSTCN1XEBirRat0Q595BIPpOl2Ldb1oqI0Vh7/CdfTvWOg3 /8jlFYONQ2jYOG1J+6uM1SlZLRjMwfcQD4iukA3c= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 8A73BF89631; Thu, 4 Apr 2019 11:41:04 +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 0D6FBF89633; Thu, 4 Apr 2019 11:41:02 +0200 (CEST) Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-eopbgr150042.outbound.protection.outlook.com [40.107.15.42]) (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 7A9D6F80714 for ; Thu, 4 Apr 2019 11:40:58 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 7A9D6F80714 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="W74ExDUr" 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=dU4KxQD7u8yoGgoDpzUgUWJzznuQJJ50HgVGw3v0DiM=; b=W74ExDUrMkyxIfs3t/Clh7I4pD6wd7V2RRfZHDIeo1JPJzYKM1yBmuncRIIJ6GQyQ13iKo+pQ3I19PzXdW/HSr/Q0VfGcvqcjqmqeAypVIb5fWnL3WGWx+dsVnCXT07XTNgzYeTfGmSOtruR0MHefERl3sfldyFqQbdVYJ/46BU= Received: from VE1PR04MB6479.eurprd04.prod.outlook.com (20.179.233.80) by VE1PR04MB6719.eurprd04.prod.outlook.com (20.179.235.208) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1750.17; Thu, 4 Apr 2019 09:40:57 +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; Thu, 4 Apr 2019 09:40:57 +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 V3] ASoC: fsl_esai: Support synchronous mode Thread-Index: AQHU6sqBPAjM1VYiq06aHRLyPL2amg== Date: Thu, 4 Apr 2019 09:40:56 +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: HK0PR01CA0048.apcprd01.prod.exchangelabs.com (2603:1096:203:3e::36) 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: b1b58ea0-7961-4b71-8eb1-08d6b8e1a348 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:VE1PR04MB6719; x-ms-traffictypediagnostic: VE1PR04MB6719: x-microsoft-antispam-prvs: x-forefront-prvs: 0997523C40 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(366004)(396003)(136003)(346002)(376002)(39860400002)(189003)(199004)(50226002)(81166006)(305945005)(106356001)(478600001)(6116002)(6486002)(8936002)(25786009)(71190400001)(6512007)(2201001)(68736007)(86362001)(7736002)(4326008)(118296001)(3846002)(2906002)(186003)(81156014)(105586002)(97736004)(386003)(66066001)(14454004)(14444005)(26005)(110136005)(53936002)(52116002)(316002)(8676002)(2501003)(99286004)(102836004)(476003)(2616005)(71200400001)(5660300002)(486006)(6506007)(6436002)(256004)(36756003); DIR:OUT; SFP:1101; SCL:1; SRVR:VE1PR04MB6719; 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: JSrJnueYdPbxwqq4rpsu0ISR+yfRr62hkgBNUR5RL0PrCBCBe0weOm4Uo+1EQkjtcUKbutHmLZIj/fePyTeSBYll/TTKqGflAjnO+q93B3Zp8Z9a3081M08FsaclK5UXWll+duE0lCQ6HBWzA1piDYTnlVUlvPNw4Yna9YfL2+F9i1PqJupMvOOv0/+7jRffVQwQf2mRJ0//2mJMd45aiAev2A3v7GAJEMCudGx5ZiFrjMBfw5CnmuDmo7tWzYPj6TgRJbb9M/QRQO/z+4VE4dwt1myGNfQeAEt94nJYzHK+Fw+XZs2x9gnWZRlAyH7ZMozwD/h5ne4XSAHiFeorMzaVWy0wYLtkloGG/cIbePiHTFsoWIircturmYuokHObeTeWyt4npySaEkRjIRoHIY6qGJLZ+Asl9oq5JNTOmoU= MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: b1b58ea0-7961-4b71-8eb1-08d6b8e1a348 X-MS-Exchange-CrossTenant-originalarrivaltime: 04 Apr 2019 09:40:56.9990 (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: VE1PR04MB6719 Cc: "linuxppc-dev@lists.ozlabs.org" Subject: [alsa-devel] [PATCH V3] 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 v3 - fix the indentation 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..c7410bbfd2af 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,