summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/device/pci_device.c6
-rw-r--r--src/include/device/pci_def.h7
2 files changed, 13 insertions, 0 deletions
diff --git a/src/device/pci_device.c b/src/device/pci_device.c
index f2e4d5d2c1..cf2f74f81a 100644
--- a/src/device/pci_device.c
+++ b/src/device/pci_device.c
@@ -211,6 +211,12 @@ struct resource *pci_get_resource(struct device *dev, unsigned long index)
resource->gran += 1;
}
resource->limit = limit = moving | (resource->size - 1);
+
+ if (pci_base_address_is_memory_space(attr)) {
+ /* Page-align to allow individual mapping of devices. */
+ if (resource->align < 12)
+ resource->align = 12;
+ }
}
/*
diff --git a/src/include/device/pci_def.h b/src/include/device/pci_def.h
index ef3427b4e7..04cf945527 100644
--- a/src/include/device/pci_def.h
+++ b/src/include/device/pci_def.h
@@ -78,6 +78,13 @@
#define PCI_BASE_ADDRESS_IO_ATTR_MASK 0x03
/* bit 1 is reserved if address_space = 1 */
+#ifndef __ROMCC__
+static inline int pci_base_address_is_memory_space(unsigned int attr)
+{
+ return (attr & PCI_BASE_ADDRESS_SPACE) == PCI_BASE_ADDRESS_SPACE_MEMORY;
+}
+#endif
+
/* Header type 0 (normal devices) */
#define PCI_CARDBUS_CIS 0x28
#define PCI_SUBSYSTEM_VENDOR_ID 0x2c