From patchwork Thu Jan 11 06:43:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolin Chen X-Patchwork-Id: 10157323 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 EE661601A1 for ; Thu, 11 Jan 2018 06:47:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DFC24286AE for ; Thu, 11 Jan 2018 06:47:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D45DB286B5; Thu, 11 Jan 2018 06:47:09 +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 42779286AE for ; Thu, 11 Jan 2018 06:47:08 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 3D8C52678D1; Thu, 11 Jan 2018 07:44:28 +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 09DE826788E; Thu, 11 Jan 2018 07:44:22 +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 DE44D267871 for ; Thu, 11 Jan 2018 07:44:16 +0100 (CET) Received: by mail-pf0-f196.google.com with SMTP id p1so873939pfh.4 for ; Wed, 10 Jan 2018 22:44:16 -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=68aTtLW9PAwuHKGZMHMoHvBXzmZblalQZ72dZ9pD6RQ=; b=CxzY3U++g4jrrr4TgzvMfLiApXsSdVpRP9tvckh2fYnujpZXzY+lHJSey2/0ro1Zzl ywFF6LHHxdMWjbC5dYduIoCSq52jjmW6eLMXlft9mHdE9yzc9xTZQUmv3uepGDMrM8r/ 3AGyPDrWpuSDM+YmN56OFeJ3ifvnD05wtXgCySfAEswCopfFk/qbOrHrLtZA2nYZ99c1 ZBgXKlxdN9UheENYu/CKyDMIU0Mmcod5dbEgJ8XOJZxVf4VwEubtWB+xJv97O/nMqUip HcJsQ235EELnF/lkSbcqVDIneZS0LMHk3n90+qxPNoyMzbUdIoInt+sj4nfKq/KFwd4Y dMjg== 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=68aTtLW9PAwuHKGZMHMoHvBXzmZblalQZ72dZ9pD6RQ=; b=RD8t60At+m/3lfjKurjyaO3MD/Sze3wXzvMOG+RL5L0jgGD3SUjPDQnf+SkMxERB+M STjl77iXbzfi0t9mGEaL7EaW0NbcsfN+JJgqCfTdFS9+qhGwfrJk4nn/p5S06MRtUJM7 IBIOtr2phrzRP0mvuMRvAjBqvrYGn/wNSTChmUMDMKMTRCaDiky80bPt+d0CFBSaiisF dKlvRHhzfVX2TXMTXLTxMhCaMtcjZrBxipdIesf06lLiECAW3UjEvW72QNiIIvHwdnu9 sTgz+rZKtM/EQTSuKg2aBf/8Z2/SB/faQWAmWjmGDRZ8xb3UvH3FKLsAL345uUSVktzN ooOA== X-Gm-Message-State: AKwxytf5+hkriFBteXbdh6W0AbACNOt1irj2ZVnw6Icc/Hjap+++Odpi 6fEUch69HS5OKjXvR3Nrma8= X-Google-Smtp-Source: ACJfBouj+lbMUI1lCeXl679DDDgLizHNzegHtZuoFrUPPBu6MG0Pdh3Wf1oXWSTO0IcgQyOYOl548w== X-Received: by 10.84.217.206 with SMTP id d14mr9980021plj.36.1515653055700; Wed, 10 Jan 2018 22:44:15 -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 b69sm27959666pfk.128.2018.01.10.22.44.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 10 Jan 2018 22:44:15 -0800 (PST) From: Nicolin Chen To: timur@tabi.org, broonie@kernel.org, mail@maciej.szmigiero.name Date: Wed, 10 Jan 2018 22:43:10 -0800 Message-Id: <1515652995-15996-12-git-send-email-nicoleotsuka@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1515652995-15996-1-git-send-email-nicoleotsuka@gmail.com> References: <1515652995-15996-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 v2 11/16] 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 --- 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 2c179a7..36e370e 100644 --- a/sound/soc/fsl/fsl_ssi.c +++ b/sound/soc/fsl/fsl_ssi.c @@ -860,7 +860,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; @@ -869,8 +868,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 */ @@ -985,16 +982,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); @@ -1244,6 +1231,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) @@ -1528,6 +1538,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;