NFC: trf7970a: Set 'Modulator and SYS_CLK Control' after 'ISO Control'

Writing to the 'ISO Control' register may cause the contents of the
'Modulator and SYS_CLK Control' register to change so be sure to write
to 'Modulator and SYS_CLK Control' after writing to 'ISO Control'.

Note that writing to the 'Modulator and SYS_CLK Control' register
shouldn't be necessary at all according to the trf790a manual but testing
shows that it is necessary.

Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
NFC: trf7970a: Allow different Modulator and SYS_CLK Control register values

Currently the driver writes the same value to the 'Modulator and SYS_CLK
Control' register no matter what RF technology is being used. That works
for now but new RF technologies (e.g., ISO/IEC 14443-B) will require
different values to be written to that register. To support this, add a
member to the trf7970a structure which is set by the RF technology handling
code and used by the framing code when it writes to that register.

Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
NFC: trf7970a: Set correct Vin voltage in Chip Status Control register

Currently, the trf7970a driver assumes that the Vin voltage is 5V when
it writes to the 'Chip Status Control' register. That may not be correct
so use the regulator facility to get the Vin voltage and set the VRS5_3
bit correctly when writing to that register.

Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
NFC: trf7970a: Turn RF on after hardware is configured

The NFC digital layer calls the 'switch_rf' hook to turn the RF on before
it configures the RF technology and framing. There is potential to confuse
a tag doing it this way so don't enable the RF until the RF technology and
initial framing have been configured.

Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
NFC: trf7970a: Add pm_runtime support

Add pm_runtime support by moving the code that enables the trf7970a to
the pm_runtime hook routines. The pm_runtime 'autosuspend' feature is
used so that the device isn't disabled until at least 30 seconds have
passed since trf7970a_switch_rf_off() was last called.

The result is that when trf7970a_switch_rf_on() is called, the device
will be enabled and initialized (if it isn't already).  When
trf7970a_switch_rf_off() is called, it will turn off the RF immediately
but leave the device enabled for at least 30 seconds.
If 30 seconds have passed and the pm_runtime facility decides to suspend
the driver, the device will be disabled then.

Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
NFC: trf7970a: Don't return value from trf7970a_switch_rf_on()

trf7970a_switch_rf_on() no longer returns anything other than 0 so make
it void and clean up the code that checks for errors when its called.

Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
NFC: trf7970a: Add 'autosuspend-delay' DTS property

The trf7970a driver currently uses a fixed autosuspend delay of 30 seconds.
To enable users to customize the delay as they see fit, add support for the
new 'autosuspend-delay' DTS property (part of the nfc node) which can
override the default 30 seconds.

Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
NFC: trf7970a: Document the 'autosuspend-delay' DTS property

The trf7970a driver recently had support added for the 'autosuspend-delay'
property so document it.

Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
NFC: digital: Add macros for the ISO/IEC 14443-B Protocol

Add RF tech and framing macros for the ISO/IEC 14443-B Protocol.

Cc: Thierry Escande <thierry.escande@linux.intel.com>
Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
NFC: digital: Add support for ISO/IEC 14443-B Protocol

Add support for the ISO/IEC 14443-B protocol and Type 4B tags.
It is expected that there will be only one tag within range so the full
anticollision scheme is not implemented. Only the SENSB_REQ/SENSB_RES
and ATTRIB_REQ/ATTRIB_RES are implemented.

CC: Thierry Escande <thierry.escande@linux.intel.com>
Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
NFC: trf7970a: Add support for the ISO/IEC 14443-B and Type 4B tags

Now that the NFC digital layer has support for the ISO/IEC 14443-B
protocol and type 4B tags, add the corresponding support to the
trf7970a driver.

Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
NFC: pn544_i2c: Fix null pointer exception when not using platform data

Fixes a null pointer exception occurring when the IRQ request in
pn544_hci_i2c_probe fails and no platform data is available.

Signed-off-by: Clément Perrochaud <clement.perrochaud@nxp.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
NFC: st21nfca: Fix sparse: cast to restricted __be16

Fixing "sparse: cast to restricted __be16" message when building with
make C=1 CF=-D__CHECK_ENDIAN__

Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
NFC: hci: Fix sparse: cast to restricted __be16

Fixing "sparse: cast to restricted __be16" message when building with
make C=1 CF=-D__CHECK_ENDIAN__

Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
NFC: st21nfca: Fix warning: array subscript is above array bounds

Fix "warning: array subscript is above array bounds" in load_session

Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
NFC: st21nfca: Remove sporadic wait_tab variable from functions.

wait_tab variable is already global and may create conflicts.

Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
NFC: st21nfca: Add __packed to struct st21nfca_pipe_info

Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
NFC: st21nfca: st21nfca_hci_i2c_probe returns st21nfca_hci_probe result.

st21nfca_hci_probe return 0 in case of successful call and a different
value in any other cases.

There is no need to check for st21nfca_hci_probe return as this will be
checked after st21nfca_hci_i2c_probe is completed.

Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
NFC: st21nfca: Reworked st21nfca_request_resources

Remove struct st21nfca_i2c_phy* as this parameter can be retrieve
through i2c_get_clientdata(client)

Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
NFC: st21nfca: Improve st21nfca initialization by handling reboot properly

Change in st21nfca_hci_platform_init in order to handle in a better way the
internal reboot command.
Once the reboot is completed, the driver expect to receive a 0x7e filled
buffer.

Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>