mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Jeremy Kerr <jk@ozlabs.org>, Joel Stanley <joel@jms.id.au>,
	Christopher Bostic <cbostic@linux.vnet.ibm.com>,
	Benjamin Herrenschmidt <benh@kernel.crashing.org>
Subject: [PATCH 05/15] fsi/fsi-master-gpio: Add "no-gpio-delays" option
Date: Tue, 29 May 2018 11:30:34 +1000	[thread overview]
Message-ID: <20180529013044.23815-6-benh@kernel.crashing.org> (raw)
In-Reply-To: <20180529013044.23815-1-benh@kernel.crashing.org>

This adds support for an optional device-tree property that
makes the driver skip all the delays around clocking the
GPIOs and set it in the device-tree of common POWER9 based
OpenPower platforms.

This useful on chips like the AST2500 where the GPIO block is
running at a fairly low clock frequency (25Mhz typically). In
this case, the delays are unnecessary and due to the low
precision of the timers, actually quite harmful in terms of
performance.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Reviewed-by: Christopher Bostic <cbostic@linux.vnet.ibm.com>
---
 arch/arm/boot/dts/aspeed-bmc-opp-romulus.dts  |  1 +
 .../boot/dts/aspeed-bmc-opp-witherspoon.dts   |  1 +
 arch/arm/boot/dts/aspeed-bmc-opp-zaius.dts    |  1 +
 drivers/fsi/fsi-master-gpio.c                 | 20 +++++++++++++++----
 4 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/arch/arm/boot/dts/aspeed-bmc-opp-romulus.dts b/arch/arm/boot/dts/aspeed-bmc-opp-romulus.dts
index 3a93ae77cde3..71cb9317d624 100644
--- a/arch/arm/boot/dts/aspeed-bmc-opp-romulus.dts
+++ b/arch/arm/boot/dts/aspeed-bmc-opp-romulus.dts
@@ -53,6 +53,7 @@
 		compatible = "fsi-master-gpio", "fsi-master";
 		#address-cells = <2>;
 		#size-cells = <0>;
+		no-gpio-delays;
 
 		clock-gpios = <&gpio ASPEED_GPIO(AA, 0) GPIO_ACTIVE_HIGH>;
 		data-gpios = <&gpio ASPEED_GPIO(AA, 2) GPIO_ACTIVE_HIGH>;
diff --git a/arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts b/arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts
index dab467463c99..97cf819309b5 100644
--- a/arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts
+++ b/arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts
@@ -126,6 +126,7 @@
 		compatible = "fsi-master-gpio", "fsi-master";
 		#address-cells = <2>;
 		#size-cells = <0>;
+		no-gpio-delays;
 
 		clock-gpios = <&gpio ASPEED_GPIO(AA, 0) GPIO_ACTIVE_HIGH>;
 		data-gpios = <&gpio ASPEED_GPIO(E, 0) GPIO_ACTIVE_HIGH>;
diff --git a/arch/arm/boot/dts/aspeed-bmc-opp-zaius.dts b/arch/arm/boot/dts/aspeed-bmc-opp-zaius.dts
index f3bc89a4262f..71a64730f080 100644
--- a/arch/arm/boot/dts/aspeed-bmc-opp-zaius.dts
+++ b/arch/arm/boot/dts/aspeed-bmc-opp-zaius.dts
@@ -86,6 +86,7 @@
 		compatible = "fsi-master-gpio", "fsi-master";
 		#address-cells = <2>;
 		#size-cells = <0>;
+		no-gpio-delays;
 
 		trans-gpios = <&gpio ASPEED_GPIO(O, 6) GPIO_ACTIVE_HIGH>;
 		enable-gpios = <&gpio ASPEED_GPIO(D, 0) GPIO_ACTIVE_HIGH>;
diff --git a/drivers/fsi/fsi-master-gpio.c b/drivers/fsi/fsi-master-gpio.c
index d6508bbad1fb..c82bbd35276e 100644
--- a/drivers/fsi/fsi-master-gpio.c
+++ b/drivers/fsi/fsi-master-gpio.c
@@ -62,6 +62,7 @@ struct fsi_master_gpio {
 	struct gpio_desc	*gpio_enable;	/* FSI enable */
 	struct gpio_desc	*gpio_mux;	/* Mux control */
 	bool			external_mode;
+	bool			no_delays;
 };
 
 #define CREATE_TRACE_POINTS
@@ -79,9 +80,11 @@ static void clock_toggle(struct fsi_master_gpio *master, int count)
 	int i;
 
 	for (i = 0; i < count; i++) {
-		ndelay(FSI_GPIO_STD_DLY);
+		if (!master->no_delays)
+			ndelay(FSI_GPIO_STD_DLY);
 		gpiod_set_value(master->gpio_clk, 0);
-		ndelay(FSI_GPIO_STD_DLY);
+		if (!master->no_delays)
+			ndelay(FSI_GPIO_STD_DLY);
 		gpiod_set_value(master->gpio_clk, 1);
 	}
 }
@@ -90,10 +93,12 @@ static int sda_clock_in(struct fsi_master_gpio *master)
 {
 	int in;
 
-	ndelay(FSI_GPIO_STD_DLY);
+	if (!master->no_delays)
+		ndelay(FSI_GPIO_STD_DLY);
 	gpiod_set_value(master->gpio_clk, 0);
 	in = gpiod_get_value(master->gpio_data);
-	ndelay(FSI_GPIO_STD_DLY);
+	if (!master->no_delays)
+		ndelay(FSI_GPIO_STD_DLY);
 	gpiod_set_value(master->gpio_clk, 1);
 	return in ? 1 : 0;
 }
@@ -677,6 +682,13 @@ static int fsi_master_gpio_probe(struct platform_device *pdev)
 	}
 	master->gpio_mux = gpio;
 
+	/*
+	 * Check if GPIO block is slow enought that no extra delays
+	 * are necessary. This improves performance on ast2500 by
+	 * an order of magnitude.
+	 */
+	master->no_delays = device_property_present(&pdev->dev, "no-gpio-delays");
+
 	master->master.n_links = 1;
 	master->master.flags = FSI_MASTER_FLAG_SWCLOCK;
 	master->master.read = fsi_master_gpio_read;
-- 
2.17.0

  parent reply	other threads:[~2018-05-29  1:31 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-29  1:30 [PATCH 00/15] fsi: Overall improvements and new SBE fifo driver Benjamin Herrenschmidt
2018-05-29  1:30 ` [PATCH 01/15] fsi: gpio: Trace busy count Benjamin Herrenschmidt
2018-05-29  1:30 ` [PATCH 02/15] fsi: gpio: Remove unused 'id' variable Benjamin Herrenschmidt
2018-05-29  1:30 ` [PATCH 03/15] fsi: gpio: Use a mutex to protect transfers Benjamin Herrenschmidt
2018-05-29  1:30 ` [PATCH 04/15] fsi/fsi-master-gpio: Sample input data on different clock phase Benjamin Herrenschmidt
2018-05-29  1:30 ` Benjamin Herrenschmidt [this message]
2018-05-29  1:42   ` [PATCH 05/15] fsi/fsi-master-gpio: Add "no-gpio-delays" option Benjamin Herrenschmidt
2018-05-29  1:43   ` [PATCH] dt-bindings: fsi-master-gpio: Document "no-gpio-delays" property Benjamin Herrenschmidt
2018-05-31 17:13     ` Rob Herring
2018-05-29  1:30 ` [PATCH 06/15] fsi/fsi-master-gpio: Reduce turnaround clocks Benjamin Herrenschmidt
2018-05-29  1:30 ` [PATCH 07/15] fsi/fsi-master-gpio: Reduce dpoll clocks Benjamin Herrenschmidt
2018-05-29  1:30 ` [PATCH 08/15] fsi/fsi-master-gpio: Delay sampling of FSI data input Benjamin Herrenschmidt
2018-05-29  1:30 ` [PATCH 09/15] fsi/gpio: Include command build in locked section Benjamin Herrenschmidt
2018-05-29  1:30 ` [PATCH 10/15] fsi/gpio: Use relative-addressing commands Benjamin Herrenschmidt
2018-05-29  1:30 ` [PATCH 11/15] fsi/fsi-master-gpio: Implement CRC error recovery Benjamin Herrenschmidt
2018-05-29  1:30 ` [PATCH 12/15] fsi/fsi-master-gpio: More error handling cleanup Benjamin Herrenschmidt
2018-05-29  1:30 ` [PATCH 13/15] fsi/master-gpio: Replace bit_bit lock with IRQ disable/enable Benjamin Herrenschmidt
2018-05-29  1:30 ` [PATCH 14/15] fsi: scom: Remove PIB reset during probe Benjamin Herrenschmidt
2018-05-29  1:30 ` [PATCH 15/15] fsi/sbefifo: Add driver for the SBE FIFO Benjamin Herrenschmidt
2018-05-29 12:30 ` [PATCH 00/15] fsi: Overall improvements and new SBE fifo driver Joel Stanley
2018-06-10  6:46   ` Benjamin Herrenschmidt
2018-06-10  6:57     ` Greg Kroah-Hartman

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=20180529013044.23815-6-benh@kernel.crashing.org \
    --to=benh@kernel.crashing.org \
    --cc=cbostic@linux.vnet.ibm.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jk@ozlabs.org \
    --cc=joel@jms.id.au \
    --cc=linux-kernel@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

Powered by JetHome