From patchwork Tue Dec 21 01:26:07 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mingkai Hu X-Patchwork-Id: 76251 X-Patchwork-Delegate: grant.likely@secretlab.ca Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from bilbo.ozlabs.org (localhost [127.0.0.1]) by ozlabs.org (Postfix) with ESMTP id C49CAB72E2 for ; Tue, 21 Dec 2010 13:05:59 +1100 (EST) Received: by ozlabs.org (Postfix) id 1AA2AB7088; Tue, 21 Dec 2010 13:05:49 +1100 (EST) Delivered-To: linuxppc-dev@ozlabs.org Received: from AM1EHSOBE004.bigfish.com (am1ehsobe004.messaging.microsoft.com [213.199.154.207]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (Client CN "mail.global.frontbridge.com", Issuer "Cybertrust SureServer Standard Validation CA" (verified OK)) by ozlabs.org (Postfix) with ESMTPS id 6DE25B7082 for ; Tue, 21 Dec 2010 13:05:47 +1100 (EST) Received: from mail21-am1-R.bigfish.com (10.3.201.253) by AM1EHSOBE004.bigfish.com (10.3.204.24) with Microsoft SMTP Server id 14.1.225.8; Tue, 21 Dec 2010 02:05:42 +0000 Received: from mail21-am1 (localhost.localdomain [127.0.0.1]) by mail21-am1-R.bigfish.com (Postfix) with ESMTP id 09DB62A0366; Tue, 21 Dec 2010 02:05:42 +0000 (UTC) X-SpamScore: 2 X-BigFish: VS2(zzbb2cKa615mzz1202hzz8275bhz2dh2a8h668h61h) X-Spam-TCS-SCL: 0:0 X-Forefront-Antispam-Report: KIP:(null); UIP:(null); IPVD:NLI; H:de01egw01.freescale.net; RD:de01egw01.freescale.net; EFVD:NLI Received: from mail21-am1 (localhost.localdomain [127.0.0.1]) by mail21-am1 (MessageSwitch) id 1292897141874244_27242; Tue, 21 Dec 2010 02:05:41 +0000 (UTC) Received: from AM1EHSMHS006.bigfish.com (unknown [10.3.201.246]) by mail21-am1.bigfish.com (Postfix) with ESMTP id D35EA1930052; Tue, 21 Dec 2010 02:05:41 +0000 (UTC) Received: from de01egw01.freescale.net (192.88.165.102) by AM1EHSMHS006.bigfish.com (10.3.207.106) with Microsoft SMTP Server (TLS) id 14.1.225.8; Tue, 21 Dec 2010 02:05:40 +0000 Received: from az33smr01.freescale.net (az33smr01.freescale.net [10.64.34.199]) by de01egw01.freescale.net (8.14.3/8.14.3) with ESMTP id oBL28Flv012358; Mon, 20 Dec 2010 19:08:15 -0700 (MST) Received: from localhost (rock.ap.freescale.net [10.193.20.106]) by az33smr01.freescale.net (8.13.1/8.13.0) with ESMTP id oBL25Zgv002590; Mon, 20 Dec 2010 20:05:36 -0600 (CST) From: Mingkai Hu To: , Subject: [PATCH 1/2] eSPI: change the read behavior of the SPIRF Date: Tue, 21 Dec 2010 09:26:07 +0800 Message-ID: <1292894768-6737-1-git-send-email-Mingkai.hu@freescale.com> X-Mailer: git-send-email 1.6.4 MIME-Version: 1.0 X-OriginatorOrg: freescale.com Cc: kumar.gala@freescale.com, Mingkai Hu X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org 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 --- 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);