From 0de6db30ef79b391cedd749801a49c485d2daf4b Mon Sep 17 00:00:00 2001 From: Sowjanya Komatineni Date: Mon, 13 Jan 2020 23:24:17 -0800 Subject: ASoC: tegra: Use device managed resource APIs to get the clock tegra_asoc_utils uses clk_get() to get the clock and clk_put() to free them explicitly. This patch updates it to use device managed resource API devm_clk_get() so the clock will be automatically released and freed when the device is unbound and removes tegra_asoc_utils_fini() as its no longer needed. Tested-by: Dmitry Osipenko Reviewed-by: Dmitry Osipenko Reviewed-by: Sameer Pujar Signed-off-by: Sowjanya Komatineni Signed-off-by: Thierry Reding --- sound/soc/tegra/tegra_alc5632.c | 7 +------ sound/soc/tegra/tegra_asoc_utils.c | 34 +++++++--------------------------- sound/soc/tegra/tegra_asoc_utils.h | 1 - sound/soc/tegra/tegra_max98090.c | 22 ++++++---------------- sound/soc/tegra/tegra_rt5640.c | 22 ++++++---------------- sound/soc/tegra/tegra_rt5677.c | 7 +------ sound/soc/tegra/tegra_sgtl5000.c | 7 +------ sound/soc/tegra/tegra_wm8753.c | 22 ++++++---------------- sound/soc/tegra/tegra_wm8903.c | 22 ++++++---------------- sound/soc/tegra/tegra_wm9712.c | 8 ++------ sound/soc/tegra/trimslice.c | 18 ++++-------------- 11 files changed, 40 insertions(+), 130 deletions(-) (limited to 'sound') diff --git a/sound/soc/tegra/tegra_alc5632.c b/sound/soc/tegra/tegra_alc5632.c index ec39ecba1e8b..2839c6cb8c38 100644 --- a/sound/soc/tegra/tegra_alc5632.c +++ b/sound/soc/tegra/tegra_alc5632.c @@ -205,13 +205,11 @@ static int tegra_alc5632_probe(struct platform_device *pdev) if (ret) { dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n", ret); - goto err_fini_utils; + goto err_put_cpu_of_node; } return 0; -err_fini_utils: - tegra_asoc_utils_fini(&alc5632->util_data); err_put_cpu_of_node: of_node_put(tegra_alc5632_dai.cpus->of_node); tegra_alc5632_dai.cpus->of_node = NULL; @@ -226,12 +224,9 @@ err: static int tegra_alc5632_remove(struct platform_device *pdev) { struct snd_soc_card *card = platform_get_drvdata(pdev); - struct tegra_alc5632 *machine = snd_soc_card_get_drvdata(card); snd_soc_unregister_card(card); - tegra_asoc_utils_fini(&machine->util_data); - of_node_put(tegra_alc5632_dai.cpus->of_node); tegra_alc5632_dai.cpus->of_node = NULL; tegra_alc5632_dai.platforms->of_node = NULL; diff --git a/sound/soc/tegra/tegra_asoc_utils.c b/sound/soc/tegra/tegra_asoc_utils.c index 536a578e9512..0d2271952555 100644 --- a/sound/soc/tegra/tegra_asoc_utils.c +++ b/sound/soc/tegra/tegra_asoc_utils.c @@ -175,52 +175,32 @@ int tegra_asoc_utils_init(struct tegra_asoc_utils_data *data, return -EINVAL; } - data->clk_pll_a = clk_get(dev, "pll_a"); + data->clk_pll_a = devm_clk_get(dev, "pll_a"); if (IS_ERR(data->clk_pll_a)) { dev_err(data->dev, "Can't retrieve clk pll_a\n"); - ret = PTR_ERR(data->clk_pll_a); - goto err; + return PTR_ERR(data->clk_pll_a); } - data->clk_pll_a_out0 = clk_get(dev, "pll_a_out0"); + data->clk_pll_a_out0 = devm_clk_get(dev, "pll_a_out0"); if (IS_ERR(data->clk_pll_a_out0)) { dev_err(data->dev, "Can't retrieve clk pll_a_out0\n"); - ret = PTR_ERR(data->clk_pll_a_out0); - goto err_put_pll_a; + return PTR_ERR(data->clk_pll_a_out0); } - data->clk_cdev1 = clk_get(dev, "mclk"); + data->clk_cdev1 = devm_clk_get(dev, "mclk"); if (IS_ERR(data->clk_cdev1)) { dev_err(data->dev, "Can't retrieve clk cdev1\n"); - ret = PTR_ERR(data->clk_cdev1); - goto err_put_pll_a_out0; + return PTR_ERR(data->clk_cdev1); } ret = tegra_asoc_utils_set_rate(data, 44100, 256 * 44100); if (ret) - goto err_put_cdev1; + return ret; return 0; - -err_put_cdev1: - clk_put(data->clk_cdev1); -err_put_pll_a_out0: - clk_put(data->clk_pll_a_out0); -err_put_pll_a: - clk_put(data->clk_pll_a); -err: - return ret; } EXPORT_SYMBOL_GPL(tegra_asoc_utils_init); -void tegra_asoc_utils_fini(struct tegra_asoc_utils_data *data) -{ - clk_put(data->clk_cdev1); - clk_put(data->clk_pll_a_out0); - clk_put(data->clk_pll_a); -} -EXPORT_SYMBOL_GPL(tegra_asoc_utils_fini); - MODULE_AUTHOR("Stephen Warren "); MODULE_DESCRIPTION("Tegra ASoC utility code"); MODULE_LICENSE("GPL"); diff --git a/sound/soc/tegra/tegra_asoc_utils.h b/sound/soc/tegra/tegra_asoc_utils.h index 0c13818dee75..a34439587d59 100644 --- a/sound/soc/tegra/tegra_asoc_utils.h +++ b/sound/soc/tegra/tegra_asoc_utils.h @@ -34,6 +34,5 @@ int tegra_asoc_utils_set_rate(struct tegra_asoc_utils_data *data, int srate, int tegra_asoc_utils_set_ac97_rate(struct tegra_asoc_utils_data *data); int tegra_asoc_utils_init(struct tegra_asoc_utils_data *data, struct device *dev); -void tegra_asoc_utils_fini(struct tegra_asoc_utils_data *data); #endif diff --git a/sound/soc/tegra/tegra_max98090.c b/sound/soc/tegra/tegra_max98090.c index d800b62b36f8..ec9050516cd7 100644 --- a/sound/soc/tegra/tegra_max98090.c +++ b/sound/soc/tegra/tegra_max98090.c @@ -218,19 +218,18 @@ static int tegra_max98090_probe(struct platform_device *pdev) ret = snd_soc_of_parse_card_name(card, "nvidia,model"); if (ret) - goto err; + return ret; ret = snd_soc_of_parse_audio_routing(card, "nvidia,audio-routing"); if (ret) - goto err; + return ret; tegra_max98090_dai.codecs->of_node = of_parse_phandle(np, "nvidia,audio-codec", 0); if (!tegra_max98090_dai.codecs->of_node) { dev_err(&pdev->dev, "Property 'nvidia,audio-codec' missing or invalid\n"); - ret = -EINVAL; - goto err; + return -EINVAL; } tegra_max98090_dai.cpus->of_node = of_parse_phandle(np, @@ -238,40 +237,31 @@ static int tegra_max98090_probe(struct platform_device *pdev) if (!tegra_max98090_dai.cpus->of_node) { dev_err(&pdev->dev, "Property 'nvidia,i2s-controller' missing or invalid\n"); - ret = -EINVAL; - goto err; + return -EINVAL; } tegra_max98090_dai.platforms->of_node = tegra_max98090_dai.cpus->of_node; ret = tegra_asoc_utils_init(&machine->util_data, &pdev->dev); if (ret) - goto err; + return ret; ret = snd_soc_register_card(card); if (ret) { dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n", ret); - goto err_fini_utils; + return ret; } return 0; - -err_fini_utils: - tegra_asoc_utils_fini(&machine->util_data); -err: - return ret; } static int tegra_max98090_remove(struct platform_device *pdev) { struct snd_soc_card *card = platform_get_drvdata(pdev); - struct tegra_max98090 *machine = snd_soc_card_get_drvdata(card); snd_soc_unregister_card(card); - tegra_asoc_utils_fini(&machine->util_data); - return 0; } diff --git a/sound/soc/tegra/tegra_rt5640.c b/sound/soc/tegra/tegra_rt5640.c index 9878bc3eb89e..201d132731f9 100644 --- a/sound/soc/tegra/tegra_rt5640.c +++ b/sound/soc/tegra/tegra_rt5640.c @@ -164,19 +164,18 @@ static int tegra_rt5640_probe(struct platform_device *pdev) ret = snd_soc_of_parse_card_name(card, "nvidia,model"); if (ret) - goto err; + return ret; ret = snd_soc_of_parse_audio_routing(card, "nvidia,audio-routing"); if (ret) - goto err; + return ret; tegra_rt5640_dai.codecs->of_node = of_parse_phandle(np, "nvidia,audio-codec", 0); if (!tegra_rt5640_dai.codecs->of_node) { dev_err(&pdev->dev, "Property 'nvidia,audio-codec' missing or invalid\n"); - ret = -EINVAL; - goto err; + return -EINVAL; } tegra_rt5640_dai.cpus->of_node = of_parse_phandle(np, @@ -184,40 +183,31 @@ static int tegra_rt5640_probe(struct platform_device *pdev) if (!tegra_rt5640_dai.cpus->of_node) { dev_err(&pdev->dev, "Property 'nvidia,i2s-controller' missing or invalid\n"); - ret = -EINVAL; - goto err; + return -EINVAL; } tegra_rt5640_dai.platforms->of_node = tegra_rt5640_dai.cpus->of_node; ret = tegra_asoc_utils_init(&machine->util_data, &pdev->dev); if (ret) - goto err; + return ret; ret = snd_soc_register_card(card); if (ret) { dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n", ret); - goto err_fini_utils; + return ret; } return 0; - -err_fini_utils: - tegra_asoc_utils_fini(&machine->util_data); -err: - return ret; } static int tegra_rt5640_remove(struct platform_device *pdev) { struct snd_soc_card *card = platform_get_drvdata(pdev); - struct tegra_rt5640 *machine = snd_soc_card_get_drvdata(card); snd_soc_unregister_card(card); - tegra_asoc_utils_fini(&machine->util_data); - return 0; } diff --git a/sound/soc/tegra/tegra_rt5677.c b/sound/soc/tegra/tegra_rt5677.c index 5821313db977..8f71e21f6ee9 100644 --- a/sound/soc/tegra/tegra_rt5677.c +++ b/sound/soc/tegra/tegra_rt5677.c @@ -270,13 +270,11 @@ static int tegra_rt5677_probe(struct platform_device *pdev) if (ret) { dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n", ret); - goto err_fini_utils; + goto err_put_cpu_of_node; } return 0; -err_fini_utils: - tegra_asoc_utils_fini(&machine->util_data); err_put_cpu_of_node: of_node_put(tegra_rt5677_dai.cpus->of_node); tegra_rt5677_dai.cpus->of_node = NULL; @@ -291,12 +289,9 @@ err: static int tegra_rt5677_remove(struct platform_device *pdev) { struct snd_soc_card *card = platform_get_drvdata(pdev); - struct tegra_rt5677 *machine = snd_soc_card_get_drvdata(card); snd_soc_unregister_card(card); - tegra_asoc_utils_fini(&machine->util_data); - tegra_rt5677_dai.platforms->of_node = NULL; of_node_put(tegra_rt5677_dai.codecs->of_node); tegra_rt5677_dai.codecs->of_node = NULL; diff --git a/sound/soc/tegra/tegra_sgtl5000.c b/sound/soc/tegra/tegra_sgtl5000.c index dc411ba2e36d..692fcc3d7d6e 100644 --- a/sound/soc/tegra/tegra_sgtl5000.c +++ b/sound/soc/tegra/tegra_sgtl5000.c @@ -156,13 +156,11 @@ static int tegra_sgtl5000_driver_probe(struct platform_device *pdev) if (ret) { dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n", ret); - goto err_fini_utils; + goto err_put_cpu_of_node; } return 0; -err_fini_utils: - tegra_asoc_utils_fini(&machine->util_data); err_put_cpu_of_node: of_node_put(tegra_sgtl5000_dai.cpus->of_node); tegra_sgtl5000_dai.cpus->of_node = NULL; @@ -177,13 +175,10 @@ err: static int tegra_sgtl5000_driver_remove(struct platform_device *pdev) { struct snd_soc_card *card = platform_get_drvdata(pdev); - struct tegra_sgtl5000 *machine = snd_soc_card_get_drvdata(card); int ret; ret = snd_soc_unregister_card(card); - tegra_asoc_utils_fini(&machine->util_data); - of_node_put(tegra_sgtl5000_dai.cpus->of_node); tegra_sgtl5000_dai.cpus->of_node = NULL; tegra_sgtl5000_dai.platforms->of_node = NULL; diff --git a/sound/soc/tegra/tegra_wm8753.c b/sound/soc/tegra/tegra_wm8753.c index 0d653a605358..2ee2ed190872 100644 --- a/sound/soc/tegra/tegra_wm8753.c +++ b/sound/soc/tegra/tegra_wm8753.c @@ -127,19 +127,18 @@ static int tegra_wm8753_driver_probe(struct platform_device *pdev) ret = snd_soc_of_parse_card_name(card, "nvidia,model"); if (ret) - goto err; + return ret; ret = snd_soc_of_parse_audio_routing(card, "nvidia,audio-routing"); if (ret) - goto err; + return ret; tegra_wm8753_dai.codecs->of_node = of_parse_phandle(np, "nvidia,audio-codec", 0); if (!tegra_wm8753_dai.codecs->of_node) { dev_err(&pdev->dev, "Property 'nvidia,audio-codec' missing or invalid\n"); - ret = -EINVAL; - goto err; + return -EINVAL; } tegra_wm8753_dai.cpus->of_node = of_parse_phandle(np, @@ -147,40 +146,31 @@ static int tegra_wm8753_driver_probe(struct platform_device *pdev) if (!tegra_wm8753_dai.cpus->of_node) { dev_err(&pdev->dev, "Property 'nvidia,i2s-controller' missing or invalid\n"); - ret = -EINVAL; - goto err; + return -EINVAL; } tegra_wm8753_dai.platforms->of_node = tegra_wm8753_dai.cpus->of_node; ret = tegra_asoc_utils_init(&machine->util_data, &pdev->dev); if (ret) - goto err; + return ret; ret = snd_soc_register_card(card); if (ret) { dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n", ret); - goto err_fini_utils; + return ret; } return 0; - -err_fini_utils: - tegra_asoc_utils_fini(&machine->util_data); -err: - return ret; } static int tegra_wm8753_driver_remove(struct platform_device *pdev) { struct snd_soc_card *card = platform_get_drvdata(pdev); - struct tegra_wm8753 *machine = snd_soc_card_get_drvdata(card); snd_soc_unregister_card(card); - tegra_asoc_utils_fini(&machine->util_data); - return 0; } diff --git a/sound/soc/tegra/tegra_wm8903.c b/sound/soc/tegra/tegra_wm8903.c index 9b5651502f12..6525b93cb75c 100644 --- a/sound/soc/tegra/tegra_wm8903.c +++ b/sound/soc/tegra/tegra_wm8903.c @@ -319,19 +319,18 @@ static int tegra_wm8903_driver_probe(struct platform_device *pdev) ret = snd_soc_of_parse_card_name(card, "nvidia,model"); if (ret) - goto err; + return ret; ret = snd_soc_of_parse_audio_routing(card, "nvidia,audio-routing"); if (ret) - goto err; + return ret; tegra_wm8903_dai.codecs->of_node = of_parse_phandle(np, "nvidia,audio-codec", 0); if (!tegra_wm8903_dai.codecs->of_node) { dev_err(&pdev->dev, "Property 'nvidia,audio-codec' missing or invalid\n"); - ret = -EINVAL; - goto err; + return -EINVAL; } tegra_wm8903_dai.cpus->of_node = of_parse_phandle(np, @@ -339,40 +338,31 @@ static int tegra_wm8903_driver_probe(struct platform_device *pdev) if (!tegra_wm8903_dai.cpus->of_node) { dev_err(&pdev->dev, "Property 'nvidia,i2s-controller' missing or invalid\n"); - ret = -EINVAL; - goto err; + return -EINVAL; } tegra_wm8903_dai.platforms->of_node = tegra_wm8903_dai.cpus->of_node; ret = tegra_asoc_utils_init(&machine->util_data, &pdev->dev); if (ret) - goto err; + return ret; ret = snd_soc_register_card(card); if (ret) { dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n", ret); - goto err_fini_utils; + return ret; } return 0; - -err_fini_utils: - tegra_asoc_utils_fini(&machine->util_data); -err: - return ret; } static int tegra_wm8903_driver_remove(struct platform_device *pdev) { struct snd_soc_card *card = platform_get_drvdata(pdev); - struct tegra_wm8903 *machine = snd_soc_card_get_drvdata(card); snd_soc_unregister_card(card); - tegra_asoc_utils_fini(&machine->util_data); - return 0; } diff --git a/sound/soc/tegra/tegra_wm9712.c b/sound/soc/tegra/tegra_wm9712.c index b85bd9f89073..726edfa21a29 100644 --- a/sound/soc/tegra/tegra_wm9712.c +++ b/sound/soc/tegra/tegra_wm9712.c @@ -113,19 +113,17 @@ static int tegra_wm9712_driver_probe(struct platform_device *pdev) ret = tegra_asoc_utils_set_ac97_rate(&machine->util_data); if (ret) - goto asoc_utils_fini; + goto codec_unregister; ret = snd_soc_register_card(card); if (ret) { dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n", ret); - goto asoc_utils_fini; + goto codec_unregister; } return 0; -asoc_utils_fini: - tegra_asoc_utils_fini(&machine->util_data); codec_unregister: platform_device_del(machine->codec); codec_put: @@ -140,8 +138,6 @@ static int tegra_wm9712_driver_remove(struct platform_device *pdev) snd_soc_unregister_card(card); - tegra_asoc_utils_fini(&machine->util_data); - platform_device_unregister(machine->codec); return 0; diff --git a/sound/soc/tegra/trimslice.c b/sound/soc/tegra/trimslice.c index f9834afaa2e8..6dca6836aa04 100644 --- a/sound/soc/tegra/trimslice.c +++ b/sound/soc/tegra/trimslice.c @@ -125,8 +125,7 @@ static int tegra_snd_trimslice_probe(struct platform_device *pdev) if (!trimslice_tlv320aic23_dai.codecs->of_node) { dev_err(&pdev->dev, "Property 'nvidia,audio-codec' missing or invalid\n"); - ret = -EINVAL; - goto err; + return -EINVAL; } trimslice_tlv320aic23_dai.cpus->of_node = of_parse_phandle(np, @@ -134,8 +133,7 @@ static int tegra_snd_trimslice_probe(struct platform_device *pdev) if (!trimslice_tlv320aic23_dai.cpus->of_node) { dev_err(&pdev->dev, "Property 'nvidia,i2s-controller' missing or invalid\n"); - ret = -EINVAL; - goto err; + return -EINVAL; } trimslice_tlv320aic23_dai.platforms->of_node = @@ -143,32 +141,24 @@ static int tegra_snd_trimslice_probe(struct platform_device *pdev) ret = tegra_asoc_utils_init(&trimslice->util_data, &pdev->dev); if (ret) - goto err; + return ret; ret = snd_soc_register_card(card); if (ret) { dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n", ret); - goto err_fini_utils; + return ret; } return 0; - -err_fini_utils: - tegra_asoc_utils_fini(&trimslice->util_data); -err: - return ret; } static int tegra_snd_trimslice_remove(struct platform_device *pdev) { struct snd_soc_card *card = platform_get_drvdata(pdev); - struct tegra_trimslice *trimslice = snd_soc_card_get_drvdata(card); snd_soc_unregister_card(card); - tegra_asoc_utils_fini(&trimslice->util_data); - return 0; } -- cgit v1.2.3 From 1e4e0bf136aa4b4aa59c1e6af19844bd6d807794 Mon Sep 17 00:00:00 2001 From: Sowjanya Komatineni Date: Mon, 13 Jan 2020 23:24:23 -0800 Subject: ASoC: tegra: Add audio mclk parent configuration Tegra PMC clock clk_out_1 is dedicated for audio mclk from Tegra30 through Tegra210 and currently Tegra clock driver does the initial parent configuration for audio mclk and keeps it enabled by default. With the move of PMC clocks from clock driver into PMC driver, audio clocks parent configuration can be specified through the device tree using assigned-clock-parents property and audio mclk control should be taken care of by the audio driver. This patch has implementation for parent configuration when default parent configuration through assigned-clock-parents property is not specified in the device tree. Tested-by: Dmitry Osipenko Reviewed-by: Dmitry Osipenko Reviewed-by: Sameer Pujar Signed-off-by: Sowjanya Komatineni Signed-off-by: Thierry Reding --- sound/soc/tegra/tegra_asoc_utils.c | 68 ++++++++++++++++++++++---------------- 1 file changed, 40 insertions(+), 28 deletions(-) (limited to 'sound') diff --git a/sound/soc/tegra/tegra_asoc_utils.c b/sound/soc/tegra/tegra_asoc_utils.c index 0d2271952555..25903ed850c8 100644 --- a/sound/soc/tegra/tegra_asoc_utils.c +++ b/sound/soc/tegra/tegra_asoc_utils.c @@ -60,8 +60,6 @@ int tegra_asoc_utils_set_rate(struct tegra_asoc_utils_data *data, int srate, data->set_mclk = 0; clk_disable_unprepare(data->clk_cdev1); - clk_disable_unprepare(data->clk_pll_a_out0); - clk_disable_unprepare(data->clk_pll_a); err = clk_set_rate(data->clk_pll_a, new_baseclock); if (err) { @@ -77,18 +75,6 @@ int tegra_asoc_utils_set_rate(struct tegra_asoc_utils_data *data, int srate, /* Don't set cdev1/extern1 rate; it's locked to pll_a_out0 */ - err = clk_prepare_enable(data->clk_pll_a); - if (err) { - dev_err(data->dev, "Can't enable pll_a: %d\n", err); - return err; - } - - err = clk_prepare_enable(data->clk_pll_a_out0); - if (err) { - dev_err(data->dev, "Can't enable pll_a_out0: %d\n", err); - return err; - } - err = clk_prepare_enable(data->clk_cdev1); if (err) { dev_err(data->dev, "Can't enable cdev1: %d\n", err); @@ -109,8 +95,6 @@ int tegra_asoc_utils_set_ac97_rate(struct tegra_asoc_utils_data *data) int err; clk_disable_unprepare(data->clk_cdev1); - clk_disable_unprepare(data->clk_pll_a_out0); - clk_disable_unprepare(data->clk_pll_a); /* * AC97 rate is fixed at 24.576MHz and is used for both the host @@ -130,18 +114,6 @@ int tegra_asoc_utils_set_ac97_rate(struct tegra_asoc_utils_data *data) /* Don't set cdev1/extern1 rate; it's locked to pll_a_out0 */ - err = clk_prepare_enable(data->clk_pll_a); - if (err) { - dev_err(data->dev, "Can't enable pll_a: %d\n", err); - return err; - } - - err = clk_prepare_enable(data->clk_pll_a_out0); - if (err) { - dev_err(data->dev, "Can't enable pll_a_out0: %d\n", err); - return err; - } - err = clk_prepare_enable(data->clk_cdev1); if (err) { dev_err(data->dev, "Can't enable cdev1: %d\n", err); @@ -158,6 +130,7 @@ EXPORT_SYMBOL_GPL(tegra_asoc_utils_set_ac97_rate); int tegra_asoc_utils_init(struct tegra_asoc_utils_data *data, struct device *dev) { + struct clk *clk_out_1, *clk_extern1; int ret; data->dev = dev; @@ -193,6 +166,45 @@ int tegra_asoc_utils_init(struct tegra_asoc_utils_data *data, return PTR_ERR(data->clk_cdev1); } + /* + * If clock parents are not set in DT, configure here to use clk_out_1 + * as mclk and extern1 as parent for Tegra30 and higher. + */ + if (!of_find_property(dev->of_node, "assigned-clock-parents", NULL) && + data->soc > TEGRA_ASOC_UTILS_SOC_TEGRA20) { + dev_warn(data->dev, + "Configuring clocks for a legacy device-tree\n"); + dev_warn(data->dev, + "Please update DT to use assigned-clock-parents\n"); + clk_extern1 = devm_clk_get(dev, "extern1"); + if (IS_ERR(clk_extern1)) { + dev_err(data->dev, "Can't retrieve clk extern1\n"); + return PTR_ERR(clk_extern1); + } + + ret = clk_set_parent(clk_extern1, data->clk_pll_a_out0); + if (ret < 0) { + dev_err(data->dev, + "Set parent failed for clk extern1\n"); + return ret; + } + + clk_out_1 = devm_clk_get(dev, "pmc_clk_out_1"); + if (IS_ERR(clk_out_1)) { + dev_err(data->dev, "Can't retrieve pmc_clk_out_1\n"); + return PTR_ERR(clk_out_1); + } + + ret = clk_set_parent(clk_out_1, clk_extern1); + if (ret < 0) { + dev_err(data->dev, + "Set parent failed for pmc_clk_out_1\n"); + return ret; + } + + data->clk_cdev1 = clk_out_1; + } + ret = tegra_asoc_utils_set_rate(data, 44100, 256 * 44100); if (ret) return ret; -- cgit v1.2.3 From ff5d18cb04f4ecccbcf05b7f83ab6df2a0d95c16 Mon Sep 17 00:00:00 2001 From: Sowjanya Komatineni Date: Mon, 13 Jan 2020 23:24:24 -0800 Subject: ASoC: tegra: Enable audio mclk during tegra_asoc_utils_init() Tegra PMC clock clk_out_1 is dedicated for audio mclk from Tegra30 through Tegra210 and currently Tegra clock driver keeps the audio mclk enabled. With the move of PMC clocks from clock driver into pmc driver, audio mclk enable from clock driver is removed and this should be taken care of by the audio driver. tegra_asoc_utils_init() calls tegra_asoc_utils_set_rate() and audio mclk rate configuration is not needed during init and the rate is actually set during the ->hw_params() callback. So, this patch removes tegra_asoc_utils_set_rate() call and just leaves the audio mclk enabled. Signed-off-by: Sowjanya Komatineni Tested-by: Dmitry Osipenko Reviewed-by: Dmitry Osipenko Signed-off-by: Thierry Reding --- sound/soc/tegra/tegra_asoc_utils.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/soc/tegra/tegra_asoc_utils.c b/sound/soc/tegra/tegra_asoc_utils.c index 25903ed850c8..587f62a288d1 100644 --- a/sound/soc/tegra/tegra_asoc_utils.c +++ b/sound/soc/tegra/tegra_asoc_utils.c @@ -205,9 +205,16 @@ int tegra_asoc_utils_init(struct tegra_asoc_utils_data *data, data->clk_cdev1 = clk_out_1; } - ret = tegra_asoc_utils_set_rate(data, 44100, 256 * 44100); - if (ret) + /* + * FIXME: There is some unknown dependency between audio mclk disable + * and suspend-resume functionality on Tegra30, although audio mclk is + * only needed for audio. + */ + ret = clk_prepare_enable(data->clk_cdev1); + if (ret) { + dev_err(data->dev, "Can't enable cdev1: %d\n", ret); return ret; + } return 0; } -- cgit v1.2.3 From c38b608504aa1ad8bfa00d85abd61cffad57f27f Mon Sep 17 00:00:00 2001 From: Shengjiu Wang Date: Fri, 24 Apr 2020 10:01:38 +0800 Subject: ASoC: wm8962: set CLOCKING2 as non-volatile register Previously CLOCKING2 is set as a volatile register, but cause issue at suspend & resume, that some bits of CLOCKING2 is not restored at resume, for example SYSCLK_SRC bits, then the output clock is wrong. The volatile property is caused by CLASSD_CLK_DIV bits, which are controlled by the chip itself. But the datasheet claims these are read only and protected by the security key, and they are not read by the driver at all. So it should be safe to change CLOCKING2 to be non-volatile. Signed-off-by: Shengjiu Wang Acked-by: Charles Keepax Link: https://lore.kernel.org/r/6d25d5b36d4b9aeb8655b5e947dad52214e34177.1587693523.git.shengjiu.wang@nxp.com Signed-off-by: Mark Brown --- sound/soc/codecs/wm8962.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/wm8962.c b/sound/soc/codecs/wm8962.c index d9d59f45833f..0a2cfff44441 100644 --- a/sound/soc/codecs/wm8962.c +++ b/sound/soc/codecs/wm8962.c @@ -118,7 +118,7 @@ static const struct reg_default wm8962_reg[] = { { 5, 0x0018 }, /* R5 - ADC & DAC Control 1 */ { 6, 0x2008 }, /* R6 - ADC & DAC Control 2 */ { 7, 0x000A }, /* R7 - Audio Interface 0 */ - + { 8, 0x01E4 }, /* R8 - Clocking2 */ { 9, 0x0300 }, /* R9 - Audio Interface 1 */ { 10, 0x00C0 }, /* R10 - Left DAC volume */ { 11, 0x00C0 }, /* R11 - Right DAC volume */ @@ -788,7 +788,6 @@ static bool wm8962_volatile_register(struct device *dev, unsigned int reg) { switch (reg) { case WM8962_CLOCKING1: - case WM8962_CLOCKING2: case WM8962_SOFTWARE_RESET: case WM8962_THERMAL_SHUTDOWN_STATUS: case WM8962_ADDITIONAL_CONTROL_4: -- cgit v1.2.3 From 1fecbb71fe0e46b886f84e3b6decca6643c3af6d Mon Sep 17 00:00:00 2001 From: Shengjiu Wang Date: Mon, 27 Apr 2020 14:23:21 +0800 Subject: ASoC: fsl_esai: Disable exception interrupt before scheduling tasklet Disable exception interrupt before scheduling tasklet, otherwise if the tasklet isn't handled immediately, there will be endless xrun interrupt. Fixes: 7ccafa2b3879 ("ASoC: fsl_esai: recover the channel swap after xrun") Signed-off-by: Shengjiu Wang Acked-by: Nicolin Chen Link: https://lore.kernel.org/r/a8f2ad955aac9e52587beedc1133b3efbe746895.1587968824.git.shengjiu.wang@nxp.com Signed-off-by: Mark Brown --- sound/soc/fsl/fsl_esai.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'sound') diff --git a/sound/soc/fsl/fsl_esai.c b/sound/soc/fsl/fsl_esai.c index c7a49d03463a..84290be778f0 100644 --- a/sound/soc/fsl/fsl_esai.c +++ b/sound/soc/fsl/fsl_esai.c @@ -87,6 +87,10 @@ static irqreturn_t esai_isr(int irq, void *devid) if ((saisr & (ESAI_SAISR_TUE | ESAI_SAISR_ROE)) && esai_priv->reset_at_xrun) { dev_dbg(&pdev->dev, "reset module for xrun\n"); + regmap_update_bits(esai_priv->regmap, REG_ESAI_TCR, + ESAI_xCR_xEIE_MASK, 0); + regmap_update_bits(esai_priv->regmap, REG_ESAI_RCR, + ESAI_xCR_xEIE_MASK, 0); tasklet_schedule(&esai_priv->task); } -- cgit v1.2.3 From a697ae6ea56e23397341b027098c1b11d9ab13da Mon Sep 17 00:00:00 2001 From: Xiyu Yang Date: Sat, 25 Apr 2020 20:48:35 +0800 Subject: ASoC: davinci-mcasp: Fix dma_chan refcnt leak when getting dma type davinci_mcasp_get_dma_type() invokes dma_request_chan(), which returns a reference of the specified dma_chan object to "chan" with increased refcnt. When davinci_mcasp_get_dma_type() returns, local variable "chan" becomes invalid, so the refcount should be decreased to keep refcount balanced. The reference counting issue happens in one exception handling path of davinci_mcasp_get_dma_type(). When chan device is NULL, the function forgets to decrease the refcnt increased by dma_request_chan(), causing a refcnt leak. Fix this issue by calling dma_release_channel() when chan device is NULL. Signed-off-by: Xiyu Yang Signed-off-by: Xin Tan Acked-by: Peter Ujfalusi Link: https://lore.kernel.org/r/1587818916-38730-1-git-send-email-xiyuyang19@fudan.edu.cn Signed-off-by: Mark Brown --- sound/soc/ti/davinci-mcasp.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/ti/davinci-mcasp.c b/sound/soc/ti/davinci-mcasp.c index 734ffe925c4d..7a7db743dc5b 100644 --- a/sound/soc/ti/davinci-mcasp.c +++ b/sound/soc/ti/davinci-mcasp.c @@ -1896,8 +1896,10 @@ static int davinci_mcasp_get_dma_type(struct davinci_mcasp *mcasp) PTR_ERR(chan)); return PTR_ERR(chan); } - if (WARN_ON(!chan->device || !chan->device->dev)) + if (WARN_ON(!chan->device || !chan->device->dev)) { + dma_release_channel(chan); return -EINVAL; + } if (chan->device->dev->of_node) ret = of_property_read_string(chan->device->dev->of_node, -- cgit v1.2.3 From be8499c48f115b912f5747c420f66a5e2c31defe Mon Sep 17 00:00:00 2001 From: Dan Murphy Date: Mon, 27 Apr 2020 15:36:08 -0500 Subject: ASoC: tlv320adcx140: Fix mic gain registers Fix the mic gain registers for channels 2-4. The incorret register was being set as it was touching the CH1 config registers. Fixes: 37bde5acf040 ("ASoC: tlv320adcx140: Add the tlv320adcx140 codec driver family") Signed-off-by: Dan Murphy Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/20200427203608.7031-1-dmurphy@ti.com Signed-off-by: Mark Brown --- sound/soc/codecs/tlv320adcx140.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/tlv320adcx140.c b/sound/soc/codecs/tlv320adcx140.c index 38897568ee96..0f713efde046 100644 --- a/sound/soc/codecs/tlv320adcx140.c +++ b/sound/soc/codecs/tlv320adcx140.c @@ -511,11 +511,11 @@ static const struct snd_soc_dapm_route adcx140_audio_map[] = { static const struct snd_kcontrol_new adcx140_snd_controls[] = { SOC_SINGLE_TLV("Analog CH1 Mic Gain Volume", ADCX140_CH1_CFG1, 2, 42, 0, adc_tlv), - SOC_SINGLE_TLV("Analog CH2 Mic Gain Volume", ADCX140_CH1_CFG2, 2, 42, 0, + SOC_SINGLE_TLV("Analog CH2 Mic Gain Volume", ADCX140_CH2_CFG1, 2, 42, 0, adc_tlv), - SOC_SINGLE_TLV("Analog CH3 Mic Gain Volume", ADCX140_CH1_CFG3, 2, 42, 0, + SOC_SINGLE_TLV("Analog CH3 Mic Gain Volume", ADCX140_CH3_CFG1, 2, 42, 0, adc_tlv), - SOC_SINGLE_TLV("Analog CH4 Mic Gain Volume", ADCX140_CH1_CFG4, 2, 42, 0, + SOC_SINGLE_TLV("Analog CH4 Mic Gain Volume", ADCX140_CH4_CFG1, 2, 42, 0, adc_tlv), SOC_SINGLE_TLV("DRE Threshold", ADCX140_DRE_CFG0, 4, 9, 0, -- cgit v1.2.3 From 8382f2949a0def8e9519603b77b3c26f81a66576 Mon Sep 17 00:00:00 2001 From: Ranjani Sridharan Date: Mon, 27 Apr 2020 09:29:53 -0700 Subject: ASoC: Intel: broadwell: Fix oops during module removal When removing the SOF module, the RT286 jack detect handler will oops if jack detection is not disabled. Disable the jack in the machine driver remove callback to prevent this. This fix is only for SOF support and is not needed for earlier versions. Signed-off-by: Ranjani Sridharan Reviewed-by: Kai Vehmanen Link: https://lore.kernel.org/r/20200427162953.21107-1-ranjani.sridharan@linux.intel.com Signed-off-by: Mark Brown --- sound/soc/intel/boards/broadwell.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/intel/boards/broadwell.c b/sound/soc/intel/boards/broadwell.c index f9a8336a0541..86deea6f136a 100644 --- a/sound/soc/intel/boards/broadwell.c +++ b/sound/soc/intel/boards/broadwell.c @@ -230,7 +230,8 @@ static struct snd_soc_dai_link broadwell_rt286_dais[] = { }, }; -static int broadwell_suspend(struct snd_soc_card *card){ +static int broadwell_disable_jack(struct snd_soc_card *card) +{ struct snd_soc_component *component; for_each_card_components(card, component) { @@ -241,9 +242,15 @@ static int broadwell_suspend(struct snd_soc_card *card){ break; } } + return 0; } +static int broadwell_suspend(struct snd_soc_card *card) +{ + return broadwell_disable_jack(card); +} + static int broadwell_resume(struct snd_soc_card *card){ struct snd_soc_component *component; @@ -292,8 +299,16 @@ static int broadwell_audio_probe(struct platform_device *pdev) return devm_snd_soc_register_card(&pdev->dev, &broadwell_rt286); } +static int broadwell_audio_remove(struct platform_device *pdev) +{ + struct snd_soc_card *card = platform_get_drvdata(pdev); + + return broadwell_disable_jack(card); +} + static struct platform_driver broadwell_audio = { .probe = broadwell_audio_probe, + .remove = broadwell_audio_remove, .driver = { .name = "broadwell-audio", }, -- cgit v1.2.3 From 49c22696348d6e7c8a2ecfd7e60fddfe188ded82 Mon Sep 17 00:00:00 2001 From: Kai-Heng Feng Date: Thu, 30 Apr 2020 17:11:39 +0800 Subject: ASoC: SOF: Update correct LED status at the first time usage of update_mute_led() At the first time update_mute_led() gets called, if channels are already muted, the temp value equals to led_value as 0, skipping the following LED setting. So set led_value to -1 as an uninitialized state, to update the correct LED status at first time usage. Fixes: 5d43001ae436 ("ASoC: SOF: acpi led support for switch controls") Signed-off-by: Kai-Heng Feng Reviewed-by: Ranjani Sridharan Acked-by: Kai Vehmanen Link: https://lore.kernel.org/r/20200430091139.7003-1-kai.heng.feng@canonical.com Signed-off-by: Mark Brown --- sound/soc/sof/control.c | 4 ++-- sound/soc/sof/sof-audio.h | 2 +- sound/soc/sof/topology.c | 2 ++ 3 files changed, 5 insertions(+), 3 deletions(-) (limited to 'sound') diff --git a/sound/soc/sof/control.c b/sound/soc/sof/control.c index dfc412e2d956..6d63768d42aa 100644 --- a/sound/soc/sof/control.c +++ b/sound/soc/sof/control.c @@ -19,8 +19,8 @@ static void update_mute_led(struct snd_sof_control *scontrol, struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - unsigned int temp = 0; - unsigned int mask; + int temp = 0; + int mask; int i; mask = 1U << snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); diff --git a/sound/soc/sof/sof-audio.h b/sound/soc/sof/sof-audio.h index bf65f31af858..875a5fc13297 100644 --- a/sound/soc/sof/sof-audio.h +++ b/sound/soc/sof/sof-audio.h @@ -56,7 +56,7 @@ struct snd_sof_pcm { struct snd_sof_led_control { unsigned int use_led; unsigned int direction; - unsigned int led_value; + int led_value; }; /* ALSA SOF Kcontrol device */ diff --git a/sound/soc/sof/topology.c b/sound/soc/sof/topology.c index fe8ba3e05e08..ab2b69de1d4d 100644 --- a/sound/soc/sof/topology.c +++ b/sound/soc/sof/topology.c @@ -1203,6 +1203,8 @@ static int sof_control_load(struct snd_soc_component *scomp, int index, return ret; } + scontrol->led_ctl.led_value = -1; + dobj->private = scontrol; list_add(&scontrol->list, &sdev->kcontrol_list); return ret; -- cgit v1.2.3 From 1a446873d7dd3a450f685928ce7f1907bde4583d Mon Sep 17 00:00:00 2001 From: Yong Zhi Date: Fri, 1 May 2020 18:44:21 -0500 Subject: ASoC: max98373: reorder max98373_reset() in resume During S3 test, the following error was observed: [ 726.174237] i2c_designware i2c_designware.0: platform_pm_resume+0x0/0x3d returned 0 after 0 usecs [ 726.184187] max98373 i2c-MX98373:00: calling max98373_resume+0x0/0x30 [snd_soc_max98373] @ 12698, parent: i2c-11 [ 726.195589] max98373 i2c-MX98373:00: Reset command failed. (ret:-16) When calling regmap_update_bits(), since map->reg_update_bits is NULL, _regmap_read() is entered with the following logic: if (!map->cache_bypass) { ret = regcache_read(map, reg, val); if (ret == 0) return 0; } if (map->cache_only) return -EBUSY; regcache_read() hits -EINVAL because MAX98373_R2000_SW_RESET is volatile, as map->cache_only is set by codec suspend, thus -EBUSY is returned. Fix by moving max98373_reset() after cache_only set to false in max98373_resume(). Signed-off-by: Yong Zhi Link: https://lore.kernel.org/r/1588376661-29799-1-git-send-email-yong.zhi@intel.com Signed-off-by: Mark Brown --- sound/soc/codecs/max98373.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/codecs/max98373.c b/sound/soc/codecs/max98373.c index cae1def8902d..96718e3a1ad0 100644 --- a/sound/soc/codecs/max98373.c +++ b/sound/soc/codecs/max98373.c @@ -850,8 +850,8 @@ static int max98373_resume(struct device *dev) { struct max98373_priv *max98373 = dev_get_drvdata(dev); - max98373_reset(max98373, dev); regcache_cache_only(max98373->regmap, false); + max98373_reset(max98373, dev); regcache_sync(max98373->regmap); return 0; } -- cgit v1.2.3 From 454b3766de45f8508b343e509fdde959b4ff289c Mon Sep 17 00:00:00 2001 From: Wolfram Sang Date: Sat, 2 May 2020 16:26:46 +0200 Subject: ASoC: codecs: max9768: update contact email The 'pengutronix' address is defunct for years. Use the proper contact address. Signed-off-by: Wolfram Sang Link: https://lore.kernel.org/r/20200502142646.19033-1-wsa@kernel.org Signed-off-by: Mark Brown --- sound/soc/codecs/max9768.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/codecs/max9768.c b/sound/soc/codecs/max9768.c index d0737db5868a..39dda1b03b3d 100644 --- a/sound/soc/codecs/max9768.c +++ b/sound/soc/codecs/max9768.c @@ -220,6 +220,6 @@ static struct i2c_driver max9768_i2c_driver = { }; module_i2c_driver(max9768_i2c_driver); -MODULE_AUTHOR("Wolfram Sang "); +MODULE_AUTHOR("Wolfram Sang "); MODULE_DESCRIPTION("ASoC MAX9768 amplifier driver"); MODULE_LICENSE("GPL v2"); -- cgit v1.2.3 From f2b1e1cbd352129cfdbc1af52059482d74b4e81a Mon Sep 17 00:00:00 2001 From: Chris Garren Date: Mon, 4 May 2020 09:43:20 -0400 Subject: ASoC: adau7118: Mark the ADAU7118 reset register as volatile Without this the previously written value was written to this reg, which caused the different configuration registers to be reset. Signed-off-by: Chris Garren Link: https://lore.kernel.org/r/1588599820-57994-1-git-send-email-cdgarren@indesign-llc.com Signed-off-by: Mark Brown --- sound/soc/codecs/adau7118-i2c.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'sound') diff --git a/sound/soc/codecs/adau7118-i2c.c b/sound/soc/codecs/adau7118-i2c.c index a8211362fe82..aa7afb3b826d 100644 --- a/sound/soc/codecs/adau7118-i2c.c +++ b/sound/soc/codecs/adau7118-i2c.c @@ -32,6 +32,12 @@ static const struct reg_default adau7118_reg_defaults[] = { { ADAU7118_REG_RESET, 0x00 }, }; +static bool adau7118_volatile(struct device *dev, unsigned int reg) +{ + return (reg == ADAU7118_REG_RESET); +} + + static const struct regmap_config adau7118_regmap_config = { .reg_bits = 8, .val_bits = 8, @@ -39,6 +45,7 @@ static const struct regmap_config adau7118_regmap_config = { .num_reg_defaults = ARRAY_SIZE(adau7118_reg_defaults), .cache_type = REGCACHE_RBTREE, .max_register = ADAU7118_REG_RESET, + .volatile_reg = adau7118_volatile, }; static int adau7118_probe_i2c(struct i2c_client *i2c, -- cgit v1.2.3 From 5a8117840a8c654c3cdf2f465e9406112d7e492d Mon Sep 17 00:00:00 2001 From: Akshu Agrawal Date: Wed, 6 May 2020 15:56:00 +0530 Subject: ASoC: amd :High hw_level while simultaneous capture Simultaneous capture on dmic and headset mic is having issue with high hw_level being reported. Issue Can be reproduced by: arecord -D hw:2,0 -f dat -d 60 /tmp/test0 & arecord -D hw:2,2 -f dat -d 60 /tmp/test1 & cat /proc/asound/card2/pcm?c/sub0/status Actual issue is : When we open one capture stream on one instance lets say I2S_SP and then once again if we open other capture on other instance lets say I2S_BT while first capture is in progress and when we try to read the status of both running instances by below command cat /proc/asound/card2/pcm?c/sub0/status we observe that avail_max is being doubled on first opened capture(I2S_SP in the example). This is because our previous implementation was like when any instance is opened it gets initialized in dma_open irrespective of on what instance it called open. For example: First I2S_SP called opened it initializes both SP/BT capture streams irrespective of on which instance the stream opened.next time I2S_BT called opened and it initializes both SP/BT this corrupts the behaviour . So with this patch the stream gets initialized only on specific instance when ever it gets opened calls hw_params. This rectifies the issue. Signed-off-by: Ravulapati Vishnu vardhan rao Signed-off-by: Akshu Agrawal Link: https://lore.kernel.org/r/20200506102602.140790-1-akshu.agrawal@amd.com Signed-off-by: Mark Brown --- sound/soc/amd/raven/acp3x-pcm-dma.c | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) (limited to 'sound') diff --git a/sound/soc/amd/raven/acp3x-pcm-dma.c b/sound/soc/amd/raven/acp3x-pcm-dma.c index e362f0bc9e46..a36c5cb848cd 100644 --- a/sound/soc/amd/raven/acp3x-pcm-dma.c +++ b/sound/soc/amd/raven/acp3x-pcm-dma.c @@ -241,14 +241,6 @@ static int acp3x_dma_open(struct snd_soc_component *component, adata->i2ssp_play_stream && !adata->i2ssp_capture_stream) rv_writel(1, adata->acp3x_base + mmACP_EXTERNAL_INTR_ENB); - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - adata->play_stream = substream; - adata->i2ssp_play_stream = substream; - } else { - adata->capture_stream = substream; - adata->i2ssp_capture_stream = substream; - } - i2s_data->acp3x_base = adata->acp3x_base; runtime->private_data = i2s_data; return ret; @@ -263,23 +255,42 @@ static int acp3x_dma_hw_params(struct snd_soc_component *component, struct snd_soc_pcm_runtime *prtd; struct snd_soc_card *card; struct acp3x_platform_info *pinfo; + struct i2s_dev_data *adata; u64 size; prtd = substream->private_data; card = prtd->card; pinfo = snd_soc_card_get_drvdata(card); + adata = dev_get_drvdata(component->dev); rtd = substream->runtime->private_data; if (!rtd) return -EINVAL; - if (pinfo) - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) + if (pinfo) { + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { rtd->i2s_instance = pinfo->play_i2s_instance; - else + switch (rtd->i2s_instance) { + case I2S_BT_INSTANCE: + adata->play_stream = substream; + break; + case I2S_SP_INSTANCE: + default: + adata->i2ssp_play_stream = substream; + } + } else { rtd->i2s_instance = pinfo->cap_i2s_instance; - else + switch (rtd->i2s_instance) { + case I2S_BT_INSTANCE: + adata->capture_stream = substream; + break; + case I2S_SP_INSTANCE: + default: + adata->i2ssp_capture_stream = substream; + } + } + } else { pr_err("pinfo failed\n"); - + } size = params_buffer_bytes(params); rtd->dma_addr = substream->dma_buffer.addr; rtd->num_pages = (PAGE_ALIGN(size) >> PAGE_SHIFT); -- cgit v1.2.3 From fe944625194515e99fcbfb0d190d50986e2b6480 Mon Sep 17 00:00:00 2001 From: Tzung-Bi Shih Date: Thu, 7 May 2020 09:54:42 +0800 Subject: ASoC: mediatek: mt8183: fix error handling of platform_get_irq() platform_get_irq() returns negative value on error instead of 0. Signed-off-by: Tzung-Bi Shih Link: https://lore.kernel.org/r/20200507015442.191336-1-tzungbi@google.com Signed-off-by: Mark Brown --- sound/soc/mediatek/mt8183/mt8183-afe-pcm.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'sound') diff --git a/sound/soc/mediatek/mt8183/mt8183-afe-pcm.c b/sound/soc/mediatek/mt8183/mt8183-afe-pcm.c index c8ded53bde1d..e0c4714da92c 100644 --- a/sound/soc/mediatek/mt8183/mt8183-afe-pcm.c +++ b/sound/soc/mediatek/mt8183/mt8183-afe-pcm.c @@ -1186,10 +1186,9 @@ static int mt8183_afe_pcm_dev_probe(struct platform_device *pdev) /* request irq */ irq_id = platform_get_irq(pdev, 0); - if (!irq_id) { - dev_err(dev, "%pOFn no irq found\n", dev->of_node); - return -ENXIO; - } + if (irq_id < 0) + return irq_id; + ret = devm_request_irq(dev, irq_id, mt8183_afe_irq_handler, IRQF_TRIGGER_NONE, "asys-isr", (void *)afe); if (ret) { -- cgit v1.2.3 From 6a5d6fd332624e4eee9a450bb3d18f761548822f Mon Sep 17 00:00:00 2001 From: Amadeusz Sławiński Date: Thu, 7 May 2020 09:34:04 -0400 Subject: ASoC: Intel: baytrail: Fix register access MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Baytrail has 64 bit registers, so we should use *read64* to read from it and then use proper mask values to check status. Signed-off-by: Amadeusz Sławiński Tested-by: Brent Lu Acked-by: Cezary Rojewski Link: https://lore.kernel.org/r/20200507133405.32251-1-amadeuszx.slawinski@linux.intel.com Signed-off-by: Mark Brown --- sound/soc/intel/baytrail/sst-baytrail-ipc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/soc/intel/baytrail/sst-baytrail-ipc.c b/sound/soc/intel/baytrail/sst-baytrail-ipc.c index 74274bd38f7a..34746fd871b0 100644 --- a/sound/soc/intel/baytrail/sst-baytrail-ipc.c +++ b/sound/soc/intel/baytrail/sst-baytrail-ipc.c @@ -666,8 +666,8 @@ static bool byt_is_dsp_busy(struct sst_dsp *dsp) { u64 ipcx; - ipcx = sst_dsp_shim_read_unlocked(dsp, SST_IPCX); - return (ipcx & (SST_IPCX_BUSY | SST_IPCX_DONE)); + ipcx = sst_dsp_shim_read64_unlocked(dsp, SST_IPCX); + return (ipcx & (SST_BYT_IPCX_BUSY | SST_BYT_IPCX_DONE)); } int sst_byt_dsp_init(struct device *dev, struct sst_pdata *pdata) -- cgit v1.2.3 From 6c47660e3c3acad9401f8fe1d288d4234f05549c Mon Sep 17 00:00:00 2001 From: Amadeusz Sławiński Date: Thu, 7 May 2020 09:34:05 -0400 Subject: ASoC: Intel: Use readq to read 64 bit registers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In order to fix issue described in: "ASoC: Intel: sst: ipc command timeout" https://patchwork.kernel.org/patch/11482829/ use readq function, which is meant to read 64 bit values from registers. On 32 bit platforms it falls back to two readl calls. Reported-by: Brent Lu Signed-off-by: Amadeusz Sławiński Tested-by: Brent Lu Acked-by: Cezary Rojewski Link: https://lore.kernel.org/r/20200507133405.32251-2-amadeuszx.slawinski@linux.intel.com Signed-off-by: Mark Brown --- sound/soc/intel/common/sst-dsp.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'sound') diff --git a/sound/soc/intel/common/sst-dsp.c b/sound/soc/intel/common/sst-dsp.c index ec66be269b69..36c077aa386e 100644 --- a/sound/soc/intel/common/sst-dsp.c +++ b/sound/soc/intel/common/sst-dsp.c @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include #include "sst-dsp.h" @@ -34,16 +34,13 @@ EXPORT_SYMBOL_GPL(sst_shim32_read); void sst_shim32_write64(void __iomem *addr, u32 offset, u64 value) { - memcpy_toio(addr + offset, &value, sizeof(value)); + writeq(value, addr + offset); } EXPORT_SYMBOL_GPL(sst_shim32_write64); u64 sst_shim32_read64(void __iomem *addr, u32 offset) { - u64 val; - - memcpy_fromio(&val, addr + offset, sizeof(val)); - return val; + return readq(addr + offset); } EXPORT_SYMBOL_GPL(sst_shim32_read64); -- cgit v1.2.3 From 00a1aca23e71d83454485d55b5af32c5b367c99f Mon Sep 17 00:00:00 2001 From: Lubomir Rintel Date: Mon, 11 May 2020 23:01:24 +0200 Subject: ASoC: mmp-sspa: Flip SNDRV_PCM_FMTBIT_S24_3LE on The hw_params() callback handles the 3-byte format, not SNDRV_PCM_FMTBIT_S24_LE. Signed-off-by: Lubomir Rintel Link: https://lore.kernel.org/r/20200511210134.1224532-2-lkundrak@v3.sk Signed-off-by: Mark Brown --- sound/soc/pxa/mmp-sspa.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/pxa/mmp-sspa.c b/sound/soc/pxa/mmp-sspa.c index 3548a2634a63..1ca6afe464c4 100644 --- a/sound/soc/pxa/mmp-sspa.c +++ b/sound/soc/pxa/mmp-sspa.c @@ -362,7 +362,7 @@ static int mmp_sspa_probe(struct snd_soc_dai *dai) #define MMP_SSPA_RATES SNDRV_PCM_RATE_8000_192000 #define MMP_SSPA_FORMATS (SNDRV_PCM_FMTBIT_S8 | \ SNDRV_PCM_FMTBIT_S16_LE | \ - SNDRV_PCM_FMTBIT_S24_LE | \ + SNDRV_PCM_FMTBIT_S24_3LE | \ SNDRV_PCM_FMTBIT_S32_LE) static const struct snd_soc_dai_ops mmp_sspa_dai_ops = { -- cgit v1.2.3 From 74fcfde748b26c68a8ab2791d9d73f698f7752d1 Mon Sep 17 00:00:00 2001 From: Lubomir Rintel Date: Mon, 11 May 2020 23:01:25 +0200 Subject: ASoC: mmp-sspa: Drop S20_3LE case It does nothing, because the corresponding bit s not flipped on in .formats and the audio SRAM DMA engine is not able to handle 20-bit transfers anyway. Signed-off-by: Lubomir Rintel Link: https://lore.kernel.org/r/20200511210134.1224532-3-lkundrak@v3.sk Signed-off-by: Mark Brown --- sound/soc/pxa/mmp-sspa.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'sound') diff --git a/sound/soc/pxa/mmp-sspa.c b/sound/soc/pxa/mmp-sspa.c index 1ca6afe464c4..90a9bc81be80 100644 --- a/sound/soc/pxa/mmp-sspa.c +++ b/sound/soc/pxa/mmp-sspa.c @@ -275,9 +275,6 @@ static int mmp_sspa_hw_params(struct snd_pcm_substream *substream, case SNDRV_PCM_FORMAT_S16_LE: sspa_ctrl |= SSPA_CTL_XSSZ1(SSPA_CTL_16_BITS); break; - case SNDRV_PCM_FORMAT_S20_3LE: - sspa_ctrl |= SSPA_CTL_XSSZ1(SSPA_CTL_20_BITS); - break; case SNDRV_PCM_FORMAT_S24_3LE: sspa_ctrl |= SSPA_CTL_XSSZ1(SSPA_CTL_24_BITS); break; -- cgit v1.2.3 From 65e412a01bc0161175a962abd5a7fef6a62d5c8e Mon Sep 17 00:00:00 2001 From: Shengjiu Wang Date: Wed, 13 May 2020 13:30:35 +0800 Subject: ASoC: wm8962: Use force clear for WM8962_SYSCLK_ENA after reset When CLOCKING2 is non-volatile register, we need force clear the WM8962_SYSCLK_ENA bit after reset, for the value in cache maybe 0 but in hardware it is 1. Otherwise there will issue as below statement in driver. /* SYSCLK defaults to on; make sure it is off so we can safely * write to registers if the device is declocked. Fixes: c38b608504aa ("ASoC: wm8962: set CLOCKING2 as non-volatile register") Signed-off-by: Shengjiu Wang Acked-by: Charles Keepax Link: https://lore.kernel.org/r/1589347835-20554-1-git-send-email-shengjiu.wang@nxp.com Signed-off-by: Mark Brown --- sound/soc/codecs/wm8962.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/wm8962.c b/sound/soc/codecs/wm8962.c index 0a2cfff44441..08d19df8a700 100644 --- a/sound/soc/codecs/wm8962.c +++ b/sound/soc/codecs/wm8962.c @@ -3798,8 +3798,8 @@ static int wm8962_runtime_resume(struct device *dev) /* SYSCLK defaults to on; make sure it is off so we can safely * write to registers if the device is declocked. */ - regmap_update_bits(wm8962->regmap, WM8962_CLOCKING2, - WM8962_SYSCLK_ENA, 0); + regmap_write_bits(wm8962->regmap, WM8962_CLOCKING2, + WM8962_SYSCLK_ENA, 0); /* Ensure we have soft control over all registers */ regmap_update_bits(wm8962->regmap, WM8962_CLOCKING2, -- cgit v1.2.3 From 0e36f32f6b6c4c86a6bf3d6f0940831691b0a3b0 Mon Sep 17 00:00:00 2001 From: Dan Murphy Date: Wed, 13 May 2020 09:28:07 -0500 Subject: ASoC: tlv320adcx140: Fix bias config values The device tree binding declares the ti,mic-bias-source and the ti,vref-source properties as u32. The code reads them as u8 which is incorrect. Since the device tree binding indicates them as u32 the conde needs to be updated to read u32. In addition the bias source needs to be shifted 4 bits to correctly write the register. driver family") Fixes: 37bde5acf040 ("ASoC: tlv320adcx140: Add the tlv320adcx140 codec Signed-off-by: Dan Murphy Link: https://lore.kernel.org/r/20200513142807.11802-1-dmurphy@ti.com Signed-off-by: Mark Brown --- sound/soc/codecs/tlv320adcx140.c | 13 +++++++------ sound/soc/codecs/tlv320adcx140.h | 1 + 2 files changed, 8 insertions(+), 6 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/tlv320adcx140.c b/sound/soc/codecs/tlv320adcx140.c index 0f713efde046..1d7d7b34a46e 100644 --- a/sound/soc/codecs/tlv320adcx140.c +++ b/sound/soc/codecs/tlv320adcx140.c @@ -739,11 +739,12 @@ static int adcx140_codec_probe(struct snd_soc_component *component) { struct adcx140_priv *adcx140 = snd_soc_component_get_drvdata(component); int sleep_cfg_val = ADCX140_WAKE_DEV; - u8 bias_source; - u8 vref_source; + u32 bias_source; + u32 vref_source; + u8 bias_cfg; int ret; - ret = device_property_read_u8(adcx140->dev, "ti,mic-bias-source", + ret = device_property_read_u32(adcx140->dev, "ti,mic-bias-source", &bias_source); if (ret) bias_source = ADCX140_MIC_BIAS_VAL_VREF; @@ -754,7 +755,7 @@ static int adcx140_codec_probe(struct snd_soc_component *component) return -EINVAL; } - ret = device_property_read_u8(adcx140->dev, "ti,vref-source", + ret = device_property_read_u32(adcx140->dev, "ti,vref-source", &vref_source); if (ret) vref_source = ADCX140_MIC_BIAS_VREF_275V; @@ -765,7 +766,7 @@ static int adcx140_codec_probe(struct snd_soc_component *component) return -EINVAL; } - bias_source |= vref_source; + bias_cfg = bias_source << ADCX140_MIC_BIAS_SHIFT | vref_source; ret = adcx140_reset(adcx140); if (ret) @@ -785,7 +786,7 @@ static int adcx140_codec_probe(struct snd_soc_component *component) ret = regmap_update_bits(adcx140->regmap, ADCX140_BIAS_CFG, ADCX140_MIC_BIAS_VAL_MSK | - ADCX140_MIC_BIAS_VREF_MSK, bias_source); + ADCX140_MIC_BIAS_VREF_MSK, bias_cfg); if (ret) dev_err(adcx140->dev, "setting MIC bias failed %d\n", ret); out: diff --git a/sound/soc/codecs/tlv320adcx140.h b/sound/soc/codecs/tlv320adcx140.h index 6d055e55909e..69de52d473f4 100644 --- a/sound/soc/codecs/tlv320adcx140.h +++ b/sound/soc/codecs/tlv320adcx140.h @@ -116,6 +116,7 @@ #define ADCX140_MIC_BIAS_VAL_VREF_1096 1 #define ADCX140_MIC_BIAS_VAL_AVDD 6 #define ADCX140_MIC_BIAS_VAL_MSK GENMASK(6, 4) +#define ADCX140_MIC_BIAS_SHIFT 4 #define ADCX140_MIC_BIAS_VREF_275V 0 #define ADCX140_MIC_BIAS_VREF_25V 1 -- cgit v1.2.3 From 8ba4dc3cff8cbe2c571063a5fd7116e8bde563ca Mon Sep 17 00:00:00 2001 From: Pavel Dobias Date: Fri, 15 May 2020 14:07:57 +0200 Subject: ASoC: max9867: fix volume controls The xmax values for Master Playback Volume and Mic Boost Capture Volume are specified incorrectly (one greater) which results in the wrong dB gain being shown to the user in the case of Master Playback Volume. Signed-off-by: Pavel Dobias Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/20200515120757.24669-1-dobias@2n.cz Signed-off-by: Mark Brown --- sound/soc/codecs/max9867.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/max9867.c b/sound/soc/codecs/max9867.c index 8600c5439e1e..2e4aa23b5a60 100644 --- a/sound/soc/codecs/max9867.c +++ b/sound/soc/codecs/max9867.c @@ -46,13 +46,13 @@ static const SNDRV_CTL_TLVD_DECLARE_DB_RANGE(max9867_micboost_tlv, static const struct snd_kcontrol_new max9867_snd_controls[] = { SOC_DOUBLE_R_TLV("Master Playback Volume", MAX9867_LEFTVOL, - MAX9867_RIGHTVOL, 0, 41, 1, max9867_master_tlv), + MAX9867_RIGHTVOL, 0, 40, 1, max9867_master_tlv), SOC_DOUBLE_R_TLV("Line Capture Volume", MAX9867_LEFTLINELVL, MAX9867_RIGHTLINELVL, 0, 15, 1, max9867_line_tlv), SOC_DOUBLE_R_TLV("Mic Capture Volume", MAX9867_LEFTMICGAIN, MAX9867_RIGHTMICGAIN, 0, 20, 1, max9867_mic_tlv), SOC_DOUBLE_R_TLV("Mic Boost Capture Volume", MAX9867_LEFTMICGAIN, - MAX9867_RIGHTMICGAIN, 5, 4, 0, max9867_micboost_tlv), + MAX9867_RIGHTMICGAIN, 5, 3, 0, max9867_micboost_tlv), SOC_SINGLE("Digital Sidetone Volume", MAX9867_SIDETONE, 0, 31, 1), SOC_SINGLE_TLV("Digital Playback Volume", MAX9867_DACLEVEL, 0, 15, 1, max9867_dac_tlv), -- cgit v1.2.3 From 53a58bf96bcdd47c670a957920f3a1bcf7215b39 Mon Sep 17 00:00:00 2001 From: Pavel Dobias Date: Wed, 20 May 2020 09:18:59 +0200 Subject: ASoC: max9867: fix ADC level control Fix swapped channels in ADC level control. Signed-off-by: Pavel Dobias Link: https://lore.kernel.org/r/20200520071904.15801-1-dobias@2n.cz Signed-off-by: Mark Brown --- sound/soc/codecs/max9867.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/codecs/max9867.c b/sound/soc/codecs/max9867.c index 2e4aa23b5a60..6d49a1cc98c6 100644 --- a/sound/soc/codecs/max9867.c +++ b/sound/soc/codecs/max9867.c @@ -58,7 +58,7 @@ static const struct snd_kcontrol_new max9867_snd_controls[] = { max9867_dac_tlv), SOC_SINGLE_TLV("Digital Boost Playback Volume", MAX9867_DACLEVEL, 4, 3, 0, max9867_dacboost_tlv), - SOC_DOUBLE_TLV("Digital Capture Volume", MAX9867_ADCLEVEL, 0, 4, 15, 1, + SOC_DOUBLE_TLV("Digital Capture Volume", MAX9867_ADCLEVEL, 4, 0, 15, 1, max9867_adc_tlv), SOC_ENUM("Speaker Mode", max9867_spkmode), SOC_SINGLE("Volume Smoothing Switch", MAX9867_MODECONFIG, 6, 1, 0), -- cgit v1.2.3 From f4aa5e214eeaf7f1c7f157526a5aa29784cb6a1f Mon Sep 17 00:00:00 2001 From: Charles Keepax Date: Tue, 26 May 2020 17:19:30 +0100 Subject: ASoC: dapm: Move dai_link widgets to runtime to fix use after free The newly added CODEC to CODEC DAI link widget pointers in snd_soc_dai_link are better placed in snd_soc_pcm_runtime. snd_soc_dai_link is really intended for static configuration of the DAI, and the runtime for dynamic data. The snd_soc_dai_link structures are not destroyed if the card is unbound. The widgets are cleared up on unbind, however if the card is rebound as the snd_soc_dai_link structures are reused these pointers will be left at their old values, causing access to freed memory. Fixes: 595571cca4de ("ASoC: dapm: Fix regression introducing multiple copies of DAI widgets") Signed-off-by: Charles Keepax Link: https://lore.kernel.org/r/20200526161930.30759-1-ckeepax@opensource.cirrus.com Signed-off-by: Mark Brown --- include/sound/soc.h | 6 +++--- sound/soc/soc-dapm.c | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) (limited to 'sound') diff --git a/include/sound/soc.h b/include/sound/soc.h index 946f88a6c63d..53e2062b9cef 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -790,9 +790,6 @@ struct snd_soc_dai_link { const struct snd_soc_pcm_stream *params; unsigned int num_params; - struct snd_soc_dapm_widget *playback_widget; - struct snd_soc_dapm_widget *capture_widget; - unsigned int dai_fmt; /* format to set on init */ enum snd_soc_dpcm_trigger trigger[2]; /* trigger type for DPCM */ @@ -1156,6 +1153,9 @@ struct snd_soc_pcm_runtime { struct snd_soc_dai **cpu_dais; unsigned int num_cpus; + struct snd_soc_dapm_widget *playback_widget; + struct snd_soc_dapm_widget *capture_widget; + struct delayed_work delayed_work; void (*close_delayed_work_func)(struct snd_soc_pcm_runtime *rtd); #ifdef CONFIG_DEBUG_FS diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index e2632841b321..c0aa64ff8e32 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c @@ -4340,16 +4340,16 @@ static void dapm_connect_dai_pair(struct snd_soc_card *card, codec = codec_dai->playback_widget; if (playback_cpu && codec) { - if (dai_link->params && !dai_link->playback_widget) { + if (dai_link->params && !rtd->playback_widget) { substream = streams[SNDRV_PCM_STREAM_PLAYBACK].substream; dai = snd_soc_dapm_new_dai(card, substream, "playback"); if (IS_ERR(dai)) goto capture; - dai_link->playback_widget = dai; + rtd->playback_widget = dai; } dapm_connect_dai_routes(&card->dapm, cpu_dai, playback_cpu, - dai_link->playback_widget, + rtd->playback_widget, codec_dai, codec); } @@ -4358,16 +4358,16 @@ capture: codec = codec_dai->capture_widget; if (codec && capture_cpu) { - if (dai_link->params && !dai_link->capture_widget) { + if (dai_link->params && !rtd->capture_widget) { substream = streams[SNDRV_PCM_STREAM_CAPTURE].substream; dai = snd_soc_dapm_new_dai(card, substream, "capture"); if (IS_ERR(dai)) return; - dai_link->capture_widget = dai; + rtd->capture_widget = dai; } dapm_connect_dai_routes(&card->dapm, codec_dai, codec, - dai_link->capture_widget, + rtd->capture_widget, cpu_dai, capture_cpu); } } -- cgit v1.2.3