1 /****************************************************************************** 2 * 3 * Copyright 2018 NXP 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 #ifndef ANDROID_HARDWARE_HAL_NXPNFC_V1_0_H 19 #define ANDROID_HARDWARE_HAL_NXPNFC_V1_0_H 20 21 #define NFC_NCI_NXP_PN54X_HARDWARE_MODULE_ID "nfc_nci.pn54x" 22 #define MAX_IOCTL_TRANSCEIVE_CMD_LEN 256 23 #define MAX_IOCTL_TRANSCEIVE_RESP_LEN 256 24 #define MAX_ATR_INFO_LEN 128 25 26 enum { 27 // HAL_NFC_ENABLE_I2C_FRAGMENTATION_EVT = 0x07, 28 HAL_NFC_POST_MIN_INIT_CPLT_EVT = 0x08 29 }; 30 /* 31 * Data structures provided below are used of Hal Ioctl calls 32 */ 33 /* 34 * nfc_nci_ExtnCmd_t shall contain data for commands used for transceive command 35 * in ioctl 36 */ 37 typedef struct { 38 uint16_t cmd_len; 39 uint8_t p_cmd[MAX_IOCTL_TRANSCEIVE_CMD_LEN]; 40 } nfc_nci_ExtnCmd_t; 41 42 /* 43 * nfc_nci_ExtnRsp_t shall contain response for command sent in transceive 44 * command 45 */ 46 typedef struct { 47 uint16_t rsp_len; 48 uint8_t p_rsp[MAX_IOCTL_TRANSCEIVE_RESP_LEN]; 49 } nfc_nci_ExtnRsp_t; 50 /* 51 * InputData_t :ioctl has multiple subcommands 52 * Each command has corresponding input data which needs to be populated in this 53 */ 54 typedef union { 55 uint16_t bootMode; 56 uint8_t halType; 57 nfc_nci_ExtnCmd_t nciCmd; 58 uint32_t timeoutMilliSec; 59 long nfcServicePid; 60 } InputData_t; 61 /* 62 * nfc_nci_ExtnInputData_t :Apart from InputData_t, there are context data 63 * which is required during callback from stub to proxy. 64 * To avoid additional copy of data while propagating from libnfc to Adaptation 65 * and Nfcstub to ncihal, common structure is used. As a sideeffect, context 66 * data 67 * is exposed to libnfc (Not encapsulated). 68 */ 69 typedef struct { 70 /*context to be used/updated only by users of proxy & stub of Nfc.hal 71 * i.e, NfcAdaptation & hardware/interface/Nfc. 72 */ 73 void* context; 74 InputData_t data; 75 uint8_t data_source; 76 long level; 77 } nfc_nci_ExtnInputData_t; 78 79 /* 80 * outputData_t :ioctl has multiple commands/responses 81 * This contains the output types for each ioctl. 82 */ 83 typedef union { 84 uint32_t status; 85 nfc_nci_ExtnRsp_t nciRsp; 86 uint8_t nxpNciAtrInfo[MAX_ATR_INFO_LEN]; 87 uint32_t p61CurrentState; 88 uint16_t fwUpdateInf; 89 uint16_t fwDwnldStatus; 90 uint16_t fwMwVerStatus; 91 uint8_t chipType; 92 } outputData_t; 93 94 /* 95 * nfc_nci_ExtnOutputData_t :Apart from outputData_t, there are other 96 * information 97 * which is required during callback from stub to proxy. 98 * For ex (context, result of the operation , type of ioctl which was 99 * completed). 100 * To avoid additional copy of data while propagating from libnfc to Adaptation 101 * and Nfcstub to ncihal, common structure is used. As a sideeffect, these data 102 * is exposed(Not encapsulated). 103 */ 104 typedef struct { 105 /*ioctlType, result & context to be used/updated only by users of 106 * proxy & stub of Nfc.hal. 107 * i.e, NfcAdaptation & hardware/interface/Nfc 108 * These fields shall not be used by libnfc or halimplementation*/ 109 uint64_t ioctlType; 110 uint32_t result; 111 void* context; 112 outputData_t data; 113 } nfc_nci_ExtnOutputData_t; 114 115 /* 116 * nfc_nci_IoctlInOutData_t :data structure for input & output 117 * to be sent for ioctl command. input is populated by client/proxy side 118 * output is provided from server/stub to client/proxy 119 */ 120 typedef struct { 121 nfc_nci_ExtnInputData_t inp; 122 nfc_nci_ExtnOutputData_t out; 123 } nfc_nci_IoctlInOutData_t; 124 125 /* 126 * nxpnfc_nci_device_t :data structure for nxp's extended nfc_nci_device 127 * Extra features added are 128 * -ioctl(manage sync between and DWP & SPI) 129 * -check request for fw download 130 */ 131 typedef struct nxpnfc_nci_device { 132 // nfc_nci_device_t nci_device; 133 /* 134 * (*ioctl)() For P61 power management synchronization 135 * between NFC Wired and SPI. 136 */ 137 int (*ioctl)(const struct nxpnfc_nci_device* p_dev, long arg, void* p_data); 138 /* 139 * (*check_fw_dwnld_flag)() Is called to get FW downlaod request. 140 */ 141 int (*check_fw_dwnld_flag)(const struct nxpnfc_nci_device* p_dev, 142 uint8_t* param1); 143 } nxpnfc_nci_device_t; 144 145 #endif // ANDROID_HARDWARE_HAL_NXPNFC_V1_0_H 146