summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorLuwei Zhou <b45643@freescale.com>2015-04-08 14:05:52 +0800
committerNitin Garg <nitin.garg@freescale.com>2015-09-17 09:22:31 -0500
commitf910d8ae263c729f6a5cd80d78373d6d2129ebbb (patch)
treebf64ac9ce3320a449926985f4d8489254c6962a1 /include
parentd65683e1d0717fa039ebd4c55562e6ee745354b7 (diff)
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>
Diffstat (limited to 'include')
-rw-r--r--include/linux/mxc_sim_interface.h124
-rw-r--r--include/uapi/linux/mxc_sim_interface.h124
2 files changed, 248 insertions, 0 deletions
diff --git a/include/linux/mxc_sim_interface.h b/include/linux/mxc_sim_interface.h
new file mode 100644
index 000000000000..5eae53a59075
--- /dev/null
+++ b/include/linux/mxc_sim_interface.h
@@ -0,0 +1,124 @@
+/*
+ * Copyright (C) 2015 Freescale Semiconductor, Inc. All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+#ifndef MXC_SIM_INTERFACE_H
+#define MXC_SIM_INTERFACE_H
+
+#define SIM_ATR_LENGTH_MAX 32
+
+/* Raw ATR SIM_IOCTL_GET_ATR */
+typedef struct {
+ unsigned int size;/* length of ATR received */
+ unsigned char *atr_buffer;/* raw ATR string received */
+ int errval;/* The error vale reported to user space after completing ATR*/
+} sim_atr_t;
+
+/* ISO7816-3 protocols */
+#define SIM_PROTOCOL_T0 1
+#define SIM_PROTOCOL_T1 2
+
+/* Transfer types for SIM_IOCTL_XFER */
+#define SIM_XFER_TYPE_TPDU 1
+#define SIM_XFER_TYPE_PTS 2
+
+typedef struct {
+ unsigned int wwt;
+ unsigned int cwt;
+ unsigned int bwt;
+ unsigned int bgt;
+ unsigned int cgt;
+} sim_timing_t;
+
+/* Transfer data for SIM_IOCTL_XFER */
+typedef struct {
+ unsigned char *xmt_buffer; /* transmit buffer pointer */
+ int xmt_length;/* transmit buffer length */
+ int timeout;/* transfer timeout in milliseconds */
+ int errval;/* The error vale reported to user space after completing transmitting*/
+} sim_xmt_t;
+
+typedef struct {
+ unsigned char *rcv_buffer; /* receive buffer pointer */
+ int rcv_length; /* receive buffer length */
+ int timeout;/* transfer timeout in milliseconds */
+ int errval;/* The error vale reported to user space after receiving*/
+} sim_rcv_t;
+
+typedef struct {
+ unsigned char di;
+ unsigned char fi;
+} sim_baud_t;
+
+/* Interface power states */
+#define SIM_POWER_OFF (0)
+#define SIM_POWER_ON (1)
+
+/* Return values for SIM_IOCTL_GET_PRESENSE */
+#define SIM_PRESENT_REMOVED (0)
+#define SIM_PRESENT_DETECTED (1)
+#define SIM_PRESENT_OPERATIONAL (2)
+
+/* The error value */
+#define SIM_OK (0)
+#define SIM_ERROR_CWT (1 << 0)
+#define SIM_ERROR_BWT (1 << 1)
+#define SIM_ERROR_PARITY (1 << 2)
+#define SIM_ERROR_INVALID_TS (1 << 3)
+#define SIM_ERROR_FRAME (1 << 4)
+#define SIM_ERROR_ATR_TIMEROUT (1 << 5)
+#define SIM_ERROR_NACK_THRESHOLD (1 << 6)
+#define SIM_ERROR_BGT (1 << 7)
+#define SIM_ERROR_ATR_DELAY (1 << 8)
+
+/* Return values for SIM_IOCTL_GET_ERROR */
+#define SIM_E_ACCESS (1)
+#define SIM_E_TPDUSHORT (2)
+#define SIM_E_PTSEMPTY (3)
+#define SIM_E_INVALIDXFERTYPE (4)
+#define SIM_E_INVALIDXMTLENGTH (5)
+#define SIM_E_INVALIDRCVLENGTH (6)
+#define SIM_E_NACK (7)
+#define SIM_E_TIMEOUT (8)
+#define SIM_E_NOCARD (9)
+#define SIM_E_PARAM_FI_INVALID (10)
+#define SIM_E_PARAM_DI_INVALID (11)
+#define SIM_E_PARAM_FBYD_WITHFRACTION (12)
+#define SIM_E_PARAM_FBYD_NOTDIVBY8OR12 (13)
+#define SIM_E_PARAM_DIVISOR_RANGE (14)
+#define SIM_E_MALLOC (15)
+#define SIM_E_IRQ (16)
+#define SIM_E_POWERED_ON (17)
+#define SIM_E_POWERED_OFF (18)
+
+/* ioctl encodings */
+#define SIM_IOCTL_BASE (0xc0)
+#define SIM_IOCTL_GET_PRESENSE _IOR(SIM_IOCTL_BASE, 1, int)
+#define SIM_IOCTL_GET_ATR _IOR(SIM_IOCTL_BASE, 2, sim_atr_t)
+#define SIM_IOCTL_XMT _IOR(SIM_IOCTL_BASE, 3, sim_xmt_t)
+#define SIM_IOCTL_RCV _IOR(SIM_IOCTL_BASE, 4, sim_rcv_t)
+#define SIM_IOCTL_ACTIVATE _IO(SIM_IOCTL_BASE, 5)
+#define SIM_IOCTL_DEACTIVATE _IO(SIM_IOCTL_BASE, 6)
+#define SIM_IOCTL_WARM_RESET _IO(SIM_IOCTL_BASE, 7)
+#define SIM_IOCTL_COLD_RESET _IO(SIM_IOCTL_BASE, 8)
+#define SIM_IOCTL_CARD_LOCK _IO(SIM_IOCTL_BASE, 9)
+#define SIM_IOCTL_CARD_EJECT _IO(SIM_IOCTL_BASE, 10)
+#define SIM_IOCTL_SET_PROTOCOL _IOR(SIM_IOCTL_BASE, 11, unsigned int)
+#define SIM_IOCTL_SET_TIMING _IOR(SIM_IOCTL_BASE, 12, sim_timing_t)
+#define SIM_IOCTL_SET_BAUD _IOR(SIM_IOCTL_BASE, 13, sim_baud_t)
+#define SIM_IOCTL_WAIT _IOR(SIM_IOCTL_BASE, 14, unsigned int)
+
+#endif
diff --git a/include/uapi/linux/mxc_sim_interface.h b/include/uapi/linux/mxc_sim_interface.h
new file mode 100644
index 000000000000..9ac3c029ab40
--- /dev/null
+++ b/include/uapi/linux/mxc_sim_interface.h
@@ -0,0 +1,124 @@
+/*
+ * Copyright (C) 2015 Freescale Semiconductor, Inc. All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+#ifndef UAPI_MXC_SIM_INTERFACE_H
+#define UAPI_MXC_SIM_INTERFACE_H
+
+#define SIM_ATR_LENGTH_MAX 32
+
+/* Raw ATR SIM_IOCTL_GET_ATR */
+typedef struct {
+ unsigned int size;/* length of ATR received */
+ unsigned char *atr_buffer;/* raw ATR string received */
+ int errval;/* The error vale reported to user space after completing ATR*/
+} sim_atr_t;
+
+/* ISO7816-3 protocols */
+#define SIM_PROTOCOL_T0 1
+#define SIM_PROTOCOL_T1 2
+
+/* Transfer types for SIM_IOCTL_XFER */
+#define SIM_XFER_TYPE_TPDU 1
+#define SIM_XFER_TYPE_PTS 2
+
+typedef struct {
+ unsigned int wwt;
+ unsigned int cwt;
+ unsigned int bwt;
+ unsigned int bgt;
+ unsigned int cgt;
+} sim_timing_t;
+
+/* Transfer data for SIM_IOCTL_XFER */
+typedef struct {
+ unsigned char *xmt_buffer; /* transmit buffer pointer */
+ int xmt_length;/* transmit buffer length */
+ int timeout;/* transfer timeout in milliseconds */
+ int errval;/* The error vale reported to user space after completing transmitting*/
+} sim_xmt_t;
+
+typedef struct {
+ unsigned char *rcv_buffer; /* receive buffer pointer */
+ int rcv_length; /* receive buffer length */
+ int timeout;/* transfer timeout in milliseconds */
+ int errval;/* The error vale reported to user space after receiving*/
+} sim_rcv_t;
+
+typedef struct {
+ unsigned char di;
+ unsigned char fi;
+} sim_baud_t;
+
+/* Interface power states */
+#define SIM_POWER_OFF (0)
+#define SIM_POWER_ON (1)
+
+/* Return values for SIM_IOCTL_GET_PRESENSE */
+#define SIM_PRESENT_REMOVED (0)
+#define SIM_PRESENT_DETECTED (1)
+#define SIM_PRESENT_OPERATIONAL (2)
+
+/* The error value */
+#define SIM_OK (0)
+#define SIM_ERROR_CWT (1 << 0)
+#define SIM_ERROR_BWT (1 << 1)
+#define SIM_ERROR_PARITY (1 << 2)
+#define SIM_ERROR_INVALID_TS (1 << 3)
+#define SIM_ERROR_FRAME (1 << 4)
+#define SIM_ERROR_ATR_TIMEROUT (1 << 5)
+#define SIM_ERROR_NACK_THRESHOLD (1 << 6)
+#define SIM_ERROR_BGT (1 << 7)
+#define SIM_ERROR_ATR_DELAY (1 << 8)
+
+/* Return values for SIM_IOCTL_GET_ERROR */
+#define SIM_E_ACCESS (1)
+#define SIM_E_TPDUSHORT (2)
+#define SIM_E_PTSEMPTY (3)
+#define SIM_E_INVALIDXFERTYPE (4)
+#define SIM_E_INVALIDXMTLENGTH (5)
+#define SIM_E_INVALIDRCVLENGTH (6)
+#define SIM_E_NACK (7)
+#define SIM_E_TIMEOUT (8)
+#define SIM_E_NOCARD (9)
+#define SIM_E_PARAM_FI_INVALID (10)
+#define SIM_E_PARAM_DI_INVALID (11)
+#define SIM_E_PARAM_FBYD_WITHFRACTION (12)
+#define SIM_E_PARAM_FBYD_NOTDIVBY8OR12 (13)
+#define SIM_E_PARAM_DIVISOR_RANGE (14)
+#define SIM_E_MALLOC (15)
+#define SIM_E_IRQ (16)
+#define SIM_E_POWERED_ON (17)
+#define SIM_E_POWERED_OFF (18)
+
+/* ioctl encodings */
+#define SIM_IOCTL_BASE (0xc0)
+#define SIM_IOCTL_GET_PRESENSE _IOR(SIM_IOCTL_BASE, 1, int)
+#define SIM_IOCTL_GET_ATR _IOR(SIM_IOCTL_BASE, 2, sim_atr_t)
+#define SIM_IOCTL_XMT _IOR(SIM_IOCTL_BASE, 3, sim_xmt_t)
+#define SIM_IOCTL_RCV _IOR(SIM_IOCTL_BASE, 4, sim_rcv_t)
+#define SIM_IOCTL_ACTIVATE _IO(SIM_IOCTL_BASE, 5)
+#define SIM_IOCTL_DEACTIVATE _IO(SIM_IOCTL_BASE, 6)
+#define SIM_IOCTL_WARM_RESET _IO(SIM_IOCTL_BASE, 7)
+#define SIM_IOCTL_COLD_RESET _IO(SIM_IOCTL_BASE, 8)
+#define SIM_IOCTL_CARD_LOCK _IO(SIM_IOCTL_BASE, 9)
+#define SIM_IOCTL_CARD_EJECT _IO(SIM_IOCTL_BASE, 10)
+#define SIM_IOCTL_SET_PROTOCOL _IOR(SIM_IOCTL_BASE, 11, unsigned int)
+#define SIM_IOCTL_SET_TIMING _IOR(SIM_IOCTL_BASE, 12, sim_timing_t)
+#define SIM_IOCTL_SET_BAUD _IOR(SIM_IOCTL_BASE, 13, sim_baud_t)
+#define SIM_IOCTL_WAIT _IOR(SIM_IOCTL_BASE, 14, unsigned int)
+
+#endif