diff options
author | Geoff Lansberry <geoff@kuvee.com> | 2016-12-21 23:18:33 -0500 |
---|---|---|
committer | Samuel Ortiz <sameo@linux.intel.com> | 2017-04-05 05:04:03 -0400 |
commit | 49d22c70aaf07cd7e33346b247f5df3ddb072ee0 (patch) | |
tree | bcdc825cff97cf30ffed42b619274e241d5e25f8 | |
parent | 837eb4d21ecde7bde7a1fe523594fdf509055f3f (diff) |
NFC: trf7970a: Add device tree option of 1.8 Volt IO voltage
The TRF7970A has configuration options for supporting hardware designs
with 1.8 Volt or 3.3 Volt IO. This commit adds a device tree option,
using a fixed regulator binding, for setting the io voltage to match
the hardware configuration. If no option is supplied it defaults to
3.3 volt configuration.
Acked-by: Rob Herring <robh@kernel.org>
Acked-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Geoff Lansberry <geoff@kuvee.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
-rw-r--r-- | Documentation/devicetree/bindings/net/nfc/trf7970a.txt | 2 | ||||
-rw-r--r-- | drivers/nfc/trf7970a.c | 26 |
2 files changed, 27 insertions, 1 deletions
diff --git a/Documentation/devicetree/bindings/net/nfc/trf7970a.txt b/Documentation/devicetree/bindings/net/nfc/trf7970a.txt index 1d186cd9817b..c627bbb3009e 100644 --- a/Documentation/devicetree/bindings/net/nfc/trf7970a.txt +++ b/Documentation/devicetree/bindings/net/nfc/trf7970a.txt | |||
@@ -21,6 +21,7 @@ Optional SoC Specific Properties: | |||
21 | - t5t-rmb-extra-byte-quirk: Specify that the trf7970a has the erratum | 21 | - t5t-rmb-extra-byte-quirk: Specify that the trf7970a has the erratum |
22 | where an extra byte is returned by Read Multiple Block commands issued | 22 | where an extra byte is returned by Read Multiple Block commands issued |
23 | to Type 5 tags. | 23 | to Type 5 tags. |
24 | - vdd-io-supply: Regulator specifying voltage for vdd-io | ||
24 | - clock-frequency: Set to specify that the input frequency to the trf7970a is 13560000Hz or 27120000Hz | 25 | - clock-frequency: Set to specify that the input frequency to the trf7970a is 13560000Hz or 27120000Hz |
25 | 26 | ||
26 | Example (for ARM-based BeagleBone with TRF7970A on SPI1): | 27 | Example (for ARM-based BeagleBone with TRF7970A on SPI1): |
@@ -40,6 +41,7 @@ Example (for ARM-based BeagleBone with TRF7970A on SPI1): | |||
40 | <&gpio2 5 GPIO_ACTIVE_LOW>; | 41 | <&gpio2 5 GPIO_ACTIVE_LOW>; |
41 | vin-supply = <&ldo3_reg>; | 42 | vin-supply = <&ldo3_reg>; |
42 | vin-voltage-override = <5000000>; | 43 | vin-voltage-override = <5000000>; |
44 | vdd-io-supply = <&ldo2_reg>; | ||
43 | autosuspend-delay = <30000>; | 45 | autosuspend-delay = <30000>; |
44 | irq-status-read-quirk; | 46 | irq-status-read-quirk; |
45 | en2-rf-quirk; | 47 | en2-rf-quirk; |
diff --git a/drivers/nfc/trf7970a.c b/drivers/nfc/trf7970a.c index ecb786283ffa..2d1c8ca6e679 100644 --- a/drivers/nfc/trf7970a.c +++ b/drivers/nfc/trf7970a.c | |||
@@ -444,6 +444,7 @@ struct trf7970a { | |||
444 | u8 iso_ctrl_tech; | 444 | u8 iso_ctrl_tech; |
445 | u8 modulator_sys_clk_ctrl; | 445 | u8 modulator_sys_clk_ctrl; |
446 | u8 special_fcn_reg1; | 446 | u8 special_fcn_reg1; |
447 | u8 io_ctrl; | ||
447 | unsigned int guard_time; | 448 | unsigned int guard_time; |
448 | int technology; | 449 | int technology; |
449 | int framing; | 450 | int framing; |
@@ -1051,6 +1052,11 @@ static int trf7970a_init(struct trf7970a *trf) | |||
1051 | if (ret) | 1052 | if (ret) |
1052 | goto err_out; | 1053 | goto err_out; |
1053 | 1054 | ||
1055 | ret = trf7970a_write(trf, TRF7970A_REG_IO_CTRL, | ||
1056 | trf->io_ctrl | TRF7970A_REG_IO_CTRL_VRS(0x1)); | ||
1057 | if (ret) | ||
1058 | goto err_out; | ||
1059 | |||
1054 | ret = trf7970a_write(trf, TRF7970A_NFC_TARGET_LEVEL, 0); | 1060 | ret = trf7970a_write(trf, TRF7970A_NFC_TARGET_LEVEL, 0); |
1055 | if (ret) | 1061 | if (ret) |
1056 | goto err_out; | 1062 | goto err_out; |
@@ -1767,7 +1773,7 @@ static int _trf7970a_tg_listen(struct nfc_digital_dev *ddev, u16 timeout, | |||
1767 | goto out_err; | 1773 | goto out_err; |
1768 | 1774 | ||
1769 | ret = trf7970a_write(trf, TRF7970A_REG_IO_CTRL, | 1775 | ret = trf7970a_write(trf, TRF7970A_REG_IO_CTRL, |
1770 | TRF7970A_REG_IO_CTRL_VRS(0x1)); | 1776 | trf->io_ctrl | TRF7970A_REG_IO_CTRL_VRS(0x1)); |
1771 | if (ret) | 1777 | if (ret) |
1772 | goto out_err; | 1778 | goto out_err; |
1773 | 1779 | ||
@@ -2107,6 +2113,24 @@ static int trf7970a_probe(struct spi_device *spi) | |||
2107 | if (uvolts > 4000000) | 2113 | if (uvolts > 4000000) |
2108 | trf->chip_status_ctrl = TRF7970A_CHIP_STATUS_VRS5_3; | 2114 | trf->chip_status_ctrl = TRF7970A_CHIP_STATUS_VRS5_3; |
2109 | 2115 | ||
2116 | trf->regulator = devm_regulator_get(&spi->dev, "vdd-io"); | ||
2117 | if (IS_ERR(trf->regulator)) { | ||
2118 | ret = PTR_ERR(trf->regulator); | ||
2119 | dev_err(trf->dev, "Can't get VDD_IO regulator: %d\n", ret); | ||
2120 | goto err_destroy_lock; | ||
2121 | } | ||
2122 | |||
2123 | ret = regulator_enable(trf->regulator); | ||
2124 | if (ret) { | ||
2125 | dev_err(trf->dev, "Can't enable VDD_IO: %d\n", ret); | ||
2126 | goto err_destroy_lock; | ||
2127 | } | ||
2128 | |||
2129 | if (regulator_get_voltage(trf->regulator) == 1800000) { | ||
2130 | trf->io_ctrl = TRF7970A_REG_IO_CTRL_IO_LOW; | ||
2131 | dev_dbg(trf->dev, "trf7970a config vdd_io to 1.8V\n"); | ||
2132 | } | ||
2133 | |||
2110 | trf->ddev = nfc_digital_allocate_device(&trf7970a_nfc_ops, | 2134 | trf->ddev = nfc_digital_allocate_device(&trf7970a_nfc_ops, |
2111 | TRF7970A_SUPPORTED_PROTOCOLS, | 2135 | TRF7970A_SUPPORTED_PROTOCOLS, |
2112 | NFC_DIGITAL_DRV_CAPS_IN_CRC | | 2136 | NFC_DIGITAL_DRV_CAPS_IN_CRC | |