Add GPIO set_multiple callback support for ISA_BUS_API drivers
Subsystems (6)
cover Add GPIO set_multiple callback support for ISA_BUS_API drivers
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(+)
Signature · 1 line
2.11.0
PATCH 1/5 gpio: 104-dio-48e: Add set_multiple callback function support
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.
--- drivers/gpio/gpio-104-dio-48e.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+)
drivers/gpio/gpio-104-dio-48e.c +39 -0
@@ -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];
Signature · 1 line
2.11.0
Re: [PATCH 1/5] gpio: 104-dio-48e: Add set_multiple callback function support
Quoted 6 lines · William Breathitt Gray
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_multiplecallback function, thus allowing multiple GPIO output lines to be set more efficiently in groups.Signed-off-by William Breathitt Gray <[email protected]>
Patch applied.
Yours,
Linus Walleij
PATCH 2/5 gpio: 104-idio-16: Add set_multiple callback function support
In reply to William Breathitt GrayThe 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.
--- drivers/gpio/gpio-104-idio-16.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
drivers/gpio/gpio-104-idio-16.c +20 -0
@@ -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 ;
Signature · 1 line
2.11.0
Re: [PATCH 2/5] gpio: 104-idio-16: Add set_multiple callback function support
Quoted 6 lines · William Breathitt Gray
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_multiplecallback function, thus allowing multiple GPIO output lines to be set more efficiently in groups.Signed-off-by William Breathitt Gray <[email protected]>
Patch applied.
Yours,
Linus Walleij
PATCH 3/5 gpio: gpio-mm: Add set_multiple callback function support
In reply to William Breathitt GrayThe Diamond Systems GPIO-MM 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.
--- drivers/gpio/gpio-gpio-mm.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+)
drivers/gpio/gpio-gpio-mm.c +39 -0
@@ -192,6 +192,44 @@ static void gpiomm_gpio_set(struct gpio_chip *chip, unsigned int offset,spin_unlock_irqrestore (&gpiommgpio->lock, flags); } +static void gpiomm_gpio_set_multiple (struct gpio_chip *chip, +unsigned long *mask,unsigned long *bits) +{ +struct gpiomm_gpio *const gpiommgpio =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 (&gpiommgpio->lock, flags); + +/* update output state data and set device gpio register */ + gpiommgpio->out_state[port] &= ~mask[BIT_WORD (i)]; + gpiommgpio->out_state[port] |= bitmask; +outb (gpiommgpio->out_state[port], gpiommgpio->base + out_port); + +spin_unlock_irqrestore (&gpiommgpio->lock, flags); + +/* prepare for next gpio register set */ + mask[BIT_WORD (i)] >>= gpio_reg_size; + bits[BIT_WORD (i)] >>= gpio_reg_size; + } +} +static int gpiomm_probe (struct device *dev,unsigned int id) {struct gpiomm_gpio *gpiommgpio;
@@ -218,6 +256,7 @@ static int gpiomm_probe(struct device *dev, unsigned int id) gpiommgpio->chip.direction_output = gpiomm_gpio_direction_output; gpiommgpio->chip.get = gpiomm_gpio_get; gpiommgpio->chip.set = gpiomm_gpio_set; + gpiommgpio->chip.set_multiple = gpiomm_gpio_set_multiple; gpiommgpio->base = base[id];spin_lock_init (&gpiommgpio->lock);
Signature · 1 line
2.11.0
Re: [PATCH 3/5] gpio: gpio-mm: Add set_multiple callback function support
Quoted 6 lines · William Breathitt Gray
The Diamond Systems GPIO-MM series provides registers where 8 lines of GPIO may be set at a time. This patch add support for the
set_multiplecallback function, thus allowing multiple GPIO output lines to be set more efficiently in groups.Signed-off-by William Breathitt Gray <[email protected]>
Patch applied.
Yours,
Linus Walleij
PATCH 4/5 gpio: ws16c48: Add set_multiple callback function support
In reply to William Breathitt GrayThe 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.
--- drivers/gpio/gpio-ws16c48.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+)
drivers/gpio/gpio-ws16c48.c +41 -0
@@ -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];
Signature · 1 line
2.11.0
Re: [PATCH 4/5] gpio: ws16c48: Add set_multiple callback function support
Quoted 6 lines · William Breathitt Gray
The WinSystems WS16C48 provides registers where 8 lines of GPIO may be set at a time. This patch add support for the
set_multiplecallback function, thus allowing multiple GPIO output lines to be set more efficiently in groups.Signed-off-by William Breathitt Gray <[email protected]>
Patch applied.
Yours,
Linus Walleij
PATCH 5/5 iio: stx104: Add GPIO set_multiple callback function support
In reply to William Breathitt GrayThe 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.
--- drivers/iio/adc/stx104.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)
drivers/iio/adc/stx104.c +23 -0
@@ -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 ;
Signature · 1 line
2.11.0
Re: [PATCH 5/5] iio: stx104: Add GPIO set_multiple callback function support
Quoted 10 lines · William Breathitt Gray
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_multiplecallback function, thus allowing multiple digital output lines to be set more efficiently in groups.Cc Jonathan Cameron <[email protected]>Cc Hartmut Knaack <[email protected]>Cc Lars-Peter Clausen <[email protected]>Cc Peter Meerwald-Stadler <[email protected]>Signed-off-by William Breathitt Gray <[email protected]>
Quoted 46 lines
--- drivers/iio/adc/stx104.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)drivers/iio/adc/stx104.c +23
-0@@ -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 ;
Re: [PATCH 5/5] iio: stx104: Add GPIO set_multiple callback function support
Quoted 6 lines · Jonathan Cameron
Quoted 5 lines · William Breathitt Gray
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_multiplecallback function, thus allowing multiple digital output lines to be set more efficiently in groups.
Quoted 6 lines
Quoted 5 lines
Cc Jonathan Cameron <[email protected]>Cc Hartmut Knaack <[email protected]>Cc Lars-Peter Clausen <[email protected]>Cc Peter Meerwald-Stadler <[email protected]>Signed-off-by William Breathitt Gray <[email protected]>Acked-by Jonathan Cameron <[email protected]>
Jonathan Cameron,
Would you pick this patch up in one of your iio.git branches?
Thanks,
William Breathitt Gray
Jonathan Cameron
maintainerRe: [PATCH 5/5] iio: stx104: Add GPIO set_multiple callback function support
Quoted 12 lines · William Breathitt Gray
Quoted 11 lines · Jonathan Cameron
Quoted 10 lines · William Breathitt Gray
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_multiplecallback function, thus allowing multiple digital output lines to be set more efficiently in groups.Cc Jonathan Cameron <[email protected]>Cc Hartmut Knaack <[email protected]>Cc Lars-Peter Clausen <[email protected]>Cc Peter Meerwald-Stadler <[email protected]>Signed-off-by William Breathitt Gray <[email protected]>
Quoted 5 lines
Quoted 1 line
Acked-by Jonathan Cameron <[email protected]>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
Quoted 5 lines
Thanks,
William Breathitt Gray
Re: [PATCH 5/5] iio: stx104: Add GPIO set_multiple callback function support
In reply to William Breathitt GrayQuoted 10 lines · William Breathitt Gray
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_multiplecallback function, thus allowing multiple digital output lines to be set more efficiently in groups.Cc Jonathan Cameron <[email protected]>Cc Hartmut Knaack <[email protected]>Cc Lars-Peter Clausen <[email protected]>Cc Peter Meerwald-Stadler <[email protected]>Signed-off-by William Breathitt Gray <[email protected]>
Best if Jonathan queues this so the changes reside in the IIO tree.
Yours,
Linus Walleij