Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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.

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

authored by

Christophe Ricard and committed by
Samuel Ortiz
ed06aeef 2df7f8c6

+585 -553
+2 -2
Documentation/devicetree/bindings/net/nfc/st21nfcb.txt Documentation/devicetree/bindings/net/nfc/st-nci.txt
··· 1 - * STMicroelectronics SAS. ST21NFCB NFC Controller 1 + * STMicroelectronics SAS. ST NCI NFC Controller 2 2 3 3 Required properties: 4 - - compatible: Should be "st,st21nfcb-i2c". 4 + - compatible: Should be "st,st21nfcb-i2c" or "st,st21nfcc-i2c". 5 5 - clock-frequency: I²C work frequency. 6 6 - reg: address on the bus 7 7 - interrupt-parent: phandle for the interrupt gpio controller
+1 -1
drivers/nfc/Kconfig
··· 72 72 source "drivers/nfc/microread/Kconfig" 73 73 source "drivers/nfc/nfcmrvl/Kconfig" 74 74 source "drivers/nfc/st21nfca/Kconfig" 75 - source "drivers/nfc/st21nfcb/Kconfig" 75 + source "drivers/nfc/st-nci/Kconfig" 76 76 source "drivers/nfc/nxp-nci/Kconfig" 77 77 endmenu
+1 -1
drivers/nfc/Makefile
··· 12 12 obj-$(CONFIG_NFC_MRVL) += nfcmrvl/ 13 13 obj-$(CONFIG_NFC_TRF7970A) += trf7970a.o 14 14 obj-$(CONFIG_NFC_ST21NFCA) += st21nfca/ 15 - obj-$(CONFIG_NFC_ST21NFCB) += st21nfcb/ 15 + obj-$(CONFIG_NFC_ST_NCI) += st-nci/ 16 16 obj-$(CONFIG_NFC_NXP_NCI) += nxp-nci/
+23
drivers/nfc/st-nci/Kconfig
··· 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.
+9
drivers/nfc/st-nci/Makefile
··· 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
+179
drivers/nfc/st-nci/core.c
··· 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);
+61
drivers/nfc/st-nci/st-nci_se.h
··· 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_ */
-22
drivers/nfc/st21nfcb/Kconfig
··· 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.
-9
drivers/nfc/st21nfcb/Makefile
··· 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
+62 -61
drivers/nfc/st21nfcb/i2c.c drivers/nfc/st-nci/i2c.c
··· 1 1 /* 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. 4 4 * 5 5 * This program is free software; you can redistribute it and/or modify it 6 6 * under the terms and conditions of the GNU General Public License, ··· 25 25 #include <linux/interrupt.h> 26 26 #include <linux/delay.h> 27 27 #include <linux/nfc.h> 28 - #include <linux/platform_data/st21nfcb.h> 28 + #include <linux/platform_data/st_nci.h> 29 29 30 30 #include "ndlc.h" 31 31 ··· 35 35 #define ST21NFCB_FRAME_HEADROOM 1 36 36 #define ST21NFCB_FRAME_TAILROOM 0 37 37 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 */ 40 40 41 - #define ST21NFCB_NCI_I2C_DRIVER_NAME "st21nfcb_nci_i2c" 41 + #define ST_NCI_I2C_DRIVER_NAME "st_nci_i2c" 42 42 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}, 45 45 {} 46 46 }; 47 - MODULE_DEVICE_TABLE(i2c, st21nfcb_nci_i2c_id_table); 47 + MODULE_DEVICE_TABLE(i2c, st_nci_i2c_id_table); 48 48 49 - struct st21nfcb_i2c_phy { 49 + struct st_nci_i2c_phy { 50 50 struct i2c_client *i2c_dev; 51 51 struct llt_ndlc *ndlc; 52 52 ··· 61 61 16, 1, (skb)->data, (skb)->len, 0); \ 62 62 } while (0) 63 63 64 - static int st21nfcb_nci_i2c_enable(void *phy_id) 64 + static int st_nci_i2c_enable(void *phy_id) 65 65 { 66 - struct st21nfcb_i2c_phy *phy = phy_id; 66 + struct st_nci_i2c_phy *phy = phy_id; 67 67 68 68 gpio_set_value(phy->gpio_reset, 0); 69 69 usleep_range(10000, 15000); ··· 76 76 return 0; 77 77 } 78 78 79 - static void st21nfcb_nci_i2c_disable(void *phy_id) 79 + static void st_nci_i2c_disable(void *phy_id) 80 80 { 81 - struct st21nfcb_i2c_phy *phy = phy_id; 81 + struct st_nci_i2c_phy *phy = phy_id; 82 82 83 83 disable_irq_nosync(phy->i2c_dev->irq); 84 84 } ··· 88 88 * It must return either zero for success, or <0 for error. 89 89 * In addition, it must not alter the skb 90 90 */ 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) 92 92 { 93 93 int r = -1; 94 - struct st21nfcb_i2c_phy *phy = phy_id; 94 + struct st_nci_i2c_phy *phy = phy_id; 95 95 struct i2c_client *client = phy->i2c_dev; 96 96 97 - I2C_DUMP_SKB("st21nfcb_nci_i2c_write", skb); 97 + I2C_DUMP_SKB("st_nci_i2c_write", skb); 98 98 99 99 if (phy->ndlc->hard_fault != 0) 100 100 return phy->ndlc->hard_fault; ··· 124 124 * at end of read) 125 125 * -EREMOTEIO : i2c read error (fatal) 126 126 * -EBADMSG : frame was incorrect and discarded 127 - * (value returned from st21nfcb_nci_i2c_repack) 127 + * (value returned from st_nci_i2c_repack) 128 128 * -EIO : if no ST21NFCB_SOF_EOF is found after reaching 129 129 * the read length end sequence 130 130 */ 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, 132 132 struct sk_buff **skb) 133 133 { 134 134 int r; 135 135 u8 len; 136 - u8 buf[ST21NFCB_NCI_I2C_MAX_SIZE]; 136 + u8 buf[ST_NCI_I2C_MAX_SIZE]; 137 137 struct i2c_client *client = phy->i2c_dev; 138 138 139 - r = i2c_master_recv(client, buf, ST21NFCB_NCI_I2C_MIN_SIZE); 139 + r = i2c_master_recv(client, buf, ST_NCI_I2C_MIN_SIZE); 140 140 if (r < 0) { /* Retry, chip was in standby */ 141 141 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); 143 143 } 144 144 145 - if (r != ST21NFCB_NCI_I2C_MIN_SIZE) 145 + if (r != ST_NCI_I2C_MIN_SIZE) 146 146 return -EREMOTEIO; 147 147 148 148 len = be16_to_cpu(*(__be16 *) (buf + 2)); 149 - if (len > ST21NFCB_NCI_I2C_MAX_SIZE) { 149 + if (len > ST_NCI_I2C_MAX_SIZE) { 150 150 nfc_err(&client->dev, "invalid frame len\n"); 151 151 return -EBADMSG; 152 152 } 153 153 154 - *skb = alloc_skb(ST21NFCB_NCI_I2C_MIN_SIZE + len, GFP_KERNEL); 154 + *skb = alloc_skb(ST_NCI_I2C_MIN_SIZE + len, GFP_KERNEL); 155 155 if (*skb == NULL) 156 156 return -ENOMEM; 157 157 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); 161 161 162 162 if (!len) 163 163 return 0; ··· 169 169 } 170 170 171 171 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); 173 173 174 174 I2C_DUMP_SKB("i2c frame read", *skb); 175 175 ··· 181 181 * 182 182 * On ST21NFCB, IRQ goes in idle state when read starts. 183 183 */ 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) 185 185 { 186 - struct st21nfcb_i2c_phy *phy = phy_id; 186 + struct st_nci_i2c_phy *phy = phy_id; 187 187 struct i2c_client *client; 188 188 struct sk_buff *skb = NULL; 189 189 int r; ··· 200 200 return IRQ_HANDLED; 201 201 202 202 if (!phy->ndlc->powered) { 203 - st21nfcb_nci_i2c_disable(phy); 203 + st_nci_i2c_disable(phy); 204 204 return IRQ_HANDLED; 205 205 } 206 206 207 - r = st21nfcb_nci_i2c_read(phy, &skb); 207 + r = st_nci_i2c_read(phy, &skb); 208 208 if (r == -EREMOTEIO || r == -ENOMEM || r == -EBADMSG) 209 209 return IRQ_HANDLED; 210 210 ··· 214 214 } 215 215 216 216 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, 220 220 }; 221 221 222 222 #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) 224 224 { 225 - struct st21nfcb_i2c_phy *phy = i2c_get_clientdata(client); 225 + struct st_nci_i2c_phy *phy = i2c_get_clientdata(client); 226 226 struct device_node *pp; 227 227 int gpio; 228 228 int r; ··· 253 253 return 0; 254 254 } 255 255 #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) 257 257 { 258 258 return -ENODEV; 259 259 } 260 260 #endif 261 261 262 - static int st21nfcb_nci_i2c_request_resources(struct i2c_client *client) 262 + static int st_nci_i2c_request_resources(struct i2c_client *client) 263 263 { 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); 266 266 int r; 267 267 268 268 pdata = client->dev.platform_data; ··· 285 285 return 0; 286 286 } 287 287 288 - static int st21nfcb_nci_i2c_probe(struct i2c_client *client, 288 + static int st_nci_i2c_probe(struct i2c_client *client, 289 289 const struct i2c_device_id *id) 290 290 { 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; 293 293 int r; 294 294 295 295 dev_dbg(&client->dev, "%s\n", __func__); ··· 300 300 return -ENODEV; 301 301 } 302 302 303 - phy = devm_kzalloc(&client->dev, sizeof(struct st21nfcb_i2c_phy), 303 + phy = devm_kzalloc(&client->dev, sizeof(struct st_nci_i2c_phy), 304 304 GFP_KERNEL); 305 305 if (!phy) 306 306 return -ENOMEM; ··· 311 311 312 312 pdata = client->dev.platform_data; 313 313 if (!pdata && client->dev.of_node) { 314 - r = st21nfcb_nci_i2c_of_request_resources(client); 314 + r = st_nci_i2c_of_request_resources(client); 315 315 if (r) { 316 316 nfc_err(&client->dev, "No platform data\n"); 317 317 return r; 318 318 } 319 319 } else if (pdata) { 320 - r = st21nfcb_nci_i2c_request_resources(client); 320 + r = st_nci_i2c_request_resources(client); 321 321 if (r) { 322 322 nfc_err(&client->dev, 323 323 "Cannot get platform resources\n"); ··· 338 338 } 339 339 340 340 r = devm_request_threaded_irq(&client->dev, client->irq, NULL, 341 - st21nfcb_nci_irq_thread_fn, 341 + st_nci_irq_thread_fn, 342 342 phy->irq_polarity | IRQF_ONESHOT, 343 - ST21NFCB_NCI_DRIVER_NAME, phy); 343 + ST_NCI_DRIVER_NAME, phy); 344 344 if (r < 0) 345 345 nfc_err(&client->dev, "Unable to register IRQ handler\n"); 346 346 347 347 return r; 348 348 } 349 349 350 - static int st21nfcb_nci_i2c_remove(struct i2c_client *client) 350 + static int st_nci_i2c_remove(struct i2c_client *client) 351 351 { 352 - struct st21nfcb_i2c_phy *phy = i2c_get_clientdata(client); 352 + struct st_nci_i2c_phy *phy = i2c_get_clientdata(client); 353 353 354 354 dev_dbg(&client->dev, "%s\n", __func__); 355 355 ··· 359 359 } 360 360 361 361 #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[] = { 363 363 { .compatible = "st,st21nfcb-i2c", }, 364 364 { .compatible = "st,st21nfcb_i2c", }, 365 + { .compatible = "st,st21nfcc-i2c", }, 365 366 {} 366 367 }; 367 - MODULE_DEVICE_TABLE(of, of_st21nfcb_i2c_match); 368 + MODULE_DEVICE_TABLE(of, of_st_nci_i2c_match); 368 369 #endif 369 370 370 - static struct i2c_driver st21nfcb_nci_i2c_driver = { 371 + static struct i2c_driver st_nci_i2c_driver = { 371 372 .driver = { 372 373 .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), 375 376 }, 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, 379 380 }; 380 381 381 - module_i2c_driver(st21nfcb_nci_i2c_driver); 382 + module_i2c_driver(st_nci_i2c_driver); 382 383 383 384 MODULE_LICENSE("GPL"); 384 385 MODULE_DESCRIPTION(DRIVER_DESC);
+6 -6
drivers/nfc/st21nfcb/ndlc.c drivers/nfc/st-nci/ndlc.c
··· 1 1 /* 2 2 * Low Level Transport (NDLC) Driver for STMicroelectronics NFC Chip 3 3 * 4 - * Copyright (C) 2014 STMicroelectronics SAS. All rights reserved. 4 + * Copyright (C) 2014-2015 STMicroelectronics SAS. All rights reserved. 5 5 * 6 6 * This program is free software; you can redistribute it and/or modify it 7 7 * under the terms and conditions of the GNU General Public License, ··· 20 20 #include <net/nfc/nci_core.h> 21 21 22 22 #include "ndlc.h" 23 - #include "st21nfcb.h" 23 + #include "st-nci.h" 24 24 25 25 #define NDLC_TIMER_T1 100 26 26 #define NDLC_TIMER_T1_WAIT 400 ··· 68 68 { 69 69 struct nci_mode_set_cmd cmd; 70 70 71 - cmd.cmd_type = ST21NFCB_NCI_SET_NFC_MODE; 71 + cmd.cmd_type = ST_NCI_SET_NFC_MODE; 72 72 cmd.mode = 0; 73 73 74 74 /* toggle reset pin */ 75 75 ndlc->ops->enable(ndlc->phy_id); 76 76 77 - nci_prop_cmd(ndlc->ndev, ST21NFCB_NCI_CORE_PROP, 77 + nci_prop_cmd(ndlc->ndev, ST_NCI_CORE_PROP, 78 78 sizeof(struct nci_mode_set_cmd), (__u8 *)&cmd); 79 79 80 80 ndlc->powered = 0; ··· 293 293 294 294 INIT_WORK(&ndlc->sm_work, llt_ndlc_sm_work); 295 295 296 - return st21nfcb_nci_probe(ndlc, phy_headroom, phy_tailroom); 296 + return st_nci_probe(ndlc, phy_headroom, phy_tailroom); 297 297 } 298 298 EXPORT_SYMBOL(ndlc_probe); 299 299 300 300 void ndlc_remove(struct llt_ndlc *ndlc) 301 301 { 302 - st21nfcb_nci_remove(ndlc->ndev); 302 + st_nci_remove(ndlc->ndev); 303 303 304 304 /* cancel timers */ 305 305 del_timer_sync(&ndlc->t1_timer);
+2 -2
drivers/nfc/st21nfcb/ndlc.h drivers/nfc/st-nci/ndlc.h
··· 1 1 /* 2 2 * NCI based Driver for STMicroelectronics NFC Chip 3 3 * 4 - * Copyright (C) 2014 STMicroelectronics SAS. All rights reserved. 4 + * Copyright (C) 2014-2015 STMicroelectronics SAS. All rights reserved. 5 5 * 6 6 * This program is free software; you can redistribute it and/or modify it 7 7 * under the terms and conditions of the GNU General Public License, ··· 43 43 struct device *dev; 44 44 45 45 /* 46 - * < 0 if hardware error occured 46 + * < 0 if hardware error occurred 47 47 * and prevents normal operation. 48 48 */ 49 49 int hard_fault;
-179
drivers/nfc/st21nfcb/st21nfcb.c
··· 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);
+11 -11
drivers/nfc/st21nfcb/st21nfcb.h drivers/nfc/st-nci/st-nci.h
··· 16 16 * along with this program; if not, see <http://www.gnu.org/licenses/>. 17 17 */ 18 18 19 - #ifndef __LOCAL_ST21NFCB_H_ 20 - #define __LOCAL_ST21NFCB_H_ 19 + #ifndef __LOCAL_ST_NCI_H_ 20 + #define __LOCAL_ST_NCI_H_ 21 21 22 - #include "st21nfcb_se.h" 22 + #include "st-nci_se.h" 23 23 #include "ndlc.h" 24 24 25 25 /* Define private flags: */ 26 - #define ST21NFCB_NCI_RUNNING 1 26 + #define ST_NCI_RUNNING 1 27 27 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 30 30 31 31 struct nci_mode_set_cmd { 32 32 u8 cmd_type; ··· 37 37 u8 status; 38 38 } __packed; 39 39 40 - struct st21nfcb_nci_info { 40 + struct st_nci_info { 41 41 struct llt_ndlc *ndlc; 42 42 unsigned long flags; 43 - struct st21nfcb_se_info se_info; 43 + struct st_nci_se_info se_info; 44 44 }; 45 45 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, 48 48 int phy_tailroom); 49 49 50 - #endif /* __LOCAL_ST21NFCB_H_ */ 50 + #endif /* __LOCAL_ST_NCI_H_ */
+192 -191
drivers/nfc/st21nfcb/st21nfcb_se.c drivers/nfc/st-nci/st-nci_se.c
··· 1 1 /* 2 - * NCI based Driver for STMicroelectronics NFC Chip 2 + * Secure Element driver for STMicroelectronics NFC NCI chip 3 3 * 4 - * Copyright (C) 2014 STMicroelectronics SAS. All rights reserved. 4 + * Copyright (C) 2014-2015 STMicroelectronics SAS. All rights reserved. 5 5 * 6 6 * This program is free software; you can redistribute it and/or modify it 7 7 * under the terms and conditions of the GNU General Public License, ··· 22 22 #include <net/nfc/nci.h> 23 23 #include <net/nfc/nci_core.h> 24 24 25 - #include "st21nfcb.h" 26 - #include "st21nfcb_se.h" 25 + #include "st-nci.h" 26 + #include "st-nci_se.h" 27 27 28 - struct st21nfcb_pipe_info { 28 + struct st_nci_pipe_info { 29 29 u8 pipe_state; 30 30 u8 src_host_id; 31 31 u8 src_gate_id; ··· 34 34 } __packed; 35 35 36 36 /* 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 41 41 42 42 /* 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 46 46 47 47 /* Pipes */ 48 - #define ST21NFCB_DEVICE_MGNT_PIPE 0x02 48 + #define ST_NCI_DEVICE_MGNT_PIPE 0x02 49 49 50 50 /* Connectivity pipe only */ 51 - #define ST21NFCB_SE_COUNT_PIPE_UICC 0x01 51 + #define ST_NCI_SE_COUNT_PIPE_UICC 0x01 52 52 /* Connectivity + APDU Reader pipe */ 53 - #define ST21NFCB_SE_COUNT_PIPE_EMBEDDED 0x02 53 + #define ST_NCI_SE_COUNT_PIPE_EMBEDDED 0x02 54 54 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 57 57 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) 59 59 60 60 #define NCI_HCI_APDU_PARAM_ATR 0x01 61 61 #define NCI_HCI_ADMIN_PARAM_SESSION_IDENTITY 0x01 62 62 #define NCI_HCI_ADMIN_PARAM_WHITELIST 0x03 63 63 #define NCI_HCI_ADMIN_PARAM_HOST_LIST 0x04 64 64 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 71 71 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 74 74 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 77 77 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 85 85 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)) 88 88 89 - #define ST21NFCB_ATR_DEFAULT_BWI 0x04 89 + #define ST_NCI_ATR_DEFAULT_BWI 0x04 90 90 91 91 /* 92 92 * WT = 2^BWI/10[s], convert into msecs and add a secure 93 93 * room by increasing by 2 this timeout 94 94 */ 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) 97 97 98 98 /* 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) 100 100 /* 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) 102 102 103 - #define ST21NFCB_NUM_DEVICES 256 103 + #define ST_NCI_NUM_DEVICES 256 104 104 105 - static DECLARE_BITMAP(dev_mask, ST21NFCB_NUM_DEVICES); 105 + static DECLARE_BITMAP(dev_mask, ST_NCI_NUM_DEVICES); 106 106 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[] = { 109 109 {NCI_HCI_ADMIN_GATE, NCI_HCI_ADMIN_PIPE, 110 - ST21NFCB_HOST_CONTROLLER_ID}, 110 + ST_NCI_HOST_CONTROLLER_ID}, 111 111 {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}, 115 115 116 116 /* 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}, 121 121 }; 122 122 123 - static u8 st21nfcb_se_get_bwi(struct nci_dev *ndev) 123 + static u8 st_nci_se_get_bwi(struct nci_dev *ndev) 124 124 { 125 125 int i; 126 126 u8 td; 127 - struct st21nfcb_nci_info *info = nci_get_drvdata(ndev); 127 + struct st_nci_info *info = nci_get_drvdata(ndev); 128 128 129 129 /* 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)) 133 133 i++; 134 - if (ST21NFCB_ATR_TB_PRESENT(td)) { 134 + if (ST_NCI_ATR_TB_PRESENT(td)) { 135 135 i++; 136 136 return info->se_info.atr[i] >> 4; 137 137 } 138 138 } 139 - return ST21NFCB_ATR_DEFAULT_BWI; 139 + return ST_NCI_ATR_DEFAULT_BWI; 140 140 } 141 141 142 - static void st21nfcb_se_get_atr(struct nci_dev *ndev) 142 + static void st_nci_se_get_atr(struct nci_dev *ndev) 143 143 { 144 - struct st21nfcb_nci_info *info = nci_get_drvdata(ndev); 144 + struct st_nci_info *info = nci_get_drvdata(ndev); 145 145 int r; 146 146 struct sk_buff *skb; 147 147 148 - r = nci_hci_get_param(ndev, ST21NFCB_APDU_READER_GATE, 148 + r = nci_hci_get_param(ndev, ST_NCI_APDU_READER_GATE, 149 149 NCI_HCI_APDU_PARAM_ATR, &skb); 150 150 if (r < 0) 151 151 return; 152 152 153 - if (skb->len <= ST21NFCB_ESE_MAX_LENGTH) { 153 + if (skb->len <= ST_NCI_ESE_MAX_LENGTH) { 154 154 memcpy(info->se_info.atr, skb->data, skb->len); 155 155 156 156 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)); 158 158 } 159 159 kfree_skb(skb); 160 160 } 161 161 162 - int st21nfcb_hci_load_session(struct nci_dev *ndev) 162 + int st_nci_hci_load_session(struct nci_dev *ndev) 163 163 { 164 164 int i, j, r; 165 165 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}; 171 171 172 - /* On ST21NFCB device pipes number are dynamics 172 + /* On ST_NCI device pipes number are dynamics 173 173 * If pipes are already created, hci_dev_up will fail. 174 174 * Doing a clear all pipe is a bad idea because: 175 175 * - It does useless EEPROM cycling 176 176 * - It might cause issue for secure elements support 177 177 * (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: 179 179 * - get a pipe list for each host. 180 - * (eg: ST21NFCB_HOST_CONTROLLER_ID for now). 180 + * (eg: ST_NCI_HOST_CONTROLLER_ID for now). 181 181 * (TODO Later on UICC HOST and eSE HOST) 182 182 * - 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. 186 186 * Pipe can be closed and need to be open. 187 187 */ 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); 191 191 if (r < 0) 192 192 goto free_info; 193 193 194 194 /* 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), 197 197 &skb_pipe_list); 198 198 if (r < 0) 199 199 goto free_info; ··· 201 201 /* Complete the existing gate_pipe table */ 202 202 for (i = 0; i < skb_pipe_list->len; i++) { 203 203 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, 206 206 sizeof(pipe_info), &skb_pipe_info); 207 207 208 208 if (r) ··· 217 217 * - destination hid (1byte) 218 218 * - destination gid (1byte) 219 219 */ 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) { 223 223 pr_err("Unexpected apdu_reader pipe on host %x\n", 224 224 dm_pipe_info->src_host_id); 225 225 continue; 226 226 } 227 227 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++) 230 230 ; 231 231 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]; 236 236 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 = 242 242 dm_pipe_info->src_host_id; 243 243 } 244 244 } 245 245 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)); 248 248 249 249 free_info: 250 250 kfree_skb(skb_pipe_info); 251 251 kfree_skb(skb_pipe_list); 252 252 return r; 253 253 } 254 - EXPORT_SYMBOL_GPL(st21nfcb_hci_load_session); 254 + EXPORT_SYMBOL_GPL(st_nci_hci_load_session); 255 255 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, 257 257 u8 event, struct sk_buff *skb) 258 258 { 259 - struct st21nfcb_nci_info *info = nci_get_drvdata(ndev); 259 + struct st_nci_info *info = nci_get_drvdata(ndev); 260 260 261 261 switch (event) { 262 - case ST21NFCB_EVT_HOT_PLUG: 262 + case ST_NCI_EVT_HOT_PLUG: 263 263 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)) { 265 265 del_timer_sync(&info->se_info.se_active_timer); 266 266 info->se_info.se_active = false; 267 267 complete(&info->se_info.req_completion); 268 268 } else { 269 269 mod_timer(&info->se_info.se_active_timer, 270 270 jiffies + 271 - msecs_to_jiffies(ST21NFCB_SE_TO_PIPES)); 271 + msecs_to_jiffies(ST_NCI_SE_TO_PIPES)); 272 272 } 273 273 } 274 274 break; 275 275 } 276 276 } 277 277 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, 279 279 u8 event, 280 280 struct sk_buff *skb) 281 281 { 282 282 int r = 0; 283 - struct st21nfcb_nci_info *info = nci_get_drvdata(ndev); 283 + struct st_nci_info *info = nci_get_drvdata(ndev); 284 284 285 285 pr_debug("apdu reader gate event: %x\n", event); 286 286 287 287 switch (event) { 288 - case ST21NFCB_EVT_TRANSMIT_DATA: 288 + case ST_NCI_EVT_TRANSMIT_DATA: 289 289 del_timer_sync(&info->se_info.bwi_timer); 290 290 info->se_info.bwi_active = false; 291 291 info->se_info.cb(info->se_info.cb_context, 292 292 skb->data, skb->len, 0); 293 293 break; 294 - case ST21NFCB_EVT_WTX_REQUEST: 294 + case ST_NCI_EVT_WTX_REQUEST: 295 295 mod_timer(&info->se_info.bwi_timer, jiffies + 296 296 msecs_to_jiffies(info->se_info.wt_timeout)); 297 297 break; ··· 306 306 * <= 0: driver handled the event, skb consumed 307 307 * 1: driver does not handle the event, please do standard processing 308 308 */ 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, 310 310 u8 host, u8 event, 311 311 struct sk_buff *skb) 312 312 { ··· 317 317 pr_debug("connectivity gate event: %x\n", event); 318 318 319 319 switch (event) { 320 - case ST21NFCB_EVT_CONNECTIVITY: 320 + case ST_NCI_EVT_CONNECTIVITY: 321 321 322 322 break; 323 - case ST21NFCB_EVT_TRANSACTION: 323 + case ST_NCI_EVT_TRANSACTION: 324 324 /* According to specification etsi 102 622 325 325 * 11.2.2.4 EVT_TRANSACTION Table 52 326 326 * Description Tag Length ··· 355 355 return r; 356 356 } 357 357 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, 359 359 u8 event, struct sk_buff *skb) 360 360 { 361 361 u8 gate = ndev->hci_dev->pipes[pipe].gate; ··· 363 363 364 364 switch (gate) { 365 365 case NCI_HCI_ADMIN_GATE: 366 - st21nfcb_hci_admin_event_received(ndev, event, skb); 366 + st_nci_hci_admin_event_received(ndev, event, skb); 367 367 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); 370 370 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, 373 373 skb); 374 374 break; 375 375 } 376 376 } 377 - EXPORT_SYMBOL_GPL(st21nfcb_hci_event_received); 377 + EXPORT_SYMBOL_GPL(st_nci_hci_event_received); 378 378 379 379 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, 381 381 struct sk_buff *skb) 382 382 { 383 - struct st21nfcb_nci_info *info = nci_get_drvdata(ndev); 383 + struct st_nci_info *info = nci_get_drvdata(ndev); 384 384 u8 gate = ndev->hci_dev->pipes[pipe].gate; 385 385 386 386 pr_debug("cmd: %x\n", cmd); 387 387 388 388 switch (cmd) { 389 389 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) 392 392 ndev->hci_dev->count_pipes++; 393 393 394 394 if (ndev->hci_dev->count_pipes == ··· 401 401 break; 402 402 } 403 403 } 404 - EXPORT_SYMBOL_GPL(st21nfcb_hci_cmd_received); 404 + EXPORT_SYMBOL_GPL(st_nci_hci_cmd_received); 405 405 406 406 /* 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) 408 408 * is rejected 409 409 */ 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, 411 411 u8 state) 412 412 { 413 - struct st21nfcb_nci_info *info = nci_get_drvdata(ndev); 413 + struct st_nci_info *info = nci_get_drvdata(ndev); 414 414 int r; 415 415 struct sk_buff *sk_host_list; 416 416 u8 host_id; 417 417 418 418 switch (se_idx) { 419 - case ST21NFCB_UICC_HOST_ID: 419 + case ST_NCI_UICC_HOST_ID: 420 420 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; 422 422 break; 423 - case ST21NFCB_ESE_HOST_ID: 423 + case ST_NCI_ESE_HOST_ID: 424 424 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; 426 426 break; 427 427 default: 428 428 return -EINVAL; ··· 438 438 return r; 439 439 440 440 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)); 442 442 info->se_info.se_active = true; 443 443 444 444 /* Ignore return value and check in any case the host_list */ ··· 458 458 459 459 host_id = sk_host_list->data[sk_host_list->len - 1]; 460 460 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) 462 462 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) 464 464 return se_idx; 465 465 466 466 return -1; 467 467 } 468 468 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) 470 470 { 471 471 int r; 472 472 473 - pr_debug("st21nfcb_nci_disable_se\n"); 473 + pr_debug("st_nci_disable_se\n"); 474 474 475 475 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); 478 478 if (r < 0) 479 479 return r; 480 480 } 481 481 482 482 return 0; 483 483 } 484 - EXPORT_SYMBOL_GPL(st21nfcb_nci_disable_se); 484 + EXPORT_SYMBOL_GPL(st_nci_disable_se); 485 485 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) 487 487 { 488 488 int r; 489 489 490 - pr_debug("st21nfcb_nci_enable_se\n"); 490 + pr_debug("st_nci_enable_se\n"); 491 491 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); 495 495 if (r < 0) 496 496 return r; 497 497 } 498 498 499 499 return 0; 500 500 } 501 - EXPORT_SYMBOL_GPL(st21nfcb_nci_enable_se); 501 + EXPORT_SYMBOL_GPL(st_nci_enable_se); 502 502 503 - static int st21nfcb_hci_network_init(struct nci_dev *ndev) 503 + static int st_nci_hci_network_init(struct nci_dev *ndev) 504 504 { 505 505 struct core_conn_create_dest_spec_params *dest_params; 506 506 struct dest_spec_params spec_params; ··· 519 519 dest_params->length = sizeof(struct dest_spec_params); 520 520 spec_params.id = ndev->hci_dev->nfcee_id; 521 521 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)); 523 524 r = nci_core_conn_create(ndev, NCI_DESTINATION_NFCEE, 1, 524 525 sizeof(struct core_conn_create_dest_spec_params) + 525 526 sizeof(struct dest_spec_params), ··· 532 531 if (!conn_info) 533 532 goto free_dest_params; 534 533 535 - memcpy(ndev->hci_dev->init_data.gates, st21nfcb_gates, 536 - sizeof(st21nfcb_gates)); 534 + memcpy(ndev->hci_dev->init_data.gates, st_nci_gates, 535 + sizeof(st_nci_gates)); 537 536 538 537 /* 539 538 * Session id must include the driver name + i2c bus addr 540 539 * persistent info to discriminate 2 identical chips 541 540 */ 542 - dev_num = find_first_zero_bit(dev_mask, ST21NFCB_NUM_DEVICES); 543 - if (dev_num >= ST21NFCB_NUM_DEVICES) { 541 + dev_num = find_first_zero_bit(dev_mask, ST_NCI_NUM_DEVICES); 542 + if (dev_num >= ST_NCI_NUM_DEVICES) { 544 543 r = -ENODEV; 545 544 goto free_dest_params; 546 545 } ··· 565 564 return r; 566 565 } 567 566 568 - int st21nfcb_nci_discover_se(struct nci_dev *ndev) 567 + int st_nci_discover_se(struct nci_dev *ndev) 569 568 { 570 569 u8 param[2]; 571 570 int r; 572 571 int se_count = 0; 573 572 574 - pr_debug("st21nfcb_nci_discover_se\n"); 573 + pr_debug("st_nci_discover_se\n"); 575 574 576 - r = st21nfcb_hci_network_init(ndev); 575 + r = st_nci_hci_network_init(ndev); 577 576 if (r != 0) 578 577 return r; 579 578 580 - param[0] = ST21NFCB_UICC_HOST_ID; 581 - param[1] = ST21NFCB_HCI_HOST_ID_ESE; 579 + param[0] = ST_NCI_UICC_HOST_ID; 580 + param[1] = ST_NCI_HCI_HOST_ID_ESE; 582 581 r = nci_hci_set_param(ndev, NCI_HCI_ADMIN_GATE, 583 582 NCI_HCI_ADMIN_PARAM_WHITELIST, 584 583 param, sizeof(param)); 585 584 if (r != NCI_HCI_ANY_OK) 586 585 return r; 587 586 588 - r = st21nfcb_nci_control_se(ndev, ST21NFCB_UICC_HOST_ID, 589 - ST21NFCB_SE_MODE_ON); 590 - if (r == ST21NFCB_UICC_HOST_ID) { 591 - nfc_add_se(ndev->nfc_dev, ST21NFCB_UICC_HOST_ID, NFC_SE_UICC); 587 + r = st_nci_control_se(ndev, ST_NCI_UICC_HOST_ID, 588 + ST_NCI_SE_MODE_ON); 589 + if (r == ST_NCI_UICC_HOST_ID) { 590 + nfc_add_se(ndev->nfc_dev, ST_NCI_UICC_HOST_ID, NFC_SE_UICC); 592 591 se_count++; 593 592 } 594 593 595 594 /* Try to enable eSE in order to check availability */ 596 - r = st21nfcb_nci_control_se(ndev, ST21NFCB_HCI_HOST_ID_ESE, 597 - ST21NFCB_SE_MODE_ON); 598 - if (r == ST21NFCB_HCI_HOST_ID_ESE) { 599 - nfc_add_se(ndev->nfc_dev, ST21NFCB_HCI_HOST_ID_ESE, 595 + r = st_nci_control_se(ndev, ST_NCI_HCI_HOST_ID_ESE, 596 + ST_NCI_SE_MODE_ON); 597 + if (r == ST_NCI_HCI_HOST_ID_ESE) { 598 + nfc_add_se(ndev->nfc_dev, ST_NCI_HCI_HOST_ID_ESE, 600 599 NFC_SE_EMBEDDED); 601 600 se_count++; 602 - st21nfcb_se_get_atr(ndev); 601 + st_nci_se_get_atr(ndev); 603 602 } 604 603 605 604 return !se_count; 606 605 } 607 - EXPORT_SYMBOL_GPL(st21nfcb_nci_discover_se); 606 + EXPORT_SYMBOL_GPL(st_nci_discover_se); 608 607 609 - int st21nfcb_nci_se_io(struct nci_dev *ndev, u32 se_idx, 608 + int st_nci_se_io(struct nci_dev *ndev, u32 se_idx, 610 609 u8 *apdu, size_t apdu_length, 611 610 se_io_cb_t cb, void *cb_context) 612 611 { 613 - struct st21nfcb_nci_info *info = nci_get_drvdata(ndev); 612 + struct st_nci_info *info = nci_get_drvdata(ndev); 614 613 615 614 pr_debug("\n"); 616 615 617 616 switch (se_idx) { 618 - case ST21NFCB_HCI_HOST_ID_ESE: 617 + case ST_NCI_HCI_HOST_ID_ESE: 619 618 info->se_info.cb = cb; 620 619 info->se_info.cb_context = cb_context; 621 620 mod_timer(&info->se_info.bwi_timer, jiffies + 622 621 msecs_to_jiffies(info->se_info.wt_timeout)); 623 622 info->se_info.bwi_active = true; 624 - return nci_hci_send_event(ndev, ST21NFCB_APDU_READER_GATE, 625 - ST21NFCB_EVT_TRANSMIT_DATA, apdu, 623 + return nci_hci_send_event(ndev, ST_NCI_APDU_READER_GATE, 624 + ST_NCI_EVT_TRANSMIT_DATA, apdu, 626 625 apdu_length); 627 626 default: 628 627 return -ENODEV; 629 628 } 630 629 } 631 - EXPORT_SYMBOL(st21nfcb_nci_se_io); 630 + EXPORT_SYMBOL(st_nci_se_io); 632 631 633 - static void st21nfcb_se_wt_timeout(unsigned long data) 632 + static void st_nci_se_wt_timeout(unsigned long data) 634 633 { 635 634 /* 636 635 * No answer from the secure element ··· 643 642 */ 644 643 /* hardware reset managed through VCC_UICC_OUT power supply */ 645 644 u8 param = 0x01; 646 - struct st21nfcb_nci_info *info = (struct st21nfcb_nci_info *) data; 645 + struct st_nci_info *info = (struct st_nci_info *) data; 647 646 648 647 pr_debug("\n"); 649 648 ··· 651 650 652 651 if (!info->se_info.xch_error) { 653 652 info->se_info.xch_error = true; 654 - nci_hci_send_event(info->ndlc->ndev, ST21NFCB_APDU_READER_GATE, 655 - ST21NFCB_EVT_SE_SOFT_RESET, NULL, 0); 653 + nci_hci_send_event(info->ndlc->ndev, ST_NCI_APDU_READER_GATE, 654 + ST_NCI_EVT_SE_SOFT_RESET, NULL, 0); 656 655 } else { 657 656 info->se_info.xch_error = false; 658 - nci_hci_send_event(info->ndlc->ndev, ST21NFCB_DEVICE_MGNT_GATE, 659 - ST21NFCB_EVT_SE_HARD_RESET, &param, 1); 657 + nci_hci_send_event(info->ndlc->ndev, ST_NCI_DEVICE_MGNT_GATE, 658 + ST_NCI_EVT_SE_HARD_RESET, &param, 1); 660 659 } 661 660 info->se_info.cb(info->se_info.cb_context, NULL, 0, -ETIME); 662 661 } 663 662 664 - static void st21nfcb_se_activation_timeout(unsigned long data) 663 + static void st_nci_se_activation_timeout(unsigned long data) 665 664 { 666 - struct st21nfcb_nci_info *info = (struct st21nfcb_nci_info *) data; 665 + struct st_nci_info *info = (struct st_nci_info *) data; 667 666 668 667 pr_debug("\n"); 669 668 ··· 672 671 complete(&info->se_info.req_completion); 673 672 } 674 673 675 - int st21nfcb_se_init(struct nci_dev *ndev) 674 + int st_nci_se_init(struct nci_dev *ndev) 676 675 { 677 - struct st21nfcb_nci_info *info = nci_get_drvdata(ndev); 676 + struct st_nci_info *info = nci_get_drvdata(ndev); 678 677 679 678 init_completion(&info->se_info.req_completion); 680 679 /* initialize timers */ 681 680 init_timer(&info->se_info.bwi_timer); 682 681 info->se_info.bwi_timer.data = (unsigned long)info; 683 - info->se_info.bwi_timer.function = st21nfcb_se_wt_timeout; 682 + info->se_info.bwi_timer.function = st_nci_se_wt_timeout; 684 683 info->se_info.bwi_active = false; 685 684 686 685 init_timer(&info->se_info.se_active_timer); 687 686 info->se_info.se_active_timer.data = (unsigned long)info; 688 687 info->se_info.se_active_timer.function = 689 - st21nfcb_se_activation_timeout; 688 + st_nci_se_activation_timeout; 690 689 info->se_info.se_active = false; 691 690 692 691 info->se_info.xch_error = false; 693 692 694 693 info->se_info.wt_timeout = 695 - ST21NFCB_BWI_TO_TIMEOUT(ST21NFCB_ATR_DEFAULT_BWI); 694 + ST_NCI_BWI_TO_TIMEOUT(ST_NCI_ATR_DEFAULT_BWI); 696 695 697 696 return 0; 698 697 } 699 - EXPORT_SYMBOL(st21nfcb_se_init); 698 + EXPORT_SYMBOL(st_nci_se_init); 700 699 701 - void st21nfcb_se_deinit(struct nci_dev *ndev) 700 + void st_nci_se_deinit(struct nci_dev *ndev) 702 701 { 703 - struct st21nfcb_nci_info *info = nci_get_drvdata(ndev); 702 + struct st_nci_info *info = nci_get_drvdata(ndev); 704 703 705 704 if (info->se_info.bwi_active) 706 705 del_timer_sync(&info->se_info.bwi_timer); ··· 710 709 info->se_info.se_active = false; 711 710 info->se_info.bwi_active = false; 712 711 } 713 - EXPORT_SYMBOL(st21nfcb_se_deinit); 712 + EXPORT_SYMBOL(st_nci_se_deinit); 714 713
-61
drivers/nfc/st21nfcb/st21nfcb_se.h
··· 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_ */
+7 -7
include/linux/platform_data/st21nfcb.h include/linux/platform_data/st-nci.h
··· 1 1 /* 2 - * Driver include for the ST21NFCB NFC chip. 2 + * Driver include for ST NCI NFC chip family. 3 3 * 4 - * Copyright (C) 2014 STMicroelectronics SAS. All rights reserved. 4 + * Copyright (C) 2014-2015 STMicroelectronics SAS. All rights reserved. 5 5 * 6 6 * This program is free software; you can redistribute it and/or modify it 7 7 * under the terms and conditions of the GNU General Public License, ··· 16 16 * along with this program; if not, see <http://www.gnu.org/licenses/>. 17 17 */ 18 18 19 - #ifndef _ST21NFCB_NCI_H_ 20 - #define _ST21NFCB_NCI_H_ 19 + #ifndef _ST_NCI_H_ 20 + #define _ST_NCI_H_ 21 21 22 - #define ST21NFCB_NCI_DRIVER_NAME "st21nfcb_nci" 22 + #define ST_NCI_DRIVER_NAME "st_nci" 23 23 24 - struct st21nfcb_nfc_platform_data { 24 + struct st_nci_nfc_platform_data { 25 25 unsigned int gpio_reset; 26 26 unsigned int irq_polarity; 27 27 }; 28 28 29 - #endif /* _ST21NFCB_NCI_H_ */ 29 + #endif /* _ST_NCI_H_ */
+29
include/linux/platform_data/st_nci.h
··· 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_ */