linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/5] include/linux/spi/dw_spi.h: enable platform specific chipselect.
@ 2010-01-21 11:40 George Shore
       [not found] ` <1264074052-2214-1-git-send-email-george-ofzTHo7+kyPpQY4QmZNtDQ@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: George Shore @ 2010-01-21 11:40 UTC (permalink / raw)
  To: spi-devel-list, Grant Likely, David Brownell; +Cc: George Shore

The driver core allows for a platform-specific chipselect assert/deassert
function, however the chipselect function in the core doesn't take advantage
of this fact.

This enables the use of a custom function, should it be defined.

Signed-off-by: George Shore <george-ofzTHo7+kyPpQY4QmZNtDQ@public.gmane.org>
---
 include/linux/spi/dw_spi.h |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/include/linux/spi/dw_spi.h b/include/linux/spi/dw_spi.h
index 1a127a3..cc813f9 100644
--- a/include/linux/spi/dw_spi.h
+++ b/include/linux/spi/dw_spi.h
@@ -172,6 +172,10 @@ static inline void spi_chip_sel(struct dw_spi *dws, u16 cs)
 {
 	if (cs > dws->num_cs)
 		return;
+
+	if (dws->cs_control)
+		dws->cs_control(1);
+
 	dw_writel(dws, ser, 1 << cs);
 }
 
-- 
1.6.6.264.gd0743


------------------------------------------------------------------------------
Throughout its 18-year history, RSA Conference consistently attracts the
world's best and brightest in the field, creating opportunities for Conference
attendees to learn about information security's most important issues through
interactions with peers, luminaries and emerging and established companies.
http://p.sf.net/sfu/rsaconf-dev2dev

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/5] spi/dw_spi: add return value to empty mrst_spi_debugfs_init()
       [not found] ` <1264074052-2214-1-git-send-email-george-ofzTHo7+kyPpQY4QmZNtDQ@public.gmane.org>
@ 2010-01-21 11:40   ` George Shore
  2010-01-21 11:40   ` [PATCH 3/5] spi/dw_spi: fixed a spelling typo in a warning message George Shore
                     ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: George Shore @ 2010-01-21 11:40 UTC (permalink / raw)
  To: spi-devel-list, Grant Likely, David Brownell; +Cc: George Shore

As per the function signature.

Signed-off-by: George Shore <george-ofzTHo7+kyPpQY4QmZNtDQ@public.gmane.org>
---
 drivers/spi/dw_spi.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/drivers/spi/dw_spi.c b/drivers/spi/dw_spi.c
index f713af8..56d53a5 100644
--- a/drivers/spi/dw_spi.c
+++ b/drivers/spi/dw_spi.c
@@ -152,6 +152,7 @@ static void mrst_spi_debugfs_remove(struct dw_spi *dws)
 #else
 static inline int mrst_spi_debugfs_init(struct dw_spi *dws)
 {
+	return 0;
 }
 
 static inline void mrst_spi_debugfs_remove(struct dw_spi *dws)
-- 
1.6.6.264.gd0743


------------------------------------------------------------------------------
Throughout its 18-year history, RSA Conference consistently attracts the
world's best and brightest in the field, creating opportunities for Conference
attendees to learn about information security's most important issues through
interactions with peers, luminaries and emerging and established companies.
http://p.sf.net/sfu/rsaconf-dev2dev

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 3/5] spi/dw_spi: fixed a spelling typo in a warning message.
       [not found] ` <1264074052-2214-1-git-send-email-george-ofzTHo7+kyPpQY4QmZNtDQ@public.gmane.org>
  2010-01-21 11:40   ` [PATCH 2/5] spi/dw_spi: add return value to empty mrst_spi_debugfs_init() George Shore
@ 2010-01-21 11:40   ` George Shore
  2010-01-21 11:40   ` [PATCH 4/5] spi/dw_spi.c: remove conditional from 'poll_transfer' George Shore
                     ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: George Shore @ 2010-01-21 11:40 UTC (permalink / raw)
  To: spi-devel-list, Grant Likely, David Brownell; +Cc: George Shore

Signed-off-by: George Shore <george-ofzTHo7+kyPpQY4QmZNtDQ@public.gmane.org>
---
 drivers/spi/dw_spi.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/spi/dw_spi.c b/drivers/spi/dw_spi.c
index 56d53a5..01292da 100644
--- a/drivers/spi/dw_spi.c
+++ b/drivers/spi/dw_spi.c
@@ -169,7 +169,7 @@ static void wait_till_not_busy(struct dw_spi *dws)
 			return;
 	}
 	dev_err(&dws->master->dev,
-		"DW SPI: Stutus keeps busy for 1000us after a read/write!\n");
+		"DW SPI: Status keeps busy for 1000us after a read/write!\n");
 }
 
 static void flush(struct dw_spi *dws)
-- 
1.6.6.264.gd0743


------------------------------------------------------------------------------
Throughout its 18-year history, RSA Conference consistently attracts the
world's best and brightest in the field, creating opportunities for Conference
attendees to learn about information security's most important issues through
interactions with peers, luminaries and emerging and established companies.
http://p.sf.net/sfu/rsaconf-dev2dev

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 4/5] spi/dw_spi.c: remove conditional from 'poll_transfer'.
       [not found] ` <1264074052-2214-1-git-send-email-george-ofzTHo7+kyPpQY4QmZNtDQ@public.gmane.org>
  2010-01-21 11:40   ` [PATCH 2/5] spi/dw_spi: add return value to empty mrst_spi_debugfs_init() George Shore
  2010-01-21 11:40   ` [PATCH 3/5] spi/dw_spi: fixed a spelling typo in a warning message George Shore
@ 2010-01-21 11:40   ` George Shore
  2010-01-21 11:40   ` [PATCH 5/5] spi/dw_spi.c: conditional transfer mode changes George Shore
  2010-01-21 14:49   ` [PATCH 1/5] include/linux/spi/dw_spi.h: enable platform specific chipselect Grant Likely
  4 siblings, 0 replies; 6+ messages in thread
From: George Shore @ 2010-01-21 11:40 UTC (permalink / raw)
  To: spi-devel-list, Grant Likely, David Brownell; +Cc: George Shore

The 'poll_transfer' function employs a conditional to test whether the
transmit buffer is valid; in doing so, on a receive operation no data is
clocked out, thus no data is clocked in and ultimately errors appear.

This removes the conditional as the transmit function will be set to a null
writer when the transmit buffer is invalid, allowing the driver to clock 0x00
out to the device to receive data from the device.

Signed-off-by: George Shore <george-ofzTHo7+kyPpQY4QmZNtDQ@public.gmane.org>
---
 drivers/spi/dw_spi.c |    7 ++-----
 1 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/spi/dw_spi.c b/drivers/spi/dw_spi.c
index 01292da..4f91554 100644
--- a/drivers/spi/dw_spi.c
+++ b/drivers/spi/dw_spi.c
@@ -408,12 +408,9 @@ static irqreturn_t dw_spi_irq(int irq, void *dev_id)
 /* Must be called inside pump_transfers() */
 static void poll_transfer(struct dw_spi *dws)
 {
-	if (dws->tx) {
-		while (dws->write(dws))
-			dws->read(dws);
-	}
+	while (dws->write(dws))
+		dws->read(dws);
 
-	dws->read(dws);
 	transfer_complete(dws);
 }
 
-- 
1.6.6.264.gd0743


------------------------------------------------------------------------------
Throughout its 18-year history, RSA Conference consistently attracts the
world's best and brightest in the field, creating opportunities for Conference
attendees to learn about information security's most important issues through
interactions with peers, luminaries and emerging and established companies.
http://p.sf.net/sfu/rsaconf-dev2dev

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 5/5] spi/dw_spi.c: conditional transfer mode changes
       [not found] ` <1264074052-2214-1-git-send-email-george-ofzTHo7+kyPpQY4QmZNtDQ@public.gmane.org>
                     ` (2 preceding siblings ...)
  2010-01-21 11:40   ` [PATCH 4/5] spi/dw_spi.c: remove conditional from 'poll_transfer' George Shore
@ 2010-01-21 11:40   ` George Shore
  2010-01-21 14:49   ` [PATCH 1/5] include/linux/spi/dw_spi.h: enable platform specific chipselect Grant Likely
  4 siblings, 0 replies; 6+ messages in thread
From: George Shore @ 2010-01-21 11:40 UTC (permalink / raw)
  To: spi-devel-list, Grant Likely, David Brownell; +Cc: George Shore

This allows the switching between transfer modes between 'transmit only',
'receive only' and 'transmit and receive' modes. Due to the design of the SPI
block, changing transfer modes requires that the block be disabled; in doing
so the chipselect line is inherently deasserted and (usually) the attached
device discards its state. Consequentially, switching modes requires that a
platform-specific chipselect function has been defined so that the chipselect
is not dropped during the change.

Signed-off-by: George Shore <george-ofzTHo7+kyPpQY4QmZNtDQ@public.gmane.org>
---
 drivers/spi/dw_spi.c |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/drivers/spi/dw_spi.c b/drivers/spi/dw_spi.c
index 4f91554..a1c195f 100644
--- a/drivers/spi/dw_spi.c
+++ b/drivers/spi/dw_spi.c
@@ -537,6 +537,22 @@ static void pump_transfers(unsigned long data)
 	}
 	message->state = RUNNING_STATE;
 
+	/*
+	 * Adjust transfer mode if necessary. Requires platform dependent
+	 * chipselect mechanism.
+	 */
+	if (dws->cs_control) {
+		if (dws->rx && dws->tx)
+			chip->tmode = 0x00;
+		else if (dws->rx)
+			chip->tmode = 0x02;
+		else
+			chip->tmode = 0x01;
+
+		cr0 &= ~(0x3 << SPI_MODE_OFFSET);
+		cr0 |= (chip->tmode << SPI_TMOD_OFFSET);
+	}
+
 	/* Check if current transfer is a DMA transaction */
 	dws->dma_mapped = map_dma_buffers(dws);
 
-- 
1.6.6.264.gd0743


------------------------------------------------------------------------------
Throughout its 18-year history, RSA Conference consistently attracts the
world's best and brightest in the field, creating opportunities for Conference
attendees to learn about information security's most important issues through
interactions with peers, luminaries and emerging and established companies.
http://p.sf.net/sfu/rsaconf-dev2dev

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/5] include/linux/spi/dw_spi.h: enable platform specific chipselect.
       [not found] ` <1264074052-2214-1-git-send-email-george-ofzTHo7+kyPpQY4QmZNtDQ@public.gmane.org>
                     ` (3 preceding siblings ...)
  2010-01-21 11:40   ` [PATCH 5/5] spi/dw_spi.c: conditional transfer mode changes George Shore
@ 2010-01-21 14:49   ` Grant Likely
  4 siblings, 0 replies; 6+ messages in thread
From: Grant Likely @ 2010-01-21 14:49 UTC (permalink / raw)
  To: George Shore; +Cc: spi-devel-list, David Brownell

On Thu, Jan 21, 2010 at 4:40 AM, George Shore <george-ofzTHo7+kyPpQY4QmZNtDQ@public.gmane.org> wrote:
> The driver core allows for a platform-specific chipselect assert/deassert
> function, however the chipselect function in the core doesn't take advantage
> of this fact.
>
> This enables the use of a custom function, should it be defined.
>
> Signed-off-by: George Shore <george-ofzTHo7+kyPpQY4QmZNtDQ@public.gmane.org>

all 5 patches merged.

> ---
>  include/linux/spi/dw_spi.h |    4 ++++
>  1 files changed, 4 insertions(+), 0 deletions(-)
>
> diff --git a/include/linux/spi/dw_spi.h b/include/linux/spi/dw_spi.h
> index 1a127a3..cc813f9 100644
> --- a/include/linux/spi/dw_spi.h
> +++ b/include/linux/spi/dw_spi.h
> @@ -172,6 +172,10 @@ static inline void spi_chip_sel(struct dw_spi *dws, u16 cs)
>  {
>        if (cs > dws->num_cs)
>                return;
> +
> +       if (dws->cs_control)
> +               dws->cs_control(1);
> +
>        dw_writel(dws, ser, 1 << cs);
>  }
>
> --
> 1.6.6.264.gd0743
>
>



-- 
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.

------------------------------------------------------------------------------
Throughout its 18-year history, RSA Conference consistently attracts the
world's best and brightest in the field, creating opportunities for Conference
attendees to learn about information security's most important issues through
interactions with peers, luminaries and emerging and established companies.
http://p.sf.net/sfu/rsaconf-dev2dev

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2010-01-21 14:49 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-01-21 11:40 [PATCH 1/5] include/linux/spi/dw_spi.h: enable platform specific chipselect George Shore
     [not found] ` <1264074052-2214-1-git-send-email-george-ofzTHo7+kyPpQY4QmZNtDQ@public.gmane.org>
2010-01-21 11:40   ` [PATCH 2/5] spi/dw_spi: add return value to empty mrst_spi_debugfs_init() George Shore
2010-01-21 11:40   ` [PATCH 3/5] spi/dw_spi: fixed a spelling typo in a warning message George Shore
2010-01-21 11:40   ` [PATCH 4/5] spi/dw_spi.c: remove conditional from 'poll_transfer' George Shore
2010-01-21 11:40   ` [PATCH 5/5] spi/dw_spi.c: conditional transfer mode changes George Shore
2010-01-21 14:49   ` [PATCH 1/5] include/linux/spi/dw_spi.h: enable platform specific chipselect Grant Likely

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).