diff options
author | Andrew Scull <ascull@google.com> | 2022-04-21 16:11:15 +0000 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2022-05-03 18:33:29 -0400 |
commit | 0699a78c0c583691c44ffab0da061d3740d288b3 (patch) | |
tree | 79aa6f8023135bf54ab3c8a2d25ca3f545342f8e | |
parent | c763e1e023cc08e6ec5fefc2be3ae28d685c0e21 (diff) | |
download | u-boot-0699a78c0c583691c44ffab0da061d3740d288b3.tar.gz |
virtio: pci: Make use of dm_pci_map_bar()
The virtio PCI capabilities describe regions of memory that should be
mapped. Map those with dm_pci_map_bar() which will ensure they are valid
PCI regions.
Signed-off-by: Andrew Scull <ascull@google.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
-rw-r--r-- | drivers/virtio/virtio_pci_modern.c | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/drivers/virtio/virtio_pci_modern.c b/drivers/virtio/virtio_pci_modern.c index f1e64a34388..880a12cc283 100644 --- a/drivers/virtio/virtio_pci_modern.c +++ b/drivers/virtio/virtio_pci_modern.c @@ -459,19 +459,17 @@ static int virtio_pci_find_capability(struct udevice *udev, u8 cfg_type, static void __iomem *virtio_pci_map_capability(struct udevice *udev, const struct virtio_pci_cap *cap) { - ulong base; - void __iomem *p; - /* - * TODO: adding 64-bit BAR support - * - * Per spec, the BAR is permitted to be either 32-bit or 64-bit. - * For simplicity, only read the BAR address as 32-bit. + * Find the corresponding memory region that isn't system memory but is + * writable. */ - base = dm_pci_read_bar32(udev, cap->bar); - p = (void __iomem *)base + cap->offset; + unsigned long mask = + PCI_REGION_TYPE | PCI_REGION_SYS_MEMORY | PCI_REGION_RO; + unsigned long flags = PCI_REGION_MEM; + u8 *p = dm_pci_map_bar(udev, PCI_BASE_ADDRESS_0 + cap->bar, cap->offset, + cap->length, mask, flags); - return p; + return (void __iomem *)p; } static int virtio_pci_bind(struct udevice *udev) |