From patchwork Fri Feb 9 14:31:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jarkko Nikula X-Patchwork-Id: 10209337 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8F7ED602D8 for ; Fri, 9 Feb 2018 14:30:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 821372988C for ; Fri, 9 Feb 2018 14:30:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 764DE298B8; Fri, 9 Feb 2018 14:30:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E2A5A2988C for ; Fri, 9 Feb 2018 14:30:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751090AbeBIOay (ORCPT ); Fri, 9 Feb 2018 09:30:54 -0500 Received: from mga01.intel.com ([192.55.52.88]:11704 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751058AbeBIOax (ORCPT ); Fri, 9 Feb 2018 09:30:53 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Feb 2018 06:30:52 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,483,1511856000"; d="scan'208";a="29490050" Received: from mylly.fi.intel.com (HELO mylly.fi.intel.com.) ([10.237.72.50]) by fmsmga001.fm.intel.com with ESMTP; 09 Feb 2018 06:30:50 -0800 From: Jarkko Nikula To: linux-spi@vger.kernel.org Cc: Mark Brown , Daniel Mack , Haojian Zhuang , Robert Jarzmik , Jarkko Nikula Subject: [PATCH] spi: pxa2xx: Move SSP idle waiting to cs_deassert() Date: Fri, 9 Feb 2018 16:31:07 +0200 Message-Id: <20180209143107.16671-1-jarkko.nikula@linux.intel.com> X-Mailer: git-send-email 2.15.1 Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Move SSP idle waiting before CS deassert from error and end of message handling function giveback() to cs_deassert(). This ensures idle waiting is done also if there is CS change between transfers. Signed-off-by: Jarkko Nikula --- drivers/spi/spi-pxa2xx.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/spi/spi-pxa2xx.c b/drivers/spi/spi-pxa2xx.c index 487a6f1067c9..713506eff07d 100644 --- a/drivers/spi/spi-pxa2xx.c +++ b/drivers/spi/spi-pxa2xx.c @@ -415,10 +415,17 @@ static void cs_deassert(struct driver_data *drv_data) { struct chip_data *chip = spi_get_ctldata(drv_data->master->cur_msg->spi); + unsigned long timeout; if (drv_data->ssp_type == CE4100_SSP) return; + /* Wait until SSP becomes idle before deasserting the CS */ + timeout = jiffies + msecs_to_jiffies(10); + while (pxa2xx_spi_read(drv_data, SSSR) & SSSR_BSY && + !time_after(jiffies, timeout)) + cpu_relax(); + if (chip->cs_control) { chip->cs_control(PXA2XX_CS_DEASSERT); return; @@ -563,7 +570,6 @@ static void giveback(struct driver_data *drv_data) { struct spi_transfer* last_transfer; struct spi_message *msg; - unsigned long timeout; msg = drv_data->master->cur_msg; drv_data->cur_transfer = NULL; @@ -575,12 +581,6 @@ static void giveback(struct driver_data *drv_data) if (last_transfer->delay_usecs) udelay(last_transfer->delay_usecs); - /* Wait until SSP becomes idle before deasserting the CS */ - timeout = jiffies + msecs_to_jiffies(10); - while (pxa2xx_spi_read(drv_data, SSSR) & SSSR_BSY && - !time_after(jiffies, timeout)) - cpu_relax(); - /* Drop chip select UNLESS cs_change is true or we are returning * a message with an error, or next message is for another chip */