aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/net/nfc/nci_core.h6
-rw-r--r--net/nfc/nci/spi.c7
2 files changed, 12 insertions, 1 deletions
diff --git a/include/net/nfc/nci_core.h b/include/net/nfc/nci_core.h
index 77880bdf93a8..5a1572a34c49 100644
--- a/include/net/nfc/nci_core.h
+++ b/include/net/nfc/nci_core.h
@@ -394,6 +394,12 @@ struct nci_spi {
394 394
395 unsigned int xfer_udelay; /* microseconds delay between 395 unsigned int xfer_udelay; /* microseconds delay between
396 transactions */ 396 transactions */
397
398 unsigned int xfer_speed_hz; /*
399 * SPI clock frequency
400 * 0 => default clock
401 */
402
397 u8 acknowledge_mode; 403 u8 acknowledge_mode;
398 404
399 struct completion req_completion; 405 struct completion req_completion;
diff --git a/net/nfc/nci/spi.c b/net/nfc/nci/spi.c
index 25153d0e33cf..d904cd2f1442 100644
--- a/net/nfc/nci/spi.c
+++ b/net/nfc/nci/spi.c
@@ -58,6 +58,7 @@ static int __nci_spi_send(struct nci_spi *nspi, struct sk_buff *skb,
58 } 58 }
59 t.cs_change = cs_change; 59 t.cs_change = cs_change;
60 t.delay_usecs = nspi->xfer_udelay; 60 t.delay_usecs = nspi->xfer_udelay;
61 t.speed_hz = nspi->xfer_speed_hz;
61 62
62 spi_message_init(&m); 63 spi_message_init(&m);
63 spi_message_add_tail(&t, &m); 64 spi_message_add_tail(&t, &m);
@@ -144,7 +145,8 @@ struct nci_spi *nci_spi_allocate_spi(struct spi_device *spi,
144 145
145 nspi->acknowledge_mode = acknowledge_mode; 146 nspi->acknowledge_mode = acknowledge_mode;
146 nspi->xfer_udelay = delay; 147 nspi->xfer_udelay = delay;
147 148 /* Use controller max SPI speed by default */
149 nspi->xfer_speed_hz = 0;
148 nspi->spi = spi; 150 nspi->spi = spi;
149 nspi->ndev = ndev; 151 nspi->ndev = ndev;
150 init_completion(&nspi->req_completion); 152 init_completion(&nspi->req_completion);
@@ -197,12 +199,14 @@ static struct sk_buff *__nci_spi_read(struct nci_spi *nspi)
197 tx.tx_buf = req; 199 tx.tx_buf = req;
198 tx.len = 2; 200 tx.len = 2;
199 tx.cs_change = 0; 201 tx.cs_change = 0;
202 tx.speed_hz = nspi->xfer_speed_hz;
200 spi_message_add_tail(&tx, &m); 203 spi_message_add_tail(&tx, &m);
201 204
202 memset(&rx, 0, sizeof(struct spi_transfer)); 205 memset(&rx, 0, sizeof(struct spi_transfer));
203 rx.rx_buf = resp_hdr; 206 rx.rx_buf = resp_hdr;
204 rx.len = 2; 207 rx.len = 2;
205 rx.cs_change = 1; 208 rx.cs_change = 1;
209 rx.speed_hz = nspi->xfer_speed_hz;
206 spi_message_add_tail(&rx, &m); 210 spi_message_add_tail(&rx, &m);
207 211
208 ret = spi_sync(nspi->spi, &m); 212 ret = spi_sync(nspi->spi, &m);
@@ -226,6 +230,7 @@ static struct sk_buff *__nci_spi_read(struct nci_spi *nspi)
226 rx.len = rx_len; 230 rx.len = rx_len;
227 rx.cs_change = 0; 231 rx.cs_change = 0;
228 rx.delay_usecs = nspi->xfer_udelay; 232 rx.delay_usecs = nspi->xfer_udelay;
233 rx.speed_hz = nspi->xfer_speed_hz;
229 spi_message_add_tail(&rx, &m); 234 spi_message_add_tail(&rx, &m);
230 235
231 ret = spi_sync(nspi->spi, &m); 236 ret = spi_sync(nspi->spi, &m);