Received: by 2002:ac0:e350:0:0:0:0:0 with SMTP id g16csp1945159imn; Mon, 1 Aug 2022 05:58:15 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vuSAi7W+KB4O68//0LD2gTCU8qU8tMF3nKPkc/E3VvERvJ1PT9xooeJdH/8n1u0XNs3km2 X-Received: by 2002:a17:907:a06f:b0:72b:564c:465b with SMTP id ia15-20020a170907a06f00b0072b564c465bmr12617827ejc.344.1659358695284; Mon, 01 Aug 2022 05:58:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659358695; cv=none; d=google.com; s=arc-20160816; b=qXUHivYl2jS3vTAgBlPM0GCOaAH6pQPnhgAXsVaVafSWXpku3VbyL+dtZBiyuR0jaF 4qQpca4KpCfnB8xmqQu+qSNbpKuayUKeSzSZ96gRU6ZWqglw+XiMNo7A+jbUV2HvI29q 6n0KaOr62Xx5wx317+3UVGBFuWrtpaaMxCkd2lHc/qC9aHkWAZDv4SioIGarKb0wh5mv idC6xAy2GWKu4QYIFvXY3IL67slNdjLOohi5TlSoISpSwXiFElNilmNhhDbT+W4XsQfS aSXpUxyp8M/04aeVpqG1nv7qu3JsSf/dBlAhKpGd/n2bSKIyhZeDLNFNS7FMuoQFlkdo HGPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from; bh=exmiAkgpOUC95aSu06fqBUHLRhddJ+lgb8xW5ZIs3Vw=; b=QtKICuk5YQxaPFPnEtRUJ5p4NRshXEE4hnHIvGW7jW8xsYHLzZk56qVdagyfZSQrf6 hS0ibaSULRiJehS1y6rQ91/mEwa6GaUC+cnaq9BvXZqY0N0Wc9QMs6G/EAnsKQmgsILn udp6SW6v4OC7qngepmahKbh96+fRIfd85y3qeo/sRlsY2oDZyHkM7iMBY0YgVFrTv/H5 dR7zDqpSt30vHitbyqcZQWrMA5oUwM4dKOF+PlK1idjUd7k5sj101sOk5Q5cOvbncBe5 fI/dX8d8lrxgIvLn+BPF/Q7fMD1xhibI7kidIzxERicwwb7ZNqUvsJrIS25VjIAsNgZ7 elLA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gr19-20020a170906e2d300b0072b44c246a5si10889259ejb.903.2022.08.01.05.57.49; Mon, 01 Aug 2022 05:58:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S230501AbiHAMt6 (ORCPT + 99 others); Mon, 1 Aug 2022 08:49:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49978 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234963AbiHAMtY (ORCPT ); Mon, 1 Aug 2022 08:49:24 -0400 Received: from inva021.nxp.com (inva021.nxp.com [92.121.34.21]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 86863232 for ; Mon, 1 Aug 2022 05:42:35 -0700 (PDT) Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 0228A20148F; Mon, 1 Aug 2022 14:42:34 +0200 (CEST) Received: from aprdc01srsp001v.ap-rdc01.nxp.com (aprdc01srsp001v.ap-rdc01.nxp.com [165.114.16.16]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id BEB9220130A; Mon, 1 Aug 2022 14:42:33 +0200 (CEST) Received: from localhost.localdomain (shlinux2.ap.freescale.net [10.192.224.44]) by aprdc01srsp001v.ap-rdc01.nxp.com (Postfix) with ESMTP id 4C22A180031C; Mon, 1 Aug 2022 20:42:32 +0800 (+08) From: Shengjiu Wang To: nicoleotsuka@gmail.com, Xiubo.Lee@gmail.com, festevam@gmail.com, shengjiu.wang@gmail.com, lgirdwood@gmail.com, broonie@kernel.org, perex@perex.cz, tiwai@suse.com, alsa-devel@alsa-project.org Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Subject: [PATCH] ASoC: imx-rpmsg: Support configure sysclk for codec dai Date: Mon, 1 Aug 2022 20:26:13 +0800 Message-Id: <1659356773-8315-1-git-send-email-shengjiu.wang@nxp.com> X-Mailer: git-send-email 2.7.4 X-Virus-Scanned: ClamAV using ClamSMTP X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Some codecs need to configure the sysclk even with slave mode, otherwise it may not work properly with some case. wm8960 is the one that need sysclk be configured, so add late_probe() to call the snd_soc_dai_set_sysclk() of codec Signed-off-by: Shengjiu Wang --- sound/soc/fsl/imx-rpmsg.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/sound/soc/fsl/imx-rpmsg.c b/sound/soc/fsl/imx-rpmsg.c index 2e117311e582..bef4bd997c98 100644 --- a/sound/soc/fsl/imx-rpmsg.c +++ b/sound/soc/fsl/imx-rpmsg.c @@ -19,6 +19,7 @@ struct imx_rpmsg { struct snd_soc_dai_link dai; struct snd_soc_card card; + unsigned int sysclk; }; static const struct snd_soc_dapm_widget imx_rpmsg_dapm_widgets[] = { @@ -28,6 +29,27 @@ static const struct snd_soc_dapm_widget imx_rpmsg_dapm_widgets[] = { SND_SOC_DAPM_MIC("Main MIC", NULL), }; +static int imx_rpmsg_late_probe(struct snd_soc_card *card) +{ + struct imx_rpmsg *data = snd_soc_card_get_drvdata(card); + struct snd_soc_pcm_runtime *rtd = list_first_entry(&card->rtd_list, + struct snd_soc_pcm_runtime, list); + struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0); + struct device *dev = card->dev; + int ret; + + if (!data->sysclk) + return 0; + + ret = snd_soc_dai_set_sysclk(codec_dai, 0, data->sysclk, SND_SOC_CLOCK_IN); + if (ret && ret != -ENOTSUPP) { + dev_err(dev, "failed to set sysclk in %s\n", __func__); + return ret; + } + + return 0; +} + static int imx_rpmsg_probe(struct platform_device *pdev) { struct snd_soc_dai_link_component *dlc; @@ -72,12 +94,18 @@ static int imx_rpmsg_probe(struct platform_device *pdev) data->dai.codecs->dai_name = "snd-soc-dummy-dai"; data->dai.codecs->name = "snd-soc-dummy"; } else { + struct clk *clk; + data->dai.codecs->of_node = args.np; ret = snd_soc_get_dai_name(&args, &data->dai.codecs->dai_name); if (ret) { dev_err(&pdev->dev, "Unable to get codec_dai_name\n"); goto fail; } + + clk = devm_get_clk_from_child(&pdev->dev, args.np, NULL); + if (!IS_ERR(clk)) + data->sysclk = clk_get_rate(clk); } data->dai.cpus->dai_name = dev_name(&rpmsg_pdev->dev); @@ -103,6 +131,7 @@ static int imx_rpmsg_probe(struct platform_device *pdev) data->card.owner = THIS_MODULE; data->card.dapm_widgets = imx_rpmsg_dapm_widgets; data->card.num_dapm_widgets = ARRAY_SIZE(imx_rpmsg_dapm_widgets); + data->card.late_probe = imx_rpmsg_late_probe; /* * Inoder to use common api to get card name and audio routing. * Use parent of_node for this device, revert it after finishing using -- 2.34.1