pci: Enable dm_pci_map_bar() for 64-bit BARs
PATCH v3 1/1 pci: Enable dm_pci_map_bar() for 64-bit BARs
Allow dm_pci_map_bar() usage on systems with CONFIG_SYS_PCI_64BIT.
Reviewed-by Philip Oberfichtner <[email protected]>
Reviewed-by Simon Glass <[email protected]>
Signed-off-by Moritz Fischer <[email protected]>
---
Changes from V2:
- Turned IS_ENABLED() into #if defined to allow
building on platforms that don't define
CONFIG_SYS_PCI_64BIT
Changes from V1:
- Reworded commit message / typo
--- drivers/pci/pci-uclass.c | 12 ++++++++++++ include/pci.h | 4 ++-- 2 files changed, 14 insertions(+), 2 deletions(-)
drivers/pci/pci-uclass.c +12 -0
@@ -1611,6 +1611,18 @@ void *dm_pci_map_bar(struct udevice *dev, int bar, size_t offset, size_t len,dm_pci_read_config32 (udev, bar, &bar_response); pci_bus_addr = (pci_addr_t)(bar_response & ~0xf ); +#if defined(CONFIG_SYS_PCI_64BIT ) +/* +* This assumes that dm_pciauto_setup_device() will allocate +* a 64-bit address if CONFIG_SYS_PCI_64BIT is enabled and +* the device advertises that it supports it. +*/ +if (bar_response &PCI_BASE_ADDRESS_MEM_TYPE_64 ) { +dm_pci_read_config32 (udev, bar +4 , &bar_response); + pci_bus_addr |= (pci_addr_t )bar_response <<32 ; + } +#endif /* CONFIG_SYS_PCI_64BIT */ +if (~((pci_addr_t )0 ) - pci_bus_addr < offset)return NULL ;
include/pci.h +2 -2
@@ -1350,8 +1350,8 @@ pci_addr_t dm_pci_phys_to_bus(struct udevice *dev, phys_addr_t addr, size_t len,* * Looks up a base address register and finds the physical memory address * that corresponds to it. -* Can be used for 32b BARs 0-5 on type 0 functions and for 32b BARs 0-1 on -* type 1 functions. +* Can be used for 32b/64b BARs 0-5 on type 0 functions and for 32b BARs 0-1 +* on type 1 functions. * Can also be used on type 0 functions that support Enhanced Allocation for * 32b/64b BARs. Note that duplicate BEI entries are not supported. *
Signature · 1 line
2.43.0.472.g3155946c3a-goog