aboutsummaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorCaleb Connolly <caleb.connolly@linaro.org>2023-12-11 18:41:41 +0000
committerTom Rini <trini@konsulko.com>2023-12-21 11:59:49 -0500
commit76c53dad6b5dc94e4c43069882b2708853c284c0 (patch)
treef9ef0304d6bd59d54ca9b49c735c269cfe6d8b7c /drivers
parente96ecbe71925f31ee43d353ceabe5b2c53df512f (diff)
downloadu-boot-76c53dad6b5dc94e4c43069882b2708853c284c0.zip
u-boot-76c53dad6b5dc94e4c43069882b2708853c284c0.tar.gz
u-boot-76c53dad6b5dc94e4c43069882b2708853c284c0.tar.bz2
iommu: add a connect op
Add an optional iommu callback to be invoked before a device probes. This can be used to configure the IOMMU in preparation for the device (e.g. by allocating a context bank) Signed-off-by: Caleb Connolly <caleb.connolly@linaro.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/iommu/iommu-uclass.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/drivers/iommu/iommu-uclass.c b/drivers/iommu/iommu-uclass.c
index 98731d5..6babc0e3 100644
--- a/drivers/iommu/iommu-uclass.c
+++ b/drivers/iommu/iommu-uclass.c
@@ -77,6 +77,7 @@ int dev_iommu_enable(struct udevice *dev)
{
struct ofnode_phandle_args args;
struct udevice *dev_iommu;
+ const struct iommu_ops *ops;
int i, count, ret = 0;
count = dev_count_phandle_with_args(dev, "iommus",
@@ -98,6 +99,16 @@ int dev_iommu_enable(struct udevice *dev)
return ret;
}
dev->iommu = dev_iommu;
+
+ if (dev->parent && dev->parent->iommu == dev_iommu)
+ continue;
+
+ ops = device_get_ops(dev->iommu);
+ if (ops && ops->connect) {
+ ret = ops->connect(dev);
+ if (ret)
+ return ret;
+ }
}
#if CONFIG_IS_ENABLED(PCI)