Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

gpio-mpc8xxx: add mpc8xxx_gpio_set_multiple function

Add a set_multiple function to the MPC8xxx GPIO chip driver and thereby allow
for actual performance improvements when setting multiple outputs
simultaneously. In my case the time needed to configure an FPGA goes down from
48 s to 20 s.

Change log:
v6: - rebase on current linux-gpio devel branch
v5: - no change
v4: - change interface of the set_multiple driver function to use
unsigned long as type for the bit fields
- use generic bitops (which also use unsigned long for bit fields)
v3: - change commit message
v2: - add this patch (v1 included only changes to gpiolib)

Signed-off-by: Rojhalat Ibrahim <imr@rtschenk.de>
Reviewed-by: Alexandre Courbot <acourbot@nvidia.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

authored by

Rojhalat Ibrahim and committed by
Linus Walleij
e5db3b33 5f424243

+27
+27
drivers/gpio/gpio-mpc8xxx.c
··· 105 105 spin_unlock_irqrestore(&mpc8xxx_gc->lock, flags); 106 106 } 107 107 108 + static void mpc8xxx_gpio_set_multiple(struct gpio_chip *gc, 109 + unsigned long *mask, unsigned long *bits) 110 + { 111 + struct of_mm_gpio_chip *mm = to_of_mm_gpio_chip(gc); 112 + struct mpc8xxx_gpio_chip *mpc8xxx_gc = to_mpc8xxx_gpio_chip(mm); 113 + unsigned long flags; 114 + int i; 115 + 116 + spin_lock_irqsave(&mpc8xxx_gc->lock, flags); 117 + 118 + for (i = 0; i < gc->ngpio; i++) { 119 + if (*mask == 0) 120 + break; 121 + if (__test_and_clear_bit(i, mask)) { 122 + if (test_bit(i, bits)) 123 + mpc8xxx_gc->data |= mpc8xxx_gpio2mask(i); 124 + else 125 + mpc8xxx_gc->data &= ~mpc8xxx_gpio2mask(i); 126 + } 127 + } 128 + 129 + out_be32(mm->regs + GPIO_DAT, mpc8xxx_gc->data); 130 + 131 + spin_unlock_irqrestore(&mpc8xxx_gc->lock, flags); 132 + } 133 + 108 134 static int mpc8xxx_gpio_dir_in(struct gpio_chip *gc, unsigned int gpio) 109 135 { 110 136 struct of_mm_gpio_chip *mm = to_of_mm_gpio_chip(gc); ··· 370 344 gc->get = of_device_is_compatible(np, "fsl,mpc8572-gpio") ? 371 345 mpc8572_gpio_get : mpc8xxx_gpio_get; 372 346 gc->set = mpc8xxx_gpio_set; 347 + gc->set_multiple = mpc8xxx_gpio_set_multiple; 373 348 gc->to_irq = mpc8xxx_gpio_to_irq; 374 349 375 350 ret = of_mm_gpiochip_add(np, mm_gc);