Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp182763pxk; Wed, 16 Sep 2020 23:25:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwd3K/1U+eKtIkVQqbVbmlMxabCPM0kXq2XqlSAl8y4RWA20QOOkvFrJUN0k9aaj6KQ1tQ7 X-Received: by 2002:a05:6402:45a:: with SMTP id p26mr33110025edw.8.1600323923922; Wed, 16 Sep 2020 23:25:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600323923; cv=none; d=google.com; s=arc-20160816; b=NaJGIOXReygdDHM51KClSSRVs9XrHNbNoT6DMTA4pPn2jkKyEnSjGtUduodi12vUL0 4nalV09PC/EmArGfkeARj7k4FCLNVD5EEyGd/6MUuA1v3WJDedu+6JDCQStmsF4hQsHJ nhf1mXkTsR+1wrIa0YlqhECswRFzAPUivhM5tkpbtkC9i4wbbt0JczCi/Mcp8Iqx7Nxt Ucmb34s4jjlwZ1GAASIAUAmsFFR2MMC0tyWfzXvhzNsy55gcad/xLDSfsaOIwtVW7K8V u2sEgoK7rztQr1YWGssMw9LXCmvw12AgjwamnSWAQ2NoJ+4x4n3GeXS8Mu3HWQrr0cj6 wrQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=2POaERxFqiP4PWflpr3MIpOd69AnAs6dC/iT9Xe0sQo=; b=HnRG3dfb5/guPjRW9JFlclURrRjd1hkN5AG4ag8K5MoHM+W/pSyTap15KBZwZTJZEx lOnclK4/ltnqplev/rCPxrZKSoT11lv771zV28gMVZmWRYLw0TkW9TbfKSZer6aotmY9 1t73t15CJQFwZPeA1DxvnY/txNF/qGIo2QB7So/fUwo1I91jMsSe6q777IDpPuaDREjy ch47dvgQTUJ4w1/hKD+dsEjVrj214ricDRF7jVUv0KqDqmaek01x0FXnG6OIYdeweS2X wH8cYT8p/aKe4qUYASnPWWYXHJ/s8uj2p/aQjcBxVsFI9K7REOQpA3y4HTEJwDtIc6R5 ldMQ== 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 g24si4879548edu.262.2020.09.16.23.25.00; Wed, 16 Sep 2020 23:25:23 -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 S1726236AbgIQGXz (ORCPT + 99 others); Thu, 17 Sep 2020 02:23:55 -0400 Received: from inva020.nxp.com ([92.121.34.13]:46286 "EHLO inva020.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725267AbgIQGXy (ORCPT ); Thu, 17 Sep 2020 02:23:54 -0400 X-Greylist: delayed 341 seconds by postgrey-1.27 at vger.kernel.org; Thu, 17 Sep 2020 02:23:52 EDT Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 047DA1A0F4A; Thu, 17 Sep 2020 08:18:13 +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 4ECC31A0E24; Thu, 17 Sep 2020 08:18:08 +0200 (CEST) Received: from 10.192.242.69 (shlinux2.ap.freescale.net [10.192.224.44]) by invc005.ap-rdc01.nxp.com (Postfix) with ESMTP id 756BE40318; Thu, 17 Sep 2020 08:18:02 +0200 (CEST) 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 Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/3] ASoC: fsl_sai: Add fsl_sai_check_version function Date: Thu, 17 Sep 2020 14:11:18 +0800 Message-Id: <1600323079-5317-3-git-send-email-shengjiu.wang@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1600323079-5317-1-git-send-email-shengjiu.wang@nxp.com> References: <1600323079-5317-1-git-send-email-shengjiu.wang@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org fsl_sai_check_version can help to parse the version info in VERID and PARAM registers. Signed-off-by: Shengjiu Wang Acked-by: Nicolin Chen --- sound/soc/fsl/fsl_sai.c | 47 +++++++++++++++++++++++++++++++++++++++++ sound/soc/fsl/fsl_sai.h | 28 ++++++++++++++++++++++++ 2 files changed, 75 insertions(+) diff --git a/sound/soc/fsl/fsl_sai.c b/sound/soc/fsl/fsl_sai.c index 24ca528ca2be..738b4dda7847 100644 --- a/sound/soc/fsl/fsl_sai.c +++ b/sound/soc/fsl/fsl_sai.c @@ -946,6 +946,48 @@ static struct regmap_config fsl_sai_regmap_config = { .cache_type = REGCACHE_FLAT, }; +static int fsl_sai_check_version(struct device *dev) +{ + struct fsl_sai *sai = dev_get_drvdata(dev); + unsigned char ofs = sai->soc_data->reg_offset; + unsigned int val; + int ret; + + if (FSL_SAI_TCSR(ofs) == FSL_SAI_VERID) + return 0; + + ret = regmap_read(sai->regmap, FSL_SAI_VERID, &val); + if (ret < 0) + return ret; + + dev_dbg(dev, "VERID: 0x%016X\n", val); + + sai->verid.major = (val & FSL_SAI_VERID_MAJOR_MASK) >> + FSL_SAI_VERID_MAJOR_SHIFT; + sai->verid.minor = (val & FSL_SAI_VERID_MINOR_MASK) >> + FSL_SAI_VERID_MINOR_SHIFT; + sai->verid.feature = val & FSL_SAI_VERID_FEATURE_MASK; + + ret = regmap_read(sai->regmap, FSL_SAI_PARAM, &val); + if (ret < 0) + return ret; + + dev_dbg(dev, "PARAM: 0x%016X\n", val); + + /* Max slots per frame, power of 2 */ + sai->param.slot_num = 1 << + ((val & FSL_SAI_PARAM_SPF_MASK) >> FSL_SAI_PARAM_SPF_SHIFT); + + /* Words per fifo, power of 2 */ + sai->param.fifo_depth = 1 << + ((val & FSL_SAI_PARAM_WPF_MASK) >> FSL_SAI_PARAM_WPF_SHIFT); + + /* Number of datalines implemented */ + sai->param.dataline = val & FSL_SAI_PARAM_DLN_MASK; + + return 0; +} + static int fsl_sai_probe(struct platform_device *pdev) { struct device_node *np = pdev->dev.of_node; @@ -1070,6 +1112,11 @@ static int fsl_sai_probe(struct platform_device *pdev) platform_set_drvdata(pdev, sai); + /* Get sai version */ + ret = fsl_sai_check_version(&pdev->dev); + if (ret < 0) + dev_warn(&pdev->dev, "Error reading SAI version: %d\n", ret); + pm_runtime_enable(&pdev->dev); regcache_cache_only(sai->regmap, true); diff --git a/sound/soc/fsl/fsl_sai.h b/sound/soc/fsl/fsl_sai.h index d16fc4241f41..ba7425a9e217 100644 --- a/sound/soc/fsl/fsl_sai.h +++ b/sound/soc/fsl/fsl_sai.h @@ -223,6 +223,32 @@ struct fsl_sai_soc_data { unsigned int reg_offset; }; +/** + * struct fsl_sai_verid - version id data + * @major: major version number + * @minor: minor version number + * @feature: feature specification number + * 0000000000000000b - Standard feature set + * 0000000000000000b - Standard feature set + */ +struct fsl_sai_verid { + u32 major; + u32 minor; + u32 feature; +}; + +/** + * struct fsl_sai_param - parameter data + * @slot_num: The maximum number of slots per frame + * @fifo_depth: The number of words in each FIFO (depth) + * @dataline: The number of datalines implemented + */ +struct fsl_sai_param { + u32 slot_num; + u32 fifo_depth; + u32 dataline; +}; + struct fsl_sai { struct platform_device *pdev; struct regmap *regmap; @@ -243,6 +269,8 @@ struct fsl_sai { const struct fsl_sai_soc_data *soc_data; struct snd_dmaengine_dai_dma_data dma_params_rx; struct snd_dmaengine_dai_dma_data dma_params_tx; + struct fsl_sai_verid verid; + struct fsl_sai_param param; }; #define TX 1 -- 2.27.0