Merge tag 'v3.4-rc6' into gpio/next
authorGrant Likely <grant.likely@secretlab.ca>
Tue, 8 May 2012 17:35:37 +0000 (11:35 -0600)
committerGrant Likely <grant.likely@secretlab.ca>
Tue, 8 May 2012 17:35:37 +0000 (11:35 -0600)
Linux 3.4-rc6

13 files changed:
Documentation/gpio.txt
drivers/gpio/Kconfig
drivers/gpio/Makefile
drivers/gpio/gpio-bt8xx.c
drivers/gpio/gpio-langwell.c
drivers/gpio/gpio-ml-ioh.c
drivers/gpio/gpio-pch.c
drivers/gpio/gpio-sodaville.c
drivers/gpio/gpiolib-of.c [moved from drivers/of/gpio.c with 100% similarity]
drivers/gpio/gpiolib.c
drivers/of/Kconfig
drivers/of/Makefile
include/linux/gpio.h

index 620a078..e08a883 100644 (file)
@@ -322,6 +322,9 @@ where 'flags' is currently defined to specify the following properties:
        * GPIOF_OPEN_DRAIN      - gpio pin is open drain type.
        * GPIOF_OPEN_SOURCE     - gpio pin is open source type.
 
+       * GPIOF_EXPORT_DIR_FIXED        - export gpio to sysfs, keep direction
+       * GPIOF_EXPORT_DIR_CHANGEABLE   - also export, allow changing direction
+
 since GPIOF_INIT_* are only valid when configured as output, so group valid
 combinations as:
 
index e03653d..7875c3f 100644 (file)
@@ -37,6 +37,10 @@ menuconfig GPIOLIB
 
 if GPIOLIB
 
+config OF_GPIO
+       def_bool y
+       depends on OF && !SPARC
+
 config DEBUG_GPIO
        bool "Debug GPIO calls"
        depends on DEBUG_KERNEL
@@ -243,7 +247,7 @@ config GPIO_MC9S08DZ60
          Select this to enable the MC9S08DZ60 GPIO driver
 
 config GPIO_PCA953X
-       tristate "PCA953x, PCA955x, TCA64xx, and MAX7310 I/O ports"
+       tristate "PCA953x, PCA955x, PCA957x, TCA64xx, and MAX7310 I/O ports"
        depends on I2C
        help
          Say yes here to provide access to several register-oriented
@@ -252,10 +256,11 @@ config GPIO_PCA953X
 
          4 bits:       pca9536, pca9537
 
-         8 bits:       max7310, pca9534, pca9538, pca9554, pca9557,
-                       tca6408
+         8 bits:       max7310, max7315, pca6107, pca9534, pca9538, pca9554,
+                       pca9556, pca9557, pca9574, tca6408
 
-         16 bits:      pca9535, pca9539, pca9555, tca6416
+         16 bits:      max7312, max7313, pca9535, pca9539, pca9555, pca9575,
+                       tca6416
 
 config GPIO_PCA953X_IRQ
        bool "Interrupt controller support for PCA953x"
index 007f54b..1c2f6c0 100644 (file)
@@ -3,6 +3,7 @@
 ccflags-$(CONFIG_DEBUG_GPIO)   += -DDEBUG
 
 obj-$(CONFIG_GPIOLIB)          += gpiolib.o devres.o
+obj-$(CONFIG_OF_GPIO)          += gpiolib-of.o
 
 # Device drivers. Generally keep list sorted alphabetically
 obj-$(CONFIG_GPIO_GENERIC)     += gpio-generic.o
index 5ca4098..e4cc7eb 100644 (file)
@@ -328,17 +328,7 @@ static struct pci_driver bt8xxgpio_pci_driver = {
        .resume         = bt8xxgpio_resume,
 };
 
-static int __init bt8xxgpio_init(void)
-{
-       return pci_register_driver(&bt8xxgpio_pci_driver);
-}
-module_init(bt8xxgpio_init)
-
-static void __exit bt8xxgpio_exit(void)
-{
-       pci_unregister_driver(&bt8xxgpio_pci_driver);
-}
-module_exit(bt8xxgpio_exit)
+module_pci_driver(bt8xxgpio_pci_driver);
 
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Michael Buesch");
index 00692e8..52f00d3 100644 (file)
@@ -263,6 +263,24 @@ static void lnw_irq_handler(unsigned irq, struct irq_desc *desc)
        chip->irq_eoi(data);
 }
 
+static void lnw_irq_init_hw(struct lnw_gpio *lnw)
+{
+       void __iomem *reg;
+       unsigned base;
+
+       for (base = 0; base < lnw->chip.ngpio; base += 32) {
+               /* Clear the rising-edge detect register */
+               reg = gpio_reg(&lnw->chip, base, GRER);
+               writel(0, reg);
+               /* Clear the falling-edge detect register */
+               reg = gpio_reg(&lnw->chip, base, GFER);
+               writel(0, reg);
+               /* Clear the edge detect status register */
+               reg = gpio_reg(&lnw->chip, base, GEDR);
+               writel(~0, reg);
+       }
+}
+
 #ifdef CONFIG_PM
 static int lnw_gpio_runtime_resume(struct device *dev)
 {
@@ -306,10 +324,11 @@ static int __devinit lnw_gpio_probe(struct pci_dev *pdev,
        u32 irq_base;
        u32 gpio_base;
        int retval = 0;
+       int ngpio = id->driver_data;
 
        retval = pci_enable_device(pdev);
        if (retval)
-               goto done;
+               return retval;
 
        retval = pci_request_regions(pdev, "langwell_gpio");
        if (retval) {
@@ -331,21 +350,28 @@ static int __devinit lnw_gpio_probe(struct pci_dev *pdev,
        /* get the register base from bar0 */
        start = pci_resource_start(pdev, 0);
        len = pci_resource_len(pdev, 0);
-       base = ioremap_nocache(start, len);
+       base = devm_ioremap_nocache(&pdev->dev, start, len);
        if (!base) {
                dev_err(&pdev->dev, "error mapping bar0\n");
                retval = -EFAULT;
                goto err3;
        }
 
-       lnw = kzalloc(sizeof(struct lnw_gpio), GFP_KERNEL);
+       lnw = devm_kzalloc(&pdev->dev, sizeof(struct lnw_gpio), GFP_KERNEL);
        if (!lnw) {
                dev_err(&pdev->dev, "can't allocate langwell_gpio chip data\n");
                retval = -ENOMEM;
-               goto err4;
+               goto err3;
        }
+
+       retval = irq_alloc_descs(-1, irq_base, ngpio, 0);
+       if (retval < 0) {
+               dev_err(&pdev->dev, "can't allocate IRQ descs\n");
+               goto err3;
+       }
+       lnw->irq_base = retval;
+
        lnw->reg_base = base;
-       lnw->irq_base = irq_base;
        lnw->chip.label = dev_name(&pdev->dev);
        lnw->chip.request = lnw_gpio_request;
        lnw->chip.direction_input = lnw_gpio_direction_input;
@@ -354,15 +380,18 @@ static int __devinit lnw_gpio_probe(struct pci_dev *pdev,
        lnw->chip.set = lnw_gpio_set;
        lnw->chip.to_irq = lnw_gpio_to_irq;
        lnw->chip.base = gpio_base;
-       lnw->chip.ngpio = id->driver_data;
+       lnw->chip.ngpio = ngpio;
        lnw->chip.can_sleep = 0;
        lnw->pdev = pdev;
        pci_set_drvdata(pdev, lnw);
        retval = gpiochip_add(&lnw->chip);
        if (retval) {
                dev_err(&pdev->dev, "langwell gpiochip_add error %d\n", retval);
-               goto err5;
+               goto err4;
        }
+
+       lnw_irq_init_hw(lnw);
+
        irq_set_handler_data(pdev->irq, lnw);
        irq_set_chained_handler(pdev->irq, lnw_irq_handler);
        for (i = 0; i < lnw->chip.ngpio; i++) {
@@ -376,16 +405,14 @@ static int __devinit lnw_gpio_probe(struct pci_dev *pdev,
        pm_runtime_put_noidle(&pdev->dev);
        pm_runtime_allow(&pdev->dev);
 
-       goto done;
-err5:
-       kfree(lnw);
+       return 0;
+
 err4:
-       iounmap(base);
+       irq_free_descs(lnw->irq_base, ngpio);
 err3:
        pci_release_regions(pdev);
 err2:
        pci_disable_device(pdev);
-done:
        return retval;
 }
 
index f0febe5..db01f15 100644 (file)
@@ -611,17 +611,7 @@ static struct pci_driver ioh_gpio_driver = {
        .resume = ioh_gpio_resume
 };
 
-static int __init ioh_gpio_pci_init(void)
-{
-       return pci_register_driver(&ioh_gpio_driver);
-}
-module_init(ioh_gpio_pci_init);
-
-static void __exit ioh_gpio_pci_exit(void)
-{
-       pci_unregister_driver(&ioh_gpio_driver);
-}
-module_exit(ioh_gpio_pci_exit);
+module_pci_driver(ioh_gpio_driver);
 
 MODULE_DESCRIPTION("OKI SEMICONDUCTOR ML-IOH series GPIO Driver");
 MODULE_LICENSE("GPL");
index e8729cc..a05fdb6 100644 (file)
@@ -539,17 +539,7 @@ static struct pci_driver pch_gpio_driver = {
        .resume = pch_gpio_resume
 };
 
-static int __init pch_gpio_pci_init(void)
-{
-       return pci_register_driver(&pch_gpio_driver);
-}
-module_init(pch_gpio_pci_init);
-
-static void __exit pch_gpio_pci_exit(void)
-{
-       pci_unregister_driver(&pch_gpio_driver);
-}
-module_exit(pch_gpio_pci_exit);
+module_pci_driver(pch_gpio_driver);
 
 MODULE_DESCRIPTION("PCH GPIO PCI Driver");
 MODULE_LICENSE("GPL");
index 031e5d2..820209c 100644 (file)
@@ -282,17 +282,7 @@ static struct pci_driver sdv_gpio_driver = {
        .remove = sdv_gpio_remove,
 };
 
-static int __init sdv_gpio_init(void)
-{
-       return pci_register_driver(&sdv_gpio_driver);
-}
-module_init(sdv_gpio_init);
-
-static void __exit sdv_gpio_exit(void)
-{
-       pci_unregister_driver(&sdv_gpio_driver);
-}
-module_exit(sdv_gpio_exit);
+module_pci_driver(sdv_gpio_driver);
 
 MODULE_AUTHOR("Hans J. Koch <hjk@linutronix.de>");
 MODULE_DESCRIPTION("GPIO interface for Intel Sodaville SoCs");
similarity index 100%
rename from drivers/of/gpio.c
rename to drivers/gpio/gpiolib-of.c
index 5a75510..566d012 100644 (file)
@@ -1302,8 +1302,18 @@ int gpio_request_one(unsigned gpio, unsigned long flags, const char *label)
                                (flags & GPIOF_INIT_HIGH) ? 1 : 0);
 
        if (err)
-               gpio_free(gpio);
+               goto free_gpio;
+
+       if (flags & GPIOF_EXPORT) {
+               err = gpio_export(gpio, flags & GPIOF_EXPORT_CHANGEABLE);
+               if (err)
+                       goto free_gpio;
+       }
+
+       return 0;
 
+ free_gpio:
+       gpio_free(gpio);
        return err;
 }
 EXPORT_SYMBOL_GPL(gpio_request_one);
index 8e84ce9..ce00d11 100644 (file)
@@ -51,12 +51,6 @@ config OF_IRQ
 config OF_DEVICE
        def_bool y
 
-config OF_GPIO
-       def_bool y
-       depends on GPIOLIB && !SPARC
-       help
-         OpenFirmware GPIO accessors
-
 config OF_I2C
        def_tristate I2C
        depends on I2C && !SPARC
index aa90e60..aff2c62 100644 (file)
@@ -4,7 +4,6 @@ obj-$(CONFIG_OF_PROMTREE) += pdt.o
 obj-$(CONFIG_OF_ADDRESS)  += address.o
 obj-$(CONFIG_OF_IRQ)    += irq.o
 obj-$(CONFIG_OF_DEVICE) += device.o platform.o
-obj-$(CONFIG_OF_GPIO)   += gpio.o
 obj-$(CONFIG_OF_I2C)   += of_i2c.o
 obj-$(CONFIG_OF_NET)   += of_net.o
 obj-$(CONFIG_OF_SPI)   += of_spi.o
index 6155ecf..d1890d4 100644 (file)
 /* Gpio pin is open source */
 #define GPIOF_OPEN_SOURCE      (1 << 3)
 
+#define GPIOF_EXPORT           (1 << 2)
+#define GPIOF_EXPORT_CHANGEABLE        (1 << 3)
+#define GPIOF_EXPORT_DIR_FIXED (GPIOF_EXPORT)
+#define GPIOF_EXPORT_DIR_CHANGEABLE (GPIOF_EXPORT | GPIOF_EXPORT_CHANGEABLE)
+
 /**
  * struct gpio - a structure describing a GPIO with configuration
  * @gpio:      the GPIO number
@@ -55,6 +60,12 @@ static inline int gpio_request(unsigned gpio, const char *label)
        return -ENOSYS;
 }
 
+static inline int devm_gpio_request(struct device *dev, unsigned gpio,
+                                   const char *label)
+{
+       return -ENOSYS;
+}
+
 static inline int gpio_request_one(unsigned gpio,
                                        unsigned long flags, const char *label)
 {
@@ -74,6 +85,14 @@ static inline void gpio_free(unsigned gpio)
        WARN_ON(1);
 }
 
+static inline void devm_gpio_free(struct device *dev, unsigned gpio)
+{
+       might_sleep();
+
+       /* GPIO can never have been requested */
+       WARN_ON(1);
+}
+
 static inline void gpio_free_array(const struct gpio *array, size_t num)
 {
        might_sleep();