Skip to content

Commit ce69b95

Browse files
Guan BenSamuel Ortiz
authored andcommitted
NFC: Make EN2 pin optional in the TRF7970A driver
Make the EN2 pin optional. This is useful for boards, which have this pin fix wired, for example to ground. Acked-by: Rob Herring <robh@kernel.org> Signed-off-by: Guan Ben <ben.guan@cn.bosch.com> Signed-off-by: Mark Jonas <mark.jonas@de.bosch.com> Signed-off-by: Heiko Schocher <hs@denx.de> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
1 parent 96bd0b5 commit ce69b95

2 files changed

Lines changed: 16 additions & 14 deletions

File tree

‎Documentation/devicetree/bindings/net/nfc/trf7970a.txt‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ Required properties:
55
- spi-max-frequency: Maximum SPI frequency (<= 2000000).
66
- interrupt-parent: phandle of parent interrupt handler.
77
- interrupts: A single interrupt specifier.
8-
- ti,enable-gpios: Two GPIO entries used for 'EN' and 'EN2' pins on the
9-
TRF7970A.
8+
- ti,enable-gpios: One or two GPIO entries used for 'EN' and 'EN2' pins on the
9+
TRF7970A. EN2 is optional.
1010
- vin-supply: Regulator for supply voltage to VIN pin
1111

1212
Optional SoC Specific Properties:

‎drivers/nfc/trf7970a.c‎

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1885,8 +1885,10 @@ static int trf7970a_power_up(struct trf7970a *trf)
18851885
usleep_range(5000, 6000);
18861886

18871887
if (!(trf->quirks & TRF7970A_QUIRK_EN2_MUST_STAY_LOW)) {
1888-
gpio_set_value(trf->en2_gpio, 1);
1889-
usleep_range(1000, 2000);
1888+
if (gpio_is_valid(trf->en2_gpio)) {
1889+
gpio_set_value(trf->en2_gpio, 1);
1890+
usleep_range(1000, 2000);
1891+
}
18901892
}
18911893

18921894
gpio_set_value(trf->en_gpio, 1);
@@ -1914,7 +1916,8 @@ static int trf7970a_power_down(struct trf7970a *trf)
19141916
}
19151917

19161918
gpio_set_value(trf->en_gpio, 0);
1917-
gpio_set_value(trf->en2_gpio, 0);
1919+
if (gpio_is_valid(trf->en2_gpio))
1920+
gpio_set_value(trf->en2_gpio, 0);
19181921

19191922
ret = regulator_disable(trf->regulator);
19201923
if (ret)
@@ -2032,15 +2035,14 @@ static int trf7970a_probe(struct spi_device *spi)
20322035

20332036
trf->en2_gpio = of_get_named_gpio(np, "ti,enable-gpios", 1);
20342037
if (!gpio_is_valid(trf->en2_gpio)) {
2035-
dev_err(trf->dev, "No EN2 GPIO property\n");
2036-
return trf->en2_gpio;
2037-
}
2038-
2039-
ret = devm_gpio_request_one(trf->dev, trf->en2_gpio,
2040-
GPIOF_DIR_OUT | GPIOF_INIT_LOW, "trf7970a EN2");
2041-
if (ret) {
2042-
dev_err(trf->dev, "Can't request EN2 GPIO: %d\n", ret);
2043-
return ret;
2038+
dev_info(trf->dev, "No EN2 GPIO property\n");
2039+
} else {
2040+
ret = devm_gpio_request_one(trf->dev, trf->en2_gpio,
2041+
GPIOF_DIR_OUT | GPIOF_INIT_LOW, "trf7970a EN2");
2042+
if (ret) {
2043+
dev_err(trf->dev, "Can't request EN2 GPIO: %d\n", ret);
2044+
return ret;
2045+
}
20442046
}
20452047

20462048
if (of_property_read_bool(np, "en2-rf-quirk"))

0 commit comments

Comments
 (0)