.. | .. |
---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-or-later */ |
---|
1 | 2 | /* |
---|
2 | 3 | * Driver for NXP PN533 NFC Chip |
---|
3 | 4 | * |
---|
4 | 5 | * Copyright (C) 2011 Instituto Nokia de Tecnologia |
---|
5 | 6 | * 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/>. |
---|
19 | 7 | */ |
---|
20 | 8 | |
---|
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 |
---|
25 | 14 | |
---|
26 | 15 | #define PN533_ALL_PROTOCOLS (NFC_PROTO_JEWEL_MASK | NFC_PROTO_MIFARE_MASK |\ |
---|
27 | 16 | NFC_PROTO_FELICA_MASK | NFC_PROTO_ISO14443_MASK |\ |
---|
.. | .. |
---|
55 | 44 | |
---|
56 | 45 | /* Preamble (1), SoPC (2), ACK Code (2), Postamble (1) */ |
---|
57 | 46 | #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 |
---|
58 | 52 | #define PN533_STD_FRAME_CHECKSUM(f) (f->data[f->datalen]) |
---|
59 | 53 | #define PN533_STD_FRAME_POSTAMBLE(f) (f->data[f->datalen + 1]) |
---|
60 | 54 | /* Half start code (3), LEN (4) should be 0xffff for extended frame */ |
---|
.. | .. |
---|
82 | 76 | #define PN533_CMD_IN_ATR 0x50 |
---|
83 | 77 | #define PN533_CMD_IN_RELEASE 0x52 |
---|
84 | 78 | #define PN533_CMD_IN_JUMP_FOR_DEP 0x56 |
---|
| 79 | +#define PN533_CMD_IN_AUTOPOLL 0x60 |
---|
85 | 80 | |
---|
86 | 81 | #define PN533_CMD_TG_INIT_AS_TARGET 0x8c |
---|
87 | 82 | #define PN533_CMD_TG_GET_DATA 0x86 |
---|
.. | .. |
---|
96 | 91 | #define PN533_CMD_MI_MASK 0x40 |
---|
97 | 92 | #define PN533_CMD_RET_SUCCESS 0x00 |
---|
98 | 93 | |
---|
| 94 | +#define PN533_FRAME_DATALEN_ACK 0x00 |
---|
| 95 | +#define PN533_FRAME_DATALEN_ERROR 0x01 |
---|
| 96 | +#define PN533_FRAME_DATALEN_EXTENDED 0xFF |
---|
99 | 97 | |
---|
100 | 98 | enum pn533_protocol_type { |
---|
101 | 99 | PN533_PROTO_REQ_ACK_RESP = 0, |
---|
.. | .. |
---|
219 | 217 | struct sk_buff *out); |
---|
220 | 218 | int (*send_ack)(struct pn533 *dev, gfp_t flags); |
---|
221 | 219 | 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); |
---|
222 | 229 | }; |
---|
223 | 230 | |
---|
224 | 231 | |
---|
225 | | -struct pn533 *pn533_register_device(u32 device_type, |
---|
226 | | - u32 protocols, |
---|
| 232 | +struct pn533 *pn53x_common_init(u32 device_type, |
---|
227 | 233 | enum pn533_protocol_type protocol_type, |
---|
228 | 234 | void *phy, |
---|
229 | 235 | struct pn533_phy_ops *phy_ops, |
---|
230 | 236 | struct pn533_frame_ops *fops, |
---|
231 | | - struct device *dev, |
---|
232 | | - struct device *parent); |
---|
| 237 | + struct device *dev); |
---|
233 | 238 | |
---|
234 | 239 | int pn533_finalize_setup(struct pn533 *dev); |
---|
235 | | -void pn533_unregister_device(struct pn533 *priv); |
---|
| 240 | +void pn53x_common_clean(struct pn533 *priv); |
---|
236 | 241 | 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); |
---|
237 | 247 | |
---|
238 | 248 | bool pn533_rx_frame_is_cmd_response(struct pn533 *dev, void *frame); |
---|
239 | 249 | bool pn533_rx_frame_is_ack(void *_frame); |
---|