Devicetree
 help / color / mirror / Atom feed
From: <shubhrajyoti.datta@gmail.com>
To: linux-gpio@vger.kernel.org, devicetree@vger.kernel.org,
	git-dev@xilinx.com
Cc: linus.walleij@linaro.org, robh+dt@kernel.org, michals@xilinx.com,
	Shubhrajyoti Datta <shubhrajyoti.datta@xilinx.com>
Subject: [PATCH 2/2] gpio: xilinx: Add support for no initialisation at probe
Date: Thu, 3 May 2018 14:35:46 +0530	[thread overview]
Message-ID: <1525338346-31684-2-git-send-email-shubhrajyoti.datta@gmail.com> (raw)
In-Reply-To: <1525338346-31684-1-git-send-email-shubhrajyoti.datta@gmail.com>

From: Shubhrajyoti Datta <shubhrajyoti.datta@xilinx.com>

Add a dt property to indicate no initialisation at probe.
In some cases the user may want no initialisation of the
gpios. For example PS only reset the user may not want the
re-initialisation of the ip.

Signed-off-by: Shubhrajyoti Datta <shubhrajyoti.datta@xilinx.com>
---
 drivers/gpio/gpio-xilinx.c | 44 ++++++++++++++++++++++++++++++++++----------
 1 file changed, 34 insertions(+), 10 deletions(-)

diff --git a/drivers/gpio/gpio-xilinx.c b/drivers/gpio/gpio-xilinx.c
index e8ec0e3..06988f1 100644
--- a/drivers/gpio/gpio-xilinx.c
+++ b/drivers/gpio/gpio-xilinx.c
@@ -41,6 +41,7 @@
 /**
  * struct xgpio_instance - Stores information about GPIO device
  * @mmchip: OF GPIO chip for memory mapped banks
+ * @no_init: No intitialisation at probe
  * @gpio_width: GPIO width for every channel
  * @gpio_state: GPIO state shadow register
  * @gpio_dir: GPIO direction shadow register
@@ -48,6 +49,7 @@
  */
 struct xgpio_instance {
 	struct of_mm_gpio_chip mmchip;
+	bool no_init;
 	unsigned int gpio_width[2];
 	u32 gpio_state[2];
 	u32 gpio_dir[2];
@@ -257,16 +259,36 @@ static void xgpio_save_regs(struct of_mm_gpio_chip *mm_gc)
 	struct xgpio_instance *chip =
 		container_of(mm_gc, struct xgpio_instance, mmchip);
 
-	xgpio_writereg(mm_gc->regs + XGPIO_DATA_OFFSET,	chip->gpio_state[0]);
-	xgpio_writereg(mm_gc->regs + XGPIO_TRI_OFFSET, chip->gpio_dir[0]);
-
-	if (!chip->gpio_width[1])
-		return;
-
-	xgpio_writereg(mm_gc->regs + XGPIO_DATA_OFFSET + XGPIO_CHANNEL_OFFSET,
-		       chip->gpio_state[1]);
-	xgpio_writereg(mm_gc->regs + XGPIO_TRI_OFFSET + XGPIO_CHANNEL_OFFSET,
-		       chip->gpio_dir[1]);
+	if (chip->no_init) {
+		chip->gpio_state[0] = xgpio_readreg(mm_gc->regs +
+						    XGPIO_DATA_OFFSET);
+		chip->gpio_dir[0] =  xgpio_readreg(mm_gc->regs +
+						   XGPIO_TRI_OFFSET);
+
+		if (!chip->gpio_width[1])
+			return;
+
+		chip->gpio_state[1] = xgpio_readreg(mm_gc->regs +
+						    XGPIO_DATA_OFFSET +
+						    XGPIO_CHANNEL_OFFSET);
+		chip->gpio_dir[1] = xgpio_readreg(mm_gc->regs +
+						   XGPIO_TRI_OFFSET +
+						   XGPIO_CHANNEL_OFFSET);
+
+	} else {
+		xgpio_writereg(mm_gc->regs + XGPIO_DATA_OFFSET,
+			       chip->gpio_state[0]);
+		xgpio_writereg(mm_gc->regs + XGPIO_TRI_OFFSET,
+			       chip->gpio_dir[0]);
+
+		if (!chip->gpio_width[1])
+			return;
+
+		xgpio_writereg(mm_gc->regs + XGPIO_DATA_OFFSET +
+			       XGPIO_CHANNEL_OFFSET, chip->gpio_state[1]);
+		xgpio_writereg(mm_gc->regs + XGPIO_TRI_OFFSET +
+			       XGPIO_CHANNEL_OFFSET, chip->gpio_dir[1]);
+	}
 }
 
 /**
@@ -323,6 +345,8 @@ static int xgpio_probe(struct platform_device *pdev)
 
 	spin_lock_init(&chip->gpio_lock[0]);
 
+	chip->no_init = of_property_read_bool(np, "xlnx,no-init");
+
 	if (of_property_read_u32(np, "xlnx,is-dual", &is_dual))
 		is_dual = 0;
 
-- 
2.1.1


  reply	other threads:[~2018-05-03  9:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-03  9:05 [PATCH 1/2] dt-bindings: gpio-xilinx: Update no-init property shubhrajyoti.datta
2018-05-03  9:05 ` shubhrajyoti.datta [this message]
2018-05-16 12:14   ` [PATCH 2/2] gpio: xilinx: Add support for no initialisation at probe Linus Walleij
2018-05-16 12:12 ` [PATCH 1/2] dt-bindings: gpio-xilinx: Update no-init property Linus Walleij

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=1525338346-31684-2-git-send-email-shubhrajyoti.datta@gmail.com \
    --to=shubhrajyoti.datta@gmail.com \
    --cc=devicetree@vger.kernel.org \
    --cc=git-dev@xilinx.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=michals@xilinx.com \
    --cc=robh+dt@kernel.org \
    --cc=shubhrajyoti.datta@xilinx.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