devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Vincent Cuissard <cuissard-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org>
To: linux-nfc-hn68Rpc1hR1g9hUCZPvPmw@public.gmane.org
Cc: devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Vincent Cuissard
	<cuissard-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org>
Subject: [PATCH v3 7/9] NFC: NCI: allow spi driver to choose transfer clock
Date: Fri, 23 Oct 2015 14:23:04 +0200	[thread overview]
Message-ID: <1445602986-3254-8-git-send-email-cuissard@marvell.com> (raw)
In-Reply-To: <1445602986-3254-1-git-send-email-cuissard-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org>

In some cases low level drivers might want to update the SPI transfer clock
(e.g. during firmware download).

This patch adds this support. Without any modification the driver will use the
default SPI clock (from pdata or device tree).

Signed-off-by: Vincent Cuissard <cuissard-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org>
---
 include/net/nfc/nci_core.h | 4 ++++
 net/nfc/nci/spi.c          | 7 ++++++-
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/include/net/nfc/nci_core.h b/include/net/nfc/nci_core.h
index f0bb5e7..0f91e09 100644
--- a/include/net/nfc/nci_core.h
+++ b/include/net/nfc/nci_core.h
@@ -381,6 +381,10 @@ struct nci_spi {
 
 	unsigned int		xfer_udelay;	/* microseconds delay between
 						  transactions */
+
+	unsigned int		xfer_speed_hz; /* SPI clock frequency
+						 0 => default clock */
+
 	u8			acknowledge_mode;
 
 	struct completion	req_completion;
diff --git a/net/nfc/nci/spi.c b/net/nfc/nci/spi.c
index 25153d0..d904cd2 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,
 	}
 	t.cs_change = cs_change;
 	t.delay_usecs = nspi->xfer_udelay;
+	t.speed_hz = nspi->xfer_speed_hz;
 
 	spi_message_init(&m);
 	spi_message_add_tail(&t, &m);
@@ -144,7 +145,8 @@ struct nci_spi *nci_spi_allocate_spi(struct spi_device *spi,
 
 	nspi->acknowledge_mode = acknowledge_mode;
 	nspi->xfer_udelay = delay;
-
+	/* Use controller max SPI speed by default */
+	nspi->xfer_speed_hz = 0;
 	nspi->spi = spi;
 	nspi->ndev = ndev;
 	init_completion(&nspi->req_completion);
@@ -197,12 +199,14 @@ static struct sk_buff *__nci_spi_read(struct nci_spi *nspi)
 	tx.tx_buf = req;
 	tx.len = 2;
 	tx.cs_change = 0;
+	tx.speed_hz = nspi->xfer_speed_hz;
 	spi_message_add_tail(&tx, &m);
 
 	memset(&rx, 0, sizeof(struct spi_transfer));
 	rx.rx_buf = resp_hdr;
 	rx.len = 2;
 	rx.cs_change = 1;
+	rx.speed_hz = nspi->xfer_speed_hz;
 	spi_message_add_tail(&rx, &m);
 
 	ret = spi_sync(nspi->spi, &m);
@@ -226,6 +230,7 @@ static struct sk_buff *__nci_spi_read(struct nci_spi *nspi)
 	rx.len = rx_len;
 	rx.cs_change = 0;
 	rx.delay_usecs = nspi->xfer_udelay;
+	rx.speed_hz = nspi->xfer_speed_hz;
 	spi_message_add_tail(&rx, &m);
 
 	ret = spi_sync(nspi->spi, &m);
-- 
2.2.0.33.gc18b867

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2015-10-23 12:23 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-23 12:22 [PATCH v3 0/9] Marvell NFC drivers for i2c and spi Vincent Cuissard
     [not found] ` <1445602986-3254-1-git-send-email-cuissard-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org>
2015-10-23 12:22   ` [PATCH v3 1/9] NFC: nfcmrvl: remove unneeded version defines Vincent Cuissard
2015-10-23 12:22   ` [PATCH v3 2/9] NFC: NCI: export nci_send_frame and nci_send_cmd function Vincent Cuissard
2015-10-23 12:23   ` [PATCH v3 3/9] NFC: nfcmrvl: add firmware download support Vincent Cuissard
2015-10-23 12:23   ` [PATCH v3 4/9] NFC: nfcmrvl: configure head/tail room values per low level drivers Vincent Cuissard
2015-10-23 12:23   ` [PATCH v3 5/9] NFC: nfcmrvl: add i2c driver Vincent Cuissard
2015-10-23 12:23   ` [PATCH v3 6/9] NFC: NCI: move generic spi driver to a module Vincent Cuissard
2015-10-23 12:23   ` Vincent Cuissard [this message]
2015-10-23 12:23   ` [PATCH v3 8/9] NFC: nfcmrvl: add spi driver Vincent Cuissard
2015-10-23 12:23   ` [PATCH v3 9/9] NFC: nfcmrvl: update device tree bindings for Marvell NFC Vincent Cuissard
     [not found]     ` <1445602986-3254-10-git-send-email-cuissard-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org>
2015-10-23 13:17       ` Rob Herring
     [not found]         ` <CAL_JsqJ7a+MNA8BPseGu_L+3yMr=jK-3YiSo+HZkoqJq2XpWgg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-10-23 13:47           ` Vincent Cuissard
2015-10-23 21:34             ` Rob Herring
     [not found]             ` <CE8AEFC3-74F2-44B9-B7B6-EBDD1966FB3A-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org>
2015-10-23 23:00               ` [linux-nfc] " Samuel Ortiz
     [not found]                 ` <20151023230034.GA23609-nKCvNrh56OoJmsy6czSMtA@public.gmane.org>
2015-10-24  0:15                   ` Vincent Cuissard
     [not found]                     ` <3CAE2505-C17A-4A4F-A222-0F0D814B8491-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org>
2015-10-24  0:22                       ` Samuel Ortiz
     [not found]                         ` <20151024002202.GC23609-nKCvNrh56OoJmsy6czSMtA@public.gmane.org>
2015-10-24  0:23                           ` Vincent Cuissard

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1445602986-3254-8-git-send-email-cuissard@marvell.com \
    --to=cuissard-eyqppykdwxrbdgjk7y7tuq@public.gmane.org \
    --cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-nfc-hn68Rpc1hR1g9hUCZPvPmw@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).