linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Fried, Ramon" <ramon.fried@linux.intel.com>
To: linus.walleij@linaro.org, bgolaszewski@baylibre.com,
	linux-gpio@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, vladimir.kondratiev@linux.intel.com
Subject: RFC: gpio: mmio: add support for 3 direction regs
Date: Thu, 3 Jan 2019 09:36:04 +0200	[thread overview]
Message-ID: <32edfd70-95dc-26a1-2ea6-143344cb2384@linux.intel.com> (raw)

Hi.

I'm working on a driver for STA2X11 GPIO controller who seems to fit best to the generic mmio driver,
the only problem I have is with the dir register case.
The STA2X11 has 3 registers for dir, one for data, one for set and one for clear.
The generic-mmio driver has support for this fashion for the dat & set & clear registers but not for dirout/dirin registers.

I wonder if support for this is generic enough to deserve a patch, if so I'm willing to quickly add this support, if not, adding a flag such as below, will allow partly using the generic mmio driver only for set/get and the direction can be handled outside the driver.

Thanks,
Ramon

diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h
index a4d5eb3..4f91526 100644
--- a/include/linux/gpio/driver.h
+++ b/include/linux/gpio/driver.h
@@ -435,6 +435,7 @@ int bgpio_init(struct gpio_chip *gc, struct device *dev,
 #define BGPIOF_BIG_ENDIAN_BYTE_ORDER   BIT(3)
 #define BGPIOF_READ_OUTPUT_REG_SET     BIT(4) /* reg_set stores output value */
 #define BGPIOF_NO_OUTPUT               BIT(5) /* only input */
+#define BGPIOF_NO_DIRECTION            BIT(6)
 
 #endif

diff --git a/drivers/gpio/gpio-mmio.c b/drivers/gpio/gpio-mmio.c
index 935292a..66f6448 100644
--- a/drivers/gpio/gpio-mmio.c
+++ b/drivers/gpio/gpio-mmio.c
@@ -554,6 +554,8 @@ static int bgpio_setup_direction(struct gpio_chip *gc,
                gc->direction_input = bgpio_dir_in;
                gc->get_direction = bgpio_get_dir;
                gc->bgpio_dir_inverted = true;
+       } else if (flags & BGPIOF_NO_DIRECTION) {
+               return 0;
        } else {
                if (flags & BGPIOF_NO_OUTPUT)
                        gc->direction_output = bgpio_dir_out_err;
@@ -638,7 +640,7 @@ int bgpio_init(struct gpio_chip *gc, struct device *dev,
        if (gc->set == bgpio_set_set &&
                        !(flags & BGPIOF_UNREADABLE_REG_SET))
                gc->bgpio_data = gc->read_reg(gc->reg_set);
-       if (gc->reg_dir && !(flags & BGPIOF_UNREADABLE_REG_DIR))
+       if (gc->reg_dir && !(flags & (BGPIOF_UNREADABLE_REG_DIR | BGPIOF_NO_DIRECTION)))
                gc->bgpio_dir = gc->read_reg(gc->reg_dir);
 
        return ret;


             reply	other threads:[~2019-01-03  7:36 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-03  7:36 Fried, Ramon [this message]
2019-01-03  8:07 ` RFC: gpio: mmio: add support for 3 direction regs Vladimir Zapolskiy
2019-01-03  8:51   ` Fried, Ramon
2019-01-03  8:59     ` Vladimir Zapolskiy
2019-01-03  9:30       ` Fried, Ramon

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=32edfd70-95dc-26a1-2ea6-143344cb2384@linux.intel.com \
    --to=ramon.fried@linux.intel.com \
    --cc=bgolaszewski@baylibre.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=vladimir.kondratiev@linux.intel.com \
    /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).