hc
2024-05-13 9d77db3c730780c8ef5ccd4b66403ff5675cfe4e
kernel/drivers/nfc/pn533/pn533.h
....@@ -1,27 +1,16 @@
1
+/* SPDX-License-Identifier: GPL-2.0-or-later */
12 /*
23 * Driver for NXP PN533 NFC Chip
34 *
45 * Copyright (C) 2011 Instituto Nokia de Tecnologia
56 * Copyright (C) 2012-2013 Tieto Poland
6
- *
7
- * This program is free software; you can redistribute it and/or modify
8
- * it under the terms of the GNU General Public License as published by
9
- * the Free Software Foundation; either version 2 of the License, or
10
- * (at your option) any later version.
11
- *
12
- * This program is distributed in the hope that it will be useful,
13
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
- * GNU General Public License for more details.
16
- *
17
- * You should have received a copy of the GNU General Public License
18
- * along with this program; if not, see <http://www.gnu.org/licenses/>.
197 */
208
21
-#define PN533_DEVICE_STD 0x1
22
-#define PN533_DEVICE_PASORI 0x2
23
-#define PN533_DEVICE_ACR122U 0x3
24
-#define PN533_DEVICE_PN532 0x4
9
+#define PN533_DEVICE_STD 0x1
10
+#define PN533_DEVICE_PASORI 0x2
11
+#define PN533_DEVICE_ACR122U 0x3
12
+#define PN533_DEVICE_PN532 0x4
13
+#define PN533_DEVICE_PN532_AUTOPOLL 0x5
2514
2615 #define PN533_ALL_PROTOCOLS (NFC_PROTO_JEWEL_MASK | NFC_PROTO_MIFARE_MASK |\
2716 NFC_PROTO_FELICA_MASK | NFC_PROTO_ISO14443_MASK |\
....@@ -55,6 +44,11 @@
5544
5645 /* Preamble (1), SoPC (2), ACK Code (2), Postamble (1) */
5746 #define PN533_STD_FRAME_ACK_SIZE 6
47
+/*
48
+ * Preamble (1), SoPC (2), Packet Length (1), Packet Length Checksum (1),
49
+ * Specific Application Level Error Code (1) , Postamble (1)
50
+ */
51
+#define PN533_STD_ERROR_FRAME_SIZE 8
5852 #define PN533_STD_FRAME_CHECKSUM(f) (f->data[f->datalen])
5953 #define PN533_STD_FRAME_POSTAMBLE(f) (f->data[f->datalen + 1])
6054 /* Half start code (3), LEN (4) should be 0xffff for extended frame */
....@@ -82,6 +76,7 @@
8276 #define PN533_CMD_IN_ATR 0x50
8377 #define PN533_CMD_IN_RELEASE 0x52
8478 #define PN533_CMD_IN_JUMP_FOR_DEP 0x56
79
+#define PN533_CMD_IN_AUTOPOLL 0x60
8580
8681 #define PN533_CMD_TG_INIT_AS_TARGET 0x8c
8782 #define PN533_CMD_TG_GET_DATA 0x86
....@@ -96,6 +91,9 @@
9691 #define PN533_CMD_MI_MASK 0x40
9792 #define PN533_CMD_RET_SUCCESS 0x00
9893
94
+#define PN533_FRAME_DATALEN_ACK 0x00
95
+#define PN533_FRAME_DATALEN_ERROR 0x01
96
+#define PN533_FRAME_DATALEN_EXTENDED 0xFF
9997
10098 enum pn533_protocol_type {
10199 PN533_PROTO_REQ_ACK_RESP = 0,
....@@ -219,21 +217,33 @@
219217 struct sk_buff *out);
220218 int (*send_ack)(struct pn533 *dev, gfp_t flags);
221219 void (*abort_cmd)(struct pn533 *priv, gfp_t flags);
220
+ /*
221
+ * dev_up and dev_down are optional.
222
+ * They are used to inform the phy layer that the nfc chip
223
+ * is going to be really used very soon. The phy layer can then
224
+ * bring up it's interface to the chip and have it suspended for power
225
+ * saving reasons otherwise.
226
+ */
227
+ int (*dev_up)(struct pn533 *priv);
228
+ int (*dev_down)(struct pn533 *priv);
222229 };
223230
224231
225
-struct pn533 *pn533_register_device(u32 device_type,
226
- u32 protocols,
232
+struct pn533 *pn53x_common_init(u32 device_type,
227233 enum pn533_protocol_type protocol_type,
228234 void *phy,
229235 struct pn533_phy_ops *phy_ops,
230236 struct pn533_frame_ops *fops,
231
- struct device *dev,
232
- struct device *parent);
237
+ struct device *dev);
233238
234239 int pn533_finalize_setup(struct pn533 *dev);
235
-void pn533_unregister_device(struct pn533 *priv);
240
+void pn53x_common_clean(struct pn533 *priv);
236241 void pn533_recv_frame(struct pn533 *dev, struct sk_buff *skb, int status);
242
+int pn532_i2c_nfc_alloc(struct pn533 *priv, u32 protocols,
243
+ struct device *parent);
244
+int pn53x_register_nfc(struct pn533 *priv, u32 protocols,
245
+ struct device *parent);
246
+void pn53x_unregister_nfc(struct pn533 *priv);
237247
238248 bool pn533_rx_frame_is_cmd_response(struct pn533 *dev, void *frame);
239249 bool pn533_rx_frame_is_ack(void *_frame);