* [PATCH] gpio: rcar: Implement gpiochip.set_multiple()
@ 2016-03-14 15:21 Geert Uytterhoeven
2016-03-22 10:52 ` Linus Walleij
0 siblings, 1 reply; 2+ messages in thread
From: Geert Uytterhoeven @ 2016-03-14 15:21 UTC (permalink / raw)
To: Linus Walleij, Alexandre Courbot, Magnus Damm
Cc: linux-gpio, linux-renesas-soc, linux-kernel, Geert Uytterhoeven
This allows to set multiple outputs using a single register write.
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
drivers/gpio/gpio-rcar.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/drivers/gpio/gpio-rcar.c b/drivers/gpio/gpio-rcar.c
index d9ab0cd1d2059635..3fe8e773d95c3b62 100644
--- a/drivers/gpio/gpio-rcar.c
+++ b/drivers/gpio/gpio-rcar.c
@@ -336,6 +336,25 @@ static void gpio_rcar_set(struct gpio_chip *chip, unsigned offset, int value)
spin_unlock_irqrestore(&p->lock, flags);
}
+static void gpio_rcar_set_multiple(struct gpio_chip *chip, unsigned long *mask,
+ unsigned long *bits)
+{
+ struct gpio_rcar_priv *p = gpiochip_get_data(chip);
+ unsigned long flags;
+ u32 val, bankmask;
+
+ bankmask = mask[0] & GENMASK(chip->ngpio - 1, 0);
+ if (!bankmask)
+ return;
+
+ spin_lock_irqsave(&p->lock, flags);
+ val = gpio_rcar_read(p, OUTDT);
+ val &= ~bankmask;
+ val |= (bankmask & bits[0]);
+ gpio_rcar_write(p, OUTDT, val);
+ spin_unlock_irqrestore(&p->lock, flags);
+}
+
static int gpio_rcar_direction_output(struct gpio_chip *chip, unsigned offset,
int value)
{
@@ -476,6 +495,7 @@ static int gpio_rcar_probe(struct platform_device *pdev)
gpio_chip->get = gpio_rcar_get;
gpio_chip->direction_output = gpio_rcar_direction_output;
gpio_chip->set = gpio_rcar_set;
+ gpio_chip->set_multiple = gpio_rcar_set_multiple;
gpio_chip->label = name;
gpio_chip->parent = dev;
gpio_chip->owner = THIS_MODULE;
--
1.9.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] gpio: rcar: Implement gpiochip.set_multiple()
2016-03-14 15:21 [PATCH] gpio: rcar: Implement gpiochip.set_multiple() Geert Uytterhoeven
@ 2016-03-22 10:52 ` Linus Walleij
0 siblings, 0 replies; 2+ messages in thread
From: Linus Walleij @ 2016-03-22 10:52 UTC (permalink / raw)
To: Geert Uytterhoeven
Cc: Alexandre Courbot, Magnus Damm, linux-gpio, linux-renesas-soc,
linux-kernel
On Mon, Mar 14, 2016 at 4:21 PM, Geert Uytterhoeven
<geert+renesas@glider.be> wrote:
> This allows to set multiple outputs using a single register write.
>
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Patch applied for v4.7.
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-03-22 10:54 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-14 15:21 [PATCH] gpio: rcar: Implement gpiochip.set_multiple() Geert Uytterhoeven
2016-03-22 10:52 ` Linus Walleij
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).