Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp276542ybt; Wed, 17 Jun 2020 00:11:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxw/nWNgLW2iJwWH+B1I14O9+sMd4kPIucGi0v+E4/94eyYFC3cE3/D5wiTWi0v+ddOI8gE X-Received: by 2002:a05:6402:144e:: with SMTP id d14mr5937596edx.14.1592377899146; Wed, 17 Jun 2020 00:11:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592377899; cv=none; d=google.com; s=arc-20160816; b=aIljlnMt3rheYcR2JfXa7rjfEFecyIID1O+ovs380Sfbbobwb8cf7zT2NNLL985BRs kMPvCrysEwdIVwaIIE4Iiubn3R/gFKwans92DffkIBiOBPfDxFtObeKgGp2I1STyHSov 6JLAf2tUB74ginxu474ezv6toA48szdOZpaqGuapbaT0yhaP69pL5yTOs/gVIbtkw8US x0sauS8hhISsa3Z4SJIEEVMwUS9zzUO6NJa3tn+WSKkAEhZlLrbZVFwFMsBKtzLzXoPC Wc/1AMMHQtE6+QyskquUgOhAcA7yO5VAc5uxuVC/j/X3zS2oIo6s3C0KveHEN4W83eDc 1nhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from; bh=hOmZ8AT8vC0pqYAEzpZYplH9zdXHLZxyYO7/FDQjEMw=; b=veOCp5FYvUcb2j5H08inIDM5nWBW026shEE6me1ILutBDblhfq9dO+gLHfLqLWi9OD E7kNvoZ9+lyRppyKf2zJtVQrbi1rzB4uPNiJUHqn1OFSsnOUC8iqfS/HgaAxJvm3TgiS yqe2L4sE++rnSQFDQtT8upvkyDtbvS9K8HJM/fsPB9eJ2XiOv84wwHptRgr2LPGJPkET 3y7O6M92gdE2pkWJ6ZxO1G2myyL1Sz5+kg7i9pkjq+uAHoBFD8FLldmtpfxJyWb7B4MQ RXTY7hEMUPkPlunmGSboIcSf2n8d4tYJimG2KGyraunYgq75Ds0T5W59pQS7Go1SUily Bevg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c6si12324762edw.220.2020.06.17.00.11.17; Wed, 17 Jun 2020 00:11:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726303AbgFQHJX (ORCPT + 99 others); Wed, 17 Jun 2020 03:09:23 -0400 Received: from inva021.nxp.com ([92.121.34.21]:60778 "EHLO inva021.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726308AbgFQHJU (ORCPT ); Wed, 17 Jun 2020 03:09:20 -0400 Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 9812C2008E7; Wed, 17 Jun 2020 09:09:17 +0200 (CEST) Received: from invc005.ap-rdc01.nxp.com (invc005.ap-rdc01.nxp.com [165.114.16.14]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 2D74B2008F7; Wed, 17 Jun 2020 09:09:12 +0200 (CEST) Received: from localhost.localdomain (shlinux2.ap.freescale.net [10.192.224.44]) by invc005.ap-rdc01.nxp.com (Postfix) with ESMTP id 67105402B1; Wed, 17 Jun 2020 15:09:05 +0800 (SGT) From: Shengjiu Wang To: timur@kernel.org, nicoleotsuka@gmail.com, Xiubo.Lee@gmail.com, festevam@gmail.com, broonie@kernel.org, perex@perex.cz, tiwai@suse.com, alsa-devel@alsa-project.org, lgirdwood@gmail.com, robh+dt@kernel.org, devicetree@vger.kernel.org Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 2/2] ASoC: fsl_spdif: Add support for imx6sx platform Date: Wed, 17 Jun 2020 14:58:01 +0800 Message-Id: <7a343edd5f8487abad248a0b862f45fd95067751.1592376770.git.shengjiu.wang@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: References: In-Reply-To: References: X-Virus-Scanned: ClamAV using ClamSMTP Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The one difference on imx6sx platform is that the root clock is shared with ASRC module, so we add a new flags "shared_root_clock" which means the root clock is not independent, then we will not do the clk_set_rate and clk_round_rate to avoid impact ASRC module usage. As add a new flags, we include the soc specific data struct. Signed-off-by: Shengjiu Wang Reviewed-by: Nicolin Chen --- changes in v3 - refine some comments - add Reviewed-by: Nicolin Chen changes in v2 - use shared_root_clk instead ind_root_clk. - add fsl_spdif_can_set_clk_rate function. sound/soc/fsl/fsl_spdif.c | 50 +++++++++++++++++++++++++++++++++++---- 1 file changed, 45 insertions(+), 5 deletions(-) diff --git a/sound/soc/fsl/fsl_spdif.c b/sound/soc/fsl/fsl_spdif.c index 1b2e516f9162..5bc0e4729341 100644 --- a/sound/soc/fsl/fsl_spdif.c +++ b/sound/soc/fsl/fsl_spdif.c @@ -42,6 +42,18 @@ static u8 srpc_dpll_locked[] = { 0x0, 0x1, 0x2, 0x3, 0x4, 0xa, 0xb }; #define DEFAULT_RXCLK_SRC 1 +/** + * struct fsl_spdif_soc_data: soc specific data + * + * @imx: for imx platform + * @shared_root_clock: flag of sharing a clock source with others; + * so the driver shouldn't set root clock rate + */ +struct fsl_spdif_soc_data { + bool imx; + bool shared_root_clock; +}; + /* * SPDIF control structure * Defines channel status, subcode and Q sub @@ -89,6 +101,7 @@ struct spdif_mixer_control { * @dma_params_rx: DMA parameters for receive channel */ struct fsl_spdif_priv { + const struct fsl_spdif_soc_data *soc; struct spdif_mixer_control fsl_spdif_control; struct snd_soc_dai_driver cpu_dai_drv; struct platform_device *pdev; @@ -110,6 +123,27 @@ struct fsl_spdif_priv { u32 regcache_srpc; }; +static struct fsl_spdif_soc_data fsl_spdif_vf610 = { + .imx = false, + .shared_root_clock = false, +}; + +static struct fsl_spdif_soc_data fsl_spdif_imx35 = { + .imx = true, + .shared_root_clock = false, +}; + +static struct fsl_spdif_soc_data fsl_spdif_imx6sx = { + .imx = true, + .shared_root_clock = true, +}; + +/* Check if clk is a root clock that does not share clock source with others */ +static inline bool fsl_spdif_can_set_clk_rate(struct fsl_spdif_priv *spdif, int clk) +{ + return (clk == STC_TXCLK_SPDIF_ROOT) && !spdif->soc->shared_root_clock; +} + /* DPLL locked and lock loss interrupt handler */ static void spdif_irq_dpll_lock(struct fsl_spdif_priv *spdif_priv) { @@ -420,8 +454,7 @@ static int spdif_set_sample_rate(struct snd_pcm_substream *substream, sysclk_df = spdif_priv->sysclk_df[rate]; - /* Don't mess up the clocks from other modules */ - if (clk != STC_TXCLK_SPDIF_ROOT) + if (!fsl_spdif_can_set_clk_rate(spdif_priv, clk)) goto clk_set_bypass; /* The S/PDIF block needs a clock of 64 * fs * txclk_df */ @@ -1186,7 +1219,7 @@ static int fsl_spdif_probe_txclk(struct fsl_spdif_priv *spdif_priv, continue; ret = fsl_spdif_txclk_caldiv(spdif_priv, clk, savesub, index, - i == STC_TXCLK_SPDIF_ROOT); + fsl_spdif_can_set_clk_rate(spdif_priv, i)); if (savesub == ret) continue; @@ -1230,6 +1263,12 @@ static int fsl_spdif_probe(struct platform_device *pdev) spdif_priv->pdev = pdev; + spdif_priv->soc = of_device_get_match_data(&pdev->dev); + if (!spdif_priv->soc) { + dev_err(&pdev->dev, "failed to get soc data\n"); + return -ENODEV; + } + /* Initialize this copy of the CPU DAI driver structure */ memcpy(&spdif_priv->cpu_dai_drv, &fsl_spdif_dai, sizeof(fsl_spdif_dai)); spdif_priv->cpu_dai_drv.name = dev_name(&pdev->dev); @@ -1359,8 +1398,9 @@ static const struct dev_pm_ops fsl_spdif_pm = { }; static const struct of_device_id fsl_spdif_dt_ids[] = { - { .compatible = "fsl,imx35-spdif", }, - { .compatible = "fsl,vf610-spdif", }, + { .compatible = "fsl,imx35-spdif", .data = &fsl_spdif_imx35, }, + { .compatible = "fsl,vf610-spdif", .data = &fsl_spdif_vf610, }, + { .compatible = "fsl,imx6sx-spdif", .data = &fsl_spdif_imx6sx, }, {} }; MODULE_DEVICE_TABLE(of, fsl_spdif_dt_ids); -- 2.21.0