|
@@ -16,7 +16,7 @@
|
|
|
#define CARDBUS_LATENCY_TIMER 176 /* secondary latency timer */
|
|
|
#define CARDBUS_RESERVE_BUSNR 3
|
|
|
|
|
|
-struct resource busn_resource = {
|
|
|
+static struct resource busn_resource = {
|
|
|
.name = "PCI busn",
|
|
|
.start = 0,
|
|
|
.end = 255,
|
|
@@ -518,7 +518,7 @@ static struct pci_host_bridge *pci_alloc_host_bridge(struct pci_bus *b)
|
|
|
return bridge;
|
|
|
}
|
|
|
|
|
|
-const unsigned char pcix_bus_speed[] = {
|
|
|
+static const unsigned char pcix_bus_speed[] = {
|
|
|
PCI_SPEED_UNKNOWN, /* 0 */
|
|
|
PCI_SPEED_66MHz_PCIX, /* 1 */
|
|
|
PCI_SPEED_100MHz_PCIX, /* 2 */
|
|
@@ -999,6 +999,60 @@ void set_pcie_hotplug_bridge(struct pci_dev *pdev)
|
|
|
pdev->is_hotplug_bridge = 1;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+/**
|
|
|
+ * pci_cfg_space_size - get the configuration space size of the PCI device.
|
|
|
+ * @dev: PCI device
|
|
|
+ *
|
|
|
+ * Regular PCI devices have 256 bytes, but PCI-X 2 and PCI Express devices
|
|
|
+ * have 4096 bytes. Even if the device is capable, that doesn't mean we can
|
|
|
+ * access it. Maybe we don't have a way to generate extended config space
|
|
|
+ * accesses, or the device is behind a reverse Express bridge. So we try
|
|
|
+ * reading the dword at 0x100 which must either be 0 or a valid extended
|
|
|
+ * capability header.
|
|
|
+ */
|
|
|
+static int pci_cfg_space_size_ext(struct pci_dev *dev)
|
|
|
+{
|
|
|
+ u32 status;
|
|
|
+ int pos = PCI_CFG_SPACE_SIZE;
|
|
|
+
|
|
|
+ if (pci_read_config_dword(dev, pos, &status) != PCIBIOS_SUCCESSFUL)
|
|
|
+ goto fail;
|
|
|
+ if (status == 0xffffffff)
|
|
|
+ goto fail;
|
|
|
+
|
|
|
+ return PCI_CFG_SPACE_EXP_SIZE;
|
|
|
+
|
|
|
+ fail:
|
|
|
+ return PCI_CFG_SPACE_SIZE;
|
|
|
+}
|
|
|
+
|
|
|
+int pci_cfg_space_size(struct pci_dev *dev)
|
|
|
+{
|
|
|
+ int pos;
|
|
|
+ u32 status;
|
|
|
+ u16 class;
|
|
|
+
|
|
|
+ class = dev->class >> 8;
|
|
|
+ if (class == PCI_CLASS_BRIDGE_HOST)
|
|
|
+ return pci_cfg_space_size_ext(dev);
|
|
|
+
|
|
|
+ if (!pci_is_pcie(dev)) {
|
|
|
+ pos = pci_find_capability(dev, PCI_CAP_ID_PCIX);
|
|
|
+ if (!pos)
|
|
|
+ goto fail;
|
|
|
+
|
|
|
+ pci_read_config_dword(dev, pos + PCI_X_STATUS, &status);
|
|
|
+ if (!(status & (PCI_X_STATUS_266MHZ | PCI_X_STATUS_533MHZ)))
|
|
|
+ goto fail;
|
|
|
+ }
|
|
|
+
|
|
|
+ return pci_cfg_space_size_ext(dev);
|
|
|
+
|
|
|
+ fail:
|
|
|
+ return PCI_CFG_SPACE_SIZE;
|
|
|
+}
|
|
|
+
|
|
|
#define LEGACY_IO_RESOURCE (IORESOURCE_IO | IORESOURCE_PCI_FIXED)
|
|
|
|
|
|
/**
|
|
@@ -1173,59 +1227,6 @@ static void pci_release_dev(struct device *dev)
|
|
|
kfree(pci_dev);
|
|
|
}
|
|
|
|
|
|
-/**
|
|
|
- * pci_cfg_space_size - get the configuration space size of the PCI device.
|
|
|
- * @dev: PCI device
|
|
|
- *
|
|
|
- * Regular PCI devices have 256 bytes, but PCI-X 2 and PCI Express devices
|
|
|
- * have 4096 bytes. Even if the device is capable, that doesn't mean we can
|
|
|
- * access it. Maybe we don't have a way to generate extended config space
|
|
|
- * accesses, or the device is behind a reverse Express bridge. So we try
|
|
|
- * reading the dword at 0x100 which must either be 0 or a valid extended
|
|
|
- * capability header.
|
|
|
- */
|
|
|
-int pci_cfg_space_size_ext(struct pci_dev *dev)
|
|
|
-{
|
|
|
- u32 status;
|
|
|
- int pos = PCI_CFG_SPACE_SIZE;
|
|
|
-
|
|
|
- if (pci_read_config_dword(dev, pos, &status) != PCIBIOS_SUCCESSFUL)
|
|
|
- goto fail;
|
|
|
- if (status == 0xffffffff)
|
|
|
- goto fail;
|
|
|
-
|
|
|
- return PCI_CFG_SPACE_EXP_SIZE;
|
|
|
-
|
|
|
- fail:
|
|
|
- return PCI_CFG_SPACE_SIZE;
|
|
|
-}
|
|
|
-
|
|
|
-int pci_cfg_space_size(struct pci_dev *dev)
|
|
|
-{
|
|
|
- int pos;
|
|
|
- u32 status;
|
|
|
- u16 class;
|
|
|
-
|
|
|
- class = dev->class >> 8;
|
|
|
- if (class == PCI_CLASS_BRIDGE_HOST)
|
|
|
- return pci_cfg_space_size_ext(dev);
|
|
|
-
|
|
|
- if (!pci_is_pcie(dev)) {
|
|
|
- pos = pci_find_capability(dev, PCI_CAP_ID_PCIX);
|
|
|
- if (!pos)
|
|
|
- goto fail;
|
|
|
-
|
|
|
- pci_read_config_dword(dev, pos + PCI_X_STATUS, &status);
|
|
|
- if (!(status & (PCI_X_STATUS_266MHZ | PCI_X_STATUS_533MHZ)))
|
|
|
- goto fail;
|
|
|
- }
|
|
|
-
|
|
|
- return pci_cfg_space_size_ext(dev);
|
|
|
-
|
|
|
- fail:
|
|
|
- return PCI_CFG_SPACE_SIZE;
|
|
|
-}
|
|
|
-
|
|
|
struct pci_dev *pci_alloc_dev(struct pci_bus *bus)
|
|
|
{
|
|
|
struct pci_dev *dev;
|