From patchwork Mon Feb 12 22:03:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolin Chen X-Patchwork-Id: 10214611 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 C792A60467 for ; Mon, 12 Feb 2018 22:05:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A553D26538 for ; Mon, 12 Feb 2018 22:05:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 997C0289C2; Mon, 12 Feb 2018 22:05:23 +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 D0B7526538 for ; Mon, 12 Feb 2018 22:05:22 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 190372676A9; Mon, 12 Feb 2018 23:03:05 +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 EB8E82676A7; Mon, 12 Feb 2018 23:03:01 +0100 (CET) Received: from mail-pl0-f65.google.com (mail-pl0-f65.google.com [209.85.160.65]) by alsa0.perex.cz (Postfix) with ESMTP id 195692675FA for ; Mon, 12 Feb 2018 23:02:53 +0100 (CET) Received: by mail-pl0-f65.google.com with SMTP id 31so116745ple.9 for ; Mon, 12 Feb 2018 14:02:53 -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=beNX6iYh6AKdtWqgcDrjiE6a9UhcrN7kktCRzntUhug=; b=IlIIF8zsOU7nJG8Ua4HTVKoAnqnTK78TGZITtMzZ6RIjD8KnVgIDQpmUF5tVJ8Mt1V kuPRH56F2imaUfX4A9MyJs36Fz7DkA2P3bHX8KuOl1ohRCbrkk1MJLjcdNG1Tv4KBbCi 6QNiDArb8820XhfZbXXcR+AsoxUtKQxoNYNRxyr1beALZN8E5t2IGz1c7lLJDuEHrpwn kLBunuGa2U/pWAwVjGgo7SIsal4oHEEQ+xZ6AIf7psmTNlNwqR1p839U/alhR90bWyF+ gHU/ixqALMIvWCRd7C0zieQGkBESf8el/DCcJ4fksI6MRCT7AMqeMeLapm9M77wdP0Mn qpfA== 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=beNX6iYh6AKdtWqgcDrjiE6a9UhcrN7kktCRzntUhug=; b=EAvbXCEkdt8EhuPYwAbz3hvjMaCXEgdJlCM3sKftcJCMgVxvGLpyD8MmfsgQ2/7gAj UKBbUhXnUkYI+5NO9V9jfNtWzliWKklTE4LbfkubnkdJ0XiFItZt4jErWEu7Ac6k0u12 zmVmy0Bn/Rr94o/wFEVWrQuz7NZ9m77lw9ruCPhJcrJie6j9s0iv1VjKT4cIDu1pQaTK o4+8FrPMsu2k/2wqEWldB94VbhaNw66KeVHUXpqcIFaxfjIcR/y5IvYXhwrFWjm2AAgL EbsPCnRyqU29ge9o4HEHxPlGlHZynkPKOGj53G06o8L7XIfnVpgg14/OwjSnJwvHIwfc 2ByQ== X-Gm-Message-State: APf1xPCSi03IF75zjy6DmK6y4UGaVbmCii31YsTo7o0+lz+jWG7C4uq/ x9y9R/f6Hr4nM1i0j4FCSnU= X-Google-Smtp-Source: AH8x227bLDp/0BISpiJtecpaJDh03GE0uipI6G+M3GUkFfQW0G8vKE4ZnHVPneuVz1MMVqbymdGJkA== X-Received: by 2002:a17:902:b610:: with SMTP id b16-v6mr11822493pls.132.1518472972949; Mon, 12 Feb 2018 14:02:52 -0800 (PST) Received: from Asurada-Nvidia.nvidia.com (thunderhill.nvidia.com. [216.228.112.22]) by smtp.gmail.com with ESMTPSA id c8sm13386159pgn.72.2018.02.12.14.02.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 12 Feb 2018 14:02:52 -0800 (PST) From: Nicolin Chen To: broonie@kernel.org, timur@tabi.org Date: Mon, 12 Feb 2018 14:03:20 -0800 Message-Id: <1518473005-14090-13-git-send-email-nicoleotsuka@gmail.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1518473005-14090-1-git-send-email-nicoleotsuka@gmail.com> References: <1518473005-14090-1-git-send-email-nicoleotsuka@gmail.com> Cc: mail@maciej.szmigiero.name, kernel@pengutronix.de, lgirdwood@gmail.com, alsa-devel@alsa-project.org, caleb@crome.org, linux-kernel@vger.kernel.org, arnaud.mouiche@invoxia.com, lukma@denx.de, fabio.estevam@nxp.com, linuxppc-dev@lists.ozlabs.org Subject: [alsa-devel] [PATCH v6 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 Tested-by: Maciej S. Szmigiero Reviewed-by: Maciej S. Szmigiero --- 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 7e15b30..36f3d51 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;