mirror of
https://github.com/u-boot/u-boot.git
synced 2025-04-27 16:01:27 +00:00
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>
This commit is contained in:
parent
e96ecbe719
commit
76c53dad6b
2 changed files with 20 additions and 0 deletions
|
@ -77,6 +77,7 @@ int dev_iommu_enable(struct udevice *dev)
|
||||||
{
|
{
|
||||||
struct ofnode_phandle_args args;
|
struct ofnode_phandle_args args;
|
||||||
struct udevice *dev_iommu;
|
struct udevice *dev_iommu;
|
||||||
|
const struct iommu_ops *ops;
|
||||||
int i, count, ret = 0;
|
int i, count, ret = 0;
|
||||||
|
|
||||||
count = dev_count_phandle_with_args(dev, "iommus",
|
count = dev_count_phandle_with_args(dev, "iommus",
|
||||||
|
@ -98,6 +99,16 @@ int dev_iommu_enable(struct udevice *dev)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
dev->iommu = dev_iommu;
|
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)
|
#if CONFIG_IS_ENABLED(PCI)
|
||||||
|
|
|
@ -4,6 +4,15 @@
|
||||||
struct udevice;
|
struct udevice;
|
||||||
|
|
||||||
struct iommu_ops {
|
struct iommu_ops {
|
||||||
|
/**
|
||||||
|
* init() - Connect a device to it's IOMMU, called before probe()
|
||||||
|
* The iommu device can be fetched through dev->iommu
|
||||||
|
*
|
||||||
|
* @iommu_dev: IOMMU device
|
||||||
|
* @dev: Device to connect
|
||||||
|
* @return 0 if OK, -errno on error
|
||||||
|
*/
|
||||||
|
int (*connect)(struct udevice *dev);
|
||||||
/**
|
/**
|
||||||
* map() - map DMA memory
|
* map() - map DMA memory
|
||||||
*
|
*
|
||||||
|
|
Loading…
Add table
Reference in a new issue