aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Lapuyade <eric.lapuyade@linux.intel.com>2012-12-18 08:53:53 -0500
committerSamuel Ortiz <sameo@linux.intel.com>2013-02-03 14:37:42 -0500
commitcfad1ba87150e198be9ea32367a24e500e59de2c (patch)
treedc70c402fb92bfcae71120b6f3cbb859686201d9
parent2323e6fc62eec19c3454642c0ac4ad42374b40a1 (diff)
NFC: Initial support for Inside Secure microread
Inside Secure microread is an HCI based NFC chipset. This initial support includes reader and p2p (Target and initiator) modes. Signed-off-by: Eric Lapuyade <eric.lapuyade@intel.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
-rw-r--r--drivers/nfc/Kconfig1
-rw-r--r--drivers/nfc/Makefile1
-rw-r--r--drivers/nfc/microread/Kconfig13
-rw-r--r--drivers/nfc/microread/Makefile5
-rw-r--r--drivers/nfc/microread/microread.c728
-rw-r--r--drivers/nfc/microread/microread.h33
-rw-r--r--include/linux/platform_data/microread.h35
7 files changed, 816 insertions, 0 deletions
diff --git a/drivers/nfc/Kconfig b/drivers/nfc/Kconfig
index 80c728b28828..e57034971ccc 100644
--- a/drivers/nfc/Kconfig
+++ b/drivers/nfc/Kconfig
@@ -27,5 +27,6 @@ config NFC_WILINK
27 into the kernel or say M to compile it as module. 27 into the kernel or say M to compile it as module.
28 28
29source "drivers/nfc/pn544/Kconfig" 29source "drivers/nfc/pn544/Kconfig"
30source "drivers/nfc/microread/Kconfig"
30 31
31endmenu 32endmenu
diff --git a/drivers/nfc/Makefile b/drivers/nfc/Makefile
index 574bbc04d97a..a189ada0926a 100644
--- a/drivers/nfc/Makefile
+++ b/drivers/nfc/Makefile
@@ -3,6 +3,7 @@
3# 3#
4 4
5obj-$(CONFIG_NFC_PN544) += pn544/ 5obj-$(CONFIG_NFC_PN544) += pn544/
6obj-$(CONFIG_NFC_MICROREAD) += microread/
6obj-$(CONFIG_NFC_PN533) += pn533.o 7obj-$(CONFIG_NFC_PN533) += pn533.o
7obj-$(CONFIG_NFC_WILINK) += nfcwilink.o 8obj-$(CONFIG_NFC_WILINK) += nfcwilink.o
8 9
diff --git a/drivers/nfc/microread/Kconfig b/drivers/nfc/microread/Kconfig
new file mode 100644
index 000000000000..5b89d011d098
--- /dev/null
+++ b/drivers/nfc/microread/Kconfig
@@ -0,0 +1,13 @@
1config NFC_MICROREAD
2 tristate "Inside Secure microread NFC driver"
3 depends on NFC_HCI
4 select CRC_CCITT
5 default n
6 ---help---
7 This module contains the main code for Inside Secure microread
8 NFC chipsets. It implements the chipset HCI logic and hooks into
9 the NFC kernel APIs. Physical layers will register against it.
10
11 To compile this driver as a module, choose m here. The module will
12 be called microread.
13 Say N if unsure.
diff --git a/drivers/nfc/microread/Makefile b/drivers/nfc/microread/Makefile
new file mode 100644
index 000000000000..9ce2c53f49a7
--- /dev/null
+++ b/drivers/nfc/microread/Makefile
@@ -0,0 +1,5 @@
1#
2# Makefile for Microread HCI based NFC driver
3#
4
5obj-$(CONFIG_NFC_MICROREAD) += microread.o
diff --git a/drivers/nfc/microread/microread.c b/drivers/nfc/microread/microread.c
new file mode 100644
index 000000000000..3420d833db17
--- /dev/null
+++ b/drivers/nfc/microread/microread.c
@@ -0,0 +1,728 @@
1/*
2 * HCI based Driver for Inside Secure microread NFC Chip
3 *
4 * Copyright (C) 2013 Intel Corporation. All rights reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the
17 * Free Software Foundation, Inc.,
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 */
20
21#include <linux/module.h>
22#include <linux/delay.h>
23#include <linux/slab.h>
24#include <linux/crc-ccitt.h>
25
26#include <linux/nfc.h>
27#include <net/nfc/nfc.h>
28#include <net/nfc/hci.h>
29#include <net/nfc/llc.h>
30
31#include "microread.h"
32
33/* Proprietary gates, events, commands and registers */
34/* Admin */
35#define MICROREAD_GATE_ID_ADM NFC_HCI_ADMIN_GATE
36#define MICROREAD_GATE_ID_MGT 0x01
37#define MICROREAD_GATE_ID_OS 0x02
38#define MICROREAD_GATE_ID_TESTRF 0x03
39#define MICROREAD_GATE_ID_LOOPBACK NFC_HCI_LOOPBACK_GATE
40#define MICROREAD_GATE_ID_IDT NFC_HCI_ID_MGMT_GATE
41#define MICROREAD_GATE_ID_LMS NFC_HCI_LINK_MGMT_GATE
42
43/* Reader */
44#define MICROREAD_GATE_ID_MREAD_GEN 0x10
45#define MICROREAD_GATE_ID_MREAD_ISO_B NFC_HCI_RF_READER_B_GATE
46#define MICROREAD_GATE_ID_MREAD_NFC_T1 0x12
47#define MICROREAD_GATE_ID_MREAD_ISO_A NFC_HCI_RF_READER_A_GATE
48#define MICROREAD_GATE_ID_MREAD_NFC_T3 0x14
49#define MICROREAD_GATE_ID_MREAD_ISO_15_3 0x15
50#define MICROREAD_GATE_ID_MREAD_ISO_15_2 0x16
51#define MICROREAD_GATE_ID_MREAD_ISO_B_3 0x17
52#define MICROREAD_GATE_ID_MREAD_BPRIME 0x18
53#define MICROREAD_GATE_ID_MREAD_ISO_A_3 0x19
54
55/* Card */
56#define MICROREAD_GATE_ID_MCARD_GEN 0x20
57#define MICROREAD_GATE_ID_MCARD_ISO_B 0x21
58#define MICROREAD_GATE_ID_MCARD_BPRIME 0x22
59#define MICROREAD_GATE_ID_MCARD_ISO_A 0x23
60#define MICROREAD_GATE_ID_MCARD_NFC_T3 0x24
61#define MICROREAD_GATE_ID_MCARD_ISO_15_3 0x25
62#define MICROREAD_GATE_ID_MCARD_ISO_15_2 0x26
63#define MICROREAD_GATE_ID_MCARD_ISO_B_2 0x27
64#define MICROREAD_GATE_ID_MCARD_ISO_CUSTOM 0x28
65#define MICROREAD_GATE_ID_SECURE_ELEMENT 0x2F
66
67/* P2P */
68#define MICROREAD_GATE_ID_P2P_GEN 0x30
69#define MICROREAD_GATE_ID_P2P_TARGET 0x31
70#define MICROREAD_PAR_P2P_TARGET_MODE 0x01
71#define MICROREAD_PAR_P2P_TARGET_GT 0x04
72#define MICROREAD_GATE_ID_P2P_INITIATOR 0x32
73#define MICROREAD_PAR_P2P_INITIATOR_GI 0x01
74#define MICROREAD_PAR_P2P_INITIATOR_GT 0x03
75
76/* Those pipes are created/opened by default in the chip */
77#define MICROREAD_PIPE_ID_LMS 0x00
78#define MICROREAD_PIPE_ID_ADMIN 0x01
79#define MICROREAD_PIPE_ID_MGT 0x02
80#define MICROREAD_PIPE_ID_OS 0x03
81#define MICROREAD_PIPE_ID_HDS_LOOPBACK 0x04
82#define MICROREAD_PIPE_ID_HDS_IDT 0x05
83#define MICROREAD_PIPE_ID_HDS_MCARD_ISO_B 0x08
84#define MICROREAD_PIPE_ID_HDS_MCARD_ISO_BPRIME 0x09
85#define MICROREAD_PIPE_ID_HDS_MCARD_ISO_A 0x0A
86#define MICROREAD_PIPE_ID_HDS_MCARD_ISO_15_3 0x0B
87#define MICROREAD_PIPE_ID_HDS_MCARD_ISO_15_2 0x0C
88#define MICROREAD_PIPE_ID_HDS_MCARD_NFC_T3 0x0D
89#define MICROREAD_PIPE_ID_HDS_MCARD_ISO_B_2 0x0E
90#define MICROREAD_PIPE_ID_HDS_MCARD_CUSTOM 0x0F
91#define MICROREAD_PIPE_ID_HDS_MREAD_ISO_B 0x10
92#define MICROREAD_PIPE_ID_HDS_MREAD_NFC_T1 0x11
93#define MICROREAD_PIPE_ID_HDS_MREAD_ISO_A 0x12
94#define MICROREAD_PIPE_ID_HDS_MREAD_ISO_15_3 0x13
95#define MICROREAD_PIPE_ID_HDS_MREAD_ISO_15_2 0x14
96#define MICROREAD_PIPE_ID_HDS_MREAD_NFC_T3 0x15
97#define MICROREAD_PIPE_ID_HDS_MREAD_ISO_B_3 0x16
98#define MICROREAD_PIPE_ID_HDS_MREAD_BPRIME 0x17
99#define MICROREAD_PIPE_ID_HDS_MREAD_ISO_A_3 0x18
100#define MICROREAD_PIPE_ID_HDS_MREAD_GEN 0x1B
101#define MICROREAD_PIPE_ID_HDS_STACKED_ELEMENT 0x1C
102#define MICROREAD_PIPE_ID_HDS_INSTANCES 0x1D
103#define MICROREAD_PIPE_ID_HDS_TESTRF 0x1E
104#define MICROREAD_PIPE_ID_HDS_P2P_TARGET 0x1F
105#define MICROREAD_PIPE_ID_HDS_P2P_INITIATOR 0x20
106
107/* Events */
108#define MICROREAD_EVT_MREAD_DISCOVERY_OCCURED NFC_HCI_EVT_TARGET_DISCOVERED
109#define MICROREAD_EVT_MREAD_CARD_FOUND 0x3D
110#define MICROREAD_EMCF_A_ATQA 0
111#define MICROREAD_EMCF_A_SAK 2
112#define MICROREAD_EMCF_A_LEN 3
113#define MICROREAD_EMCF_A_UID 4
114#define MICROREAD_EMCF_A3_ATQA 0
115#define MICROREAD_EMCF_A3_SAK 2
116#define MICROREAD_EMCF_A3_LEN 3
117#define MICROREAD_EMCF_A3_UID 4
118#define MICROREAD_EMCF_B_UID 0
119#define MICROREAD_EMCF_T1_ATQA 0
120#define MICROREAD_EMCF_T1_UID 4
121#define MICROREAD_EMCF_T3_UID 0
122#define MICROREAD_EVT_MREAD_DISCOVERY_START NFC_HCI_EVT_READER_REQUESTED
123#define MICROREAD_EVT_MREAD_DISCOVERY_START_SOME 0x3E
124#define MICROREAD_EVT_MREAD_DISCOVERY_STOP NFC_HCI_EVT_END_OPERATION
125#define MICROREAD_EVT_MREAD_SIM_REQUESTS 0x3F
126#define MICROREAD_EVT_MCARD_EXCHANGE NFC_HCI_EVT_TARGET_DISCOVERED
127#define MICROREAD_EVT_P2P_INITIATOR_EXCHANGE_TO_RF 0x20
128#define MICROREAD_EVT_P2P_INITIATOR_EXCHANGE_FROM_RF 0x21
129#define MICROREAD_EVT_MCARD_FIELD_ON 0x11
130#define MICROREAD_EVT_P2P_TARGET_ACTIVATED 0x13
131#define MICROREAD_EVT_P2P_TARGET_DEACTIVATED 0x12
132#define MICROREAD_EVT_MCARD_FIELD_OFF 0x14
133
134/* Commands */
135#define MICROREAD_CMD_MREAD_EXCHANGE 0x10
136#define MICROREAD_CMD_MREAD_SUBSCRIBE 0x3F
137
138/* Hosts IDs */