diff options
author | John W. Linville <linville@tuxdriver.com> | 2014-09-26 13:37:02 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2014-09-26 13:37:02 -0400 |
commit | 330bd4ec9d046a6e6f8b7cf4a53c2d15b7705e00 (patch) | |
tree | d278d8325e1e1cfca1ecfaf592158dcec10539f2 /net | |
parent | 687b93082c0469fe9fe85583e6265a3d910cd89a (diff) | |
parent | 094e93592433312548dd5e43d7b24b152f658063 (diff) |
Merge tag 'nfc-next-3.18-1' of git://git.kernel.org/pub/scm/linux/kernel/git/sameo/nfc-next
Samuel Ortiz <sameo@linux.intel.com> says:
"NFC: 3.18 pull request
This is the NFC pull request for 3.18.
We've had major updates for TI and ST Microelectronics drivers:
For TI's trf7970a driver:
- Target mode support for trf7970a
- Suspend/resume support for trf7970a
- DT properties additions to handle different quirks
- A bunch of fixes for smartphone IOP related issues
For ST Microelectronics' ST21NFCA and ST21NFCB drivers:
- ISO15693 support for st21nfcb
- checkpatch and sparse related warning fixes
- Code cleanups and a few minor fixes
Finally, Marvell add ISO15693 support to the NCI stack, together with a
couple of NCI fixes."
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'net')
-rw-r--r-- | net/nfc/digital_dep.c | 101 | ||||
-rw-r--r-- | net/nfc/nci/core.c | 21 | ||||
-rw-r--r-- | net/nfc/nci/data.c | 7 | ||||
-rw-r--r-- | net/nfc/nci/ntf.c | 40 |
4 files changed, 158 insertions, 11 deletions
diff --git a/net/nfc/digital_dep.c b/net/nfc/digital_dep.c index e1638dab076d..b60aa35c074f 100644 --- a/net/nfc/digital_dep.c +++ b/net/nfc/digital_dep.c | |||
@@ -33,6 +33,8 @@ | |||
33 | #define DIGITAL_ATR_REQ_MAX_SIZE 64 | 33 | #define DIGITAL_ATR_REQ_MAX_SIZE 64 |
34 | 34 | ||
35 | #define DIGITAL_LR_BITS_PAYLOAD_SIZE_254B 0x30 | 35 | #define DIGITAL_LR_BITS_PAYLOAD_SIZE_254B 0x30 |
36 | #define DIGITAL_FSL_BITS_PAYLOAD_SIZE_254B \ | ||
37 | (DIGITAL_LR_BITS_PAYLOAD_SIZE_254B >> 4) | ||
36 | #define DIGITAL_GB_BIT 0x02 | 38 | #define DIGITAL_GB_BIT 0x02 |
37 | 39 | ||
38 | #define DIGITAL_NFC_DEP_PFB_TYPE(pfb) ((pfb) & 0xE0) | 40 | #define DIGITAL_NFC_DEP_PFB_TYPE(pfb) ((pfb) & 0xE0) |
@@ -127,6 +129,98 @@ static int digital_skb_pull_dep_sod(struct nfc_digital_dev *ddev, | |||
127 | return 0; | 129 | return 0; |
128 | } | 130 | } |
129 | 131 | ||
132 | static void digital_in_recv_psl_res(struct nfc_digital_dev *ddev, void *arg, | ||
133 | struct sk_buff *resp) | ||
134 | { | ||
135 | struct nfc_target *target = arg; | ||
136 | struct digital_psl_res *psl_res; | ||
137 | int rc; | ||
138 | |||
139 | if (IS_ERR(resp)) { | ||
140 | rc = PTR_ERR(resp); | ||
141 | resp = NULL; | ||
142 | goto exit; | ||
143 | } | ||
144 | |||
145 | rc = ddev->skb_check_crc(resp); | ||
146 | if (rc) { | ||
147 | PROTOCOL_ERR("14.4.1.6"); | ||
148 | goto exit; | ||
149 | } | ||
150 | |||
151 | rc = digital_skb_pull_dep_sod(ddev, resp); | ||
152 | if (rc) { | ||
153 | PROTOCOL_ERR("14.4.1.2"); | ||
154 | goto exit; | ||
155 | } | ||
156 | |||
157 | psl_res = (struct digital_psl_res *)resp->data; | ||
158 | |||
159 | if ((resp->len != sizeof(*psl_res)) || | ||
160 | (psl_res->dir != DIGITAL_NFC_DEP_FRAME_DIR_IN) || | ||
161 | (psl_res->cmd != DIGITAL_CMD_PSL_RES)) { | ||
162 | rc = -EIO; | ||
163 | goto exit; | ||
164 | } | ||
165 | |||
166 | rc = digital_in_configure_hw(ddev, NFC_DIGITAL_CONFIG_RF_TECH, | ||
167 | NFC_DIGITAL_RF_TECH_424F); | ||
168 | if (rc) | ||
169 | goto exit; | ||
170 | |||
171 | rc = digital_in_configure_hw(ddev, NFC_DIGITAL_CONFIG_FRAMING, | ||
172 | NFC_DIGITAL_FRAMING_NFCF_NFC_DEP); | ||
173 | if (rc) | ||
174 | goto exit; | ||
175 | |||
176 | if (!DIGITAL_DRV_CAPS_IN_CRC(ddev) && | ||
177 | (ddev->curr_rf_tech == NFC_DIGITAL_RF_TECH_106A)) { | ||
178 | ddev->skb_add_crc = digital_skb_add_crc_f; | ||
179 | ddev->skb_check_crc = digital_skb_check_crc_f; | ||
180 | } | ||
181 | |||
182 | ddev->curr_rf_tech = NFC_DIGITAL_RF_TECH_424F; | ||
183 | |||
184 | nfc_dep_link_is_up(ddev->nfc_dev, target->idx, NFC_COMM_ACTIVE, | ||
185 | NFC_RF_INITIATOR); | ||
186 | |||
187 | ddev->curr_nfc_dep_pni = 0; | ||
188 | |||
189 | exit: | ||
190 | dev_kfree_skb(resp); | ||
191 | |||
192 | if (rc) | ||
193 | ddev->curr_protocol = 0; | ||
194 | } | ||
195 | |||
196 | static int digital_in_send_psl_req(struct nfc_digital_dev *ddev, | ||
197 | struct nfc_target *target) | ||
198 | { | ||
199 | struct sk_buff *skb; | ||
200 | struct digital_psl_req *psl_req; | ||
201 | |||
202 | skb = digital_skb_alloc(ddev, sizeof(*psl_req)); | ||
203 | if (!skb) | ||
204 | return -ENOMEM; | ||
205 | |||
206 | skb_put(skb, sizeof(*psl_req)); | ||
207 | |||
208 | psl_req = (struct digital_psl_req *)skb->data; | ||
209 | |||
210 | psl_req->dir = DIGITAL_NFC_DEP_FRAME_DIR_OUT; | ||
211 | psl_req->cmd = DIGITAL_CMD_PSL_REQ; | ||
212 | psl_req->did = 0; | ||
213 | psl_req->brs = (0x2 << 3) | 0x2; /* 424F both directions */ | ||
214 | psl_req->fsl = DIGITAL_FSL_BITS_PAYLOAD_SIZE_254B; | ||
215 | |||
216 | digital_skb_push_dep_sod(ddev, skb); | ||
217 | |||
218 | ddev->skb_add_crc(skb); | ||
219 | |||
220 | return digital_in_send_cmd(ddev, skb, 500, digital_in_recv_psl_res, | ||
221 | target); | ||
222 | } | ||
223 | |||
130 | static void digital_in_recv_atr_res(struct nfc_digital_dev *ddev, void *arg, | 224 | static void digital_in_recv_atr_res(struct nfc_digital_dev *ddev, void *arg, |
131 | struct sk_buff *resp) | 225 | struct sk_buff *resp) |
132 | { | 226 | { |
@@ -166,6 +260,13 @@ static void digital_in_recv_atr_res(struct nfc_digital_dev *ddev, void *arg, | |||
166 | if (rc) | 260 | if (rc) |
167 | goto exit; | 261 | goto exit; |
168 | 262 | ||
263 | if ((ddev->protocols & NFC_PROTO_FELICA_MASK) && | ||
264 | (ddev->curr_rf_tech != NFC_DIGITAL_RF_TECH_424F)) { | ||
265 | rc = digital_in_send_psl_req(ddev, target); | ||
266 | if (!rc) | ||
267 | goto exit; | ||
268 | } | ||
269 | |||
169 | rc = nfc_dep_link_is_up(ddev->nfc_dev, target->idx, NFC_COMM_ACTIVE, | 270 | rc = nfc_dep_link_is_up(ddev->nfc_dev, target->idx, NFC_COMM_ACTIVE, |
170 | NFC_RF_INITIATOR); | 271 | NFC_RF_INITIATOR); |
171 | 272 | ||
diff --git a/net/nfc/nci/core.c b/net/nfc/nci/core.c index 2b400e1a8695..90b16cb40058 100644 --- a/net/nfc/nci/core.c +++ b/net/nfc/nci/core.c | |||
@@ -231,6 +231,14 @@ static void nci_rf_discover_req(struct nci_dev *ndev, unsigned long opt) | |||
231 | cmd.num_disc_configs++; | 231 | cmd.num_disc_configs++; |
232 | } | 232 | } |
233 | 233 | ||
234 | if ((cmd.num_disc_configs < NCI_MAX_NUM_RF_CONFIGS) && | ||
235 | (protocols & NFC_PROTO_ISO15693_MASK)) { | ||
236 | cmd.disc_configs[cmd.num_disc_configs].rf_tech_and_mode = | ||
237 | NCI_NFC_V_PASSIVE_POLL_MODE; | ||
238 | cmd.disc_configs[cmd.num_disc_configs].frequency = 1; | ||
239 | cmd.num_disc_configs++; | ||
240 | } | ||
241 | |||
234 | nci_send_cmd(ndev, NCI_OP_RF_DISCOVER_CMD, | 242 | nci_send_cmd(ndev, NCI_OP_RF_DISCOVER_CMD, |
235 | (1 + (cmd.num_disc_configs * sizeof(struct disc_config))), | 243 | (1 + (cmd.num_disc_configs * sizeof(struct disc_config))), |
236 | &cmd); | 244 | &cmd); |
@@ -751,10 +759,6 @@ int nci_register_device(struct nci_dev *ndev) | |||
751 | struct device *dev = &ndev->nfc_dev->dev; | 759 | struct device *dev = &ndev->nfc_dev->dev; |
752 | char name[32]; | 760 | char name[32]; |
753 | 761 | ||
754 | rc = nfc_register_device(ndev->nfc_dev); | ||
755 | if (rc) | ||
756 | goto exit; | ||
757 | |||
758 | ndev->flags = 0; | 762 | ndev->flags = 0; |
759 | 763 | ||
760 | INIT_WORK(&ndev->cmd_work, nci_cmd_work); | 764 | INIT_WORK(&ndev->cmd_work, nci_cmd_work); |
@@ -762,7 +766,7 @@ int nci_register_device(struct nci_dev *ndev) | |||
762 | ndev->cmd_wq = create_singlethread_workqueue(name); | 766 | ndev->cmd_wq = create_singlethread_workqueue(name); |
763 | if (!ndev->cmd_wq) { | 767 | if (!ndev->cmd_wq) { |
764 | rc = -ENOMEM; | 768 | rc = -ENOMEM; |
765 | goto unreg_exit; | 769 | goto exit; |
766 | } | 770 | } |
767 | 771 | ||
768 | INIT_WORK(&ndev->rx_work, nci_rx_work); | 772 | INIT_WORK(&ndev->rx_work, nci_rx_work); |
@@ -792,6 +796,10 @@ int nci_register_device(struct nci_dev *ndev) | |||
792 | 796 | ||
793 | mutex_init(&ndev->req_lock); | 797 | mutex_init(&ndev->req_lock); |
794 | 798 | ||
799 | rc = nfc_register_device(ndev->nfc_dev); | ||
800 | if (rc) | ||
801 | goto destroy_rx_wq_exit; | ||
802 | |||
795 | goto exit; | 803 | goto exit; |
796 | 804 | ||
797 | destroy_rx_wq_exit: | 805 | destroy_rx_wq_exit: |
@@ -800,9 +808,6 @@ destroy_rx_wq_exit: | |||
800 | destroy_cmd_wq_exit: | 808 | destroy_cmd_wq_exit: |
801 | destroy_workqueue(ndev->cmd_wq); | 809 | destroy_workqueue(ndev->cmd_wq); |
802 | 810 | ||
803 | unreg_exit: | ||
804 | nfc_unregister_device(ndev->nfc_dev); | ||
805 | |||
806 | exit: | 811 | exit: |
807 | return rc; | 812 | return rc; |
808 | } | 813 | } |
diff --git a/net/nfc/nci/data.c b/net/nfc/nci/data.c index 6c3aef852876..427ef2c7ab68 100644 --- a/net/nfc/nci/data.c +++ b/net/nfc/nci/data.c | |||
@@ -241,9 +241,12 @@ void nci_rx_data_packet(struct nci_dev *ndev, struct sk_buff *skb) | |||
241 | /* strip the nci data header */ | 241 | /* strip the nci data header */ |
242 | skb_pull(skb, NCI_DATA_HDR_SIZE); | 242 | skb_pull(skb, NCI_DATA_HDR_SIZE); |
243 | 243 | ||
244 | if (ndev->target_active_prot == NFC_PROTO_MIFARE) { | 244 | if (ndev->target_active_prot == NFC_PROTO_MIFARE || |
245 | ndev->target_active_prot == NFC_PROTO_JEWEL || | ||
246 | ndev->target_active_prot == NFC_PROTO_FELICA || | ||
247 | ndev->target_active_prot == NFC_PROTO_ISO15693) { | ||
245 | /* frame I/F => remove the status byte */ | 248 | /* frame I/F => remove the status byte */ |
246 | pr_debug("NFC_PROTO_MIFARE => remove the status byte\n"); | 249 | pr_debug("frame I/F => remove the status byte\n"); |
247 | skb_trim(skb, (skb->len - 1)); | 250 | skb_trim(skb, (skb->len - 1)); |
248 | } | 251 | } |
249 | 252 | ||
diff --git a/net/nfc/nci/ntf.c b/net/nfc/nci/ntf.c index df91bb95b12a..205b35f666db 100644 --- a/net/nfc/nci/ntf.c +++ b/net/nfc/nci/ntf.c | |||
@@ -2,6 +2,7 @@ | |||
2 | * The NFC Controller Interface is the communication protocol between an | 2 | * The NFC Controller Interface is the communication protocol between an |
3 | * NFC Controller (NFCC) and a Device Host (DH). | 3 | * NFC Controller (NFCC) and a Device Host (DH). |
4 | * | 4 | * |
5 | * Copyright (C) 2014 Marvell International Ltd. | ||
5 | * Copyright (C) 2011 Texas Instruments, Inc. | 6 | * Copyright (C) 2011 Texas Instruments, Inc. |
6 | * | 7 | * |
7 | * Written by Ilan Elias <ilane@ti.com> | 8 | * Written by Ilan Elias <ilane@ti.com> |
@@ -155,6 +156,24 @@ static __u8 *nci_extract_rf_params_nfcf_passive_poll(struct nci_dev *ndev, | |||
155 | return data; | 156 | return data; |
156 | } | 157 | } |
157 | 158 | ||
159 | static __u8 *nci_extract_rf_params_nfcv_passive_poll(struct nci_dev *ndev, | ||
160 | struct rf_tech_specific_params_nfcv_poll *nfcv_poll, | ||
161 | __u8 *data) | ||
162 | { | ||
163 | ++data; | ||
164 | nfcv_poll->dsfid = *data++; | ||
165 | memcpy(nfcv_poll->uid, data, NFC_ISO15693_UID_MAXSIZE); | ||
166 | data += NFC_ISO15693_UID_MAXSIZE; | ||
167 | return data; | ||
168 | } | ||
169 | |||
170 | __u32 nci_get_prop_rf_protocol(struct nci_dev *ndev, __u8 rf_protocol) | ||
171 | { | ||
172 | if (ndev->ops->get_rfprotocol) | ||
173 | return ndev->ops->get_rfprotocol(ndev, rf_protocol); | ||
174 | return 0; | ||
175 | } | ||
176 | |||
158 | static int nci_add_new_protocol(struct nci_dev *ndev, | 177 | static int nci_add_new_protocol(struct nci_dev *ndev, |
159 | struct nfc_target *target, | 178 | struct nfc_target *target, |
160 | __u8 rf_protocol, | 179 | __u8 rf_protocol, |
@@ -164,6 +183,7 @@ static int nci_add_new_protocol(struct nci_dev *ndev, | |||
164 | struct rf_tech_specific_params_nfca_poll *nfca_poll; | 183 | struct rf_tech_specific_params_nfca_poll *nfca_poll; |
165 | struct rf_tech_specific_params_nfcb_poll *nfcb_poll; | 184 | struct rf_tech_specific_params_nfcb_poll *nfcb_poll; |
166 | struct rf_tech_specific_params_nfcf_poll *nfcf_poll; | 185 | struct rf_tech_specific_params_nfcf_poll *nfcf_poll; |
186 | struct rf_tech_specific_params_nfcv_poll *nfcv_poll; | ||
167 | __u32 protocol; | 187 | __u32 protocol; |
168 | 188 | ||
169 | if (rf_protocol == NCI_RF_PROTOCOL_T1T) | 189 | if (rf_protocol == NCI_RF_PROTOCOL_T1T) |
@@ -179,8 +199,10 @@ static int nci_add_new_protocol(struct nci_dev *ndev, | |||
179 | protocol = NFC_PROTO_FELICA_MASK; | 199 | protocol = NFC_PROTO_FELICA_MASK; |
180 | else if (rf_protocol == NCI_RF_PROTOCOL_NFC_DEP) | 200 | else if (rf_protocol == NCI_RF_PROTOCOL_NFC_DEP) |
181 | protocol = NFC_PROTO_NFC_DEP_MASK; | 201 | protocol = NFC_PROTO_NFC_DEP_MASK; |
202 | else if (rf_protocol == NCI_RF_PROTOCOL_T5T) | ||
203 | protocol = NFC_PROTO_ISO15693_MASK; | ||
182 | else | 204 | else |
183 | protocol = 0; | 205 | protocol = nci_get_prop_rf_protocol(ndev, rf_protocol); |
184 | 206 | ||
185 | if (!(protocol & ndev->poll_prots)) { | 207 | if (!(protocol & ndev->poll_prots)) { |
186 | pr_err("the target found does not have the desired protocol\n"); | 208 | pr_err("the target found does not have the desired protocol\n"); |
@@ -213,6 +235,12 @@ static int nci_add_new_protocol(struct nci_dev *ndev, | |||
213 | memcpy(target->sensf_res, nfcf_poll->sensf_res, | 235 | memcpy(target->sensf_res, nfcf_poll->sensf_res, |
214 | target->sensf_res_len); | 236 | target->sensf_res_len); |
215 | } | 237 | } |
238 | } else if (rf_tech_and_mode == NCI_NFC_V_PASSIVE_POLL_MODE) { | ||
239 | nfcv_poll = (struct rf_tech_specific_params_nfcv_poll *)params; | ||
240 | |||
241 | target->is_iso15693 = 1; | ||
242 | target->iso15693_dsfid = nfcv_poll->dsfid; | ||
243 | memcpy(target->iso15693_uid, nfcv_poll->uid, NFC_ISO15693_UID_MAXSIZE); | ||
216 | } else { | 244 | } else { |
217 | pr_err("unsupported rf_tech_and_mode 0x%x\n", rf_tech_and_mode); | 245 | pr_err("unsupported rf_tech_and_mode 0x%x\n", rf_tech_and_mode); |
218 | return -EPROTO; | 246 | return -EPROTO; |
@@ -305,6 +333,11 @@ static void nci_rf_discover_ntf_packet(struct nci_dev *ndev, | |||
305 | &(ntf.rf_tech_specific_params.nfcf_poll), data); | 333 | &(ntf.rf_tech_specific_params.nfcf_poll), data); |
306 | break; | 334 | break; |
307 | 335 | ||
336 | case NCI_NFC_V_PASSIVE_POLL_MODE: | ||
337 | data = nci_extract_rf_params_nfcv_passive_poll(ndev, | ||
338 | &(ntf.rf_tech_specific_params.nfcv_poll), data); | ||
339 | break; | ||
340 | |||
308 | default: | 341 | default: |
309 | pr_err("unsupported rf_tech_and_mode 0x%x\n", | 342 | pr_err("unsupported rf_tech_and_mode 0x%x\n", |
310 | ntf.rf_tech_and_mode); | 343 | ntf.rf_tech_and_mode); |
@@ -455,6 +488,11 @@ static void nci_rf_intf_activated_ntf_packet(struct nci_dev *ndev, | |||
455 | &(ntf.rf_tech_specific_params.nfcf_poll), data); | 488 | &(ntf.rf_tech_specific_params.nfcf_poll), data); |
456 | break; | 489 | break; |
457 | 490 | ||
491 | case NCI_NFC_V_PASSIVE_POLL_MODE: | ||
492 | data = nci_extract_rf_params_nfcv_passive_poll(ndev, | ||
493 | &(ntf.rf_tech_specific_params.nfcv_poll), data); | ||
494 | break; | ||
495 | |||
458 | default: | 496 | default: |
459 | pr_err("unsupported activation_rf_tech_and_mode 0x%x\n", | 497 | pr_err("unsupported activation_rf_tech_and_mode 0x%x\n", |
460 | ntf.activation_rf_tech_and_mode); | 498 | ntf.activation_rf_tech_and_mode); |