ASoC: rockchip: i2s_tdm: Make the grf property optional
authorNicolas Frattaroli <frattaroli.nicolas@gmail.com>
Tue, 25 Oct 2022 12:41:30 +0000 (14:41 +0200)
committerMark Brown <broonie@kernel.org>
Fri, 25 Nov 2022 19:31:05 +0000 (19:31 +0000)
Only IO Multiplex and two TRCM modes need access to the GRF, so
making it a hard requirement is not a wise idea, as it complicates
support for newer SoCs which do not do these things.

Signed-off-by: Nicolas Frattaroli <frattaroli.nicolas@gmail.com>
Link: https://lore.kernel.org/r/20221025124132.399729-3-frattaroli.nicolas@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/rockchip/rockchip_i2s_tdm.c

index 2550bd2..917f171 100644 (file)
@@ -756,6 +756,12 @@ static int rockchip_i2s_io_multiplex(struct snd_pcm_substream *substream,
        if (!i2s_tdm->io_multiplex)
                return 0;
 
+       if (IS_ERR_OR_NULL(i2s_tdm->grf)) {
+               dev_err(i2s_tdm->dev,
+                       "io multiplex not supported for this device\n");
+               return -EINVAL;
+       }
+
        if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
                struct snd_pcm_str *playback_str =
                        &substream->pcm->streams[SNDRV_PCM_STREAM_PLAYBACK];
@@ -1222,6 +1228,12 @@ static int common_soc_init(struct device *dev, u32 addr)
        if (trcm == TRCM_TXRX)
                return 0;
 
+       if (IS_ERR_OR_NULL(i2s_tdm->grf)) {
+               dev_err(i2s_tdm->dev,
+                       "no grf present but non-txrx TRCM specified\n");
+               return -EINVAL;
+       }
+
        for (i = 0; i < i2s_tdm->soc_data->config_count; i++) {
                if (addr != configs[i].addr)
                        continue;
@@ -1568,10 +1580,6 @@ static int rockchip_i2s_tdm_probe(struct platform_device *pdev)
                return ret;
 
        i2s_tdm->grf = syscon_regmap_lookup_by_phandle(node, "rockchip,grf");
-       if (IS_ERR(i2s_tdm->grf))
-               return dev_err_probe(i2s_tdm->dev, PTR_ERR(i2s_tdm->grf),
-                                    "Error in rockchip,grf\n");
-
        i2s_tdm->tx_reset = devm_reset_control_get_optional_exclusive(&pdev->dev,
                                                                      "tx-m");
        if (IS_ERR(i2s_tdm->tx_reset)) {