005f4b507f8a7ad4b66425bc5c630e94b508d9c9
[openwrt/staging/linusw.git] /
1 From 34a1cd97a2ef6f68a12ff2f2fd813548e867f72f Mon Sep 17 00:00:00 2001
2 From: Viorel Suman <viorel.suman@nxp.com>
3 Date: Thu, 20 Jun 2019 13:25:15 +0300
4 Subject: [PATCH] MLK-21957-2: ASoC: fsl_sai: read SAI version and params in
5 probe
6
7 Read SAI IP version and parameters in probe function.
8
9 Signed-off-by: Viorel Suman <viorel.suman@nxp.com>
10 ---
11 sound/soc/fsl/fsl_sai.c | 30 ++++++++++++++++++++----------
12 1 file changed, 20 insertions(+), 10 deletions(-)
13
14 --- a/sound/soc/fsl/fsl_sai.c
15 +++ b/sound/soc/fsl/fsl_sai.c
16 @@ -465,11 +465,12 @@ static int fsl_sai_set_dai_fmt(struct sn
17 return ret;
18 }
19
20 -static int fsl_sai_check_ver(struct snd_soc_dai *cpu_dai)
21 +static int fsl_sai_check_ver(struct device *dev)
22 {
23 - struct fsl_sai *sai = dev_get_drvdata(cpu_dai->dev);
24 + struct fsl_sai *sai = dev_get_drvdata(dev);
25 unsigned char offset = sai->soc->reg_offset;
26 unsigned int val;
27 + int ret;
28
29 if (FSL_SAI_TCSR(offset) == FSL_SAI_VERID)
30 return 0;
31 @@ -477,16 +478,21 @@ static int fsl_sai_check_ver(struct snd_
32 if (sai->verid.loaded)
33 return 0;
34
35 - sai->verid.loaded = true;
36 - regmap_read(sai->regmap, FSL_SAI_VERID, &val);
37 - dev_dbg(cpu_dai->dev, "VERID: 0x%016X\n", val);
38 + ret = regmap_read(sai->regmap, FSL_SAI_VERID, &val);
39 + if (ret < 0)
40 + return ret;
41 +
42 + dev_dbg(dev, "VERID: 0x%016X\n", val);
43
44 sai->verid.id = (val & FSL_SAI_VER_ID_MASK) >> FSL_SAI_VER_ID_SHIFT;
45 sai->verid.extfifo_en = (val & FSL_SAI_VER_EFIFO_EN);
46 sai->verid.timestamp_en = (val & FSL_SAI_VER_TSTMP_EN);
47
48 - regmap_read(sai->regmap, FSL_SAI_PARAM, &val);
49 - dev_dbg(cpu_dai->dev, "PARAM: 0x%016X\n", val);
50 + ret = regmap_read(sai->regmap, FSL_SAI_PARAM, &val);
51 + if (ret < 0)
52 + return ret;
53 +
54 + dev_dbg(dev, "PARAM: 0x%016X\n", val);
55
56 /* max slots per frame, power of 2 */
57 sai->param.spf = 1 <<
58 @@ -499,11 +505,13 @@ static int fsl_sai_check_ver(struct snd_
59 /* number of datalines implemented */
60 sai->param.dln = val & FSL_SAI_PAR_DLN_MASK;
61
62 - dev_dbg(cpu_dai->dev,
63 + dev_dbg(dev,
64 "Version: 0x%08X, SPF: %u, WPF: %u, DLN: %u\n",
65 sai->verid.id, sai->param.spf, sai->param.wpf, sai->param.dln
66 );
67
68 + sai->verid.loaded = true;
69 +
70 return 0;
71 }
72
73 @@ -521,8 +529,6 @@ static int fsl_sai_set_bclk(struct snd_s
74 if (sai->slave_mode[tx])
75 return 0;
76
77 - fsl_sai_check_ver(dai);
78 -
79 for (id = 0; id < FSL_SAI_MCLK_MAX; id++) {
80 clk_rate = clk_get_rate(sai->mclk_clk[id]);
81 if (!clk_rate)
82 @@ -1517,6 +1523,10 @@ static int fsl_sai_probe(struct platform
83
84 platform_set_drvdata(pdev, sai);
85
86 + ret = fsl_sai_check_ver(&pdev->dev);
87 + if (ret < 0)
88 + dev_warn(&pdev->dev, "Error reading SAI version: %d\n", ret);
89 +
90 pm_runtime_enable(&pdev->dev);
91
92 regcache_cache_only(sai->regmap, true);