Commit Graph

30 Commits

Author SHA1 Message Date
Joakim Zhang 2143242c69 MLK-24364 mxc: sim: add runtime pm support
Add runtime pm support for SIM.

Reviewed-by: Fugang Duan <fugang.duan@nxp.com>
Signed-off-by: Joakim Zhang <qiangqing.zhang@nxp.com>
2020-07-02 21:32:13 +08:00
Joakim Zhang 1de612cb22 MLK-24363-2 mxc: emvsim: fix error report in probe stage
In probe stage, setting "emvsim_dev.parent = &pdev->dev" after error
report which is unreasonable, this patch fixes this issue.

Reviewed-by: Fugang Duan <fugang.duan@nxp.com>
Signed-off-by: Joakim Zhang <qiangqing.zhang@nxp.com>
2020-07-02 21:32:12 +08:00
Joakim Zhang 68f1614266 MLK-24363-1 mxc: emvsim: add error check when enable clk
Add error check when enable clk and register misc device at the end of
probe stage. This patch just improve and clean up the code, no function
change.

Fixes: commit d494420149 ("MLK-23793-2 mxc: emvsim: add runtime pm support")
Reviewed-by: Fugang Duan <fugang.duan@nxp.com>
Signed-off-by: Joakim Zhang <qiangqing.zhang@nxp.com>
2020-07-02 21:32:12 +08:00
Joakim Zhang 511ca8224d LF-1573 mxc: sim: Unchecked return value
Coverity report: CID = 10280137

check_return: Calling clk_prepare_enable without checking return value
(as is done elsewhere 8 out of 10 times).

Reviewed-by: Fugang Duan <fugang.duan@nxp.com>
Signed-off-by: Joakim Zhang <qiangqing.zhang@nxp.com>
2020-06-23 19:50:41 +08:00
Joakim Zhang af5b1d275e LF-1572 mxc: sim: Unchecked return value
Coverity report: CID = 10280138

check_return: Calling clk_prepare_enable without checking return value
(as is done elsewhere 8 out of 10 times).

Reviewed-by: Fugang Duan <fugang.duan@nxp.com>
Signed-off-by: Joakim Zhang <qiangqing.zhang@nxp.com>
2020-06-23 19:50:41 +08:00
Joakim Zhang a93e76030c MLK-20236 mxc: sim/emvsim: useless call
Coverity reprot: CID = 4159427

side_effect_free: Calling emvsim_check_baud_rate(&emvsim->baud_rate)
is only useful for its return value, which is ignored.

Reviewed-by: Fugang Duan <fugang.duan@nxp.com>
Signed-off-by: Joakim Zhang <qiangqing.zhang@nxp.com>
2020-06-19 22:23:23 +08:00
Joakim Zhang d494420149 MLK-23793-2 mxc: emvsim: add runtime pm support
Add runtime pm support in emvsim driver. Reading power mode from debug
monitor, EMVSIM_0 was on and with this patch it is lp.

Reviewed-by: Fugang Duan <fugang.duan@nxp.com>
Signed-off-by: Joakim Zhang <qiangqing.zhang@nxp.com>
2020-04-16 12:51:20 +08:00
Joakim Zhang 4522d69bd9 MLK-23793-1 mxc: emvsim: fix pm issue
Should enable clock when open_cnt = 1.

Reviewed-by: Fugang Duan <fugang.duan@nxp.com>
Signed-off-by: Joakim Zhang <qiangqing.zhang@nxp.com>
2020-04-16 12:51:20 +08:00
Joakim Zhang 7a059a09be sim: emvsim: add multi power domain support
Add multi power domain support for emvsim as it needs power domain both
SOC and Board level.

Signed-off-by: Joakim Zhang <qiangqing.zhang@nxp.com>
2019-11-25 15:48:02 +08:00
Joakim Zhang b3e7783229 MLK-22217 mxc: emvsim: add value adjustment for cwt/bwt timer
Add value adjustment for cwt/bwt timer, otherwise it will fail with
ultimate cwt/bwt value.

Signed-off-by: Joakim Zhang <qiangqing.zhang@nxp.com>
Acked-by: Fugang Duan <fugang.duan@nxp.com>
2019-11-25 15:48:02 +08:00
Joakim Zhang 297bfc6c1d MLK-22216 mxc: emvsim: last character need be transmitted separately with no guard time
It can't receive when transmitting on EMVSIM IP. ICC will send response
quickly when Terminal transmits last character with guard time. If the
response came to Terminal before the guard time expired, the Terminal
would not receive the respone. So should transmit last character with no
guard time.

This patch intends to fix the communication failure when setting guard
time.

This will cause about 1 ETU delay before transmitting last character
(according to timing measured), but it does not matter.

Signed-off-by: Joakim Zhang <qiangqing.zhang@nxp.com>
Acked-by: Fugang Duan <fugang.duan@nxp.com>
2019-11-25 15:48:02 +08:00
Joakim Zhang 0612dea846 MLK-22215 mxc: emvsim: correct irq mask and clear irq status before receiving
Just clean up the code and normalize the code.

Signed-off-by: Joakim Zhang <qiangqing.zhang@nxp.com>
Acked-by: Fugang Duan <fugang.duan@nxp.com>
2019-11-25 15:48:01 +08:00
Joakim Zhang 88a1ff5c08 MLK-22214 mxc: emvsim: clean up the code in ATR stage
Clean up the code in ATR stage.

Signed-off-by: Joakim Zhang <qiangqing.zhang@nxp.com>
Acked-by: Fugang Duan <fugang.duan@nxp.com>
2019-11-25 15:47:59 +08:00
Joakim Zhang 05d7253157 MLK-22213 mxc: emvsim: read TS character before updating value of GPCNT1
Should read TS character before updating value of GPCNT1, because TS
character will also cost 12 etus.

Signed-off-by: Joakim Zhang <qiangqing.zhang@nxp.com>
Acked-by: Fugang Duan <fugang.duan@nxp.com>
2019-11-25 15:47:58 +08:00
Joakim Zhang f0fba896a3 MLK-22211 mxc: emvsim: should not clear PEF/FEF flag in irq handler
Shouldn't clear PEF/FEF flag in irq handler as they are just a flag which
can't trigger interrupt. And they will be check later in irq handler.

Signed-off-by: Joakim Zhang <qiangqing.zhang@nxp.com>
Acked-by: Fugang Duan <fugang.duan@nxp.com>
2019-11-25 15:47:57 +08:00
Joakim Zhang c79402071a MLK-22210 mxc: emvsim: enable ICM mode
Once detected a valid TS, the ICM bit is cleared and the data format bit,
IC bit , is set to appropriate value depending on the data format
detected using the initial character.

When TS is 0x3B (direct convention) in cold reset, and then become 0x3F
(inverse convention) in warm reset, it will not in ICM mode.

Signed-off-by: Joakim Zhang <qiangqing.zhang@nxp.com>
Acked-by: Fugang Duan <fugang.duan@nxp.com>
2019-11-25 15:47:57 +08:00
Gao Pan 557037b6bd MLK-18485 emvsim: enable CWT for ATR
Enable CWT for ATR, and switch to RX_DATA_IM to detect receiving data
in fifo.

Signed-off-by: Gao Pan <pandy.gao@nxp.com>
Acked-by: Fugang Duan <fugang.duan@nxp.com>
2019-11-25 15:47:56 +08:00
Gao Pan 4265cbdb4b MLK-17416 imx8: sim: add usleep_range() before reading SPDP Bit
Card Presence Detect Status Bit SPDP in EMV_SIM_PCSR is
synchronized by two posedge of low_ref_clk which is 32KHz.

So there should be 1.5 low_ref_clk cycles(about 90us) before
reading SPDP Bit.

Signed-off-by: Gao Pan <pandy.gao@nxp.com>
Acked-by: Fugang Duan <fugang.duan@nxp.com>
2019-11-25 15:47:56 +08:00
Gao Pan bbc881815d MLK-17319-1 imx8: sim: add driver to support EMVSIM module
The EMVSIM module is designed to facilitate communication to
Smart Cards compatible to the EMV ver4.3 standard and compatible
with ISO/IEC 7816-3 Standard.

This patch adds driver to support EMVSIM module for imx8.

Signed-off-by: Gao Pan <pandy.gao@nxp.com>
Reviewed-by: Andy Duan <fugang.duan@nxp.com>
2019-11-25 15:47:55 +08:00
Julien Olivain c0fa458f65 MLK-13473: imx_sim: fix module device table name
This fixes the build when this driver is built as a module, when
CONFIG_MXC_SIM=m

Signed-off-by: Julien Olivain <julien.olivain@nxp.com>
2019-11-25 15:47:55 +08:00
Gao Pan 3135b8110b MLK-14642 imx: sim: fix segment fault caused by user address access
Kernel space cannot access user space memory directly.
In fact, the issue always exited. Since 4.4, the kernel
handle the action as page abort.

Signed-off-by: Gao Pan <pandy.gao@nxp.com>
Signed-off-by: Fugang Duan <fugang.duan@nxp.com>
2019-11-25 15:47:54 +08:00
Gao Pan 34a04d8706 MLK-11472 sim: imx: set sim1 IOMUX to default state
SIM1 IOMUX is changed into reset state in LPSR mode.As a result,
sim can't work again.

This patch sets sim1 IOMUX to default state after existing from LPSR mode.

(cherry-picked from commit 8e237775cd413645bfd806e4c648954e1a773a2d)

Signed-off-by: Gao Pan <b54642@freescale.com>
2019-11-25 15:47:54 +08:00
Gao Pan 957de2871d MLK-11777 sim: imx: remove useless code
sim_activate() process is contained in the cold reset.
Thus, it is redundant and should be removed.

This patch also adds comments to cold reset process.

Signed-off-by: Gao Pan <b54642@freescale.com>
2019-11-25 15:47:54 +08:00
Gao Pan 44ab966c17 MLK-11354 sim: imx: relapce devm_request_and_ioremap with devm_ioremap_resource
The API devm_request_and_ioremap meets compile error
on branch imx_4.1.y. It is recommend to replace the api
with devm_ioremap_resource.

Signed-off-by: Gao Pan <b54642@freescale.com>
2019-11-25 15:47:53 +08:00
Luwei Zhou 1305ce8ff1 MLK-10976: mxc: sim: Using timer interrupt to implement precise timing.
The EMV4.3 has strict requirement about the reset sequence. The old code use the mdelay, udelay to
achievet, which is not precise enough. Replace it with the timer interrupt. The EMV4.3 requires
40000~45000 clock cycles duration when reset is low.

Signed-off-by: Luwei Zhou <b45643@freescale.com>
(cherry picked from a006fe283c8b97f0a711cb0829bfbdaaf4a5f31f)
2019-11-25 15:47:53 +08:00
Luwei Zhou 81d3ff9421 MLK-10968: mxc: sim: Add the init delay detection function in the driver.
In EMV4.3 after warm/cold reset, there would be a receiving window. The receiving
window would be 42000 clock length.If the receiving window expires without receiving
one byte, IFD need to take actions as EMV4.3 spec. The driver need to support this
to identify the sequence of the receiving window expiring event and the receiving event.
Since theinterrupt latency in linux OS is not certain, we need to tune this setting to
pass the cases. Current tuning parameter can work.

Signed-off-by: Luwei Zhou <b45643@freescale.com>
(cherry picked from faf1d8d881a6ad2c6b88fdf312cef142996937c1)
2019-11-25 15:47:52 +08:00
Luwei Zhou 0d5d107690 MLK-10959: mxc: sim: Disable cwt timer when tx and enable in rx.
The CWT timer is used to detect the the character interval in the data traffic.
When tx, SIM IP can guarantee the interval based our setting. When RX, we need
to enalbe the CWT timer to check whether the interval is in the range. This patch
fix this.

Signed-off-by: Luwei Zhou <b45643@freescale.com>
(cherry picked from 9c92dfd070e7427eb1e0166f368b89b4a7ac1bff)
2019-11-25 15:47:52 +08:00
Luwei Zhou 50b2602a93 MLK-10913-1: mxc: sim: Add the SIM driver support for i.MX6UL-EVK platform.
Modify the driver to support the SIM on i.MX6UL-EVK platform. The main modification is:
1. Add port index to support different port on platform.
2. Add POS-CARD support. The POS card has external IC to assert when SVEN to low. Add support.
3. Using a function to calculate the strict timing delay.

Signed-off-by: Luwei Zhou <b45643@freescale.com>
(cherry picked from 17d1315b0704e2db63ee6bd7aaefa0c796f53104)
2019-11-25 15:47:51 +08:00
Luwei Zhou 3867b4bd9f MLK-10600-2: mxc: sim: add an option to enable SIM driver build
Add the option to enable SIM driver build.

Signed-off-by: Luwei Zhou <b45643@freescale.com>
Signed-off-by: Gao Pan <b45643@freescale.com>
(cherry picked from 0f7a6fa3c141bfc7333d9056639b7a5b1154ed1d)
2019-11-25 15:47:50 +08:00
Luwei Zhou fb80f7afe2 MLK-10600-1: mxc: sim: Add SIM IP driver support on the i.MX7d-12x12-arm2 platform.
This driver is based on the current code which runs the the EMV test on the i.MX258 platform.
Since there are still many cases that can't pass on the i.MX258 and i.MX7d platform. The
driver will need to be improved after per-test work. Just check in as a base code. There
would be definitly some timing improvement work to do in the future.

Signed-off-by: Luwei Zhou <b45643@freescale.com>
(cherry picked from 3ac1ad5b2a68ecb052ccacca4ac7459ead04415e)
2019-11-25 15:47:50 +08:00