Skip to content

Commit

Permalink
ata: sata_highbank: Convert to use GPIO descriptors
Browse files Browse the repository at this point in the history
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>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
  • Loading branch information
Linus Walleij authored and Jens Axboe committed Dec 5, 2018
1 parent 3e21626 commit 83a7faa
Showing 1 changed file with 17 additions and 20 deletions.
37 changes: 17 additions & 20 deletions drivers/ata/sata_highbank.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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];
};
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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);
}
Expand All @@ -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,
Expand Down

0 comments on commit 83a7faa

Please sign in to comment.