0001
0002
0003
0004
0005
0006
0007 #ifndef __NFC_DIGITAL_H
0008 #define __NFC_DIGITAL_H
0009
0010 #include <linux/skbuff.h>
0011 #include <net/nfc/nfc.h>
0012
0013
0014
0015
0016 enum {
0017 NFC_DIGITAL_CONFIG_RF_TECH = 0,
0018 NFC_DIGITAL_CONFIG_FRAMING,
0019 };
0020
0021
0022
0023
0024
0025 enum {
0026 NFC_DIGITAL_RF_TECH_106A = 0,
0027 NFC_DIGITAL_RF_TECH_212F,
0028 NFC_DIGITAL_RF_TECH_424F,
0029 NFC_DIGITAL_RF_TECH_ISO15693,
0030 NFC_DIGITAL_RF_TECH_106B,
0031
0032 NFC_DIGITAL_RF_TECH_LAST,
0033 };
0034
0035
0036
0037
0038
0039 enum {
0040 NFC_DIGITAL_FRAMING_NFCA_SHORT = 0,
0041 NFC_DIGITAL_FRAMING_NFCA_STANDARD,
0042 NFC_DIGITAL_FRAMING_NFCA_STANDARD_WITH_CRC_A,
0043 NFC_DIGITAL_FRAMING_NFCA_ANTICOL_COMPLETE,
0044
0045 NFC_DIGITAL_FRAMING_NFCA_T1T,
0046 NFC_DIGITAL_FRAMING_NFCA_T2T,
0047 NFC_DIGITAL_FRAMING_NFCA_T4T,
0048 NFC_DIGITAL_FRAMING_NFCA_NFC_DEP,
0049
0050 NFC_DIGITAL_FRAMING_NFCF,
0051 NFC_DIGITAL_FRAMING_NFCF_T3T,
0052 NFC_DIGITAL_FRAMING_NFCF_NFC_DEP,
0053 NFC_DIGITAL_FRAMING_NFC_DEP_ACTIVATED,
0054
0055 NFC_DIGITAL_FRAMING_ISO15693_INVENTORY,
0056 NFC_DIGITAL_FRAMING_ISO15693_T5T,
0057
0058 NFC_DIGITAL_FRAMING_NFCB,
0059 NFC_DIGITAL_FRAMING_NFCB_T4T,
0060
0061 NFC_DIGITAL_FRAMING_LAST,
0062 };
0063
0064 #define DIGITAL_MDAA_NFCID1_SIZE 3
0065
0066 struct digital_tg_mdaa_params {
0067 u16 sens_res;
0068 u8 nfcid1[DIGITAL_MDAA_NFCID1_SIZE];
0069 u8 sel_res;
0070
0071 u8 nfcid2[NFC_NFCID2_MAXSIZE];
0072 u16 sc;
0073 };
0074
0075 struct nfc_digital_dev;
0076
0077
0078
0079
0080
0081
0082
0083
0084
0085
0086
0087 typedef void (*nfc_digital_cmd_complete_t)(struct nfc_digital_dev *ddev,
0088 void *arg, struct sk_buff *resp);
0089
0090
0091
0092
0093
0094
0095
0096
0097
0098
0099
0100
0101
0102
0103
0104
0105
0106
0107
0108
0109
0110
0111
0112
0113
0114
0115
0116
0117
0118
0119
0120
0121
0122
0123
0124
0125
0126
0127
0128
0129
0130
0131
0132
0133
0134
0135
0136
0137
0138
0139
0140
0141
0142
0143
0144
0145
0146 struct nfc_digital_ops {
0147 int (*in_configure_hw)(struct nfc_digital_dev *ddev, int type,
0148 int param);
0149 int (*in_send_cmd)(struct nfc_digital_dev *ddev, struct sk_buff *skb,
0150 u16 timeout, nfc_digital_cmd_complete_t cb,
0151 void *arg);
0152
0153 int (*tg_configure_hw)(struct nfc_digital_dev *ddev, int type,
0154 int param);
0155 int (*tg_send_cmd)(struct nfc_digital_dev *ddev, struct sk_buff *skb,
0156 u16 timeout, nfc_digital_cmd_complete_t cb,
0157 void *arg);
0158 int (*tg_listen)(struct nfc_digital_dev *ddev, u16 timeout,
0159 nfc_digital_cmd_complete_t cb, void *arg);
0160 int (*tg_listen_mdaa)(struct nfc_digital_dev *ddev,
0161 struct digital_tg_mdaa_params *mdaa_params,
0162 u16 timeout, nfc_digital_cmd_complete_t cb,
0163 void *arg);
0164 int (*tg_listen_md)(struct nfc_digital_dev *ddev, u16 timeout,
0165 nfc_digital_cmd_complete_t cb, void *arg);
0166 int (*tg_get_rf_tech)(struct nfc_digital_dev *ddev, u8 *rf_tech);
0167
0168 int (*switch_rf)(struct nfc_digital_dev *ddev, bool on);
0169 void (*abort_cmd)(struct nfc_digital_dev *ddev);
0170 };
0171
0172 #define NFC_DIGITAL_POLL_MODE_COUNT_MAX 6
0173
0174 typedef int (*digital_poll_t)(struct nfc_digital_dev *ddev, u8 rf_tech);
0175
0176 struct digital_poll_tech {
0177 u8 rf_tech;
0178 digital_poll_t poll_func;
0179 };
0180
0181
0182
0183
0184
0185
0186
0187
0188
0189 #define NFC_DIGITAL_DRV_CAPS_IN_CRC 0x0001
0190 #define NFC_DIGITAL_DRV_CAPS_TG_CRC 0x0002
0191
0192 struct nfc_digital_dev {
0193 struct nfc_dev *nfc_dev;
0194 const struct nfc_digital_ops *ops;
0195
0196 u32 protocols;
0197
0198 int tx_headroom;
0199 int tx_tailroom;
0200
0201 u32 driver_capabilities;
0202 void *driver_data;
0203
0204 struct digital_poll_tech poll_techs[NFC_DIGITAL_POLL_MODE_COUNT_MAX];
0205 u8 poll_tech_count;
0206 u8 poll_tech_index;
0207 struct mutex poll_lock;
0208
0209 struct work_struct cmd_work;
0210 struct work_struct cmd_complete_work;
0211 struct list_head cmd_queue;
0212 struct mutex cmd_lock;
0213
0214 struct delayed_work poll_work;
0215
0216 u8 curr_protocol;
0217 u8 curr_rf_tech;
0218 u8 curr_nfc_dep_pni;
0219 u8 did;
0220 u16 dep_rwt;
0221
0222 u8 local_payload_max;
0223 u8 remote_payload_max;
0224
0225 struct sk_buff *chaining_skb;
0226 struct digital_data_exch *data_exch;
0227
0228 int atn_count;
0229 int nack_count;
0230
0231 struct sk_buff *saved_skb;
0232
0233 u16 target_fsc;
0234
0235 int (*skb_check_crc)(struct sk_buff *skb);
0236 void (*skb_add_crc)(struct sk_buff *skb);
0237 };
0238
0239 struct nfc_digital_dev *nfc_digital_allocate_device(const struct nfc_digital_ops *ops,
0240 __u32 supported_protocols,
0241 __u32 driver_capabilities,
0242 int tx_headroom,
0243 int tx_tailroom);
0244 void nfc_digital_free_device(struct nfc_digital_dev *ndev);
0245 int nfc_digital_register_device(struct nfc_digital_dev *ndev);
0246 void nfc_digital_unregister_device(struct nfc_digital_dev *ndev);
0247
0248 static inline void nfc_digital_set_parent_dev(struct nfc_digital_dev *ndev,
0249 struct device *dev)
0250 {
0251 nfc_set_parent_dev(ndev->nfc_dev, dev);
0252 }
0253
0254 static inline void nfc_digital_set_drvdata(struct nfc_digital_dev *dev,
0255 void *data)
0256 {
0257 dev->driver_data = data;
0258 }
0259
0260 static inline void *nfc_digital_get_drvdata(struct nfc_digital_dev *dev)
0261 {
0262 return dev->driver_data;
0263 }
0264
0265 #endif