Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp1049643pxb; Thu, 26 Aug 2021 23:24:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwIjBFAzv35+vsIPMWzWN4fws6dYTui/lrKDiAhKjxGnmbeOFe72udGv47YVhjxlduqdMGJ X-Received: by 2002:aa7:c857:: with SMTP id g23mr8281972edt.219.1630045485871; Thu, 26 Aug 2021 23:24:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630045485; cv=none; d=google.com; s=arc-20160816; b=ks+ug0sOs/AV8sa40a+Omt1b5FYWgeKIT11/zu4w3tAd7vfJcNDcK8OfM7uHEk4iSB v9J3IwzclvpDwBP8yC1JJga8y2k1pzVST3IB6qeAgEZ0ofjKkn/bZ4HKv1PrPqhN5frx Jwy20akzH1HBlZ/WgqQsqWz0pqdqSL7c1T+mgxPjYhEWuyxPLL9FyPsKI2cepOdRi278 tiRvQyXwWsTp5d7nHEEj7zIrW8ku0hCWmkGuLNQvySWOj2EAQ4XtqFsdJiZ1zCrJA2L0 G+q6+I2RcLs0jGqBrTyU3T7FwF3AIpVYluhKdKrJQx/8z+T24N4FDXKgodjWLuQvrEZr bfZw== 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=tuLYFxb0jlo/gH9gfgBUKox5I8q/FxddfCajtGG2md4=; b=yyg8zacnEhx8j1AwIHjKrwfrVeoCj6bFwyIBa227p5gOQ6sHHzAIYjaYlOTc95NMa9 f4MBoQiAzDSn5G3CAQDVraMEzsnl9cTPkSJ0kQWC2Ga67gJwtry+RCxSEWckoIhE1r7i swnLz4rXeeVPbp+kFQfCyfPGji5a0Xvh/+dDvp3P5h3qALlCAO4Lf9V2qz/Yr20PZLfG Vx8YLa+VEaKEFtt8JAMmiyXVl/7XhGh86A8Keojo357PjWXMkJludb6hvG4mWHL58H6Q 1xMOQ0w8EDY9e5L/nH+rn3Gj6paIm9bAPcA5WOBS9h4Rumm19zsHPe/jSWUxK3bR87zF Qgfw== 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 i11si1252480ejw.358.2021.08.26.23.24.21; Thu, 26 Aug 2021 23:24:45 -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 S235220AbhH0GXy (ORCPT + 99 others); Fri, 27 Aug 2021 02:23:54 -0400 Received: from inva021.nxp.com ([92.121.34.21]:59884 "EHLO inva021.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229611AbhH0GXx (ORCPT ); Fri, 27 Aug 2021 02:23:53 -0400 Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 55FD1200FE7; Fri, 27 Aug 2021 08:23:04 +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 DBF18200E4B; Fri, 27 Aug 2021 08:23:03 +0200 (CEST) Received: from localhost.localdomain (shlinux2.ap.freescale.net [10.192.224.44]) by aprdc01srsp001v.ap-rdc01.nxp.com (Postfix) with ESMTP id 6E4D8183AC8B; Fri, 27 Aug 2021 14:23:02 +0800 (+08) 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 Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] ASoC: fsl_rpmsg: add soc specific data structure Date: Fri, 27 Aug 2021 14:00:38 +0800 Message-Id: <1630044038-19036-1-git-send-email-shengjiu.wang@nxp.com> X-Mailer: git-send-email 2.7.4 X-Virus-Scanned: ClamAV using ClamSMTP Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Each platform has different supported rates and formats, so add soc specific data for each platform. This soc specific data is attached with compatible string. Signed-off-by: Shengjiu Wang Reviewed-by: Fabio Estevam --- changes in v2: - remove checking rpmsg->soc_data is NULL - add Reviewed-by Fabio sound/soc/fsl/fsl_rpmsg.c | 46 +++++++++++++++++++++++++++++++++++---- sound/soc/fsl/fsl_rpmsg.h | 12 ++++++++++ 2 files changed, 54 insertions(+), 4 deletions(-) diff --git a/sound/soc/fsl/fsl_rpmsg.c b/sound/soc/fsl/fsl_rpmsg.c index d60f4dac6c1b..07abad7fe372 100644 --- a/sound/soc/fsl/fsl_rpmsg.c +++ b/sound/soc/fsl/fsl_rpmsg.c @@ -138,11 +138,42 @@ static const struct snd_soc_component_driver fsl_component = { .name = "fsl-rpmsg", }; +static const struct fsl_rpmsg_soc_data imx7ulp_data = { + .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 | + SNDRV_PCM_RATE_48000, + .formats = SNDRV_PCM_FMTBIT_S16_LE, +}; + +static const struct fsl_rpmsg_soc_data imx8mm_data = { + .rates = SNDRV_PCM_RATE_KNOT, + .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE | + SNDRV_PCM_FMTBIT_S32_LE | SNDRV_PCM_FMTBIT_DSD_U8 | + SNDRV_PCM_FMTBIT_DSD_U16_LE | SNDRV_PCM_FMTBIT_DSD_U32_LE, +}; + +static const struct fsl_rpmsg_soc_data imx8mn_data = { + .rates = SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 | + SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 | + SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 | + SNDRV_PCM_RATE_192000, + .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE | + SNDRV_PCM_FMTBIT_S32_LE, +}; + +static const struct fsl_rpmsg_soc_data imx8mp_data = { + .rates = SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 | + SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 | + SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 | + SNDRV_PCM_RATE_192000, + .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE | + SNDRV_PCM_FMTBIT_S32_LE, +}; + static const struct of_device_id fsl_rpmsg_ids[] = { - { .compatible = "fsl,imx7ulp-rpmsg-audio"}, - { .compatible = "fsl,imx8mm-rpmsg-audio"}, - { .compatible = "fsl,imx8mn-rpmsg-audio"}, - { .compatible = "fsl,imx8mp-rpmsg-audio"}, + { .compatible = "fsl,imx7ulp-rpmsg-audio", .data = &imx7ulp_data}, + { .compatible = "fsl,imx8mm-rpmsg-audio", .data = &imx8mm_data}, + { .compatible = "fsl,imx8mn-rpmsg-audio", .data = &imx8mn_data}, + { .compatible = "fsl,imx8mp-rpmsg-audio", .data = &imx8mp_data}, { /* sentinel */ } }; MODULE_DEVICE_TABLE(of, fsl_rpmsg_ids); @@ -157,6 +188,13 @@ static int fsl_rpmsg_probe(struct platform_device *pdev) if (!rpmsg) return -ENOMEM; + rpmsg->soc_data = of_device_get_match_data(&pdev->dev); + + fsl_rpmsg_dai.playback.rates = rpmsg->soc_data->rates; + fsl_rpmsg_dai.capture.rates = rpmsg->soc_data->rates; + fsl_rpmsg_dai.playback.formats = rpmsg->soc_data->formats; + fsl_rpmsg_dai.capture.formats = rpmsg->soc_data->formats; + if (of_property_read_bool(np, "fsl,enable-lpa")) { rpmsg->enable_lpa = 1; rpmsg->buffer_size = LPA_LARGE_BUFFER_SIZE; diff --git a/sound/soc/fsl/fsl_rpmsg.h b/sound/soc/fsl/fsl_rpmsg.h index 4f5b49eb18d8..b04086fbf828 100644 --- a/sound/soc/fsl/fsl_rpmsg.h +++ b/sound/soc/fsl/fsl_rpmsg.h @@ -6,6 +6,16 @@ #ifndef __FSL_RPMSG_H #define __FSL_RPMSG_H +/* + * struct fsl_rpmsg_soc_data + * @rates: supported rates + * @formats: supported formats + */ +struct fsl_rpmsg_soc_data { + int rates; + u64 formats; +}; + /* * struct fsl_rpmsg - rpmsg private data * @@ -15,6 +25,7 @@ * @pll8k: parent clock for multiple of 8kHz frequency * @pll11k: parent clock for multiple of 11kHz frequency * @card_pdev: Platform_device pointer to register a sound card + * @soc_data: soc specific data * @mclk_streams: Active streams that are using baudclk * @force_lpa: force enable low power audio routine if condition satisfy * @enable_lpa: enable low power audio routine according to dts setting @@ -27,6 +38,7 @@ struct fsl_rpmsg { struct clk *pll8k; struct clk *pll11k; struct platform_device *card_pdev; + const struct fsl_rpmsg_soc_data *soc_data; unsigned int mclk_streams; int force_lpa; int enable_lpa; -- 2.17.1