From patchwork Mon Jan 15 23:16:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolin Chen X-Patchwork-Id: 10165479 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 A3EBE602C2 for ; Mon, 15 Jan 2018 23:20:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4E00A27C0B for ; Mon, 15 Jan 2018 23:20:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9E2BF27F82; Mon, 15 Jan 2018 23:20:44 +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 F1EDE2832B for ; Mon, 15 Jan 2018 23:20:40 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id DC15126769C; Tue, 16 Jan 2018 00:17:47 +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 D670326765E; Tue, 16 Jan 2018 00:17:41 +0100 (CET) Received: from mail-pl0-f66.google.com (mail-pl0-f66.google.com [209.85.160.66]) by alsa0.perex.cz (Postfix) with ESMTP id 6C33C267656 for ; Tue, 16 Jan 2018 00:17:36 +0100 (CET) Received: by mail-pl0-f66.google.com with SMTP id 66so4718251plc.13 for ; Mon, 15 Jan 2018 15:17:36 -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=1/W19q46SUwHfBnyi0YSmTJLnLWwXGMZNVZ393wh1mo=; b=OqYHMFxTEaPmJ+56c/8bHCwqp+s59SWa35Q3MJ0p9kwHszdzVxVX9LYsTGmjFWMl6b s/5Zy3uuOCc+WYk1fHPWr52a6m5C0SqfudhFdZszA37STQmvQAWbJ0GIn6TidJVve9Fe RDS5ItSzKDwZlRaulCcDthnAg98E3iL5DRl4Yx7I1mPrO96QQAlzHS4KrAAd+7q4OZ+t 0jyHYI5QmrjtD8cr1jCfM6TY7gKU05PFgKjJXF6ZnxJE8QVcH80dykBMFikuEiTB/v3Q vGvyg2UawbGmglpwES6DFrcOkYym/EZ1jMlp3nQBcp+m245DnObF1hjufy7BoZwh7ZDR CmLQ== 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=1/W19q46SUwHfBnyi0YSmTJLnLWwXGMZNVZ393wh1mo=; b=IOJ2byjhpP+RtjO5nZIt1D/TgW+nMmgpi7E0ry7N+e0LOo5QySXKh4LlCTH/27vWyt xrRfgkZ9FHiL9/CRfhstC56VJhr/QfhHw0d2oc+rPY+EA8q4T6tIhgPh24QnysmtZFUp MKuC3J96mz1yCQIBY0dBV0bLAmvRV0eJj03qoz2KeG/SP9y6+kNLYRMazcJZIHX0IJ/h 0PQ5iDRvR7u8jzv7aB0H3OoQWXtDvqTjLkLq8zBJT27qmKLZPjcgQK5WVC4iTfvIABLC SCiOCo+hTK5trljCn/gAkwdNtMGi07loFilFPOiqU0mWBgVBBf7aSAAV9B7/eoRaxRUI 4lyg== X-Gm-Message-State: AKwxytfTKOAdNqka0hUtsINQxfuEHjtFqZueog7JYYRA6T6IvChAMNSc f8uJJx/GvXPAWqI87Mnccv0= X-Google-Smtp-Source: ACJfBou4D8mHeHNa7qNdFTo55HF52bpyrlKRu6In/aj1DVZCkksNo1rGSi+zX6m6RyPYCYvyYK9HLQ== X-Received: by 10.159.216.147 with SMTP id s19mr1624370plp.101.1516058255305; Mon, 15 Jan 2018 15:17:35 -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.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 15 Jan 2018 15:17:34 -0800 (PST) From: Nicolin Chen To: timur@tabi.org, broonie@kernel.org, mail@maciej.szmigiero.name Date: Mon, 15 Jan 2018 15:16:27 -0800 Message-Id: <1516058192-65519-13-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 12/17] ASoC: fsl_ssi: Move one-time configurations to probe() 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 The probe() could handle some one-time configurations since they will not be changed once being configured. Signed-off-by: Nicolin Chen Tested-by: Caleb Crome --- Changelog v2 * Moved all to fsl_ssi_hw_init() in platform probe() sound/soc/fsl/fsl_ssi.c | 39 ++++++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c index e1fe511..50648f5 100644 --- a/sound/soc/fsl/fsl_ssi.c +++ b/sound/soc/fsl/fsl_ssi.c @@ -865,7 +865,6 @@ static int _fsl_ssi_set_dai_fmt(struct device *dev, { struct regmap *regs = ssi->regs; u32 strcr = 0, stcr, srcr, scr, mask; - u8 wm; ssi->dai_fmt = fmt; @@ -874,8 +873,6 @@ static int _fsl_ssi_set_dai_fmt(struct device *dev, return -EINVAL; } - fsl_ssi_setup_regvals(ssi); - regmap_read(regs, REG_SSI_SCR, &scr); scr &= ~(SSI_SCR_SYN | SSI_SCR_I2S_MODE_MASK); /* Synchronize frame sync clock for TE to avoid data slipping */ @@ -990,16 +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); - wm = ssi->fifo_watermark; - - regmap_write(regs, REG_SSI_SFCSR, - SSI_SFCSR_TFWM0(wm) | SSI_SFCSR_RFWM0(wm) | - SSI_SFCSR_TFWM1(wm) | SSI_SFCSR_RFWM1(wm)); - - if (ssi->use_dual_fifo) - regmap_update_bits(regs, REG_SSI_SCR, - SSI_SCR_TCH_EN, SSI_SCR_TCH_EN); - if ((fmt & SND_SOC_DAIFMT_FORMAT_MASK) == SND_SOC_DAIFMT_AC97) fsl_ssi_setup_ac97(ssi); @@ -1249,6 +1236,29 @@ static struct snd_ac97_bus_ops fsl_ssi_ac97_ops = { }; /** + * Initialize SSI registers + */ +static int fsl_ssi_hw_init(struct fsl_ssi *ssi) +{ + u32 wm = ssi->fifo_watermark; + + /* Initialize regvals */ + fsl_ssi_setup_regvals(ssi); + + /* Set watermarks */ + regmap_write(ssi->regs, REG_SSI_SFCSR, + SSI_SFCSR_TFWM0(wm) | SSI_SFCSR_RFWM0(wm) | + SSI_SFCSR_TFWM1(wm) | SSI_SFCSR_RFWM1(wm)); + + /* Enable Dual FIFO mode */ + if (ssi->use_dual_fifo) + regmap_update_bits(ssi->regs, REG_SSI_SCR, + SSI_SCR_TCH_EN, SSI_SCR_TCH_EN); + + return 0; +} + +/** * Make every character in a string lower-case */ static void make_lowercase(char *s) @@ -1533,6 +1543,9 @@ static int fsl_ssi_probe(struct platform_device *pdev) if (ssi->dai_fmt) _fsl_ssi_set_dai_fmt(dev, ssi, ssi->dai_fmt); + /* Initially configures SSI registers */ + fsl_ssi_hw_init(ssi); + if (fsl_ssi_is_ac97(ssi)) { u32 ssi_idx;