diff mbox series

ata: sata_highbank: Convert to use GPIO descriptors

Message ID 20181114000241.26069-1-linus.walleij@linaro.org
State Not Applicable
Delegated to: David Miller
Headers show
Series ata: sata_highbank: Convert to use GPIO descriptors | expand

Commit Message

Linus Walleij Nov. 14, 2018, 12:02 a.m. UTC
This pure device tree driver is simple to convert to use
just GPIO descriptors instead of GPIO numbers. So let's
just do it.

Cc: Mark Langsdorf <mlangsdo@redhat.com>
Cc: Rob Herring <robh@kernel.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
 drivers/ata/sata_highbank.c | 37 +++++++++++++++++--------------------
 1 file changed, 17 insertions(+), 20 deletions(-)

Comments

Rob Herring Nov. 14, 2018, 12:43 a.m. UTC | #1
On Tue, Nov 13, 2018 at 6:04 PM Linus Walleij <linus.walleij@linaro.org> wrote:
>
> This pure device tree driver is simple to convert to use
> just GPIO descriptors instead of GPIO numbers. So let's
> just do it.

Actually, all this SGPIO (nothing really to do with GPIO other than
being a bit-bang implementation) can probably just be deleted. I don't
think h/w using this ever materialized. It may not be too long til we
can just remove the whole driver and rest of Calxeda code.

But you already wrote this, so:

Acked-by: Rob Herring <robh@kernel.org>

Rob
Linus Walleij Dec. 4, 2018, 1:07 p.m. UTC | #2
On Wed, Nov 14, 2018 at 1:04 AM Linus Walleij <linus.walleij@linaro.org> wrote:

> This pure device tree driver is simple to convert to use
> just GPIO descriptors instead of GPIO numbers. So let's
> just do it.
>
> Cc: Mark Langsdorf <mlangsdo@redhat.com>
> Cc: Rob Herring <robh@kernel.org>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

Ping on this patch.

If nothing happens I will apply it to the GPIO tree.

Yours,
Linus Walleij
Jens Axboe Dec. 5, 2018, 12:15 a.m. UTC | #3
On 11/13/18 5:02 PM, Linus Walleij wrote:
> This pure device tree driver is simple to convert to use
> just GPIO descriptors instead of GPIO numbers. So let's
> just do it.

Applied, thanks.
diff mbox series

Patch

diff --git a/drivers/ata/sata_highbank.c b/drivers/ata/sata_highbank.c
index e67815b896fc..c8fc9280d6e4 100644
--- a/drivers/ata/sata_highbank.c
+++ b/drivers/ata/sata_highbank.c
@@ -31,8 +31,7 @@ 
 #include <linux/interrupt.h>
 #include <linux/delay.h>
 #include <linux/export.h>
-#include <linux/gpio.h>
-#include <linux/of_gpio.h>
+#include <linux/gpio/consumer.h>
 
 #include "ahci.h"
 
@@ -85,7 +84,7 @@  struct ecx_plat_data {
 	/* number of extra clocks that the SGPIO PIC controller expects */
 	u32		pre_clocks;
 	u32		post_clocks;
-	unsigned	sgpio_gpio[SGPIO_PINS];
+	struct gpio_desc *sgpio_gpiod[SGPIO_PINS];
 	u32		sgpio_pattern;
 	u32		port_to_sgpio[SGPIO_PORTS];
 };
@@ -131,9 +130,9 @@  static void ecx_parse_sgpio(struct ecx_plat_data *pdata, u32 port, u32 state)
  */
 static void ecx_led_cycle_clock(struct ecx_plat_data *pdata)
 {
-	gpio_set_value(pdata->sgpio_gpio[SCLOCK], 1);
+	gpiod_set_value(pdata->sgpio_gpiod[SCLOCK], 1);
 	udelay(50);
-	gpio_set_value(pdata->sgpio_gpio[SCLOCK], 0);
+	gpiod_set_value(pdata->sgpio_gpiod[SCLOCK], 0);
 	udelay(50);
 }
 
@@ -164,15 +163,15 @@  static ssize_t ecx_transmit_led_message(struct ata_port *ap, u32 state,
 	for (i = 0; i < pdata->pre_clocks; i++)
 		ecx_led_cycle_clock(pdata);
 
-	gpio_set_value(pdata->sgpio_gpio[SLOAD], 1);
+	gpiod_set_value(pdata->sgpio_gpiod[SLOAD], 1);
 	ecx_led_cycle_clock(pdata);
-	gpio_set_value(pdata->sgpio_gpio[SLOAD], 0);
+	gpiod_set_value(pdata->sgpio_gpiod[SLOAD], 0);
 	/*
 	 * bit-bang out the SGPIO pattern, by consuming a bit and then
 	 * clocking it out.
 	 */
 	for (i = 0; i < (SGPIO_SIGNALS * pdata->n_ports); i++) {
-		gpio_set_value(pdata->sgpio_gpio[SDATA], sgpio_out & 1);
+		gpiod_set_value(pdata->sgpio_gpiod[SDATA], sgpio_out & 1);
 		sgpio_out >>= 1;
 		ecx_led_cycle_clock(pdata);
 	}
@@ -193,21 +192,19 @@  static void highbank_set_em_messages(struct device *dev,
 	struct device_node *np = dev->of_node;
 	struct ecx_plat_data *pdata = hpriv->plat_data;
 	int i;
-	int err;
 
 	for (i = 0; i < SGPIO_PINS; i++) {
-		err = of_get_named_gpio(np, "calxeda,sgpio-gpio", i);
-		if (err < 0)
-			return;
-
-		pdata->sgpio_gpio[i] = err;
-		err = gpio_request(pdata->sgpio_gpio[i], "CX SGPIO");
-		if (err) {
-			pr_err("sata_highbank gpio_request %d failed: %d\n",
-					i, err);
-			return;
+		struct gpio_desc *gpiod;
+
+		gpiod = devm_gpiod_get_index(dev, "calxeda,sgpio", i,
+					     GPIOD_OUT_HIGH);
+		if (IS_ERR(gpiod)) {
+			dev_err(dev, "failed to get GPIO %d\n", i);
+			continue;
 		}
-		gpio_direction_output(pdata->sgpio_gpio[i], 1);
+		gpiod_set_consumer_name(gpiod, "CX SGPIO");
+
+		pdata->sgpio_gpiod[i] = gpiod;
 	}
 	of_property_read_u32_array(np, "calxeda,led-order",
 						pdata->port_to_sgpio,