NFC: trf7970a: add device tree option for 27MHz clock
Subsystems (5)
PATCH v3 1/3 NFC: trf7970a: add device tree option for 27MHz clock
The TRF7970A has configuration options to support hardware designs which use a 27.12MHz clock. This commit adds a device tree option 'clock-frequency' to support configuring the this chip for default 13.56MHz clock or the optional 27.12MHz clock.
--- .../devicetree/bindings/net/nfc/trf7970a.txt | 2 + drivers/nfc/trf7970a.c | 50 +++++++++++++++++----- 2 files changed, 41 insertions(+), 11 deletions(-)
Documentation/devicetree/bindings/net/nfc/trf7970a.txt +2 -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. +- clock-frequency: Set to specify that the input frequency to the trf7970a is 13560000Hz or 27120000Hz Example (for ARM-based BeagleBone with TRF7970A on SPI1):
@@ -43,6 +44,7 @@ Example (for ARM-based BeagleBone with TRF7970A on SPI1): irq-status-read-quirk; en2-rf-quirk; t5t-rmb-extra-byte-quirk; + clock-frequency = <27120000>; status = "okay"; }; };
drivers/nfc/trf7970a.c +39 -11
113 lines not on this page · raw message
Signature · 6 lines
2.7.4 -- 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
PATCH v3 2/3 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.
--- .../devicetree/bindings/net/nfc/trf7970a.txt | 2 ++ drivers/nfc/trf7970a.c | 26 +++++++++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/net/nfc/trf7970a.txt +2 -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-supply: Regulator specifying voltage for vdd-io - clock-frequency: Set to specify that the input frequency to the trf7970a is 13560000Hz or 27120000Hz Example (for ARM-based BeagleBone with TRF7970A on SPI1):
@@ -40,6 +41,7 @@ Example (for ARM-based BeagleBone with TRF7970A on SPI1): <&gpio2 5 GPIO_ACTIVE_LOW>; vin-supply = <&ldo3_reg>; vin-voltage-override = <5000000>; + vdd-io-supply = <&ldo2_reg>; autosuspend-delay = <30000>; irq-status-read-quirk; en2-rf-quirk;
drivers/nfc/trf7970a.c +25 -1
@@ -444,6 +444,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;
@@ -1051,6 +1052,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;
@@ -1767,7 +1773,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;
@@ -2105,6 +2111,24 @@ static int trf7970a_probe(struct spi_device *spi)if (uvolts >4000000 ) trf->chip_status_ctrl =TRF7970A_CHIP_STATUS_VRS5_3 ; + trf->regulator =devm_regulator_get (&spi->dev,"vdd-io" ); +if (IS_ERR (trf->regulator)) { + ret =PTR_ERR (trf->regulator); +dev_err (trf->dev,"Can't get VDD_IO regulator: %d\n" , ret); + goto err_destroy_lock; + } + + ret =regulator_enable (trf->regulator); +if (ret) { +dev_err (trf->dev,"Can't enable VDD_IO: %d\n" , ret); + goto err_destroy_lock; + } + +if (regulator_get_voltage (trf->regulator) ==1800000 ) { + trf->io_ctrl =TRF7970A_REG_IO_CTRL_IO_LOW ; +dev_dbg (trf->dev,"trf7970a config vdd_io to 1.8V\n" ); + } + trf->ddev = nfc_digital_allocate_device(&trf7970a_nfc_ops, TRF7970A_SUPPORTED_PROTOCOLS, NFC_DIGITAL_DRV_CAPS_IN_CRC |
Signature · 1 line
2.7.4
Re: [PATCH v3 2/3] NFC: trf7970a: Add device tree option of 1.8 Volt IO voltage
Quoted 9 lines · Geoff Lansberry
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.Signed-off-by Geoff Lansberry <[email protected]>--- .../devicetree/bindings/net/nfc/trf7970a.txt | 2 ++
Quoted 2 lines
drivers/nfc/trf7970a.c | 26 +++++++++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-)
Re: [PATCH v3 2/3] NFC: trf7970a: Add device tree option of 1.8 Volt IO voltage
In reply to Geoff LansberryQuoted 10 lines · Geoff Lansberry
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.Signed-off-by Geoff Lansberry <[email protected]>--- .../devicetree/bindings/net/nfc/trf7970a.txt | 2 ++ drivers/nfc/trf7970a.c | 26 +++++++++++++++++++++-
PATCH v3 3/3 nfc: trf7970a: Prevent repeated polling from crashing the kernel
In reply to Geoff LansberryFrom: Jaret Cantu <[email protected]>
Repeated polling attempts cause a NULL dereference error to occur. This is because the state of the trf7970a is currently reading but another request has been made to send a command before it has finished.
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
@@ -1496,6 +1496,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
2.7.4
Mark Greer
maintainerRe: [PATCH v3 3/3] nfc: trf7970a: Prevent repeated polling from crashing the kernel
Quoted 11 lines · Geoff Lansberry
From: Jaret Cantu <[email protected]>
Repeated polling attempts cause a NULL dereference error to occur. This is because the state of the trf7970a is currently reading but another request has been made to send a command before it has finished.
The solution is to properly kill the waiting reading (workqueue) before failing on the send.
Signed-off-by Geoff Lansberry <[email protected]>---
You've still provided virtually no information on the actual problem(s) nor justified why you think this is the best solution. You're adding code to a section of code that should _never_ be executed so the only reasonable things I can infer is that there are, at least, two problems:
1) There is a bug causing execution to get into this block of code.
2) Once in this block of code, there is another bug.
You seem to be attempting to fix 2) and completely ignoring 1).
1) is the first bug that needs to be root-caused and fixed.
Also, what exactly is the "NULL dereference error" you mention? Is this the neard crash you talked about in another thread or is this a kernel crash? If it is the kernel crash, please post the relevant information. If this is the neard crash - which seems unlikely - then how can changing a section of kernel code that shouldn't be executed in the first place fix that?
Mark
Re: [PATCH v3 3/3] nfc: trf7970a: Prevent repeated polling from crashing the kernel
Mark - I'm sorry, but I did not write this code, and therefore was not
able to accurately describe it. It is fixing a different issue, not
the neard segfault that we are still chasing. Last week Jaret Cantu sent a separate email explaining the purpose of the code, which had
you copied, did you see that? Does it explain why it was done to
your satisfaction? I've asked him to join in on the effort to push
the change upstream, however he will not be available until the new year.
I know you did suggest that we split off that change from the others,
and if now is the time to do that, let me know. If you don't have
the email from Jaret, also please let me know and I will forward it to you.
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 34 lines · Mark Greer
Quoted 11 lines · Geoff Lansberry
From: Jaret Cantu <[email protected]>
Repeated polling attempts cause a NULL dereference error to occur. This is because the state of the trf7970a is currently reading but another request has been made to send a command before it has finished.
The solution is to properly kill the waiting reading (workqueue) before failing on the send.
Signed-off-by Geoff Lansberry <[email protected]>---
You've still provided virtually no information on the actual problem(s) nor justified why you think this is the best solution. You're adding code to a section of code that should _never_ be executed so the only reasonable things I can infer is that there are, at least, two problems:
1) There is a bug causing execution to get into this block of code.
2) Once in this block of code, there is another bug.
You seem to be attempting to fix 2) and completely ignoring 1).
1) is the first bug that needs to be root-caused and fixed.Also, what exactly is the "NULL dereference error" you mention? Is this the neard crash you talked about in another thread or is this a kernel crash? If it is the kernel crash, please post the relevant information. If this is the neard crash - which seems unlikely - then how can changing a section of kernel code that shouldn't be executed in the first place fix that?
Mark
--
Mark Greer
maintainerRe: [PATCH v3 3/3] nfc: trf7970a: Prevent repeated polling from crashing the kernel
Quoted 5 lines · Geoff Lansberry
Mark - I'm sorry, but I did not write this code, and therefore was not
able to accurately describe it. It is fixing a different issue, not
the neard segfault that we are still chasing. Last week Jaret Cantu sent a separate email explaining the purpose of the code, which had you copied, did you see that?
Hm, no, I didn't. I received an email from Justin Bronder but not from Jaret Cantu. Justin's email did help but is still pretty high-level. We need a clear understanding as to what is happening in the digital layer and the driver to know how execution is getting into a block of error handling code that should never be executed. Once we understand that we can start thinking about what the best fix is.
Quoted 4 lines
Does it explain why it was done to
your satisfaction? I've asked him to join in on the effort to push
the change upstream, however he will not be available until the new year.
I expect that it would help if he joins. After the holidays is fine - I think many people are taking it easy for the next week or so, anyway.
Quoted 4 lines
I know you did suggest that we split off that change from the others,
and if now is the time to do that, let me know. If you don't have
the email from Jaret, also please let me know and I will forward it to you.
I think it would help you if you split it off because the first two patches have a good chance of being accepted but this one doesn't (yet). If you separate the them, it will make it easier for Samuel to take the first two (or he may take the first two anyway but its always good to make it as easy maintainers as you can).
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
Re: [PATCH v3 3/3] nfc: trf7970a: Prevent repeated polling from crashing the kernel
Mark - I will split this off soon.
In the meantime - here is some more info about how we use it.
We do use NFC structures. I did find an interesting clue in that
there are certain bottles that cause neard to segfault, I'm not sure what is different about them. We write a string, like "coppola_chardonnay_2015" to the bottles. Come to think of it, I haven't done anything special to make that an ndef record, just assumed that it would happen by default, I'll look into this further.
Also, I've been running neard with --plugin nfctype2. Just in case
the problem was happening due to cycling through other tag types. It
didn't seem to make any difference, but I have not gone back to default.
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 35 lines · Mark Greer
Quoted 5 lines · Geoff Lansberry
Mark - I'm sorry, but I did not write this code, and therefore was not
able to accurately describe it. It is fixing a different issue, not
the neard segfault that we are still chasing. Last week Jaret Cantu sent a separate email explaining the purpose of the code, which had you copied, did you see that?Hm, no, I didn't. I received an email from Justin Bronder but not from Jaret Cantu. Justin's email did help but is still pretty high-level. We need a clear understanding as to what is happening in the digital layer and the driver to know how execution is getting into a block of error handling code that should never be executed. Once we understand that we can start thinking about what the best fix is.
Quoted 4 lines
Does it explain why it was done to
your satisfaction? I've asked him to join in on the effort to push
the change upstream, however he will not be available until the new year.I expect that it would help if he joins. After the holidays is fine - I think many people are taking it easy for the next week or so, anyway.
Quoted 4 lines
I know you did suggest that we split off that change from the others,
and if now is the time to do that, let me know. If you don't have
the email from Jaret, also please let me know and I will forward it to you.I think it would help you if you split it off because the first two patches have a good chance of being accepted but this one doesn't (yet). If you separate the them, it will make it easier for Samuel to take the first two (or he may take the first two anyway but its always good to make it as easy maintainers as you can).
Mark
--
Mark Greer
maintainerRe: [PATCH v3 3/3] nfc: trf7970a: Prevent repeated polling from crashing the kernel
[Please stop top-posting. Bottom-post only to these lists.]
Hi Geoff & happy new year.
Quoted 1 line · Geoff Lansberry
Mark - I will split this off soon.
OK
Quoted 6 lines
In the meantime - here is some more info about how we use it.
We do use NFC structures. I did find an interesting clue in that
there are certain bottles that cause neard to segfault, I'm not sure what is different about them. We write a string, like "coppola_chardonnay_2015" to the bottles.
Off the top of my head, it could be the length of the text. It would be useful to compare the data that works to the data that doesn't work. Can you install NXP's 'TagInfo' app on a smartphone and scan tags with working & non-working data? You can email the data from the app to yourself, edit out the cruft, and share here.
Quoted 3 lines
Come to think of it, I
haven't done anything special to make that an ndef record, just assumed that it would happen by default, I'll look into this further.
If you wrote the data using neard, it will be NDEF formatted. Since it is working this well, it is virtually guaranteed that the data is NDEF formatted.
Quoted 4 lines
Also, I've been running neard with --plugin nfctype2. Just in case
the problem was happening due to cycling through other tag types. It
didn't seem to make any difference, but I have not gone back to default.
Good to know, thanks.
Mark
--
Re: [PATCH v3 3/3] nfc: trf7970a: Prevent repeated polling from crashing the kernel
Quoted 1 line · Mark Greer
[Please stop top-posting. Bottom-post only to these lists.]
Sorry; gmail keeps baiting me to do it...
Quoted 7 lines
Hi Geoff & happy new year.
Quoted 1 line · Geoff Lansberry
Mark - I will split this off soon.
OK
Thanks for the reminder!
Quoted 8 lines
Quoted 7 lines
In the meantime - here is some more info about how we use it.
We do use NFC structures. I did find an interesting clue in that
there are certain bottles that cause neard to segfault, I'm not sure what is different about them. We write a string, like "coppola_chardonnay_2015" to the bottles.
Quoted 6 lines
Off the top of my head, it could be the length of the text. It would be useful to compare the data that works to the data that doesn't work. Can you install NXP's 'TagInfo' app on a smartphone and scan tags with working & non-working data? You can email the data from the app to yourself, edit out the cruft, and share here.
The data is always the same - and the tags are all the same. Only difference is that the tag is physically different, and perhaps orientation; distance from antenna to tag is fixed. I can't even
write the tags at all, so reading them will show blank. Also a minor
but significant detail, is that the tags are embedded in such a way that the phone cannot get close enough to them to connect.
Quoted 8 lines
Quoted 4 lines
Come to think of it, I
haven't done anything special to make that an ndef record, just assumed that it would happen by default, I'll look into this further.If you wrote the data using neard, it will be NDEF formatted. Since it is working this well, it is virtually guaranteed that the data is NDEF formatted.
OK, good.
Quoted 10 lines
Quoted 5 lines
Also, I've been running neard with --plugin nfctype2. Just in case
the problem was happening due to cycling through other tag types. It
didn't seem to make any difference, but I have not gone back to default.Good to know, thanks.
Mark
--
Mark Greer
maintainerRe: [PATCH v3 3/3] nfc: trf7970a: Prevent repeated polling from crashing the kernel
Quoted 17 lines · Geoff Lansberry
Quoted 9 lines · Mark Greer
Quoted 6 lines · Geoff Lansberry
In the meantime - here is some more info about how we use it.
We do use NFC structures. I did find an interesting clue in that
there are certain bottles that cause neard to segfault, I'm not sure what is different about them. We write a string, like "coppola_chardonnay_2015" to the bottles.Quoted 6 lines
Off the top of my head, it could be the length of the text. It would be useful to compare the data that works to the data that doesn't work. Can you install NXP's 'TagInfo' app on a smartphone and scan tags with working & non-working data? You can email the data from the app to yourself, edit out the cruft, and share here.
Quoted 3 lines
The data is always the same - and the tags are all the same. Only difference is that the tag is physically different, and perhaps orientation; distance from antenna to tag is fixed.
Interesting... They're all type 2 tags, right?
Quoted 4 lines
I can't even
write the tags at all, so reading them will show blank. Also a minor
but significant detail, is that the tags are embedded in such a way that the phone cannot get close enough to them to connect.
This section had me completely confused for a couple minutes until I realized that you mean that you can read & write the tags using the trf7970a with an attached antenna but not with your phone. Is that correct?
If so, try a tag that isn't embedded in something else and move it around the back of the phone. Try to find where it works best. The phone manufacturers are notorius for paying little attention to the NFC antenna they put on their products. For example, I have a Samsung S5 next to me and it seems to work best around the center of the phone. I've used others where I had to use the upper-left or upper-right corner of the phone.
Mark
Re: [PATCH v3 3/3] nfc: trf7970a: Prevent repeated polling from crashing the kernel
Quoted 18 lines · Mark Greer
Quoted 17 lines · Geoff Lansberry
Quoted 15 lines · Mark Greer
Quoted 6 lines · Geoff Lansberry
In the meantime - here is some more info about how we use it.
We do use NFC structures. I did find an interesting clue in that
there are certain bottles that cause neard to segfault, I'm not sure what is different about them. We write a string, like "coppola_chardonnay_2015" to the bottles.Off the top of my head, it could be the length of the text. It would be useful to compare the data that works to the data that doesn't work. Can you install NXP's 'TagInfo' app on a smartphone and scan tags with working & non-working data? You can email the data from the app to yourself, edit out the cruft, and share here.
Quoted 5 lines
Quoted 3 lines
The data is always the same - and the tags are all the same. Only difference is that the tag is physically different, and perhaps orientation; distance from antenna to tag is fixed.
Interesting... They're all type 2 tags, right?
Yes type 2.
Quoted 9 lines
Quoted 5 lines
I can't even
write the tags at all, so reading them will show blank. Also a minor
but significant detail, is that the tags are embedded in such a way that the phone cannot get close enough to them to connect.This section had me completely confused for a couple minutes until I realized that you mean that you can read & write the tags using the trf7970a with an attached antenna but not with your phone. Is that correct?
Correct, due to the physical arrangement of the part the tag is embedded in.
Quoted 7 lines
If so, try a tag that isn't embedded in something else and move it around the back of the phone. Try to find where it works best. The phone manufacturers are notorius for paying little attention to the NFC antenna they put on their products. For example, I have a Samsung S5 next to me and it seems to work best around the center of the phone. I've used others where I had to use the upper-left or upper-right corner of the phone.
I can borrow a phone and try, I do have some other tags. This will take me some time and
I'm not optimistic that we will learn much, other than that the tag
was not programmed when
it does not work. Don't wait on this answer.
Quoted 3 lines
Mark
--
Quoted 8 lines · Geoff Lansberry
The TRF7970A has configuration options to support hardware designs which use a 27.12MHz clock. This commit adds a device tree option 'clock-frequency' to support configuring the this chip for default 13.56MHz clock or the optional 27.12MHz clock.
Signed-off-by Geoff Lansberry <[email protected]>--- .../devicetree/bindings/net/nfc/trf7970a.txt | 2 +
Quoted 2 lines
drivers/nfc/trf7970a.c | 50 +++++++++++++++++----- 2 files changed, 41 insertions(+), 11 deletions(-)
--
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
Quoted 7 lines · Geoff Lansberry
The TRF7970A has configuration options to support hardware designs which use a 27.12MHz clock. This commit adds a device tree option 'clock-frequency' to support configuring the this chip for default 13.56MHz clock or the optional 27.12MHz clock.
Signed-off-by Geoff Lansberry <[email protected]>---
Hi Geoff,
Quoted 10 lines · Geoff Lansberry
The TRF7970A has configuration options to support hardware designs which use a 27.12MHz clock. This commit adds a device tree option 'clock-frequency' to support configuring the this chip for default 13.56MHz clock or the optional 27.12MHz clock.
Signed-off-by Geoff Lansberry <[email protected]>--- .../devicetree/bindings/net/nfc/trf7970a.txt | 2 + drivers/nfc/trf7970a.c | 50 +++++++++++++++++----- 2 files changed, 41 insertions(+), 11 deletions(-)
Patches #1 and #2 applied to nfc-next. I'll wait for you to rework #3 before merging.
Cheers,
Samuel.
Quoted 12 lines · Samuel Ortiz
Hi Geoff,
Quoted 9 lines · Geoff Lansberry
The TRF7970A has configuration options to support hardware designs which use a 27.12MHz clock. This commit adds a device tree option 'clock-frequency' to support configuring the this chip for default 13.56MHz clock or the optional 27.12MHz clock.
Signed-off-by Geoff Lansberry <[email protected]>--- .../devicetree/bindings/net/nfc/trf7970a.txt | 2 + drivers/nfc/trf7970a.c | 50
Quoted 8 lines
+++++++++++++++++-----
Quoted 1 line
2 files changed, 41 insertions(+), 11 deletions(-)Patches #1 and #2 applied to nfc-next. I'll wait for you to rework #3 before merging.
Cheers,
Samuel.
Excellent - thank you. For the record, we may end up dropping #3.
Geoff