summaryrefslogtreecommitdiff
path: root/sound/soc/meson/axg-fifo.c
diff options
context:
space:
mode:
authorJerome Brunet <jbrunet@baylibre.com>2019-12-18 20:24:19 +0300
committerMark Brown <broonie@kernel.org>2019-12-18 23:01:15 +0300
commit23b89e1d62c75f2c1985449e968886e8a97860c0 (patch)
treea0d235212b482f107dc1345bbc8b23978c614d34 /sound/soc/meson/axg-fifo.c
parent864cee90d4bd870e5d5e5a0b1a6f055f4f951350 (diff)
downloadlinux-23b89e1d62c75f2c1985449e968886e8a97860c0.tar.xz
ASoC: meson: axg-fifo: improve depth handling
Let the fifo driver parse the fifo depth from DT. Eventually all DT should have this property. Until it is actually the case, default to 256 bytes if the property is missing. 256 bytes is the size of the smallest fifo on the supported SoCs. On the supported SoC, fifo A is usually bigger than the other ones. With depth known, we can improve the usage of the fifo and adapt the setup of request threshold. Signed-off-by: Jerome Brunet <jbrunet@baylibre.com> Link: https://lore.kernel.org/r/20191218172420.1199117-4-jbrunet@baylibre.com Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound/soc/meson/axg-fifo.c')
-rw-r--r--sound/soc/meson/axg-fifo.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/sound/soc/meson/axg-fifo.c b/sound/soc/meson/axg-fifo.c
index 4365086c9a31..c2742a02d866 100644
--- a/sound/soc/meson/axg-fifo.c
+++ b/sound/soc/meson/axg-fifo.c
@@ -132,8 +132,7 @@ int axg_fifo_pcm_hw_params(struct snd_soc_component *component,
* - Half the fifo size
* - Half the period size
*/
- threshold = min(period / 2,
- (unsigned int)AXG_FIFO_MIN_DEPTH / 2);
+ threshold = min(period / 2, fifo->depth / 2);
/*
* With the threshold in bytes, register value is:
@@ -320,6 +319,7 @@ int axg_fifo_probe(struct platform_device *pdev)
const struct axg_fifo_match_data *data;
struct axg_fifo *fifo;
void __iomem *regs;
+ int ret;
data = of_device_get_match_data(dev);
if (!data) {
@@ -370,6 +370,21 @@ int axg_fifo_probe(struct platform_device *pdev)
if (IS_ERR(fifo->field_threshold))
return PTR_ERR(fifo->field_threshold);
+ ret = of_property_read_u32(dev->of_node, "amlogic,fifo-depth",
+ &fifo->depth);
+ if (ret) {
+ /* Error out for anything but a missing property */
+ if (ret != -EINVAL)
+ return ret;
+ /*
+ * If the property is missing, it might be because of an old
+ * DT. In such case, assume the smallest known fifo depth
+ */
+ fifo->depth = 256;
+ dev_warn(dev, "fifo depth not found, assume %u bytes\n",
+ fifo->depth);
+ }
+
return devm_snd_soc_register_component(dev, data->component_drv,
data->dai_drv, 1);
}