Lines Matching +full:c +full:- +full:phy

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Driver for NXP PN533 NFC Chip - I2C transport layer
5 * Copyright (C) 2011 Instituto Nokia de Tecnologia
6 * Copyright (C) 2012-2013 Tieto Poland
7 * Copyright (C) 2016 HALE electronic
39 struct pn533_i2c_phy *phy = dev->phy; in pn533_i2c_send_ack() local
40 struct i2c_client *client = phy->i2c_dev; in pn533_i2c_send_ack()
50 struct pn533_i2c_phy *phy = dev->phy; in pn533_i2c_send_frame() local
51 struct i2c_client *client = phy->i2c_dev; in pn533_i2c_send_frame()
54 if (phy->hard_fault != 0) in pn533_i2c_send_frame()
55 return phy->hard_fault; in pn533_i2c_send_frame()
57 if (phy->priv == NULL) in pn533_i2c_send_frame()
58 phy->priv = dev; in pn533_i2c_send_frame()
60 phy->aborted = false; in pn533_i2c_send_frame()
63 out->data, out->len, false); in pn533_i2c_send_frame()
65 rc = i2c_master_send(client, out->data, out->len); in pn533_i2c_send_frame()
67 if (rc == -EREMOTEIO) { /* Retry, chip was in power down */ in pn533_i2c_send_frame()
69 rc = i2c_master_send(client, out->data, out->len); in pn533_i2c_send_frame()
73 if (rc != out->len) in pn533_i2c_send_frame()
74 rc = -EREMOTEIO; in pn533_i2c_send_frame()
84 struct pn533_i2c_phy *phy = dev->phy; in pn533_i2c_abort_cmd() local
86 phy->aborted = true; in pn533_i2c_abort_cmd()
92 pn533_recv_frame(phy->priv, NULL, -ENOENT); in pn533_i2c_abort_cmd()
95 static int pn533_i2c_read(struct pn533_i2c_phy *phy, struct sk_buff **skb) in pn533_i2c_read() argument
97 struct i2c_client *client = phy->i2c_dev; in pn533_i2c_read()
105 return -ENOMEM; in pn533_i2c_read()
109 nfc_err(&client->dev, "cannot read. r=%d len=%d\n", r, len); in pn533_i2c_read()
111 return -EREMOTEIO; in pn533_i2c_read()
114 if (!((*skb)->data[0] & 0x01)) { in pn533_i2c_read()
115 nfc_err(&client->dev, "READY flag not set"); in pn533_i2c_read()
117 return -EBUSY; in pn533_i2c_read()
123 skb_trim(*skb, phy->priv->ops->rx_frame_size((*skb)->data)); in pn533_i2c_read()
130 struct pn533_i2c_phy *phy = data; in pn533_i2c_irq_thread_fn() local
134 if (!phy || irq != phy->i2c_dev->irq) { in pn533_i2c_irq_thread_fn()
139 if (phy->hard_fault != 0) in pn533_i2c_irq_thread_fn()
142 r = pn533_i2c_read(phy, &skb); in pn533_i2c_irq_thread_fn()
143 if (r == -EREMOTEIO) { in pn533_i2c_irq_thread_fn()
144 phy->hard_fault = r; in pn533_i2c_irq_thread_fn()
146 pn533_recv_frame(phy->priv, NULL, -EREMOTEIO); in pn533_i2c_irq_thread_fn()
149 } else if ((r == -ENOMEM) || (r == -EBADMSG) || (r == -EBUSY)) { in pn533_i2c_irq_thread_fn()
153 if (!phy->aborted) in pn533_i2c_irq_thread_fn()
154 pn533_recv_frame(phy->priv, skb, 0); in pn533_i2c_irq_thread_fn()
169 struct pn533_i2c_phy *phy; in pn533_i2c_probe() local
173 if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { in pn533_i2c_probe()
174 nfc_err(&client->dev, "Need I2C_FUNC_I2C\n"); in pn533_i2c_probe()
175 return -ENODEV; in pn533_i2c_probe()
178 phy = devm_kzalloc(&client->dev, sizeof(struct pn533_i2c_phy), in pn533_i2c_probe()
180 if (!phy) in pn533_i2c_probe()
181 return -ENOMEM; in pn533_i2c_probe()
183 phy->i2c_dev = client; in pn533_i2c_probe()
184 i2c_set_clientdata(client, phy); in pn533_i2c_probe()
188 phy, &i2c_phy_ops, NULL, in pn533_i2c_probe()
189 &phy->i2c_dev->dev); in pn533_i2c_probe()
194 phy->priv = priv; in pn533_i2c_probe()
195 r = pn532_i2c_nfc_alloc(priv, PN533_NO_TYPE_B_PROTOCOLS, &client->dev); in pn533_i2c_probe()
199 r = request_threaded_irq(client->irq, NULL, pn533_i2c_irq_thread_fn, in pn533_i2c_probe()
202 PN533_I2C_DRIVER_NAME, phy); in pn533_i2c_probe()
204 nfc_err(&client->dev, "Unable to register IRQ handler\n"); in pn533_i2c_probe()
212 r = nfc_register_device(priv->nfc_dev); in pn533_i2c_probe()
219 free_irq(client->irq, phy); in pn533_i2c_probe()
222 nfc_free_device(priv->nfc_dev); in pn533_i2c_probe()
225 pn53x_common_clean(phy->priv); in pn533_i2c_probe()
232 struct pn533_i2c_phy *phy = i2c_get_clientdata(client); in pn533_i2c_remove() local
234 free_irq(client->irq, phy); in pn533_i2c_remove()
236 pn53x_unregister_nfc(phy->priv); in pn533_i2c_remove()
237 pn53x_common_clean(phy->priv); in pn533_i2c_remove()
243 * NOTE: The use of the compatibles with the trailing "...-i2c" is
246 { .compatible = "nxp,pn533-i2c", },
247 { .compatible = "nxp,pn532-i2c", },