]> git.neil.brown.name Git - history.git/commitdiff
[PCI] pci-9: Kill per-architecture pcibios_update_resource()
authorRussell King <rmk@flint.arm.linux.org.uk>
Sun, 16 Mar 2003 22:17:24 +0000 (22:17 +0000)
committerRussell King <rmk@flint.arm.linux.org.uk>
Sun, 16 Mar 2003 22:17:24 +0000 (22:17 +0000)
Kill pcibios_update_resource(), replacing it with pci_update_resource().
pci_update_resource() uses pcibios_resource_to_bus() to convert a
resource to a device BAR - the transformation should be exactly the
same as the transformation used for the PCI bridges.

pci_update_resource "knows" about 64-bit BARs, but doesn't attempt to
set the high 32-bits to anything non-zero - currently no architecture
attempts to do something different.  If anyone cares, please fix; I'm
going to reflect current behaviour for the time being.

Ivan pointed out the following architectures need to examine their
pcibios_update_resource() implementation - they should make sure that
this new implementation does the right thing.  #warning's have been
added where appropriate.

ia64
mips
mips64

This cset also includes a fix for the problem reported by AKPM where
64-bit arch compilers complain about the resource mask being placed
in a u32.

25 files changed:
arch/alpha/kernel/pci.c
arch/arm/kernel/bios32.c
arch/i386/pci/i386.c
arch/ia64/pci/pci.c
arch/mips/ddb5074/pci.c
arch/mips/ddb5476/pci.c
arch/mips/ddb5xxx/common/pci.c
arch/mips/gt64120/common/pci.c
arch/mips/ite-boards/generic/it8172_pci.c
arch/mips/kernel/pci.c
arch/mips/mips-boards/generic/pci.c
arch/mips/sni/pci.c
arch/mips64/mips-boards/generic/pci.c
arch/mips64/sgi-ip27/ip27-pci.c
arch/mips64/sgi-ip32/ip32-pci.c
arch/parisc/kernel/pci.c
arch/ppc/kernel/pci.c
arch/ppc64/kernel/pci.c
arch/sh/kernel/pcibios.c
arch/sparc/kernel/pcic.c
arch/sparc64/kernel/pci.c
arch/v850/kernel/rte_mb_a_pci.c
arch/x86_64/pci/x86-64.c
drivers/pci/setup-res.c
include/linux/pci.h

index 10942ee451059dee370bd909b38b0363474c676d..b52bc3719803986798a3ab5549d3f321b871708e 100644 (file)
@@ -264,45 +264,6 @@ pcibios_fixup_bus(struct pci_bus *bus)
        }
 }
 
-void
-pcibios_update_resource(struct pci_dev *dev, struct resource *res,
-                       int resource)
-{
-       struct pci_controller *hose = dev->sysdata;
-       struct resource *root;
-       int where;
-       u32 reg;
-
-       if (resource < PCI_ROM_RESOURCE) 
-               where = PCI_BASE_ADDRESS_0 + (resource * 4);
-       else if (resource == PCI_ROM_RESOURCE)
-               where = dev->rom_base_reg;
-       else {
-               return; /* Don't update non-standard resources here. */
-       }
-
-       /* Point root at the hose root. */
-       if (res->flags & IORESOURCE_IO)
-               root = hose->io_space;
-       else if (res->flags & IORESOURCE_MEM)
-               root = hose->mem_space;
-       else {
-               return; /* Don't update non-standard resources here. */
-       }
-
-       reg = (res->start - root->start) | (res->flags & 0xf);
-       pci_write_config_dword(dev, where, reg);
-       if ((res->flags & (PCI_BASE_ADDRESS_SPACE
-                          | PCI_BASE_ADDRESS_MEM_TYPE_MASK))
-           == (PCI_BASE_ADDRESS_SPACE_MEMORY
-               | PCI_BASE_ADDRESS_MEM_TYPE_64)) {
-               pci_write_config_dword(dev, where+4, 0);
-               printk(KERN_WARNING "PCI: dev %s type 64-bit\n", dev->dev.name);
-       }
-
-       /* ??? FIXME -- record old value for shutdown.  */
-}
-
 void __init
 pcibios_update_irq(struct pci_dev *dev, int irq)
 {
index 090a29fee3e7a4cb243c5e137d3461c129c42866..265b3c183d5ac18db33705cd4fd75a5fd5842bca 100644 (file)
@@ -259,47 +259,6 @@ struct pci_fixup pcibios_fixups[] = {
        }, { 0 }
 };
 
-void __devinit
-pcibios_update_resource(struct pci_dev *dev, struct resource *res,
-                       int resource)
-{
-       struct pci_sys_data *sys = dev->sysdata;
-       u32 val, check;
-       int reg;
-
-       if (debug_pci)
-               printk("PCI: Assigning %3s %08lx to %s\n",
-                       res->flags & IORESOURCE_IO ? "IO" : "MEM",
-                       res->start, dev->dev.name);
-
-       if (resource < 6) {
-               reg = PCI_BASE_ADDRESS_0 + 4*resource;
-       } else if (resource == PCI_ROM_RESOURCE) {
-               reg = dev->rom_base_reg;
-       } else {
-               /* Somebody might have asked allocation of a
-                * non-standard resource.
-                */
-               return;
-       }
-
-       val = res->start;
-       if (res->flags & IORESOURCE_MEM)
-               val -= sys->mem_offset;
-       else
-               val -= sys->io_offset;
-       val |= res->flags & PCI_REGION_FLAG_MASK;
-
-       pci_write_config_dword(dev, reg, val);
-       pci_read_config_dword(dev, reg, &check);
-       if ((val ^ check) & ((val & PCI_BASE_ADDRESS_SPACE_IO) ?
-           PCI_BASE_ADDRESS_IO_MASK : PCI_BASE_ADDRESS_MEM_MASK)) {
-               printk(KERN_ERR "PCI: Error while updating region "
-                       "%s/%d (%08x != %08x)\n", dev->slot_name,
-                       resource, val, check);
-       }
-}
-
 void __devinit pcibios_update_irq(struct pci_dev *dev, int irq)
 {
        if (debug_pci)
index 36e5d4e30bbca0779fbdb6f7ae04196c1aaec1f3..b81cf06d9bead6761bf381c76027234b9331b452 100644 (file)
 
 #include "pci.h"
 
-void
-pcibios_update_resource(struct pci_dev *dev, struct resource *res,
-                       int resource)
-{
-       u32 new, check;
-       int reg;
-
-       new = res->start | (res->flags & PCI_REGION_FLAG_MASK);
-       if (resource < 6) {
-               reg = PCI_BASE_ADDRESS_0 + 4*resource;
-       } else if (resource == PCI_ROM_RESOURCE) {
-               res->flags |= PCI_ROM_ADDRESS_ENABLE;
-               new |= PCI_ROM_ADDRESS_ENABLE;
-               reg = dev->rom_base_reg;
-       } else {
-               /* Somebody might have asked allocation of a non-standard resource */
-               return;
-       }
-       
-       pci_write_config_dword(dev, reg, new);
-       pci_read_config_dword(dev, reg, &check);
-       if ((new ^ check) & ((new & PCI_BASE_ADDRESS_SPACE_IO) ? PCI_BASE_ADDRESS_IO_MASK : PCI_BASE_ADDRESS_MEM_MASK)) {
-               printk(KERN_ERR "PCI: Error while updating region "
-                      "%s/%d (%08x != %08x)\n", dev->slot_name, resource,
-                      new, check);
-       }
-}
-
 /*
  * We need to avoid collisions with `mirrored' VGA ports
  * and other strange ISA hardware, so we always want the
index 03fcd62072f5899ccf8a229bccb9573403f59a16..27757a02feda74ba93de2389c8a3432851023ccb 100644 (file)
@@ -143,22 +143,7 @@ pcibios_fixup_bus (struct pci_bus *b)
        return;
 }
 
-void __devinit
-pcibios_update_resource (struct pci_dev *dev, struct resource *res,
-                        int resource)
-{
-       unsigned long where, size;
-       u32 reg;
-
-       where = PCI_BASE_ADDRESS_0 + (resource * 4);
-       size = res->end - res->start;
-       pci_read_config_dword(dev, where, &reg);
-       /* FIXME - this doesn't work for PCI-PCI bridges. */
-       reg = (reg & size) | (((u32)(res->start - res->parent->start)) & ~size);
-       pci_write_config_dword(dev, where, reg);
-
-       /* ??? FIXME -- record old value for shutdown.  */
-}
+#warning pcibios_update_resource() is now a generic implementation - please check
 
 void __devinit
 pcibios_update_irq (struct pci_dev *dev, int irq)
index 6baf4bea33cf9296530c14d5a32b044dcdcb74e1..d57926842c6fb555f67e8fc0e8b46c1850e55969 100644 (file)
@@ -336,37 +336,6 @@ int pcibios_enable_device(struct pci_dev *dev)
        return pcibios_enable_resources(dev);
 }
 
-void pcibios_update_resource(struct pci_dev *dev, struct resource *res,
-                            int resource)
-{
-       u32 new, check;
-       int reg;
-
-       new = res->start | (res->flags & PCI_REGION_FLAG_MASK);
-       if (resource < 6) {
-               reg = PCI_BASE_ADDRESS_0 + 4 * resource;
-       } else if (resource == PCI_ROM_RESOURCE) {
-               res->flags |= PCI_ROM_ADDRESS_ENABLE;
-               reg = dev->rom_base_reg;
-       } else {
-               /*
-                * Somebody might have asked allocation of a non-standard
-                * resource
-                */
-               return;
-       }
-
-       pci_write_config_dword(dev, reg, new);
-       pci_read_config_dword(dev, reg, &check);
-       if ((new ^ check) &
-           ((new & PCI_BASE_ADDRESS_SPACE_IO) ? PCI_BASE_ADDRESS_IO_MASK :
-            PCI_BASE_ADDRESS_MEM_MASK)) {
-               printk(KERN_ERR "PCI: Error while updating region "
-                      "%s/%d (%08x != %08x)\n", dev->slot_name, resource,
-                      new, check);
-       }
-}
-
 void pcibios_align_resource(void *data, struct resource *res,
                            unsigned long size, unsigned long align)
 {
index 08f4a867c03f9b0fc6a5df816d61733b49f77b19..6290eff027935a46147d243117b6e6c2e9f34a5b 100644 (file)
@@ -400,37 +400,6 @@ int pcibios_enable_device(struct pci_dev *dev)
        return pcibios_enable_resources(dev);
 }
 
-void pcibios_update_resource(struct pci_dev *dev, struct resource *res,
-                            int resource)
-{
-       u32 new, check;
-       int reg;
-
-       new = res->start | (res->flags & PCI_REGION_FLAG_MASK);
-       if (resource < 6) {
-               reg = PCI_BASE_ADDRESS_0 + 4 * resource;
-       } else if (resource == PCI_ROM_RESOURCE) {
-               res->flags |= PCI_ROM_ADDRESS_ENABLE;
-               reg = dev->rom_base_reg;
-       } else {
-               /*
-                * Somebody might have asked allocation of a non-standard
-                * resource
-                */
-               return;
-       }
-
-       pci_write_config_dword(dev, reg, new);
-       pci_read_config_dword(dev, reg, &check);
-       if ((new ^ check) &
-           ((new & PCI_BASE_ADDRESS_SPACE_IO) ? PCI_BASE_ADDRESS_IO_MASK :
-            PCI_BASE_ADDRESS_MEM_MASK)) {
-               printk(KERN_ERR "PCI: Error while updating region "
-                      "%s/%d (%08x != %08x)\n", dev->slot_name, resource,
-                      new, check);
-       }
-}
-
 void pcibios_align_resource(void *data, struct resource *res,
                            unsigned long size, unsigned long align)
 {
index c6a453cff05131f965b7288a8b320731d63a9e45..4c8457fbbbd111c33a5b6cbd91a5aca8964fea39 100644 (file)
@@ -170,11 +170,3 @@ pcibios_align_resource(void *data, struct resource *res,
        /* this should not be called */
        MIPS_ASSERT(1 == 0);
 }
-
-void
-pcibios_update_resource(struct pci_dev *dev, struct resource *res,
-                       int resource)
-{
-       /* this should not be called */
-       MIPS_ASSERT(1 == 0);
-}
index 15517ff37104a0a2a808fdc56683d4f5d7be5bf1..8350b9dad0b1af0a65b099f02d276b9fd56b76b0 100644 (file)
@@ -785,39 +785,6 @@ int pcibios_enable_device(struct pci_dev *dev)
        return pcibios_enable_resources(dev);
 }
 
-void pcibios_update_resource(struct pci_dev *dev, struct resource *res,
-                            int resource)
-{
-       u32 new, check;
-       int reg;
-
-       return;
-
-       new = res->start | (res->flags & PCI_REGION_FLAG_MASK);
-       if (resource < 6) {
-               reg = PCI_BASE_ADDRESS_0 + 4 * resource;
-       } else if (resource == PCI_ROM_RESOURCE) {
-               res->flags |= PCI_ROM_ADDRESS_ENABLE;
-               reg = dev->rom_base_reg;
-       } else {
-               /*
-                * Somebody might have asked allocation of a non-standard
-                * resource
-                */
-               return;
-       }
-
-       pci_write_config_dword(dev, reg, new);
-       pci_read_config_dword(dev, reg, &check);
-       if ((new ^ check) &
-           ((new & PCI_BASE_ADDRESS_SPACE_IO) ? PCI_BASE_ADDRESS_IO_MASK :
-            PCI_BASE_ADDRESS_MEM_MASK)) {
-               printk(KERN_ERR "PCI: Error while updating region "
-                      "%s/%d (%08x != %08x)\n", dev->slot_name, resource,
-                      new, check);
-       }
-}
-
 void pcibios_align_resource(void *data, struct resource *res,
                            unsigned long size, unsigned long align)
 {
index 7a9a942ca7dfddc96e852d78c1aefc68b0313226..6073dfcb36b8efdec3060b05ba3262ff5539058a 100644 (file)
@@ -196,20 +196,7 @@ pcibios_setup(char *str)
        return str;
 }
 
-void __init
-pcibios_update_resource(struct pci_dev *dev, struct resource *res,
-                       int resource)
-{
-       unsigned long where, size;
-       u32 reg;
-
-       where = PCI_BASE_ADDRESS_0 + (resource * 4);
-       size = res->end - res->start;
-       pci_read_config_dword(dev, where, &reg);
-       /* FIXME - this doesn't work for PCI-PCI bridges. */
-       reg = (reg & size) | (((u32)(res->start - res->parent->start)) & ~size);
-       pci_write_config_dword(dev, where, reg);
-}
+#warning pcibios_update_resource() is now a generic implementation - please check
 
 void __init pcibios_fixup_bus(struct pci_bus *b)
 {
index d6daceee99babfe9076eba259bc2315a8491bf31..b7b72fd1a267de01bfae1e92b229cc4d6a96970a 100644 (file)
@@ -166,10 +166,3 @@ pcibios_align_resource(void *data, struct resource *res,
 {
        /* this should not be called */
 }
-
-void
-pcibios_update_resource(struct pci_dev *dev, struct resource *res,
-                       int resource)
-{
-       /* this should not be called */
-}
index 36e90a299322002a2771757b91e8fafc308441b5..2faf1bc5376c7d7e53fbd2dc23a2a646dedaa7c8 100644 (file)
@@ -248,20 +248,7 @@ struct pci_fixup pcibios_fixups[] = {
        { 0 }
 };
 
-void __init
-pcibios_update_resource(struct pci_dev *dev, struct resource *res,
-                       int resource)
-{
-       unsigned long where, size;
-       u32 reg;
-
-       where = PCI_BASE_ADDRESS_0 + (resource * 4);
-       size = res->end - res->start;
-       pci_read_config_dword(dev, where, &reg);
-       /* FIXME - this doesn't work for PCI-PCI bridges. */
-       reg = (reg & size) | (((u32)(res->start - res->parent->start)) & ~size);
-       pci_write_config_dword(dev, where, reg);
-}
+#warning pcibios_update_resource() is now a generic implementation - please check
 
 /*
  *  Called after each bus is probed, but before its children
index 26d0b20a7525cbbaa11af2cabc77bbbc4d6e3518..8bdc9324559d4bb8e4e5b0b7a73fab85487ba83f 100644 (file)
@@ -137,34 +137,6 @@ pcibios_fixup_bus(struct pci_bus *b)
 {
 }
 
-void
-pcibios_update_resource(struct pci_dev *dev, struct resource *res,
-                       int resource)
-{
-       u32 new, check;
-       int reg;
-
-       new = res->start | (res->flags & PCI_REGION_FLAG_MASK);
-       if (resource < 6) {
-               reg = PCI_BASE_ADDRESS_0 + 4*resource;
-       } else if (resource == PCI_ROM_RESOURCE) {
-               res->flags |= PCI_ROM_ADDRESS_ENABLE;
-               new |= PCI_ROM_ADDRESS_ENABLE;
-               reg = dev->rom_base_reg;
-       } else {
-               /* Somebody might have asked allocation of a non-standard resource */
-               return;
-       }
-       
-       pci_write_config_dword(dev, reg, new);
-       pci_read_config_dword(dev, reg, &check);
-       if ((new ^ check) & ((new & PCI_BASE_ADDRESS_SPACE_IO) ? PCI_BASE_ADDRESS_IO_MASK : PCI_BASE_ADDRESS_MEM_MASK)) {
-               printk(KERN_ERR "PCI: Error while updating region "
-                      "%s/%d (%08x != %08x)\n", dev->slot_name, resource,
-                      new, check);
-       }
-}
-
 void __init pcibios_init(void)
 {
        struct pci_ops *ops = &sni_pci_ops;
index a0f42b33a1756b9d0abffc8d0c8d18c0e48d2c54..93ffe1ff3f7fcf5eb9c4a7f887cdc905921b9e91 100644 (file)
@@ -307,20 +307,7 @@ struct pci_fixup pcibios_fixups[] = {
        { 0 }
 };
 
-void __init
-pcibios_update_resource(struct pci_dev *dev, struct resource *res,
-                       int resource)
-{
-       unsigned long where, size;
-       u32 reg;
-
-       where = PCI_BASE_ADDRESS_0 + (resource * 4);
-       size = res->end - res->start;
-       pci_read_config_dword(dev, where, &reg);
-       /* FIXME - this doesn't work for PCI-PCI bridges. */
-       reg = (reg & size) | (((u32)(res->start - res->parent->start)) & ~size);
-       pci_write_config_dword(dev, where, reg);
-}
+#warning pcibios_update_resource() is now a generic implementation - please check
 
 unsigned __init int pcibios_assign_all_busses(void)
 {
index 328fe39a12a18d3623258765b8f5fb164a85ab6a..55f0234e87e068cb5aa4415f970b0f0bf0066bdc 100644 (file)
@@ -214,20 +214,7 @@ pcibios_update_irq(struct pci_dev *dev, int irq)
        pci_write_config_byte(dev, PCI_INTERRUPT_LINE, irq);
 }
 
-void __init
-pcibios_update_resource(struct pci_dev *dev, struct resource *res,
-                       int resource)
-{
-       unsigned long where, size;
-       u32 reg;
-
-       where = PCI_BASE_ADDRESS_0 + (resource * 4);
-       size = res->end - res->start;
-       pci_read_config_dword(dev, where, &reg);
-       /* FIXME - this doesn't work for PCI-PCI bridges. */
-       reg = (reg & size) | (((u32)(res->start - res->parent->start)) & ~size);
-       pci_write_config_dword(dev, where, reg);
-}
+#warning pcibios_update_resource() is now a generic implementation - please check
 
 void __init
 pcibios_fixup_bus(struct pci_bus *b)
index 2aa4aeccdd742139dc6f16c42a2b3b032a850edf..d4af201dc9757223a8fe0d1f8de1e14146be2770 100644 (file)
@@ -333,11 +333,6 @@ void __init pcibios_align_resource (void *data, struct resource *res,
 {
 }
 
-void __init pcibios_update_resource (struct pci_dev *dev, struct resource *res,
-                                    int resource)
-{
-}
-
 void __init pcibios_update_irq (struct pci_dev *dev, int irq)
 {
        pci_write_config_byte (dev, PCI_INTERRUPT_LINE, irq);
index 67bf315c62e12f31aaebb200b62a55edf135d6e3..257b8f2b9a54462a973194c94cb4566900baf9d2 100644 (file)
@@ -192,73 +192,6 @@ void __devinit pcibios_update_irq(struct pci_dev *dev, int irq)
 }
 
 
-/* ------------------------------------
-**
-** Program one BAR in PCI config space.
-**
-** ------------------------------------
-** PAT PDC systems need this routine. PA legacy PDC does not.
-**
-** When BAR's are configured by linux, this routine will update
-** configuration space with the "normalized" address. "root" indicates
-** where the range starts and res is some portion of that range.
-**
-** VCLASS: For all PA-RISC systems except V-class, root->start would be zero.
-**
-** PAT PDC can tell us which MMIO ranges are available or already in use.
-** I/O port space and such are not memory mapped anyway for PA-Risc.
-*/
-void __devinit
-pcibios_update_resource(
-       struct pci_dev *dev,
-       struct resource *res,
-       int barnum
-       )
-{
-       int where;
-       u32 barval = 0;
-
-       DBG_RES("pcibios_update_resource(%s, ..., %d) [%lx,%lx]/%x\n",
-               dev->slot_name,
-               barnum, res->start, res->end, (int) res->flags);
-
-       if (barnum >= PCI_BRIDGE_RESOURCES) {
-               /* handled in PCI-PCI bridge specific support */
-               return;
-       }
-
-       if (barnum == PCI_ROM_RESOURCE) {
-               where = PCI_ROM_ADDRESS;
-       } else {
-               /* 0-5  standard PCI "regions" */
-               where = PCI_BASE_ADDRESS_0 + (barnum * 4);
-       }
-
-       if (res->flags & IORESOURCE_IO) {
-               barval = PCI_PORT_ADDR(res->start);
-       } else if (res->flags & IORESOURCE_MEM) {
-               barval = PCI_BUS_ADDR(HBA_DATA(dev->bus->dev->platform_data), res->start);
-       } else {
-               panic("pcibios_update_resource() WTF? flags not IO or MEM");
-       }
-
-       pci_write_config_dword(dev, where, barval);
-
-/* XXX FIXME - Elroy does support 64-bit (dual cycle) addressing.
-** But at least one device (Symbios 53c896) which has 64-bit BAR
-** doesn't actually work right with dual cycle addresses.
-** So ignore the whole mess for now.
-*/
-
-       if ((res->flags & (PCI_BASE_ADDRESS_SPACE
-                          | PCI_BASE_ADDRESS_MEM_TYPE_MASK))
-           == (PCI_BASE_ADDRESS_SPACE_MEMORY
-               | PCI_BASE_ADDRESS_MEM_TYPE_64)) {
-               pci_write_config_dword(dev, where+4, 0);
-               DBGC("PCIBIOS: dev %s type 64-bit\n", dev->name);
-       }
-}
-
 /*
 ** Called by pci_set_master() - a driver interface.
 **
index d35111a4bf3800f11042f9b81b8a09ca97998767..c9b0d0490058bd04c797fbce292bbe186c7a7476 100644 (file)
@@ -93,46 +93,6 @@ fixup_broken_pcnet32(struct pci_dev* dev)
        }
 }
 
-void
-pcibios_update_resource(struct pci_dev *dev, struct resource *res,
-                       int resource)
-{
-       u32 new, check;
-       int reg;
-       struct pci_controller* hose = dev->sysdata;
-       unsigned long io_offset;
-       
-       new = res->start;
-       res->flags &= ~IORESOURCE_UNSET;
-       if (hose && res->flags & IORESOURCE_IO) {
-               io_offset = (unsigned long)hose->io_base_virt - isa_io_base;
-               new -= io_offset;
-       }
-       if (hose && res->flags & IORESOURCE_MEM)
-               new -= hose->pci_mem_offset;
-       new |= (res->flags & PCI_REGION_FLAG_MASK);
-       if (resource < 6) {
-               reg = PCI_BASE_ADDRESS_0 + 4*resource;
-       } else if (resource == PCI_ROM_RESOURCE) {
-               res->flags |= PCI_ROM_ADDRESS_ENABLE;
-               reg = dev->rom_base_reg;
-       } else {
-               /* Somebody might have asked allocation of a non-standard resource */
-               return;
-       }
-
-       pci_write_config_dword(dev, reg, new);
-       pci_read_config_dword(dev, reg, &check);
-       if ((new ^ check) & ((new & PCI_BASE_ADDRESS_SPACE_IO) ? PCI_BASE_ADDRESS_IO_MASK : PCI_BASE_ADDRESS_MEM_MASK)) {
-               printk(KERN_ERR "PCI: Error while updating region "
-                      "%s/%d (%08x != %08x)\n", dev->slot_name, resource,
-                      new, check);
-       }
-       printk(KERN_INFO "PCI: moved device %s resource %d (%lx) to %x\n",
-              dev->slot_name, resource, res->flags,
-              new & ~PCI_REGION_FLAG_MASK);
-}
-
 static void
 pcibios_fixup_resources(struct pci_dev *dev)
 {
index 7edf23857c245d9532792b960aee7d3b707e7ac1..ba9a6feaeb5066923e68beb009707074de4072a3 100644 (file)
@@ -127,37 +127,6 @@ struct pci_dev *pci_find_dev_by_addr(unsigned long addr)
        return NULL;
 }
 
-void
-pcibios_update_resource(struct pci_dev *dev, struct resource *res,
-                       int resource)
-{
-       u32 new, check;
-       int reg;
-       struct pci_controller* hose = PCI_GET_PHB_PTR(dev);
-       
-       new = res->start;
-       if (hose && res->flags & IORESOURCE_MEM)
-               new -= hose->pci_mem_offset;
-       new |= (res->flags & PCI_REGION_FLAG_MASK);
-       if (resource < 6) {
-               reg = PCI_BASE_ADDRESS_0 + 4*resource;
-       } else if (resource == PCI_ROM_RESOURCE) {
-               res->flags |= PCI_ROM_ADDRESS_ENABLE;
-               reg = dev->rom_base_reg;
-       } else {
-               /* Somebody might have asked allocation of a non-standard resource */
-               return;
-       }
-
-       pci_write_config_dword(dev, reg, new);
-       pci_read_config_dword(dev, reg, &check);
-       if ((new ^ check) & ((new & PCI_BASE_ADDRESS_SPACE_IO) ? PCI_BASE_ADDRESS_IO_MASK : PCI_BASE_ADDRESS_MEM_MASK)) {
-               printk(KERN_ERR "PCI: Error while updating region "
-                      "%s/%d (%08x != %08x)\n", dev->slot_name, resource,
-                      new, check);
-       }
-}
-
 static void
 pcibios_fixup_resources(struct pci_dev* dev)
 {
index 6b785b914ab4831de0140b6d731f3fd5cd3173ec..f9bb8ce67b94537f47b997af1a163ffd9fa846e2 100644 (file)
@@ -6,7 +6,6 @@
  * This is GPL'd.
  *
  * Provided here are generic versions of:
- *     pcibios_update_resource()
  *     pcibios_align_resource()
  *     pcibios_enable_device()
  *     pcibios_set_master()
 #include <linux/pci.h>
 #include <linux/init.h>
 
-void
-pcibios_update_resource(struct pci_dev *dev, struct resource *res,
-                       int resource)
-{
-       u32 new, check;
-       int reg;
-
-       new = res->start | (res->flags & PCI_REGION_FLAG_MASK);
-       if (resource < 6) {
-               reg = PCI_BASE_ADDRESS_0 + 4*resource;
-       } else if (resource == PCI_ROM_RESOURCE) {
-               res->flags |= PCI_ROM_ADDRESS_ENABLE;
-               new |= PCI_ROM_ADDRESS_ENABLE;
-               reg = dev->rom_base_reg;
-       } else {
-               /* Somebody might have asked allocation of a non-standard resource */
-               return;
-       }
-       
-       pci_write_config_dword(dev, reg, new);
-       pci_read_config_dword(dev, reg, &check);
-       if ((new ^ check) & ((new & PCI_BASE_ADDRESS_SPACE_IO) ? PCI_BASE_ADDRESS_IO_MASK : PCI_BASE_ADDRESS_MEM_MASK)) {
-               printk(KERN_ERR "PCI: Error while updating region "
-                      "%s/%d (%08x != %08x)\n", dev->slot_name, resource,
-                      new, check);
-       }
-}
-
 /*
  * We need to avoid collisions with `mirrored' VGA ports
  * and other strange ISA hardware, so we always want the
index 9c1ebf20487c5ceadd6e3a2f97b900c4db78775d..b6e83af5d8a9ec2ac02d971406dde838003ad5cd 100644 (file)
@@ -854,13 +854,6 @@ char * __init pcibios_setup(char *str)
        return str;
 }
 
-/*
- */
-void pcibios_update_resource(struct pci_dev *pdev, struct resource *res,
-                            int index)
-{
-}
-
 void pcibios_align_resource(void *data, struct resource *res,
                            unsigned long size, unsigned long align)
 {
index 86288ba4e3c2d4337ab78f3d840a1744419c9ea7..917614a36c23911517f52469bb5d2589fc052a4b 100644 (file)
@@ -470,20 +470,10 @@ int pci_assign_resource(struct pci_dev *pdev, int resource)
        return err;
 }
 
-void pcibios_update_resource(struct pci_dev *pdev, struct resource *res,
-                            int index)
-{
-}
-
 void pcibios_update_irq(struct pci_dev *pdev, int irq)
 {
 }
 
-void __devinit pcibios_fixup_pbus_ranges(struct pci_bus *pbus,
-                                        struct pbus_set_ranges_data *pranges)
-{
-}
-
 void pcibios_align_resource(void *data, struct resource *res,
                            unsigned long size, unsigned long align)
 {
index 56acfce6b449d40cfd046b97591edee867319522..8e7c094292f48c321bc2730f5d5e785245425032 100644 (file)
@@ -287,43 +287,20 @@ void __devinit pcibios_update_irq (struct pci_dev *dev, int irq)
        pci_write_config_byte (dev, PCI_INTERRUPT_LINE, irq);
 }
 
-void __nomods_init
-pcibios_update_resource (struct pci_dev *dev, struct resource *r, int resource)
+void __devinit
+pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region,
+                       struct resource *res)
 {
-       u32 new, check;
-       int reg;
-
-       if (r->flags & IORESOURCE_IO)
-               new = (((r->start - MB_A_PCI_IO_ADDR)
-                       & PCI_BASE_ADDRESS_IO_MASK)
-                      | PCI_BASE_ADDRESS_SPACE_IO);
-       else if (r->flags & IORESOURCE_MEM)
-               new = (((r->start - MB_A_PCI_MEM_ADDR)
-                       & PCI_BASE_ADDRESS_MEM_MASK)
-                      | PCI_BASE_ADDRESS_MEM_TYPE_32
-                      | ((r->flags & IORESOURCE_PREFETCH)
-                         ? PCI_BASE_ADDRESS_MEM_PREFETCH
-                         : 0)
-                      | PCI_BASE_ADDRESS_SPACE_MEMORY);
-       else
-               panic ("pcibios_update_resource: unknown resource type");
-
-       if (resource < 6)
-               reg = PCI_BASE_ADDRESS_0 + 4*resource;
-       else if (resource == PCI_ROM_RESOURCE) {
-               r->flags |= PCI_ROM_ADDRESS_ENABLE;
-               new |= PCI_ROM_ADDRESS_ENABLE;
-               reg = dev->rom_base_reg;
-       } else
-               return;
-       
-       pci_write_config_dword(dev, reg, new);
-       pci_read_config_dword(dev, reg, &check);
-       if ((new ^ check) & ((new & PCI_BASE_ADDRESS_SPACE_IO) ? PCI_BASE_ADDRESS_IO_MASK : PCI_BASE_ADDRESS_MEM_MASK)) {
-               printk (KERN_ERR "PCI: Error while updating region "
-                       "%s/%d (%08x != %08x)\n", dev->slot_name, resource,
-                       new, check);
+       unsigned long offset = 0;
+
+       if (res->flags & IORESOURCE_IO) {
+               offset = MB_A_PCI_IO_ADDR;
+       } else if (res->flags & IORESOURCE_MEM) {
+               offset = MB_A_PCI_MEM_ADDR;
        }
+
+       region->start = res->start - offset;
+       region->end = res->end - offset;
 }
 
 \f
index f9ee1dd440613040106d1afbc043cfee1084627e..ba5a9f09adac9ddf0d216f325929385b78d94a0c 100644 (file)
 
 #include "pci.h"
 
-void
-pcibios_update_resource(struct pci_dev *dev, struct resource *res,
-                       int resource)
-{
-       u32 new, check;
-       int reg;
-
-       new = res->start | (res->flags & PCI_REGION_FLAG_MASK);
-       if (resource < 6) {
-               reg = PCI_BASE_ADDRESS_0 + 4*resource;
-       } else if (resource == PCI_ROM_RESOURCE) {
-               res->flags |= PCI_ROM_ADDRESS_ENABLE;
-               new |= PCI_ROM_ADDRESS_ENABLE;
-               reg = dev->rom_base_reg;
-       } else {
-               /* Somebody might have asked allocation of a non-standard resource */
-               return;
-       }
-       
-       pci_write_config_dword(dev, reg, new);
-       pci_read_config_dword(dev, reg, &check);
-       if ((new ^ check) & ((new & PCI_BASE_ADDRESS_SPACE_IO) ? PCI_BASE_ADDRESS_IO_MASK : PCI_BASE_ADDRESS_MEM_MASK)) {
-               printk(KERN_ERR "PCI: Error while updating region "
-                      "%s/%d (%08x != %08x)\n", dev->slot_name, resource,
-                      new, check);
-       }
-}
-
 /*
  * We need to avoid collisions with `mirrored' VGA ports
  * and other strange ISA hardware, so we always want the
index be89db151d9091be5bff3f3e71fcc9a229956886..4989b88b45d38e279908a1a49aa692a5c7ebbc29 100644 (file)
 #endif
 
 
+static void
+pci_update_resource(struct pci_dev *dev, struct resource *res, int resno)
+{
+       struct pci_bus_region region;
+       u32 new, check, mask;
+       int reg;
+
+       pcibios_resource_to_bus(dev, &region, res);
+
+       DBGC((KERN_ERR "  got res [%lx:%lx] bus [%lx:%lx] for "
+             "resource %d of %s\n", res->start, res->end,
+             region.start, region.end, resno, dev->dev.name));
+
+       new = region.start | (res->flags & PCI_REGION_FLAG_MASK);
+       if (res->flags & IORESOURCE_IO)
+               mask = (u32)PCI_BASE_ADDRESS_IO_MASK;
+       else
+               mask = (u32)PCI_BASE_ADDRESS_MEM_MASK;
+
+       if (resno < 6) {
+               reg = PCI_BASE_ADDRESS_0 + 4 * resno;
+       } else if (resno == PCI_ROM_RESOURCE) {
+               new |= res->flags & PCI_ROM_ADDRESS_ENABLE;
+               reg = dev->rom_base_reg;
+       } else {
+               /* Hmm, non-standard resource. */
+               printk("PCI: trying to set non-standard region %s/%d\n",
+                      dev->slot_name, resno);
+               return;
+       }
+
+       pci_write_config_dword(dev, reg, new);
+       pci_read_config_dword(dev, reg, &check);
+
+       if ((new ^ check) & mask) {
+               printk(KERN_ERR "PCI: Error while updating region "
+                      "%s/%d (%08x != %08x)\n", dev->slot_name, resno,
+                      new, check);
+       }
+
+       if ((new & (PCI_BASE_ADDRESS_SPACE|PCI_BASE_ADDRESS_MEM_TYPE_MASK)) ==
+           (PCI_BASE_ADDRESS_SPACE_MEMORY|PCI_BASE_ADDRESS_MEM_TYPE_64)) {
+               new = 0; /* currently everyone zeros the high address */
+               pci_write_config_dword(dev, reg + 4, new);
+               pci_read_config_dword(dev, reg + 4, &check);
+               if (check != new) {
+                       printk(KERN_ERR "PCI: Error updating region "
+                              "%s/%d (high %08x != %08x)\n",
+                              dev->slot_name, resno, new, check);
+               }
+       }
+}
+
 int __init
 pci_claim_resource(struct pci_dev *dev, int resource)
 {
@@ -89,10 +142,7 @@ int pci_assign_resource(struct pci_dev *dev, int resno)
                printk(KERN_ERR "PCI: Failed to allocate resource %d(%lx-%lx) for %s\n",
                       resno, res->start, res->end, dev->slot_name);
        } else {
-               DBGC((KERN_ERR "  got res[%lx:%lx] for resource %d of %s\n",
-                     res->start, res->end, resno, dev->dev.name));
-               /* Update PCI config space.  */
-               pcibios_update_resource(dev, res, resno);
+               pci_update_resource(dev, res, resno);
        }
 
        return ret;
index b01ae2e4df9cbd50ac5c4659988445c2c9b3ae2d..f87c44ae0689eb84a629f9c903585d80677459fc 100644 (file)
@@ -529,7 +529,6 @@ char *pcibios_setup (char *str);
 /* Used only when drivers/pci/setup.c is used */
 void pcibios_align_resource(void *, struct resource *,
                            unsigned long, unsigned long);
-void pcibios_update_resource(struct pci_dev *, struct resource *, int);
 void pcibios_update_irq(struct pci_dev *, int irq);
 
 /* Generic PCI functions used internally */