[PATCH] chardev: GPIO for SCx200 & PC-8736x: migrate gpio_dump to common module
[firefly-linux-kernel-4.4.55.git] / arch / i386 / kernel / scx200.c
index 69e203a0d330ea8de05182f38bb53e5681fabfcb..edead73ebef2b0300f8ff26e68c61d597d8cd455 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/pci.h>
 
 #include <linux/scx200.h>
+#include <linux/scx200_gpio.h>
 
 /* Verify that the configuration block really is there */
 #define scx200_cb_probe(base) (inw((base) + SCx200_CBA) == (base))
@@ -46,9 +47,17 @@ static struct pci_driver scx200_pci_driver = {
 
 static DEFINE_SPINLOCK(scx200_gpio_config_lock);
 
-static int __devinit scx200_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
+static void __devinit scx200_init_shadow(void)
 {
        int bank;
+
+       /* 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);
+}
+
+static int __devinit scx200_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
+{
        unsigned base;
 
        if (pdev->device == PCI_DEVICE_ID_NS_SCx200_BRIDGE ||
@@ -62,10 +71,7 @@ static int __devinit scx200_probe(struct pci_dev *pdev, const struct pci_device_
                }
 
                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);
+               scx200_init_shadow();
 
        } else {
                /* find the base of the Configuration Block */
@@ -86,7 +92,7 @@ static int __devinit scx200_probe(struct pci_dev *pdev, const struct pci_device_
        return 0;
 }
 
-u32 scx200_gpio_configure(int index, u32 mask, u32 bits)
+u32 scx200_gpio_configure(unsigned index, u32 mask, u32 bits)
 {
        u32 config, new_config;
        unsigned long flags;
@@ -104,45 +110,11 @@ 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);
-       printk(KERN_DEBUG "GPIO%02u: 0x%08lx", index, (unsigned long)config);
-       
-       if (config & 1) 
-               printk(" OE"); /* output enabled */
-       else
-               printk(" TS"); /* tristate */
-       if (config & 2) 
-               printk(" PP"); /* push pull */
-       else
-               printk(" OD"); /* open drain */
-       if (config & 4) 
-               printk(" PUE"); /* pull up enabled */
-       else
-               printk(" PUD"); /* pull up disabled */
-       if (config & 8) 
-               printk(" LOCKED"); /* locked */
-       if (config & 16) 
-               printk(" LEVEL"); /* level input */
-       else
-               printk(" EDGE"); /* edge input */
-       if (config & 32) 
-               printk(" HI"); /* trigger on rising edge */
-       else
-               printk(" LO"); /* trigger on falling edge */
-       if (config & 64) 
-               printk(" DEBOUNCE"); /* debounce */
-       printk("\n");
-}
-#endif  /*  0  */
-
 static int __init scx200_init(void)
 {
        printk(KERN_INFO NAME ": NatSemi SCx200 Driver\n");
 
-       return pci_module_init(&scx200_pci_driver);
+       return pci_register_driver(&scx200_pci_driver);
 }
 
 static void __exit scx200_cleanup(void)
@@ -158,10 +130,3 @@ EXPORT_SYMBOL(scx200_gpio_base);
 EXPORT_SYMBOL(scx200_gpio_shadow);
 EXPORT_SYMBOL(scx200_gpio_configure);
 EXPORT_SYMBOL(scx200_cb_base);
-
-/*
-    Local variables:
-        compile-command: "make -k -C ../../.. SUBDIRS=arch/i386/kernel modules"
-        c-basic-offset: 8
-    End:
-*/