]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commitdiff
pinctrl: at91: Add set_multiple GPIO chip feature
authorAlexander Stein <alexanders83@web.de>
Thu, 2 Apr 2015 09:55:49 +0000 (11:55 +0200)
committerLinus Walleij <linus.walleij@linaro.org>
Wed, 6 May 2015 12:45:18 +0000 (14:45 +0200)
This adds the callback for set_multiple.

As this controller has a separate set and clear register, we
can't write directly to PIO_ODSR as this would required a cached
variable and would race with at91_gpio_set.

So build masks for the PIO_SODR and PIO_CODR registers and
write them together.

Signed-off-by: Alexander Stein <alexanders83@web.de>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
drivers/pinctrl/pinctrl-at91.c

index 2f797cb7e2050175e8b870d9caf342a623061dce..d80ade23fd1bb454bf172b538a60921e7a336058 100644 (file)
@@ -1326,6 +1326,21 @@ static void at91_gpio_set(struct gpio_chip *chip, unsigned offset,
        writel_relaxed(mask, pio + (val ? PIO_SODR : PIO_CODR));
 }
 
+static void at91_gpio_set_multiple(struct gpio_chip *chip,
+                                     unsigned long *mask, unsigned long *bits)
+{
+       struct at91_gpio_chip *at91_gpio = to_at91_gpio_chip(chip);
+       void __iomem *pio = at91_gpio->regbase;
+
+#define BITS_MASK(bits) (((bits) == 32) ? ~0U : (BIT(bits) - 1))
+       /* Mask additionally to ngpio as not all GPIO controllers have 32 pins */
+       uint32_t set_mask = (*mask & *bits) & BITS_MASK(chip->ngpio);
+       uint32_t clear_mask = (*mask & ~(*bits)) & BITS_MASK(chip->ngpio);
+
+       writel_relaxed(set_mask, pio + PIO_SODR);
+       writel_relaxed(clear_mask, pio + PIO_CODR);
+}
+
 static int at91_gpio_direction_output(struct gpio_chip *chip, unsigned offset,
                                int val)
 {
@@ -1685,6 +1700,7 @@ static struct gpio_chip at91_gpio_template = {
        .get                    = at91_gpio_get,
        .direction_output       = at91_gpio_direction_output,
        .set                    = at91_gpio_set,
+       .set_multiple           = at91_gpio_set_multiple,
        .dbg_show               = at91_gpio_dbg_show,
        .can_sleep              = false,
        .ngpio                  = MAX_NB_GPIO_PER_BANK,