summaryrefslogtreecommitdiff
path: root/drivers/iio
diff options
context:
space:
mode:
authorWilliam Breathitt Gray <vilhelm.gray@gmail.com>2017-01-19 18:06:16 +0300
committerJonathan Cameron <jic23@kernel.org>2017-02-01 21:50:54 +0300
commitbfe7288e0dd143268359f703ac9b8d4f904d3f75 (patch)
tree5c427121bc273f8209ff80277eb4e3af953e000f /drivers/iio
parent1c74a6da1e4fefb9db9ce467b5e482fb6a15c676 (diff)
downloadlinux-bfe7288e0dd143268359f703ac9b8d4f904d3f75.tar.xz
iio: stx104: Add GPIO set_multiple callback function support
The Apex Embedded Systems STX104 series provides a digital output register where 4 lines may be set at a time. This patch add support for the set_multiple callback function, thus allowing multiple digital output lines to be set more efficiently in groups. Cc: Jonathan Cameron <jic23@kernel.org> Cc: Hartmut Knaack <knaack.h@gmx.de> Cc: Lars-Peter Clausen <lars@metafoo.de> Cc: Peter Meerwald-Stadler <pmeerw@pmeerw.net> Signed-off-by: William Breathitt Gray <vilhelm.gray@gmail.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'drivers/iio')
-rw-r--r--drivers/iio/adc/stx104.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/drivers/iio/adc/stx104.c b/drivers/iio/adc/stx104.c
index 40c05df218f8..be2de48844bc 100644
--- a/drivers/iio/adc/stx104.c
+++ b/drivers/iio/adc/stx104.c
@@ -261,6 +261,28 @@ static const char *stx104_names[STX104_NGPIO] = {
"DIN0", "DIN1", "DIN2", "DIN3", "DOUT0", "DOUT1", "DOUT2", "DOUT3"
};
+static void stx104_gpio_set_multiple(struct gpio_chip *chip,
+ unsigned long *mask, unsigned long *bits)
+{
+ struct stx104_gpio *const stx104gpio = gpiochip_get_data(chip);
+ unsigned long flags;
+
+ /* verify masked GPIO are output */
+ if (!(*mask & 0xF0))
+ return;
+
+ *mask >>= 4;
+ *bits >>= 4;
+
+ spin_lock_irqsave(&stx104gpio->lock, flags);
+
+ stx104gpio->out_state &= ~*mask;
+ stx104gpio->out_state |= *mask & *bits;
+ outb(stx104gpio->out_state, stx104gpio->base);
+
+ spin_unlock_irqrestore(&stx104gpio->lock, flags);
+}
+
static int stx104_probe(struct device *dev, unsigned int id)
{
struct iio_dev *indio_dev;
@@ -321,6 +343,7 @@ static int stx104_probe(struct device *dev, unsigned int id)
stx104gpio->chip.direction_output = stx104_gpio_direction_output;
stx104gpio->chip.get = stx104_gpio_get;
stx104gpio->chip.set = stx104_gpio_set;
+ stx104gpio->chip.set_multiple = stx104_gpio_set_multiple;
stx104gpio->base = base[id] + 3;
stx104gpio->out_state = 0x0;