Lines Matching +full:nfc +full:- +full:uart
1 // SPDX-License-Identifier: GPL-2.0+
3 * Driver for NXP PN532 NFC Chip - UART transport layer
13 #include <linux/nfc.h>
38 * no-op to the chip.
52 struct pn532_uart_phy *pn532 = dev->phy; in pn532_uart_send_frame()
56 out->data, out->len, false); in pn532_uart_send_frame()
58 pn532->cur_out_buf = out; in pn532_uart_send_frame()
59 if (pn532->send_wakeup) { in pn532_uart_send_frame()
60 err = serdev_device_write(pn532->serdev, in pn532_uart_send_frame()
67 if (pn532->send_wakeup == PN532_SEND_LAST_WAKEUP) in pn532_uart_send_frame()
68 pn532->send_wakeup = PN532_SEND_NO_WAKEUP; in pn532_uart_send_frame()
70 err = serdev_device_write(pn532->serdev, out->data, out->len, in pn532_uart_send_frame()
75 mod_timer(&pn532->cmd_timeout, HZ / 40 + jiffies); in pn532_uart_send_frame()
84 struct pn532_uart_phy *pn532 = dev->phy; in pn532_uart_send_ack()
87 err = serdev_device_write(pn532->serdev, ack, sizeof(ack), in pn532_uart_send_ack()
100 pn533_recv_frame(dev, NULL, -ENOENT); in pn532_uart_abort_cmd()
105 struct pn532_uart_phy *pn532 = dev->phy; in pn532_dev_up()
108 ret = serdev_device_open(pn532->serdev); in pn532_dev_up()
112 pn532->send_wakeup = PN532_SEND_LAST_WAKEUP; in pn532_dev_up()
118 struct pn532_uart_phy *pn532 = dev->phy; in pn532_dev_down()
120 serdev_device_close(pn532->serdev); in pn532_dev_down()
121 pn532->send_wakeup = PN532_SEND_WAKEUP; in pn532_dev_down()
138 pn532_uart_send_frame(dev->priv, dev->cur_out_buf); in pn532_cmd_timeout()
155 for (i = 0; i + PN533_STD_FRAME_ACK_SIZE <= skb->len; i++) { in pn532_uart_rx_is_frame()
156 std = (struct pn533_std_frame *)&skb->data[i]; in pn532_uart_rx_is_frame()
158 if (std->start_frame != cpu_to_be16(PN533_STD_FRAME_SOF)) in pn532_uart_rx_is_frame()
162 switch (std->datalen) { in pn532_uart_rx_is_frame()
164 if (std->datalen_checksum == 0xff) { in pn532_uart_rx_is_frame()
171 if ((std->datalen_checksum == 0xff) && in pn532_uart_rx_is_frame()
172 (skb->len >= in pn532_uart_rx_is_frame()
180 ext = (struct pn533_ext_frame *)&skb->data[i]; in pn532_uart_rx_is_frame()
181 frame_len = be16_to_cpu(ext->datalen); in pn532_uart_rx_is_frame()
182 if (skb->len >= frame_len + in pn532_uart_rx_is_frame()
191 frame_len = std->datalen; in pn532_uart_rx_is_frame()
192 if (skb->len >= frame_len + in pn532_uart_rx_is_frame()
212 del_timer(&dev->cmd_timeout); in pn532_receive_buf()
214 skb_put_u8(dev->recv_skb, *data++); in pn532_receive_buf()
215 if (!pn532_uart_rx_is_frame(dev->recv_skb)) in pn532_receive_buf()
218 pn533_recv_frame(dev->priv, dev->recv_skb, 0); in pn532_receive_buf()
219 dev->recv_skb = alloc_skb(PN532_UART_SKB_BUFF_LEN, GFP_KERNEL); in pn532_receive_buf()
220 if (!dev->recv_skb) in pn532_receive_buf()
244 err = -ENOMEM; in pn532_uart_probe()
249 pn532->recv_skb = alloc_skb(PN532_UART_SKB_BUFF_LEN, GFP_KERNEL); in pn532_uart_probe()
250 if (!pn532->recv_skb) in pn532_uart_probe()
253 pn532->serdev = serdev; in pn532_uart_probe()
258 dev_err(&serdev->dev, "Unable to open device\n"); in pn532_uart_probe()
264 err = -EINVAL; in pn532_uart_probe()
269 pn532->send_wakeup = PN532_SEND_WAKEUP; in pn532_uart_probe()
270 timer_setup(&pn532->cmd_timeout, pn532_cmd_timeout, 0); in pn532_uart_probe()
274 &pn532->serdev->dev); in pn532_uart_probe()
280 pn532->priv = priv; in pn532_uart_probe()
281 err = pn533_finalize_setup(pn532->priv); in pn532_uart_probe()
286 err = pn53x_register_nfc(priv, PN533_NO_TYPE_B_PROTOCOLS, &serdev->dev); in pn532_uart_probe()
288 pn53x_common_clean(pn532->priv); in pn532_uart_probe()
295 pn53x_common_clean(pn532->priv); in pn532_uart_probe()
299 kfree_skb(pn532->recv_skb); in pn532_uart_probe()
310 pn53x_unregister_nfc(pn532->priv); in pn532_uart_remove()
312 pn53x_common_clean(pn532->priv); in pn532_uart_remove()
313 del_timer_sync(&pn532->cmd_timeout); in pn532_uart_remove()
314 kfree_skb(pn532->recv_skb); in pn532_uart_remove()
330 MODULE_DESCRIPTION("PN532 UART driver");