From patchwork Mon Jan 15 04:21:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolin Chen X-Patchwork-Id: 10163031 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 48BE5601C0 for ; Mon, 15 Jan 2018 04:25:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4999C28329 for ; Mon, 15 Jan 2018 04:25:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3DE582889F; Mon, 15 Jan 2018 04:25:36 +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 69D4428329 for ; Mon, 15 Jan 2018 04:25:35 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id BA337267416; Mon, 15 Jan 2018 05:22:40 +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 04575267345; Mon, 15 Jan 2018 05:22:36 +0100 (CET) Received: from mail-pf0-f193.google.com (mail-pf0-f193.google.com [209.85.192.193]) by alsa0.perex.cz (Postfix) with ESMTP id 6387B26739D for ; Mon, 15 Jan 2018 05:22:30 +0100 (CET) Received: by mail-pf0-f193.google.com with SMTP id p1so7474278pfh.4 for ; Sun, 14 Jan 2018 20:22:30 -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=schuJb090Y8So5YJy9ME6C0AAV0uSlVKjZ6D2d/KjDineG71Gk9piZC4dqlPhnvaJV uYuloD2heB6oBBoZ90YF8JB3QcSdB1f4/QFVJ+nhwnYJkQpOCnFvWRY4Z01427laxAOX wX9t7J/aIrY4XnL1/gcfqKQL+DYIf2ApbRPClghVtidhevgr2MxuTmBKCzi78qzAyCEW VKW/PjPJLwwyFWLfEd2zeoMFfIiktXDedtFlxnhdLYh1DqKYLEKxfdPurqrCjCuGlzHS RbmSec6vCqKs5t0IwuqbbeyxihP3/tmYXcc0q/2xHYdEJMHO4eFdIqsvov8WxMpS8bbW ZRkw== 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=GeNvfbfkyIwPcNI34NhLe77cFjgOY6pl+A5skoCN/yxbUfemUqPkbbrncY2NmsElRF hnPClAVTfz2HCuFPFtlPeGnFsJ01l259OuilV+G1N2+nfsAnqGNlFr4OIajd4c0jBdUf 6O3W4Lm/r3gkdWr/6gBwThCJ9dMp0CLOxvMizX5j9rmH8/3ZhXsFJudOxT2neZf7/3UY f/Vsq+IX/2NYPBH42HV3FuUkc6oE7PTiVDk1rQfCT9n1w0C+5AT27mOUBvtcCbvUbZ9q Ool6rcKG5cDXOMZ3lwYAnoioJeXi/bGL5R4Edjepwf6YoMYKjUO2TX7fQTKlRj06PTq6 BC+g== X-Gm-Message-State: AKGB3mL/TUBBecm5CGQFfid/ChDvEkliiihu81Vms+930RAo44ST+qW5 Q9FEk9ZHsf2lw9rXi7fKCQc= X-Google-Smtp-Source: ACJfBovmwhDQ+CU+wqe7g14dQxNIwWN31Pe9TdJjy7DFIwau2rrnC18YWRoK2OGSBURxP/eMXlHC0w== X-Received: by 10.101.81.7 with SMTP id f7mr26935454pgq.447.1515990149291; Sun, 14 Jan 2018 20:22:29 -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 v7sm17011018pgs.83.2018.01.14.20.22.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 14 Jan 2018 20:22:28 -0800 (PST) From: Nicolin Chen To: timur@tabi.org, broonie@kernel.org, mail@maciej.szmigiero.name Date: Sun, 14 Jan 2018 20:21:23 -0800 Message-Id: <1515990087-11598-14-git-send-email-nicoleotsuka@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1515990087-11598-1-git-send-email-nicoleotsuka@gmail.com> References: <1515990087-11598-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 v3 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)