From: Grant Likely <grant.likely@secretlab.ca>
To: Mingkai Hu <Mingkai.hu@freescale.com>
Cc: linuxppc-dev@ozlabs.org, kumar.gala@freescale.com,
spi-devel-general@lists.sourceforge.net
Subject: Re: [PATCH 1/2] eSPI: change the read behavior of the SPIRF
Date: Fri, 24 Dec 2010 01:55:13 -0700 [thread overview]
Message-ID: <20101224085513.GF5544@angua.secretlab.ca> (raw)
In-Reply-To: <1292894768-6737-1-git-send-email-Mingkai.hu@freescale.com>
On Tue, Dec 21, 2010 at 09:26:07AM +0800, Mingkai Hu wrote:
> The user must read N bytes of SPIRF (1 <= N <= 4) that do not exceed the
> amount of data in the receive FIFO, so read the SPIRF byte by byte when
> the data in receive FIFO is less than 4 bytes.
>
> On Simics, when read N bytes that exceed the amout of data in receive
> FIFO, we can't read the data out, that is we can't clear the rx FIFO,
> then the CPU will loop on the espi rx interrupt.
>
> Signed-off-by: Mingkai Hu <Mingkai.hu@freescale.com>
Applied to merge branch for 2.6.27, thanks.
g.
> ---
> The patch 2/2 is againsted on this patch, so I resent this patch again
> for convience which sent several weeks ago.
>
> drivers/spi/spi_fsl_espi.c | 19 ++++++++++++++++---
> 1 files changed, 16 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/spi/spi_fsl_espi.c b/drivers/spi/spi_fsl_espi.c
> index e3b4f64..ae78926 100644
> --- a/drivers/spi/spi_fsl_espi.c
> +++ b/drivers/spi/spi_fsl_espi.c
> @@ -507,16 +507,29 @@ void fsl_espi_cpu_irq(struct mpc8xxx_spi *mspi, u32 events)
>
> /* We need handle RX first */
> if (events & SPIE_NE) {
> - u32 rx_data;
> + u32 rx_data, tmp;
> + u8 rx_data_8;
>
> /* Spin until RX is done */
> while (SPIE_RXCNT(events) < min(4, mspi->len)) {
> cpu_relax();
> events = mpc8xxx_spi_read_reg(®_base->event);
> }
> - mspi->len -= 4;
>
> - rx_data = mpc8xxx_spi_read_reg(®_base->receive);
> + if (mspi->len >= 4) {
> + rx_data = mpc8xxx_spi_read_reg(®_base->receive);
> + } else {
> + tmp = mspi->len;
> + rx_data = 0;
> + while (tmp--) {
> + rx_data_8 = in_8((u8 *)®_base->receive);
> + rx_data |= (rx_data_8 << (tmp * 8));
> + }
> +
> + rx_data <<= (4 - mspi->len) * 8;
> + }
> +
> + mspi->len -= 4;
>
> if (mspi->rx)
> mspi->get_rx(rx_data, mspi);
> --
> 1.6.4
>
>
prev parent reply other threads:[~2010-12-24 8:55 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-21 1:26 [PATCH 1/2] eSPI: change the read behavior of the SPIRF Mingkai Hu
2010-12-24 8:55 ` Grant Likely [this message]
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=20101224085513.GF5544@angua.secretlab.ca \
--to=grant.likely@secretlab.ca \
--cc=Mingkai.hu@freescale.com \
--cc=kumar.gala@freescale.com \
--cc=linuxppc-dev@ozlabs.org \
--cc=spi-devel-general@lists.sourceforge.net \
/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).