.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * Driver for NXP PN533 NFC Chip - I2C transport layer |
---|
3 | 4 | * |
---|
4 | 5 | * Copyright (C) 2011 Instituto Nokia de Tecnologia |
---|
5 | 6 | * Copyright (C) 2012-2013 Tieto Poland |
---|
6 | 7 | * Copyright (C) 2016 HALE electronic |
---|
7 | | - * |
---|
8 | | - * |
---|
9 | | - * This program is free software; you can redistribute it and/or modify |
---|
10 | | - * it under the terms of the GNU General Public License as published by |
---|
11 | | - * the Free Software Foundation; either version 2 of the License, or |
---|
12 | | - * (at your option) any later version. |
---|
13 | | - * |
---|
14 | | - * This program is distributed in the hope that it will be useful, |
---|
15 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
16 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
17 | | - * GNU General Public License for more details. |
---|
18 | | - * |
---|
19 | | - * You should have received a copy of the GNU General Public License |
---|
20 | | - * along with this program; if not, see <http://www.gnu.org/licenses/>. |
---|
21 | 8 | */ |
---|
22 | 9 | |
---|
23 | 10 | #include <linux/device.h> |
---|
.. | .. |
---|
206 | 193 | phy->i2c_dev = client; |
---|
207 | 194 | i2c_set_clientdata(client, phy); |
---|
208 | 195 | |
---|
209 | | - priv = pn533_register_device(PN533_DEVICE_PN532, |
---|
210 | | - PN533_NO_TYPE_B_PROTOCOLS, |
---|
211 | | - PN533_PROTO_REQ_ACK_RESP, |
---|
212 | | - phy, &i2c_phy_ops, NULL, |
---|
213 | | - &phy->i2c_dev->dev, |
---|
214 | | - &client->dev); |
---|
| 196 | + priv = pn53x_common_init(PN533_DEVICE_PN532, |
---|
| 197 | + PN533_PROTO_REQ_ACK_RESP, |
---|
| 198 | + phy, &i2c_phy_ops, NULL, |
---|
| 199 | + &phy->i2c_dev->dev); |
---|
215 | 200 | |
---|
216 | 201 | if (IS_ERR(priv)) { |
---|
217 | 202 | r = PTR_ERR(priv); |
---|
.. | .. |
---|
219 | 204 | } |
---|
220 | 205 | |
---|
221 | 206 | phy->priv = priv; |
---|
| 207 | + r = pn532_i2c_nfc_alloc(priv, PN533_NO_TYPE_B_PROTOCOLS, &client->dev); |
---|
| 208 | + if (r) |
---|
| 209 | + goto nfc_alloc_err; |
---|
222 | 210 | |
---|
223 | 211 | r = request_threaded_irq(client->irq, NULL, pn533_i2c_irq_thread_fn, |
---|
224 | 212 | IRQF_TRIGGER_FALLING | |
---|
.. | .. |
---|
233 | 221 | if (r) |
---|
234 | 222 | goto fn_setup_err; |
---|
235 | 223 | |
---|
236 | | - return 0; |
---|
| 224 | + r = nfc_register_device(priv->nfc_dev); |
---|
| 225 | + if (r) |
---|
| 226 | + goto fn_setup_err; |
---|
| 227 | + |
---|
| 228 | + return r; |
---|
237 | 229 | |
---|
238 | 230 | fn_setup_err: |
---|
239 | 231 | free_irq(client->irq, phy); |
---|
240 | 232 | |
---|
241 | 233 | irq_rqst_err: |
---|
242 | | - pn533_unregister_device(phy->priv); |
---|
| 234 | + nfc_free_device(priv->nfc_dev); |
---|
| 235 | + |
---|
| 236 | +nfc_alloc_err: |
---|
| 237 | + pn53x_common_clean(phy->priv); |
---|
243 | 238 | |
---|
244 | 239 | return r; |
---|
245 | 240 | } |
---|
.. | .. |
---|
252 | 247 | |
---|
253 | 248 | free_irq(client->irq, phy); |
---|
254 | 249 | |
---|
255 | | - pn533_unregister_device(phy->priv); |
---|
| 250 | + pn53x_unregister_nfc(phy->priv); |
---|
| 251 | + pn53x_common_clean(phy->priv); |
---|
256 | 252 | |
---|
257 | 253 | return 0; |
---|
258 | 254 | } |
---|
259 | 255 | |
---|
260 | 256 | static const struct of_device_id of_pn533_i2c_match[] = { |
---|
| 257 | + { .compatible = "nxp,pn532", }, |
---|
| 258 | + /* |
---|
| 259 | + * NOTE: The use of the compatibles with the trailing "...-i2c" is |
---|
| 260 | + * deprecated and will be removed. |
---|
| 261 | + */ |
---|
261 | 262 | { .compatible = "nxp,pn533-i2c", }, |
---|
262 | 263 | { .compatible = "nxp,pn532-i2c", }, |
---|
263 | 264 | {}, |
---|
.. | .. |
---|
273 | 274 | static struct i2c_driver pn533_i2c_driver = { |
---|
274 | 275 | .driver = { |
---|
275 | 276 | .name = PN533_I2C_DRIVER_NAME, |
---|
276 | | - .owner = THIS_MODULE, |
---|
277 | 277 | .of_match_table = of_match_ptr(of_pn533_i2c_match), |
---|
278 | 278 | }, |
---|
279 | 279 | .probe = pn533_i2c_probe, |
---|