diff options
author | John Watts <contact@jookia.org> | 2023-09-18 23:15:31 +1000 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2023-09-18 14:32:11 +0100 |
commit | 5d34887eab8daad8f63d584ae4d12d480beb9f0e (patch) | |
tree | 716e11ca71eaf529a55d4c894e547744a13cc0c8 | |
parent | 00524a8415aa400567538c0e75a463d517cded7f (diff) |
ASoC: wm8782: Use wlf,fsampen device tree property
The wm8782 supports rates 96kHz and 192kHz as long as the hardware
is configured properly. Allow this to be specified in the device tree.
Signed-off-by: John Watts <contact@jookia.org>
Acked-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20230918131532.2257615-3-contact@jookia.org
Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r-- | sound/soc/codecs/wm8782.c | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/sound/soc/codecs/wm8782.c b/sound/soc/codecs/wm8782.c index f3dc87b92b1e..3a2acdfa9b85 100644 --- a/sound/soc/codecs/wm8782.c +++ b/sound/soc/codecs/wm8782.c @@ -119,8 +119,9 @@ static const struct snd_soc_component_driver soc_component_dev_wm8782 = { static int wm8782_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; + struct device_node *np = dev->of_node; struct wm8782_priv *priv; - int ret, i; + int ret, i, fsampen; priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); if (!priv) @@ -136,8 +137,26 @@ static int wm8782_probe(struct platform_device *pdev) if (ret < 0) return ret; - /* For configurations with FSAMPEN=0 */ - priv->max_rate = 48000; + // Assume lowest value by default to avoid inadvertent overclocking + fsampen = 0; + + if (np) + of_property_read_u32(np, "wlf,fsampen", &fsampen); + + switch (fsampen) { + case 0: + priv->max_rate = 48000; + break; + case 1: + priv->max_rate = 96000; + break; + case 2: + priv->max_rate = 192000; + break; + default: + dev_err(dev, "Invalid wlf,fsampen value"); + return -EINVAL; + } return devm_snd_soc_register_component(&pdev->dev, &soc_component_dev_wm8782, &wm8782_dai, 1); |