ALSA: hda/tegra: Use clk_bulk helpers

[ Upstream commit 3a465f027a33cbd2af74f882ad41729583195e8f ]

Use clk_bulk helpers to make code cleaner. Note that this patch changed
the order in which clocks are enabled to make code look nicer, but this
doesn't matter in terms of hardware.

Tested-by: Peter Geis <pgwipeout@gmail.com> # Ouya T30 audio works
Tested-by: Matt Merhar <mattmerhar@protonmail.com> # Ouya T30 boot-tested
Tested-by: Nicolas Chauvet <kwizart@gmail.com> # TK1 boot-tested
Acked-by: Thierry Reding <treding@nvidia.com>
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
Link: https://lore.kernel.org/r/20210120003154.26749-2-digetx@gmail.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Stable-dep-of: f89e409402e2 ("ALSA: hda: Fix Nvidia dp infoframe")
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
Dmitry Osipenko
2021-01-20 03:31:49 +03:00
committed by Greg Kroah-Hartman
parent b2ad53fbc0
commit ded9e8964d

View File

@@ -70,9 +70,8 @@
struct hda_tegra { struct hda_tegra {
struct azx chip; struct azx chip;
struct device *dev; struct device *dev;
struct clk *hda_clk; struct clk_bulk_data clocks[3];
struct clk *hda2codec_2x_clk; unsigned int nclocks;
struct clk *hda2hdmi_clk;
void __iomem *regs; void __iomem *regs;
struct work_struct probe_work; struct work_struct probe_work;
}; };
@@ -113,36 +112,6 @@ static void hda_tegra_init(struct hda_tegra *hda)
writel(v, hda->regs + HDA_IPFS_INTR_MASK); writel(v, hda->regs + HDA_IPFS_INTR_MASK);
} }
static int hda_tegra_enable_clocks(struct hda_tegra *data)
{
int rc;
rc = clk_prepare_enable(data->hda_clk);
if (rc)
return rc;
rc = clk_prepare_enable(data->hda2codec_2x_clk);
if (rc)
goto disable_hda;
rc = clk_prepare_enable(data->hda2hdmi_clk);
if (rc)
goto disable_codec_2x;
return 0;
disable_codec_2x:
clk_disable_unprepare(data->hda2codec_2x_clk);
disable_hda:
clk_disable_unprepare(data->hda_clk);
return rc;
}
static void hda_tegra_disable_clocks(struct hda_tegra *data)
{
clk_disable_unprepare(data->hda2hdmi_clk);
clk_disable_unprepare(data->hda2codec_2x_clk);
clk_disable_unprepare(data->hda_clk);
}
/* /*
* power management * power management
*/ */
@@ -186,7 +155,7 @@ static int __maybe_unused hda_tegra_runtime_suspend(struct device *dev)
azx_stop_chip(chip); azx_stop_chip(chip);
azx_enter_link_reset(chip); azx_enter_link_reset(chip);
} }
hda_tegra_disable_clocks(hda); clk_bulk_disable_unprepare(hda->nclocks, hda->clocks);
return 0; return 0;
} }
@@ -198,7 +167,7 @@ static int __maybe_unused hda_tegra_runtime_resume(struct device *dev)
struct hda_tegra *hda = container_of(chip, struct hda_tegra, chip); struct hda_tegra *hda = container_of(chip, struct hda_tegra, chip);
int rc; int rc;
rc = hda_tegra_enable_clocks(hda); rc = clk_bulk_prepare_enable(hda->nclocks, hda->clocks);
if (rc != 0) if (rc != 0)
return rc; return rc;
if (chip && chip->running) { if (chip && chip->running) {
@@ -268,29 +237,6 @@ static int hda_tegra_init_chip(struct azx *chip, struct platform_device *pdev)
return 0; return 0;
} }
static int hda_tegra_init_clk(struct hda_tegra *hda)
{
struct device *dev = hda->dev;
hda->hda_clk = devm_clk_get(dev, "hda");
if (IS_ERR(hda->hda_clk)) {
dev_err(dev, "failed to get hda clock\n");
return PTR_ERR(hda->hda_clk);
}
hda->hda2codec_2x_clk = devm_clk_get(dev, "hda2codec_2x");
if (IS_ERR(hda->hda2codec_2x_clk)) {
dev_err(dev, "failed to get hda2codec_2x clock\n");
return PTR_ERR(hda->hda2codec_2x_clk);
}
hda->hda2hdmi_clk = devm_clk_get(dev, "hda2hdmi");
if (IS_ERR(hda->hda2hdmi_clk)) {
dev_err(dev, "failed to get hda2hdmi clock\n");
return PTR_ERR(hda->hda2hdmi_clk);
}
return 0;
}
static int hda_tegra_first_init(struct azx *chip, struct platform_device *pdev) static int hda_tegra_first_init(struct azx *chip, struct platform_device *pdev)
{ {
struct hda_tegra *hda = container_of(chip, struct hda_tegra, chip); struct hda_tegra *hda = container_of(chip, struct hda_tegra, chip);
@@ -499,7 +445,11 @@ static int hda_tegra_probe(struct platform_device *pdev)
return err; return err;
} }
err = hda_tegra_init_clk(hda); hda->clocks[hda->nclocks++].id = "hda";
hda->clocks[hda->nclocks++].id = "hda2hdmi";
hda->clocks[hda->nclocks++].id = "hda2codec_2x";
err = devm_clk_bulk_get(&pdev->dev, hda->nclocks, hda->clocks);
if (err < 0) if (err < 0)
goto out_free; goto out_free;