diff mbox

[5/5] iio: stx104: Add GPIO set_multiple callback function support

Message ID 53039e49d1421a6f070c691988eb22ef0987eba4.1484838095.git.vilhelm.gray@gmail.com
State New
Headers show

Commit Message

William Breathitt Gray Jan. 19, 2017, 3:06 p.m. UTC
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>
---
 drivers/iio/adc/stx104.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

Comments

Jonathan Cameron Jan. 22, 2017, 1:23 p.m. UTC | #1
On 19/01/17 15:06, William Breathitt Gray wrote:
> 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>
Acked-by: Jonathan Cameron <jic23@kernel.org>
> ---
>  drivers/iio/adc/stx104.c | 23 +++++++++++++++++++++++
>  1 file changed, 23 insertions(+)
> 
> diff --git a/drivers/iio/adc/stx104.c b/drivers/iio/adc/stx104.c
> index 7e3645749eaf..6971293909f7 100644
> --- a/drivers/iio/adc/stx104.c
> +++ b/drivers/iio/adc/stx104.c
> @@ -266,6 +266,28 @@ static void stx104_gpio_set(struct gpio_chip *chip, unsigned int offset,
>  	spin_unlock_irqrestore(&stx104gpio->lock, flags);
>  }
>  
> +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;
> @@ -330,6 +352,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;
>  
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Linus Walleij Jan. 22, 2017, 1:26 p.m. UTC | #2
On Thu, Jan 19, 2017 at 4:06 PM, William Breathitt Gray
<vilhelm.gray@gmail.com> wrote:

> 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>

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

Best if Jonathan queues this so the changes reside in the
IIO tree.

Yours,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
William Breathitt Gray Jan. 31, 2017, 8:03 p.m. UTC | #3
On Sun, Jan 22, 2017 at 01:23:07PM +0000, Jonathan Cameron wrote:
>On 19/01/17 15:06, William Breathitt Gray wrote:
>> 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>
>Acked-by: Jonathan Cameron <jic23@kernel.org>

Jonathan Cameron,

Would you pick this patch up in one of your iio.git branches?

Thanks,

William Breathitt Gray
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Jonathan Cameron Feb. 1, 2017, 6:50 p.m. UTC | #4
On 31/01/17 20:03, William Breathitt Gray wrote:
> On Sun, Jan 22, 2017 at 01:23:07PM +0000, Jonathan Cameron wrote:
>> On 19/01/17 15:06, William Breathitt Gray wrote:
>>> 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>
>> Acked-by: Jonathan Cameron <jic23@kernel.org>
> 
> Jonathan Cameron,
> 
> Would you pick this patch up in one of your iio.git branches?
Sure.  For some reason I got into my head this should go via the gpio
tree, but no reason why really.

Anyhow, applied, but there was some fuzz.

Applied to the toreg branch of iio.git and pushed out as testing for
the autobuilders to play with it.

Thanks.

Jonathan
> 
> Thanks,
> 
> William Breathitt Gray
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/iio/adc/stx104.c b/drivers/iio/adc/stx104.c
index 7e3645749eaf..6971293909f7 100644
--- a/drivers/iio/adc/stx104.c
+++ b/drivers/iio/adc/stx104.c
@@ -266,6 +266,28 @@  static void stx104_gpio_set(struct gpio_chip *chip, unsigned int offset,
 	spin_unlock_irqrestore(&stx104gpio->lock, flags);
 }
 
+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;
@@ -330,6 +352,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;