From patchwork Tue Apr 27 02:24:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takahiro Kuwano X-Patchwork-Id: 1470526 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=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=Hno8ssDg; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FTlyR1Mqsz9sWp for ; Tue, 27 Apr 2021 12:26:55 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 5968082CB8; Tue, 27 Apr 2021 04:25:41 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Hno8ssDg"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9926182B95; Tue, 27 Apr 2021 04:25:13 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pg1-x52d.google.com (mail-pg1-x52d.google.com [IPv6:2607:f8b0:4864:20::52d]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 22E0682B81 for ; Tue, 27 Apr 2021 04:25:09 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=tkuw584924@gmail.com Received: by mail-pg1-x52d.google.com with SMTP id t22so6069273pgu.0 for ; Mon, 26 Apr 2021 19:25:09 -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 :mime-version:content-transfer-encoding; bh=5vcppKJ3TAF1ZVIwiNMqLMLoRlwSe/fqVRt5F13oTWw=; b=Hno8ssDguPr6QGdE8WBwaxz2ckqspvdAPvIKVRZhSckXI0yNy2Q1CuK5ofz/SfkGUF yVKesBPS1GKBEuVDOtWAiM2saEv/4s9JWmWCjSBd+G+T3l33mWGrre1L9CmTOyHvKh8I Au6bybU+u9bbtKqFvn87M4ZqA2MKOGmwAYUllPccl7bMgE2bhQl9TF+uYCnTkoXB4HBM HUYQgMILNfmyDvHikXFFaT66G6evgNz27bbPNShbtWSfFpLIRLYvFrHm6RxNltIcJ2rm 5MQ9v8OOl/kQasMWxN9klBYnokeuA+OYys+B6J2B6i3JpxgtRExaRW42mPaRPLx/4Vq0 nXWA== 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:mime-version:content-transfer-encoding; bh=5vcppKJ3TAF1ZVIwiNMqLMLoRlwSe/fqVRt5F13oTWw=; b=pEzKmqE2Kz5lLP0jrssqMGxu5z7rpXp7vN8JjFei5vEIj/YCwmioSxsb8qWneLB3PL crVK9odtuwMsIr65pRlCFLrScwwkw1axBMGhrnJdglrv7cvuX0zM1uw3Kizj0EGv6ngo rDe5/uqMUoX5dlj8RbCy+/v/TO0X8iHLAGI0uXiS6T7KVr503tz1nk/FrcD+x9YVb/C8 o8s59JTem8Ot18BrXM8itezYtD1gx91y97QQ63e9iA8atZ4Fk0I0G4V0LC+xA7lS5pOm o1sZScz93J+UbmcA56615UctqThd3DsYrM5NV8ToNCyHazB0QEmPDR8OlNDKgpVA38Bf qosA== X-Gm-Message-State: AOAM532yPKDoW54nrFF+5baJzmCLziWhnHR2pxZvB9hdNEku8yvNxZoK yAAbpDx0tncYdG2s1cOjoUdUf66GDmk= X-Google-Smtp-Source: ABdhPJx8VvZiENAv42MZP5Rk2TJV4trJcL9YGlEWEQMBz+P2vGX1dViNuQDa6K7fO1fMrP5qbn5amQ== X-Received: by 2002:aa7:8b0f:0:b029:20d:1b60:e823 with SMTP id f15-20020aa78b0f0000b029020d1b60e823mr20496167pfd.16.1619490307581; Mon, 26 Apr 2021 19:25:07 -0700 (PDT) Received: from ISCNPF1JZGWX.infineon.com (zz20174137476F6254EB.userreverse.dion.ne.jp. [111.98.84.235]) by smtp.gmail.com with ESMTPSA id n39sm829264pfv.51.2021.04.26.19.25.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Apr 2021 19:25:07 -0700 (PDT) From: tkuw584924@gmail.com X-Google-Original-From: Takahiro.Kuwano@infineon.com To: u-boot@lists.denx.de Cc: jagan@amarulasolutions.com, vigneshr@ti.com, p.yadav@ti.com, tkuw584924@gmail.com, Bacem.Daassi@infineon.com, Takahiro Kuwano Subject: [PATCH v7 10/14] mtd: spi-nor-core: Add the ->ready() hook Date: Tue, 27 Apr 2021 11:24:15 +0900 Message-Id: <55a4f43e592e6502ffb3fa3ac15c962a99ca3871.1619488394.git.Takahiro.Kuwano@infineon.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.4 at phobos.denx.de X-Virus-Status: Clean From: Takahiro Kuwano For dual/quad die package devices from Spansion/Cypress, the device's status needs to be checked by reading status registers in all dies, by using Read Any Register command. To support this, a Flash specific hook that can overwrite the legacy status check is needed. Signed-off-by: Takahiro Kuwano Reviewed-by: Pratyush Yadav --- Changes in v7: - No change Changes in v6: - Rebase and fix commit description Changes in v5: - Move spansion_sr_ready() to different patch - Move original code in spi_nor_ready() to newly created spi_nor_default_ready() drivers/mtd/spi/spi-nor-core.c | 10 +++++++++- include/linux/mtd/spi-nor.h | 2 ++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/mtd/spi/spi-nor-core.c b/drivers/mtd/spi/spi-nor-core.c index d731df30a7..55e17aace3 100644 --- a/drivers/mtd/spi/spi-nor-core.c +++ b/drivers/mtd/spi/spi-nor-core.c @@ -567,7 +567,7 @@ static int spi_nor_fsr_ready(struct spi_nor *nor) return fsr & FSR_READY; } -static int spi_nor_ready(struct spi_nor *nor) +static int spi_nor_default_ready(struct spi_nor *nor) { int sr, fsr; @@ -580,6 +580,14 @@ static int spi_nor_ready(struct spi_nor *nor) return sr && fsr; } +static int spi_nor_ready(struct spi_nor *nor) +{ + if (nor->ready) + return nor->ready(nor); + + return spi_nor_default_ready(nor); +} + /* * Service routine to read status register until ready, or timeout occurs. * Returns non-zero if error. diff --git a/include/linux/mtd/spi-nor.h b/include/linux/mtd/spi-nor.h index de4472da5c..2236e36e28 100644 --- a/include/linux/mtd/spi-nor.h +++ b/include/linux/mtd/spi-nor.h @@ -437,6 +437,7 @@ struct spi_flash { * @flash_is_locked: [FLASH-SPECIFIC] check if a region of the SPI NOR is * completely locked * @quad_enable: [FLASH-SPECIFIC] enables SPI NOR quad mode + * @ready: [FLASH-SPECIFIC] check if the flash is ready * @priv: the private data */ struct spi_nor { @@ -482,6 +483,7 @@ struct spi_nor { int (*flash_unlock)(struct spi_nor *nor, loff_t ofs, uint64_t len); int (*flash_is_locked)(struct spi_nor *nor, loff_t ofs, uint64_t len); int (*quad_enable)(struct spi_nor *nor); + int (*ready)(struct spi_nor *nor); void *priv; /* Compatibility for spi_flash, remove once sf layer is merged with mtd */