From: Rojhalat Ibrahim <imr@rtschenk.de>
To: linux-gpio@vger.kernel.org
Cc: Alexandre Courbot <gnurou@gmail.com>, Gerhard Sittig <gsi@denx.de>
Subject: [RFC PATCH 2/2] gpio-mpc8xxx: add mpc8xxx_gpio_set_multiple function
Date: Wed, 21 May 2014 15:00:14 +0200 [thread overview]
Message-ID: <3728352.HA8JhAoUDB@pcimr> (raw)
In-Reply-To: <1883250.Le7v5oGnod@pcimr>
This patch adds a set_multiple function to the MPC8xxx GPIO chip driver.
It depends on my previous patch "gpiolib: allow simultaneous setting of
multiple GPIO outputs" and allows for actual performance improvements when
setting multiple outputs simultaneously. In my case the time needed to
configure an FPGA goes down from 48 s to 19 s.
Signed-off-by: Rojhalat Ibrahim <imr@rtschenk.de>
---
drivers/gpio/gpio-mpc8xxx.c | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/drivers/gpio/gpio-mpc8xxx.c b/drivers/gpio/gpio-mpc8xxx.c
index d7d6d72..d226f5c 100644
--- a/drivers/gpio/gpio-mpc8xxx.c
+++ b/drivers/gpio/gpio-mpc8xxx.c
@@ -105,6 +105,33 @@ static void mpc8xxx_gpio_set(struct gpio_chip *gc, unsigned int gpio, int val)
spin_unlock_irqrestore(&mpc8xxx_gc->lock, flags);
}
+static void mpc8xxx_gpio_set_multiple(struct gpio_chip *gc,
+ u32 *mask, u32 *bits)
+{
+ struct of_mm_gpio_chip *mm = to_of_mm_gpio_chip(gc);
+ struct mpc8xxx_gpio_chip *mpc8xxx_gc = to_mpc8xxx_gpio_chip(mm);
+ unsigned long flags;
+ int i;
+
+ spin_lock_irqsave(&mpc8xxx_gc->lock, flags);
+
+ for (i = 0; i < gc->ngpio; i++) {
+ if (*mask == 0)
+ break;
+ if (*mask & (1 << i)) {
+ if ((*bits >> i) & 1)
+ mpc8xxx_gc->data |= mpc8xxx_gpio2mask(i);
+ else
+ mpc8xxx_gc->data &= ~mpc8xxx_gpio2mask(i);
+ *mask &= ~(1 << i);
+ }
+ }
+
+ out_be32(mm->regs + GPIO_DAT, mpc8xxx_gc->data);
+
+ spin_unlock_irqrestore(&mpc8xxx_gc->lock, flags);
+}
+
static int mpc8xxx_gpio_dir_in(struct gpio_chip *gc, unsigned int gpio)
{
struct of_mm_gpio_chip *mm = to_of_mm_gpio_chip(gc);
@@ -344,6 +371,7 @@ static void __init mpc8xxx_add_controller(struct device_node *np)
gc->get = of_device_is_compatible(np, "fsl,mpc8572-gpio") ?
mpc8572_gpio_get : mpc8xxx_gpio_get;
gc->set = mpc8xxx_gpio_set;
+ gc->set_multiple = mpc8xxx_gpio_set_multiple;
gc->to_irq = mpc8xxx_gpio_to_irq;
ret = of_mm_gpiochip_add(np, mm_gc);
--
1.8.5.5
next prev parent reply other threads:[~2014-05-21 13:00 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-21 12:58 [RFC PATCH 1/2] gpiolib: allow simultaneous setting of multiple GPIO outputs Rojhalat Ibrahim
2014-05-21 13:00 ` Rojhalat Ibrahim [this message]
2014-05-22 16:54 ` [RFC PATCH 2/2] gpio-mpc8xxx: add mpc8xxx_gpio_set_multiple function Gerhard Sittig
2014-05-23 7:24 ` Rojhalat Ibrahim
2014-05-22 16:50 ` [RFC PATCH 1/2] gpiolib: allow simultaneous setting of multiple GPIO outputs Gerhard Sittig
2014-05-23 7:22 ` Rojhalat Ibrahim
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3728352.HA8JhAoUDB@pcimr \
--to=imr@rtschenk.de \
--cc=gnurou@gmail.com \
--cc=gsi@denx.de \
--cc=linux-gpio@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).