mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-03 17:40:04 +00:00
iommu: dart: Add suspend/resume support
We need to save/restore the TCR/TTBR registers, since they are lost on power gate. Reviewed-by: Sven Peter <sven@svenpeter.dev> Signed-off-by: Hector Martin <marcan@marcan.st> Link: https://lore.kernel.org/r/20230113105029.26654-3-marcan@marcan.st Signed-off-by: Joerg Roedel <jroedel@suse.de>
This commit is contained in:
parent
659bf8e582
commit
3d68bbb81b
1 changed files with 43 additions and 0 deletions
|
@ -121,6 +121,9 @@ struct apple_dart {
|
|||
|
||||
struct iommu_group *sid2group[DART_MAX_STREAMS];
|
||||
struct iommu_device iommu;
|
||||
|
||||
u32 save_tcr[DART_MAX_STREAMS];
|
||||
u32 save_ttbr[DART_MAX_STREAMS][DART_MAX_TTBR];
|
||||
};
|
||||
|
||||
/*
|
||||
|
@ -932,6 +935,45 @@ static const struct apple_dart_hw apple_dart_hw_t6000 = {
|
|||
.fmt = APPLE_DART2,
|
||||
};
|
||||
|
||||
static __maybe_unused int apple_dart_suspend(struct device *dev)
|
||||
{
|
||||
struct apple_dart *dart = dev_get_drvdata(dev);
|
||||
unsigned int sid, idx;
|
||||
|
||||
for (sid = 0; sid < DART_MAX_STREAMS; sid++) {
|
||||
dart->save_tcr[sid] = readl_relaxed(dart->regs + DART_TCR(sid));
|
||||
for (idx = 0; idx < DART_MAX_TTBR; idx++)
|
||||
dart->save_ttbr[sid][idx] =
|
||||
readl(dart->regs + DART_TTBR(sid, idx));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static __maybe_unused int apple_dart_resume(struct device *dev)
|
||||
{
|
||||
struct apple_dart *dart = dev_get_drvdata(dev);
|
||||
unsigned int sid, idx;
|
||||
int ret;
|
||||
|
||||
ret = apple_dart_hw_reset(dart);
|
||||
if (ret) {
|
||||
dev_err(dev, "Failed to reset DART on resume\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
for (sid = 0; sid < DART_MAX_STREAMS; sid++) {
|
||||
for (idx = 0; idx < DART_MAX_TTBR; idx++)
|
||||
writel(dart->save_ttbr[sid][idx],
|
||||
dart->regs + DART_TTBR(sid, idx));
|
||||
writel(dart->save_tcr[sid], dart->regs + DART_TCR(sid));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
DEFINE_SIMPLE_DEV_PM_OPS(apple_dart_pm_ops, apple_dart_suspend, apple_dart_resume);
|
||||
|
||||
static const struct of_device_id apple_dart_of_match[] = {
|
||||
{ .compatible = "apple,t8103-dart", .data = &apple_dart_hw_t8103 },
|
||||
{ .compatible = "apple,t6000-dart", .data = &apple_dart_hw_t6000 },
|
||||
|
@ -944,6 +986,7 @@ static struct platform_driver apple_dart_driver = {
|
|||
.name = "apple-dart",
|
||||
.of_match_table = apple_dart_of_match,
|
||||
.suppress_bind_attrs = true,
|
||||
.pm = pm_sleep_ptr(&apple_dart_pm_ops),
|
||||
},
|
||||
.probe = apple_dart_probe,
|
||||
.remove = apple_dart_remove,
|
||||
|
|
Loading…
Reference in a new issue