2 * NFC Digital Protocol stack
3 * Copyright (c) 2013, Intel Corporation.
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms and conditions of the GNU General Public License,
7 * version 2, as published by the Free Software Foundation.
9 * This program is distributed in the hope it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16 #define pr_fmt(fmt) "digital: %s: " fmt, __func__
20 #define DIGITAL_CMD_SENS_REQ 0x26
21 #define DIGITAL_CMD_ALL_REQ 0x52
22 #define DIGITAL_CMD_SEL_REQ_CL1 0x93
23 #define DIGITAL_CMD_SEL_REQ_CL2 0x95
24 #define DIGITAL_CMD_SEL_REQ_CL3 0x97
26 #define DIGITAL_SDD_REQ_SEL_PAR 0x20
28 #define DIGITAL_SDD_RES_CT 0x88
29 #define DIGITAL_SDD_RES_LEN 5
31 #define DIGITAL_SEL_RES_NFCID1_COMPLETE(sel_res) (!((sel_res) & 0x04))
32 #define DIGITAL_SEL_RES_IS_T2T(sel_res) (!((sel_res) & 0x60))
33 #define DIGITAL_SEL_RES_IS_T4T(sel_res) ((sel_res) & 0x20)
34 #define DIGITAL_SEL_RES_IS_NFC_DEP(sel_res) ((sel_res) & 0x40)
36 #define DIGITAL_SENS_RES_IS_T1T(sens_res) (((sens_res) & 0x0C00) == 0x0C00)
37 #define DIGITAL_SENS_RES_IS_VALID(sens_res) \
38 ((!((sens_res) & 0x001F) && (((sens_res) & 0x0C00) == 0x0C00)) || \
39 (((sens_res) & 0x001F) && ((sens_res) & 0x0C00) != 0x0C00))
41 #define DIGITAL_MIFARE_READ_RES_LEN 16
42 #define DIGITAL_MIFARE_ACK_RES 0x0A
44 #define DIGITAL_CMD_SENSF_REQ 0x00
45 #define DIGITAL_CMD_SENSF_RES 0x01
47 #define DIGITAL_SENSF_RES_MIN_LENGTH 17
48 #define DIGITAL_SENSF_RES_RD_AP_B1 0x00
49 #define DIGITAL_SENSF_RES_RD_AP_B2 0x8F
51 #define DIGITAL_SENSF_REQ_RC_NONE 0
52 #define DIGITAL_SENSF_REQ_RC_SC 1
53 #define DIGITAL_SENSF_REQ_RC_AP 2
55 #define DIGITAL_CMD_ISO15693_INVENTORY_REQ 0x01
57 #define DIGITAL_ISO15693_REQ_FLAG_DATA_RATE BIT(1)
58 #define DIGITAL_ISO15693_REQ_FLAG_INVENTORY BIT(2)
59 #define DIGITAL_ISO15693_REQ_FLAG_NB_SLOTS BIT(5)
60 #define DIGITAL_ISO15693_RES_FLAG_ERROR BIT(0)
61 #define DIGITAL_ISO15693_RES_IS_VALID(flags) \
62 (!((flags) & DIGITAL_ISO15693_RES_FLAG_ERROR))
64 #define DIGITAL_ISO_DEP_I_PCB 0x02
65 #define DIGITAL_ISO_DEP_PNI(pni) ((pni) & 0x01)
67 #define DIGITAL_ISO_DEP_PCB_TYPE(pcb) ((pcb) & 0xC0)
69 #define DIGITAL_ISO_DEP_I_BLOCK 0x00
71 #define DIGITAL_ISO_DEP_BLOCK_HAS_DID(pcb) ((pcb) & 0x08)
73 static const u8 digital_ats_fsc
[] = {
74 16, 24, 32, 40, 48, 64, 96, 128,
77 #define DIGITAL_ATS_FSCI(t0) ((t0) & 0x0F)
78 #define DIGITAL_ATS_MAX_FSC 256
80 #define DIGITAL_RATS_BYTE1 0xE0
81 #define DIGITAL_RATS_PARAM 0x80
83 struct digital_sdd_res
{
88 struct digital_sel_req
{
95 struct digital_sensf_req
{
103 struct digital_sensf_res
{
114 struct digital_iso15693_inv_req
{
121 struct digital_iso15693_inv_res
{
127 static int digital_in_send_sdd_req(struct nfc_digital_dev
*ddev
,
128 struct nfc_target
*target
);
130 int digital_in_iso_dep_pull_sod(struct nfc_digital_dev
*ddev
,
140 block_type
= DIGITAL_ISO_DEP_PCB_TYPE(pcb
);
142 /* No support fo R-block nor S-block */
143 if (block_type
!= DIGITAL_ISO_DEP_I_BLOCK
) {
144 pr_err("ISO_DEP R-block and S-block not supported\n");
148 if (DIGITAL_ISO_DEP_BLOCK_HAS_DID(pcb
)) {
149 pr_err("DID field in ISO_DEP PCB not supported\n");
158 int digital_in_iso_dep_push_sod(struct nfc_digital_dev
*ddev
,
162 * Chaining not supported so skb->len + 1 PCB byte + 2 CRC bytes must
163 * not be greater than remote FSC
165 if (skb
->len
+ 3 > ddev
->target_fsc
)
170 *skb
->data
= DIGITAL_ISO_DEP_I_PCB
| ddev
->curr_nfc_dep_pni
;
172 ddev
->curr_nfc_dep_pni
=
173 DIGITAL_ISO_DEP_PNI(ddev
->curr_nfc_dep_pni
+ 1);
178 static void digital_in_recv_ats(struct nfc_digital_dev
*ddev
, void *arg
,
179 struct sk_buff
*resp
)
181 struct nfc_target
*target
= arg
;
196 fsdi
= DIGITAL_ATS_FSCI(resp
->data
[1]);
198 ddev
->target_fsc
= DIGITAL_ATS_MAX_FSC
;
200 ddev
->target_fsc
= digital_ats_fsc
[fsdi
];
202 ddev
->curr_nfc_dep_pni
= 0;
204 rc
= digital_target_found(ddev
, target
, NFC_PROTO_ISO14443
);
211 digital_poll_next_tech(ddev
);
214 static int digital_in_send_rats(struct nfc_digital_dev
*ddev
,
215 struct nfc_target
*target
)
220 skb
= digital_skb_alloc(ddev
, 2);
224 *skb_put(skb
, 1) = DIGITAL_RATS_BYTE1
;
225 *skb_put(skb
, 1) = DIGITAL_RATS_PARAM
;
227 rc
= digital_in_send_cmd(ddev
, skb
, 30, digital_in_recv_ats
,
235 static void digital_in_recv_sel_res(struct nfc_digital_dev
*ddev
, void *arg
,
236 struct sk_buff
*resp
)
238 struct nfc_target
*target
= arg
;
249 if (!DIGITAL_DRV_CAPS_IN_CRC(ddev
)) {
250 rc
= digital_skb_check_crc_a(resp
);
252 PROTOCOL_ERR("4.4.1.3");
262 sel_res
= resp
->data
[0];
264 if (!DIGITAL_SEL_RES_NFCID1_COMPLETE(sel_res
)) {
265 rc
= digital_in_send_sdd_req(ddev
, target
);
272 target
->sel_res
= sel_res
;
274 if (DIGITAL_SEL_RES_IS_T2T(sel_res
)) {
275 nfc_proto
= NFC_PROTO_MIFARE
;
276 } else if (DIGITAL_SEL_RES_IS_T4T(sel_res
)) {
277 rc
= digital_in_send_rats(ddev
, target
);
281 * Skip target_found and don't free it for now. This will be
282 * done when receiving the ATS
285 } else if (DIGITAL_SEL_RES_IS_NFC_DEP(sel_res
)) {
286 nfc_proto
= NFC_PROTO_NFC_DEP
;
292 rc
= digital_target_found(ddev
, target
, nfc_proto
);
301 digital_poll_next_tech(ddev
);
304 static int digital_in_send_sel_req(struct nfc_digital_dev
*ddev
,
305 struct nfc_target
*target
,
306 struct digital_sdd_res
*sdd_res
)
309 struct digital_sel_req
*sel_req
;
313 skb
= digital_skb_alloc(ddev
, sizeof(struct digital_sel_req
));
317 skb_put(skb
, sizeof(struct digital_sel_req
));
318 sel_req
= (struct digital_sel_req
*)skb
->data
;
320 if (target
->nfcid1_len
<= 4)
321 sel_cmd
= DIGITAL_CMD_SEL_REQ_CL1
;
322 else if (target
->nfcid1_len
< 10)
323 sel_cmd
= DIGITAL_CMD_SEL_REQ_CL2
;
325 sel_cmd
= DIGITAL_CMD_SEL_REQ_CL3
;
327 sel_req
->sel_cmd
= sel_cmd
;
329 memcpy(sel_req
->nfcid1
, sdd_res
->nfcid1
, 4);
330 sel_req
->bcc
= sdd_res
->bcc
;
332 if (DIGITAL_DRV_CAPS_IN_CRC(ddev
)) {
333 rc
= digital_in_configure_hw(ddev
, NFC_DIGITAL_CONFIG_FRAMING
,
334 NFC_DIGITAL_FRAMING_NFCA_STANDARD_WITH_CRC_A
);
338 digital_skb_add_crc_a(skb
);
341 rc
= digital_in_send_cmd(ddev
, skb
, 30, digital_in_recv_sel_res
,
350 static void digital_in_recv_sdd_res(struct nfc_digital_dev
*ddev
, void *arg
,
351 struct sk_buff
*resp
)
353 struct nfc_target
*target
= arg
;
354 struct digital_sdd_res
*sdd_res
;
365 if (resp
->len
< DIGITAL_SDD_RES_LEN
) {
366 PROTOCOL_ERR("4.7.2.8");
371 sdd_res
= (struct digital_sdd_res
*)resp
->data
;
373 for (i
= 0, bcc
= 0; i
< 4; i
++)
374 bcc
^= sdd_res
->nfcid1
[i
];
376 if (bcc
!= sdd_res
->bcc
) {
377 PROTOCOL_ERR("4.7.2.6");
382 if (sdd_res
->nfcid1
[0] == DIGITAL_SDD_RES_CT
) {
390 memcpy(target
->nfcid1
+ target
->nfcid1_len
, sdd_res
->nfcid1
+ offset
,
392 target
->nfcid1_len
+= size
;
394 rc
= digital_in_send_sel_req(ddev
, target
, sdd_res
);
401 digital_poll_next_tech(ddev
);
405 static int digital_in_send_sdd_req(struct nfc_digital_dev
*ddev
,
406 struct nfc_target
*target
)
412 rc
= digital_in_configure_hw(ddev
, NFC_DIGITAL_CONFIG_FRAMING
,
413 NFC_DIGITAL_FRAMING_NFCA_STANDARD
);
417 skb
= digital_skb_alloc(ddev
, 2);
421 if (target
->nfcid1_len
== 0)
422 sel_cmd
= DIGITAL_CMD_SEL_REQ_CL1
;
423 else if (target
->nfcid1_len
== 3)
424 sel_cmd
= DIGITAL_CMD_SEL_REQ_CL2
;
426 sel_cmd
= DIGITAL_CMD_SEL_REQ_CL3
;
428 *skb_put(skb
, sizeof(u8
)) = sel_cmd
;
429 *skb_put(skb
, sizeof(u8
)) = DIGITAL_SDD_REQ_SEL_PAR
;
431 return digital_in_send_cmd(ddev
, skb
, 30, digital_in_recv_sdd_res
,
435 static void digital_in_recv_sens_res(struct nfc_digital_dev
*ddev
, void *arg
,
436 struct sk_buff
*resp
)
438 struct nfc_target
*target
= NULL
;
447 if (resp
->len
< sizeof(u16
)) {
452 target
= kzalloc(sizeof(struct nfc_target
), GFP_KERNEL
);
458 target
->sens_res
= __le16_to_cpu(*(__le16
*)resp
->data
);
460 if (!DIGITAL_SENS_RES_IS_VALID(target
->sens_res
)) {
461 PROTOCOL_ERR("4.6.3.3");
466 if (DIGITAL_SENS_RES_IS_T1T(target
->sens_res
))
467 rc
= digital_target_found(ddev
, target
, NFC_PROTO_JEWEL
);
469 rc
= digital_in_send_sdd_req(ddev
, target
);
476 digital_poll_next_tech(ddev
);
480 int digital_in_send_sens_req(struct nfc_digital_dev
*ddev
, u8 rf_tech
)
485 rc
= digital_in_configure_hw(ddev
, NFC_DIGITAL_CONFIG_RF_TECH
,
486 NFC_DIGITAL_RF_TECH_106A
);
490 rc
= digital_in_configure_hw(ddev
, NFC_DIGITAL_CONFIG_FRAMING
,
491 NFC_DIGITAL_FRAMING_NFCA_SHORT
);
495 skb
= digital_skb_alloc(ddev
, 1);
499 *skb_put(skb
, sizeof(u8
)) = DIGITAL_CMD_SENS_REQ
;
501 rc
= digital_in_send_cmd(ddev
, skb
, 30, digital_in_recv_sens_res
, NULL
);
508 int digital_in_recv_mifare_res(struct sk_buff
*resp
)
510 /* Successful READ command response is 16 data bytes + 2 CRC bytes long.
511 * Since the driver can't differentiate a ACK/NACK response from a valid
512 * READ response, the CRC calculation must be handled at digital level
513 * even if the driver supports it for this technology.
515 if (resp
->len
== DIGITAL_MIFARE_READ_RES_LEN
+ DIGITAL_CRC_LEN
) {
516 if (digital_skb_check_crc_a(resp
)) {
517 PROTOCOL_ERR("9.4.1.2");
524 /* ACK response (i.e. successful WRITE). */
525 if (resp
->len
== 1 && resp
->data
[0] == DIGITAL_MIFARE_ACK_RES
) {
530 /* NACK and any other responses are treated as error. */
534 static void digital_in_recv_sensf_res(struct nfc_digital_dev
*ddev
, void *arg
,
535 struct sk_buff
*resp
)
539 struct nfc_target target
;
540 struct digital_sensf_res
*sensf_res
;
548 if (resp
->len
< DIGITAL_SENSF_RES_MIN_LENGTH
) {
553 if (!DIGITAL_DRV_CAPS_IN_CRC(ddev
)) {
554 rc
= digital_skb_check_crc_f(resp
);
556 PROTOCOL_ERR("6.4.1.8");
563 memset(&target
, 0, sizeof(struct nfc_target
));
565 sensf_res
= (struct digital_sensf_res
*)resp
->data
;
567 memcpy(target
.sensf_res
, sensf_res
, resp
->len
);
568 target
.sensf_res_len
= resp
->len
;
570 memcpy(target
.nfcid2
, sensf_res
->nfcid2
, NFC_NFCID2_MAXSIZE
);
571 target
.nfcid2_len
= NFC_NFCID2_MAXSIZE
;
573 if (target
.nfcid2
[0] == DIGITAL_SENSF_NFCID2_NFC_DEP_B1
&&
574 target
.nfcid2
[1] == DIGITAL_SENSF_NFCID2_NFC_DEP_B2
)
575 proto
= NFC_PROTO_NFC_DEP
;
577 proto
= NFC_PROTO_FELICA
;
579 rc
= digital_target_found(ddev
, &target
, proto
);
585 digital_poll_next_tech(ddev
);
588 int digital_in_send_sensf_req(struct nfc_digital_dev
*ddev
, u8 rf_tech
)
590 struct digital_sensf_req
*sensf_req
;
595 rc
= digital_in_configure_hw(ddev
, NFC_DIGITAL_CONFIG_RF_TECH
, rf_tech
);
599 rc
= digital_in_configure_hw(ddev
, NFC_DIGITAL_CONFIG_FRAMING
,
600 NFC_DIGITAL_FRAMING_NFCF
);
604 size
= sizeof(struct digital_sensf_req
);
606 skb
= digital_skb_alloc(ddev
, size
);
612 sensf_req
= (struct digital_sensf_req
*)skb
->data
;
613 sensf_req
->cmd
= DIGITAL_CMD_SENSF_REQ
;
614 sensf_req
->sc1
= 0xFF;
615 sensf_req
->sc2
= 0xFF;
619 *skb_push(skb
, 1) = size
+ 1;
621 if (!DIGITAL_DRV_CAPS_IN_CRC(ddev
))
622 digital_skb_add_crc_f(skb
);
624 rc
= digital_in_send_cmd(ddev
, skb
, 30, digital_in_recv_sensf_res
,
632 static void digital_in_recv_iso15693_inv_res(struct nfc_digital_dev
*ddev
,
633 void *arg
, struct sk_buff
*resp
)
635 struct digital_iso15693_inv_res
*res
;
636 struct nfc_target
*target
= NULL
;
645 if (resp
->len
!= sizeof(*res
)) {
650 res
= (struct digital_iso15693_inv_res
*)resp
->data
;
652 if (!DIGITAL_ISO15693_RES_IS_VALID(res
->flags
)) {
653 PROTOCOL_ERR("ISO15693 - 10.3.1");
658 target
= kzalloc(sizeof(*target
), GFP_KERNEL
);
664 target
->is_iso15693
= 1;
665 target
->iso15693_dsfid
= res
->dsfid
;
666 memcpy(target
->iso15693_uid
, &res
->uid
, sizeof(target
->iso15693_uid
));
668 rc
= digital_target_found(ddev
, target
, NFC_PROTO_ISO15693
);
676 digital_poll_next_tech(ddev
);
679 int digital_in_send_iso15693_inv_req(struct nfc_digital_dev
*ddev
, u8 rf_tech
)
681 struct digital_iso15693_inv_req
*req
;
685 rc
= digital_in_configure_hw(ddev
, NFC_DIGITAL_CONFIG_RF_TECH
,
686 NFC_DIGITAL_RF_TECH_ISO15693
);
690 rc
= digital_in_configure_hw(ddev
, NFC_DIGITAL_CONFIG_FRAMING
,
691 NFC_DIGITAL_FRAMING_ISO15693_INVENTORY
);
695 skb
= digital_skb_alloc(ddev
, sizeof(*req
));
699 skb_put(skb
, sizeof(*req
) - sizeof(req
->mask
)); /* No mask */
700 req
= (struct digital_iso15693_inv_req
*)skb
->data
;
702 /* Single sub-carrier, high data rate, no AFI, single slot
705 req
->flags
= DIGITAL_ISO15693_REQ_FLAG_DATA_RATE
|
706 DIGITAL_ISO15693_REQ_FLAG_INVENTORY
|
707 DIGITAL_ISO15693_REQ_FLAG_NB_SLOTS
;
708 req
->cmd
= DIGITAL_CMD_ISO15693_INVENTORY_REQ
;
711 rc
= digital_in_send_cmd(ddev
, skb
, 30,
712 digital_in_recv_iso15693_inv_res
, NULL
);
719 static int digital_tg_send_sel_res(struct nfc_digital_dev
*ddev
)
724 skb
= digital_skb_alloc(ddev
, 1);
728 *skb_put(skb
, 1) = DIGITAL_SEL_RES_NFC_DEP
;
730 if (!DIGITAL_DRV_CAPS_TG_CRC(ddev
))
731 digital_skb_add_crc_a(skb
);
733 rc
= digital_tg_send_cmd(ddev
, skb
, 300, digital_tg_recv_atr_req
,
741 static void digital_tg_recv_sel_req(struct nfc_digital_dev
*ddev
, void *arg
,
742 struct sk_buff
*resp
)
752 if (!DIGITAL_DRV_CAPS_TG_CRC(ddev
)) {
753 rc
= digital_skb_check_crc_a(resp
);
755 PROTOCOL_ERR("4.4.1.3");
760 /* Silently ignore SEL_REQ content and send a SEL_RES for NFC-DEP */
762 rc
= digital_tg_send_sel_res(ddev
);
766 digital_poll_next_tech(ddev
);
771 static int digital_tg_send_sdd_res(struct nfc_digital_dev
*ddev
)
774 struct digital_sdd_res
*sdd_res
;
777 skb
= digital_skb_alloc(ddev
, sizeof(struct digital_sdd_res
));
781 skb_put(skb
, sizeof(struct digital_sdd_res
));
782 sdd_res
= (struct digital_sdd_res
*)skb
->data
;
784 sdd_res
->nfcid1
[0] = 0x08;
785 get_random_bytes(sdd_res
->nfcid1
+ 1, 3);
788 for (i
= 0; i
< 4; i
++)
789 sdd_res
->bcc
^= sdd_res
->nfcid1
[i
];
791 rc
= digital_tg_send_cmd(ddev
, skb
, 300, digital_tg_recv_sel_req
,
799 static void digital_tg_recv_sdd_req(struct nfc_digital_dev
*ddev
, void *arg
,
800 struct sk_buff
*resp
)
811 sdd_req
= resp
->data
;
813 if (resp
->len
< 2 || sdd_req
[0] != DIGITAL_CMD_SEL_REQ_CL1
||
814 sdd_req
[1] != DIGITAL_SDD_REQ_SEL_PAR
) {
819 rc
= digital_tg_send_sdd_res(ddev
);
823 digital_poll_next_tech(ddev
);
828 static int digital_tg_send_sens_res(struct nfc_digital_dev
*ddev
)
834 skb
= digital_skb_alloc(ddev
, 2);
838 sens_res
= skb_put(skb
, 2);
840 sens_res
[0] = (DIGITAL_SENS_RES_NFC_DEP
>> 8) & 0xFF;
841 sens_res
[1] = DIGITAL_SENS_RES_NFC_DEP
& 0xFF;
843 rc
= digital_tg_send_cmd(ddev
, skb
, 300, digital_tg_recv_sdd_req
,
851 void digital_tg_recv_sens_req(struct nfc_digital_dev
*ddev
, void *arg
,
852 struct sk_buff
*resp
)
863 sens_req
= resp
->data
[0];
865 if (!resp
->len
|| (sens_req
!= DIGITAL_CMD_SENS_REQ
&&
866 sens_req
!= DIGITAL_CMD_ALL_REQ
)) {
871 rc
= digital_tg_send_sens_res(ddev
);
875 digital_poll_next_tech(ddev
);
880 static int digital_tg_send_sensf_res(struct nfc_digital_dev
*ddev
,
881 struct digital_sensf_req
*sensf_req
)
886 struct digital_sensf_res
*sensf_res
;
888 size
= sizeof(struct digital_sensf_res
);
890 if (sensf_req
->rc
!= DIGITAL_SENSF_REQ_RC_NONE
)
891 size
-= sizeof(sensf_res
->rd
);
893 skb
= digital_skb_alloc(ddev
, size
);
899 sensf_res
= (struct digital_sensf_res
*)skb
->data
;
901 memset(sensf_res
, 0, size
);
903 sensf_res
->cmd
= DIGITAL_CMD_SENSF_RES
;
904 sensf_res
->nfcid2
[0] = DIGITAL_SENSF_NFCID2_NFC_DEP_B1
;
905 sensf_res
->nfcid2
[1] = DIGITAL_SENSF_NFCID2_NFC_DEP_B2
;
906 get_random_bytes(&sensf_res
->nfcid2
[2], 6);
908 switch (sensf_req
->rc
) {
909 case DIGITAL_SENSF_REQ_RC_SC
:
910 sensf_res
->rd
[0] = sensf_req
->sc1
;
911 sensf_res
->rd
[1] = sensf_req
->sc2
;
913 case DIGITAL_SENSF_REQ_RC_AP
:
914 sensf_res
->rd
[0] = DIGITAL_SENSF_RES_RD_AP_B1
;
915 sensf_res
->rd
[1] = DIGITAL_SENSF_RES_RD_AP_B2
;
919 *skb_push(skb
, sizeof(u8
)) = size
+ 1;
921 if (!DIGITAL_DRV_CAPS_TG_CRC(ddev
))
922 digital_skb_add_crc_f(skb
);
924 rc
= digital_tg_send_cmd(ddev
, skb
, 300,
925 digital_tg_recv_atr_req
, NULL
);
932 void digital_tg_recv_sensf_req(struct nfc_digital_dev
*ddev
, void *arg
,
933 struct sk_buff
*resp
)
935 struct digital_sensf_req
*sensf_req
;
944 if (!DIGITAL_DRV_CAPS_TG_CRC(ddev
)) {
945 rc
= digital_skb_check_crc_f(resp
);
947 PROTOCOL_ERR("6.4.1.8");
952 if (resp
->len
!= sizeof(struct digital_sensf_req
) + 1) {
958 sensf_req
= (struct digital_sensf_req
*)resp
->data
;
960 if (sensf_req
->cmd
!= DIGITAL_CMD_SENSF_REQ
) {
965 rc
= digital_tg_send_sensf_res(ddev
, sensf_req
);
969 digital_poll_next_tech(ddev
);
974 int digital_tg_listen_nfca(struct nfc_digital_dev
*ddev
, u8 rf_tech
)
978 rc
= digital_tg_configure_hw(ddev
, NFC_DIGITAL_CONFIG_RF_TECH
, rf_tech
);
982 rc
= digital_tg_configure_hw(ddev
, NFC_DIGITAL_CONFIG_FRAMING
,
983 NFC_DIGITAL_FRAMING_NFCA_NFC_DEP
);
987 return digital_tg_listen(ddev
, 300, digital_tg_recv_sens_req
, NULL
);
990 int digital_tg_listen_nfcf(struct nfc_digital_dev
*ddev
, u8 rf_tech
)
995 rc
= digital_tg_configure_hw(ddev
, NFC_DIGITAL_CONFIG_RF_TECH
, rf_tech
);
999 rc
= digital_tg_configure_hw(ddev
, NFC_DIGITAL_CONFIG_FRAMING
,
1000 NFC_DIGITAL_FRAMING_NFCF_NFC_DEP
);
1004 nfcid2
= kzalloc(NFC_NFCID2_MAXSIZE
, GFP_KERNEL
);
1008 nfcid2
[0] = DIGITAL_SENSF_NFCID2_NFC_DEP_B1
;
1009 nfcid2
[1] = DIGITAL_SENSF_NFCID2_NFC_DEP_B2
;
1010 get_random_bytes(nfcid2
+ 2, NFC_NFCID2_MAXSIZE
- 2);
1012 return digital_tg_listen(ddev
, 300, digital_tg_recv_sensf_req
, nfcid2
);