Commit d34e48d6 authored by Mark Greer's avatar Mark Greer Committed by Samuel Ortiz

NFC: trf7970a: Convert to descriptor based GPIO interface

The trf7970a driver uses the deprecated integer-based GPIO consumer
interface so convert it to use the new descriptor-based GPIO
consumer interface.
Signed-off-by: default avatarMark Greer <mgreer@animalcreek.com>
Signed-off-by: default avatarSamuel Ortiz <sameo@linux.intel.com>
parent 1877d2c5
...@@ -7,7 +7,7 @@ menu "Near Field Communication (NFC) devices" ...@@ -7,7 +7,7 @@ menu "Near Field Communication (NFC) devices"
config NFC_TRF7970A config NFC_TRF7970A
tristate "Texas Instruments TRF7970a NFC driver" tristate "Texas Instruments TRF7970a NFC driver"
depends on SPI && NFC_DIGITAL depends on SPI && NFC_DIGITAL && GPIOLIB
help help
This option enables the NFC driver for Texas Instruments' TRF7970a This option enables the NFC driver for Texas Instruments' TRF7970a
device. Such device supports 5 different protocols: ISO14443A, device. Such device supports 5 different protocols: ISO14443A,
......
...@@ -20,9 +20,8 @@ ...@@ -20,9 +20,8 @@
#include <linux/nfc.h> #include <linux/nfc.h>
#include <linux/skbuff.h> #include <linux/skbuff.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/gpio.h> #include <linux/gpio/consumer.h>
#include <linux/of.h> #include <linux/of.h>
#include <linux/of_gpio.h>
#include <linux/spi/spi.h> #include <linux/spi/spi.h>
#include <linux/regulator/consumer.h> #include <linux/regulator/consumer.h>
...@@ -452,8 +451,8 @@ struct trf7970a { ...@@ -452,8 +451,8 @@ struct trf7970a {
u8 tx_cmd; u8 tx_cmd;
bool issue_eof; bool issue_eof;
bool adjust_resp_len; bool adjust_resp_len;
int en2_gpio; struct gpio_desc *en_gpiod;
int en_gpio; struct gpio_desc *en2_gpiod;
struct mutex lock; struct mutex lock;
unsigned int timeout; unsigned int timeout;
bool ignore_timeout; bool ignore_timeout;
...@@ -1908,14 +1907,13 @@ static int trf7970a_power_up(struct trf7970a *trf) ...@@ -1908,14 +1907,13 @@ static int trf7970a_power_up(struct trf7970a *trf)
usleep_range(5000, 6000); usleep_range(5000, 6000);
if (!(trf->quirks & TRF7970A_QUIRK_EN2_MUST_STAY_LOW)) { if (trf->en2_gpiod &&
if (gpio_is_valid(trf->en2_gpio)) { !(trf->quirks & TRF7970A_QUIRK_EN2_MUST_STAY_LOW)) {
gpio_set_value(trf->en2_gpio, 1); gpiod_set_value_cansleep(trf->en2_gpiod, 1);
usleep_range(1000, 2000); usleep_range(1000, 2000);
}
} }
gpio_set_value(trf->en_gpio, 1); gpiod_set_value_cansleep(trf->en_gpiod, 1);
usleep_range(20000, 21000); usleep_range(20000, 21000);
...@@ -1939,11 +1937,11 @@ static int trf7970a_power_down(struct trf7970a *trf) ...@@ -1939,11 +1937,11 @@ static int trf7970a_power_down(struct trf7970a *trf)
return -EBUSY; return -EBUSY;
} }
gpio_set_value(trf->en_gpio, 0); gpiod_set_value_cansleep(trf->en_gpiod, 0);
if (!(trf->quirks & TRF7970A_QUIRK_EN2_MUST_STAY_LOW)) if (trf->en2_gpiod &&
if (gpio_is_valid(trf->en2_gpio)) !(trf->quirks & TRF7970A_QUIRK_EN2_MUST_STAY_LOW))
gpio_set_value(trf->en2_gpio, 0); gpiod_set_value_cansleep(trf->en2_gpiod, 0);
ret = regulator_disable(trf->regulator); ret = regulator_disable(trf->regulator);
if (ret) if (ret)
...@@ -2041,32 +2039,23 @@ static int trf7970a_probe(struct spi_device *spi) ...@@ -2041,32 +2039,23 @@ static int trf7970a_probe(struct spi_device *spi)
trf->quirks |= TRF7970A_QUIRK_IRQ_STATUS_READ; trf->quirks |= TRF7970A_QUIRK_IRQ_STATUS_READ;
/* There are two enable pins - only EN must be present in the DT */ /* There are two enable pins - only EN must be present in the DT */
trf->en_gpio = of_get_named_gpio(np, "ti,enable-gpios", 0); trf->en_gpiod = devm_gpiod_get_index(trf->dev, "ti,enable", 0,
if (!gpio_is_valid(trf->en_gpio)) { GPIOD_OUT_LOW);
if (IS_ERR(trf->en_gpiod)) {
dev_err(trf->dev, "No EN GPIO property\n"); dev_err(trf->dev, "No EN GPIO property\n");
return trf->en_gpio; return PTR_ERR(trf->en_gpiod);
}
ret = devm_gpio_request_one(trf->dev, trf->en_gpio,
GPIOF_DIR_OUT | GPIOF_INIT_LOW, "trf7970a EN");
if (ret) {
dev_err(trf->dev, "Can't request EN GPIO: %d\n", ret);
return ret;
} }
trf->en2_gpio = of_get_named_gpio(np, "ti,enable-gpios", 1); trf->en2_gpiod = devm_gpiod_get_index_optional(trf->dev, "ti,enable", 1,
if (!gpio_is_valid(trf->en2_gpio)) { GPIOD_OUT_LOW);
if (!trf->en2_gpiod) {
dev_info(trf->dev, "No EN2 GPIO property\n"); dev_info(trf->dev, "No EN2 GPIO property\n");
} else { } else if (IS_ERR(trf->en2_gpiod)) {
ret = devm_gpio_request_one(trf->dev, trf->en2_gpio, dev_err(trf->dev, "Error getting EN2 GPIO property: %ld\n",
GPIOF_DIR_OUT | GPIOF_INIT_LOW, "trf7970a EN2"); PTR_ERR(trf->en2_gpiod));
if (ret) { return PTR_ERR(trf->en2_gpiod);
dev_err(trf->dev, "Can't request EN2 GPIO: %d\n", ret); } else if (of_property_read_bool(np, "en2-rf-quirk")) {
return ret; trf->quirks |= TRF7970A_QUIRK_EN2_MUST_STAY_LOW;
}
if (of_property_read_bool(np, "en2-rf-quirk"))
trf->quirks |= TRF7970A_QUIRK_EN2_MUST_STAY_LOW;
} }
of_property_read_u32(np, "clock-frequency", &clk_freq); of_property_read_u32(np, "clock-frequency", &clk_freq);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment