diff options
author | Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com> | 2014-07-30 10:39:35 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2014-07-31 07:27:16 +0200 |
commit | b7ffe9ad0e926113f35b7780ceef4953cbaaf262 (patch) | |
tree | aff550597e60589b8a2fb2a14956216a5ef05f83 /drivers/pci/pci.c | |
parent | 7587a04434349dcae5c0ea024c65705b01c1a825 (diff) | |
download | barebox-b7ffe9ad0e926113f35b7780ceef4953cbaaf262.tar.gz barebox-b7ffe9ad0e926113f35b7780ceef4953cbaaf262.tar.xz |
pci: pci_scan_bus: respect 64b BARs
In PCI 64-bit BARs span two 32-bit BARs, therefore if BAR type
indicates a 64-bit BAR we have to skip the next BAR register.
While at it, also set proper IORESOURCE flags for I/O and
32b MEM.
Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
Acked-by: Lucas Stach <l.stach@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/pci/pci.c')
-rw-r--r-- | drivers/pci/pci.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 3d88b0ff5f..83d44fc103 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -211,19 +211,29 @@ unsigned int pci_scan_bus(struct pci_bus *bus) size = -(mask & 0xfffffffe); DBG(" PCI: pbar%d: mask=%08x io %d bytes\n", bar, mask, size); pci_write_config_dword(dev, PCI_BASE_ADDRESS_0 + bar * 4, last_io); + dev->resource[bar].flags = IORESOURCE_IO; last_addr = last_io; last_io += size; - } else { /* MEM */ size = -(mask & 0xfffffff0); DBG(" PCI: pbar%d: mask=%08x memory %d bytes\n", bar, mask, size); pci_write_config_dword(dev, PCI_BASE_ADDRESS_0 + bar * 4, last_mem); + dev->resource[bar].flags = IORESOURCE_MEM; last_addr = last_mem; last_mem += size; + + if ((mask & PCI_BASE_ADDRESS_MEM_TYPE_MASK) == + PCI_BASE_ADDRESS_MEM_TYPE_64) { + dev->resource[bar].flags |= IORESOURCE_MEM_64; + pci_write_config_dword(dev, + PCI_BASE_ADDRESS_1 + bar * 4, 0); + } } dev->resource[bar].start = last_addr; dev->resource[bar].end = last_addr + size - 1; + if (dev->resource[bar].flags & IORESOURCE_MEM_64) + bar++; } } |