All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] dt-bindings: gpio-xilinx: Update no-init property
@ 2018-05-03  9:05 shubhrajyoti.datta
  2018-05-03  9:05 ` [PATCH 2/2] gpio: xilinx: Add support for no initialisation at probe shubhrajyoti.datta
  2018-05-16 12:12 ` [PATCH 1/2] dt-bindings: gpio-xilinx: Update no-init property Linus Walleij
  0 siblings, 2 replies; 4+ messages in thread
From: shubhrajyoti.datta @ 2018-05-03  9:05 UTC (permalink / raw)
  To: linux-gpio, devicetree, git-dev
  Cc: linus.walleij, robh+dt, michals, Shubhrajyoti Datta

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

In some cases the user may not want to initialise the
gpios to default. Add a property to allow the same. This is specially
useful in case the PS is reset and PL is not.

Signed-off-by: Shubhrajyoti Datta <shubhrajyoti.datta@xilinx.com>
---
 Documentation/devicetree/bindings/gpio/gpio-xilinx.txt | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/gpio/gpio-xilinx.txt b/Documentation/devicetree/bindings/gpio/gpio-xilinx.txt
index 63bf4be..3a09d9e 100644
--- a/Documentation/devicetree/bindings/gpio/gpio-xilinx.txt
+++ b/Documentation/devicetree/bindings/gpio/gpio-xilinx.txt
@@ -25,6 +25,7 @@ Optional properties:
 - xlnx,dout-default-2 : as above but the second channel
 - xlnx,gpio2-width : as above but for the second channel
 - xlnx,tri-default-2 : as above but for the second channel
+- xlnx,no-init : No initialisation at probe
 
 
 Example:
-- 
2.1.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] gpio: xilinx: Add support for no initialisation at probe
  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
  2018-05-16 12:14   ` Linus Walleij
  2018-05-16 12:12 ` [PATCH 1/2] dt-bindings: gpio-xilinx: Update no-init property Linus Walleij
  1 sibling, 1 reply; 4+ messages in thread
From: shubhrajyoti.datta @ 2018-05-03  9:05 UTC (permalink / raw)
  To: linux-gpio, devicetree, git-dev
  Cc: linus.walleij, robh+dt, michals, Shubhrajyoti Datta

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


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] dt-bindings: gpio-xilinx: Update no-init property
  2018-05-03  9:05 [PATCH 1/2] dt-bindings: gpio-xilinx: Update no-init property shubhrajyoti.datta
  2018-05-03  9:05 ` [PATCH 2/2] gpio: xilinx: Add support for no initialisation at probe shubhrajyoti.datta
@ 2018-05-16 12:12 ` Linus Walleij
  1 sibling, 0 replies; 4+ messages in thread
From: Linus Walleij @ 2018-05-16 12:12 UTC (permalink / raw)
  To: Shubhrajyoti Datta
  Cc: open list:GPIO SUBSYSTEM,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	git-dev, Rob Herring, michals, Shubhrajyoti Datta

On Thu, May 3, 2018 at 11:05 AM,  <shubhrajyoti.datta@gmail.com> wrote:

> From: Shubhrajyoti Datta <shubhrajyoti.datta@xilinx.com>
>
> In some cases the user may not want to initialise the
> gpios to default. Add a property to allow the same. This is specially
> useful in case the PS is reset and PL is not.
>
> Signed-off-by: Shubhrajyoti Datta <shubhrajyoti.datta@xilinx.com>
(...)
> @@ -25,6 +25,7 @@ Optional properties:
>  - xlnx,dout-default-2 : as above but the second channel
>  - xlnx,gpio2-width : as above but for the second channel
>  - xlnx,tri-default-2 : as above but for the second channel
> +- xlnx,no-init : No initialisation at probe

This doesn't seem very Xilinx-specific? It looks more like something
any GPIO driver would want to do.

So a no-init-hardware; in gpio.txt seems more appropriate,
if this is even needed, see comments on next patch.

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] gpio: xilinx: Add support for no initialisation at probe
  2018-05-03  9:05 ` [PATCH 2/2] gpio: xilinx: Add support for no initialisation at probe shubhrajyoti.datta
@ 2018-05-16 12:14   ` Linus Walleij
  0 siblings, 0 replies; 4+ messages in thread
From: Linus Walleij @ 2018-05-16 12:14 UTC (permalink / raw)
  To: Shubhrajyoti Datta, michals
  Cc: open list:GPIO SUBSYSTEM,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	git-dev, Rob Herring, Shubhrajyoti Datta

On Thu, May 3, 2018 at 11:05 AM,  <shubhrajyoti.datta@gmail.com> wrote:

> 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>

Usually the recommendation is to leave electronics in the
power-on-state until their state is explicitly changed.

Is it possible to just make the new "no-init" behaviour
the default? Do we even need to keep the initialization code?

Michal?

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-05-16 12:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-03  9:05 [PATCH 1/2] dt-bindings: gpio-xilinx: Update no-init property shubhrajyoti.datta
2018-05-03  9:05 ` [PATCH 2/2] gpio: xilinx: Add support for no initialisation at probe shubhrajyoti.datta
2018-05-16 12:14   ` Linus Walleij
2018-05-16 12:12 ` [PATCH 1/2] dt-bindings: gpio-xilinx: Update no-init property Linus Walleij

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.