* [PATCH] [SPI] SPI100k: Fix 8-bit and RX-only transfers
@ 2010-05-30 0:12 Cory Maccarrone
2010-07-20 3:22 ` Cory Maccarrone
2010-08-02 15:34 ` Cory Maccarrone
0 siblings, 2 replies; 4+ messages in thread
From: Cory Maccarrone @ 2010-05-30 0:12 UTC (permalink / raw)
To: spi-devel-general; +Cc: linux-omap, Cory Maccarrone
This change fixes 8-bit transfers and RX-only transfers. The
SPI100k framework requires minimum 16-bit words to be written, so 8-bit
transfers must be shited by 8 bits and sent out as a 16-bit word.
Additionally, receive-only transfers were failing due to the
perceived need to fill the TX buffer with something. This is in
fact not needed.
Signed-off-by: Cory Maccarrone <darkstar6262@gmail.com>
---
drivers/spi/omap_spi_100k.c | 23 ++++++++++++-----------
1 files changed, 12 insertions(+), 11 deletions(-)
diff --git a/drivers/spi/omap_spi_100k.c b/drivers/spi/omap_spi_100k.c
index 24668b3..9bd1c92 100644
--- a/drivers/spi/omap_spi_100k.c
+++ b/drivers/spi/omap_spi_100k.c
@@ -141,7 +141,12 @@ static void spi100k_write_data(struct spi_master *master, int len, int data)
{
struct omap1_spi100k *spi100k = spi_master_get_devdata(master);
- /* write 16-bit word */
+ /* write 16-bit word, shifting 8-bit data if necessary */
+ if (len <= 8) {
+ data <<= 8;
+ len = 16;
+ }
+
spi100k_enable_clock(master);
writew( data , spi100k->base + SPI_TX_MSB);
@@ -162,6 +167,10 @@ static int spi100k_read_data(struct spi_master *master, int len)
int dataH,dataL;
struct omap1_spi100k *spi100k = spi_master_get_devdata(master);
+ /* Always do at least 16 bits */
+ if (len <= 8)
+ len = 16;
+
spi100k_enable_clock(master);
writew(SPI_CTRL_SEN(0) |
SPI_CTRL_WORD_SIZE(len) |
@@ -214,10 +223,6 @@ omap1_spi100k_txrx_pio(struct spi_device *spi, struct spi_transfer *xfer)
c = count;
word_len = cs->word_len;
- /* RX_ONLY mode needs dummy data in TX reg */
- if (xfer->tx_buf == NULL)
- spi100k_write_data(spi->master,word_len, 0);
-
if (word_len <= 8) {
u8 *rx;
const u8 *tx;
@@ -227,9 +232,9 @@ omap1_spi100k_txrx_pio(struct spi_device *spi, struct spi_transfer *xfer)
do {
c-=1;
if (xfer->tx_buf != NULL)
- spi100k_write_data(spi->master,word_len, *tx);
+ spi100k_write_data(spi->master, word_len, *tx++);
if (xfer->rx_buf != NULL)
- *rx = spi100k_read_data(spi->master,word_len);
+ *rx++ = spi100k_read_data(spi->master, word_len);
} while(c);
} else if (word_len <= 16) {
u16 *rx;
@@ -380,10 +385,6 @@ static void omap1_spi100k_work(struct work_struct *work)
if (t->len) {
unsigned count;
- /* RX_ONLY mode needs dummy data in TX reg */
- if (t->tx_buf == NULL)
- spi100k_write_data(spi->master, 8, 0);
-
count = omap1_spi100k_txrx_pio(spi, t);
m->actual_length += count;
--
1.7.0.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] [SPI] SPI100k: Fix 8-bit and RX-only transfers
2010-05-30 0:12 [PATCH] [SPI] SPI100k: Fix 8-bit and RX-only transfers Cory Maccarrone
@ 2010-07-20 3:22 ` Cory Maccarrone
2010-08-02 15:34 ` Cory Maccarrone
1 sibling, 0 replies; 4+ messages in thread
From: Cory Maccarrone @ 2010-07-20 3:22 UTC (permalink / raw)
To: spi-devel-general; +Cc: linux-omap, Cory Maccarrone
On Sat, May 29, 2010 at 6:12 PM, Cory Maccarrone <darkstar6262@gmail.com> wrote:
> This change fixes 8-bit transfers and RX-only transfers. The
> SPI100k framework requires minimum 16-bit words to be written, so 8-bit
> transfers must be shited by 8 bits and sent out as a 16-bit word.
>
> Additionally, receive-only transfers were failing due to the
> perceived need to fill the TX buffer with something. This is in
> fact not needed.
>
> Signed-off-by: Cory Maccarrone <darkstar6262@gmail.com>
> ---
> drivers/spi/omap_spi_100k.c | 23 ++++++++++++-----------
> 1 files changed, 12 insertions(+), 11 deletions(-)
>
Any feedback on this? I submitted it almost two months ago and
nothing seems to have happened with it. Can this be included in the
next RC?
- Cory
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] [SPI] SPI100k: Fix 8-bit and RX-only transfers
2010-05-30 0:12 [PATCH] [SPI] SPI100k: Fix 8-bit and RX-only transfers Cory Maccarrone
2010-07-20 3:22 ` Cory Maccarrone
@ 2010-08-02 15:34 ` Cory Maccarrone
2010-08-10 16:40 ` Grant Likely
1 sibling, 1 reply; 4+ messages in thread
From: Cory Maccarrone @ 2010-08-02 15:34 UTC (permalink / raw)
To: spi-devel-general, Grant Likely; +Cc: linux-omap, Cory Maccarrone
On Sat, May 29, 2010 at 5:12 PM, Cory Maccarrone <darkstar6262@gmail.com> wrote:
> This change fixes 8-bit transfers and RX-only transfers. The
> SPI100k framework requires minimum 16-bit words to be written, so 8-bit
> transfers must be shited by 8 bits and sent out as a 16-bit word.
>
> Additionally, receive-only transfers were failing due to the
> perceived need to fill the TX buffer with something. This is in
> fact not needed.
>
> Signed-off-by: Cory Maccarrone <darkstar6262@gmail.com>
> ---
> drivers/spi/omap_spi_100k.c | 23 ++++++++++++-----------
> 1 files changed, 12 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/spi/omap_spi_100k.c b/drivers/spi/omap_spi_100k.c
> index 24668b3..9bd1c92 100644
> --- a/drivers/spi/omap_spi_100k.c
> +++ b/drivers/spi/omap_spi_100k.c
> @@ -141,7 +141,12 @@ static void spi100k_write_data(struct spi_master *master, int len, int data)
> {
> struct omap1_spi100k *spi100k = spi_master_get_devdata(master);
>
> - /* write 16-bit word */
> + /* write 16-bit word, shifting 8-bit data if necessary */
> + if (len <= 8) {
> + data <<= 8;
> + len = 16;
> + }
> +
> spi100k_enable_clock(master);
> writew( data , spi100k->base + SPI_TX_MSB);
>
> @@ -162,6 +167,10 @@ static int spi100k_read_data(struct spi_master *master, int len)
> int dataH,dataL;
> struct omap1_spi100k *spi100k = spi_master_get_devdata(master);
>
> + /* Always do at least 16 bits */
> + if (len <= 8)
> + len = 16;
> +
> spi100k_enable_clock(master);
> writew(SPI_CTRL_SEN(0) |
> SPI_CTRL_WORD_SIZE(len) |
> @@ -214,10 +223,6 @@ omap1_spi100k_txrx_pio(struct spi_device *spi, struct spi_transfer *xfer)
> c = count;
> word_len = cs->word_len;
>
> - /* RX_ONLY mode needs dummy data in TX reg */
> - if (xfer->tx_buf == NULL)
> - spi100k_write_data(spi->master,word_len, 0);
> -
> if (word_len <= 8) {
> u8 *rx;
> const u8 *tx;
> @@ -227,9 +232,9 @@ omap1_spi100k_txrx_pio(struct spi_device *spi, struct spi_transfer *xfer)
> do {
> c-=1;
> if (xfer->tx_buf != NULL)
> - spi100k_write_data(spi->master,word_len, *tx);
> + spi100k_write_data(spi->master, word_len, *tx++);
> if (xfer->rx_buf != NULL)
> - *rx = spi100k_read_data(spi->master,word_len);
> + *rx++ = spi100k_read_data(spi->master, word_len);
> } while(c);
> } else if (word_len <= 16) {
> u16 *rx;
> @@ -380,10 +385,6 @@ static void omap1_spi100k_work(struct work_struct *work)
> if (t->len) {
> unsigned count;
>
> - /* RX_ONLY mode needs dummy data in TX reg */
> - if (t->tx_buf == NULL)
> - spi100k_write_data(spi->master, 8, 0);
> -
> count = omap1_spi100k_txrx_pio(spi, t);
> m->actual_length += count;
>
> --
> 1.7.0.4
>
>
Adding another name to the list.
- Cory
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] [SPI] SPI100k: Fix 8-bit and RX-only transfers
2010-08-02 15:34 ` Cory Maccarrone
@ 2010-08-10 16:40 ` Grant Likely
0 siblings, 0 replies; 4+ messages in thread
From: Grant Likely @ 2010-08-10 16:40 UTC (permalink / raw)
To: Cory Maccarrone; +Cc: spi-devel-general, linux-omap
On Mon, Aug 2, 2010 at 9:34 AM, Cory Maccarrone <darkstar6262@gmail.com> wrote:
> On Sat, May 29, 2010 at 5:12 PM, Cory Maccarrone <darkstar6262@gmail.com> wrote:
>> This change fixes 8-bit transfers and RX-only transfers. The
>> SPI100k framework requires minimum 16-bit words to be written, so 8-bit
>> transfers must be shited by 8 bits and sent out as a 16-bit word.
>>
>> Additionally, receive-only transfers were failing due to the
>> perceived need to fill the TX buffer with something. This is in
>> fact not needed.
>>
>> Signed-off-by: Cory Maccarrone <darkstar6262@gmail.com>
>> ---
>> drivers/spi/omap_spi_100k.c | 23 ++++++++++++-----------
>> 1 files changed, 12 insertions(+), 11 deletions(-)
>>[...]
>
> Adding another name to the list.
This patch has been in my next-spi branch for a while, and I have a
pull request pending out to Linus.
g.
--
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-08-10 16:40 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-05-30 0:12 [PATCH] [SPI] SPI100k: Fix 8-bit and RX-only transfers Cory Maccarrone
2010-07-20 3:22 ` Cory Maccarrone
2010-08-02 15:34 ` Cory Maccarrone
2010-08-10 16:40 ` 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).