Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1508636ybt; Thu, 2 Jul 2020 07:15:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzFicqxA1Whh4Orh5BR+Ao1V6P1zAeL1kO9GyfciezXEVosKEjrL+KY1amT0yqS5ACfex30 X-Received: by 2002:a17:906:2a91:: with SMTP id l17mr28688358eje.539.1593699321131; Thu, 02 Jul 2020 07:15:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593699321; cv=none; d=google.com; s=arc-20160816; b=bZQoJAQ0vxivQpuyLKgvv5ntJDh51Q2LANX9Wn02q3KSu9doynDmQYJe+vHIFF9r9j dnmspNzb6oVJKQYqUPo5IcgOyTFUQ4DSquoLojlj/SwP2xp6QAmVbHhDWR5o2YrN0bmb Kvj66E4UHt0l38whkOBh2nnYeucIFx4Wp+CC+0K3xqs4Z6EZ/WWwkUJE96/sMihH36zA GkHjFfVHPgyPCEB9Pvilt/cOEt6KWytLmVKPPu+oXquGcAORf4GXkCtg7tDX5l2DkVYz j9ofSUEOFJv7RukXRGl0bNs9x7TbyyPVVwgEqptuemujEJbKDk54sctFxEDm2YHdq5q8 wmZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:from; bh=GXdaCQ69t+7Tedve/Ps2T+2cyiX9oWjXNkZ86Vw1cy8=; b=USJ894jQ4iGHXJHo1x1QaiIoGUpaVGT8aQP5Il/0kq+NAeNbGQXl5clzer++TIsBnA BiW21bMCSV66HrOzZM6J9Rldn3WKNJTtkNRbAfOzxFzX/P0VIV9wStz/P7PjyHV+F2/+ A5TPvSz5JN6zZfuTh4ekhXlT2USg4iAYpetulqUpZ2wC0Xm+TQrXu3a57+kFq8+FPbMr qmt6uh+Go/y3/vwUIh+quGNCn0qJ6egzTKfQkQYAyNMyIhUbVfcxhSYjAMHaxpRvwvPm VRKHF2RM3mgI9uq557AhJeYyf80gnKCvzirpoTy22Qx4GTEpc/hC9fkVVdUJkkJ9+peA ehXw== 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=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b8si8018921edz.89.2020.07.02.07.14.57; Thu, 02 Jul 2020 07:15:21 -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=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729539AbgGBOM2 (ORCPT + 99 others); Thu, 2 Jul 2020 10:12:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44842 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728179AbgGBOMV (ORCPT ); Thu, 2 Jul 2020 10:12:21 -0400 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0B0ACC08C5C1; Thu, 2 Jul 2020 07:12:21 -0700 (PDT) Received: from xps.home (unknown [IPv6:2a01:e35:2fb5:1510:315a:ecf0:6250:a3ed]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: aferraris) by bhuna.collabora.co.uk (Postfix) with ESMTPSA id 35F8E2A5EC4; Thu, 2 Jul 2020 15:12:19 +0100 (BST) From: Arnaud Ferraris Cc: kernel@collabora.com, Liam Girdwood , Mark Brown , Rob Herring , Timur Tabi , Nicolin Chen , Xiubo Li , Fabio Estevam , Jaroslav Kysela , Takashi Iwai , alsa-devel@alsa-project.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Subject: [PATCH 2/2] ASoC: fsl-asoc-card: add support for generic I2S slave use-case Date: Thu, 2 Jul 2020 16:11:15 +0200 Message-Id: <20200702141114.232688-3-arnaud.ferraris@collabora.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200702141114.232688-1-arnaud.ferraris@collabora.com> References: <20200702141114.232688-1-arnaud.ferraris@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit To: unlisted-recipients:; (no To-header on input) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This commit implements support for generic codecs with the SoC acting as I2S slave, by implementing the new `fsl,imx-audio-i2s-slave` compatible and related properties. This is particularly useful when using a Bluetooth controller acting as I2S master, but other simple or dummy codecs might benefit from it too. Signed-off-by: Arnaud Ferraris --- sound/soc/fsl/fsl-asoc-card.c | 46 ++++++++++++++++++++++++++--------- 1 file changed, 35 insertions(+), 11 deletions(-) diff --git a/sound/soc/fsl/fsl-asoc-card.c b/sound/soc/fsl/fsl-asoc-card.c index 57ea1b072326..6076b963c873 100644 --- a/sound/soc/fsl/fsl-asoc-card.c +++ b/sound/soc/fsl/fsl-asoc-card.c @@ -166,12 +166,15 @@ static int fsl_asoc_card_hw_params(struct snd_pcm_substream *substream, return 0; /* Specific configurations of DAIs starts from here */ - ret = snd_soc_dai_set_sysclk(asoc_rtd_to_cpu(rtd, 0), cpu_priv->sysclk_id[tx], - cpu_priv->sysclk_freq[tx], - cpu_priv->sysclk_dir[tx]); - if (ret && ret != -ENOTSUPP) { - dev_err(dev, "failed to set sysclk for cpu dai\n"); - return ret; + if (cpu_priv->sysclk_freq[tx] > 0) { + ret = snd_soc_dai_set_sysclk(asoc_rtd_to_cpu(rtd, 0), + cpu_priv->sysclk_id[tx], + cpu_priv->sysclk_freq[tx], + cpu_priv->sysclk_dir[tx]); + if (ret && ret != -ENOTSUPP) { + dev_err(dev, "failed to set sysclk for cpu dai\n"); + return ret; + } } if (cpu_priv->slot_width) { @@ -475,11 +478,14 @@ static int fsl_asoc_card_late_probe(struct snd_soc_card *card) return 0; } - ret = snd_soc_dai_set_sysclk(codec_dai, codec_priv->mclk_id, - codec_priv->mclk_freq, SND_SOC_CLOCK_IN); - if (ret && ret != -ENOTSUPP) { - dev_err(dev, "failed to set sysclk in %s\n", __func__); - return ret; + if (codec_priv->mclk_freq > 0) { + ret = snd_soc_dai_set_sysclk(codec_dai, codec_priv->mclk_id, + codec_priv->mclk_freq, + SND_SOC_CLOCK_IN); + if (ret && ret != -ENOTSUPP) { + dev_err(dev, "failed to set sysclk in %s\n", __func__); + return ret; + } } return 0; @@ -620,6 +626,23 @@ static int fsl_asoc_card_probe(struct platform_device *pdev) priv->cpu_priv.slot_width = 32; priv->card.dapm_routes = audio_map_tx; priv->card.num_dapm_routes = ARRAY_SIZE(audio_map_tx); + } else if (of_device_is_compatible(np, "fsl,imx-audio-i2s-slave")) { + ret = of_property_read_string(np, "audio-codec-dai-name", + &codec_dai_name); + if (ret) { + dev_err(&pdev->dev, "failed to get codec DAI name\n"); + ret = -EINVAL; + goto asrc_fail; + } + ret = of_property_read_u32(np, "audio-slot-width", + &priv->cpu_priv.slot_width); + if (ret) { + dev_err(&pdev->dev, "failed to get slot width\n"); + ret = -EINVAL; + goto asrc_fail; + } + priv->card.set_bias_level = NULL; + priv->dai_fmt |= SND_SOC_DAIFMT_CBM_CFM; } else { dev_err(&pdev->dev, "unknown Device Tree compatible\n"); ret = -EINVAL; @@ -763,6 +786,7 @@ static int fsl_asoc_card_probe(struct platform_device *pdev) static const struct of_device_id fsl_asoc_card_dt_ids[] = { { .compatible = "fsl,imx-audio-ac97", }, + { .compatible = "fsl,imx-audio-i2s-slave", }, { .compatible = "fsl,imx-audio-cs42888", }, { .compatible = "fsl,imx-audio-cs427x", }, { .compatible = "fsl,imx-audio-sgtl5000", }, -- 2.27.0