devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Jeffery <andrew@aj.id.au>
To: linux-gpio@vger.kernel.org
Cc: Andrew Jeffery <andrew@aj.id.au>,
	linus.walleij@linaro.org, corbet@lwn.net, joel@jms.id.au,
	ryan_chen@aspeedtech.com, robh+dt@kernel.org,
	frowand.list@gmail.com, ckeepax@opensource.wolfsonmicro.com,
	ldewangan@nvidia.com, linux-doc@vger.kernel.org,
	linux-kernel@vger.kernel.org, patches@opensource.cirrus.com,
	devicetree@vger.kernel.org, openbmc@lists.ozlabs.org,
	linux-aspeed@lists.ozlabs.org
Subject: [RFC PATCH 2/5] gpio: gpiolib: Add OF support for maintaining GPIO values on reset
Date: Fri, 20 Oct 2017 14:07:24 +1030	[thread overview]
Message-ID: <20171020033727.21557-3-andrew@aj.id.au> (raw)
In-Reply-To: <20171020033727.21557-1-andrew@aj.id.au>

Add flags and the associated flag mappings between interfaces to enable
GPIO reset tolerance to be specified via devicetree.

Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
---
 drivers/gpio/gpiolib-of.c       | 2 ++
 drivers/gpio/gpiolib.c          | 5 +++++
 include/dt-bindings/gpio/gpio.h | 4 ++++
 include/linux/of_gpio.h         | 1 +
 4 files changed, 12 insertions(+)

diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c
index e0d59e61b52f..4a268ba52998 100644
--- a/drivers/gpio/gpiolib-of.c
+++ b/drivers/gpio/gpiolib-of.c
@@ -155,6 +155,8 @@ struct gpio_desc *of_find_gpio(struct device *dev, const char *con_id,
 
 	if (of_flags & OF_GPIO_SLEEP_MAY_LOSE_VALUE)
 		*flags |= GPIO_SLEEP_MAY_LOSE_VALUE;
+	if (of_flags & OF_GPIO_RESET_TOLERANT)
+		*flags |= GPIO_RESET_TOLERANT;
 
 	return desc;
 }
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index d9dc7e588699..6b4c5df10e84 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -3434,6 +3434,7 @@ struct gpio_desc *fwnode_get_named_gpiod(struct fwnode_handle *fwnode,
 	bool active_low = false;
 	bool single_ended = false;
 	bool open_drain = false;
+	bool reset_tolerant = false;
 	int ret;
 
 	if (!fwnode)
@@ -3448,6 +3449,7 @@ struct gpio_desc *fwnode_get_named_gpiod(struct fwnode_handle *fwnode,
 			active_low = flags & OF_GPIO_ACTIVE_LOW;
 			single_ended = flags & OF_GPIO_SINGLE_ENDED;
 			open_drain = flags & OF_GPIO_OPEN_DRAIN;
+			reset_tolerant = flags & OF_GPIO_RESET_TOLERANT;
 		}
 	} else if (is_acpi_node(fwnode)) {
 		struct acpi_gpio_info info;
@@ -3478,6 +3480,9 @@ struct gpio_desc *fwnode_get_named_gpiod(struct fwnode_handle *fwnode,
 			lflags |= GPIO_OPEN_SOURCE;
 	}
 
+	if (reset_tolerant)
+		lflags |= GPIO_RESET_TOLERANT;
+
 	ret = gpiod_configure_flags(desc, propname, lflags, dflags);
 	if (ret < 0) {
 		gpiod_put(desc);
diff --git a/include/dt-bindings/gpio/gpio.h b/include/dt-bindings/gpio/gpio.h
index 70de5b7a6c9b..01c75d9e308e 100644
--- a/include/dt-bindings/gpio/gpio.h
+++ b/include/dt-bindings/gpio/gpio.h
@@ -32,4 +32,8 @@
 #define GPIO_SLEEP_MAINTAIN_VALUE 0
 #define GPIO_SLEEP_MAY_LOSE_VALUE 8
 
+/* Bit 4 express GPIO persistence on reset */
+#define GPIO_RESET_INTOLERANT 0
+#define GPIO_RESET_TOLERANT 16
+
 #endif
diff --git a/include/linux/of_gpio.h b/include/linux/of_gpio.h
index 1fe205582111..9b34737706a7 100644
--- a/include/linux/of_gpio.h
+++ b/include/linux/of_gpio.h
@@ -32,6 +32,7 @@ enum of_gpio_flags {
 	OF_GPIO_SINGLE_ENDED = 0x2,
 	OF_GPIO_OPEN_DRAIN = 0x4,
 	OF_GPIO_SLEEP_MAY_LOSE_VALUE = 0x8,
+	OF_GPIO_RESET_TOLERANT = 0x16,
 };
 
 #ifdef CONFIG_OF_GPIO
-- 
2.11.0

  parent reply	other threads:[~2017-10-20  3:37 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-20  3:37 [RFC PATCH 0/5] gpio: Expose reset tolerance capability Andrew Jeffery
2017-10-20  3:37 ` [RFC PATCH 1/5] gpio: gpiolib: Add core support for maintaining GPIO values on reset Andrew Jeffery
2017-10-20  7:17   ` Linus Walleij
2017-10-20  7:43     ` Linus Walleij
2017-10-20  8:32       ` Andrew Jeffery
2017-10-25  8:11         ` Charles Keepax
2017-10-26  0:00           ` Andrew Jeffery
2017-10-20  8:24     ` Andrew Jeffery
2017-10-20  3:37 ` Andrew Jeffery [this message]
     [not found]   ` <20171020033727.21557-3-andrew-zrmu5oMJ5Fs@public.gmane.org>
2017-10-20  7:18     ` [RFC PATCH 2/5] gpio: gpiolib: Add OF " Linus Walleij
2017-10-20  7:29       ` Andrew Jeffery
2017-10-20  3:37 ` [RFC PATCH 3/5] gpio: gpiolib: Add chardev " Andrew Jeffery
2017-10-20  7:27   ` Linus Walleij
2017-10-20  9:02     ` Andrew Jeffery
2017-10-25  8:14       ` Charles Keepax
2017-10-26  0:05         ` Andrew Jeffery
     [not found]           ` <1508976339.13477.5.camel-zrmu5oMJ5Fs@public.gmane.org>
2017-10-26  9:10             ` Charles Keepax
2017-10-31  9:59           ` Linus Walleij
2017-10-20  3:37 ` [RFC PATCH 4/5] gpio: gpiolib: Add sysfs " Andrew Jeffery
     [not found]   ` <20171020033727.21557-5-andrew-zrmu5oMJ5Fs@public.gmane.org>
2017-10-20  7:29     ` Linus Walleij
2017-10-20  7:40       ` Andrew Jeffery
2017-10-20  3:37 ` [RFC PATCH 5/5] gpio: aspeed: Add support for reset tolerance Andrew Jeffery

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=20171020033727.21557-3-andrew@aj.id.au \
    --to=andrew@aj.id.au \
    --cc=ckeepax@opensource.wolfsonmicro.com \
    --cc=corbet@lwn.net \
    --cc=devicetree@vger.kernel.org \
    --cc=frowand.list@gmail.com \
    --cc=joel@jms.id.au \
    --cc=ldewangan@nvidia.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-aspeed@lists.ozlabs.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=openbmc@lists.ozlabs.org \
    --cc=patches@opensource.cirrus.com \
    --cc=robh+dt@kernel.org \
    --cc=ryan_chen@aspeedtech.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).