digital_technology.c (2c66daecc4092e6049673c281b2e6f0d5e59a94c) | digital_technology.c (8c0695e4998dd268ff2a05951961247b7e015651) |
---|---|
1/* 2 * NFC Digital Protocol stack 3 * Copyright (c) 2013, Intel Corporation. 4 * 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. 8 * --- 23 unchanged lines hidden (view full) --- 32#define DIGITAL_SENS_RES_IS_T1T(sens_res) (((sens_res) & 0x000C) == 0x000C) 33#define DIGITAL_SENS_RES_IS_VALID(sens_res) \ 34 ((!((sens_res) & 0x1F00) && (((sens_res) & 0x000C) == 0x000C)) || \ 35 (((sens_res) & 0x1F00) && ((sens_res) & 0x000C) != 0x000C)) 36 37#define DIGITAL_MIFARE_READ_RES_LEN 16 38#define DIGITAL_MIFARE_ACK_RES 0x0A 39 | 1/* 2 * NFC Digital Protocol stack 3 * Copyright (c) 2013, Intel Corporation. 4 * 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. 8 * --- 23 unchanged lines hidden (view full) --- 32#define DIGITAL_SENS_RES_IS_T1T(sens_res) (((sens_res) & 0x000C) == 0x000C) 33#define DIGITAL_SENS_RES_IS_VALID(sens_res) \ 34 ((!((sens_res) & 0x1F00) && (((sens_res) & 0x000C) == 0x000C)) || \ 35 (((sens_res) & 0x1F00) && ((sens_res) & 0x000C) != 0x000C)) 36 37#define DIGITAL_MIFARE_READ_RES_LEN 16 38#define DIGITAL_MIFARE_ACK_RES 0x0A 39 |
40#define DIGITAL_CMD_SENSF_REQ 0x00 41#define DIGITAL_CMD_SENSF_RES 0x01 42 43#define DIGITAL_SENSF_RES_MIN_LENGTH 17 44#define DIGITAL_SENSF_RES_RD_AP_B1 0x00 45#define DIGITAL_SENSF_RES_RD_AP_B2 0x8F 46 47#define DIGITAL_SENSF_REQ_RC_NONE 0 48#define DIGITAL_SENSF_REQ_RC_SC 1 49#define DIGITAL_SENSF_REQ_RC_AP 2 50 |
|
40struct digital_sdd_res { 41 u8 nfcid1[4]; 42 u8 bcc; 43} __packed; 44 45struct digital_sel_req { 46 u8 sel_cmd; 47 u8 b2; 48 u8 nfcid1[4]; 49 u8 bcc; 50} __packed; 51 | 51struct digital_sdd_res { 52 u8 nfcid1[4]; 53 u8 bcc; 54} __packed; 55 56struct digital_sel_req { 57 u8 sel_cmd; 58 u8 b2; 59 u8 nfcid1[4]; 60 u8 bcc; 61} __packed; 62 |
63struct digital_sensf_req { 64 u8 cmd; 65 u8 sc1; 66 u8 sc2; 67 u8 rc; 68 u8 tsn; 69} __packed; 70 71struct digital_sensf_res { 72 u8 cmd; 73 u8 nfcid2[8]; 74 u8 pad0[2]; 75 u8 pad1[3]; 76 u8 mrti_check; 77 u8 mrti_update; 78 u8 pad2; 79 u8 rd[2]; 80} __packed; 81 |
|
52static int digital_in_send_sdd_req(struct nfc_digital_dev *ddev, 53 struct nfc_target *target); 54 55static void digital_in_recv_sel_res(struct nfc_digital_dev *ddev, void *arg, 56 struct sk_buff *resp) 57{ 58 struct nfc_target *target = arg; 59 int rc; --- 279 unchanged lines hidden (view full) --- 339 if (resp->len == 1 && resp->data[0] == DIGITAL_MIFARE_ACK_RES) { 340 resp->data[0] = 0; 341 return 0; 342 } 343 344 /* NACK and any other responses are treated as error. */ 345 return -EIO; 346} | 82static int digital_in_send_sdd_req(struct nfc_digital_dev *ddev, 83 struct nfc_target *target); 84 85static void digital_in_recv_sel_res(struct nfc_digital_dev *ddev, void *arg, 86 struct sk_buff *resp) 87{ 88 struct nfc_target *target = arg; 89 int rc; --- 279 unchanged lines hidden (view full) --- 369 if (resp->len == 1 && resp->data[0] == DIGITAL_MIFARE_ACK_RES) { 370 resp->data[0] = 0; 371 return 0; 372 } 373 374 /* NACK and any other responses are treated as error. */ 375 return -EIO; 376} |
377 378static void digital_in_recv_sensf_res(struct nfc_digital_dev *ddev, void *arg, 379 struct sk_buff *resp) 380{ 381 int rc; 382 struct nfc_target target; 383 struct digital_sensf_res *sensf_res; 384 385 if (IS_ERR(resp)) { 386 rc = PTR_ERR(resp); 387 resp = NULL; 388 goto exit; 389 } 390 391 if (resp->len < DIGITAL_SENSF_RES_MIN_LENGTH) { 392 rc = -EIO; 393 goto exit; 394 } 395 396 if (!DIGITAL_DRV_CAPS_IN_CRC(ddev)) { 397 rc = digital_skb_check_crc_f(resp); 398 if (rc) { 399 PROTOCOL_ERR("6.4.1.8"); 400 goto exit; 401 } 402 } 403 404 skb_pull(resp, 1); 405 406 memset(&target, 0, sizeof(struct nfc_target)); 407 408 sensf_res = (struct digital_sensf_res *)resp->data; 409 410 memcpy(target.sensf_res, sensf_res, resp->len); 411 target.sensf_res_len = resp->len; 412 413 memcpy(target.nfcid2, sensf_res->nfcid2, NFC_NFCID2_MAXSIZE); 414 target.nfcid2_len = NFC_NFCID2_MAXSIZE; 415 416 rc = digital_target_found(ddev, &target, NFC_PROTO_FELICA); 417 418exit: 419 dev_kfree_skb(resp); 420 421 if (rc) 422 digital_poll_next_tech(ddev); 423} 424 425int digital_in_send_sensf_req(struct nfc_digital_dev *ddev, u8 rf_tech) 426{ 427 struct digital_sensf_req *sensf_req; 428 struct sk_buff *skb; 429 int rc; 430 u8 size; 431 432 rc = digital_in_configure_hw(ddev, NFC_DIGITAL_CONFIG_RF_TECH, rf_tech); 433 if (rc) 434 return rc; 435 436 rc = digital_in_configure_hw(ddev, NFC_DIGITAL_CONFIG_FRAMING, 437 NFC_DIGITAL_FRAMING_NFCF); 438 if (rc) 439 return rc; 440 441 size = sizeof(struct digital_sensf_req); 442 443 skb = digital_skb_alloc(ddev, size); 444 if (!skb) 445 return -ENOMEM; 446 447 skb_put(skb, size); 448 449 sensf_req = (struct digital_sensf_req *)skb->data; 450 sensf_req->cmd = DIGITAL_CMD_SENSF_REQ; 451 sensf_req->sc1 = 0xFF; 452 sensf_req->sc2 = 0xFF; 453 sensf_req->rc = 0; 454 sensf_req->tsn = 0; 455 456 *skb_push(skb, 1) = size + 1; 457 458 if (!DIGITAL_DRV_CAPS_IN_CRC(ddev)) 459 digital_skb_add_crc_f(skb); 460 461 rc = digital_in_send_cmd(ddev, skb, 30, digital_in_recv_sensf_res, 462 NULL); 463 if (rc) 464 kfree_skb(skb); 465 466 return rc; 467} |
|