• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /******************************************************************************
2  *
3  *  Copyright (C) 2015 NXP Semiconductors
4  *
5  *  Licensed under the Apache License, Version 2.0 (the "License");
6  *  you may not use this file except in compliance with the License.
7  *  You may obtain a copy of the License at
8  *
9  *  http://www.apache.org/licenses/LICENSE-2.0
10  *
11  *  Unless required by applicable law or agreed to in writing, software
12  *  distributed under the License is distributed on an "AS IS" BASIS,
13  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  *  See the License for the specific language governing permissions and
15  *  limitations under the License.
16  *
17  ******************************************************************************/
18 #define LOG_TAG "NxpHal"
19 #include "NxpNfcCapability.h"
20 #include <phNxpLog.h>
21 
22 capability* capability::instance = NULL;
23 tNFC_chipType capability::chipType = pn81T;
24 tNfc_featureList nfcFL;
25 
capability()26 capability::capability() {}
27 
getInstance()28 capability* capability::getInstance() {
29   if (NULL == instance) {
30     instance = new capability();
31   }
32   return instance;
33 }
34 
getChipType(uint8_t * msg,uint16_t msg_len)35 tNFC_chipType capability::getChipType(uint8_t* msg, uint16_t msg_len) {
36   if ((msg != NULL) && (msg_len != 0)) {
37     uint16_t offsetHwVersion = 0;
38     uint16_t offsetFwVersion = 0;
39 
40     if (msg[0] == 0x60 && msg[1] == 0x00) {
41       /*CORE_RST_NTF*/
42       offsetHwVersion = offsetRstHwVersion;
43       offsetFwVersion = offsetRstFwVersion;
44     } else if (msg[0] == 0x40 && msg[1] == 0x01) {
45       /*CORE_INIT_RSP*/
46       offsetHwVersion = offsetInitHwVersion;
47       offsetFwVersion = offsetInitFwVersion;
48     } else if (msg[0] == 0x00 && msg[1] == 0x0A) {
49       /*Propreitary Response*/
50       offsetHwVersion = offsetPropHwVersion;
51       offsetFwVersion = offsetPropFwVersion;
52     }
53 
54     if ((offsetHwVersion > 0) && (offsetHwVersion < msg_len)) {
55       ALOGD("%s HwVersion : 0x%02x", __func__, msg[offsetHwVersion]);
56       switch (msg[offsetHwVersion]) {
57         case 0x40:  // PN553 A0
58         case 0x41:  // PN553 B0
59           // NQ310
60           chipType = pn553;
61           break;
62 
63         case 0x50:  // PN553 A0 + P73
64         case 0x51:  // PN553 B0 + P73 , NQ440
65                     // NQ330
66                     // PN80T
67                     // PN81T
68           if (msg[offsetFwVersion] == 0x12) {
69             chipType = pn81T;
70           } else {
71             chipType = pn80T;
72           }
73           break;
74 
75         case 0x61:
76           if (msg[offsetFwVersion] == 0x11) {
77             chipType = pn553;
78           }
79           break;
80 
81         case 0x98:
82           chipType = pn551;
83           break;
84 
85         case 0xA8:
86         case 0x08:
87           chipType = pn67T;
88           break;
89 
90         case 0x28:
91         case 0x48:  // NQ210
92           chipType = pn548C2;
93           break;
94 
95         case 0x18:
96         case 0x58:  // NQ220
97           chipType = pn66T;
98           break;
99 
100         default:
101           chipType = pn80T;
102       }
103     } else {
104       ALOGD("%s Wrong msg_len. Setting Default ChiptType pn81T", __func__);
105       chipType = pn81T;
106     }
107   }
108   ALOGD("%s Product : %s", __func__, product[chipType]);
109   return chipType;
110 }
111