NFC: trf7970a: Add option to reduce antenna gain
Subsystems (5)
v3 cover NFC: trf7970a: Add option to reduce antenna gain
The TRF7970a device is sensitive to RF disturbances, which can make it hard to pass some EMC immunity tests. By reducing the RX antenna gain, the device becomes less sensitive to EMC disturbances, as a trade-off against antenna performance.
---
v2 -> v3:
- User SI units for the DT property, instead of the direct register value
v1 -> v2:
- Added vendor prefix
- Added units
PATCH v3 1/2 dt-bindings: net/nfc: ti,trf7970a: Add ti,rx-gain-reduction-db option
Add option to reduce the RX antenna gain to be able to reduce the sensitivity.
--- Documentation/devicetree/bindings/net/nfc/ti,trf7970a.yaml | 7 +++++++ 1 file changed, 7 insertions(+)
Documentation/devicetree/bindings/net/nfc/ti,trf7970a.yaml +7 -0
@@ -55,6 +55,12 @@ properties: description: | Regulator for supply voltage to VIN pin + ti,rx-gain-reduction-db: + $ref: /schemas/types.yaml#/definitions/uint32 + description: | + Specify an RX gain reduction to reduce antenna sensitivity with 5dB per + increment, with a maximum of 15dB. Supported values: [0, 5, 10, 15]. + required: - compatible - interrupts
@@ -95,5 +101,6 @@ examples: irq-status-read-quirk; en2-rf-quirk; clock-frequency = <27120000>; + ti,rx-gain-reduction-db = <15>; }; };
Signature · 1 line
2.39.2
Re: [PATCH v3 1/2] dt-bindings: net/nfc: ti,trf7970a: Add ti,rx-gain-reduction-db option
Quoted 13 lines · Paul Geurts
Add option to reduce the RX antenna gain to be able to reduce the sensitivity.
Signed-off-by Paul Geurts <[email protected]>--- Documentation/devicetree/bindings/net/nfc/ti,trf7970a.yaml | 7 +++++++ 1 file changed, 7 insertions(+)Documentation/devicetree/bindings/net/nfc/ti,trf7970a.yaml +0
-0
Documentation/devicetree/bindings/net/nfc/ti,trf7970a.yaml properties: · line 58
Quoted 4 lines
Documentation/devicetree/bindings/net/nfc/ti,trf7970a.yaml +1
-0@@ -55,6 +55,12 @@ properties: description: | Regulator for supply voltage to VIN pin + ti,rx-gain-reduction-db:
I'll add db unit to the dtschema.
Best regards,
Krzysztof
Re: [PATCH v3 1/2] dt-bindings: net/nfc: ti,trf7970a: Add ti,rx-gain-reduction-db option
Quoted 17 lines · Krzysztof Kozlowski
Quoted 16 lines · Paul Geurts
Add option to reduce the RX antenna gain to be able to reduce the sensitivity.
Signed-off-by Paul Geurts <[email protected]>--- Documentation/devicetree/bindings/net/nfc/ti,trf7970a.yaml | 7 +++++++ 1 file changed, 7 insertions(+)Documentation/devicetree/bindings/net/nfc/ti,trf7970a.yaml +0
-0@@ -55,6 +55,12 @@ properties: description: | Regulator for supply voltage to VIN pin
Quoted 5 lines
Documentation/devicetree/bindings/net/nfc/ti,trf7970a.yaml properties: · line 58
Quoted 1 line
Documentation/devicetree/bindings/net/nfc/ti,trf7970a.yaml +1
-0+ ti,rx-gain-reduction-db:I'll add db unit to the dtschema.
Reviewed-by Krzysztof Kozlowski <[email protected]>
BTW, I found your patchset only via patchwork, because Gmail flagged your entire v3 and others as spam. You might need to check your SMTP setup. I see DMARC failure from google in the headers:
Authentication-Results: mx.google.com;
spf=pass (google.com: domain of
[email protected] designates 147........ as permitted sender) smtp.mailfrom="[email protected]";
dmarc=fail (p=REJECT sp=REJECT dis=QUARANTINE)
header.from=prodrive-technologies.com
Maybe you sent via kernel.org something with different address? Actually this looks like that - your From does not match kernel.org at all. Rules are quite strict recently and for example you cannot use non-kernel.org SMTP server for kernel.org accounts (see kernel users wiki).
Anyway, likely any other future patches or such patches to other people to end up in spam as well.
Best regards,
Krzysztof
RE: [PATCH v3 1/2] dt-bindings: net/nfc: ti,trf7970a: Add ti,rx-gain-reduction-db option
Quoted 35 lines · Krzysztof Kozlowski
Quoted 20 lines · Paul Geurts
Quoted 19 lines
Add option to reduce the RX antenna gain to be able to reduce the sensitivity.
Signed-off-by Paul Geurts <[email protected]>--- Documentation/devicetree/bindings/net/nfc/ti,trf7970a.yaml | 7 +++++++ 1 file changed, 7 insertions(+)(quoted diff) +0
-0
a/Documentation/devicetree/bindings/net/nfc/ti,trf7970a.yamlb/Documentation/devicetree/bindings/net/nfc/ti,trf7970a.yamlindexd0332eb76ad2..5f49bd9ac5e6100644Documentation/devicetree/bindings/net/nfc/ti,trf7970a.yaml +0
-0@@ -55,6 +55,12 @@ properties: description: | Regulator for supply voltage to VIN pinQuoted 5 lines
Documentation/devicetree/bindings/net/nfc/ti,trf7970a.yaml properties: · line 58
Quoted 1 line
Documentation/devicetree/bindings/net/nfc/ti,trf7970a.yaml +1
-0+ ti,rx-gain-reduction-db:I'll add db unit to the dtschema.
Reviewed-by Krzysztof Kozlowski <[email protected]>BTW, I found your patchset only via patchwork, because Gmail flagged your entire v3 and others as spam. You might need to check your SMTP setup. I see DMARC failure from google in the headers:
Authentication-Results: mx.google.com;
spf=pass (google.com: domain of
[email protected] designates 147........ as permitted sender) smtp.mailfrom="[email protected]";
dmarc=fail (p=REJECT sp=REJECT dis=QUARANTINE) header.from=prodrive-technologies.com
Quoted 4 lines
Maybe you sent via kernel.org something with different address? Actually this looks like that - your From does not match kernel.org at all. Rules are quite strict recently and for example you cannot use non-kernel.org SMTP server for kernel.org accounts (see kernel users wiki).
Anyway, likely any other future patches or such patches to other people to end up in spam as well.
Thanks for the heads up! I'll contact our IT dept. to look into that. And thanks for the review!
Quoted 3 lines
Best regards,
Krzysztof
Paul
PATCH v3 2/2 NFC: trf7970a: Create device-tree parameter for RX gain reduction
In reply to Paul GeurtsThe TRF7970a device is sensitive to RF disturbances, which can make it hard to pass some EMC immunity tests. By reducing the RX antenna gain, the device becomes less sensitive to EMC disturbances, as a trade-off against antenna performance.
Add a device tree option to select RX gain reduction to improve EMC performance.
Selecting a communication standard in the ISO control register resets the RX antenna gain settings. Therefore set the RX gain reduction everytime the ISO control register changes, when the option is used.
--- drivers/nfc/trf7970a.c | 91 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 80 insertions(+), 11 deletions(-)
drivers/nfc/trf7970a.c +80 -11
@@ -272,12 +272,18 @@#define TRF7970A_MODULATOR_EN_OOK BIT(6)#define TRF7970A_MODULATOR_27MHZ BIT(7) +#define TRF7970A_RX_GAIN_REDUCTION_MAX_DB 15 +#define TRF7970A_RX_GAIN_REDUCTION_DB_PER_LSB 5#define TRF7970A_RX_SPECIAL_SETTINGS_NO_LIM BIT(0)#define TRF7970A_RX_SPECIAL_SETTINGS_AGCR BIT(1) -#define TRF7970A_RX_SPECIAL_SETTINGS_GD_0DB (0x0 << 2) -#define TRF7970A_RX_SPECIAL_SETTINGS_GD_5DB (0x1 << 2) -#define TRF7970A_RX_SPECIAL_SETTINGS_GD_10DB (0x2 << 2) -#define TRF7970A_RX_SPECIAL_SETTINGS_GD_15DB (0x3 << 2) +#define TRF7970A_RX_SPECIAL_SETTINGS_GD_SHIFT 2 +#define TRF7970A_RX_SPECIAL_SETTINGS_GD_MAX (0x3) +#define TRF7970A_RX_SPECIAL_SETTINGS_GD_MASK (TRF7970A_RX_SPECIAL_SETTINGS_GD_MAX << \ + TRF7970A_RX_SPECIAL_SETTINGS_GD_SHIFT) +#define TRF7970A_RX_SPECIAL_SETTINGS_GD_0DB (0x0 << TRF7970A_RX_SPECIAL_SETTINGS_GD_SHIFT) +#define TRF7970A_RX_SPECIAL_SETTINGS_GD_5DB (0x1 << TRF7970A_RX_SPECIAL_SETTINGS_GD_SHIFT) +#define TRF7970A_RX_SPECIAL_SETTINGS_GD_10DB (0x2 << TRF7970A_RX_SPECIAL_SETTINGS_GD_SHIFT) +#define TRF7970A_RX_SPECIAL_SETTINGS_GD_15DB (0x3 << TRF7970A_RX_SPECIAL_SETTINGS_GD_SHIFT)#define TRF7970A_RX_SPECIAL_SETTINGS_HBT BIT(4)#define TRF7970A_RX_SPECIAL_SETTINGS_M848 BIT(5)#define TRF7970A_RX_SPECIAL_SETTINGS_C424 BIT(6)
@@ -452,6 +458,8 @@ struct trf7970a {unsigned int timeout;bool ignore_timeout;struct delayed_work timeout_work; +u8 rx_gain_reduction; +bool custom_rx_gain_reduction; };static int trf7970a_cmd (struct trf7970a *trf,u8 opcode)
@@ -551,6 +559,41 @@ static int trf7970a_read_irqstatus(struct trf7970a *trf, u8 *status)return ret; } +static int trf7970a_update_rx_gain_reduction (struct trf7970a *trf) +{ +int ret =0 ; +u8 reg; + +if (!trf->custom_rx_gain_reduction) +return 0 ; + + ret =trf7970a_read (trf,TRF7970A_RX_SPECIAL_SETTINGS , ®); +if (ret) +return ret; + reg &= ~(TRF7970A_RX_SPECIAL_SETTINGS_GD_MASK ); + reg |= trf->rx_gain_reduction; + + ret =trf7970a_write (trf,TRF7970A_RX_SPECIAL_SETTINGS , reg); + +return ret; +} + +static int trf7970a_update_iso_ctrl_register (struct trf7970a *trf,u8 iso_ctrl) +{ +int ret; + + ret =trf7970a_write (trf,TRF7970A_ISO_CTRL , iso_ctrl); +if (ret) +return ret; +/* +* Every time the ISO_CTRL register is written, the RX special setting register is reset by +* the chip. When a custom gain reguduction is required, it should be rewritten now. +*/ + ret =trf7970a_update_rx_gain_reduction (trf); + +return ret; +} +static int trf7970a_read_target_proto (struct trf7970a *trf,u8 *target_proto) {int ret;
@@ -930,8 +973,7 @@ static irqreturn_t trf7970a_irq(int irq, void *dev_id) }if (iso_ctrl != trf->iso_ctrl) { - ret =trf7970a_write (trf,TRF7970A_ISO_CTRL , - iso_ctrl); + ret =trf7970a_update_iso_ctrl_register (trf, iso_ctrl);if (ret) goto err_unlock_exit;
@@ -1035,6 +1077,11 @@ static int trf7970a_init(struct trf7970a *trf)if (ret) goto err_out; +/* Set the gain reduction after soft init */ + ret =trf7970a_update_rx_gain_reduction (trf); +if (ret) + goto err_out; + ret =trf7970a_cmd (trf,TRF7970A_CMD_IDLE );if (ret) goto err_out;
@@ -1309,7 +1356,7 @@ static int trf7970a_in_config_framing(struct trf7970a *trf, int framing) }if (iso_ctrl != trf->iso_ctrl) { - ret =trf7970a_write (trf,TRF7970A_ISO_CTRL , iso_ctrl); + ret =trf7970a_update_iso_ctrl_register (trf, iso_ctrl);if (ret)return ret;
@@ -1441,7 +1488,7 @@ static int trf7970a_per_cmd_config(struct trf7970a *trf, }if (iso_ctrl != trf->iso_ctrl) { - ret =trf7970a_write (trf,TRF7970A_ISO_CTRL , iso_ctrl); + ret =trf7970a_update_iso_ctrl_register (trf, iso_ctrl);if (ret)return ret;
@@ -1605,8 +1652,7 @@ static int trf7970a_tg_config_rf_tech(struct trf7970a *trf, int tech)*/ if ((trf->framing ==NFC_DIGITAL_FRAMING_NFC_DEP_ACTIVATED ) && (trf->iso_ctrl_tech != trf->iso_ctrl)) { - ret =trf7970a_write (trf,TRF7970A_ISO_CTRL , - trf->iso_ctrl_tech); + ret =trf7970a_update_iso_ctrl_register (trf, trf->iso_ctrl_tech); trf->iso_ctrl = trf->iso_ctrl_tech; }
@@ -1654,7 +1700,7 @@ static int trf7970a_tg_config_framing(struct trf7970a *trf, int framing) trf->framing = framing;if (iso_ctrl != trf->iso_ctrl) { - ret =trf7970a_write (trf,TRF7970A_ISO_CTRL , iso_ctrl); + ret =trf7970a_update_iso_ctrl_register (trf, iso_ctrl);if (ret)return ret;
@@ -1755,6 +1801,10 @@ static int _trf7970a_tg_listen(struct nfc_digital_dev *ddev, u16 timeout,if (ret) goto out_err; + ret =trf7970a_update_rx_gain_reduction (trf); +if (ret) + goto out_err; + ret =trf7970a_write (trf,TRF7970A_REG_IO_CTRL , trf->io_ctrl |TRF7970A_REG_IO_CTRL_VRS (0x1 ));if (ret)
@@ -1945,6 +1995,10 @@ static int trf7970a_startup(struct trf7970a *trf)if (ret)return ret; + ret =trf7970a_update_rx_gain_reduction (trf); +if (ret) +return ret; +pm_runtime_set_active (trf->dev);pm_runtime_enable (trf->dev);pm_runtime_mark_last_busy (trf->dev);
@@ -1993,6 +2047,7 @@ static int trf7970a_probe(struct spi_device *spi)struct trf7970a *trf;int uvolts, autosuspend_delay, ret;u32 clk_freq =TRF7970A_13MHZ_CLOCK_FREQUENCY ; +u32 rx_gain_reduction_db;if (!np) {dev_err (&spi->dev,"No Device Tree entry\n" );
@@ -2054,6 +2109,20 @@ static int trf7970a_probe(struct spi_device *spi) trf->modulator_sys_clk_ctrl =0 ; } +if (of_property_read_u32 (np,"ti,rx-gain-reduction-db" , &rx_gain_reduction_db) ==0 ) { +if (rx_gain_reduction_db >TRF7970A_RX_GAIN_REDUCTION_MAX_DB ) { +dev_warn (trf->dev,"RX Gain reduction too high. Ignored\n" ); + }else if ((rx_gain_reduction_db %TRF7970A_RX_GAIN_REDUCTION_DB_PER_LSB )) { +dev_warn (trf->dev,"RX Gain must be set in 5 dB increments. Ignored\n" ); + }else { +dev_dbg (trf->dev,"RX gain set to -%udB\n" , rx_gain_reduction_db); + trf->rx_gain_reduction = ((rx_gain_reduction_db / +TRF7970A_RX_GAIN_REDUCTION_DB_PER_LSB ) << +TRF7970A_RX_SPECIAL_SETTINGS_GD_SHIFT ); + trf->custom_rx_gain_reduction = true; + } + } + ret = devm_request_threaded_irq(trf->dev, spi->irq, NULL, trf7970a_irq, IRQF_TRIGGER_RISING | IRQF_ONESHOT,
Signature · 1 line
2.39.2
Re: [PATCH v3 2/2] NFC: trf7970a: Create device-tree parameter for RX gain reduction
Quoted 8 lines · Paul Geurts
The TRF7970a device is sensitive to RF disturbances, which can make it hard to pass some EMC immunity tests. By reducing the RX antenna gain, the device becomes less sensitive to EMC disturbances, as a trade-off against antenna performance.
Add a device tree option to select RX gain reduction to improve EMC performance.
Quoted 8 lines
Selecting a communication standard in the ISO control register resets the RX antenna gain settings. Therefore set the RX gain reduction everytime the ISO control register changes, when the option is used.
Signed-off-by Paul Geurts <[email protected]>--- drivers/nfc/trf7970a.c | 91 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 80 insertions(+), 11 deletions(-)
Best regards,
Krzysztof
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 8 lines · On Thu, 26 Jun 2025 16:12:40 +0200 you wrote:
The TRF7970a device is sensitive to RF disturbances, which can make it hard to pass some EMC immunity tests. By reducing the RX antenna gain, the device becomes less sensitive to EMC disturbances, as a trade-off against antenna performance.
Signed-off-by Paul Geurts <[email protected]>[...]
Here is the summary with links:
- [v3,1/2] dt-bindings: net/nfc: ti,trf7970a: Add ti,rx-gain-reduction-db option
https://git.kernel.org/netdev/net-next/c/2bee162a28fb - [v3,2/2] NFC: trf7970a: Create device-tree parameter for RX gain reduction https://git.kernel.org/netdev/net-next/c/5d69351820ea
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html