Skip to contentSkip to conversation

NFC: trf7970a: add device tree option for 27MHz clock

PATCH In review Geoff Lansberry 3 participants 12 messages Dec 15, 2016 – Dec 22, 2016

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

PATCH 1/3 NFC: trf7970a: add device tree option for 27MHz clock

From: Geoff Lansberry <[email protected]>

---
 .../devicetree/bindings/net/nfc/trf7970a.txt       |  3 ++
 drivers/nfc/trf7970a.c                             | 42 ++++++++++++++++------
 2 files changed, 34 insertions(+), 11 deletions(-)
Documentation/devicetree/bindings/net/nfc/trf7970a.txt +3 -0
index 32b35a0..9dda879 100644
@@ -21,6 +21,8 @@ Optional SoC Specific Properties:
 - t5t-rmb-extra-byte-quirk: Specify that the trf7970a has the erratum
   where an extra byte is returned by Read Multiple Block commands issued
   to Type 5 tags.
+- crystal_27mhz: Set to specify that the input frequency to the trf7970a is 27.12MHz
+
 
 Example (for ARM-based BeagleBone with TRF7970A on SPI1):
 
@@ -43,6 +45,7 @@ Example (for ARM-based BeagleBone with TRF7970A on SPI1):
 		irq-status-read-quirk;
 		en2-rf-quirk;
 		t5t-rmb-extra-byte-quirk;
+		crystal_27mhz;
 		status = "okay";
 	};
 };
drivers/nfc/trf7970a.c +31 -11

93 lines not on this page · raw message

Signature · 1 line
Signed-off-by: Geoff Lansberry <[email protected]>
#1 lore raw

PATCH 2/3 NFC: trf7970a: Add device tree option of 1.8 Volt IO voltage

From: Geoff Lansberry <[email protected]>

---
 Documentation/devicetree/bindings/net/nfc/trf7970a.txt |  2 ++
 drivers/nfc/trf7970a.c                                 | 13 ++++++++++++-
 2 files changed, 14 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/net/nfc/trf7970a.txt +2 -0
index 9dda879..208f045 100644
@@ -21,6 +21,7 @@ Optional SoC Specific Properties:
 - t5t-rmb-extra-byte-quirk: Specify that the trf7970a has the erratum
   where an extra byte is returned by Read Multiple Block commands issued
   to Type 5 tags.
+- vdd_io_1v8: Set to specify that the trf7970a io voltage should be set to 1.8V
 - crystal_27mhz: Set to specify that the input frequency to the trf7970a is 27.12MHz
 
 
@@ -45,6 +46,7 @@ Example (for ARM-based BeagleBone with TRF7970A on SPI1):
 		irq-status-read-quirk;
 		en2-rf-quirk;
 		t5t-rmb-extra-byte-quirk;
+		vdd_io_1v8;
 		crystal_27mhz;
 		status = "okay";
 	};
drivers/nfc/trf7970a.c +12 -1
index 2d2a077..b4c37ab 100644
@@ -441,6 +441,7 @@ struct trf7970a {
 	u8				iso_ctrl_tech;
 	u8				modulator_sys_clk_ctrl;
 	u8				special_fcn_reg1;
+	u8				io_ctrl;
 	unsigned int			guard_time;
 	int				technology;
 	int				framing;
@@ -1048,6 +1049,11 @@ static int trf7970a_init(struct trf7970a *trf)
 	if (ret)
 		goto err_out;
 
+	ret = trf7970a_write(trf, TRF7970A_REG_IO_CTRL,
+			trf->io_ctrl|TRF7970A_REG_IO_CTRL_VRS(0x1));
+	if (ret)
+		goto err_out;
+
 	ret = trf7970a_write(trf, TRF7970A_NFC_TARGET_LEVEL, 0);
 	if (ret)
 		goto err_out;
@@ -1764,7 +1770,7 @@ static int _trf7970a_tg_listen(struct nfc_digital_dev *ddev, u16 timeout,
 		goto out_err;
 
 	ret = trf7970a_write(trf, TRF7970A_REG_IO_CTRL,
-			TRF7970A_REG_IO_CTRL_VRS(0x1));
+			trf->io_ctrl|TRF7970A_REG_IO_CTRL_VRS(0x1));
 	if (ret)
 		goto out_err;
 
@@ -2058,6 +2064,11 @@ static int trf7970a_probe(struct spi_device *spi)
 		return ret;
 	}
 
+	if (of_property_read_bool(np, "vdd_io_1v8")) {
+		trf->io_ctrl = TRF7970A_REG_IO_CTRL_IO_LOW;
+		dev_dbg(trf->dev, "trf7970a config vdd_io_1v8\n");
+	}
+
 	if (of_property_read_bool(np, "crystal_27mhz")) {
 		trf->modulator_sys_clk_ctrl = TRF7970A_MODULATOR_27MHZ;
 		dev_dbg(trf->dev, "trf7970a configure crystal_27mhz\n");
Signature · 6 lines
Signed-off-by: Geoff Lansberry <[email protected]>

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
maintainer
#2 lore raw

Re: [PATCH 2/3] NFC: trf7970a: Add device tree option of 1.8 Volt IO voltage

Quoted 1 line · Geoff Lansberry

From: Geoff Lansberry <[email protected]>

Missing commit description.

drivers/nfc/trf7970a.c static int trf7970a_init(struct trf7970a *trf) · line 1053

Quoted 11 lines
drivers/nfc/trf7970a.c +2 -0
index 2d2a077..b4c37ab 100644
@@ -1048,6 +1049,11 @@ static int trf7970a_init(struct trf7970a *trf)
 	if (ret)
 		goto err_out;
 
+	ret = trf7970a_write(trf, TRF7970A_REG_IO_CTRL,
+			trf->io_ctrl|TRF7970A_REG_IO_CTRL_VRS(0x1));

s/l|T/l | T/

Otherwise, looks good.

Mark
--
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

maintainer
#3 lore raw

Re: [PATCH 2/3] NFC: trf7970a: Add device tree option of 1.8 Volt IO voltage

In reply to Geoff Lansberry
Quoted 12 lines · Geoff Lansberry

From: Geoff Lansberry <[email protected]>

---
 Documentation/devicetree/bindings/net/nfc/trf7970a.txt |  2 ++
 drivers/nfc/trf7970a.c                                 | 13 ++++++++++++-
 2 files changed, 14 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/net/nfc/trf7970a.txt +0 -0
index 9dda879..208f045 100644

Documentation/devicetree/bindings/net/nfc/trf7970a.txt Optional SoC Specific Properties: · line 24

Quoted 4 lines
Documentation/devicetree/bindings/net/nfc/trf7970a.txt +1 -0
@@ -21,6 +21,7 @@ Optional SoC Specific Properties:
 - t5t-rmb-extra-byte-quirk: Specify that the trf7970a has the erratum
   where an extra byte is returned by Read Multiple Block commands issued
   to Type 5 tags.
+- vdd_io_1v8: Set to specify that the trf7970a io voltage should be set to 1.8V

Use the regulator binding and provide a fixed 1.8V supply.

Quoted 11 lines
Documentation/devicetree/bindings/net/nfc/trf7970a.txt +1 -0
 - crystal_27mhz: Set to specify that the input frequency to the trf7970a is 27.12MHz
 
 
@@ -45,6 +46,7 @@ Example (for ARM-based BeagleBone with TRF7970A on SPI1):
 		irq-status-read-quirk;
 		en2-rf-quirk;
 		t5t-rmb-extra-byte-quirk;
+		vdd_io_1v8;
 		crystal_27mhz;
 		status = "okay";
 	};
#4 lore raw

Re: [PATCH 2/3] NFC: trf7970a: Add device tree option of 1.8 Volt IO voltage

Quoted 23 lines · Rob Herring
Quoted 12 lines · Geoff Lansberry

From: Geoff Lansberry <[email protected]>

---
 Documentation/devicetree/bindings/net/nfc/trf7970a.txt |  2 ++
 drivers/nfc/trf7970a.c                                 | 13 ++++++++++++-
 2 files changed, 14 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/net/nfc/trf7970a.txt +0 -0
index 9dda879..208f045 100644

Documentation/devicetree/bindings/net/nfc/trf7970a.txt Optional SoC Specific Properties: · line 24

Quoted 4 lines
Documentation/devicetree/bindings/net/nfc/trf7970a.txt +1 -0
@@ -21,6 +21,7 @@ Optional SoC Specific Properties:
 - t5t-rmb-extra-byte-quirk: Specify that the trf7970a has the erratum
   where an extra byte is returned by Read Multiple Block commands issued
   to Type 5 tags.
+- vdd_io_1v8: Set to specify that the trf7970a io voltage should be set to 1.8V

Use the regulator binding and provide a fixed 1.8V supply.

Quoted 3 lines
Documentation/devicetree/bindings/net/nfc/trf7970a.txt +0 -0
 - crystal_27mhz: Set to specify that the input frequency to the trf7970a is 27.12MHz
 
 
Quoted 8 lines

Documentation/devicetree/bindings/net/nfc/trf7970a.txt Example (for ARM-based BeagleBone with TRF7970A on SPI1): · line 52

Quoted 8 lines
Documentation/devicetree/bindings/net/nfc/trf7970a.txt +1 -0
@@ -45,6 +46,7 @@ Example (for ARM-based BeagleBone with TRF7970A on SPI1):
              irq-status-read-quirk;
              en2-rf-quirk;
              t5t-rmb-extra-byte-quirk;
+             vdd_io_1v8;
              crystal_27mhz;
              status = "okay";
      };

Rob - using the regulator binding is new to me, but I've given it a shot and just sent you another set of patches for your inspection. Please let me know if this is what you had in mind.

Geoff

maintainer
#5 lore raw

Re: [PATCH 2/3] NFC: trf7970a: Add device tree option of 1.8 Volt IO voltage

Quoted 24 lines · Geoff Lansberry
Quoted 23 lines · Rob Herring
Quoted 12 lines · Geoff Lansberry

From: Geoff Lansberry <[email protected]>

---
 Documentation/devicetree/bindings/net/nfc/trf7970a.txt |  2 ++
 drivers/nfc/trf7970a.c                                 | 13 ++++++++++++-
 2 files changed, 14 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/net/nfc/trf7970a.txt +0 -0
index 9dda879..208f045 100644

Documentation/devicetree/bindings/net/nfc/trf7970a.txt Optional SoC Specific Properties: · line 24

Quoted 4 lines
Documentation/devicetree/bindings/net/nfc/trf7970a.txt +1 -0
@@ -21,6 +21,7 @@ Optional SoC Specific Properties:
 - t5t-rmb-extra-byte-quirk: Specify that the trf7970a has the erratum
   where an extra byte is returned by Read Multiple Block commands issued
   to Type 5 tags.
+- vdd_io_1v8: Set to specify that the trf7970a io voltage should be set to 1.8V

Use the regulator binding and provide a fixed 1.8V supply.

Quoted 3 lines
Documentation/devicetree/bindings/net/nfc/trf7970a.txt +0 -0
 - crystal_27mhz: Set to specify that the input frequency to the trf7970a is 27.12MHz
 
 
Quoted 12 lines
Quoted 8 lines

Documentation/devicetree/bindings/net/nfc/trf7970a.txt Example (for ARM-based BeagleBone with TRF7970A on SPI1): · line 52

Quoted 8 lines
Documentation/devicetree/bindings/net/nfc/trf7970a.txt +1 -0
@@ -45,6 +46,7 @@ Example (for ARM-based BeagleBone with TRF7970A on SPI1):
              irq-status-read-quirk;
              en2-rf-quirk;
              t5t-rmb-extra-byte-quirk;
+             vdd_io_1v8;
              crystal_27mhz;
              status = "okay";
      };

Rob - using the regulator binding is new to me, but I've given it a shot and just sent you another set of patches for your inspection. Please let me know if this is what you had in mind.

This is my bad. Geoff followed my example and did something similar to 'vin-voltage-override' which shouldn't have been there in the first place. I have this fixed (I think) locally and will submit once it I'm back from my holiday travels.

Mark
--
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#6 lore raw

PATCH 3/3 nfc: trf7970a: Prevent repeated polling from crashing the kernel

In reply to Geoff Lansberry

From: Jaret Cantu <[email protected]>

Repeated polling attempts cause a NULL dereference error to occur. This is because the curent state of the trf7970a is reading but a request has been made to send a command.

The solution is to properly kill the waiting reading (workqueue) before failing on the send.

---
 drivers/nfc/trf7970a.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/nfc/trf7970a.c +4 -0
index b4c37ab..f96a321 100644
@@ -1493,6 +1493,10 @@ static int trf7970a_send_cmd(struct nfc_digital_dev *ddev,
 			(trf->state != TRF7970A_ST_IDLE_RX_BLOCKED)) {
 		dev_err(trf->dev, "%s - Bogus state: %d\n", __func__,
 				trf->state);
+		if (trf->state == TRF7970A_ST_WAIT_FOR_RX_DATA ||
+		    trf->state == TRF7970A_ST_WAIT_FOR_RX_DATA_CONT)
+			trf->ignore_timeout =
+				!cancel_delayed_work(&trf->timeout_work);
 		ret = -EIO;
 		goto out_err;
 	}
Signature · 1 line
Signed-off-by: Geoff Lansberry <[email protected]>
maintainer
#7 lore raw

Re: [PATCH 3/3] nfc: trf7970a: Prevent repeated polling from crashing the kernel

Quoted 8 lines · Geoff Lansberry

From: Jaret Cantu <[email protected]>

Repeated polling attempts cause a NULL dereference error to occur. This is because the curent state of the trf7970a is reading but a request has been made to send a command.

The solution is to properly kill the waiting reading (workqueue) before failing on the send.

Maybe its just me but I find this description a little hard to grok. Mind reworking it?

The patch itself looks fine.

Thanks,

Mark
--
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

maintainer
#8 lore raw
In reply to Geoff Lansberry

Hi Geoff.

Quoted 1 line · Geoff Lansberry

From: Geoff Lansberry <[email protected]>

Please add an informative commit description to all of your commits. No matter how trivial this patch may seem to you now, it may not be to others (or to you in a few years).

drivers/nfc/trf7970a.c static int trf7970a_in_config_rf_tech(struct trf7970a *trf, int tech) · line 1184

Quoted 12 lines
drivers/nfc/trf7970a.c +2 -1
index 26c9dbb..2d2a077 100644
@@ -1181,27 +1180,37 @@ static int trf7970a_in_config_rf_tech(struct trf7970a *trf, int tech)
 	switch (tech) {
 	case NFC_DIGITAL_RF_TECH_106A:
 		trf->iso_ctrl_tech = TRF7970A_ISO_CTRL_14443A_106;
-		trf->modulator_sys_clk_ctrl = TRF7970A_MODULATOR_DEPTH_OOK;
+		trf->modulator_sys_clk_ctrl =
+			(trf->modulator_sys_clk_ctrl & 0xF8) |

nit: s/0xF8/0xf8/ please (for consistency with the rest of the file.).

Otherwise, it looks good.

Thanks,

Mark
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

maintainer
#9 lore raw
In reply to Geoff Lansberry
Quoted 12 lines · Geoff Lansberry

From: Geoff Lansberry <[email protected]>

---
 .../devicetree/bindings/net/nfc/trf7970a.txt       |  3 ++
 drivers/nfc/trf7970a.c                             | 42 ++++++++++++++++------
 2 files changed, 34 insertions(+), 11 deletions(-)
Documentation/devicetree/bindings/net/nfc/trf7970a.txt +0 -0
index 32b35a0..9dda879 100644

Documentation/devicetree/bindings/net/nfc/trf7970a.txt Optional SoC Specific Properties: · line 25

Quoted 5 lines
Documentation/devicetree/bindings/net/nfc/trf7970a.txt +2 -0
@@ -21,6 +21,8 @@ Optional SoC Specific Properties:
 - t5t-rmb-extra-byte-quirk: Specify that the trf7970a has the erratum
   where an extra byte is returned by Read Multiple Block commands issued
   to Type 5 tags.
+- crystal_27mhz: Set to specify that the input frequency to the trf7970a is 27.12MHz
+

Can't you use 'clock-frequency = "27000000";'?

Quoted 11 lines
Documentation/devicetree/bindings/net/nfc/trf7970a.txt +1 -0
 Example (for ARM-based BeagleBone with TRF7970A on SPI1):
 
@@ -43,6 +45,7 @@ Example (for ARM-based BeagleBone with TRF7970A on SPI1):
 		irq-status-read-quirk;
 		en2-rf-quirk;
 		t5t-rmb-extra-byte-quirk;
+		crystal_27mhz;
 		status = "okay";
 	};
 };
#10 lore raw

I can make that change, however, I worry that it may be a bit misleading, since there are only two supported clock frequencies, but a number like that to me implies that it could be set to any number
you want. I'm new at this, and so I'll go ahead and change it as you
request, but I'd like to hear your thoughts on my concern.

Thanks
Geoff
Geoff Lansberry

Engineering Guy
Kuvée, Inc
125 Kingston St., 3rd Floor
Boston, MA 02111
1-617-290-1118 (m)
geoff.lansberry (skype)
http://www.kuvee.com

Quoted 24 lines · Rob Herring
Quoted 12 lines · Geoff Lansberry

From: Geoff Lansberry <[email protected]>

---
 .../devicetree/bindings/net/nfc/trf7970a.txt       |  3 ++
 drivers/nfc/trf7970a.c                             | 42 ++++++++++++++++------
 2 files changed, 34 insertions(+), 11 deletions(-)
Documentation/devicetree/bindings/net/nfc/trf7970a.txt +0 -0
index 32b35a0..9dda879 100644

Documentation/devicetree/bindings/net/nfc/trf7970a.txt Optional SoC Specific Properties: · line 25

Quoted 5 lines
Documentation/devicetree/bindings/net/nfc/trf7970a.txt +2 -0
@@ -21,6 +21,8 @@ Optional SoC Specific Properties:
 - t5t-rmb-extra-byte-quirk: Specify that the trf7970a has the erratum
   where an extra byte is returned by Read Multiple Block commands issued
   to Type 5 tags.
+- crystal_27mhz: Set to specify that the input frequency to the trf7970a is 27.12MHz
+

Can't you use 'clock-frequency = "27000000";'?

Quoted 3 lines
Documentation/devicetree/bindings/net/nfc/trf7970a.txt +0 -0
 Example (for ARM-based BeagleBone with TRF7970A on SPI1):
 
Quoted 8 lines

Documentation/devicetree/bindings/net/nfc/trf7970a.txt Example (for ARM-based BeagleBone with TRF7970A on SPI1): · line 51

Quoted 8 lines
Documentation/devicetree/bindings/net/nfc/trf7970a.txt +1 -0
@@ -43,6 +45,7 @@ Example (for ARM-based BeagleBone with TRF7970A on SPI1):
              irq-status-read-quirk;
              en2-rf-quirk;
              t5t-rmb-extra-byte-quirk;
+             crystal_27mhz;
              status = "okay";
      };
 };

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

maintainer
#11 lore raw
Quoted 5 lines · Geoff Lansberry

I can make that change, however, I worry that it may be a bit misleading, since there are only two supported clock frequencies, but a number like that to me implies that it could be set to any number
you want. I'm new at this, and so I'll go ahead and change it as you
request, but I'd like to hear your thoughts on my concern.

Then the binding doc just needs to state what are the 2 valid frequencies.

Rob
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html