Commit 1dc658b1 authored by Shengjiu Wang's avatar Shengjiu Wang Committed by Mark Brown

ASoC: fsl_sai: Add fsl_sai_check_version function

fsl_sai_check_version can help to parse the version info
in VERID and PARAM registers.
Signed-off-by: default avatarShengjiu Wang <shengjiu.wang@nxp.com>
Acked-by: default avatarNicolin Chen <nicoleotsuka@gmail.com>
Reviewed-by: default avatarFabio Estevam <festevam@gmail.com>
Link: https://lore.kernel.org/r/1600323079-5317-3-git-send-email-shengjiu.wang@nxp.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 0b2cbce6
......@@ -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);
......
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment