* [PATCH] ADS5121 Fix: put dummy byte to enable fixing EOF bug to first place in order not to break some drivers\nUse ALARM interrupt to avoid waiting for data to come in
@ 2008-12-10 18:49 Matteo Fortini
2008-12-10 23:06 ` Stephen Rothwell
2008-12-11 14:35 ` Josh Boyer
0 siblings, 2 replies; 7+ messages in thread
From: Matteo Fortini @ 2008-12-10 18:49 UTC (permalink / raw)
To: linuxppc-dev; +Cc: John Rigby
From d500e922b750a2bea554d32d8f12937f4da9c80a Mon Sep 17 00:00:00 2001
From: Matteo Fortini <m.fortini@selcomgroup.com>
Date: Wed, 10 Dec 2008 19:33:16 +0100
Subject: [PATCH] Fix: put dummy byte to enable fixing EOF bug to first
place in order not to break some drivers
Use ALARM interrupt to avoid waiting for data to come in
Signed-off-by: Matteo Fortini <m.fortini@selcomgroup.com>
---
drivers/spi/mpc512x_psc_spi.c | 53
++++++++++++++++++++++++-----------------
1 files changed, 31 insertions(+), 22 deletions(-)
diff --git a/drivers/spi/mpc512x_psc_spi.c b/drivers/spi/mpc512x_psc_spi.c
index 1fd7ad4..41faa49 100644
--- a/drivers/spi/mpc512x_psc_spi.c
+++ b/drivers/spi/mpc512x_psc_spi.c
@@ -136,6 +136,7 @@ static void mpc512x_psc_spi_deactivate_cs(struct
spi_device *spi)
(spi->mode & SPI_CS_HIGH) ? 1 : 0);
}
+
/*
* Current MPC5121's have a bug in the SS logic that requires setting
* the EOF flag on the next to last byte instead of the last
@@ -155,7 +156,7 @@ static int mpc512x_psc_spi_transfer_rxtx(struct
spi_device *spi,
if (!tx_buf && !rx_buf && t->len)
return -EINVAL;
-
+
/*
* zero out Mode register 2
* From the ref man:
@@ -175,6 +176,7 @@ static int mpc512x_psc_spi_transfer_rxtx(struct
spi_device *spi,
u8 data;
size_t fifosz;
int rxcount;
+ int txcount;
/*
* The number of bytes that can be sent at a time
@@ -183,41 +185,49 @@ static int mpc512x_psc_spi_transfer_rxtx(struct
spi_device *spi,
fifosz = MPC512x_PSC_FIFO_SZ(in_be32(&fifo->txsz));
count = min(fifosz, len);
+ txcount = 0;
+ /*
+ * Insert a dummy byte before a message of len 1 to make it at
least 2 bytes long
+ * to be able to set EOF correctly
+ */
+ if (t->len == 1) {
+ out_8(&fifo->txdata_8, 0);
+ txcount++;
+ }
for (i = count; i > 0; i--) {
if (len == EOFBYTE || t->len == 1)
setbits32(&fifo->txcmd, MPC512x_PSC_FIFO_EOF);
data = tx_buf ? *tx_buf++ : 0;
out_8(&fifo->txdata_8, data);
- if (t->len == 1)
- out_8(&fifo->txdata_8, 0);
+ txcount++;
len--;
}
INIT_COMPLETION(mps->done);
- /* interrupt on tx fifo empty */
- out_be32(&fifo->txisr, MPC512x_PSC_FIFO_EMPTY);
- out_be32(&fifo->tximr, MPC512x_PSC_FIFO_EMPTY);
+ /* Enable FIFO_ALARM interrupts for rx_fifo */
+ out_be32(&fifo->rxalarm, txcount);
+ out_be32(&fifo->rxisr, MPC512x_PSC_FIFO_ALARM);
+ out_be32(&fifo->rximr, MPC512x_PSC_FIFO_ALARM);
- /* enable transmiter/receiver */
- out_8(&psc->command, MPC52xx_PSC_TX_ENABLE |
MPC52xx_PSC_RX_ENABLE);
-
- wait_for_completion(&mps->done);
+ /* Disable tx_fifo interrupts */
+ out_be32(&fifo->txisr, 0xffffffff);
+ out_be32(&fifo->tximr, 0);
- mdelay(1);
+ out_8(&psc->command, MPC52xx_PSC_TX_ENABLE |
MPC52xx_PSC_RX_ENABLE);
- /* rx fifo should have count bytes in it */
- rxcount = in_be32(&fifo->rxcnt);
- if (rxcount != count)
- mdelay(1);
+ wait_for_completion (&mps->done);
rxcount = in_be32(&fifo->rxcnt);
- if (rxcount != count && t->len != 1)
+ if (rxcount != txcount)
printk(KERN_WARNING "expected %d bytes in rx fifo "
- "but got %d\n", count, rxcount);
-
+ "but got %d\n", txcount, rxcount);
rxcount = min(rxcount, count);
{
+ /* Throw away possible initial dummy byte */
+ if (t->len == 1) {
+ (void)in_8(&fifo->rxdata_8);
+ }
for (i = rxcount; i > 0; i--) {
data = in_8(&fifo->rxdata_8);
if (rx_buf)
@@ -418,10 +428,9 @@ static irqreturn_t mpc512x_psc_spi_isr(int irq,
void *dev_id)
struct mpc512x_psc_fifo __iomem *fifo = mps->fifo;
/* clear interrupt and wake up the work queue */
- if (in_be32(&fifo->txisr)
- & in_be32(&fifo->tximr) & MPC512x_PSC_FIFO_EMPTY) {
- out_be32(&fifo->txisr, MPC512x_PSC_FIFO_EMPTY);
- out_be32(&fifo->tximr, 0);
+ if (in_be32(&fifo->rxisr) & in_be32(&fifo->rximr) &
MPC512x_PSC_FIFO_ALARM) {
+ out_be32(&fifo->rxisr, MPC512x_PSC_FIFO_ALARM);
+ out_be32(&fifo->rximr, 0);
complete(&mps->done);
return IRQ_HANDLED;
}
--
1.5.4.3
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] ADS5121 Fix: put dummy byte to enable fixing EOF bug to first place in order not to break some drivers\nUse ALARM interrupt to avoid waiting for data to come in
2008-12-10 18:49 [PATCH] ADS5121 Fix: put dummy byte to enable fixing EOF bug to first place in order not to break some drivers\nUse ALARM interrupt to avoid waiting for data to come in Matteo Fortini
@ 2008-12-10 23:06 ` Stephen Rothwell
2008-12-11 14:35 ` Josh Boyer
1 sibling, 0 replies; 7+ messages in thread
From: Stephen Rothwell @ 2008-12-10 23:06 UTC (permalink / raw)
To: Matteo Fortini; +Cc: linuxppc-dev, John Rigby
[-- Attachment #1: Type: text/plain, Size: 672 bytes --]
Hi Matteo,
On Wed, 10 Dec 2008 19:49:58 +0100 Matteo Fortini <m.fortini@selcomgroup.com> wrote:
>
> From d500e922b750a2bea554d32d8f12937f4da9c80a Mon Sep 17 00:00:00 2001
> From: Matteo Fortini <m.fortini@selcomgroup.com>
> Date: Wed, 10 Dec 2008 19:33:16 +0100
> Subject: [PATCH] Fix: put dummy byte to enable fixing EOF bug to first
> place in order not to break some drivers
> Use ALARM interrupt to avoid waiting for data to come in
Please don't make unrelated cleanups in patches - it makes it very hard
for the reviewers to do their work.
--
Cheers,
Stephen Rothwell sfr@canb.auug.org.au
http://www.canb.auug.org.au/~sfr/
[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] ADS5121 Fix: put dummy byte to enable fixing EOF bug to first place in order not to break some drivers\nUse ALARM interrupt to avoid waiting for data to come in
2008-12-10 18:49 [PATCH] ADS5121 Fix: put dummy byte to enable fixing EOF bug to first place in order not to break some drivers\nUse ALARM interrupt to avoid waiting for data to come in Matteo Fortini
2008-12-10 23:06 ` Stephen Rothwell
@ 2008-12-11 14:35 ` Josh Boyer
2008-12-11 18:39 ` [RESEND] " Matteo Fortini
1 sibling, 1 reply; 7+ messages in thread
From: Josh Boyer @ 2008-12-11 14:35 UTC (permalink / raw)
To: Matteo Fortini; +Cc: linuxppc-dev, John Rigby
On Wed, 10 Dec 2008 19:49:58 +0100
Matteo Fortini <m.fortini@selcomgroup.com> wrote:
> From d500e922b750a2bea554d32d8f12937f4da9c80a Mon Sep 17 00:00:00 2001
> From: Matteo Fortini <m.fortini@selcomgroup.com>
> Date: Wed, 10 Dec 2008 19:33:16 +0100
> Subject: [PATCH] Fix: put dummy byte to enable fixing EOF bug to first
> place in order not to break some drivers
> Use ALARM interrupt to avoid waiting for data to come in
>
>
> Signed-off-by: Matteo Fortini <m.fortini@selcomgroup.com>
> ---
> drivers/spi/mpc512x_psc_spi.c | 53
> ++++++++++++++++++++++++-----------------
> 1 files changed, 31 insertions(+), 22 deletions(-)
This patch is whitespace corrupted.
josh
^ permalink raw reply [flat|nested] 7+ messages in thread
* [RESEND] [PATCH] ADS5121 Fix: put dummy byte to enable fixing EOF bug to first place in order not to break some drivers\nUse ALARM interrupt to avoid waiting for data to come in
2008-12-11 14:35 ` Josh Boyer
@ 2008-12-11 18:39 ` Matteo Fortini
2008-12-11 18:46 ` Josh Boyer
0 siblings, 1 reply; 7+ messages in thread
From: Matteo Fortini @ 2008-12-11 18:39 UTC (permalink / raw)
To: Josh Boyer; +Cc: linuxppc-dev, John Rigby
This patch is to avoid breaking some drivers, in my case the ADS7846
touchscreen one, which use 1 char messages.
If you put the dummy byte after the 1 char message, you get part of the
answer to the message in the rxbuf of the message, which is thrown away.
The solution is to put the dummy byte before the message, so that the
slave doesn't respond.
It also optimizes the interrupt handling, by using the alarm function of
the FIFO, to wait until the rx FIFO has received enough bytes, instead
of waiting until the tx FIFO is empty.
Signed-off-by: Matteo Fortini <m.fortini@selcomgroup.com>
---
drivers/spi/mpc512x_psc_spi.c | 50
+++++++++++++++++++++++-----------------
1 files changed, 29 insertions(+), 21 deletions(-)
diff --git a/drivers/spi/mpc512x_psc_spi.c b/drivers/spi/mpc512x_psc_spi.c
index 1fd7ad4..eace796 100644
--- a/drivers/spi/mpc512x_psc_spi.c
+++ b/drivers/spi/mpc512x_psc_spi.c
@@ -175,6 +175,7 @@ static int mpc512x_psc_spi_transfer_rxtx(struct
spi_device *spi,
u8 data;
size_t fifosz;
int rxcount;
+ int txcount;
/*
* The number of bytes that can be sent at a time
@@ -183,41 +184,49 @@ static int mpc512x_psc_spi_transfer_rxtx(struct
spi_device *spi,
fifosz = MPC512x_PSC_FIFO_SZ(in_be32(&fifo->txsz));
count = min(fifosz, len);
+ txcount = 0;
+ /*
+ * Insert a dummy byte before a message of len 1 to make it at
least 2 bytes long
+ * to be able to set EOF correctly
+ */
+ if (t->len == 1) {
+ out_8(&fifo->txdata_8, 0);
+ txcount++;
+ }
for (i = count; i > 0; i--) {
if (len == EOFBYTE || t->len == 1)
setbits32(&fifo->txcmd, MPC512x_PSC_FIFO_EOF);
data = tx_buf ? *tx_buf++ : 0;
out_8(&fifo->txdata_8, data);
- if (t->len == 1)
- out_8(&fifo->txdata_8, 0);
+ txcount++;
len--;
}
INIT_COMPLETION(mps->done);
- /* interrupt on tx fifo empty */
- out_be32(&fifo->txisr, MPC512x_PSC_FIFO_EMPTY);
- out_be32(&fifo->tximr, MPC512x_PSC_FIFO_EMPTY);
-
- /* enable transmiter/receiver */
- out_8(&psc->command, MPC52xx_PSC_TX_ENABLE |
MPC52xx_PSC_RX_ENABLE);
+ /* Enable FIFO_ALARM interrupts for rx_fifo */
+ out_be32(&fifo->rxalarm, txcount);
+ out_be32(&fifo->rxisr, MPC512x_PSC_FIFO_ALARM);
+ out_be32(&fifo->rximr, MPC512x_PSC_FIFO_ALARM);
- wait_for_completion(&mps->done);
+ /* Disable tx_fifo interrupts */
+ out_be32(&fifo->txisr, 0xffffffff);
+ out_be32(&fifo->tximr, 0);
- mdelay(1);
+ out_8(&psc->command, MPC52xx_PSC_TX_ENABLE |
MPC52xx_PSC_RX_ENABLE);
- /* rx fifo should have count bytes in it */
- rxcount = in_be32(&fifo->rxcnt);
- if (rxcount != count)
- mdelay(1);
+ wait_for_completion (&mps->done);
rxcount = in_be32(&fifo->rxcnt);
- if (rxcount != count && t->len != 1)
+ if (rxcount != txcount)
printk(KERN_WARNING "expected %d bytes in rx fifo "
- "but got %d\n", count, rxcount);
-
+ "but got %d\n", txcount, rxcount);
rxcount = min(rxcount, count);
{
+ /* Throw away possible initial dummy byte */
+ if (t->len == 1) {
+ (void)in_8(&fifo->rxdata_8);
+ }
for (i = rxcount; i > 0; i--) {
data = in_8(&fifo->rxdata_8);
if (rx_buf)
@@ -418,10 +427,9 @@ static irqreturn_t mpc512x_psc_spi_isr(int irq,
void *dev_id)
struct mpc512x_psc_fifo __iomem *fifo = mps->fifo;
/* clear interrupt and wake up the work queue */
- if (in_be32(&fifo->txisr)
- & in_be32(&fifo->tximr) & MPC512x_PSC_FIFO_EMPTY) {
- out_be32(&fifo->txisr, MPC512x_PSC_FIFO_EMPTY);
- out_be32(&fifo->tximr, 0);
+ if (in_be32(&fifo->rxisr) & in_be32(&fifo->rximr) &
MPC512x_PSC_FIFO_ALARM) {
+ out_be32(&fifo->rxisr, MPC512x_PSC_FIFO_ALARM);
+ out_be32(&fifo->rximr, 0);
complete(&mps->done);
return IRQ_HANDLED;
}
--
1.5.4.3
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [RESEND] [PATCH] ADS5121 Fix: put dummy byte to enable fixing EOF bug to first place in order not to break some drivers\nUse ALARM interrupt to avoid waiting for data to come in
2008-12-11 18:39 ` [RESEND] " Matteo Fortini
@ 2008-12-11 18:46 ` Josh Boyer
2008-12-11 21:57 ` Matteo Fortini
0 siblings, 1 reply; 7+ messages in thread
From: Josh Boyer @ 2008-12-11 18:46 UTC (permalink / raw)
To: Matteo Fortini; +Cc: linuxppc-dev, John Rigby
On Thu, 11 Dec 2008 19:39:21 +0100
Matteo Fortini <m.fortini@selcomgroup.com> wrote:
>
> This patch is to avoid breaking some drivers, in my case the ADS7846
> touchscreen one, which use 1 char messages.
> If you put the dummy byte after the 1 char message, you get part of the
> answer to the message in the rxbuf of the message, which is thrown away.
>
> The solution is to put the dummy byte before the message, so that the
> slave doesn't respond.
>
> It also optimizes the interrupt handling, by using the alarm function of
> the FIFO, to wait until the rx FIFO has received enough bytes, instead
> of waiting until the tx FIFO is empty.
>
>
>
> Signed-off-by: Matteo Fortini <m.fortini@selcomgroup.com>
> ---
> drivers/spi/mpc512x_psc_spi.c | 50
> +++++++++++++++++++++++-----------------
> 1 files changed, 29 insertions(+), 21 deletions(-)
This still seems to be whitespace corrupted. Also, that file doesn't
even exist in any upstream kernel I can find. What tree did you diff
this from?
josh
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [RESEND] [PATCH] ADS5121 Fix: put dummy byte to enable fixing EOF bug to first place in order not to break some drivers\nUse ALARM interrupt to avoid waiting for data to come in
2008-12-11 18:46 ` Josh Boyer
@ 2008-12-11 21:57 ` Matteo Fortini
2008-12-11 22:06 ` Josh Boyer
0 siblings, 1 reply; 7+ messages in thread
From: Matteo Fortini @ 2008-12-11 21:57 UTC (permalink / raw)
To: Josh Boyer; +Cc: linuxppc-dev, John Rigby
I rechecked it and I should have taken away all the only-whitespace changes.
The diffs are from the ads5121 branch from Denx.
Regards,
M
Josh Boyer ha scritto:
> On Thu, 11 Dec 2008 19:39:21 +0100
> Matteo Fortini <m.fortini@selcomgroup.com> wrote:
>
>
>> This patch is to avoid breaking some drivers, in my case the ADS7846
>> touchscreen one, which use 1 char messages.
>> If you put the dummy byte after the 1 char message, you get part of the
>> answer to the message in the rxbuf of the message, which is thrown away.
>>
>> The solution is to put the dummy byte before the message, so that the
>> slave doesn't respond.
>>
>> It also optimizes the interrupt handling, by using the alarm function of
>> the FIFO, to wait until the rx FIFO has received enough bytes, instead
>> of waiting until the tx FIFO is empty.
>>
>>
>>
>> Signed-off-by: Matteo Fortini <m.fortini@selcomgroup.com>
>> ---
>> drivers/spi/mpc512x_psc_spi.c | 50
>> +++++++++++++++++++++++-----------------
>> 1 files changed, 29 insertions(+), 21 deletions(-)
>>
>
> This still seems to be whitespace corrupted. Also, that file doesn't
> even exist in any upstream kernel I can find. What tree did you diff
> this from?
>
> josh
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@ozlabs.org
> https://ozlabs.org/mailman/listinfo/linuxppc-dev
>
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [RESEND] [PATCH] ADS5121 Fix: put dummy byte to enable fixing EOF bug to first place in order not to break some drivers\nUse ALARM interrupt to avoid waiting for data to come in
2008-12-11 21:57 ` Matteo Fortini
@ 2008-12-11 22:06 ` Josh Boyer
0 siblings, 0 replies; 7+ messages in thread
From: Josh Boyer @ 2008-12-11 22:06 UTC (permalink / raw)
To: Matteo Fortini; +Cc: linuxppc-dev, John Rigby
On Thu, 11 Dec 2008 22:57:56 +0100
Matteo Fortini <m.fortini@selcomgroup.com> wrote:
> I rechecked it and I should have taken away all the only-whitespace changes.
No, I mean the patch is corrupted. Your mailer has taken tabs and
turned them into spaces. Thunderbird sucks.
> The diffs are from the ads5121 branch from Denx.
OK. You should send this to Denx then.
josh
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2008-12-11 22:07 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-12-10 18:49 [PATCH] ADS5121 Fix: put dummy byte to enable fixing EOF bug to first place in order not to break some drivers\nUse ALARM interrupt to avoid waiting for data to come in Matteo Fortini
2008-12-10 23:06 ` Stephen Rothwell
2008-12-11 14:35 ` Josh Boyer
2008-12-11 18:39 ` [RESEND] " Matteo Fortini
2008-12-11 18:46 ` Josh Boyer
2008-12-11 21:57 ` Matteo Fortini
2008-12-11 22:06 ` Josh Boyer
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).