aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpio
diff options
context:
space:
mode:
authorGeert Uytterhoeven <geert+renesas@glider.be>2016-03-14 11:19:18 -0400
committerLinus Walleij <linus.walleij@linaro.org>2016-03-30 04:38:50 -0400
commitd46ab6823963de2165f5a2af7600ce830e990e53 (patch)
tree13b50f2d48b1908a6b514e46728a284ee1ebd69e /drivers/gpio
parentdbb763b8ea5d8eb0ce3e45e289969f6f1f418921 (diff)
gpio: 74x164: Implement gpiochip.set_multiple()
This allows to set multiple outputs using a single SPI transfer. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Reviewed-by: Phil Reid <preid@electromag.com.au> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/gpio')
-rw-r--r--drivers/gpio/gpio-74x164.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/drivers/gpio/gpio-74x164.c b/drivers/gpio/gpio-74x164.c
index c81224ff2dca..62291a81c97f 100644
--- a/drivers/gpio/gpio-74x164.c
+++ b/drivers/gpio/gpio-74x164.c
@@ -75,6 +75,29 @@ static void gen_74x164_set_value(struct gpio_chip *gc,
75 mutex_unlock(&chip->lock); 75 mutex_unlock(&chip->lock);
76} 76}
77 77
78static void gen_74x164_set_multiple(struct gpio_chip *gc, unsigned long *mask,
79 unsigned long *bits)
80{
81 struct gen_74x164_chip *chip = gpiochip_get_data(gc);
82 unsigned int i, idx, shift;
83 u8 bank, bankmask;
84
85 mutex_lock(&chip->lock);
86 for (i = 0, bank = chip->registers - 1; i < chip->registers;
87 i++, bank--) {
88 idx = i / sizeof(*mask);
89 shift = i % sizeof(*mask) * BITS_PER_BYTE;
90 bankmask = mask[idx] >> shift;
91 if (!bankmask)
92 continue;
93
94 chip->buffer[bank] &= ~bankmask;
95 chip->buffer[bank] |= bankmask & (bits[idx] >> shift);
96 }
97 __gen_74x164_write_config(chip);
98 mutex_unlock(&chip->lock);
99}
100
78static int gen_74x164_direction_output(struct gpio_chip *gc, 101static int gen_74x164_direction_output(struct gpio_chip *gc,
79 unsigned offset, int val) 102 unsigned offset, int val)
80{ 103{
@@ -114,6 +137,7 @@ static int gen_74x164_probe(struct spi_device *spi)
114 chip->gpio_chip.direction_output = gen_74x164_direction_output; 137 chip->gpio_chip.direction_output = gen_74x164_direction_output;
115 chip->gpio_chip.get = gen_74x164_get_value; 138 chip->gpio_chip.get = gen_74x164_get_value;
116 chip->gpio_chip.set = gen_74x164_set_value; 139 chip->gpio_chip.set = gen_74x164_set_value;
140 chip->gpio_chip.set_multiple = gen_74x164_set_multiple;
117 chip->gpio_chip.base = -1; 141 chip->gpio_chip.base = -1;
118 142
119 chip->registers = nregs; 143 chip->registers = nregs;