Commit 5c9016f0 authored by Thierry Reding's avatar Thierry Reding Committed by Krzysztof Kozlowski

memory: tegra: Push suspend/resume into SoC drivers

Continuing the scheme of unification, push suspend/resume callbacks into
per-SoC driver so that they can be properly parameterized.
Signed-off-by: default avatarThierry Reding <treding@nvidia.com>
Link: https://lore.kernel.org/r/20210602163302.120041-5-thierry.reding@gmail.comSigned-off-by: default avatarKrzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
parent 6cc884c1
...@@ -867,37 +867,28 @@ static int tegra_mc_probe(struct platform_device *pdev) ...@@ -867,37 +867,28 @@ static int tegra_mc_probe(struct platform_device *pdev)
return 0; return 0;
} }
static int tegra_mc_suspend(struct device *dev) static int __maybe_unused tegra_mc_suspend(struct device *dev)
{ {
struct tegra_mc *mc = dev_get_drvdata(dev); struct tegra_mc *mc = dev_get_drvdata(dev);
int err;
if (IS_ENABLED(CONFIG_TEGRA_IOMMU_GART) && mc->gart) { if (mc->soc->ops && mc->soc->ops->suspend)
err = tegra_gart_suspend(mc->gart); return mc->soc->ops->suspend(mc);
if (err)
return err;
}
return 0; return 0;
} }
static int tegra_mc_resume(struct device *dev) static int __maybe_unused tegra_mc_resume(struct device *dev)
{ {
struct tegra_mc *mc = dev_get_drvdata(dev); struct tegra_mc *mc = dev_get_drvdata(dev);
int err;
if (IS_ENABLED(CONFIG_TEGRA_IOMMU_GART) && mc->gart) { if (mc->soc->ops && mc->soc->ops->resume)
err = tegra_gart_resume(mc->gart); return mc->soc->ops->resume(mc);
if (err)
return err;
}
return 0; return 0;
} }
static const struct dev_pm_ops tegra_mc_pm_ops = { static const struct dev_pm_ops tegra_mc_pm_ops = {
.suspend = tegra_mc_suspend, SET_SYSTEM_SLEEP_PM_OPS(tegra_mc_suspend, tegra_mc_resume)
.resume = tegra_mc_resume,
}; };
static struct platform_driver tegra_mc_driver = { static struct platform_driver tegra_mc_driver = {
......
...@@ -45,6 +45,17 @@ static void tegra186_mc_program_sid(struct tegra_mc *mc) ...@@ -45,6 +45,17 @@ static void tegra186_mc_program_sid(struct tegra_mc *mc)
} }
} }
static int tegra186_mc_resume(struct tegra_mc *mc)
{
tegra186_mc_program_sid(mc);
return 0;
}
static const struct tegra_mc_ops tegra186_mc_ops = {
.resume = tegra186_mc_resume,
};
#if defined(CONFIG_ARCH_TEGRA_186_SOC) #if defined(CONFIG_ARCH_TEGRA_186_SOC)
static const struct tegra_mc_client tegra186_mc_clients[] = { static const struct tegra_mc_client tegra186_mc_clients[] = {
{ {
...@@ -701,6 +712,7 @@ static const struct tegra_mc_client tegra186_mc_clients[] = { ...@@ -701,6 +712,7 @@ static const struct tegra_mc_client tegra186_mc_clients[] = {
static const struct tegra_mc_soc tegra186_mc_soc = { static const struct tegra_mc_soc tegra186_mc_soc = {
.num_clients = ARRAY_SIZE(tegra186_mc_clients), .num_clients = ARRAY_SIZE(tegra186_mc_clients),
.clients = tegra186_mc_clients, .clients = tegra186_mc_clients,
.ops = &tegra186_mc_ops,
}; };
#endif #endif
...@@ -1909,6 +1921,7 @@ static const struct tegra_mc_client tegra194_mc_clients[] = { ...@@ -1909,6 +1921,7 @@ static const struct tegra_mc_client tegra194_mc_clients[] = {
static const struct tegra_mc_soc tegra194_mc_soc = { static const struct tegra_mc_soc tegra194_mc_soc = {
.num_clients = ARRAY_SIZE(tegra194_mc_clients), .num_clients = ARRAY_SIZE(tegra194_mc_clients),
.clients = tegra194_mc_clients, .clients = tegra194_mc_clients,
.ops = &tegra186_mc_ops,
}; };
#endif #endif
...@@ -1961,22 +1974,28 @@ static const struct of_device_id tegra186_mc_of_match[] = { ...@@ -1961,22 +1974,28 @@ static const struct of_device_id tegra186_mc_of_match[] = {
}; };
MODULE_DEVICE_TABLE(of, tegra186_mc_of_match); MODULE_DEVICE_TABLE(of, tegra186_mc_of_match);
static int __maybe_unused tegra186_mc_suspend(struct device *dev) static int __maybe_unused tegra_mc_suspend(struct device *dev)
{ {
struct tegra_mc *mc = dev_get_drvdata(dev);
if (mc->soc->ops && mc->soc->ops->suspend)
return mc->soc->ops->suspend(mc);
return 0; return 0;
} }
static int __maybe_unused tegra186_mc_resume(struct device *dev) static int __maybe_unused tegra_mc_resume(struct device *dev)
{ {
struct tegra_mc *mc = dev_get_drvdata(dev); struct tegra_mc *mc = dev_get_drvdata(dev);
tegra186_mc_program_sid(mc); if (mc->soc->ops && mc->soc->ops->resume)
return mc->soc->ops->resume(mc);
return 0; return 0;
} }
static const struct dev_pm_ops tegra186_mc_pm_ops = { static const struct dev_pm_ops tegra186_mc_pm_ops = {
SET_SYSTEM_SLEEP_PM_OPS(tegra186_mc_suspend, tegra186_mc_resume) SET_SYSTEM_SLEEP_PM_OPS(tegra_mc_suspend, tegra_mc_resume)
}; };
static struct platform_driver tegra186_mc_driver = { static struct platform_driver tegra186_mc_driver = {
......
...@@ -687,8 +687,36 @@ static int tegra20_mc_init(struct tegra_mc *mc) ...@@ -687,8 +687,36 @@ static int tegra20_mc_init(struct tegra_mc *mc)
return 0; return 0;
} }
static int tegra20_mc_suspend(struct tegra_mc *mc)
{
int err;
if (IS_ENABLED(CONFIG_TEGRA_IOMMU_GART) && mc->gart) {
err = tegra_gart_suspend(mc->gart);
if (err < 0)
return err;
}
return 0;
}
static int tegra20_mc_resume(struct tegra_mc *mc)
{
int err;
if (IS_ENABLED(CONFIG_TEGRA_IOMMU_GART) && mc->gart) {
err = tegra_gart_resume(mc->gart);
if (err < 0)
return err;
}
return 0;
}
static const struct tegra_mc_ops tegra20_mc_ops = { static const struct tegra_mc_ops tegra20_mc_ops = {
.init = tegra20_mc_init, .init = tegra20_mc_init,
.suspend = tegra20_mc_suspend,
.resume = tegra20_mc_resume,
}; };
const struct tegra_mc_soc tegra20_mc_soc = { const struct tegra_mc_soc tegra20_mc_soc = {
......
...@@ -171,6 +171,8 @@ struct tegra_mc_icc_ops { ...@@ -171,6 +171,8 @@ struct tegra_mc_icc_ops {
struct tegra_mc_ops { struct tegra_mc_ops {
int (*init)(struct tegra_mc *mc); int (*init)(struct tegra_mc *mc);
int (*suspend)(struct tegra_mc *mc);
int (*resume)(struct tegra_mc *mc);
}; };
struct tegra_mc_soc { struct tegra_mc_soc {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment