From patchwork Tue Jun 16 07:30:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shengjiu Wang X-Patchwork-Id: 187977 Delivered-To: patch@linaro.org Received: by 2002:a92:cf06:0:0:0:0:0 with SMTP id c6csp3418254ilo; Tue, 16 Jun 2020 00:41:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyP23TYnCf3f3qnFwYyVTr4+XNhorSuQhVkxI4809SWHXvVP6rJuwwT0jl0gV5i+TX+NYgy X-Received: by 2002:a17:906:90b:: with SMTP id i11mr1501165ejd.343.1592293311430; Tue, 16 Jun 2020 00:41:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592293311; cv=none; d=google.com; s=arc-20160816; b=rlUrG9pS1rSquaXzkg1haq6M3K5gbWsmnP4Tk6K3NgRao3h1uwnVu0vGd9x8sU6zZh 7z8EpBRHRs14w0mns6CLgfg5gmuRWpYyTFZL8hFD3vBnurNgYQZ4GzAd2ikfCwfUH7ga wBIrT+F3WIPEDYHA7Av+7P3jS/oxQ5zC9xqcucEY+HTocPGVZlqvk8I/J8o7I4AYDKz+ jou9ri6eAL9iibMt7CuGMOf4h373JtZFy4TeMuGUHDeW68fhxRGi6NL6aBGeM/flayHk xKEQrAbw+mAusMbCv++zkC6FhWhdMaytP2m3EXgR1Bnm9MSjDnTmGkSQ/jQ6LAmFfIBG hT9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=j0PLa6/eUQvYGpZIXSrs2Xn2IRXns8ZFm0mruUcvafw=; b=k9tfTBdXl0EoKlmJgks5zl8F1ym7pkCT3cGsZSWHraepaT+wNXz5XIWNFqqKEs1Dt2 uBD1NhoeCTzjZdZyAXduegxGeq/4lgSMD2phxGIpD94aevjVmnAKK3e7+G0KQqQ2uB07 Eb67W4h9Z7CVT5IE+ycYre4EEkONaQ0oXzVmUe6OzO4qLzandZQiiLiqQ8RLC1j47sXG XnMMNt+oD3XeNE070oai8JphNd0EUMdS6ZIXdlSSJX5ohKEzYcCXgW/TII92a1cLkW4z LE9K/tUvT+2yC8oz+ciDAB1pOJoqP+jAy+nfjTvf68V0ZG3XSS3eSUAYWXHrj8WV6olx dsDA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-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 bi11si9614495edb.544.2020.06.16.00.41.50; Tue, 16 Jun 2020 00:41:51 -0700 (PDT) Received-SPF: pass (google.com: domain of devicetree-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 devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-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 S1727006AbgFPHlu (ORCPT + 6 others); Tue, 16 Jun 2020 03:41:50 -0400 Received: from inva021.nxp.com ([92.121.34.21]:59902 "EHLO inva021.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726261AbgFPHlu (ORCPT ); Tue, 16 Jun 2020 03:41:50 -0400 Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id BCEA9200495; Tue, 16 Jun 2020 09:41:48 +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 7FF912004BB; Tue, 16 Jun 2020 09:41:43 +0200 (CEST) Received: from localhost.localdomain (shlinux2.ap.freescale.net [10.192.224.44]) by invc005.ap-rdc01.nxp.com (Postfix) with ESMTP id B6B2B402E8; Tue, 16 Jun 2020 15:41:36 +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 1/2] ASoC: bindings: fsl-asoc-card: Add compatible string for MQS Date: Tue, 16 Jun 2020 15:30:36 +0800 Message-Id: <1592292637-25734-1-git-send-email-shengjiu.wang@nxp.com> X-Mailer: git-send-email 2.7.4 X-Virus-Scanned: ClamAV using ClamSMTP Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Add compatible string "fsl,imx-audio-mqs" for MQS Signed-off-by: Shengjiu Wang --- Documentation/devicetree/bindings/sound/fsl-asoc-card.txt | 2 ++ 1 file changed, 2 insertions(+) -- 2.21.0 diff --git a/Documentation/devicetree/bindings/sound/fsl-asoc-card.txt b/Documentation/devicetree/bindings/sound/fsl-asoc-card.txt index c60a5732d29c..6417c5dffa9a 100644 --- a/Documentation/devicetree/bindings/sound/fsl-asoc-card.txt +++ b/Documentation/devicetree/bindings/sound/fsl-asoc-card.txt @@ -34,6 +34,8 @@ The compatible list for this generic sound card currently: "fsl,imx-audio-wm8960" + "fsl,imx-audio-mqs" + Required properties: - compatible : Contains one of entries in the compatible list. From patchwork Tue Jun 16 07:30:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shengjiu Wang X-Patchwork-Id: 187978 Delivered-To: patch@linaro.org Received: by 2002:a92:cf06:0:0:0:0:0 with SMTP id c6csp3418298ilo; Tue, 16 Jun 2020 00:41:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJydoPeF7inX3MrgnRIpUMhUvSIYtN2x2fLLoLkyXmuEVjsYFy5tsjC+WBdGo/DhMbixtPqM X-Received: by 2002:a17:906:5785:: with SMTP id k5mr1504226ejq.494.1592293314357; Tue, 16 Jun 2020 00:41:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592293314; cv=none; d=google.com; s=arc-20160816; b=XpQO04p3AW0R24p5WSZwuoxKsu9EVPBo+J50rRtaSk45Y/ONsGqaYaM1hCdJEZqOxy eb+KVY//kwxlmlpvNrePJA8ZJTRuSVu+grHL4K7MkcVJFSjtErUw+qayachvTwaOxUJi du6SlDxbLMwwRHOzlczCzHPzamJaorOWZKrn4QTaeM3quPi6i0309dJ7bJp1U/YwEr5q mWW6afVSfjJNdcVzMgO2FH5Kx4piuWuXxI1K7dEk9xx9po0mYhJnPxYb28y/7IdGQJk+ aPdOwXwtYRFBPppm4NJnaeZtYzjDCDvTsKaC8dp/9puDc0nLOVuzKkNZbtwuz+cAyW87 mGDQ== 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:message-id:date :subject:cc:to:from; bh=nPkRo7EnYOtQMn2qbWXKKInwEw4WzuJ07a5l21yaJC4=; b=lgNXwLUp91MAh4KXhfJqVqz0MPGJDvMGntohTaz77FU45cCYeQ+0/yRlzAvewMJGnh d4gbMRetiP8ftnBXTxExFc/Yd5fjQdNQpzAs2KkHJtE4jXubsqF0d9djVmFRuc52ICZU PW+/MG62ySVmtZVOsJKXg4jZ2UMVHhOcxsDyTyaGgIqhzwaaKHLys96rL13Rn0MjFwPN 8JMETTI4UEFzRLAqqVi4GIppriHQz7x9SF9Z5BWkTH9Mj3DdSQbwGg7roY58qCvRV4yp LqlDsbxQ8R2882HKs1KBiGG0FdxMjgqb5NN73GwpsrPJbcR0MTnhC7Lfb/ib89XIBO14 7GYw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-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 bi11si9614495edb.544.2020.06.16.00.41.54; Tue, 16 Jun 2020 00:41:54 -0700 (PDT) Received-SPF: pass (google.com: domain of devicetree-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 devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-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 S1726891AbgFPHlx (ORCPT + 6 others); Tue, 16 Jun 2020 03:41:53 -0400 Received: from inva020.nxp.com ([92.121.34.13]:41428 "EHLO inva020.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726261AbgFPHlw (ORCPT ); Tue, 16 Jun 2020 03:41:52 -0400 Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 2B92C1A05F8; Tue, 16 Jun 2020 09:41:50 +0200 (CEST) Received: from invc005.ap-rdc01.nxp.com (invc005.ap-rdc01.nxp.com [165.114.16.14]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id B7B011A16D6; Tue, 16 Jun 2020 09:41:44 +0200 (CEST) Received: from localhost.localdomain (shlinux2.ap.freescale.net [10.192.224.44]) by invc005.ap-rdc01.nxp.com (Postfix) with ESMTP id 043F84030D; Tue, 16 Jun 2020 15:41:37 +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 2/2] ASoC: fsl-asoc-card: Add MQS support Date: Tue, 16 Jun 2020 15:30:37 +0800 Message-Id: <1592292637-25734-2-git-send-email-shengjiu.wang@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1592292637-25734-1-git-send-email-shengjiu.wang@nxp.com> References: <1592292637-25734-1-git-send-email-shengjiu.wang@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org The MQS codec isn't an i2c device, so add a new platform device for it. MQS only support playback, so add a new audio map. Add there maybe "model" property or no "audio-routing" property in devicetree, so add some enhancement for these two property. Signed-off-by: Shengjiu Wang --- sound/soc/fsl/fsl-asoc-card.c | 70 ++++++++++++++++++++++++++--------- 1 file changed, 52 insertions(+), 18 deletions(-) -- 2.21.0 diff --git a/sound/soc/fsl/fsl-asoc-card.c b/sound/soc/fsl/fsl-asoc-card.c index 00be73900888..2ac8cb9ddd10 100644 --- a/sound/soc/fsl/fsl-asoc-card.c +++ b/sound/soc/fsl/fsl-asoc-card.c @@ -119,6 +119,13 @@ static const struct snd_soc_dapm_route audio_map_ac97[] = { {"ASRC-Capture", NULL, "AC97 Capture"}, }; +static const struct snd_soc_dapm_route audio_map_tx[] = { + /* 1st half -- Normal DAPM routes */ + {"Playback", NULL, "CPU-Playback"}, + /* 2nd half -- ASRC DAPM routes */ + {"CPU-Playback", NULL, "ASRC-Playback"}, +}; + /* Add all possible widgets into here without being redundant */ static const struct snd_soc_dapm_widget fsl_asoc_card_dapm_widgets[] = { SND_SOC_DAPM_LINE("Line Out Jack", NULL), @@ -482,6 +489,7 @@ static int fsl_asoc_card_probe(struct platform_device *pdev) { struct device_node *cpu_np, *codec_np, *asrc_np; struct device_node *np = pdev->dev.of_node; + struct platform_device *codec_pdev = NULL; /* used for non i2c device*/ struct platform_device *asrc_pdev = NULL; struct platform_device *cpu_pdev; struct fsl_asoc_card_priv *priv; @@ -512,10 +520,13 @@ static int fsl_asoc_card_probe(struct platform_device *pdev) } codec_np = of_parse_phandle(np, "audio-codec", 0); - if (codec_np) + if (codec_np) { codec_dev = of_find_i2c_device_by_node(codec_np); - else + if (!codec_dev) + codec_pdev = of_find_device_by_node(codec_np); + } else { codec_dev = NULL; + } asrc_np = of_parse_phandle(np, "audio-asrc", 0); if (asrc_np) @@ -525,6 +536,13 @@ static int fsl_asoc_card_probe(struct platform_device *pdev) if (codec_dev) { struct clk *codec_clk = clk_get(&codec_dev->dev, NULL); + if (!IS_ERR(codec_clk)) { + priv->codec_priv.mclk_freq = clk_get_rate(codec_clk); + clk_put(codec_clk); + } + } else if (codec_pdev) { + struct clk *codec_clk = clk_get(&codec_pdev->dev, NULL); + if (!IS_ERR(codec_clk)) { priv->codec_priv.mclk_freq = clk_get_rate(codec_clk); clk_put(codec_clk); @@ -538,6 +556,11 @@ static int fsl_asoc_card_probe(struct platform_device *pdev) /* Assign a default DAI format, and allow each card to overwrite it */ priv->dai_fmt = DAI_FMT_BASE; + memcpy(priv->dai_link, fsl_asoc_card_dai, + sizeof(struct snd_soc_dai_link) * ARRAY_SIZE(priv->dai_link)); + + priv->card.dapm_routes = audio_map; + priv->card.num_dapm_routes = ARRAY_SIZE(audio_map); /* Diversify the card configurations */ if (of_device_is_compatible(np, "fsl,imx-audio-cs42888")) { codec_dai_name = "cs42888"; @@ -573,13 +596,25 @@ static int fsl_asoc_card_probe(struct platform_device *pdev) codec_dai_name = "ac97-hifi"; priv->card.set_bias_level = NULL; priv->dai_fmt = SND_SOC_DAIFMT_AC97; + priv->card.dapm_routes = audio_map_ac97; + priv->card.num_dapm_routes = ARRAY_SIZE(audio_map_ac97); + } else if (of_device_is_compatible(np, "fsl,imx-audio-mqs")) { + codec_dai_name = "fsl-mqs-dai"; + priv->card.set_bias_level = NULL; + priv->dai_fmt = SND_SOC_DAIFMT_LEFT_J | + SND_SOC_DAIFMT_CBS_CFS | + SND_SOC_DAIFMT_NB_NF; + priv->dai_link[1].dpcm_playback = 1; + priv->dai_link[2].dpcm_playback = 1; + priv->card.dapm_routes = audio_map_tx; + priv->card.num_dapm_routes = ARRAY_SIZE(audio_map_tx); } else { dev_err(&pdev->dev, "unknown Device Tree compatible\n"); ret = -EINVAL; goto asrc_fail; } - if (!fsl_asoc_card_is_ac97(priv) && !codec_dev) { + if (!fsl_asoc_card_is_ac97(priv) && !codec_dev && !codec_pdev) { dev_err(&pdev->dev, "failed to find codec device\n"); ret = -EPROBE_DEFER; goto asrc_fail; @@ -601,19 +636,18 @@ static int fsl_asoc_card_probe(struct platform_device *pdev) priv->cpu_priv.sysclk_id[0] = FSL_SAI_CLK_MAST1; } - snprintf(priv->name, sizeof(priv->name), "%s-audio", - fsl_asoc_card_is_ac97(priv) ? "ac97" : - codec_dev->name); - /* Initialize sound card */ priv->pdev = pdev; priv->card.dev = &pdev->dev; - priv->card.name = priv->name; + ret = snd_soc_of_parse_card_name(&priv->card, "model"); + if (ret) { + snprintf(priv->name, sizeof(priv->name), "%s-audio", + fsl_asoc_card_is_ac97(priv) ? "ac97" : + (codec_dev ? codec_dev->name : codec_pdev->name)); + priv->card.name = priv->name; + } priv->card.dai_link = priv->dai_link; - priv->card.dapm_routes = fsl_asoc_card_is_ac97(priv) ? - audio_map_ac97 : audio_map; priv->card.late_probe = fsl_asoc_card_late_probe; - priv->card.num_dapm_routes = ARRAY_SIZE(audio_map); priv->card.dapm_widgets = fsl_asoc_card_dapm_widgets; priv->card.num_dapm_widgets = ARRAY_SIZE(fsl_asoc_card_dapm_widgets); @@ -621,13 +655,12 @@ static int fsl_asoc_card_probe(struct platform_device *pdev) if (!asrc_pdev) priv->card.num_dapm_routes /= 2; - memcpy(priv->dai_link, fsl_asoc_card_dai, - sizeof(struct snd_soc_dai_link) * ARRAY_SIZE(priv->dai_link)); - - ret = snd_soc_of_parse_audio_routing(&priv->card, "audio-routing"); - if (ret) { - dev_err(&pdev->dev, "failed to parse audio-routing: %d\n", ret); - goto asrc_fail; + if (of_property_read_bool(np, "audio-routing")) { + ret = snd_soc_of_parse_audio_routing(&priv->card, "audio-routing"); + if (ret) { + dev_err(&pdev->dev, "failed to parse audio-routing: %d\n", ret); + goto asrc_fail; + } } /* Normal DAI Link */ @@ -724,6 +757,7 @@ static const struct of_device_id fsl_asoc_card_dt_ids[] = { { .compatible = "fsl,imx-audio-sgtl5000", }, { .compatible = "fsl,imx-audio-wm8962", }, { .compatible = "fsl,imx-audio-wm8960", }, + { .compatible = "fsl,imx-audio-mqs", }, {} }; MODULE_DEVICE_TABLE(of, fsl_asoc_card_dt_ids);