From patchwork Wed Jan 17 06:51:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolin Chen X-Patchwork-Id: 10168659 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 41B0B60386 for ; Wed, 17 Jan 2018 06:56:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2E86D27F10 for ; Wed, 17 Jan 2018 06:56:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 22A6327FC0; Wed, 17 Jan 2018 06:56:08 +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 5A7DD27F10 for ; Wed, 17 Jan 2018 06:56:07 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 9AB0B267799; Wed, 17 Jan 2018 07:52:49 +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 B5810267791; Wed, 17 Jan 2018 07:52:42 +0100 (CET) Received: from mail-pf0-f196.google.com (mail-pf0-f196.google.com [209.85.192.196]) by alsa0.perex.cz (Postfix) with ESMTP id D2EA5267790 for ; Wed, 17 Jan 2018 07:52:39 +0100 (CET) Received: by mail-pf0-f196.google.com with SMTP id i66so11033645pfd.7 for ; Tue, 16 Jan 2018 22:52:39 -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=59RhHP5hIiWGgcdeJz43PYDfiO6BLgPEe3TM90wVmfo=; b=NhrKe8+KCMnPsHADl6uSd4+1xYBLIWLglSSy3od0zO6ZUZQBU/VXJruhieoHSFOhwo cvz0GmPfUNihy/0GcsoF+FzdiTT4M4tuMZwBIJgnaFaAym1IZpQXmakSQVdnyzLys95L f/C29mSr1FwSfoaYPhAVIJgfgSStWd3aV3etpV5IYH0ub5mgHRNXY3wt3D7NJ6VqyXu6 58vuP4GkUuTfdlM5Wr2w6xLhqRFv69QkUdOYVcajXb0Ywfy4EovclFJFyZrxOu07yPYq juVn2rwrRaWVslRQG/E3QaoJpPy/6s/hzCBIkq4ZsCNCfyW79CoytLGSnhhmeRsEVPNm 3KVw== 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=59RhHP5hIiWGgcdeJz43PYDfiO6BLgPEe3TM90wVmfo=; b=uIC8+qNtPK75QshaF66sbPNvSao9bP2PyhJN2zYNREfkySiQyVUrrySvEC6GLvqGQp Z9blJjg+gN1bwxm6jLFq+26DgkgRahVbl2qR0eihd0fYPWsH9tVKnV/xQa2UoxRpiABk leAfo0wdksuMPJ3Iu+xqhd/Ow09x4jbP3ujUuGdjYRv3jvoiQdff5Nu1Jmo4gP1/uLBg lXeNOlXRALwOrv+lZRDIRtekjUqGOVcnyuRrSRwZQF5xkRuxMo2Wt9kHhEgipAmgJI/2 yscSA2AYoPobz4mBrJwDpf2uzpHIfSzYYnwiYAO2ULQJC2PI7u1FYEQidmkaYcuJtPTQ 4LHw== X-Gm-Message-State: AKwxytd1hwVdyITiGUSCJ5+B3KCMLg9R8cNax3ijYbDq0myMTDIzgA/9 xm+R9vwWegcEpJ+zEMfFsFM= X-Google-Smtp-Source: ACJfBou+ysf0PSWnxxkmtc7HLSdhCagpBk6FNFcK8XurIEGxVnvH8mOEGbCkugOdSW0YzGyuZ6hZUw== X-Received: by 10.99.171.12 with SMTP id p12mr5400664pgf.304.1516171958565; Tue, 16 Jan 2018 22:52:38 -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 e185sm7503221pfg.155.2018.01.16.22.52.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 16 Jan 2018 22:52:38 -0800 (PST) From: Nicolin Chen To: timur@tabi.org, broonie@kernel.org, mail@maciej.szmigiero.name Date: Tue, 16 Jan 2018 22:51:38 -0800 Message-Id: <1516171902-32669-14-git-send-email-nicoleotsuka@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1516171902-32669-1-git-send-email-nicoleotsuka@gmail.com> References: <1516171902-32669-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 v5 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 v5 * Moved fsl_ssi_hw_clean() after unregister CODEC platform dev * For cleanup sequence, disabled TE and RE first while SSIEN at last 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 | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c index 50648f5..d577f3d 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,34 @@ 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)) { + /* Disable TE and RE bits first */ + regmap_update_bits(ssi->regs, REG_SSI_SCR, + SSI_SCR_TE | SSI_SCR_RE, 0); + /* Disable AC97 mode */ + regmap_write(ssi->regs, REG_SSI_SACNT, 0); + /* Unset WAIT bits */ + regmap_write(ssi->regs, REG_SSI_SOR, 0); + /* Disable SSI -- software reset */ + regmap_update_bits(ssi->regs, REG_SSI_SCR, SSI_SCR_SSIEN, 0); + } +} +/** * Make every character in a string lower-case */ static void make_lowercase(char *s) @@ -1540,9 +1561,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); @@ -1592,6 +1610,9 @@ static int fsl_ssi_remove(struct platform_device *pdev) if (ssi->pdev) platform_device_unregister(ssi->pdev); + /* Clean up SSI registers */ + fsl_ssi_hw_clean(ssi); + if (ssi->soc->imx) fsl_ssi_imx_clean(pdev, ssi);