From patchwork Thu Nov 21 14:42:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joyce Ooi X-Patchwork-Id: 1198987 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=intel.com Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 47Jj2j5WFJz9sQy for ; Fri, 22 Nov 2019 01:42:37 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 79634C21F50; Thu, 21 Nov 2019 14:42:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 5EEA0C21E35; Thu, 21 Nov 2019 14:42:30 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 7A7C0C21E35; Thu, 21 Nov 2019 14:42:29 +0000 (UTC) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by lists.denx.de (Postfix) with ESMTPS id 84903C21DFD for ; Thu, 21 Nov 2019 14:42:28 +0000 (UTC) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 Nov 2019 06:42:26 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,226,1571727600"; d="scan'208";a="219099518" Received: from joyceboo-mobl4.gar.corp.intel.com (HELO ubuntu.localdomain) ([10.249.64.105]) by orsmga002.jf.intel.com with ESMTP; 21 Nov 2019 06:42:24 -0800 From: "Ooi, Joyce" To: Jagan Teki Date: Thu, 21 Nov 2019 06:42:05 -0800 Message-Id: <1574347325-13919-1-git-send-email-joyce.ooi@intel.com> X-Mailer: git-send-email 1.9.1 Cc: u-boot@lists.denx.de, Chee Hong Ang Subject: [U-Boot] [PATCH] spi: cadence_qspi_apb: fix QSPI write issues X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" From: Chee Hong Ang QSPI driver perform chip select on every flash read/write access. The driver need to disable/enable the QSPI controller while performing chip select. This may cause some data lost especially the QSPI controller is configured to run at slower speed as it may take longer time to access the flash device. This patch prevent the driver from disable/enable the QSPI controller too soon and inadvertently halting any ongoing flash read/write access by ensuring the QSPI controller is always in idle mode after each read/write access. Signed-off-by: Chee Hong Ang Signed-off-by: Ooi, Joyce Reviewed-by: Ley Foon Tan Reviewed-by: Simon Goldschmidt --- drivers/spi/cadence_qspi_apb.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/spi/cadence_qspi_apb.c b/drivers/spi/cadence_qspi_apb.c index 55a7501..ab14a5f 100644 --- a/drivers/spi/cadence_qspi_apb.c +++ b/drivers/spi/cadence_qspi_apb.c @@ -676,6 +676,10 @@ int cadence_qspi_apb_indirect_read_execute(struct cadence_spi_platdata *plat, writel(CQSPI_REG_INDIRECTRD_DONE, plat->regbase + CQSPI_REG_INDIRECTRD); + /* Wait til QSPI is idle */ + if (!cadence_qspi_wait_idle(plat->regbase)) + return -EIO; + return 0; failrd: @@ -782,6 +786,11 @@ int cadence_qspi_apb_indirect_write_execute(struct cadence_spi_platdata *plat, plat->regbase + CQSPI_REG_INDIRECTWR); if (bounce_buf) free(bounce_buf); + + /* Wait til QSPI is idle */ + if (!cadence_qspi_wait_idle(plat->regbase)) + return -EIO; + return 0; failwr: