From patchwork Mon Jan 15 23:16:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolin Chen X-Patchwork-Id: 10165481 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A2628602C2 for ; Mon, 15 Jan 2018 23:20:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 92CA827F17 for ; Mon, 15 Jan 2018 23:20:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9031027F9F; Mon, 15 Jan 2018 23:20:57 +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=-1.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, T_DKIM_INVALID autolearn=no version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9651C27F95 for ; Mon, 15 Jan 2018 23:20:55 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 8C156267666; Tue, 16 Jan 2018 00:17:50 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id C6524267669; Tue, 16 Jan 2018 00:17:42 +0100 (CET) Received: from mail-pf0-f195.google.com (mail-pf0-f195.google.com [209.85.192.195]) by alsa0.perex.cz (Postfix) with ESMTP id D498C266BBC for ; Tue, 16 Jan 2018 00:17:37 +0100 (CET) Received: by mail-pf0-f195.google.com with SMTP id k19so8743913pfj.5 for ; Mon, 15 Jan 2018 15:17:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=892+TzhuXmjl+qcUlr6xjRLPz5H5H8ShvbGy3nf02Vo=; b=qbTyAe+lQC919qqH3wSUsJknLO3sCe3Vspfe4JqmN5p9wxOtlDJpO1D2AMq7tTZzHw bGZhsIUf8h2JXX06gWe+6B3KL08dgJ80P9Pxul4Lo2yEOwV4Y0bTSRiAs674W6urA6hj utr6u3ppls/VoQdi7PVZr+KkEzNJONn7YB8cEdovx8rjIrmyALOCU7ru8YahwFOcKwQg WzKvvDUyBb7z3uo5YTs4PntqAeuk8PSFfk6Xrdd1JEVM4XGsKDl1C75bCuxwP9FHfUB8 3fMgJmU1hOP6cJroQNSiN+oT3NpReFjAtSpNlqYVpC6h6gJ+i00miSFFLxtIPWshBpeT Onuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=892+TzhuXmjl+qcUlr6xjRLPz5H5H8ShvbGy3nf02Vo=; b=Pqlk52ecXAGEWg3Xnbyz+Q9/hsDHKUa2eXGVnA8il2ZHQI2ViDrnKWBWnyII0asFdy EbfDx+bIk0klTNu6aV0P345aPbNFc/MDTXuEX2h9GeTVd3ehNY5B8Kuocq55UIECjscQ +ZCMU4ILHeZTabC1CtV3Jp+vF8lFnZHlo8LwSaiZaxt0BvsRALFAaoT4pVVrLIy4VAix MNTlVpoGcgs8iL4XNcqWGtRIYIamFDcMmsXR7c4Hkfbn+ymZSwNMqazdtpr3yh0h/mei ikQHhT0ns3rBocGb1lQIL4pV3JoXCBCNqbpPVy1eBVRc3k8L/Gm6L3ebTyPNtQDLQapM WhSg== X-Gm-Message-State: AKwxytdc4khW/x8VCNSZ9uxp9PkMQnpRwU++tbbqkbM1c/t8ee4kG2Nl vdlk8l8syq7Ta09MOhv/5nv9yQ== X-Google-Smtp-Source: ACJfBouE/4WKcmd5TWSvsxB/SVxqDH1E0wxSf26hoZraeWQykWjDCkuufHk+P8ucwtyRFiykvnuRzw== X-Received: by 10.98.7.207 with SMTP id 76mr8528252pfh.130.1516058256329; Mon, 15 Jan 2018 15:17:36 -0800 (PST) Received: from Asurada-CZ80.localdomain (c-73-231-2-134.hsd1.ca.comcast.net. [73.231.2.134]) by smtp.gmail.com with ESMTPSA id b6sm776442pfe.85.2018.01.15.15.17.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 15 Jan 2018 15:17:35 -0800 (PST) From: Nicolin Chen To: timur@tabi.org, broonie@kernel.org, mail@maciej.szmigiero.name Date: Mon, 15 Jan 2018 15:16:28 -0800 Message-Id: <1516058192-65519-14-git-send-email-nicoleotsuka@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1516058192-65519-1-git-send-email-nicoleotsuka@gmail.com> References: <1516058192-65519-1-git-send-email-nicoleotsuka@gmail.com> Cc: alsa-devel@alsa-project.org, kernel@pengutronix.de, linux-kernel@vger.kernel.org, caleb@crome.org, lgirdwood@gmail.com, arnaud.mouiche@invoxia.com, lukma@denx.de, fabio.estevam@nxp.com, linuxppc-dev@lists.ozlabs.org Subject: [alsa-devel] [PATCH v4 13/17] ASoC: fsl_ssi: Setup AC97 in fsl_ssi_hw_init() X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 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: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP AC97 configures most of registers earlier to start a communication with CODECs in order to successfully initialize CODEC. Currently, _fsl_ssi_set_dai_fmt() and fsl_ssi_setup_ac97() are called to get all SSI registers properly set. Since now the driver has a fsl_ssi_hw_init() to handle all register initial settings, this patch moves those register settings of AC97 to the fsl_ssi_hw_init() as well. Meanwhile it applies _fsl_ssi_set_dai_fmt() call to AC97 only since other formats would be configured via normal set_dai_fmt() directly. This patch also adds fsl_ssi_hw_clean() to cleanup control bits for AC97 in the platform remote() function. Signed-off-by: Nicolin Chen Tested-by: Caleb Crome --- Changelog v2 * Moved all to fsl_ssi_hw_init() in platform probe() * Added fsl_ssi_hw_clean() instead of dai remove() sound/soc/fsl/fsl_ssi.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c index 50648f5..ebb3eb9 100644 --- a/sound/soc/fsl/fsl_ssi.c +++ b/sound/soc/fsl/fsl_ssi.c @@ -987,9 +987,6 @@ static int _fsl_ssi_set_dai_fmt(struct device *dev, regmap_write(regs, REG_SSI_SRCR, srcr); regmap_write(regs, REG_SSI_SCR, scr); - if ((fmt & SND_SOC_DAIFMT_FORMAT_MASK) == SND_SOC_DAIFMT_AC97) - fsl_ssi_setup_ac97(ssi); - return 0; } @@ -1255,10 +1252,28 @@ static int fsl_ssi_hw_init(struct fsl_ssi *ssi) regmap_update_bits(ssi->regs, REG_SSI_SCR, SSI_SCR_TCH_EN, SSI_SCR_TCH_EN); + /* AC97 should start earlier to communicate with CODECs */ + if (fsl_ssi_is_ac97(ssi)) { + _fsl_ssi_set_dai_fmt(ssi->dev, ssi, ssi->dai_fmt); + fsl_ssi_setup_ac97(ssi); + } + return 0; } /** + * Clear SSI registers + */ +static void fsl_ssi_hw_clean(struct fsl_ssi *ssi) +{ + /* Disable registers for AC97 */ + if (fsl_ssi_is_ac97(ssi)) { + regmap_write(ssi->regs, REG_SSI_SCR, 0); + regmap_write(ssi->regs, REG_SSI_SACNT, 0); + regmap_write(ssi->regs, REG_SSI_SOR, 0); + } +} +/** * Make every character in a string lower-case */ static void make_lowercase(char *s) @@ -1540,9 +1555,6 @@ static int fsl_ssi_probe(struct platform_device *pdev) } done: - if (ssi->dai_fmt) - _fsl_ssi_set_dai_fmt(dev, ssi, ssi->dai_fmt); - /* Initially configures SSI registers */ fsl_ssi_hw_init(ssi); @@ -1587,6 +1599,8 @@ static int fsl_ssi_remove(struct platform_device *pdev) { struct fsl_ssi *ssi = dev_get_drvdata(&pdev->dev); + fsl_ssi_hw_clean(ssi); + fsl_ssi_debugfs_remove(&ssi->dbg_stats); if (ssi->pdev)