From: jason77.wang@gmail.com (Jason Wang)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] spi/omap2_mcspi: disable and enable chan between each SPI transfer
Date: Thu, 24 Jun 2010 20:12:45 +0800 [thread overview]
Message-ID: <1277381565-6305-1-git-send-email-jason77.wang@gmail.com> (raw)
In current design, the SPI channel is always enable during the period
of handling a SPI message, it is risky when more than one SPI transfer
are included in a message. Current working route like that:
[
SPI channel enable
configure channel
handle transfer #1
configure channel
handle transfer #2
...
SPI channel disable
]
If we can disable channel before configure it and reenable
channel after it is configured, it will be more safe.
The commit a330ce2 "omap2_mcspi: Flush posted writes" make this risk
to a real problem for ads7846 driver on omap3530evm. The
ads7846 driver will send a SPI messge which includes,
[
TX_ONLY transfer (1 byte)
RX_ONLY transfer (2 bytes)
TX_ONLY transfer (1 byte)
RX_ONLY transfer (2 bytes)
]
If we don't add disable/reenable channel between TX and RX transfers,
the RX transfer will get wrong datas sent from slave.
Signed-off-by: Jason Wang <jason77.wang@gmail.com>
---
drivers/spi/omap2_mcspi.c | 16 ++++++----------
1 files changed, 6 insertions(+), 10 deletions(-)
diff --git a/drivers/spi/omap2_mcspi.c b/drivers/spi/omap2_mcspi.c
index b3a94ca..1e3cb7b 100644
--- a/drivers/spi/omap2_mcspi.c
+++ b/drivers/spi/omap2_mcspi.c
@@ -408,7 +408,6 @@ omap2_mcspi_txrx_dma(struct spi_device *spi, struct spi_transfer *xfer)
count -= (word_len <= 8) ? 2 :
(word_len <= 16) ? 4 :
/* word_len <= 32 */ 8;
- omap2_mcspi_set_enable(spi, 1);
return count;
}
}
@@ -430,8 +429,10 @@ omap2_mcspi_txrx_dma(struct spi_device *spi, struct spi_transfer *xfer)
(word_len <= 16) ? 2 :
/* word_len <= 32 */ 4;
}
- omap2_mcspi_set_enable(spi, 1);
}
+
+ omap2_mcspi_set_enable(spi, 0);
+
return count;
}
@@ -517,8 +518,6 @@ omap2_mcspi_txrx_pio(struct spi_device *spi, struct spi_transfer *xfer)
goto out;
}
c = 0;
- } else if (c == 0 && tx == NULL) {
- omap2_mcspi_set_enable(spi, 0);
}
*rx++ = __raw_readl(rx_reg);
@@ -570,8 +569,6 @@ omap2_mcspi_txrx_pio(struct spi_device *spi, struct spi_transfer *xfer)
goto out;
}
c = 0;
- } else if (c == 0 && tx == NULL) {
- omap2_mcspi_set_enable(spi, 0);
}
*rx++ = __raw_readl(rx_reg);
@@ -623,8 +620,6 @@ omap2_mcspi_txrx_pio(struct spi_device *spi, struct spi_transfer *xfer)
goto out;
}
c = 0;
- } else if (c == 0 && tx == NULL) {
- omap2_mcspi_set_enable(spi, 0);
}
*rx++ = __raw_readl(rx_reg);
@@ -646,7 +641,7 @@ omap2_mcspi_txrx_pio(struct spi_device *spi, struct spi_transfer *xfer)
dev_err(&spi->dev, "EOT timed out\n");
}
out:
- omap2_mcspi_set_enable(spi, 1);
+ omap2_mcspi_set_enable(spi, 0);
return count - c;
}
@@ -894,7 +889,6 @@ static void omap2_mcspi_work(struct work_struct *work)
cs = spi->controller_state;
cd = spi->controller_data;
- omap2_mcspi_set_enable(spi, 1);
list_for_each_entry(t, &m->transfers, transfer_list) {
if (t->tx_buf == NULL && t->rx_buf == NULL && t->len) {
status = -EINVAL;
@@ -931,6 +925,8 @@ static void omap2_mcspi_work(struct work_struct *work)
mcspi_write_chconf0(spi, chconf);
+ omap2_mcspi_set_enable(spi, 1);
+
if (t->len) {
unsigned count;
--
1.5.6.5
next reply other threads:[~2010-06-24 12:12 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-24 12:12 Jason Wang [this message]
2010-06-24 14:32 ` [PATCH] spi/omap2_mcspi: disable and enable chan between each SPI transfer roman.tereshonkov at nokia.com
2010-06-25 12:05 ` jason
2010-06-27 6:08 ` Grant Likely
2010-06-27 13:12 ` jason
2010-06-24 15:12 ` Grant Likely
2010-06-25 12:30 ` jason
2010-06-28 9:12 ` roman.tereshonkov at nokia.com
2010-06-28 12:59 ` jason
2010-06-29 10:20 ` roman.tereshonkov at nokia.com
2010-06-29 13:17 ` jason
2010-07-01 11:58 ` jason
2010-07-01 13:57 ` roman.tereshonkov at nokia.com
2010-07-01 23:35 ` jason
2010-07-03 11:21 ` jason
2010-07-13 13:26 ` jason
2010-07-13 18:09 ` roman.tereshonkov at nokia.com
2010-07-13 23:48 ` jason
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=1277381565-6305-1-git-send-email-jason77.wang@gmail.com \
--to=jason77.wang@gmail.com \
--cc=linux-arm-kernel@lists.infradead.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).