Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1562806 > unrolled thread

[PATCH 0/5] Add GPIO set_multiple callback support for ISA_BUS_API drivers

Started byWilliam Breathitt Gray <vilhelm.gray@gmail.com>
First post2017-01-19 16:10 +0100
Last post2017-01-22 14:40 +0100
Articles 10 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH 0/5] Add GPIO set_multiple callback support for ISA_BUS_API drivers William Breathitt Gray <vilhelm.gray@gmail.com> - 2017-01-19 16:10 +0100
    [PATCH 1/5] gpio: 104-dio-48e: Add set_multiple callback function support William Breathitt Gray <vilhelm.gray@gmail.com> - 2017-01-19 16:10 +0100
      Re: [PATCH 1/5] gpio: 104-dio-48e: Add set_multiple callback function support Linus Walleij <linus.walleij@linaro.org> - 2017-01-26 11:00 +0100
    [PATCH 2/5] gpio: 104-idio-16: Add set_multiple callback function support William Breathitt Gray <vilhelm.gray@gmail.com> - 2017-01-19 16:10 +0100
      Re: [PATCH 2/5] gpio: 104-idio-16: Add set_multiple callback function support Linus Walleij <linus.walleij@linaro.org> - 2017-01-26 11:00 +0100
    [PATCH 4/5] gpio: ws16c48: Add set_multiple callback function support William Breathitt Gray <vilhelm.gray@gmail.com> - 2017-01-19 16:10 +0100
      Re: [PATCH 4/5] gpio: ws16c48: Add set_multiple callback function support Linus Walleij <linus.walleij@linaro.org> - 2017-01-26 11:00 +0100
    [PATCH 5/5] iio: stx104: Add GPIO set_multiple callback function support William Breathitt Gray <vilhelm.gray@gmail.com> - 2017-01-19 16:20 +0100
      Re: [PATCH 5/5] iio: stx104: Add GPIO set_multiple callback function  support Jonathan Cameron <jic23@kernel.org> - 2017-01-22 14:30 +0100
      Re: [PATCH 5/5] iio: stx104: Add GPIO set_multiple callback function support Linus Walleij <linus.walleij@linaro.org> - 2017-01-22 14:40 +0100

#1562806 — [PATCH 0/5] Add GPIO set_multiple callback support for ISA_BUS_API drivers

FromWilliam Breathitt Gray <vilhelm.gray@gmail.com>
Date2017-01-19 16:10 +0100
Subject[PATCH 0/5] Add GPIO set_multiple callback support for ISA_BUS_API drivers
Message-ID<t1mvD-38y-3@gated-at.bofh.it>
Most of the ISA_BUS_API drivers control GPIO via 8-bit ioport registers.
Since updating any given GPIO line involves writing out all 8 bits for
the respective register, it makes sense to add support for the GPIO
set_multiple callback function so that multiple GPIO lines may be set
more efficiently. This patchset adds such support in each respective
driver.

William Breathitt Gray (5):
  gpio: 104-dio-48e: Add set_multiple callback function support
  gpio: 104-idio-16: Add set_multiple callback function support
  gpio: gpio-mm: Add set_multiple callback function support
  gpio: ws16c48: Add set_multiple callback function support
  iio: stx104: Add GPIO set_multiple callback function support

 drivers/gpio/gpio-104-dio-48e.c | 39 +++++++++++++++++++++++++++++++++++++++
 drivers/gpio/gpio-104-idio-16.c | 20 ++++++++++++++++++++
 drivers/gpio/gpio-gpio-mm.c     | 39 +++++++++++++++++++++++++++++++++++++++
 drivers/gpio/gpio-ws16c48.c     | 41 +++++++++++++++++++++++++++++++++++++++++
 drivers/iio/adc/stx104.c        | 23 +++++++++++++++++++++++
 5 files changed, 162 insertions(+)

-- 
2.11.0

[toc] | [next] | [standalone]


#1562808 — [PATCH 1/5] gpio: 104-dio-48e: Add set_multiple callback function support

FromWilliam Breathitt Gray <vilhelm.gray@gmail.com>
Date2017-01-19 16:10 +0100
Subject[PATCH 1/5] gpio: 104-dio-48e: Add set_multiple callback function support
Message-ID<t1mvD-38y-11@gated-at.bofh.it>
In reply to#1562806
The ACCES 104-DIO-48E series provides registers where 8 lines of GPIO
may be set at a time. This patch add support for the set_multiple
callback function, thus allowing multiple GPIO output lines to be set
more efficiently in groups.

Signed-off-by: William Breathitt Gray <vilhelm.gray@gmail.com>
---
 drivers/gpio/gpio-104-dio-48e.c | 39 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)

diff --git a/drivers/gpio/gpio-104-dio-48e.c b/drivers/gpio/gpio-104-dio-48e.c
index fcf776971ca9..7bc891f1d11a 100644
--- a/drivers/gpio/gpio-104-dio-48e.c
+++ b/drivers/gpio/gpio-104-dio-48e.c
@@ -204,6 +204,44 @@ static void dio48e_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
 	spin_unlock_irqrestore(&dio48egpio->lock, flags);
 }
 
+static void dio48e_gpio_set_multiple(struct gpio_chip *chip,
+	unsigned long *mask, unsigned long *bits)
+{
+	struct dio48e_gpio *const dio48egpio = gpiochip_get_data(chip);
+	unsigned int i;
+	const unsigned int gpio_reg_size = 8;
+	unsigned int port;
+	unsigned int out_port;
+	unsigned int bitmask;
+	unsigned long flags;
+
+	/* set bits are evaluated a gpio register size at a time */
+	for (i = 0; i < chip->ngpio; i += gpio_reg_size) {
+		/* no more set bits in this mask word; skip to the next word */
+		if (!mask[BIT_WORD(i)]) {
+			i = (BIT_WORD(i) + 1) * BITS_PER_LONG - gpio_reg_size;
+			continue;
+		}
+
+		port = i / gpio_reg_size;
+		out_port = (port > 2) ? port + 1 : port;
+		bitmask = mask[BIT_WORD(i)] & bits[BIT_WORD(i)];
+
+		spin_lock_irqsave(&dio48egpio->lock, flags);
+
+		/* update output state data and set device gpio register */
+		dio48egpio->out_state[port] &= ~mask[BIT_WORD(i)];
+		dio48egpio->out_state[port] |= bitmask;
+		outb(dio48egpio->out_state[port], dio48egpio->base + out_port);
+
+		spin_unlock_irqrestore(&dio48egpio->lock, flags);
+
+		/* prepare for next gpio register set */
+		mask[BIT_WORD(i)] >>= gpio_reg_size;
+		bits[BIT_WORD(i)] >>= gpio_reg_size;
+	}
+}
+
 static void dio48e_irq_ack(struct irq_data *data)
 {
 }
@@ -328,6 +366,7 @@ static int dio48e_probe(struct device *dev, unsigned int id)
 	dio48egpio->chip.direction_output = dio48e_gpio_direction_output;
 	dio48egpio->chip.get = dio48e_gpio_get;
 	dio48egpio->chip.set = dio48e_gpio_set;
+	dio48egpio->chip.set_multiple = dio48e_gpio_set_multiple;
 	dio48egpio->base = base[id];
 	dio48egpio->irq = irq[id];
 
-- 
2.11.0

[toc] | [prev] | [next] | [standalone]


#1567257 — Re: [PATCH 1/5] gpio: 104-dio-48e: Add set_multiple callback function support

FromLinus Walleij <linus.walleij@linaro.org>
Date2017-01-26 11:00 +0100
SubjectRe: [PATCH 1/5] gpio: 104-dio-48e: Add set_multiple callback function support
Message-ID<t3P0v-5Js-43@gated-at.bofh.it>
In reply to#1562808
On Thu, Jan 19, 2017 at 4:05 PM, William Breathitt Gray
<vilhelm.gray@gmail.com> wrote:

> The ACCES 104-DIO-48E series provides registers where 8 lines of GPIO
> may be set at a time. This patch add support for the set_multiple
> callback function, thus allowing multiple GPIO output lines to be set
> more efficiently in groups.
>
> Signed-off-by: William Breathitt Gray <vilhelm.gray@gmail.com>

Patch applied.

Yours,
Linus Walleij

[toc] | [prev] | [next] | [standalone]


#1562809 — [PATCH 2/5] gpio: 104-idio-16: Add set_multiple callback function support

FromWilliam Breathitt Gray <vilhelm.gray@gmail.com>
Date2017-01-19 16:10 +0100
Subject[PATCH 2/5] gpio: 104-idio-16: Add set_multiple callback function support
Message-ID<t1mvE-38y-21@gated-at.bofh.it>
In reply to#1562806
The ACCES 104-IDIO-16 series provides registers where 8 lines of GPIO
may be set at a time. This patch add support for the set_multiple
callback function, thus allowing multiple GPIO output lines to be set
more efficiently in groups.

Signed-off-by: William Breathitt Gray <vilhelm.gray@gmail.com>
---
 drivers/gpio/gpio-104-idio-16.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/drivers/gpio/gpio-104-idio-16.c b/drivers/gpio/gpio-104-idio-16.c
index 6787b8fcf0d8..a57900fd0dc7 100644
--- a/drivers/gpio/gpio-104-idio-16.c
+++ b/drivers/gpio/gpio-104-idio-16.c
@@ -116,6 +116,25 @@ static void idio_16_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
 	spin_unlock_irqrestore(&idio16gpio->lock, flags);
 }
 
+static void idio_16_gpio_set_multiple(struct gpio_chip *chip,
+	unsigned long *mask, unsigned long *bits)
+{
+	struct idio_16_gpio *const idio16gpio = gpiochip_get_data(chip);
+	unsigned long flags;
+
+	spin_lock_irqsave(&idio16gpio->lock, flags);
+
+	idio16gpio->out_state &= ~*mask;
+	idio16gpio->out_state |= *mask & *bits;
+
+	if (*mask & 0xFF)
+		outb(idio16gpio->out_state, idio16gpio->base);
+	if ((*mask >> 8) & 0xFF)
+		outb(idio16gpio->out_state >> 8, idio16gpio->base + 4);
+
+	spin_unlock_irqrestore(&idio16gpio->lock, flags);
+}
+
 static void idio_16_irq_ack(struct irq_data *data)
 {
 }
@@ -219,6 +238,7 @@ static int idio_16_probe(struct device *dev, unsigned int id)
 	idio16gpio->chip.direction_output = idio_16_gpio_direction_output;
 	idio16gpio->chip.get = idio_16_gpio_get;
 	idio16gpio->chip.set = idio_16_gpio_set;
+	idio16gpio->chip.set_multiple = idio_16_gpio_set_multiple;
 	idio16gpio->base = base[id];
 	idio16gpio->irq = irq[id];
 	idio16gpio->out_state = 0xFFFF;
-- 
2.11.0

[toc] | [prev] | [next] | [standalone]


#1567254 — Re: [PATCH 2/5] gpio: 104-idio-16: Add set_multiple callback function support

FromLinus Walleij <linus.walleij@linaro.org>
Date2017-01-26 11:00 +0100
SubjectRe: [PATCH 2/5] gpio: 104-idio-16: Add set_multiple callback function support
Message-ID<t3P0v-5Js-37@gated-at.bofh.it>
In reply to#1562809
On Thu, Jan 19, 2017 at 4:05 PM, William Breathitt Gray
<vilhelm.gray@gmail.com> wrote:

> The ACCES 104-IDIO-16 series provides registers where 8 lines of GPIO
> may be set at a time. This patch add support for the set_multiple
> callback function, thus allowing multiple GPIO output lines to be set
> more efficiently in groups.
>
> Signed-off-by: William Breathitt Gray <vilhelm.gray@gmail.com>

Patch applied.

Yours,
Linus Walleij

[toc] | [prev] | [next] | [standalone]


#1562810 — [PATCH 4/5] gpio: ws16c48: Add set_multiple callback function support

FromWilliam Breathitt Gray <vilhelm.gray@gmail.com>
Date2017-01-19 16:10 +0100
Subject[PATCH 4/5] gpio: ws16c48: Add set_multiple callback function support
Message-ID<t1mvE-38y-23@gated-at.bofh.it>
In reply to#1562806
The WinSystems WS16C48 provides registers where 8 lines of GPIO may be
set at a time. This patch add support for the set_multiple callback
function, thus allowing multiple GPIO output lines to be set more
efficiently in groups.

Signed-off-by: William Breathitt Gray <vilhelm.gray@gmail.com>
---
 drivers/gpio/gpio-ws16c48.c | 41 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)

diff --git a/drivers/gpio/gpio-ws16c48.c b/drivers/gpio/gpio-ws16c48.c
index eaa71d440ccf..25e539530c08 100644
--- a/drivers/gpio/gpio-ws16c48.c
+++ b/drivers/gpio/gpio-ws16c48.c
@@ -155,6 +155,46 @@ static void ws16c48_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
 	spin_unlock_irqrestore(&ws16c48gpio->lock, flags);
 }
 
+static void ws16c48_gpio_set_multiple(struct gpio_chip *chip,
+	unsigned long *mask, unsigned long *bits)
+{
+	struct ws16c48_gpio *const ws16c48gpio = gpiochip_get_data(chip);
+	unsigned int i;
+	const unsigned int gpio_reg_size = 8;
+	unsigned int port;
+	unsigned int iomask;
+	unsigned int bitmask;
+	unsigned long flags;
+
+	/* set bits are evaluated a gpio register size at a time */
+	for (i = 0; i < chip->ngpio; i += gpio_reg_size) {
+		/* no more set bits in this mask word; skip to the next word */
+		if (!mask[BIT_WORD(i)]) {
+			i = (BIT_WORD(i) + 1) * BITS_PER_LONG - gpio_reg_size;
+			continue;
+		}
+
+		port = i / gpio_reg_size;
+
+		/* mask out GPIO configured for input */
+		iomask = mask[BIT_WORD(i)] & ~ws16c48gpio->io_state[port];
+		bitmask = iomask & bits[BIT_WORD(i)];
+
+		spin_lock_irqsave(&ws16c48gpio->lock, flags);
+
+		/* update output state data and set device gpio register */
+		ws16c48gpio->out_state[port] &= ~iomask;
+		ws16c48gpio->out_state[port] |= bitmask;
+		outb(ws16c48gpio->out_state[port], ws16c48gpio->base + port);
+
+		spin_unlock_irqrestore(&ws16c48gpio->lock, flags);
+
+		/* prepare for next gpio register set */
+		mask[BIT_WORD(i)] >>= gpio_reg_size;
+		bits[BIT_WORD(i)] >>= gpio_reg_size;
+	}
+}
+
 static void ws16c48_irq_ack(struct irq_data *data)
 {
 	struct gpio_chip *chip = irq_data_get_irq_chip_data(data);
@@ -329,6 +369,7 @@ static int ws16c48_probe(struct device *dev, unsigned int id)
 	ws16c48gpio->chip.direction_output = ws16c48_gpio_direction_output;
 	ws16c48gpio->chip.get = ws16c48_gpio_get;
 	ws16c48gpio->chip.set = ws16c48_gpio_set;
+	ws16c48gpio->chip.set_multiple = ws16c48_gpio_set_multiple;
 	ws16c48gpio->base = base[id];
 	ws16c48gpio->irq = irq[id];
 
-- 
2.11.0

[toc] | [prev] | [next] | [standalone]


#1567252 — Re: [PATCH 4/5] gpio: ws16c48: Add set_multiple callback function support

FromLinus Walleij <linus.walleij@linaro.org>
Date2017-01-26 11:00 +0100
SubjectRe: [PATCH 4/5] gpio: ws16c48: Add set_multiple callback function support
Message-ID<t3P0u-5Js-29@gated-at.bofh.it>
In reply to#1562810
On Thu, Jan 19, 2017 at 4:05 PM, William Breathitt Gray
<vilhelm.gray@gmail.com> wrote:

> The WinSystems WS16C48 provides registers where 8 lines of GPIO may be
> set at a time. This patch add support for the set_multiple callback
> function, thus allowing multiple GPIO output lines to be set more
> efficiently in groups.
>
> Signed-off-by: William Breathitt Gray <vilhelm.gray@gmail.com>

Patch applied.

Yours,
Linus Walleij

[toc] | [prev] | [next] | [standalone]


#1562817 — [PATCH 5/5] iio: stx104: Add GPIO set_multiple callback function support

FromWilliam Breathitt Gray <vilhelm.gray@gmail.com>
Date2017-01-19 16:20 +0100
Subject[PATCH 5/5] iio: stx104: Add GPIO set_multiple callback function support
Message-ID<t1mFj-3bS-15@gated-at.bofh.it>
In reply to#1562806
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(+)

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

[toc] | [prev] | [next] | [standalone]


#1564399 — Re: [PATCH 5/5] iio: stx104: Add GPIO set_multiple callback function support

FromJonathan Cameron <jic23@kernel.org>
Date2017-01-22 14:30 +0100
SubjectRe: [PATCH 5/5] iio: stx104: Add GPIO set_multiple callback function support
Message-ID<t2qnv-1hi-9@gated-at.bofh.it>
In reply to#1562817
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;
>  
> 

[toc] | [prev] | [next] | [standalone]


#1564400 — Re: [PATCH 5/5] iio: stx104: Add GPIO set_multiple callback function support

FromLinus Walleij <linus.walleij@linaro.org>
Date2017-01-22 14:40 +0100
SubjectRe: [PATCH 5/5] iio: stx104: Add GPIO set_multiple callback function support
Message-ID<t2qxb-1kJ-1@gated-at.bofh.it>
In reply to#1562817
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

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web