Commit 67769a06 authored by Linus Torvalds's avatar Linus Torvalds

Merge bk://are.twiddle.net/pci-2.5

into home.transmeta.com:/home/torvalds/v2.5/linux
parents cc3cd601 2c79a80a
...@@ -36,11 +36,22 @@ static inline unsigned int pci_calc_resource_flags(unsigned int flags) ...@@ -36,11 +36,22 @@ static inline unsigned int pci_calc_resource_flags(unsigned int flags)
/* /*
* Find the extent of a PCI decode.. * Find the extent of a PCI decode..
*/ */
static u32 pci_size(u32 base, unsigned long mask) static u32 pci_size(u32 base, u32 maxbase, unsigned long mask)
{ {
u32 size = mask & base; /* Find the significant bits */ u32 size = mask & maxbase; /* Find the significant bits */
size = size & ~(size-1); /* Get the lowest of them to find the decode size */ if (!size)
return size-1; /* extent = size - 1 */ return 0;
/* Get the lowest of them to find the decode size, and
from that the extent. */
size = (size & ~(size-1)) - 1;
/* base == maxbase can be valid only if the BAR has
already been programmed with all 1s. */
if (base == maxbase && ((base | size) & mask) != mask)
return 0;
return size;
} }
static void pci_read_bases(struct pci_dev *dev, unsigned int howmany, int rom) static void pci_read_bases(struct pci_dev *dev, unsigned int howmany, int rom)
...@@ -63,13 +74,17 @@ static void pci_read_bases(struct pci_dev *dev, unsigned int howmany, int rom) ...@@ -63,13 +74,17 @@ static void pci_read_bases(struct pci_dev *dev, unsigned int howmany, int rom)
if (l == 0xffffffff) if (l == 0xffffffff)
l = 0; l = 0;
if ((l & PCI_BASE_ADDRESS_SPACE) == PCI_BASE_ADDRESS_SPACE_MEMORY) { if ((l & PCI_BASE_ADDRESS_SPACE) == PCI_BASE_ADDRESS_SPACE_MEMORY) {
sz = pci_size(l, sz, PCI_BASE_ADDRESS_MEM_MASK);
if (!sz)
continue;
res->start = l & PCI_BASE_ADDRESS_MEM_MASK; res->start = l & PCI_BASE_ADDRESS_MEM_MASK;
res->flags |= l & ~PCI_BASE_ADDRESS_MEM_MASK; res->flags |= l & ~PCI_BASE_ADDRESS_MEM_MASK;
sz = pci_size(sz, PCI_BASE_ADDRESS_MEM_MASK);
} else { } else {
sz = pci_size(l, sz, PCI_BASE_ADDRESS_IO_MASK & 0xffff);
if (!sz)
continue;
res->start = l & PCI_BASE_ADDRESS_IO_MASK; res->start = l & PCI_BASE_ADDRESS_IO_MASK;
res->flags |= l & ~PCI_BASE_ADDRESS_IO_MASK; res->flags |= l & ~PCI_BASE_ADDRESS_IO_MASK;
sz = pci_size(sz, PCI_BASE_ADDRESS_IO_MASK & 0xffff);
} }
res->end = res->start + (unsigned long) sz; res->end = res->start + (unsigned long) sz;
res->flags |= pci_calc_resource_flags(l); res->flags |= pci_calc_resource_flags(l);
...@@ -99,6 +114,7 @@ static void pci_read_bases(struct pci_dev *dev, unsigned int howmany, int rom) ...@@ -99,6 +114,7 @@ static void pci_read_bases(struct pci_dev *dev, unsigned int howmany, int rom)
if (rom) { if (rom) {
dev->rom_base_reg = rom; dev->rom_base_reg = rom;
res = &dev->resource[PCI_ROM_RESOURCE]; res = &dev->resource[PCI_ROM_RESOURCE];
res->name = dev->dev.name;
pci_read_config_dword(dev, rom, &l); pci_read_config_dword(dev, rom, &l);
pci_write_config_dword(dev, rom, ~PCI_ROM_ADDRESS_ENABLE); pci_write_config_dword(dev, rom, ~PCI_ROM_ADDRESS_ENABLE);
pci_read_config_dword(dev, rom, &sz); pci_read_config_dword(dev, rom, &sz);
...@@ -106,13 +122,15 @@ static void pci_read_bases(struct pci_dev *dev, unsigned int howmany, int rom) ...@@ -106,13 +122,15 @@ static void pci_read_bases(struct pci_dev *dev, unsigned int howmany, int rom)
if (l == 0xffffffff) if (l == 0xffffffff)
l = 0; l = 0;
if (sz && sz != 0xffffffff) { if (sz && sz != 0xffffffff) {
sz = pci_size(l, sz, PCI_ROM_ADDRESS_MASK);
if (sz) {
res->flags = (l & PCI_ROM_ADDRESS_ENABLE) | res->flags = (l & PCI_ROM_ADDRESS_ENABLE) |
IORESOURCE_MEM | IORESOURCE_PREFETCH | IORESOURCE_READONLY | IORESOURCE_CACHEABLE; IORESOURCE_MEM | IORESOURCE_PREFETCH |
IORESOURCE_READONLY | IORESOURCE_CACHEABLE;
res->start = l & PCI_ROM_ADDRESS_MASK; res->start = l & PCI_ROM_ADDRESS_MASK;
sz = pci_size(sz, PCI_ROM_ADDRESS_MASK);
res->end = res->start + (unsigned long) sz; res->end = res->start + (unsigned long) sz;
} }
res->name = dev->dev.name; }
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment