History

nfc: st-nci: Rename st21nfcb to st-nci

STMicroelectronics NFC NCI chips family is extending with the new ST21NFCC using the AMS AS39230 RF booster. The st21nfcb driver is relevant for this solution and might be with future products.

Christophe Ricard committed 11 years ago

Commit ed06aee1 parent 2df7f8c18 files · +585 −553Browse files

Unified · Split

18 files
  1. Documentation/devicetree/bindings/net/nfc/st-nci.txt +2 −2
  2. drivers/nfc/Kconfig +1 −1
  3. drivers/nfc/Makefile +1 −1
  4. drivers/nfc/st-nci/Kconfig +23 −0
  5. drivers/nfc/st-nci/Makefile +9 −0
  6. drivers/nfc/st-nci/core.c +179 −0
  7. drivers/nfc/st-nci/i2c.c +62 −61
  8. drivers/nfc/st-nci/ndlc.c +6 −6
  9. drivers/nfc/st-nci/ndlc.h +2 −2
  10. drivers/nfc/st-nci/st-nci.h +11 −11
  11. drivers/nfc/st-nci/st-nci_se.c +192 −191
  12. drivers/nfc/st-nci/st-nci_se.h +61 −0
  13. drivers/nfc/st21nfcb/Kconfig +0 −22
  14. drivers/nfc/st21nfcb/Makefile +0 −9
  15. drivers/nfc/st21nfcb/st21nfcb.c +0 −179
  16. drivers/nfc/st21nfcb/st21nfcb_se.h +0 −61
  17. include/linux/platform_data/st-nci.h +7 −7
  18. include/linux/platform_data/st_nci.h +29 −0
Documentation/devicetree/bindings/net/nfc/st-nci.txtrenamed from Documentation/devicetree/bindings/net/nfc/st21nfcb.txt+2−2
@@ -1,7 +1,7 @@
1−* STMicroelectronics SAS. ST21NFCB NFC Controller
1+* STMicroelectronics SAS. ST NCI NFC Controller
22
33 Required properties:
4−- compatible: Should be "st,st21nfcb-i2c".
4+- compatible: Should be "st,st21nfcb-i2c" or "st,st21nfcc-i2c".
55 - clock-frequency: I²C work frequency.
66 - reg: address on the bus
77 - interrupt-parent: phandle for the interrupt gpio controller
drivers/nfc/Kconfig+1−1
@@ -72,6 +72,6 @@ source "drivers/nfc/pn544/Kconfig" · 71 unmodified lines
7272 source "drivers/nfc/microread/Kconfig"
7373 source "drivers/nfc/nfcmrvl/Kconfig"
7474 source "drivers/nfc/st21nfca/Kconfig"
75−source "drivers/nfc/st21nfcb/Kconfig"
75+source "drivers/nfc/st-nci/Kconfig"
7676 source "drivers/nfc/nxp-nci/Kconfig"
7777 endmenu
drivers/nfc/Makefile+1−1
@@ -12,5 +12,5 @@ obj-$(CONFIG_NFC_PORT100) += port100.o · 11 unmodified lines
1212 obj-$(CONFIG_NFC_MRVL) += nfcmrvl/
1313 obj-$(CONFIG_NFC_TRF7970A) += trf7970a.o
1414 obj-$(CONFIG_NFC_ST21NFCA) += st21nfca/
15−obj-$(CONFIG_NFC_ST21NFCB) += st21nfcb/
15+obj-$(CONFIG_NFC_ST_NCI) += st-nci/
1616 obj-$(CONFIG_NFC_NXP_NCI) += nxp-nci/
drivers/nfc/st-nci/Kconfig+23−0
@@ -0,0 +1,23 @@
1+config NFC_ST_NCI
2+ tristate "STMicroelectronics ST NCI NFC driver"
3+ depends on NFC_NCI
4+ default n
5+ ---help---
6+ STMicroelectronics NFC NCI chips core driver. It implements the chipset
7+ NCI logic and hooks into the NFC kernel APIs. Physical layers will
8+ register against it.
9+
10+ To compile this driver as a module, choose m here. The module will
11+ be called st-nci.
12+ Say N if unsure.
13+
14+config NFC_ST_NCI_I2C
15+ tristate "NFC ST NCI i2c support"
16+ depends on NFC_ST_NCI && I2C
17+ ---help---
18+ This module adds support for an I2C interface to the
19+ STMicroelectronics NFC NCI chips familly.
20+ Select this if your platform is using the i2c bus.
21+
22+ If you choose to build a module, it'll be called st-nci_i2c.
23+ Say N if unsure.
drivers/nfc/st-nci/Makefile+9−0
@@ -0,0 +1,9 @@
1+#
2+# Makefile for ST21NFCB NCI based NFC driver
3+#
4+
5+st-nci-objs = ndlc.o core.o st-nci_se.o
6+obj-$(CONFIG_NFC_ST_NCI) += st-nci.o
7+
8+st-nci_i2c-objs = i2c.o
9+obj-$(CONFIG_NFC_ST_NCI_I2C) += st-nci_i2c.o
drivers/nfc/st-nci/core.c+179−0
@@ -0,0 +1,179 @@
1+/*
2+ * NCI based Driver for STMicroelectronics NFC Chip
3+ *
4+ * Copyright (C) 2014-2015 STMicroelectronics SAS. 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, see <http://www.gnu.org/licenses/>.
17+ */
18+
19+#include <linux/module.h>
20+#include <linux/nfc.h>
21+#include <net/nfc/nci.h>
22+#include <net/nfc/nci_core.h>
23+#include <linux/gpio.h>
24+#include <linux/delay.h>
25+
26+#include "st-nci.h"
27+#include "st-nci_se.h"
28+
29+#define DRIVER_DESC "NCI NFC driver for ST_NCI"
30+
31+#define ST_NCI1_X_PROPRIETARY_ISO15693 0x83
32+
33+static int st_nci_init(struct nci_dev *ndev)
34+{
35+ struct nci_mode_set_cmd cmd;
36+
37+ cmd.cmd_type = ST_NCI_SET_NFC_MODE;
38+ cmd.mode = 1;
39+
40+ return nci_prop_cmd(ndev, ST_NCI_CORE_PROP,
41+ sizeof(struct nci_mode_set_cmd), (__u8 *)&cmd);
42+}
43+
44+static int st_nci_open(struct nci_dev *ndev)
45+{
46+ struct st_nci_info *info = nci_get_drvdata(ndev);
47+ int r;
48+
49+ if (test_and_set_bit(ST_NCI_RUNNING, &info->flags))
50+ return 0;
51+
52+ r = ndlc_open(info->ndlc);
53+ if (r)
54+ clear_bit(ST_NCI_RUNNING, &info->flags);
55+
56+ return r;
57+}
58+
59+static int st_nci_close(struct nci_dev *ndev)
60+{
61+ struct st_nci_info *info = nci_get_drvdata(ndev);
62+
63+ if (!test_bit(ST_NCI_RUNNING, &info->flags))
64+ return 0;
65+
66+ ndlc_close(info->ndlc);
67+
68+ clear_bit(ST_NCI_RUNNING, &info->flags);
69+
70+ return 0;
71+}
72+
73+static int st_nci_send(struct nci_dev *ndev, struct sk_buff *skb)
74+{
75+ struct st_nci_info *info = nci_get_drvdata(ndev);
76+
77+ skb->dev = (void *)ndev;
78+
79+ if (!test_bit(ST_NCI_RUNNING, &info->flags))
80+ return -EBUSY;
81+
82+ return ndlc_send(info->ndlc, skb);
83+}
84+
85+static __u32 st_nci_get_rfprotocol(struct nci_dev *ndev,
86+ __u8 rf_protocol)
87+{
88+ return rf_protocol == ST_NCI1_X_PROPRIETARY_ISO15693 ?
89+ NFC_PROTO_ISO15693_MASK : 0;
90+}
91+
92+static int st_nci_prop_rsp_packet(struct nci_dev *ndev,
93+ struct sk_buff *skb)
94+{
95+ __u8 status = skb->data[0];
96+
97+ nci_req_complete(ndev, status);
98+ return 0;
99+}
100+
101+static struct nci_prop_ops st_nci_prop_ops[] = {
102+ {
103+ .opcode = nci_opcode_pack(NCI_GID_PROPRIETARY,
104+ ST_NCI_CORE_PROP),
105+ .rsp = st_nci_prop_rsp_packet,
106+ },
107+};
108+
109+static struct nci_ops st_nci_ops = {
110+ .init = st_nci_init,
111+ .open = st_nci_open,
112+ .close = st_nci_close,
113+ .send = st_nci_send,
114+ .get_rfprotocol = st_nci_get_rfprotocol,
115+ .discover_se = st_nci_discover_se,
116+ .enable_se = st_nci_enable_se,
117+ .disable_se = st_nci_disable_se,
118+ .se_io = st_nci_se_io,
119+ .hci_load_session = st_nci_hci_load_session,
120+ .hci_event_received = st_nci_hci_event_received,
121+ .hci_cmd_received = st_nci_hci_cmd_received,
122+ .prop_ops = st_nci_prop_ops,
123+ .n_prop_ops = ARRAY_SIZE(st_nci_prop_ops),
124+};
125+
126+int st_nci_probe(struct llt_ndlc *ndlc, int phy_headroom,
127+ int phy_tailroom)
128+{
129+ struct st_nci_info *info;
130+ int r;
131+ u32 protocols;
132+
133+ info = devm_kzalloc(ndlc->dev,
134+ sizeof(struct st_nci_info), GFP_KERNEL);
135+ if (!info)
136+ return -ENOMEM;
137+
138+ protocols = NFC_PROTO_JEWEL_MASK
139+ | NFC_PROTO_MIFARE_MASK
140+ | NFC_PROTO_FELICA_MASK
141+ | NFC_PROTO_ISO14443_MASK
142+ | NFC_PROTO_ISO14443_B_MASK
143+ | NFC_PROTO_ISO15693_MASK
144+ | NFC_PROTO_NFC_DEP_MASK;
145+
146+ ndlc->ndev = nci_allocate_device(&st_nci_ops, protocols,
147+ phy_headroom, phy_tailroom);
148+ if (!ndlc->ndev) {
149+ pr_err("Cannot allocate nfc ndev\n");
150+ return -ENOMEM;
151+ }
152+ info->ndlc = ndlc;
153+
154+ nci_set_drvdata(ndlc->ndev, info);
155+
156+ r = nci_register_device(ndlc->ndev);
157+ if (r) {
158+ pr_err("Cannot register nfc device to nci core\n");
159+ nci_free_device(ndlc->ndev);
160+ return r;
161+ }
162+
163+ return st_nci_se_init(ndlc->ndev);
164+}
165+EXPORT_SYMBOL_GPL(st_nci_probe);
166+
167+void st_nci_remove(struct nci_dev *ndev)
168+{
169+ struct st_nci_info *info = nci_get_drvdata(ndev);
170+
171+ ndlc_close(info->ndlc);
172+
173+ nci_unregister_device(ndev);
174+ nci_free_device(ndev);
175+}
176+EXPORT_SYMBOL_GPL(st_nci_remove);
177+
178+MODULE_LICENSE("GPL");
179+MODULE_DESCRIPTION(DRIVER_DESC);
drivers/nfc/st-nci/i2c.crenamed from drivers/nfc/st21nfcb/i2c.c+62−61
@@ -1,6 +1,6 @@
11 /*
2− * I2C Link Layer for ST21NFCB NCI based Driver
3− * Copyright (C) 2014 STMicroelectronics SAS. All rights reserved.
2+ * I2C Link Layer for ST NCI NFC controller familly based Driver
3+ * Copyright (C) 2014-2015 STMicroelectronics SAS. All rights reserved.
44 *
55 * This program is free software; you can redistribute it and/or modify it
66 * under the terms and conditions of the GNU General Public License,
@@ -25,7 +25,7 @@ · 18 unmodified lines
2525 #include <linux/interrupt.h>
2626 #include <linux/delay.h>
2727 #include <linux/nfc.h>
28−#include <linux/platform_data/st21nfcb.h>
28+#include <linux/platform_data/st_nci.h>
2929
3030 #include "ndlc.h"
3131
@@ -35,18 +35,18 @@ · 3 unmodified lines
3535 #define ST21NFCB_FRAME_HEADROOM 1
3636 #define ST21NFCB_FRAME_TAILROOM 0
3737
38−#define ST21NFCB_NCI_I2C_MIN_SIZE 4 /* PCB(1) + NCI Packet header(3) */
39−#define ST21NFCB_NCI_I2C_MAX_SIZE 250 /* req 4.2.1 */
38+#define ST_NCI_I2C_MIN_SIZE 4 /* PCB(1) + NCI Packet header(3) */
39+#define ST_NCI_I2C_MAX_SIZE 250 /* req 4.2.1 */
4040
41−#define ST21NFCB_NCI_I2C_DRIVER_NAME "st21nfcb_nci_i2c"
41+#define ST_NCI_I2C_DRIVER_NAME "st_nci_i2c"
4242
43−static struct i2c_device_id st21nfcb_nci_i2c_id_table[] = {
44− {ST21NFCB_NCI_DRIVER_NAME, 0},
43+static struct i2c_device_id st_nci_i2c_id_table[] = {
44+ {ST_NCI_DRIVER_NAME, 0},
4545 {}
4646 };
47−MODULE_DEVICE_TABLE(i2c, st21nfcb_nci_i2c_id_table);
47+MODULE_DEVICE_TABLE(i2c, st_nci_i2c_id_table);
4848
49−struct st21nfcb_i2c_phy {
49+struct st_nci_i2c_phy {
5050 struct i2c_client *i2c_dev;
5151 struct llt_ndlc *ndlc;
5252
@@ -61,9 +61,9 @@ do { \ · 8 unmodified lines
6161 16, 1, (skb)->data, (skb)->len, 0); \
6262 } while (0)
6363
64−static int st21nfcb_nci_i2c_enable(void *phy_id)
64+static int st_nci_i2c_enable(void *phy_id)
6565 {
66− struct st21nfcb_i2c_phy *phy = phy_id;
66+ struct st_nci_i2c_phy *phy = phy_id;
6767
6868 gpio_set_value(phy->gpio_reset, 0);
6969 usleep_range(10000, 15000);
@@ -76,9 +76,9 @@ static int st21nfcb_nci_i2c_enable(void *phy_id) · 6 unmodified lines
7676 return 0;
7777 }
7878
79−static void st21nfcb_nci_i2c_disable(void *phy_id)
79+static void st_nci_i2c_disable(void *phy_id)
8080 {
81− struct st21nfcb_i2c_phy *phy = phy_id;
81+ struct st_nci_i2c_phy *phy = phy_id;
8282
8383 disable_irq_nosync(phy->i2c_dev->irq);
8484 }
@@ -88,13 +88,13 @@ static void st21nfcb_nci_i2c_disable(void *phy_id) · 3 unmodified lines
8888 * It must return either zero for success, or <0 for error.
8989 * In addition, it must not alter the skb
9090 */
91−static int st21nfcb_nci_i2c_write(void *phy_id, struct sk_buff *skb)
91+static int st_nci_i2c_write(void *phy_id, struct sk_buff *skb)
9292 {
9393 int r = -1;
94− struct st21nfcb_i2c_phy *phy = phy_id;
94+ struct st_nci_i2c_phy *phy = phy_id;
9595 struct i2c_client *client = phy->i2c_dev;
9696
97− I2C_DUMP_SKB("st21nfcb_nci_i2c_write", skb);
97+ I2C_DUMP_SKB("st_nci_i2c_write", skb);
9898
9999 if (phy->ndlc->hard_fault != 0)
100100 return phy->ndlc->hard_fault;
@@ -124,40 +124,40 @@ static int st21nfcb_nci_i2c_write(void *phy_id, struct sk_buff *skb) · 23 unmodified lines
124124 * at end of read)
125125 * -EREMOTEIO : i2c read error (fatal)
126126 * -EBADMSG : frame was incorrect and discarded
127− * (value returned from st21nfcb_nci_i2c_repack)
127+ * (value returned from st_nci_i2c_repack)
128128 * -EIO : if no ST21NFCB_SOF_EOF is found after reaching
129129 * the read length end sequence
130130 */
131−static int st21nfcb_nci_i2c_read(struct st21nfcb_i2c_phy *phy,
131+static int st_nci_i2c_read(struct st_nci_i2c_phy *phy,
132132 struct sk_buff **skb)
133133 {
134134 int r;
135135 u8 len;
136− u8 buf[ST21NFCB_NCI_I2C_MAX_SIZE];
136+ u8 buf[ST_NCI_I2C_MAX_SIZE];
137137 struct i2c_client *client = phy->i2c_dev;
138138
139− r = i2c_master_recv(client, buf, ST21NFCB_NCI_I2C_MIN_SIZE);
139+ r = i2c_master_recv(client, buf, ST_NCI_I2C_MIN_SIZE);
140140 if (r < 0) { /* Retry, chip was in standby */
141141 usleep_range(1000, 4000);
142− r = i2c_master_recv(client, buf, ST21NFCB_NCI_I2C_MIN_SIZE);
142+ r = i2c_master_recv(client, buf, ST_NCI_I2C_MIN_SIZE);
143143 }
144144
145− if (r != ST21NFCB_NCI_I2C_MIN_SIZE)
145+ if (r != ST_NCI_I2C_MIN_SIZE)
146146 return -EREMOTEIO;
147147
148148 len = be16_to_cpu(*(__be16 *) (buf + 2));
149− if (len > ST21NFCB_NCI_I2C_MAX_SIZE) {
149+ if (len > ST_NCI_I2C_MAX_SIZE) {
150150 nfc_err(&client->dev, "invalid frame len\n");
151151 return -EBADMSG;
152152 }
153153
154− *skb = alloc_skb(ST21NFCB_NCI_I2C_MIN_SIZE + len, GFP_KERNEL);
154+ *skb = alloc_skb(ST_NCI_I2C_MIN_SIZE + len, GFP_KERNEL);
155155 if (*skb == NULL)
156156 return -ENOMEM;
157157
158− skb_reserve(*skb, ST21NFCB_NCI_I2C_MIN_SIZE);
159− skb_put(*skb, ST21NFCB_NCI_I2C_MIN_SIZE);
160− memcpy((*skb)->data, buf, ST21NFCB_NCI_I2C_MIN_SIZE);
158+ skb_reserve(*skb, ST_NCI_I2C_MIN_SIZE);
159+ skb_put(*skb, ST_NCI_I2C_MIN_SIZE);
160+ memcpy((*skb)->data, buf, ST_NCI_I2C_MIN_SIZE);
161161
162162 if (!len)
163163 return 0;
@@ -169,7 +169,7 @@ static int st21nfcb_nci_i2c_read(struct st21nfcb_i2c_phy *phy, · 5 unmodified lines
169169 }
170170
171171 skb_put(*skb, len);
172− memcpy((*skb)->data + ST21NFCB_NCI_I2C_MIN_SIZE, buf, len);
172+ memcpy((*skb)->data + ST_NCI_I2C_MIN_SIZE, buf, len);
173173
174174 I2C_DUMP_SKB("i2c frame read", *skb);
175175
@@ -181,9 +181,9 @@ static int st21nfcb_nci_i2c_read(struct st21nfcb_i2c_phy *phy, · 5 unmodified lines
181181 *
182182 * On ST21NFCB, IRQ goes in idle state when read starts.
183183 */
184−static irqreturn_t st21nfcb_nci_irq_thread_fn(int irq, void *phy_id)
184+static irqreturn_t st_nci_irq_thread_fn(int irq, void *phy_id)
185185 {
186− struct st21nfcb_i2c_phy *phy = phy_id;
186+ struct st_nci_i2c_phy *phy = phy_id;
187187 struct i2c_client *client;
188188 struct sk_buff *skb = NULL;
189189 int r;
@@ -200,11 +200,11 @@ static irqreturn_t st21nfcb_nci_irq_thread_fn(int irq, void *phy_id) · 10 unmodified lines
200200 return IRQ_HANDLED;
201201
202202 if (!phy->ndlc->powered) {
203− st21nfcb_nci_i2c_disable(phy);
203+ st_nci_i2c_disable(phy);
204204 return IRQ_HANDLED;
205205 }
206206
207− r = st21nfcb_nci_i2c_read(phy, &skb);
207+ r = st_nci_i2c_read(phy, &skb);
208208 if (r == -EREMOTEIO || r == -ENOMEM || r == -EBADMSG)
209209 return IRQ_HANDLED;
210210
@@ -214,15 +214,15 @@ static irqreturn_t st21nfcb_nci_irq_thread_fn(int irq, void *phy_id) · 3 unmodified lines
214214 }
215215
216216 static struct nfc_phy_ops i2c_phy_ops = {
217− .write = st21nfcb_nci_i2c_write,
218− .enable = st21nfcb_nci_i2c_enable,
219− .disable = st21nfcb_nci_i2c_disable,
217+ .write = st_nci_i2c_write,
218+ .enable = st_nci_i2c_enable,
219+ .disable = st_nci_i2c_disable,
220220 };
221221
222222 #ifdef CONFIG_OF
223−static int st21nfcb_nci_i2c_of_request_resources(struct i2c_client *client)
223+static int st_nci_i2c_of_request_resources(struct i2c_client *client)
224224 {
225− struct st21nfcb_i2c_phy *phy = i2c_get_clientdata(client);
225+ struct st_nci_i2c_phy *phy = i2c_get_clientdata(client);
226226 struct device_node *pp;
227227 int gpio;
228228 int r;
@@ -253,16 +253,16 @@ static int st21nfcb_nci_i2c_of_request_resources(struct i2c_client *client) · 24 unmodified lines
253253 return 0;
254254 }
255255 #else
256−static int st21nfcb_nci_i2c_of_request_resources(struct i2c_client *client)
256+static int st_nci_i2c_of_request_resources(struct i2c_client *client)
257257 {
258258 return -ENODEV;
259259 }
260260 #endif
261261
262−static int st21nfcb_nci_i2c_request_resources(struct i2c_client *client)
262+static int st_nci_i2c_request_resources(struct i2c_client *client)
263263 {
264− struct st21nfcb_nfc_platform_data *pdata;
265− struct st21nfcb_i2c_phy *phy = i2c_get_clientdata(client);
264+ struct st_nci_nfc_platform_data *pdata;
265+ struct st_nci_i2c_phy *phy = i2c_get_clientdata(client);
266266 int r;
267267
268268 pdata = client->dev.platform_data;
@@ -285,11 +285,11 @@ static int st21nfcb_nci_i2c_request_resources(struct i2c_client *client) · 16 unmodified lines
285285 return 0;
286286 }
287287
288−static int st21nfcb_nci_i2c_probe(struct i2c_client *client,
288+static int st_nci_i2c_probe(struct i2c_client *client,
289289 const struct i2c_device_id *id)
290290 {
291− struct st21nfcb_i2c_phy *phy;
292− struct st21nfcb_nfc_platform_data *pdata;
291+ struct st_nci_i2c_phy *phy;
292+ struct st_nci_nfc_platform_data *pdata;
293293 int r;
294294
295295 dev_dbg(&client->dev, "%s\n", __func__);
@@ -300,7 +300,7 @@ static int st21nfcb_nci_i2c_probe(struct i2c_client *client, · 4 unmodified lines
300300 return -ENODEV;
301301 }
302302
303− phy = devm_kzalloc(&client->dev, sizeof(struct st21nfcb_i2c_phy),
303+ phy = devm_kzalloc(&client->dev, sizeof(struct st_nci_i2c_phy),
304304 GFP_KERNEL);
305305 if (!phy)
306306 return -ENOMEM;
@@ -311,13 +311,13 @@ static int st21nfcb_nci_i2c_probe(struct i2c_client *client, · 4 unmodified lines
311311
312312 pdata = client->dev.platform_data;
313313 if (!pdata && client->dev.of_node) {
314− r = st21nfcb_nci_i2c_of_request_resources(client);
314+ r = st_nci_i2c_of_request_resources(client);
315315 if (r) {
316316 nfc_err(&client->dev, "No platform data\n");
317317 return r;
318318 }
319319 } else if (pdata) {
320− r = st21nfcb_nci_i2c_request_resources(client);
320+ r = st_nci_i2c_request_resources(client);
321321 if (r) {
322322 nfc_err(&client->dev,
323323 "Cannot get platform resources\n");
@@ -338,18 +338,18 @@ static int st21nfcb_nci_i2c_probe(struct i2c_client *client, · 14 unmodified lines
338338 }
339339
340340 r = devm_request_threaded_irq(&client->dev, client->irq, NULL,
341− st21nfcb_nci_irq_thread_fn,
341+ st_nci_irq_thread_fn,
342342 phy->irq_polarity | IRQF_ONESHOT,
343− ST21NFCB_NCI_DRIVER_NAME, phy);
343+ ST_NCI_DRIVER_NAME, phy);
344344 if (r < 0)
345345 nfc_err(&client->dev, "Unable to register IRQ handler\n");
346346
347347 return r;
348348 }
349349
350−static int st21nfcb_nci_i2c_remove(struct i2c_client *client)
350+static int st_nci_i2c_remove(struct i2c_client *client)
351351 {
352− struct st21nfcb_i2c_phy *phy = i2c_get_clientdata(client);
352+ struct st_nci_i2c_phy *phy = i2c_get_clientdata(client);
353353
354354 dev_dbg(&client->dev, "%s\n", __func__);
355355
@@ -359,26 +359,27 @@ static int st21nfcb_nci_i2c_remove(struct i2c_client *client) · 3 unmodified lines
359359 }
360360
361361 #ifdef CONFIG_OF
362−static const struct of_device_id of_st21nfcb_i2c_match[] = {
362+static const struct of_device_id of_st_nci_i2c_match[] = {
363363 { .compatible = "st,st21nfcb-i2c", },
364364 { .compatible = "st,st21nfcb_i2c", },
365+ { .compatible = "st,st21nfcc-i2c", },
365366 {}
366367 };
367−MODULE_DEVICE_TABLE(of, of_st21nfcb_i2c_match);
368+MODULE_DEVICE_TABLE(of, of_st_nci_i2c_match);
368369 #endif
369370
370−static struct i2c_driver st21nfcb_nci_i2c_driver = {
371+static struct i2c_driver st_nci_i2c_driver = {
371372 .driver = {
372373 .owner = THIS_MODULE,
373− .name = ST21NFCB_NCI_I2C_DRIVER_NAME,
374− .of_match_table = of_match_ptr(of_st21nfcb_i2c_match),
374+ .name = ST_NCI_I2C_DRIVER_NAME,
375+ .of_match_table = of_match_ptr(of_st_nci_i2c_match),
375376 },
376− .probe = st21nfcb_nci_i2c_probe,
377− .id_table = st21nfcb_nci_i2c_id_table,
378− .remove = st21nfcb_nci_i2c_remove,
377+ .probe = st_nci_i2c_probe,
378+ .id_table = st_nci_i2c_id_table,
379+ .remove = st_nci_i2c_remove,
379380 };
380381
381−module_i2c_driver(st21nfcb_nci_i2c_driver);
382+module_i2c_driver(st_nci_i2c_driver);
382383
383384 MODULE_LICENSE("GPL");
384385 MODULE_DESCRIPTION(DRIVER_DESC);
drivers/nfc/st-nci/ndlc.crenamed from drivers/nfc/st21nfcb/ndlc.c+6−6
@@ -1,7 +1,7 @@
11 /*
22 * Low Level Transport (NDLC) Driver for STMicroelectronics NFC Chip
33 *
4− * Copyright (C) 2014 STMicroelectronics SAS. All rights reserved.
4+ * Copyright (C) 2014-2015 STMicroelectronics SAS. All rights reserved.
55 *
66 * This program is free software; you can redistribute it and/or modify it
77 * under the terms and conditions of the GNU General Public License,
@@ -20,7 +20,7 @@ · 12 unmodified lines
2020 #include <net/nfc/nci_core.h>
2121
2222 #include "ndlc.h"
23−#include "st21nfcb.h"
23+#include "st-nci.h"
2424
2525 #define NDLC_TIMER_T1 100
2626 #define NDLC_TIMER_T1_WAIT 400
@@ -68,13 +68,13 @@ void ndlc_close(struct llt_ndlc *ndlc) · 41 unmodified lines
6868 {
6969 struct nci_mode_set_cmd cmd;
7070
71− cmd.cmd_type = ST21NFCB_NCI_SET_NFC_MODE;
71+ cmd.cmd_type = ST_NCI_SET_NFC_MODE;
7272 cmd.mode = 0;
7373
7474 /* toggle reset pin */
7575 ndlc->ops->enable(ndlc->phy_id);
7676
77− nci_prop_cmd(ndlc->ndev, ST21NFCB_NCI_CORE_PROP,
77+ nci_prop_cmd(ndlc->ndev, ST_NCI_CORE_PROP,
7878 sizeof(struct nci_mode_set_cmd), (__u8 *)&cmd);
7979
8080 ndlc->powered = 0;
@@ -293,13 +293,13 @@ int ndlc_probe(void *phy_id, struct nfc_phy_ops *phy_ops, struct device *dev, · 212 unmodified lines
293293
294294 INIT_WORK(&ndlc->sm_work, llt_ndlc_sm_work);
295295
296− return st21nfcb_nci_probe(ndlc, phy_headroom, phy_tailroom);
296+ return st_nci_probe(ndlc, phy_headroom, phy_tailroom);
297297 }
298298 EXPORT_SYMBOL(ndlc_probe);
299299
300300 void ndlc_remove(struct llt_ndlc *ndlc)
301301 {
302− st21nfcb_nci_remove(ndlc->ndev);
302+ st_nci_remove(ndlc->ndev);
303303
304304 /* cancel timers */
305305 del_timer_sync(&ndlc->t1_timer);
drivers/nfc/st-nci/ndlc.hrenamed from drivers/nfc/st21nfcb/ndlc.h+2−2
@@ -1,7 +1,7 @@
11 /*
22 * NCI based Driver for STMicroelectronics NFC Chip
33 *
4− * Copyright (C) 2014 STMicroelectronics SAS. All rights reserved.
4+ * Copyright (C) 2014-2015 STMicroelectronics SAS. All rights reserved.
55 *
66 * This program is free software; you can redistribute it and/or modify it
77 * under the terms and conditions of the GNU General Public License,
@@ -43,7 +43,7 @@ struct llt_ndlc { · 35 unmodified lines
4343 struct device *dev;
4444
4545 /*
46− * < 0 if hardware error occured
46+ * < 0 if hardware error occurred
4747 * and prevents normal operation.
4848 */
4949 int hard_fault;
drivers/nfc/st-nci/st-nci.hrenamed from drivers/nfc/st21nfcb/st21nfcb.h+11−11
@@ -16,17 +16,17 @@ · 15 unmodified lines
1616 * along with this program; if not, see <http://www.gnu.org/licenses/>.
1717 */
1818
19−#ifndef __LOCAL_ST21NFCB_H_
20−#define __LOCAL_ST21NFCB_H_
19+#ifndef __LOCAL_ST_NCI_H_
20+#define __LOCAL_ST_NCI_H_
2121
22−#include "st21nfcb_se.h"
22+#include "st-nci_se.h"
2323 #include "ndlc.h"
2424
2525 /* Define private flags: */
26−#define ST21NFCB_NCI_RUNNING 1
26+#define ST_NCI_RUNNING 1
2727
28−#define ST21NFCB_NCI_CORE_PROP 0x01
29−#define ST21NFCB_NCI_SET_NFC_MODE 0x02
28+#define ST_NCI_CORE_PROP 0x01
29+#define ST_NCI_SET_NFC_MODE 0x02
3030
3131 struct nci_mode_set_cmd {
3232 u8 cmd_type;
@@ -37,14 +37,14 @@ struct nci_mode_set_rsp { · 4 unmodified lines
3737 u8 status;
3838 } __packed;
3939
40−struct st21nfcb_nci_info {
40+struct st_nci_info {
4141 struct llt_ndlc *ndlc;
4242 unsigned long flags;
43− struct st21nfcb_se_info se_info;
43+ struct st_nci_se_info se_info;
4444 };
4545
46−void st21nfcb_nci_remove(struct nci_dev *ndev);
47−int st21nfcb_nci_probe(struct llt_ndlc *ndlc, int phy_headroom,
46+void st_nci_remove(struct nci_dev *ndev);
47+int st_nci_probe(struct llt_ndlc *ndlc, int phy_headroom,
4848 int phy_tailroom);
4949
50−#endif /* __LOCAL_ST21NFCB_H_ */
50+#endif /* __LOCAL_ST_NCI_H_ */
drivers/nfc/st-nci/st-nci_se.crenamed from drivers/nfc/st21nfcb/st21nfcb_se.c+192−191
@@ -1,7 +1,7 @@
11 /*
2− * NCI based Driver for STMicroelectronics NFC Chip
2+ * Secure Element driver for STMicroelectronics NFC NCI chip
33 *
4− * Copyright (C) 2014 STMicroelectronics SAS. All rights reserved.
4+ * Copyright (C) 2014-2015 STMicroelectronics SAS. All rights reserved.
55 *
66 * This program is free software; you can redistribute it and/or modify it
77 * under the terms and conditions of the GNU General Public License,
@@ -22,10 +22,10 @@ · 14 unmodified lines
2222 #include <net/nfc/nci.h>
2323 #include <net/nfc/nci_core.h>
2424
25−#include "st21nfcb.h"
26−#include "st21nfcb_se.h"
25+#include "st-nci.h"
26+#include "st-nci_se.h"
2727
28−struct st21nfcb_pipe_info {
28+struct st_nci_pipe_info {
2929 u8 pipe_state;
3030 u8 src_host_id;
3131 u8 src_gate_id;
@@ -34,166 +34,166 @@ struct st21nfcb_pipe_info { · 2 unmodified lines
3434 } __packed;
3535
3636 /* Hosts */
37−#define ST21NFCB_HOST_CONTROLLER_ID 0x00
38−#define ST21NFCB_TERMINAL_HOST_ID 0x01
39−#define ST21NFCB_UICC_HOST_ID 0x02
40−#define ST21NFCB_ESE_HOST_ID 0xc0
37+#define ST_NCI_HOST_CONTROLLER_ID 0x00
38+#define ST_NCI_TERMINAL_HOST_ID 0x01
39+#define ST_NCI_UICC_HOST_ID 0x02
40+#define ST_NCI_ESE_HOST_ID 0xc0
4141
4242 /* Gates */
43−#define ST21NFCB_DEVICE_MGNT_GATE 0x01
44−#define ST21NFCB_APDU_READER_GATE 0xf0
45−#define ST21NFCB_CONNECTIVITY_GATE 0x41
43+#define ST_NCI_DEVICE_MGNT_GATE 0x01
44+#define ST_NCI_APDU_READER_GATE 0xf0
45+#define ST_NCI_CONNECTIVITY_GATE 0x41
4646
4747 /* Pipes */
48−#define ST21NFCB_DEVICE_MGNT_PIPE 0x02
48+#define ST_NCI_DEVICE_MGNT_PIPE 0x02
4949
5050 /* Connectivity pipe only */
51−#define ST21NFCB_SE_COUNT_PIPE_UICC 0x01
51+#define ST_NCI_SE_COUNT_PIPE_UICC 0x01
5252 /* Connectivity + APDU Reader pipe */
53−#define ST21NFCB_SE_COUNT_PIPE_EMBEDDED 0x02
53+#define ST_NCI_SE_COUNT_PIPE_EMBEDDED 0x02
5454
55−#define ST21NFCB_SE_TO_HOT_PLUG 1000 /* msecs */
56−#define ST21NFCB_SE_TO_PIPES 2000
55+#define ST_NCI_SE_TO_HOT_PLUG 1000 /* msecs */
56+#define ST_NCI_SE_TO_PIPES 2000
5757
58−#define ST21NFCB_EVT_HOT_PLUG_IS_INHIBITED(x) (x->data[0] & 0x80)
58+#define ST_NCI_EVT_HOT_PLUG_IS_INHIBITED(x) (x->data[0] & 0x80)
5959
6060 #define NCI_HCI_APDU_PARAM_ATR 0x01
6161 #define NCI_HCI_ADMIN_PARAM_SESSION_IDENTITY 0x01
6262 #define NCI_HCI_ADMIN_PARAM_WHITELIST 0x03
6363 #define NCI_HCI_ADMIN_PARAM_HOST_LIST 0x04
6464
65−#define ST21NFCB_EVT_SE_HARD_RESET 0x20
66−#define ST21NFCB_EVT_TRANSMIT_DATA 0x10
67−#define ST21NFCB_EVT_WTX_REQUEST 0x11
68−#define ST21NFCB_EVT_SE_SOFT_RESET 0x11
69−#define ST21NFCB_EVT_SE_END_OF_APDU_TRANSFER 0x21
70−#define ST21NFCB_EVT_HOT_PLUG 0x03
65+#define ST_NCI_EVT_SE_HARD_RESET 0x20
66+#define ST_NCI_EVT_TRANSMIT_DATA 0x10
67+#define ST_NCI_EVT_WTX_REQUEST 0x11
68+#define ST_NCI_EVT_SE_SOFT_RESET 0x11
69+#define ST_NCI_EVT_SE_END_OF_APDU_TRANSFER 0x21
70+#define ST_NCI_EVT_HOT_PLUG 0x03
7171
72−#define ST21NFCB_SE_MODE_OFF 0x00
73−#define ST21NFCB_SE_MODE_ON 0x01
72+#define ST_NCI_SE_MODE_OFF 0x00
73+#define ST_NCI_SE_MODE_ON 0x01
7474
75−#define ST21NFCB_EVT_CONNECTIVITY 0x10
76−#define ST21NFCB_EVT_TRANSACTION 0x12
75+#define ST_NCI_EVT_CONNECTIVITY 0x10
76+#define ST_NCI_EVT_TRANSACTION 0x12
7777
78−#define ST21NFCB_DM_GETINFO 0x13
79−#define ST21NFCB_DM_GETINFO_PIPE_LIST 0x02
80−#define ST21NFCB_DM_GETINFO_PIPE_INFO 0x01
81−#define ST21NFCB_DM_PIPE_CREATED 0x02
82−#define ST21NFCB_DM_PIPE_OPEN 0x04
83−#define ST21NFCB_DM_RF_ACTIVE 0x80
84−#define ST21NFCB_DM_DISCONNECT 0x30
78+#define ST_NCI_DM_GETINFO 0x13
79+#define ST_NCI_DM_GETINFO_PIPE_LIST 0x02
80+#define ST_NCI_DM_GETINFO_PIPE_INFO 0x01
81+#define ST_NCI_DM_PIPE_CREATED 0x02
82+#define ST_NCI_DM_PIPE_OPEN 0x04
83+#define ST_NCI_DM_RF_ACTIVE 0x80
84+#define ST_NCI_DM_DISCONNECT 0x30
8585
86−#define ST21NFCB_DM_IS_PIPE_OPEN(p) \
87− ((p & 0x0f) == (ST21NFCB_DM_PIPE_CREATED | ST21NFCB_DM_PIPE_OPEN))
86+#define ST_NCI_DM_IS_PIPE_OPEN(p) \
87+ ((p & 0x0f) == (ST_NCI_DM_PIPE_CREATED | ST_NCI_DM_PIPE_OPEN))
8888
89−#define ST21NFCB_ATR_DEFAULT_BWI 0x04
89+#define ST_NCI_ATR_DEFAULT_BWI 0x04
9090
9191 /*
9292 * WT = 2^BWI/10[s], convert into msecs and add a secure
9393 * room by increasing by 2 this timeout
9494 */
95−#define ST21NFCB_BWI_TO_TIMEOUT(x) ((1 << x) * 200)
96−#define ST21NFCB_ATR_GET_Y_FROM_TD(x) (x >> 4)
95+#define ST_NCI_BWI_TO_TIMEOUT(x) ((1 << x) * 200)
96+#define ST_NCI_ATR_GET_Y_FROM_TD(x) (x >> 4)
9797
9898 /* If TA is present bit 0 is set */
99−#define ST21NFCB_ATR_TA_PRESENT(x) (x & 0x01)
99+#define ST_NCI_ATR_TA_PRESENT(x) (x & 0x01)
100100 /* If TB is present bit 1 is set */
101−#define ST21NFCB_ATR_TB_PRESENT(x) (x & 0x02)
101+#define ST_NCI_ATR_TB_PRESENT(x) (x & 0x02)
102102
103−#define ST21NFCB_NUM_DEVICES 256
103+#define ST_NCI_NUM_DEVICES 256
104104
105−static DECLARE_BITMAP(dev_mask, ST21NFCB_NUM_DEVICES);
105+static DECLARE_BITMAP(dev_mask, ST_NCI_NUM_DEVICES);
106106
107−/* Here are the mandatory pipe for st21nfcb */
108−static struct nci_hci_gate st21nfcb_gates[] = {
107+/* Here are the mandatory pipe for st_nci */
108+static struct nci_hci_gate st_nci_gates[] = {
109109 {NCI_HCI_ADMIN_GATE, NCI_HCI_ADMIN_PIPE,
110− ST21NFCB_HOST_CONTROLLER_ID},
110+ ST_NCI_HOST_CONTROLLER_ID},
111111 {NCI_HCI_LINK_MGMT_GATE, NCI_HCI_LINK_MGMT_PIPE,
112− ST21NFCB_HOST_CONTROLLER_ID},
113− {ST21NFCB_DEVICE_MGNT_GATE, ST21NFCB_DEVICE_MGNT_PIPE,
114− ST21NFCB_HOST_CONTROLLER_ID},
112+ ST_NCI_HOST_CONTROLLER_ID},
113+ {ST_NCI_DEVICE_MGNT_GATE, ST_NCI_DEVICE_MGNT_PIPE,
114+ ST_NCI_HOST_CONTROLLER_ID},
115115
116116 /* Secure element pipes are created by secure element host */
117− {ST21NFCB_CONNECTIVITY_GATE, NCI_HCI_DO_NOT_OPEN_PIPE,
118− ST21NFCB_HOST_CONTROLLER_ID},
119− {ST21NFCB_APDU_READER_GATE, NCI_HCI_DO_NOT_OPEN_PIPE,
120− ST21NFCB_HOST_CONTROLLER_ID},
117+ {ST_NCI_CONNECTIVITY_GATE, NCI_HCI_DO_NOT_OPEN_PIPE,
118+ ST_NCI_HOST_CONTROLLER_ID},
119+ {ST_NCI_APDU_READER_GATE, NCI_HCI_DO_NOT_OPEN_PIPE,
120+ ST_NCI_HOST_CONTROLLER_ID},
121121 };
122122
123−static u8 st21nfcb_se_get_bwi(struct nci_dev *ndev)
123+static u8 st_nci_se_get_bwi(struct nci_dev *ndev)
124124 {
125125 int i;
126126 u8 td;
127− struct st21nfcb_nci_info *info = nci_get_drvdata(ndev);
127+ struct st_nci_info *info = nci_get_drvdata(ndev);
128128
129129 /* Bits 8 to 5 of the first TB for T=1 encode BWI from zero to nine */
130− for (i = 1; i < ST21NFCB_ESE_MAX_LENGTH; i++) {
131− td = ST21NFCB_ATR_GET_Y_FROM_TD(info->se_info.atr[i]);
132− if (ST21NFCB_ATR_TA_PRESENT(td))
130+ for (i = 1; i < ST_NCI_ESE_MAX_LENGTH; i++) {
131+ td = ST_NCI_ATR_GET_Y_FROM_TD(info->se_info.atr[i]);
132+ if (ST_NCI_ATR_TA_PRESENT(td))
133133 i++;
134− if (ST21NFCB_ATR_TB_PRESENT(td)) {
134+ if (ST_NCI_ATR_TB_PRESENT(td)) {
135135 i++;
136136 return info->se_info.atr[i] >> 4;
137137 }
138138 }
139− return ST21NFCB_ATR_DEFAULT_BWI;
139+ return ST_NCI_ATR_DEFAULT_BWI;
140140 }
141141
142−static void st21nfcb_se_get_atr(struct nci_dev *ndev)
142+static void st_nci_se_get_atr(struct nci_dev *ndev)
143143 {
144− struct st21nfcb_nci_info *info = nci_get_drvdata(ndev);
144+ struct st_nci_info *info = nci_get_drvdata(ndev);
145145 int r;
146146 struct sk_buff *skb;
147147
148− r = nci_hci_get_param(ndev, ST21NFCB_APDU_READER_GATE,
148+ r = nci_hci_get_param(ndev, ST_NCI_APDU_READER_GATE,
149149 NCI_HCI_APDU_PARAM_ATR, &skb);
150150 if (r < 0)
151151 return;
152152
153− if (skb->len <= ST21NFCB_ESE_MAX_LENGTH) {
153+ if (skb->len <= ST_NCI_ESE_MAX_LENGTH) {
154154 memcpy(info->se_info.atr, skb->data, skb->len);
155155
156156 info->se_info.wt_timeout =
157− ST21NFCB_BWI_TO_TIMEOUT(st21nfcb_se_get_bwi(ndev));
157+ ST_NCI_BWI_TO_TIMEOUT(st_nci_se_get_bwi(ndev));
158158 }
159159 kfree_skb(skb);
160160 }
161161
162−int st21nfcb_hci_load_session(struct nci_dev *ndev)
162+int st_nci_hci_load_session(struct nci_dev *ndev)
163163 {
164164 int i, j, r;
165165 struct sk_buff *skb_pipe_list, *skb_pipe_info;
166− struct st21nfcb_pipe_info *dm_pipe_info;
167− u8 pipe_list[] = { ST21NFCB_DM_GETINFO_PIPE_LIST,
168− ST21NFCB_TERMINAL_HOST_ID};
169− u8 pipe_info[] = { ST21NFCB_DM_GETINFO_PIPE_INFO,
170− ST21NFCB_TERMINAL_HOST_ID, 0};
166+ struct st_nci_pipe_info *dm_pipe_info;
167+ u8 pipe_list[] = { ST_NCI_DM_GETINFO_PIPE_LIST,
168+ ST_NCI_TERMINAL_HOST_ID};
169+ u8 pipe_info[] = { ST_NCI_DM_GETINFO_PIPE_INFO,
170+ ST_NCI_TERMINAL_HOST_ID, 0};
171171
172− /* On ST21NFCB device pipes number are dynamics
172+ /* On ST_NCI device pipes number are dynamics
173173 * If pipes are already created, hci_dev_up will fail.
174174 * Doing a clear all pipe is a bad idea because:
175175 * - It does useless EEPROM cycling
176176 * - It might cause issue for secure elements support
177177 * (such as removing connectivity or APDU reader pipe)
178− * A better approach on ST21NFCB is to:
178+ * A better approach on ST_NCI is to:
179179 * - get a pipe list for each host.
180− * (eg: ST21NFCB_HOST_CONTROLLER_ID for now).
180+ * (eg: ST_NCI_HOST_CONTROLLER_ID for now).
181181 * (TODO Later on UICC HOST and eSE HOST)
182182 * - get pipe information
183− * - match retrieved pipe list in st21nfcb_gates
184− * ST21NFCB_DEVICE_MGNT_GATE is a proprietary gate
185− * with ST21NFCB_DEVICE_MGNT_PIPE.
183+ * - match retrieved pipe list in st_nci_gates
184+ * ST_NCI_DEVICE_MGNT_GATE is a proprietary gate
185+ * with ST_NCI_DEVICE_MGNT_PIPE.
186186 * Pipe can be closed and need to be open.
187187 */
188− r = nci_hci_connect_gate(ndev, ST21NFCB_HOST_CONTROLLER_ID,
189− ST21NFCB_DEVICE_MGNT_GATE,
190− ST21NFCB_DEVICE_MGNT_PIPE);
188+ r = nci_hci_connect_gate(ndev, ST_NCI_HOST_CONTROLLER_ID,
189+ ST_NCI_DEVICE_MGNT_GATE,
190+ ST_NCI_DEVICE_MGNT_PIPE);
191191 if (r < 0)
192192 goto free_info;
193193
194194 /* Get pipe list */
195− r = nci_hci_send_cmd(ndev, ST21NFCB_DEVICE_MGNT_GATE,
196− ST21NFCB_DM_GETINFO, pipe_list, sizeof(pipe_list),
195+ r = nci_hci_send_cmd(ndev, ST_NCI_DEVICE_MGNT_GATE,
196+ ST_NCI_DM_GETINFO, pipe_list, sizeof(pipe_list),
197197 &skb_pipe_list);
198198 if (r < 0)
199199 goto free_info;
@@ -201,8 +201,8 @@ int st21nfcb_hci_load_session(struct nci_dev *ndev) · 1 unmodified line
201201 /* Complete the existing gate_pipe table */
202202 for (i = 0; i < skb_pipe_list->len; i++) {
203203 pipe_info[2] = skb_pipe_list->data[i];
204− r = nci_hci_send_cmd(ndev, ST21NFCB_DEVICE_MGNT_GATE,
205− ST21NFCB_DM_GETINFO, pipe_info,
204+ r = nci_hci_send_cmd(ndev, ST_NCI_DEVICE_MGNT_GATE,
205+ ST_NCI_DM_GETINFO, pipe_info,
206206 sizeof(pipe_info), &skb_pipe_info);
207207
208208 if (r)
@@ -217,81 +217,81 @@ int st21nfcb_hci_load_session(struct nci_dev *ndev) · 8 unmodified lines
217217 * - destination hid (1byte)
218218 * - destination gid (1byte)
219219 */
220− dm_pipe_info = (struct st21nfcb_pipe_info *)skb_pipe_info->data;
221− if (dm_pipe_info->dst_gate_id == ST21NFCB_APDU_READER_GATE &&
222− dm_pipe_info->src_host_id != ST21NFCB_ESE_HOST_ID) {
220+ dm_pipe_info = (struct st_nci_pipe_info *)skb_pipe_info->data;
221+ if (dm_pipe_info->dst_gate_id == ST_NCI_APDU_READER_GATE &&
222+ dm_pipe_info->src_host_id != ST_NCI_ESE_HOST_ID) {
223223 pr_err("Unexpected apdu_reader pipe on host %x\n",
224224 dm_pipe_info->src_host_id);
225225 continue;
226226 }
227227
228− for (j = 0; (j < ARRAY_SIZE(st21nfcb_gates)) &&
229− (st21nfcb_gates[j].gate != dm_pipe_info->dst_gate_id); j++)
228+ for (j = 0; (j < ARRAY_SIZE(st_nci_gates)) &&
229+ (st_nci_gates[j].gate != dm_pipe_info->dst_gate_id); j++)
230230 ;
231231
232− if (j < ARRAY_SIZE(st21nfcb_gates) &&
233− st21nfcb_gates[j].gate == dm_pipe_info->dst_gate_id &&
234− ST21NFCB_DM_IS_PIPE_OPEN(dm_pipe_info->pipe_state)) {
235− st21nfcb_gates[j].pipe = pipe_info[2];
232+ if (j < ARRAY_SIZE(st_nci_gates) &&
233+ st_nci_gates[j].gate == dm_pipe_info->dst_gate_id &&
234+ ST_NCI_DM_IS_PIPE_OPEN(dm_pipe_info->pipe_state)) {
235+ st_nci_gates[j].pipe = pipe_info[2];
236236
237− ndev->hci_dev->gate2pipe[st21nfcb_gates[j].gate] =
238− st21nfcb_gates[j].pipe;
239− ndev->hci_dev->pipes[st21nfcb_gates[j].pipe].gate =
240− st21nfcb_gates[j].gate;
241− ndev->hci_dev->pipes[st21nfcb_gates[j].pipe].host =
237+ ndev->hci_dev->gate2pipe[st_nci_gates[j].gate] =
238+ st_nci_gates[j].pipe;
239+ ndev->hci_dev->pipes[st_nci_gates[j].pipe].gate =
240+ st_nci_gates[j].gate;
241+ ndev->hci_dev->pipes[st_nci_gates[j].pipe].host =
242242 dm_pipe_info->src_host_id;
243243 }
244244 }
245245
246− memcpy(ndev->hci_dev->init_data.gates, st21nfcb_gates,
247− sizeof(st21nfcb_gates));
246+ memcpy(ndev->hci_dev->init_data.gates, st_nci_gates,
247+ sizeof(st_nci_gates));
248248
249249 free_info:
250250 kfree_skb(skb_pipe_info);
251251 kfree_skb(skb_pipe_list);
252252 return r;
253253 }
254−EXPORT_SYMBOL_GPL(st21nfcb_hci_load_session);
254+EXPORT_SYMBOL_GPL(st_nci_hci_load_session);
255255
256−static void st21nfcb_hci_admin_event_received(struct nci_dev *ndev,
256+static void st_nci_hci_admin_event_received(struct nci_dev *ndev,
257257 u8 event, struct sk_buff *skb)
258258 {
259− struct st21nfcb_nci_info *info = nci_get_drvdata(ndev);
259+ struct st_nci_info *info = nci_get_drvdata(ndev);
260260
261261 switch (event) {
262− case ST21NFCB_EVT_HOT_PLUG:
262+ case ST_NCI_EVT_HOT_PLUG:
263263 if (info->se_info.se_active) {
264− if (!ST21NFCB_EVT_HOT_PLUG_IS_INHIBITED(skb)) {
264+ if (!ST_NCI_EVT_HOT_PLUG_IS_INHIBITED(skb)) {
265265 del_timer_sync(&info->se_info.se_active_timer);
266266 info->se_info.se_active = false;
267267 complete(&info->se_info.req_completion);
268268 } else {
269269 mod_timer(&info->se_info.se_active_timer,
270270 jiffies +
271− msecs_to_jiffies(ST21NFCB_SE_TO_PIPES));
271+ msecs_to_jiffies(ST_NCI_SE_TO_PIPES));
272272 }
273273 }
274274 break;
275275 }
276276 }
277277
278−static int st21nfcb_hci_apdu_reader_event_received(struct nci_dev *ndev,
278+static int st_nci_hci_apdu_reader_event_received(struct nci_dev *ndev,
279279 u8 event,
280280 struct sk_buff *skb)
281281 {
282282 int r = 0;
283− struct st21nfcb_nci_info *info = nci_get_drvdata(ndev);
283+ struct st_nci_info *info = nci_get_drvdata(ndev);
284284
285285 pr_debug("apdu reader gate event: %x\n", event);
286286
287287 switch (event) {
288− case ST21NFCB_EVT_TRANSMIT_DATA:
288+ case ST_NCI_EVT_TRANSMIT_DATA:
289289 del_timer_sync(&info->se_info.bwi_timer);
290290 info->se_info.bwi_active = false;
291291 info->se_info.cb(info->se_info.cb_context,
292292 skb->data, skb->len, 0);
293293 break;
294− case ST21NFCB_EVT_WTX_REQUEST:
294+ case ST_NCI_EVT_WTX_REQUEST:
295295 mod_timer(&info->se_info.bwi_timer, jiffies +
296296 msecs_to_jiffies(info->se_info.wt_timeout));
297297 break;
@@ -306,7 +306,7 @@ static int st21nfcb_hci_apdu_reader_event_received(struct nci_dev *ndev, · 8 unmodified lines
306306 * <= 0: driver handled the event, skb consumed
307307 * 1: driver does not handle the event, please do standard processing
308308 */
309−static int st21nfcb_hci_connectivity_event_received(struct nci_dev *ndev,
309+static int st_nci_hci_connectivity_event_received(struct nci_dev *ndev,
310310 u8 host, u8 event,
311311 struct sk_buff *skb)
312312 {
@@ -317,10 +317,10 @@ static int st21nfcb_hci_connectivity_event_received(struct nci_dev *ndev, · 4 unmodified lines
317317 pr_debug("connectivity gate event: %x\n", event);
318318
319319 switch (event) {
320− case ST21NFCB_EVT_CONNECTIVITY:
320+ case ST_NCI_EVT_CONNECTIVITY:
321321
322322 break;
323− case ST21NFCB_EVT_TRANSACTION:
323+ case ST_NCI_EVT_TRANSACTION:
324324 /* According to specification etsi 102 622
325325 * 11.2.2.4 EVT_TRANSACTION Table 52
326326 * Description Tag Length
@@ -355,7 +355,7 @@ static int st21nfcb_hci_connectivity_event_received(struct nci_dev *ndev, · 28 unmodified lines
355355 return r;
356356 }
357357
358−void st21nfcb_hci_event_received(struct nci_dev *ndev, u8 pipe,
358+void st_nci_hci_event_received(struct nci_dev *ndev, u8 pipe,
359359 u8 event, struct sk_buff *skb)
360360 {
361361 u8 gate = ndev->hci_dev->pipes[pipe].gate;
@@ -363,32 +363,32 @@ void st21nfcb_hci_event_received(struct nci_dev *ndev, u8 pipe, · 1 unmodified line
363363
364364 switch (gate) {
365365 case NCI_HCI_ADMIN_GATE:
366− st21nfcb_hci_admin_event_received(ndev, event, skb);
366+ st_nci_hci_admin_event_received(ndev, event, skb);
367367 break;
368− case ST21NFCB_APDU_READER_GATE:
369− st21nfcb_hci_apdu_reader_event_received(ndev, event, skb);
368+ case ST_NCI_APDU_READER_GATE:
369+ st_nci_hci_apdu_reader_event_received(ndev, event, skb);
370370 break;
371− case ST21NFCB_CONNECTIVITY_GATE:
372− st21nfcb_hci_connectivity_event_received(ndev, host, event,
371+ case ST_NCI_CONNECTIVITY_GATE:
372+ st_nci_hci_connectivity_event_received(ndev, host, event,
373373 skb);
374374 break;
375375 }
376376 }
377−EXPORT_SYMBOL_GPL(st21nfcb_hci_event_received);
377+EXPORT_SYMBOL_GPL(st_nci_hci_event_received);
378378
379379
380−void st21nfcb_hci_cmd_received(struct nci_dev *ndev, u8 pipe, u8 cmd,
380+void st_nci_hci_cmd_received(struct nci_dev *ndev, u8 pipe, u8 cmd,
381381 struct sk_buff *skb)
382382 {
383− struct st21nfcb_nci_info *info = nci_get_drvdata(ndev);
383+ struct st_nci_info *info = nci_get_drvdata(ndev);
384384 u8 gate = ndev->hci_dev->pipes[pipe].gate;
385385
386386 pr_debug("cmd: %x\n", cmd);
387387
388388 switch (cmd) {
389389 case NCI_HCI_ANY_OPEN_PIPE:
390− if (gate != ST21NFCB_APDU_READER_GATE &&
391− ndev->hci_dev->pipes[pipe].host != ST21NFCB_UICC_HOST_ID)
390+ if (gate != ST_NCI_APDU_READER_GATE &&
391+ ndev->hci_dev->pipes[pipe].host != ST_NCI_UICC_HOST_ID)
392392 ndev->hci_dev->count_pipes++;
393393
394394 if (ndev->hci_dev->count_pipes ==
@@ -401,28 +401,28 @@ void st21nfcb_hci_cmd_received(struct nci_dev *ndev, u8 pipe, u8 cmd, · 6 unmodified lines
401401 break;
402402 }
403403 }
404−EXPORT_SYMBOL_GPL(st21nfcb_hci_cmd_received);
404+EXPORT_SYMBOL_GPL(st_nci_hci_cmd_received);
405405
406406 /*
407− * Remarks: On some early st21nfcb firmware, nci_nfcee_mode_set(0)
407+ * Remarks: On some early st_nci firmware, nci_nfcee_mode_set(0)
408408 * is rejected
409409 */
410−static int st21nfcb_nci_control_se(struct nci_dev *ndev, u8 se_idx,
410+static int st_nci_control_se(struct nci_dev *ndev, u8 se_idx,
411411 u8 state)
412412 {
413− struct st21nfcb_nci_info *info = nci_get_drvdata(ndev);
413+ struct st_nci_info *info = nci_get_drvdata(ndev);
414414 int r;
415415 struct sk_buff *sk_host_list;
416416 u8 host_id;
417417
418418 switch (se_idx) {
419− case ST21NFCB_UICC_HOST_ID:
419+ case ST_NCI_UICC_HOST_ID:
420420 ndev->hci_dev->count_pipes = 0;
421− ndev->hci_dev->expected_pipes = ST21NFCB_SE_COUNT_PIPE_UICC;
421+ ndev->hci_dev->expected_pipes = ST_NCI_SE_COUNT_PIPE_UICC;
422422 break;
423− case ST21NFCB_ESE_HOST_ID:
423+ case ST_NCI_ESE_HOST_ID:
424424 ndev->hci_dev->count_pipes = 0;
425− ndev->hci_dev->expected_pipes = ST21NFCB_SE_COUNT_PIPE_EMBEDDED;
425+ ndev->hci_dev->expected_pipes = ST_NCI_SE_COUNT_PIPE_EMBEDDED;
426426 break;
427427 default:
428428 return -EINVAL;
@@ -438,7 +438,7 @@ static int st21nfcb_nci_control_se(struct nci_dev *ndev, u8 se_idx, · 9 unmodified lines
438438 return r;
439439
440440 mod_timer(&info->se_info.se_active_timer, jiffies +
441− msecs_to_jiffies(ST21NFCB_SE_TO_HOT_PLUG));
441+ msecs_to_jiffies(ST_NCI_SE_TO_HOT_PLUG));
442442 info->se_info.se_active = true;
443443
444444 /* Ignore return value and check in any case the host_list */
@@ -458,49 +458,49 @@ static int st21nfcb_nci_control_se(struct nci_dev *ndev, u8 se_idx, · 13 unmodified lines
458458
459459 host_id = sk_host_list->data[sk_host_list->len - 1];
460460 kfree_skb(sk_host_list);
461− if (state == ST21NFCB_SE_MODE_ON && host_id == se_idx)
461+ if (state == ST_NCI_SE_MODE_ON && host_id == se_idx)
462462 return se_idx;
463− else if (state == ST21NFCB_SE_MODE_OFF && host_id != se_idx)
463+ else if (state == ST_NCI_SE_MODE_OFF && host_id != se_idx)
464464 return se_idx;
465465
466466 return -1;
467467 }
468468
469−int st21nfcb_nci_disable_se(struct nci_dev *ndev, u32 se_idx)
469+int st_nci_disable_se(struct nci_dev *ndev, u32 se_idx)
470470 {
471471 int r;
472472
473− pr_debug("st21nfcb_nci_disable_se\n");
473+ pr_debug("st_nci_disable_se\n");
474474
475475 if (se_idx == NFC_SE_EMBEDDED) {
476− r = nci_hci_send_event(ndev, ST21NFCB_APDU_READER_GATE,
477− ST21NFCB_EVT_SE_END_OF_APDU_TRANSFER, NULL, 0);
476+ r = nci_hci_send_event(ndev, ST_NCI_APDU_READER_GATE,
477+ ST_NCI_EVT_SE_END_OF_APDU_TRANSFER, NULL, 0);
478478 if (r < 0)
479479 return r;
480480 }
481481
482482 return 0;
483483 }
484−EXPORT_SYMBOL_GPL(st21nfcb_nci_disable_se);
484+EXPORT_SYMBOL_GPL(st_nci_disable_se);
485485
486−int st21nfcb_nci_enable_se(struct nci_dev *ndev, u32 se_idx)
486+int st_nci_enable_se(struct nci_dev *ndev, u32 se_idx)
487487 {
488488 int r;
489489
490− pr_debug("st21nfcb_nci_enable_se\n");
490+ pr_debug("st_nci_enable_se\n");
491491
492− if (se_idx == ST21NFCB_HCI_HOST_ID_ESE) {
493− r = nci_hci_send_event(ndev, ST21NFCB_APDU_READER_GATE,
494− ST21NFCB_EVT_SE_SOFT_RESET, NULL, 0);
492+ if (se_idx == ST_NCI_HCI_HOST_ID_ESE) {
493+ r = nci_hci_send_event(ndev, ST_NCI_APDU_READER_GATE,
494+ ST_NCI_EVT_SE_SOFT_RESET, NULL, 0);
495495 if (r < 0)
496496 return r;
497497 }
498498
499499 return 0;
500500 }
501−EXPORT_SYMBOL_GPL(st21nfcb_nci_enable_se);
501+EXPORT_SYMBOL_GPL(st_nci_enable_se);
502502
503−static int st21nfcb_hci_network_init(struct nci_dev *ndev)
503+static int st_nci_hci_network_init(struct nci_dev *ndev)
504504 {
505505 struct core_conn_create_dest_spec_params *dest_params;
506506 struct dest_spec_params spec_params;
@@ -519,7 +519,8 @@ static int st21nfcb_hci_network_init(struct nci_dev *ndev) · 12 unmodified lines
519519 dest_params->length = sizeof(struct dest_spec_params);
520520 spec_params.id = ndev->hci_dev->nfcee_id;
521521 spec_params.protocol = NCI_NFCEE_INTERFACE_HCI_ACCESS;
522− memcpy(dest_params->value, &spec_params, sizeof(struct dest_spec_params));
522+ memcpy(dest_params->value, &spec_params,
523+ sizeof(struct dest_spec_params));
523524 r = nci_core_conn_create(ndev, NCI_DESTINATION_NFCEE, 1,
524525 sizeof(struct core_conn_create_dest_spec_params) +
525526 sizeof(struct dest_spec_params),
@@ -531,15 +532,15 @@ static int st21nfcb_hci_network_init(struct nci_dev *ndev) · 5 unmodified lines
531532 if (!conn_info)
532533 goto free_dest_params;
533534
534− memcpy(ndev->hci_dev->init_data.gates, st21nfcb_gates,
535− sizeof(st21nfcb_gates));
535+ memcpy(ndev->hci_dev->init_data.gates, st_nci_gates,
536+ sizeof(st_nci_gates));
536537
537538 /*
538539 * Session id must include the driver name + i2c bus addr
539540 * persistent info to discriminate 2 identical chips
540541 */
541− dev_num = find_first_zero_bit(dev_mask, ST21NFCB_NUM_DEVICES);
542− if (dev_num >= ST21NFCB_NUM_DEVICES) {
542+ dev_num = find_first_zero_bit(dev_mask, ST_NCI_NUM_DEVICES);
543+ if (dev_num >= ST_NCI_NUM_DEVICES) {
543544 r = -ENODEV;
544545 goto free_dest_params;
545546 }
@@ -564,72 +565,72 @@ exit: · 18 unmodified lines
564565 return r;
565566 }
566567
567−int st21nfcb_nci_discover_se(struct nci_dev *ndev)
568+int st_nci_discover_se(struct nci_dev *ndev)
568569 {
569570 u8 param[2];
570571 int r;
571572 int se_count = 0;
572573
573− pr_debug("st21nfcb_nci_discover_se\n");
574+ pr_debug("st_nci_discover_se\n");
574575
575− r = st21nfcb_hci_network_init(ndev);
576+ r = st_nci_hci_network_init(ndev);
576577 if (r != 0)
577578 return r;
578579
579− param[0] = ST21NFCB_UICC_HOST_ID;
580− param[1] = ST21NFCB_HCI_HOST_ID_ESE;
580+ param[0] = ST_NCI_UICC_HOST_ID;
581+ param[1] = ST_NCI_HCI_HOST_ID_ESE;
581582 r = nci_hci_set_param(ndev, NCI_HCI_ADMIN_GATE,
582583 NCI_HCI_ADMIN_PARAM_WHITELIST,
583584 param, sizeof(param));
584585 if (r != NCI_HCI_ANY_OK)
585586 return r;
586587
587− r = st21nfcb_nci_control_se(ndev, ST21NFCB_UICC_HOST_ID,
588− ST21NFCB_SE_MODE_ON);
589− if (r == ST21NFCB_UICC_HOST_ID) {
590− nfc_add_se(ndev->nfc_dev, ST21NFCB_UICC_HOST_ID, NFC_SE_UICC);
588+ r = st_nci_control_se(ndev, ST_NCI_UICC_HOST_ID,
589+ ST_NCI_SE_MODE_ON);
590+ if (r == ST_NCI_UICC_HOST_ID) {
591+ nfc_add_se(ndev->nfc_dev, ST_NCI_UICC_HOST_ID, NFC_SE_UICC);
591592 se_count++;
592593 }
593594
594595 /* Try to enable eSE in order to check availability */
595− r = st21nfcb_nci_control_se(ndev, ST21NFCB_HCI_HOST_ID_ESE,
596− ST21NFCB_SE_MODE_ON);
597− if (r == ST21NFCB_HCI_HOST_ID_ESE) {
598− nfc_add_se(ndev->nfc_dev, ST21NFCB_HCI_HOST_ID_ESE,
596+ r = st_nci_control_se(ndev, ST_NCI_HCI_HOST_ID_ESE,
597+ ST_NCI_SE_MODE_ON);
598+ if (r == ST_NCI_HCI_HOST_ID_ESE) {
599+ nfc_add_se(ndev->nfc_dev, ST_NCI_HCI_HOST_ID_ESE,
599600 NFC_SE_EMBEDDED);
600601 se_count++;
601− st21nfcb_se_get_atr(ndev);
602+ st_nci_se_get_atr(ndev);
602603 }
603604
604605 return !se_count;
605606 }
606−EXPORT_SYMBOL_GPL(st21nfcb_nci_discover_se);
607+EXPORT_SYMBOL_GPL(st_nci_discover_se);
607608
608−int st21nfcb_nci_se_io(struct nci_dev *ndev, u32 se_idx,
609+int st_nci_se_io(struct nci_dev *ndev, u32 se_idx,
609610 u8 *apdu, size_t apdu_length,
610611 se_io_cb_t cb, void *cb_context)
611612 {
612− struct st21nfcb_nci_info *info = nci_get_drvdata(ndev);
613+ struct st_nci_info *info = nci_get_drvdata(ndev);
613614
614615 pr_debug("\n");
615616
616617 switch (se_idx) {
617− case ST21NFCB_HCI_HOST_ID_ESE:
618+ case ST_NCI_HCI_HOST_ID_ESE:
618619 info->se_info.cb = cb;
619620 info->se_info.cb_context = cb_context;
620621 mod_timer(&info->se_info.bwi_timer, jiffies +
621622 msecs_to_jiffies(info->se_info.wt_timeout));
622623 info->se_info.bwi_active = true;
623− return nci_hci_send_event(ndev, ST21NFCB_APDU_READER_GATE,
624− ST21NFCB_EVT_TRANSMIT_DATA, apdu,
624+ return nci_hci_send_event(ndev, ST_NCI_APDU_READER_GATE,
625+ ST_NCI_EVT_TRANSMIT_DATA, apdu,
625626 apdu_length);
626627 default:
627628 return -ENODEV;
628629 }
629630 }
630−EXPORT_SYMBOL(st21nfcb_nci_se_io);
631+EXPORT_SYMBOL(st_nci_se_io);
631632
632−static void st21nfcb_se_wt_timeout(unsigned long data)
633+static void st_nci_se_wt_timeout(unsigned long data)
633634 {
634635 /*
635636 * No answer from the secure element
@@ -642,7 +643,7 @@ static void st21nfcb_se_wt_timeout(unsigned long data) · 6 unmodified lines
642643 */
643644 /* hardware reset managed through VCC_UICC_OUT power supply */
644645 u8 param = 0x01;
645− struct st21nfcb_nci_info *info = (struct st21nfcb_nci_info *) data;
646+ struct st_nci_info *info = (struct st_nci_info *) data;
646647
647648 pr_debug("\n");
648649
@@ -650,19 +651,19 @@ static void st21nfcb_se_wt_timeout(unsigned long data) · 1 unmodified line
650651
651652 if (!info->se_info.xch_error) {
652653 info->se_info.xch_error = true;
653− nci_hci_send_event(info->ndlc->ndev, ST21NFCB_APDU_READER_GATE,
654− ST21NFCB_EVT_SE_SOFT_RESET, NULL, 0);
654+ nci_hci_send_event(info->ndlc->ndev, ST_NCI_APDU_READER_GATE,
655+ ST_NCI_EVT_SE_SOFT_RESET, NULL, 0);
655656 } else {
656657 info->se_info.xch_error = false;
657− nci_hci_send_event(info->ndlc->ndev, ST21NFCB_DEVICE_MGNT_GATE,
658− ST21NFCB_EVT_SE_HARD_RESET, &param, 1);
658+ nci_hci_send_event(info->ndlc->ndev, ST_NCI_DEVICE_MGNT_GATE,
659+ ST_NCI_EVT_SE_HARD_RESET, &param, 1);
659660 }
660661 info->se_info.cb(info->se_info.cb_context, NULL, 0, -ETIME);
661662 }
662663
663−static void st21nfcb_se_activation_timeout(unsigned long data)
664+static void st_nci_se_activation_timeout(unsigned long data)
664665 {
665− struct st21nfcb_nci_info *info = (struct st21nfcb_nci_info *) data;
666+ struct st_nci_info *info = (struct st_nci_info *) data;
666667
667668 pr_debug("\n");
668669
@@ -671,35 +672,35 @@ static void st21nfcb_se_activation_timeout(unsigned long data) · 2 unmodified lines
671672 complete(&info->se_info.req_completion);
672673 }
673674
674−int st21nfcb_se_init(struct nci_dev *ndev)
675+int st_nci_se_init(struct nci_dev *ndev)
675676 {
676− struct st21nfcb_nci_info *info = nci_get_drvdata(ndev);
677+ struct st_nci_info *info = nci_get_drvdata(ndev);
677678
678679 init_completion(&info->se_info.req_completion);
679680 /* initialize timers */
680681 init_timer(&info->se_info.bwi_timer);
681682 info->se_info.bwi_timer.data = (unsigned long)info;
682− info->se_info.bwi_timer.function = st21nfcb_se_wt_timeout;
683+ info->se_info.bwi_timer.function = st_nci_se_wt_timeout;
683684 info->se_info.bwi_active = false;
684685
685686 init_timer(&info->se_info.se_active_timer);
686687 info->se_info.se_active_timer.data = (unsigned long)info;
687688 info->se_info.se_active_timer.function =
688− st21nfcb_se_activation_timeout;
689+ st_nci_se_activation_timeout;
689690 info->se_info.se_active = false;
690691
691692 info->se_info.xch_error = false;
692693
693694 info->se_info.wt_timeout =
694− ST21NFCB_BWI_TO_TIMEOUT(ST21NFCB_ATR_DEFAULT_BWI);
695+ ST_NCI_BWI_TO_TIMEOUT(ST_NCI_ATR_DEFAULT_BWI);
695696
696697 return 0;
697698 }
698−EXPORT_SYMBOL(st21nfcb_se_init);
699+EXPORT_SYMBOL(st_nci_se_init);
699700
700−void st21nfcb_se_deinit(struct nci_dev *ndev)
701+void st_nci_se_deinit(struct nci_dev *ndev)
701702 {
702− struct st21nfcb_nci_info *info = nci_get_drvdata(ndev);
703+ struct st_nci_info *info = nci_get_drvdata(ndev);
703704
704705 if (info->se_info.bwi_active)
705706 del_timer_sync(&info->se_info.bwi_timer);
@@ -709,5 +710,5 @@ void st21nfcb_se_deinit(struct nci_dev *ndev) · 3 unmodified lines
709710 info->se_info.se_active = false;
710711 info->se_info.bwi_active = false;
711712 }
712−EXPORT_SYMBOL(st21nfcb_se_deinit);
713+EXPORT_SYMBOL(st_nci_se_deinit);
713714
drivers/nfc/st-nci/st-nci_se.h+61−0
@@ -0,0 +1,61 @@
1+/*
2+ * Secure Element Driver for STMicroelectronics NFC NCI Chip
3+ *
4+ * Copyright (C) 2014-2015 STMicroelectronics SAS. 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, see <http://www.gnu.org/licenses/>.
17+ */
18+#ifndef __LOCAL_ST_NCI_SE_H_
19+#define __LOCAL_ST_NCI_SE_H_
20+
21+/*
22+ * ref ISO7816-3 chap 8.1. the initial character TS is followed by a
23+ * sequence of at most 32 characters.
24+ */
25+#define ST_NCI_ESE_MAX_LENGTH 33
26+#define ST_NCI_HCI_HOST_ID_ESE 0xc0
27+
28+struct st_nci_se_info {
29+ u8 atr[ST_NCI_ESE_MAX_LENGTH];
30+ struct completion req_completion;
31+
32+ struct timer_list bwi_timer;
33+ int wt_timeout; /* in msecs */
34+ bool bwi_active;
35+
36+ struct timer_list se_active_timer;
37+ bool se_active;
38+
39+ bool xch_error;
40+
41+ se_io_cb_t cb;
42+ void *cb_context;
43+};
44+
45+int st_nci_se_init(struct nci_dev *ndev);
46+void st_nci_se_deinit(struct nci_dev *ndev);
47+
48+int st_nci_discover_se(struct nci_dev *ndev);
49+int st_nci_enable_se(struct nci_dev *ndev, u32 se_idx);
50+int st_nci_disable_se(struct nci_dev *ndev, u32 se_idx);
51+int st_nci_se_io(struct nci_dev *ndev, u32 se_idx,
52+ u8 *apdu, size_t apdu_length,
53+ se_io_cb_t cb, void *cb_context);
54+int st_nci_hci_load_session(struct nci_dev *ndev);
55+void st_nci_hci_event_received(struct nci_dev *ndev, u8 pipe,
56+ u8 event, struct sk_buff *skb);
57+void st_nci_hci_cmd_received(struct nci_dev *ndev, u8 pipe, u8 cmd,
58+ struct sk_buff *skb);
59+
60+
61+#endif /* __LOCAL_ST_NCI_SE_H_ */
drivers/nfc/st21nfcb/Kconfig+0−22
@@ -1,22 +0,0 @@
1−config NFC_ST21NFCB
2− tristate "STMicroelectronics ST21NFCB NFC driver"
3− depends on NFC_NCI
4− default n
5− ---help---
6− STMicroelectronics ST21NFCB core driver. It implements the chipset
7− NCI logic and hooks into the NFC kernel APIs. Physical layers will
8− register against it.
9−
10− To compile this driver as a module, choose m here. The module will
11− be called st21nfcb.
12− Say N if unsure.
13−
14−config NFC_ST21NFCB_I2C
15− tristate "NFC ST21NFCB i2c support"
16− depends on NFC_ST21NFCB && I2C
17− ---help---
18− This module adds support for the STMicroelectronics st21nfcb i2c interface.
19− Select this if your platform is using the i2c bus.
20−
21− If you choose to build a module, it'll be called st21nfcb_i2c.
22− Say N if unsure.
drivers/nfc/st21nfcb/Makefile+0−9
@@ -1,9 +0,0 @@
1−#
2−# Makefile for ST21NFCB NCI based NFC driver
3−#
4−
5−st21nfcb_nci-objs = ndlc.o st21nfcb.o st21nfcb_se.o
6−obj-$(CONFIG_NFC_ST21NFCB) += st21nfcb_nci.o
7−
8−st21nfcb_i2c-objs = i2c.o
9−obj-$(CONFIG_NFC_ST21NFCB_I2C) += st21nfcb_i2c.o
drivers/nfc/st21nfcb/st21nfcb.c+0−179
@@ -1,179 +0,0 @@
1−/*
2− * NCI based Driver for STMicroelectronics NFC Chip
3− *
4− * Copyright (C) 2014 STMicroelectronics SAS. 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, see <http://www.gnu.org/licenses/>.
17− */
18−
19−#include <linux/module.h>
20−#include <linux/nfc.h>
21−#include <net/nfc/nci.h>
22−#include <net/nfc/nci_core.h>
23−#include <linux/gpio.h>
24−#include <linux/delay.h>
25−
26−#include "st21nfcb.h"
27−#include "st21nfcb_se.h"
28−
29−#define DRIVER_DESC "NCI NFC driver for ST21NFCB"
30−
31−#define ST21NFCB_NCI1_X_PROPRIETARY_ISO15693 0x83
32−
33−static int st21nfcb_nci_init(struct nci_dev *ndev)
34−{
35− struct nci_mode_set_cmd cmd;
36−
37− cmd.cmd_type = ST21NFCB_NCI_SET_NFC_MODE;
38− cmd.mode = 1;
39−
40− return nci_prop_cmd(ndev, ST21NFCB_NCI_CORE_PROP,
41− sizeof(struct nci_mode_set_cmd), (__u8 *)&cmd);
42−}
43−
44−static int st21nfcb_nci_open(struct nci_dev *ndev)
45−{
46− struct st21nfcb_nci_info *info = nci_get_drvdata(ndev);
47− int r;
48−
49− if (test_and_set_bit(ST21NFCB_NCI_RUNNING, &info->flags))
50− return 0;
51−
52− r = ndlc_open(info->ndlc);
53− if (r)
54− clear_bit(ST21NFCB_NCI_RUNNING, &info->flags);
55−
56− return r;
57−}
58−
59−static int st21nfcb_nci_close(struct nci_dev *ndev)
60−{
61− struct st21nfcb_nci_info *info = nci_get_drvdata(ndev);
62−
63− if (!test_bit(ST21NFCB_NCI_RUNNING, &info->flags))
64− return 0;
65−
66− ndlc_close(info->ndlc);
67−
68− clear_bit(ST21NFCB_NCI_RUNNING, &info->flags);
69−
70− return 0;
71−}
72−
73−static int st21nfcb_nci_send(struct nci_dev *ndev, struct sk_buff *skb)
74−{
75− struct st21nfcb_nci_info *info = nci_get_drvdata(ndev);
76−
77− skb->dev = (void *)ndev;
78−
79− if (!test_bit(ST21NFCB_NCI_RUNNING, &info->flags))
80− return -EBUSY;
81−
82− return ndlc_send(info->ndlc, skb);
83−}
84−
85−static __u32 st21nfcb_nci_get_rfprotocol(struct nci_dev *ndev,
86− __u8 rf_protocol)
87−{
88− return rf_protocol == ST21NFCB_NCI1_X_PROPRIETARY_ISO15693 ?
89− NFC_PROTO_ISO15693_MASK : 0;
90−}
91−
92−static int st21nfcb_nci_prop_rsp_packet(struct nci_dev *ndev,
93− struct sk_buff *skb)
94−{
95− __u8 status = skb->data[0];
96−
97− nci_req_complete(ndev, status);
98− return 0;
99−}
100−
101−static struct nci_prop_ops st21nfcb_nci_prop_ops[] = {
102− {
103− .opcode = nci_opcode_pack(NCI_GID_PROPRIETARY,
104− ST21NFCB_NCI_CORE_PROP),
105− .rsp = st21nfcb_nci_prop_rsp_packet,
106− },
107−};
108−
109−static struct nci_ops st21nfcb_nci_ops = {
110− .init = st21nfcb_nci_init,
111− .open = st21nfcb_nci_open,
112− .close = st21nfcb_nci_close,
113− .send = st21nfcb_nci_send,
114− .get_rfprotocol = st21nfcb_nci_get_rfprotocol,
115− .discover_se = st21nfcb_nci_discover_se,
116− .enable_se = st21nfcb_nci_enable_se,
117− .disable_se = st21nfcb_nci_disable_se,
118− .se_io = st21nfcb_nci_se_io,
119− .hci_load_session = st21nfcb_hci_load_session,
120− .hci_event_received = st21nfcb_hci_event_received,
121− .hci_cmd_received = st21nfcb_hci_cmd_received,
122− .prop_ops = st21nfcb_nci_prop_ops,
123− .n_prop_ops = ARRAY_SIZE(st21nfcb_nci_prop_ops),
124−};
125−
126−int st21nfcb_nci_probe(struct llt_ndlc *ndlc, int phy_headroom,
127− int phy_tailroom)
128−{
129− struct st21nfcb_nci_info *info;
130− int r;
131− u32 protocols;
132−
133− info = devm_kzalloc(ndlc->dev,
134− sizeof(struct st21nfcb_nci_info), GFP_KERNEL);
135− if (!info)
136− return -ENOMEM;
137−
138− protocols = NFC_PROTO_JEWEL_MASK
139− | NFC_PROTO_MIFARE_MASK
140− | NFC_PROTO_FELICA_MASK
141− | NFC_PROTO_ISO14443_MASK
142− | NFC_PROTO_ISO14443_B_MASK
143− | NFC_PROTO_ISO15693_MASK
144− | NFC_PROTO_NFC_DEP_MASK;
145−
146− ndlc->ndev = nci_allocate_device(&st21nfcb_nci_ops, protocols,
147− phy_headroom, phy_tailroom);
148− if (!ndlc->ndev) {
149− pr_err("Cannot allocate nfc ndev\n");
150− return -ENOMEM;
151− }
152− info->ndlc = ndlc;
153−
154− nci_set_drvdata(ndlc->ndev, info);
155−
156− r = nci_register_device(ndlc->ndev);
157− if (r) {
158− pr_err("Cannot register nfc device to nci core\n");
159− nci_free_device(ndlc->ndev);
160− return r;
161− }
162−
163− return st21nfcb_se_init(ndlc->ndev);
164−}
165−EXPORT_SYMBOL_GPL(st21nfcb_nci_probe);
166−
167−void st21nfcb_nci_remove(struct nci_dev *ndev)
168−{
169− struct st21nfcb_nci_info *info = nci_get_drvdata(ndev);
170−
171− ndlc_close(info->ndlc);
172−
173− nci_unregister_device(ndev);
174− nci_free_device(ndev);
175−}
176−EXPORT_SYMBOL_GPL(st21nfcb_nci_remove);
177−
178−MODULE_LICENSE("GPL");
179−MODULE_DESCRIPTION(DRIVER_DESC);
drivers/nfc/st21nfcb/st21nfcb_se.h+0−61
@@ -1,61 +0,0 @@
1−/*
2− * NCI based Driver for STMicroelectronics NFC Chip
3− *
4− * Copyright (C) 2014 STMicroelectronics SAS. 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, see <http://www.gnu.org/licenses/>.
17− */
18−#ifndef __LOCAL_ST21NFCB_SE_H_
19−#define __LOCAL_ST21NFCB_SE_H_
20−
21−/*
22− * ref ISO7816-3 chap 8.1. the initial character TS is followed by a
23− * sequence of at most 32 characters.
24− */
25−#define ST21NFCB_ESE_MAX_LENGTH 33
26−#define ST21NFCB_HCI_HOST_ID_ESE 0xc0
27−
28−struct st21nfcb_se_info {
29− u8 atr[ST21NFCB_ESE_MAX_LENGTH];
30− struct completion req_completion;
31−
32− struct timer_list bwi_timer;
33− int wt_timeout; /* in msecs */
34− bool bwi_active;
35−
36− struct timer_list se_active_timer;
37− bool se_active;
38−
39− bool xch_error;
40−
41− se_io_cb_t cb;
42− void *cb_context;
43−};
44−
45−int st21nfcb_se_init(struct nci_dev *ndev);
46−void st21nfcb_se_deinit(struct nci_dev *ndev);
47−
48−int st21nfcb_nci_discover_se(struct nci_dev *ndev);
49−int st21nfcb_nci_enable_se(struct nci_dev *ndev, u32 se_idx);
50−int st21nfcb_nci_disable_se(struct nci_dev *ndev, u32 se_idx);
51−int st21nfcb_nci_se_io(struct nci_dev *ndev, u32 se_idx,
52− u8 *apdu, size_t apdu_length,
53− se_io_cb_t cb, void *cb_context);
54−int st21nfcb_hci_load_session(struct nci_dev *ndev);
55−void st21nfcb_hci_event_received(struct nci_dev *ndev, u8 pipe,
56− u8 event, struct sk_buff *skb);
57−void st21nfcb_hci_cmd_received(struct nci_dev *ndev, u8 pipe, u8 cmd,
58− struct sk_buff *skb);
59−
60−
61−#endif /* __LOCAL_ST21NFCB_NCI_H_ */
include/linux/platform_data/st-nci.hrenamed from include/linux/platform_data/st21nfcb.h+7−7
@@ -1,7 +1,7 @@
11 /*
2− * Driver include for the ST21NFCB NFC chip.
2+ * Driver include for ST NCI NFC chip family.
33 *
4− * Copyright (C) 2014 STMicroelectronics SAS. All rights reserved.
4+ * Copyright (C) 2014-2015 STMicroelectronics SAS. All rights reserved.
55 *
66 * This program is free software; you can redistribute it and/or modify it
77 * under the terms and conditions of the GNU General Public License,
@@ -16,14 +16,14 @@ · 8 unmodified lines
1616 * along with this program; if not, see <http://www.gnu.org/licenses/>.
1717 */
1818
19−#ifndef _ST21NFCB_NCI_H_
20−#define _ST21NFCB_NCI_H_
19+#ifndef _ST_NCI_H_
20+#define _ST_NCI_H_
2121
22−#define ST21NFCB_NCI_DRIVER_NAME "st21nfcb_nci"
22+#define ST_NCI_DRIVER_NAME "st_nci"
2323
24−struct st21nfcb_nfc_platform_data {
24+struct st_nci_nfc_platform_data {
2525 unsigned int gpio_reset;
2626 unsigned int irq_polarity;
2727 };
2828
29−#endif /* _ST21NFCB_NCI_H_ */
29+#endif /* _ST_NCI_H_ */
include/linux/platform_data/st_nci.h+29−0
@@ -0,0 +1,29 @@
1+/*
2+ * Driver include for ST NCI NFC chip family.
3+ *
4+ * Copyright (C) 2014-2015 STMicroelectronics SAS. 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, see <http://www.gnu.org/licenses/>.
17+ */
18+
19+#ifndef _ST_NCI_H_
20+#define _ST_NCI_H_
21+
22+#define ST_NCI_DRIVER_NAME "st_nci"
23+
24+struct st_nci_nfc_platform_data {
25+ unsigned int gpio_reset;
26+ unsigned int irq_polarity;
27+};
28+
29+#endif /* _ST_NCI_H_ */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t