From patchwork Sun Oct 1 01:20:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ahmed Samir Khalil X-Patchwork-Id: 820228 X-Patchwork-Delegate: jagannadh.teki@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) 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; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="IDHC/rDh"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3y4SFP0WPXz9t32 for ; Sun, 1 Oct 2017 12:22:00 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id B2C53C21DED; Sun, 1 Oct 2017 01:21:42 +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=FREEMAIL_FROM, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, T_DKIM_INVALID 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 CC8CDC21E50; Sun, 1 Oct 2017 01:21:06 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id E3065C21E3D; Sun, 1 Oct 2017 01:20:58 +0000 (UTC) Received: from mail-wm0-f67.google.com (mail-wm0-f67.google.com [74.125.82.67]) by lists.denx.de (Postfix) with ESMTPS id 5839BC21DB9 for ; Sun, 1 Oct 2017 01:20:52 +0000 (UTC) Received: by mail-wm0-f67.google.com with SMTP id u138so4864015wmu.4 for ; Sat, 30 Sep 2017 18:20:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=ty4fitLMSy6TxH8t4U1e/mMXEtlw54Pe8pJF/Ol/CRE=; b=IDHC/rDh3A41KG56YZPAsJT4CKq4ZJZgSjtvPftgrFQwAyBVNf1jCTbmd8FIm1bJmz W9fpYqwVPHX5XIEZLRt5uzkiAlgpax5bJqrvkkxqmTIEwUlbG/iZBWgWGML9ofBKRMyk dY0O+srBq/AkqM5IBoQryGHf9KwKL+LvoBipaCwS/X1pUN5HuVlESQURY+pCNPUbj4D+ Mq+waBU9I+kQeCPbs/VhWXQ1ShFHDeTf5Wu8N5zhBsAQ+0ZpZ4duvQInHUTb0jUwyPoR h5yOzumT5to1Q1+FcsNwebWTuZ86KBLVwkme4WMx+8vnb38nvD8eO35RpvqvzToQmSGR pyXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=ty4fitLMSy6TxH8t4U1e/mMXEtlw54Pe8pJF/Ol/CRE=; b=e7LIO/nftGD/6Pu+hNzy6gEmKyMFWPvI25cgnjll9I1n9CavkKASjrkOO2RL9Dxl+E RtxSV5bUKSO7iua8JpAutB98Ip1/cwc5nM1abRFFinT2UpGz2ARoT75WRYmPpMDSFWN/ JohPTKT/rzz3xxy2nRyL6nR8wxNPRUtg88NEgUvwrJCXNKSxXSNDI9wu2sjaVuEjCBTM f1ik3eM/aga5kYxER9/WPAWYFQqXopN6kMteHn/WN+GPPg05D4B1PV1Neb52LU6cwJP+ KEKlgwS/BGPlODztkateJ47ZUaaiZlPgLVaK8HAk97rlk9iQcx8VcbDAeGufHQ5H5gt/ DL0A== X-Gm-Message-State: AMCzsaV0MOcHXLmQJZgBw4pjsEK5n9PxdMLq0IHM+wyu8HZW4pIKgY+H Ui3VdyQEQqqWGDdJ3bPhQIZAlg== X-Google-Smtp-Source: AOwi7QC0TqruZyiyrzZUBnfd02TpGSOKPqPxN+s1FFlT5yHXzptEkyb/xdvRYmsA0YJyXuAqz1eOrg== X-Received: by 10.28.4.135 with SMTP id 129mr7334396wme.34.1506820851663; Sat, 30 Sep 2017 18:20:51 -0700 (PDT) Received: from sam-VirtualBox.Speedport_W_723V_1_43_000 (p50837F14.dip0.t-ipconnect.de. [80.131.127.20]) by smtp.gmail.com with ESMTPSA id o14sm3079684wra.54.2017.09.30.18.20.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 30 Sep 2017 18:20:50 -0700 (PDT) From: Ahmed Samir Khalil To: u-boot@lists.denx.de Date: Sun, 1 Oct 2017 03:20:41 +0200 Message-Id: <055a433c8d6137cbf73c4248f7d37faf7ebd1215.1506820067.git.engkhalil86@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: References: In-Reply-To: References: Cc: Ahmed Samir Khalil Subject: [U-Boot] [PATCH 2/5] mtd: spi_flash: Support clearing status register 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" A function to clear status register-1 after error flag(s) being triggered. Signed-off-by: Ahmed S. Khalil --- drivers/mtd/spi/spi_flash.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/drivers/mtd/spi/spi_flash.c b/drivers/mtd/spi/spi_flash.c index 34f6888..52dcb84 100644 --- a/drivers/mtd/spi/spi_flash.c +++ b/drivers/mtd/spi/spi_flash.c @@ -110,6 +110,27 @@ static int write_cr(struct spi_flash *flash, u8 wc) return 0; } + +/* + * Clear status register-1 + * + * TODO: Check validity for the other flash vendors. + */ +static int clear_sr(struct spi_flash *flash) +{ + struct spi_slave *spi = flash->spi; + u8 cmd, buf; + int ret; + + cmd = CMD_CLEAR_STATUS; + ret = spi_flash_cmd_write(spi, cmd, 1, buf, 1); + if (ret < 0) { + debug("SF: fail to clear status register\n"); + return ret; + } + + return ret; +} #endif #ifdef CONFIG_SPI_FLASH_BAR