From patchwork Mon Jan 15 04:21:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolin Chen X-Patchwork-Id: 10163019 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 7F8E1601C0 for ; Mon, 15 Jan 2018 04:25:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8147D28904 for ; Mon, 15 Jan 2018 04:25:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 75BE9289FF; Mon, 15 Jan 2018 04:25:00 +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 7F9BC28904 for ; Mon, 15 Jan 2018 04:24:59 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 984BF2673DA; Mon, 15 Jan 2018 05:22:38 +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 A5FE82673A0; Mon, 15 Jan 2018 05:22:32 +0100 (CET) Received: from mail-pf0-f194.google.com (mail-pf0-f194.google.com [209.85.192.194]) by alsa0.perex.cz (Postfix) with ESMTP id 5E434267399 for ; Mon, 15 Jan 2018 05:22:29 +0100 (CET) Received: by mail-pf0-f194.google.com with SMTP id b25so1187833pfd.9 for ; Sun, 14 Jan 2018 20:22:29 -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=ZZ8oT10DwLqaz94oElgPU4xaEC1VgpZWWT2e/JEjztl66qspSQGJ3154Qx/O7iEogV 8zyPCV2VdxpFaBvQwLMfuyqeIguGFaMVGWuGDbFNFj3FIOmtW9YTs+wCzqXKLckrgH/9 e7h9JlqXv6FYzEGFATZ2chxK4J0LwcFohkM/rN+WwgN50Dc6idnDDtechTW/Ir39WIpL RqU53V6TyCaXrtTWwWiEBtpuTjQBk2eRCROzAHm/Vq0g2Mpb7nNt4QKnKPym3ZnWbkXl wCzLwofFEVOdMx5bOyCAF+QYelvATzASlkaKPb5ConX2K6aYEmJwvSYSBpyl8JfNH95W jHaA== 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=Vlxklmk7KF39LyhjpVbi/pnmZSlhhnBB4K3jSKv/3vUUYv/WIb0hUW5RncV5KYABaT ELLiAtXAudDaJIt6pWOkUO8t3QPRCc+JaF46+aenXZoJECsB7mlYM0QW5xyxWdlTPOIq eRI72aCNBYX5r3uToTbLUAa/+iOzEv8tReiKgrPBD0VOwzgd5N4PgyZLyE3Ljuo3nTNt w4cRpdXZn0P4dQttowaeDP8bA/oFwscWxIR8t+I8QIDDrs9XPz37vH7fJWmVQq5oLSQn pNgy6pMvAsyorZdBBJvTrGVi8+P0RuyztKw5iGiK6w1k3QBSajbxCl1+L30QO2J0wSee 6pQw== X-Gm-Message-State: AKGB3mIrgtW8BGokkvQ5fpPlcr1fuUffWanKUA9vnpAIS5HuEASNbF5K MRCfUKb7M6zx6dwX8rT0MhA= X-Google-Smtp-Source: ACJfBotAjCzOAFxssmkzi5ymrVxtjdY1LMiwkNX0jamR9N6u+UbvWha0yApM0tWjLrW2AgA5SV8qvQ== X-Received: by 10.101.71.205 with SMTP id f13mr26608210pgs.411.1515990148219; Sun, 14 Jan 2018 20:22:28 -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.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 14 Jan 2018 20:22:27 -0800 (PST) From: Nicolin Chen To: timur@tabi.org, broonie@kernel.org, mail@maciej.szmigiero.name Date: Sun, 14 Jan 2018 20:21:22 -0800 Message-Id: <1515990087-11598-13-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 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;