Skip to contentSkip to conversation

NFC: trf7970a: Ignore antenna noise when checking for RF field

PATCH Applied Paul Geurts 4 participants 4 messages Apr 22 – Apr 28

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

PATCH 1/1 NFC: trf7970a: Ignore antenna noise when checking for RF field

The main channel Received Signal Strength Indicator (RSSI) measurement is used to determine whether an RF field is present or not. RSSI != 0 is interpreted as an RF Field is present. This does not take RF noise and measurement inaccuracy into account, and results in false positives in the field.

Define a noise level and make sure the RF field is only interpreted as present when the RSSI is above the noise level.

Fixes 851ee3cbf850 ("NFC: trf7970a: Don't turn on RF if there is already an RF field")
---
 drivers/nfc/trf7970a.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/nfc/trf7970a.c +2 -1
index d17c701c7888..08c27bb438b5 100644
@@ -317,6 +317,7 @@
 #define TRF7970A_RSSI_OSC_STATUS_RSSI_MASK	(BIT(2) | BIT(1) | BIT(0))
 #define TRF7970A_RSSI_OSC_STATUS_RSSI_X_MASK	(BIT(5) | BIT(4) | BIT(3))
 #define TRF7970A_RSSI_OSC_STATUS_RSSI_OSC_OK	BIT(6)
+#define TRF7970A_RSSI_OSC_STATUS_RSSI_NOISE_LEVEL	1
 
 #define TRF7970A_SPECIAL_FCN_REG1_COL_7_6		BIT(0)
 #define TRF7970A_SPECIAL_FCN_REG1_14_ANTICOLL		BIT(1)
@@ -1300,7 +1301,7 @@ static int trf7970a_is_rf_field(struct trf7970a *trf, bool *is_rf_field)
 	if (ret)
 		return ret;
 
-	if (rssi & TRF7970A_RSSI_OSC_STATUS_RSSI_MASK)
+	if ((rssi & TRF7970A_RSSI_OSC_STATUS_RSSI_MASK) > TRF7970A_RSSI_OSC_STATUS_RSSI_NOISE_LEVEL)
 		*is_rf_field = true;
 	else
 		*is_rf_field = false;
Signature · 1 line
2.39.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Paul Geurts

The main channel Received Signal Strength Indicator (RSSI) measurement is used to determine whether an RF field is present or not. RSSI != 0 is interpreted as an RF Field is present. This does not take RF noise and measurement inaccuracy into account, and results in false positives in the field.

Quoted 7 lines

Define a noise level and make sure the RF field is only interpreted as present when the RSSI is above the noise level.

Fixes 851ee3cbf850 ("NFC: trf7970a: Don't turn on RF if there is already an RF field")
---
 drivers/nfc/trf7970a.c | 3 ++-

Looks reasonable so a poor man's review:

Best regards,
Krzysztof

maintainer Reviewed-by on v1 1/1
#2 lore raw
In reply to Paul Geurts
Quoted 28 lines · Paul Geurts

The main channel Received Signal Strength Indicator (RSSI) measurement is used to determine whether an RF field is present or not. RSSI != 0 is interpreted as an RF Field is present. This does not take RF noise and measurement inaccuracy into account, and results in false positives in the field.

Define a noise level and make sure the RF field is only interpreted as present when the RSSI is above the noise level.

Fixes 851ee3cbf850 ("NFC: trf7970a: Don't turn on RF if there is already an RF field")
---
  drivers/nfc/trf7970a.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
drivers/nfc/trf7970a.c +1 -0
index d17c701c7888..08c27bb438b5 100644
@@ -317,6 +317,7 @@
  #define TRF7970A_RSSI_OSC_STATUS_RSSI_MASK	(BIT(2) | BIT(1) | BIT(0))
  #define TRF7970A_RSSI_OSC_STATUS_RSSI_X_MASK	(BIT(5) | BIT(4) | BIT(3))
  #define TRF7970A_RSSI_OSC_STATUS_RSSI_OSC_OK	BIT(6)
+#define TRF7970A_RSSI_OSC_STATUS_RSSI_NOISE_LEVEL	1
 
  #define TRF7970A_SPECIAL_FCN_REG1_COL_7_6		BIT(0)
  #define TRF7970A_SPECIAL_FCN_REG1_14_ANTICOLL		BIT(1)

drivers/nfc/trf7970a.c static int trf7970a_is_rf_field(struct trf7970a *trf, bool *is_rf_field) · line 1307

Quoted 8 lines
drivers/nfc/trf7970a.c +1 -1
@@ -1300,7 +1301,7 @@ static int trf7970a_is_rf_field(struct trf7970a *trf, bool *is_rf_field)
  	if (ret)
  		return ret;
 
-	if (rssi & TRF7970A_RSSI_OSC_STATUS_RSSI_MASK)
+	if ((rssi & TRF7970A_RSSI_OSC_STATUS_RSSI_MASK) > TRF7970A_RSSI_OSC_STATUS_RSSI_NOISE_LEVEL)
  		*is_rf_field = true;
  	else
  		*is_rf_field = false;

Given that false positives are happening in the field and assuming that a value of 1 is enough to filter out those false positives, this seems like a reasonable solution.

#3 lore raw
In reply to Paul Geurts
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:

Quoted 10 lines · On Wed, 22 Apr 2026 12:09:30 +0200 you wrote:

The main channel Received Signal Strength Indicator (RSSI) measurement is used to determine whether an RF field is present or not. RSSI != 0 is interpreted as an RF Field is present. This does not take RF noise and measurement inaccuracy into account, and results in false positives in the field.

Define a noise level and make sure the RF field is only interpreted as present when the RSSI is above the noise level.

[...]

Here is the summary with links:
- NFC: trf7970a: Ignore antenna noise when checking for RF field

    https://git.kernel.org/netdev/net/c/a9bc28aa4e64

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html