Lines Matching +full:miso +full:- +full:gpios
1 // SPDX-License-Identifier: GPL-2.0-only
4 * Copyright (C) 2014-2015 STMicroelectronics SAS. All rights reserved.
19 #include "st-nci.h"
48 gpiod_set_value(phy->gpiod_reset, 0); in st_nci_spi_enable()
50 gpiod_set_value(phy->gpiod_reset, 1); in st_nci_spi_enable()
53 if (phy->ndlc->powered == 0 && phy->irq_active == 0) { in st_nci_spi_enable()
54 enable_irq(phy->spi_dev->irq); in st_nci_spi_enable()
55 phy->irq_active = true; in st_nci_spi_enable()
65 disable_irq_nosync(phy->spi_dev->irq); in st_nci_spi_disable()
66 phy->irq_active = false; in st_nci_spi_disable()
78 struct spi_device *dev = phy->spi_dev; in st_nci_spi_write()
83 .tx_buf = skb->data, in st_nci_spi_write()
85 .len = skb->len, in st_nci_spi_write()
88 if (phy->ndlc->hard_fault != 0) in st_nci_spi_write()
89 return phy->ndlc->hard_fault; in st_nci_spi_write()
93 * We may have received some valuable data on miso line. in st_nci_spi_write()
97 skb_rx = alloc_skb(skb->len, GFP_KERNEL); in st_nci_spi_write()
99 r = -ENOMEM; in st_nci_spi_write()
103 skb_put(skb_rx, skb->len); in st_nci_spi_write()
104 memcpy(skb_rx->data, buf, skb->len); in st_nci_spi_write()
105 ndlc_recv(phy->ndlc, skb_rx); in st_nci_spi_write()
116 * -EREMOTEIO : i2c read error (fatal)
117 * -EBADMSG : frame was incorrect and discarded
118 * -ENOMEM : cannot allocate skb, frame dropped
126 struct spi_device *dev = phy->spi_dev; in st_nci_spi_read()
134 return -EREMOTEIO; in st_nci_spi_read()
138 nfc_err(&dev->dev, "invalid frame len\n"); in st_nci_spi_read()
139 phy->ndlc->hard_fault = 1; in st_nci_spi_read()
140 return -EBADMSG; in st_nci_spi_read()
145 return -ENOMEM; in st_nci_spi_read()
149 memcpy((*skb)->data, buf, ST_NCI_SPI_MIN_SIZE); in st_nci_spi_read()
158 return -EREMOTEIO; in st_nci_spi_read()
162 memcpy((*skb)->data + ST_NCI_SPI_MIN_SIZE, buf, len); in st_nci_spi_read()
179 if (!phy || !phy->ndlc || irq != phy->spi_dev->irq) { in st_nci_irq_thread_fn()
184 dev = phy->spi_dev; in st_nci_irq_thread_fn()
185 dev_dbg(&dev->dev, "IRQ\n"); in st_nci_irq_thread_fn()
187 if (phy->ndlc->hard_fault) in st_nci_irq_thread_fn()
190 if (!phy->ndlc->powered) { in st_nci_irq_thread_fn()
196 if (r == -EREMOTEIO || r == -ENOMEM || r == -EBADMSG) in st_nci_irq_thread_fn()
199 ndlc_recv(phy->ndlc, skb); in st_nci_irq_thread_fn()
213 { "reset-gpios", &reset_gpios, 1 },
222 dev_dbg(&dev->dev, "%s\n", __func__); in st_nci_spi_probe()
223 dev_dbg(&dev->dev, "IRQ: %d\n", dev->irq); in st_nci_spi_probe()
229 return -ENODEV; in st_nci_spi_probe()
232 phy = devm_kzalloc(&dev->dev, sizeof(struct st_nci_spi_phy), in st_nci_spi_probe()
235 return -ENOMEM; in st_nci_spi_probe()
237 phy->spi_dev = dev; in st_nci_spi_probe()
241 r = devm_acpi_dev_add_driver_gpios(&dev->dev, acpi_st_nci_gpios); in st_nci_spi_probe()
243 dev_dbg(&dev->dev, "Unable to add GPIO mapping table\n"); in st_nci_spi_probe()
246 phy->gpiod_reset = devm_gpiod_get(&dev->dev, "reset", GPIOD_OUT_HIGH); in st_nci_spi_probe()
247 if (IS_ERR(phy->gpiod_reset)) { in st_nci_spi_probe()
248 nfc_err(&dev->dev, "Unable to get RESET GPIO\n"); in st_nci_spi_probe()
249 return PTR_ERR(phy->gpiod_reset); in st_nci_spi_probe()
252 phy->se_status.is_ese_present = in st_nci_spi_probe()
253 device_property_read_bool(&dev->dev, "ese-present"); in st_nci_spi_probe()
254 phy->se_status.is_uicc_present = in st_nci_spi_probe()
255 device_property_read_bool(&dev->dev, "uicc-present"); in st_nci_spi_probe()
257 r = ndlc_probe(phy, &spi_phy_ops, &dev->dev, in st_nci_spi_probe()
259 &phy->ndlc, &phy->se_status); in st_nci_spi_probe()
261 nfc_err(&dev->dev, "Unable to register ndlc layer\n"); in st_nci_spi_probe()
265 phy->irq_active = true; in st_nci_spi_probe()
266 r = devm_request_threaded_irq(&dev->dev, dev->irq, NULL, in st_nci_spi_probe()
271 nfc_err(&dev->dev, "Unable to register IRQ handler\n"); in st_nci_spi_probe()
280 dev_dbg(&dev->dev, "%s\n", __func__); in st_nci_spi_remove()
282 ndlc_remove(phy->ndlc); in st_nci_spi_remove()
300 { .compatible = "st,st21nfcb-spi", },