[PATCH 1/9] ata: ahci_tegra: Explicitly specify PMC instance to use

From: Thierry Reding

Date: Wed May 06 2026 - 09:43:25 EST


From: Thierry Reding <treding@xxxxxxxxxx>

Currently the kernel relies on a global variable to reference the PMC
context. Use an explicit lookup for the PMC and pass that to the public
PMC APIs.

Signed-off-by: Thierry Reding <treding@xxxxxxxxxx>
---
drivers/ata/ahci_tegra.c | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/drivers/ata/ahci_tegra.c b/drivers/ata/ahci_tegra.c
index 44584eed6374..554f05e09f98 100644
--- a/drivers/ata/ahci_tegra.c
+++ b/drivers/ata/ahci_tegra.c
@@ -175,6 +175,7 @@ struct tegra_ahci_priv {
struct reset_control *sata_cold_rst;
/* Needs special handling, cannot use ahci_platform */
struct clk *sata_clk;
+ struct tegra_pmc *pmc;
struct regulator_bulk_data *supplies;
const struct tegra_ahci_soc *soc;
};
@@ -246,9 +247,10 @@ static int tegra_ahci_power_on(struct ahci_host_priv *hpriv)
return ret;

if (!tegra->pdev->dev.pm_domain) {
- ret = tegra_powergate_sequence_power_up(TEGRA_POWERGATE_SATA,
- tegra->sata_clk,
- tegra->sata_rst);
+ ret = tegra_pmc_powergate_sequence_power_up(tegra->pmc,
+ TEGRA_POWERGATE_SATA,
+ tegra->sata_clk,
+ tegra->sata_rst);
if (ret)
goto disable_regulators;
}
@@ -269,7 +271,7 @@ static int tegra_ahci_power_on(struct ahci_host_priv *hpriv)
clk_disable_unprepare(tegra->sata_clk);

if (!tegra->pdev->dev.pm_domain)
- tegra_powergate_power_off(TEGRA_POWERGATE_SATA);
+ tegra_pmc_powergate_power_off(tegra->pmc, TEGRA_POWERGATE_SATA);

disable_regulators:
regulator_bulk_disable(tegra->soc->num_supplies, tegra->supplies);
@@ -289,7 +291,7 @@ static void tegra_ahci_power_off(struct ahci_host_priv *hpriv)

clk_disable_unprepare(tegra->sata_clk);
if (!tegra->pdev->dev.pm_domain)
- tegra_powergate_power_off(TEGRA_POWERGATE_SATA);
+ tegra_pmc_powergate_power_off(tegra->pmc, TEGRA_POWERGATE_SATA);

regulator_bulk_disable(tegra->soc->num_supplies, tegra->supplies);
}
@@ -571,6 +573,11 @@ static int tegra_ahci_probe(struct platform_device *pdev)
return PTR_ERR(tegra->sata_clk);
}

+ tegra->pmc = devm_tegra_pmc_get(&pdev->dev);
+ if (IS_ERR(tegra->pmc))
+ return dev_err_probe(&pdev->dev, PTR_ERR(tegra->pmc),
+ "failed to get PMC\n");
+
tegra->supplies = devm_kcalloc(&pdev->dev,
tegra->soc->num_supplies,
sizeof(*tegra->supplies), GFP_KERNEL);

--
2.52.0