vserver 2.0 rc7
[linux-2.6.git] / arch / i386 / kernel / scx200.c
index d02df17..69e203a 100644 (file)
@@ -13,6 +13,9 @@
 
 #include <linux/scx200.h>
 
+/* Verify that the configuration block really is there */
+#define scx200_cb_probe(base) (inw((base) + SCx200_CBA) == (base))
+
 #define NAME "scx200"
 
 MODULE_AUTHOR("Christer Weinigel <wingel@nano-system.com>");
@@ -22,9 +25,13 @@ MODULE_LICENSE("GPL");
 unsigned scx200_gpio_base = 0;
 long scx200_gpio_shadow[2];
 
+unsigned scx200_cb_base = 0;
+
 static struct pci_device_id scx200_tbl[] = {
        { PCI_DEVICE(PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_SCx200_BRIDGE) },
        { PCI_DEVICE(PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_SC1100_BRIDGE) },
+       { PCI_DEVICE(PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_SCx200_XBUS)   },
+       { PCI_DEVICE(PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_SC1100_XBUS)   },
        { },
 };
 MODULE_DEVICE_TABLE(pci,scx200_tbl);
@@ -37,7 +44,6 @@ static struct pci_driver scx200_pci_driver = {
        .probe = scx200_probe,
 };
 
-DEFINE_SPINLOCK(scx200_gpio_lock);
 static DEFINE_SPINLOCK(scx200_gpio_config_lock);
 
 static int __devinit scx200_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
@@ -45,22 +51,39 @@ static int __devinit scx200_probe(struct pci_dev *pdev, const struct pci_device_
        int bank;
        unsigned base;
 
-       base = pci_resource_start(pdev, 0);
-       printk(KERN_INFO NAME ": GPIO base 0x%x\n", base);
-
-       if (request_region(base, SCx200_GPIO_SIZE, "NatSemi SCx200 GPIO") == 0) {
-               printk(KERN_ERR NAME ": can't allocate I/O for GPIOs\n");
-               return -EBUSY;
+       if (pdev->device == PCI_DEVICE_ID_NS_SCx200_BRIDGE ||
+           pdev->device == PCI_DEVICE_ID_NS_SC1100_BRIDGE) {
+               base = pci_resource_start(pdev, 0);
+               printk(KERN_INFO NAME ": GPIO base 0x%x\n", base);
+
+               if (request_region(base, SCx200_GPIO_SIZE, "NatSemi SCx200 GPIO") == 0) {
+                       printk(KERN_ERR NAME ": can't allocate I/O for GPIOs\n");
+                       return -EBUSY;
+               }
+
+               scx200_gpio_base = base;
+
+               /* read the current values driven on the GPIO signals */
+               for (bank = 0; bank < 2; ++bank)
+                       scx200_gpio_shadow[bank] = inl(scx200_gpio_base + 0x10 * bank);
+
+       } else {
+               /* find the base of the Configuration Block */
+               if (scx200_cb_probe(SCx200_CB_BASE_FIXED)) {
+                       scx200_cb_base = SCx200_CB_BASE_FIXED;
+               } else {
+                       pci_read_config_dword(pdev, SCx200_CBA_SCRATCH, &base);
+                       if (scx200_cb_probe(base)) {
+                               scx200_cb_base = base;
+                       } else {
+                               printk(KERN_WARNING NAME ": Configuration Block not found\n");
+                               return -ENODEV;
+                       }
+               }
+               printk(KERN_INFO NAME ": Configuration Block base 0x%x\n", scx200_cb_base);
        }
 
-       scx200_gpio_base = base;
-
-       /* read the current values driven on the GPIO signals */
-       for (bank = 0; bank < 2; ++bank)
-               scx200_gpio_shadow[bank] = inl(scx200_gpio_base + 0x10 * bank);
-
        return 0;
-
 }
 
 u32 scx200_gpio_configure(int index, u32 mask, u32 bits)
@@ -81,6 +104,7 @@ u32 scx200_gpio_configure(int index, u32 mask, u32 bits)
        return config;
 }
 
+#if 0
 void scx200_gpio_dump(unsigned index)
 {
        u32 config = scx200_gpio_configure(index, ~0, 0);
@@ -112,15 +136,16 @@ void scx200_gpio_dump(unsigned index)
                printk(" DEBOUNCE"); /* debounce */
        printk("\n");
 }
+#endif  /*  0  */
 
-int __init scx200_init(void)
+static int __init scx200_init(void)
 {
        printk(KERN_INFO NAME ": NatSemi SCx200 Driver\n");
 
        return pci_module_init(&scx200_pci_driver);
 }
 
-void __exit scx200_cleanup(void)
+static void __exit scx200_cleanup(void)
 {
        pci_unregister_driver(&scx200_pci_driver);
        release_region(scx200_gpio_base, SCx200_GPIO_SIZE);
@@ -131,9 +156,8 @@ module_exit(scx200_cleanup);
 
 EXPORT_SYMBOL(scx200_gpio_base);
 EXPORT_SYMBOL(scx200_gpio_shadow);
-EXPORT_SYMBOL(scx200_gpio_lock);
 EXPORT_SYMBOL(scx200_gpio_configure);
-EXPORT_SYMBOL(scx200_gpio_dump);
+EXPORT_SYMBOL(scx200_cb_base);
 
 /*
     Local variables: