From patchwork Tue Apr 27 07:08:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takahiro Kuwano X-Patchwork-Id: 1470572 X-Patchwork-Delegate: tudor.ambarus@gmail.com 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.infradead.org (client-ip=2001:8b0:10b:1:d65d:64ff:fe57:4e05; helo=desiato.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=desiato.20200630 header.b=rdD/uaKl; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=infradead.org header.i=@infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=2N94Gc75; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=I134BzO4; dkim-atps=neutral Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FTtFx0fGrz9sRf for ; Tue, 27 Apr 2021 17:10:45 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=32O2CfJSAXvoXihqnKTcVWC58p0AKx4WamwPzV3/5Kw=; b=rdD/uaKlB9Nv5Vk1sSKU4TDEt wdv6anc9mX/M+fPNs2gzb5hbqgTd+sCffaFsChIyqw/VA03cIgumgtNntjA9QSt8G+xxmiNIq45LC aC6RyO93N07C/yhIrKqCJV4Y8u8V5vIz4iAb0c7WXP2PD/CtLRK5oe4eeCbSGTj5a5dkheZ4lJP/D 1BfDqzNmSVpCOzt7yEvL5cyUoaLhnBmLRmpQIjPTgvEwCVzuq19ZEgcEu48cGtUynoKCaXn0t85hk dM8NOCp7FOIF/OkxPGUjLvf36+7LkUtMRnsMnAxlNbOBJaJ5SODLVghQnBpUn2ana5G1GCeB8vfmW pEjS/0oZA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lbHr6-000vXr-5i; Tue, 27 Apr 2021 07:10:00 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lbHqW-000vS4-LR for linux-mtd@desiato.infradead.org; Tue, 27 Apr 2021 07:09:25 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=eR9z+Ji8NDSOLpqPFMExAd+c9AwErHtHJlGp3w2UMv8=; b=2N94Gc75pR9tHbQsc2i5LfuVdu uM4myXbR988M6V8ltD7qO/PA0vUZkwWWKsJAPDlxGu5wE+9/LvS7HC79U11X9WW2ApXwaqlNF4v5V Cq9Th07NalvHZYvmJsIIWoEPCuW1J7u6Pn3QG+b52sVIZsAdU03LN5rOdS/J0lMF/p7QsMvktpopg 3KfG/Ye07vHae1ePFZd+kS7uoqnyxDQEOjCxreHmdNMc1b4ZrmarNCtI5oxC/8DxCHXeIsBo6gREp b25lwjUWgqQI0Sm8SRIkCWUp6T3D3tzUgwoPnTNcpol8jdW8R6Jewz1Ry1c/gnNYQTYjQ2pnxKciT EYGMMb1w==; Received: from mail-pj1-x1032.google.com ([2607:f8b0:4864:20::1032]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lbHqT-00GUfO-UT for linux-mtd@lists.infradead.org; Tue, 27 Apr 2021 07:09:23 +0000 Received: by mail-pj1-x1032.google.com with SMTP id lr7so12241267pjb.2 for ; Tue, 27 Apr 2021 00:09:21 -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=eR9z+Ji8NDSOLpqPFMExAd+c9AwErHtHJlGp3w2UMv8=; b=I134BzO4cu123xe1y5RAeHCG9NWLDjpZtxsGMImlCLIZuuPPvH0Z+sILlaW5Dz9/av Gr5lL7XSr8i0wxPPwRvUsplWiYTAn/u0iCtGGof50KdBIqd9jHgn3XS5QyxKAz2kYQ75 ZEBL+OFDt+D9Jlde+EwsIIuVBoClOP9UgQcYF0VnNGB0TJRuzg3bX5FmfrqIvKV9VVd7 LqOVSHi4uuJc8PQeMAMlYMt5x6Jnbj8S/cIHVBgSslItoNMYWBXnxh4GG+4kCHwpi3aA 7SRig9R7t6enFvmkSAZYu9YyB7DfecgM/XwvENbqj84RQHMYTGK7hR2JM1ZtqRPW8XET yUGg== 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=eR9z+Ji8NDSOLpqPFMExAd+c9AwErHtHJlGp3w2UMv8=; b=V3lG3QDefvRB0cTVXMPOmD43P3Jesrmmc5U+1u210abzOw+t4WD6Noqu8OEDiqDs4d VhViMKAIpeUtJgIetxXAKitxDh9c85PP8+Pid8rQntyjBLDVXL4bMQJ8CI9l31Gxydde ATVQQWtQWfv3O6ohMVYYAL0ojgtvB6DmbErb4Gd2h0XexFH/n+et6OmB2jAxso8GgLLO TFqofc9FEuF+JeNZisbra7WQkLDT1cekWmhT32p9RsIMLeeYsb6msXA9e8FeHVyQ0SkX FYL+1qML1UVn2bsw1SjREozjIymeJIwfETUNS3PRWdZ2CO82SnVkGd2c6i5bZhiqie0F 5kqw== X-Gm-Message-State: AOAM532puvtjS/v6ylAiHOumJCf5XAZcX3gZ/UT+1uXXMaC+1I5b1fRZ OJOUPEgqKSUC2L5t+1gpxt50uFUsfng= X-Google-Smtp-Source: ABdhPJxLZZTZhDhMLsx/FqjVoXfvkqTrWrCBjSKF7zVQLHNPYQtJtzXrDjEzrB1ViwI9YozgID+izQ== X-Received: by 2002:a17:90a:1d44:: with SMTP id u4mr3468085pju.46.1619507360696; Tue, 27 Apr 2021 00:09:20 -0700 (PDT) Received: from ISCNPF1JZGWX.infineon.com (zz20174137476F6254EB.userreverse.dion.ne.jp. [111.98.84.235]) by smtp.gmail.com with ESMTPSA id u189sm1589803pfb.151.2021.04.27.00.09.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Apr 2021 00:09:20 -0700 (PDT) From: tkuw584924@gmail.com X-Google-Original-From: Takahiro.Kuwano@infineon.com To: linux-mtd@lists.infradead.org Cc: tudor.ambarus@microchip.com, miquel.raynal@bootlin.com, richard@nod.at, vigneshr@ti.com, p.yadav@ti.com, tkuw584924@gmail.com, Bacem.Daassi@infineon.com, Takahiro Kuwano Subject: [PATCH v5 1/6] mtd: spi-nor: core: Add the ->ready() hook Date: Tue, 27 Apr 2021 16:08:56 +0900 Message-Id: <46d97ad6665f72d9c491fae836fa1dc5e55c12b8.1619504535.git.Takahiro.Kuwano@infineon.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210427_000922_005298_28711FD3 X-CRM114-Status: GOOD ( 17.27 ) X-Spam-Score: 0.1 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From: Takahiro Kuwano This hook can be used for SPI NOR flashes that do not support default status read method. Signed-off-by: Takahiro Kuwano Reviewed-by: Pratyush Yadav --- Changes in v5: - No change Content analysis details: (0.1 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:1032 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.2 FREEMAIL_ENVFROM_END_DIGIT Envelope-from freemail username ends in digit [tkuw584924[at]gmail.com] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [tkuw584924[at]gmail.com] -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: Takahiro Kuwano This hook can be used for SPI NOR flashes that do not support default status read method. Signed-off-by: Takahiro Kuwano Reviewed-by: Pratyush Yadav --- Changes in v5: - No change Changes in v4: - Reword 'legacy' to 'default' in commit description - Rename spi_nor_read() to spi_nor_default_ready() Changes in v3: - New in v3 The purpose is same as the patch introduced by Yaliang Wang. https://patchwork.ozlabs.org/project/linux-mtd/patch/20210301142844.1089385-1-yaliang.wang@windriver.com/ drivers/mtd/spi-nor/core.c | 8 +++++--- drivers/mtd/spi-nor/core.h | 2 ++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c index 0522304f52fa..5de72322ae32 100644 --- a/drivers/mtd/spi-nor/core.c +++ b/drivers/mtd/spi-nor/core.c @@ -785,12 +785,13 @@ static int spi_nor_fsr_ready(struct spi_nor *nor) } /** - * spi_nor_ready() - Query the flash to see if it is ready for new commands. + * spi_nor_default_ready() - Query the flash to see if it is ready for new + * commands. * @nor: pointer to 'struct spi_nor'. * * Return: 1 if ready, 0 if not ready, -errno on errors. */ -static int spi_nor_ready(struct spi_nor *nor) +static int spi_nor_default_ready(struct spi_nor *nor) { int sr, fsr; @@ -826,7 +827,7 @@ static int spi_nor_wait_till_ready_with_timeout(struct spi_nor *nor, if (time_after_eq(jiffies, deadline)) timeout = 1; - ret = spi_nor_ready(nor); + ret = nor->params->ready(nor); if (ret < 0) return ret; if (ret) @@ -2920,6 +2921,7 @@ static void spi_nor_info_init_params(struct spi_nor *nor) params->quad_enable = spi_nor_sr2_bit1_quad_enable; params->set_4byte_addr_mode = spansion_set_4byte_addr_mode; params->setup = spi_nor_default_setup; + params->ready = spi_nor_default_ready; /* Default to 16-bit Write Status (01h) Command */ nor->flags |= SNOR_F_HAS_16BIT_SR; diff --git a/drivers/mtd/spi-nor/core.h b/drivers/mtd/spi-nor/core.h index 4a3f7f150b5d..4d06c27630fe 100644 --- a/drivers/mtd/spi-nor/core.h +++ b/drivers/mtd/spi-nor/core.h @@ -218,6 +218,7 @@ struct spi_nor_locking_ops { * flashes that have peculiarities to the SPI NOR standard * e.g. different opcodes, specific address calculation, * page size, etc. + * @ready: checks if the SPI NOR flash is ready. * @locking_ops: SPI NOR locking methods. */ struct spi_nor_flash_parameter { @@ -238,6 +239,7 @@ struct spi_nor_flash_parameter { int (*set_4byte_addr_mode)(struct spi_nor *nor, bool enable); u32 (*convert_addr)(struct spi_nor *nor, u32 addr); int (*setup)(struct spi_nor *nor, const struct spi_nor_hwcaps *hwcaps); + int (*ready)(struct spi_nor *nor); const struct spi_nor_locking_ops *locking_ops; }; From patchwork Tue Apr 27 07:08:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takahiro Kuwano X-Patchwork-Id: 1470573 X-Patchwork-Delegate: tudor.ambarus@gmail.com 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.infradead.org (client-ip=2001:8b0:10b:1:d65d:64ff:fe57:4e05; helo=desiato.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=desiato.20200630 header.b=eBqcWYdb; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=infradead.org header.i=@infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=sPf8v37E; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=dMTroffx; dkim-atps=neutral Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FTtHJ582Hz9sXL for ; Tue, 27 Apr 2021 17:11:56 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=mvyj4YIm8L20Cjn3LOHuTd1PxCECBBrG/6hkjcu1GPs=; b=eBqcWYdbsVaxgGKPDKTWu/YE4 hxXhFxv4lZzBtmUjccnazcnRy1VcJNVBlA8+kL83sSUNOGk4nGSU0Da3enzqHWB9kT2N1qDVCAesa AlCPlxAoglWB1xwV8ui6diqft0qeXb2oMNF+z0KT1GB4caiaNJbXhFVld7LA7l6uzbB1dFHm31cSc cABvEStpTIUBkrMkaygMMtgt2ExTGJbFDN/uGy9bpkiGlEXKmdBsCbskN5M41lp5edtRmuiX4jhba QFpMaUmnPJxkO8Jxe91QTTQDzkFRadwpZINDJhUa5RPNSzVA6PsUFqPwEsaJiGQjQgPowBv+9GZzr CHsypRB2g==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lbHsG-000vkx-BN; Tue, 27 Apr 2021 07:11:12 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lbHqa-000vSm-If for linux-mtd@desiato.infradead.org; Tue, 27 Apr 2021 07:09:28 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=6X6cQuI6AS/vcnXCbALDKX3RnEEMroVHSFoATv+sePw=; b=sPf8v37EFmsnsnquNd2yQ9lOxz IyrpKlToAONyXJ0HXZEXQN21X0FNCBZJduK/qfn5nJfTx3sBCckGdcsl22eZzZLHvsXLpCHKesrG2 XGX5aL8JIcotwB5bwl6l8e8eTKAcYQ2bphCk5DVEl3vmmJmbepu3j0gBseTPzn/RCrXkFZyy9xa16 ZI0tSnU0MUk0683XXfFTr7JiTzikdhpCeu/Vk7OAIViDSw/XjZa4s4HQuQq7CguZVlXCBR1A5ID4g ELRtaaGOMPdSd8OhupXNLVKxIkKNgQ2s5dp456k+QusmT5pQoAAezufNBNgME7ZJgnRzp17Kq4BKR aimVtXRg==; Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lbHqY-00GUgD-3V for linux-mtd@lists.infradead.org; Tue, 27 Apr 2021 07:09:27 +0000 Received: by mail-pl1-x631.google.com with SMTP id p17so4448459plf.12 for ; Tue, 27 Apr 2021 00:09:24 -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=6X6cQuI6AS/vcnXCbALDKX3RnEEMroVHSFoATv+sePw=; b=dMTroffxqXz028CHfQvj7IsjVXF1pE5KTTZmzHHbaP4MAs2jtonh+yC+Qu0zkvekhE Jgh0Ea/10a8y77OfZhWizw5A1dxSSYF/NDCYdJeMGo7YxqedvQqwfxPS4zcnh6ugNgUG NaT884VT8DyGgpgKtPuevcBC4hfUG9/OXyblPdKqqlb59Zyv1E4u1gYZPoaB5gTBVgfH Rey37USapN3U2o5W45lVZYRw4jZnJDBFxqjzBwU5kaLLmZRpOCV67VPgN5rT0d9nHzwl cIK6ksqphEncpshe/Zx64fmZtS8hlUyMD/CNQQ0lu896AEFfaKezTmC0Vuv/p+7Qgi/J Y1uA== 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=6X6cQuI6AS/vcnXCbALDKX3RnEEMroVHSFoATv+sePw=; b=GNz5AvsetCW6OWETcaiM5e1mqeE8+x5U3vSojQi1Nev/pCOR8BfgTwrzgerKqKvdNp PBozLTKu3HJqpNQioHWNi1IIGH/wgKHLDsFD4IkqxgZnOw+ndsJK8nEyuCeZ1QQ2GSng YJeDpsqRReIq2MmWRjzL40yCpVZVts41gW1N05gqJN6KlnKBH61GlfNPXZBBSdGRpsQN lb6hbG1XQA8JHNBMtIBBJlnIvaRxmFio2LpmgzFmEdN6V2lhgSA3N2YXEmXYQe3doiDM o6vKq8z5DEAqKLbsYGQhSyMFbmv1kDfEQ4CeLfX8iPBlbx2II5dLo6imI3RQGR1g32pW VI/w== X-Gm-Message-State: AOAM533s38XnQmKLOMTOTUq38iEA1IRTiUewRUD0aurZ1ykB67Xrc4Nr gaGtX0raYi3mpciYnJBIxY3xQZj+pck= X-Google-Smtp-Source: ABdhPJyevKjayBAXFjWcE+lOAvJ2pFPmmO/FHohN2WeTm1CG/uknKg8ocuBXGn6C5DJQh7PGsAbxqQ== X-Received: by 2002:a17:903:310a:b029:ed:2b66:107d with SMTP id w10-20020a170903310ab02900ed2b66107dmr9826949plc.12.1619507364073; Tue, 27 Apr 2021 00:09:24 -0700 (PDT) Received: from ISCNPF1JZGWX.infineon.com (zz20174137476F6254EB.userreverse.dion.ne.jp. [111.98.84.235]) by smtp.gmail.com with ESMTPSA id u189sm1589803pfb.151.2021.04.27.00.09.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Apr 2021 00:09:23 -0700 (PDT) From: tkuw584924@gmail.com X-Google-Original-From: Takahiro.Kuwano@infineon.com To: linux-mtd@lists.infradead.org Cc: tudor.ambarus@microchip.com, miquel.raynal@bootlin.com, richard@nod.at, vigneshr@ti.com, p.yadav@ti.com, tkuw584924@gmail.com, Bacem.Daassi@infineon.com, Takahiro Kuwano Subject: [PATCH v5 2/6] mtd: spi-nor: core: Expose spi_nor_clear_sr() to manufacturer drivers Date: Tue, 27 Apr 2021 16:08:57 +0900 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210427_000926_165597_6DBFD42D X-CRM114-Status: GOOD ( 11.93 ) X-Spam-Score: 0.1 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From: Takahiro Kuwano spi_nor_clear_sr() needs to be called from manufacturer drivers that implement the ->ready(). Signed-off-by: Takahiro Kuwano Reviewed-by: Pratyush Yadav --- Changes in v5: - No change Content analysis details: (0.1 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:631 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.2 FREEMAIL_ENVFROM_END_DIGIT Envelope-from freemail username ends in digit [tkuw584924[at]gmail.com] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [tkuw584924[at]gmail.com] -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: Takahiro Kuwano spi_nor_clear_sr() needs to be called from manufacturer drivers that implement the ->ready(). Signed-off-by: Takahiro Kuwano Reviewed-by: Pratyush Yadav --- Changes in v5: - No change Changes in v4: - No change Changes in v3: - New in v3 drivers/mtd/spi-nor/core.c | 2 +- drivers/mtd/spi-nor/core.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c index 5de72322ae32..7ab0225473e1 100644 --- a/drivers/mtd/spi-nor/core.c +++ b/drivers/mtd/spi-nor/core.c @@ -653,7 +653,7 @@ static int spi_nor_xsr_ready(struct spi_nor *nor) * spi_nor_clear_sr() - Clear the Status Register. * @nor: pointer to 'struct spi_nor'. */ -static void spi_nor_clear_sr(struct spi_nor *nor) +void spi_nor_clear_sr(struct spi_nor *nor) { int ret; diff --git a/drivers/mtd/spi-nor/core.h b/drivers/mtd/spi-nor/core.h index 4d06c27630fe..596480aef924 100644 --- a/drivers/mtd/spi-nor/core.h +++ b/drivers/mtd/spi-nor/core.h @@ -447,6 +447,7 @@ int spi_nor_read_cr(struct spi_nor *nor, u8 *cr); int spi_nor_write_sr(struct spi_nor *nor, const u8 *sr, size_t len); int spi_nor_write_sr_and_check(struct spi_nor *nor, u8 sr1); +void spi_nor_clear_sr(struct spi_nor *nor); int spi_nor_xread_sr(struct spi_nor *nor, u8 *sr); ssize_t spi_nor_read_data(struct spi_nor *nor, loff_t from, size_t len, u8 *buf); From patchwork Tue Apr 27 07:08:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takahiro Kuwano X-Patchwork-Id: 1470574 X-Patchwork-Delegate: tudor.ambarus@gmail.com 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.infradead.org (client-ip=2001:8b0:10b:1:d65d:64ff:fe57:4e05; helo=desiato.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=desiato.20200630 header.b=BZyrGy16; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=infradead.org header.i=@infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=yaZnj4/o; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=I+oWfBen; dkim-atps=neutral Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FTtJl4zDGz9sRf for ; Tue, 27 Apr 2021 17:13:11 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=cLyASXfjzAyyU1wrAvHheIEBHX23xwAfgrEjr0s6f7s=; b=BZyrGy16fRBoiuhW8ycbndOux lrbGrfid8CP4Y40yZAjtROtluBxZz7QuOtKrYipYa1/xIGVaME86gSPr2Jh3O7iN4py+08b0o0vXU lEG4i+e5pIdSxuFT+aULqkpXK6IUmZQL5izmbW4PRaH+BswCeFG4hsuZz+GaxwAUNLil8alrNvOhX xFtt6vK5ETUqooEwDkar7xIpPs+9NhfJm6stQEPAcWYlLETiQ5/5wSxLBu3896HcdWC37a+pPYX+V HrSQmp79gDh366oBOaeVg8agz/zRDwjF718ZO99XlOiv2tNWIV4hubEpEA/wZ8HH0uWjfCDBgej8V PRX2O7i+Q==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lbHt5-000vuM-Gc; Tue, 27 Apr 2021 07:12:03 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lbHqe-000vTD-5H for linux-mtd@desiato.infradead.org; Tue, 27 Apr 2021 07:09:32 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=yBFj+weq+k6Dd1LdPQHzr9yg0kIJfnYhl1IjAjuonac=; b=yaZnj4/o7vJzMJXbnX8jIg5WRU Y2hPFOPPtr+G+jeyF4XJ+Ahkhtz0lzHaLyRcfm36xQ4U2fCRRbXRHQHSC759I5xVNH9Kfzhg94cTG Ginqq45Ucu/b9mRzZiCp09O3UWNLFV6d+op8SGxH2SSWdCz1Z1qsEppMbys+An6D9nSJmq3yIo4XU UwkTaaKWt3xIUqsxVWWK5g9GuPCRIQXn7FrdzTOGKtzg/QY0U9jrWs+4TgYmkt/XyN8LNvoUT89o2 R4hy/PuaGzVQ+zBnKvWVLhEp6ePuYtq68gRmwWXhp0hJtS8R75VJlysZHZmv+BiA3QCJQSHKGMXnh H7G2/wMQ==; Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lbHqb-00GUgX-Ep for linux-mtd@lists.infradead.org; Tue, 27 Apr 2021 07:09:30 +0000 Received: by mail-pl1-x62e.google.com with SMTP id s20so14509030plr.13 for ; Tue, 27 Apr 2021 00:09:27 -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=yBFj+weq+k6Dd1LdPQHzr9yg0kIJfnYhl1IjAjuonac=; b=I+oWfBenWU8jKFkbG2Ol4bRjkoTiqx9qappwy27SiDwnWbv06tOLrfFpZKYSRWQxeo rY2OIGpLUT77pkISGQBN1GwQiMX2pyBGFWwmlUgha8Zyh/sB/A6mS1OrcURfkD+vKchD f3dYwhgTgHi8n/UD5R3EoNSHyl3ttskTk/Xd7QTAQjbU9ET50hT8E3S4SU6tjp1RSHVi goNeO9sJ4bLxC1Rwh7gnDNJQODC8NZrHsoee6609rsoruzEl9pDgjC4pUFs3KOUfVpV8 GQVpAHCx4E3sCodf40SXEzn/WX/7aJLBRVOpoefbFTU0iUvdQtBabwN1jxDusYzX+8bD iY5w== 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=yBFj+weq+k6Dd1LdPQHzr9yg0kIJfnYhl1IjAjuonac=; b=Os6nZX2gd6YetDg7iZPC8OmOj1zF6qwk8QUPytgXHoVye6G2ny48puDVbUm2yZCI+Y fDIn5c5OY9HoJk5mWIQL6MKq4YOAY0OqnSCOFxvlw72T8vvXZrDEDJSQ3VXgxjD4vLjr X62unz6qhP0GksPKe9qJaIJa98QRUvq9uOV3aZQGFY4GmCRbWa5/rmTuIukWHujJCo3m 9EWsxOgCtQZUUVzx8zC8SC0gaRJzyzVNtU1zZFVvU5xIrIAMBIU0owOddgqPA1oTqxtp 58lrOwTUVV5ndUzu5y3Sr5fH9y+6cVWBsA/xTm10zcqzPv9jMkihYF+TOYTpWpk6yDaQ LLUw== X-Gm-Message-State: AOAM530BbAgVbwbeV/a3mnH5SeB+Xiy41k2+bZ1IiMrS/snuZRXL6NW2 y5CBQVdfu1qJHeFDoUD+cV2DINT+cHI= X-Google-Smtp-Source: ABdhPJxcfA5Hxa6BO7dVXK/rAbXB0FaEB174N4bskI216q0fNw3Lz91SdwgiA0ZS3fQSjoo7ySlt+g== X-Received: by 2002:a17:902:8d83:b029:e6:508a:7b8d with SMTP id v3-20020a1709028d83b02900e6508a7b8dmr23611636plo.18.1619507367411; Tue, 27 Apr 2021 00:09:27 -0700 (PDT) Received: from ISCNPF1JZGWX.infineon.com (zz20174137476F6254EB.userreverse.dion.ne.jp. [111.98.84.235]) by smtp.gmail.com with ESMTPSA id u189sm1589803pfb.151.2021.04.27.00.09.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Apr 2021 00:09:27 -0700 (PDT) From: tkuw584924@gmail.com X-Google-Original-From: Takahiro.Kuwano@infineon.com To: linux-mtd@lists.infradead.org Cc: tudor.ambarus@microchip.com, miquel.raynal@bootlin.com, richard@nod.at, vigneshr@ti.com, p.yadav@ti.com, tkuw584924@gmail.com, Bacem.Daassi@infineon.com, Takahiro Kuwano Subject: [PATCH v5 3/6] mtd: spi-nor: spansion: Add support for Read/Write Any Register Date: Tue, 27 Apr 2021 16:08:58 +0900 Message-Id: <55919d6bce07a5b534edef10b56a6c1b3fecae9d.1619504535.git.Takahiro.Kuwano@infineon.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210427_000929_521430_EA9F3E0A X-CRM114-Status: GOOD ( 16.11 ) X-Spam-Score: 0.1 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From: Takahiro Kuwano Some of Spansion/Cypress chips support Read/Write Any Register commands. These commands are mainly used to write volatile registers and access to the registers in second and subsequent die for multi-d [...] Content analysis details: (0.1 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:62e listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.2 FREEMAIL_ENVFROM_END_DIGIT Envelope-from freemail username ends in digit [tkuw584924[at]gmail.com] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [tkuw584924[at]gmail.com] -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: Takahiro Kuwano Some of Spansion/Cypress chips support Read/Write Any Register commands. These commands are mainly used to write volatile registers and access to the registers in second and subsequent die for multi-die package parts. The Read Any Register instruction (65h) is followed by register address and dummy cycles, then the selected register byte is returned. The Write Any Register instruction (71h) is followed by register address and register byte to write. Signed-off-by: Takahiro Kuwano Reviewed-by: Pratyush Yadav --- Changes in v5: - Fix 'if (ret == 1)' to 'if (ret < 0)' in spansion_read_any_reg() Changes in v4: - Fix dummy cycle calculation in spansion_read_any_reg() - Modify comment for spansion_write_any_reg() Changes in v3: - Cleanup implementation drivers/mtd/spi-nor/spansion.c | 106 +++++++++++++++++++++++++++++++++ 1 file changed, 106 insertions(+) diff --git a/drivers/mtd/spi-nor/spansion.c b/drivers/mtd/spi-nor/spansion.c index b0c5521c1e27..436db8933dcf 100644 --- a/drivers/mtd/spi-nor/spansion.c +++ b/drivers/mtd/spi-nor/spansion.c @@ -19,6 +19,112 @@ #define SPINOR_REG_CYPRESS_CFR5V_OCT_DTR_DS 0 #define SPINOR_OP_CYPRESS_RD_FAST 0xee +/** + * spansion_read_any_reg() - Read Any Register. + * @nor: pointer to a 'struct spi_nor' + * @reg_addr: register address + * @reg_dummy: number of dummy cycles for register read + * @reg_val: pointer to a buffer where the register value is copied into + * + * Return: 0 on success, -errno otherwise. + */ +static int spansion_read_any_reg(struct spi_nor *nor, u32 reg_addr, + u8 reg_dummy, u8 *reg_val) +{ + ssize_t ret; + + if (nor->spimem) { + struct spi_mem_op op = + SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_RD_ANY_REG, 0), + SPI_MEM_OP_ADDR(nor->addr_width, reg_addr, 0), + SPI_MEM_OP_DUMMY(reg_dummy, 0), + SPI_MEM_OP_DATA_IN(1, reg_val, 0)); + + spi_nor_spimem_setup_op(nor, &op, nor->reg_proto); + + op.dummy.nbytes = (reg_dummy * op.dummy.buswidth) / 8; + if (spi_nor_protocol_is_dtr(nor->reg_proto)) + op.dummy.nbytes *= 2; + + ret = spi_mem_exec_op(nor->spimem, &op); + } else { + enum spi_nor_protocol proto = nor->read_proto; + u8 opcode = nor->read_opcode; + u8 dummy = nor->read_dummy; + + nor->read_opcode = SPINOR_OP_RD_ANY_REG; + nor->read_dummy = reg_dummy; + nor->read_proto = nor->reg_proto; + + ret = nor->controller_ops->read(nor, reg_addr, 1, reg_val); + + nor->read_opcode = opcode; + nor->read_dummy = dummy; + nor->read_proto = proto; + + if (ret < 0) + return ret; + if (ret != 1) + return -EIO; + + ret = 0; + } + + return ret; +} + +/** + * spansion_write_any_reg() - Write Any Register. + * @nor: pointer to a 'struct spi_nor' + * @reg_addr: register address (should be a volatile register) + * @reg_val: register value to be written + * + * Volatile register write will be effective immediately after the operation so + * this function does not poll the status. + * + * Return: 0 on success, -errno otherwise. + */ +static int spansion_write_any_reg(struct spi_nor *nor, u32 reg_addr, u8 reg_val) +{ + ssize_t ret; + + ret = spi_nor_write_enable(nor); + if (ret) + return ret; + + if (nor->spimem) { + struct spi_mem_op op = + SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_WR_ANY_REG, 0), + SPI_MEM_OP_ADDR(nor->addr_width, reg_addr, 0), + SPI_MEM_OP_NO_DUMMY, + SPI_MEM_OP_DATA_OUT(1, ®_val, 0)); + + spi_nor_spimem_setup_op(nor, &op, nor->reg_proto); + + ret = spi_mem_exec_op(nor->spimem, &op); + } else { + enum spi_nor_protocol proto = nor->write_proto; + u8 opcode = nor->program_opcode; + + nor->program_opcode = SPINOR_OP_WR_ANY_REG; + nor->write_proto = nor->reg_proto; + + ret = nor->controller_ops->write(nor, reg_addr, 1, ®_val); + + nor->program_opcode = opcode; + nor->write_proto = proto; + + if (ret < 0) + return ret; + if (ret != 1) + return -EIO; + + ret = 0; + } + + return ret; +} + /** * spi_nor_cypress_octal_dtr_enable() - Enable octal DTR on Cypress flashes. * @nor: pointer to a 'struct spi_nor' From patchwork Tue Apr 27 07:08:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takahiro Kuwano X-Patchwork-Id: 1470579 X-Patchwork-Delegate: tudor.ambarus@gmail.com 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.infradead.org (client-ip=2001:8b0:10b:1:d65d:64ff:fe57:4e05; helo=desiato.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=desiato.20200630 header.b=hmnML/P+; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=infradead.org header.i=@infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=5BURqzBl; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=P7s1wocr; dkim-atps=neutral Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FTtLX21WGz9sRf for ; Tue, 27 Apr 2021 17:14:44 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=RWaUS8z1ZlSS1uVQTTjYzWahZxBwVORDo+sROW2vA3U=; b=hmnML/P+d7+W71BHXZ8o+OKwH Pf3jZq3PA+7Jo/uKfM4+WuQa2XPbFk7GF+JQv7Bsyr3I6yffgLIqt9QaQ9mDxhAo9H6JP3b3TzVq3 GOUIxrWgf8O9bdnJLP1s1/K2FjYHSEHx6Q2Dtm2zJ8V2fwrxFG74SF8lOSB3OmFgZYFPY8Xdzkaql 6jr94IyokKNaQDqvfNlykNiS+gGfnLk9RQJy5kyNVdanzaezkNhupnVB4JNE8e+zlHWJl8+rxGAVx 8vZYhsUe+9Pi9ySeKu7tu6nipUbwHQ6KRFdzSUt3z8XRgMeiesor7OsArQzv6LpNquTmooy3f+9bc T9TSudCaw==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lbHuZ-000w6P-6f; Tue, 27 Apr 2021 07:13:37 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lbHqg-000vU8-HB for linux-mtd@desiato.infradead.org; Tue, 27 Apr 2021 07:09:35 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=4Q8vX3NoAVOb/mZph+oUCKQacfcoPoavlAUnHHeT1EA=; b=5BURqzBlDHNWAsOOW+X+zPif6U +54HBi24EDx9j2bN3GrJ8XEanLfWQCLVXdtgESklst6yltlRwPb0/k0rCv38VnYCqbhPWFzOcgNXe Pi9gxv6Dy/6iT8NgwdnVp00Bh5umvTBfkC0HJ4NFFySPaNQNq56HFoJulUrdy8+WxV3yt1YN9I4zA ZpqzwPTCQNkZhV1dsyVuR1DYe+cgzNpWgS6gRxpWnWM/fcRtbelix2RuLESQjrIl7DDSgtbyqeTBZ rKOOxlKjNzGeZORQZIEjlh1biCjhWQ+2GI5ni7qpwRwQ8HdHodRIjiMmYrKOjLpV93UBUwEW4+fWl oXlJs/Tw==; Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lbHqd-00GUgp-Tg for linux-mtd@lists.infradead.org; Tue, 27 Apr 2021 07:09:33 +0000 Received: by mail-pl1-x62b.google.com with SMTP id p17so4448618plf.12 for ; Tue, 27 Apr 2021 00:09:31 -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=4Q8vX3NoAVOb/mZph+oUCKQacfcoPoavlAUnHHeT1EA=; b=P7s1wocrmJhbM2TIBkWgszhqz9IyDcm0kR63iu7eC9qTcriWKi3GiD0MxJOwcqMxvS lixpWUvxGbnspjLw6uYAM85PIXX8trxVC6huGNpdj8zheTkmRxxz0Nb1Uy1LNkWMcgsG PhyXIFj2YP/8TQoyRzXNV/rWHfrbqdnpBFHbw1r0Jp2J52EMvdKPGo9siR5FnLqZG5lp aa+h6OnuUapNgeVTbO7dZGvAyCX66RXnlFKWe8L/B4XV+eiyi5bt1GH0Ml5beqa9USVp cUk9BOJYCkOAbMasoLckx+anZDBojs6s9H+FIQNn4OVjw7E0n0ex13BymGF3LvctUgjF jPsg== 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=4Q8vX3NoAVOb/mZph+oUCKQacfcoPoavlAUnHHeT1EA=; b=B6DEA9nhXumlaPt5AcL9K+c4/4eX7VgHBW04ojhtuiPOlddHPPy2sMS4aNeijiel58 75EljhC2Vbjk6C5+ZzQ+fKVrEX1+JnP0r5txpc8GNp+Im5C4359GnN72UKVhuPU357Pp hqHVhnD0Kw/GGedJLMz/9+vboNjPbAiqVEVJEOMAMC/EBGi+j4axCFi+iI1T1Y2S7AHK l2BlW7z5kATpii4gKkod53VSAEhGC26UUZn08IpQ988k5ADt6re0ZqJKKeh+mrH9yM4W 0+7PeJmpf34xGUYW9+eJDfPwsi+X4wFGPZQNkzhHgaKoCmjFI/ChbjYG0NhqytgH1Aaj p2Uw== X-Gm-Message-State: AOAM533THEcDlotDRKPKgyMuNcMTpneX11PrCyxYQRSoPBTYjM0m85qK Haq7+sAiXFJNTkax7z7QQeKW5LCh4/4= X-Google-Smtp-Source: ABdhPJzjLqEvXUjtqSXcSMgY4NqUja5d9tVyUsdsdsLk84VB6wydoixOOLzDY+hcCp91mT4+5VQXLw== X-Received: by 2002:a17:903:18e:b029:ec:7e58:fbe1 with SMTP id z14-20020a170903018eb02900ec7e58fbe1mr22743378plg.70.1619507370703; Tue, 27 Apr 2021 00:09:30 -0700 (PDT) Received: from ISCNPF1JZGWX.infineon.com (zz20174137476F6254EB.userreverse.dion.ne.jp. [111.98.84.235]) by smtp.gmail.com with ESMTPSA id u189sm1589803pfb.151.2021.04.27.00.09.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Apr 2021 00:09:30 -0700 (PDT) From: tkuw584924@gmail.com X-Google-Original-From: Takahiro.Kuwano@infineon.com To: linux-mtd@lists.infradead.org Cc: tudor.ambarus@microchip.com, miquel.raynal@bootlin.com, richard@nod.at, vigneshr@ti.com, p.yadav@ti.com, tkuw584924@gmail.com, Bacem.Daassi@infineon.com, Takahiro Kuwano Subject: [PATCH v5 4/6] mtd: spi-nor: spansion: Add support for volatile QE bit Date: Tue, 27 Apr 2021 16:08:59 +0900 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210427_000931_980404_4B105A6C X-CRM114-Status: GOOD ( 18.26 ) X-Spam-Score: 0.1 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From: Takahiro Kuwano Some of Spansion/Cypress chips support volatile version of configuration registers and it is recommended to update volatile registers in the field application due to a risk of the non-volatile registe [...] Content analysis details: (0.1 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:62b listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.2 FREEMAIL_ENVFROM_END_DIGIT Envelope-from freemail username ends in digit [tkuw584924[at]gmail.com] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [tkuw584924[at]gmail.com] -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: Takahiro Kuwano Some of Spansion/Cypress chips support volatile version of configuration registers and it is recommended to update volatile registers in the field application due to a risk of the non-volatile registers corruption by power interrupt. This patch adds a function to set Quad Enable bit in CFR1 volatile. The function supports multi-die package parts that require to set the Quad Enable bit in each die. Signed-off-by: Takahiro Kuwano Reviewed-by: Pratyush Yadav --- Changes in v5: - No change Changes in v4: - No change Changes in v3: - Add multi-die package parts support drivers/mtd/spi-nor/spansion.c | 58 ++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/drivers/mtd/spi-nor/spansion.c b/drivers/mtd/spi-nor/spansion.c index 436db8933dcf..0eac092f6c95 100644 --- a/drivers/mtd/spi-nor/spansion.c +++ b/drivers/mtd/spi-nor/spansion.c @@ -10,6 +10,8 @@ #define SPINOR_OP_RD_ANY_REG 0x65 /* Read any register */ #define SPINOR_OP_WR_ANY_REG 0x71 /* Write any register */ +#define SPINOR_REG_CYPRESS_CFR1V 0x00800002 +#define SPINOR_REG_CYPRESS_CFR1V_QUAD_EN BIT(1) /* Quad Enable */ #define SPINOR_REG_CYPRESS_CFR2V 0x00800003 #define SPINOR_REG_CYPRESS_CFR2V_MEMLAT_11_24 0xb #define SPINOR_REG_CYPRESS_CFR3V 0x00800004 @@ -125,6 +127,62 @@ static int spansion_write_any_reg(struct spi_nor *nor, u32 reg_addr, u8 reg_val) return ret; } +/** + * spansion_quad_enable_volatile() - enable Quad I/O mode in volatile register. + * @nor: pointer to a 'struct spi_nor' + * @reg_dummy: number of dummy cycles for register read + * @die_size: size of each die to determine the number of dies + * + * It is recommended to update volatile registers in the field application due + * to a risk of the non-volatile registers corruption by power interrupt. This + * function sets Quad Enable bit in CFR1 volatile. If users set the Quad Enable + * bit in the CFR1 non-volatile in advance (typically by a Flash programmer + * before mounting Flash on PCB), the Quad Enable bit in the CFR1 volatile is + * also set during Flash power-up. This function supports multi-die package + * parts that require to set the Quad Enable bit in each die. + * + * Return: 0 on success, -errno otherwise. + */ +static int spansion_quad_enable_volatile(struct spi_nor *nor, u8 reg_dummy, + u32 die_size) +{ + int ret; + u32 base, reg_addr; + u8 cfr1v, cfr1v_written; + + for (base = 0; base < nor->params->size; base += die_size) { + reg_addr = base + SPINOR_REG_CYPRESS_CFR1V; + + ret = spansion_read_any_reg(nor, reg_addr, reg_dummy, &cfr1v); + if (ret) + return ret; + + if (cfr1v & SPINOR_REG_CYPRESS_CFR1V_QUAD_EN) + continue; + + /* Update the Quad Enable bit. */ + cfr1v |= SPINOR_REG_CYPRESS_CFR1V_QUAD_EN; + + ret = spansion_write_any_reg(nor, reg_addr, cfr1v); + if (ret) + return ret; + + cfr1v_written = cfr1v; + + /* Read back and check it. */ + ret = spansion_read_any_reg(nor, reg_addr, reg_dummy, &cfr1v); + if (ret) + return ret; + + if (cfr1v != cfr1v_written) { + dev_err(nor->dev, "CFR1: Read back test failed\n"); + return -EIO; + } + } + + return 0; +} + /** * spi_nor_cypress_octal_dtr_enable() - Enable octal DTR on Cypress flashes. * @nor: pointer to a 'struct spi_nor' From patchwork Tue Apr 27 07:09:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takahiro Kuwano X-Patchwork-Id: 1470581 X-Patchwork-Delegate: tudor.ambarus@gmail.com 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.infradead.org (client-ip=2001:8b0:10b:1:d65d:64ff:fe57:4e05; helo=desiato.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=desiato.20200630 header.b=pA+L481U; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=infradead.org header.i=@infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=YbNFGnPw; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=fPww58c3; dkim-atps=neutral Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FTtMt5XS4z9sRf for ; Tue, 27 Apr 2021 17:15:54 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=2bQ1WttdxQry7OE9zkeV+KDd5lnxk2yh0zPLjXeiOus=; b=pA+L481U9Fsfmhl+fu9SD6Jql CgbykDcpJVQtZ04iDhddgaE1NAapqwT6ZwcXkLKqfQ7w5/EPJeUmXRl0FlFgjCJcInaFezALohUDg roq0bfdptijrztT8/CMx0onXLZX+kXTMgu4pfX/HC6TX7Yw2Xrvqn+ZjBWMIbfwVP6VBjvqYDYUzW OvHvoXsxWhL1f7HJsNpe68RaIlEJmmnl5GwaFPs8uX2ocPmMgNkKi6zY4ms2JFq10j2CRazf8LMUs P/Ek6Pbib8AygKqa8gmV0zqfOsTeq7CNhDAP6fip9AWojZ4kSBUeYAlcNSRMF7pKDdVdWpTdJ9Rwh Scikl1/9Q==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lbHvr-000wI1-TG; Tue, 27 Apr 2021 07:14:56 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lbHqj-000vUR-Ny for linux-mtd@desiato.infradead.org; Tue, 27 Apr 2021 07:09:37 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=rsJi8hKlYDZIitHEEue7CAARFKVfgqG/xoWHcXoMSJA=; b=YbNFGnPw8IduOcwXcICYRsFYah CpGY/0rakrFyu86oG+nWZ9sze7khYZzXDjamjeKVvNpYpt8gItH3GcHeAMC6UoR9NYXIm7K4XSKTD BfBPhNO15sCEM0VwVu0kdjqb6MPyVy0hgvrUKjaxVKcflaONXkZUdDTJkxHzxLxl2M3B89tfBPPIy OieWI798ry1dkMwWnMsr6RxVZo6dUnNS25Qw8H8ndQqx7MhqWc9Sx2SxIJVZ9a5NEofVYczGN9rT3 7dr/rdcGX3TesWTliMHD9bxV1Q6HJTOkNl5Gq4SzFTSMcHJTKgUDk5R881ejek7d2g6MkNZyvAVBa EVAGm0Zg==; Received: from mail-pg1-x52d.google.com ([2607:f8b0:4864:20::52d]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lbHqh-00GUh7-7m for linux-mtd@lists.infradead.org; Tue, 27 Apr 2021 07:09:36 +0000 Received: by mail-pg1-x52d.google.com with SMTP id t22so6470465pgu.0 for ; Tue, 27 Apr 2021 00:09:34 -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=rsJi8hKlYDZIitHEEue7CAARFKVfgqG/xoWHcXoMSJA=; b=fPww58c30w7fFFWPFry3uIBPGKVeQ4kRte1hoI4i3C4D76hozz3e+o3vSpICa+MZc4 wSzzjDbcbFkjjr1iuRfAj3je10Mw1NPKfm3xKeJaydvxM1mm+n7SB/GV6+rW5HWulvRm uyDYE06H4aSTE88u/oxx4vI9cvlIsfM7JQI4AU2UGf3RR5pFrNRcyrtjZv7vggoFe1Bp tWnOC549xZK9uUX1ooLnq9jPLjoFLtqpqsC6fRKllojDSWVpQQy28meAgsFTqFtP7Prw ZYs3hTizp90JZL0IuD7jQeYzkbbzu7UbS7HIQNahpRFU57PSbR7XU+bmcdW+xz1iYFBP n3Ig== 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=rsJi8hKlYDZIitHEEue7CAARFKVfgqG/xoWHcXoMSJA=; b=ZRyZ04ESQh59uNhGezb4qNvS5i7tjcx93jzCM3jYl9xQj5bw1K/tGld8LKCcIq0Rk+ /dAznY34P6vDFDkv8Ze7/LICK5XN/qDckPJguSIKaxkvylybZEXPX//ihZXHLcbVcj/D Tfj0BnjDry+ukZ9+YsUHhMkWgqXL+rtE4y2e8gKdXWBZMyvG+JcwhC6EuS6810yL3icn TIe2scATXfxsFQagPTVEHQjMZEs6BhlTP7ZLorO5+44+lXlV1FKAzoWh2H4zGZuAnjkO jkDWCFmU7WzLaQ+Dz+pm3P+n1qsGvlv06RAti3+NmkWE/+r8bodtHJPytD7ZRklzN9+t /4qQ== X-Gm-Message-State: AOAM5319WCirlgIxrxIkCoc62jlaE6SS8oRsaG5WaTAIn9mrDpFW0QDB H9tT7DpvEwO2HhSMAAxID8P67bLTUG0= X-Google-Smtp-Source: ABdhPJxGZR4PfnjCdpYKXyU7ZgIZPra9U0khEidZddUNKSL0hTbl9zsAVLxdm17Y4GDAVGF02IjYUQ== X-Received: by 2002:aa7:96bb:0:b029:254:e8ed:2897 with SMTP id g27-20020aa796bb0000b0290254e8ed2897mr20946626pfk.24.1619507373990; Tue, 27 Apr 2021 00:09:33 -0700 (PDT) Received: from ISCNPF1JZGWX.infineon.com (zz20174137476F6254EB.userreverse.dion.ne.jp. [111.98.84.235]) by smtp.gmail.com with ESMTPSA id u189sm1589803pfb.151.2021.04.27.00.09.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Apr 2021 00:09:33 -0700 (PDT) From: tkuw584924@gmail.com X-Google-Original-From: Takahiro.Kuwano@infineon.com To: linux-mtd@lists.infradead.org Cc: tudor.ambarus@microchip.com, miquel.raynal@bootlin.com, richard@nod.at, vigneshr@ti.com, p.yadav@ti.com, tkuw584924@gmail.com, Bacem.Daassi@infineon.com, Takahiro Kuwano Subject: [PATCH v5 5/6] mtd: spi-nor: spansion: Add status check for multi-die parts Date: Tue, 27 Apr 2021 16:09:00 +0900 Message-Id: <565b7e8adf8de81b037dae148a38980b880f844f.1619504535.git.Takahiro.Kuwano@infineon.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210427_000935_300303_AE70051A X-CRM114-Status: GOOD ( 17.25 ) X-Spam-Score: 0.1 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From: Takahiro Kuwano The multi-die package parts from Spansion/Cypress require to check the status register value in each die to detemine the device is ready. This patch adds a helper that queries status of each die by Re [...] Content analysis details: (0.1 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:52d listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.2 FREEMAIL_ENVFROM_END_DIGIT Envelope-from freemail username ends in digit [tkuw584924[at]gmail.com] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [tkuw584924[at]gmail.com] -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: Takahiro Kuwano The multi-die package parts from Spansion/Cypress require to check the status register value in each die to detemine the device is ready. This patch adds a helper that queries status of each die by Read Any Register command. The device specific ->ready() hook will call this helper with the number of dummy cycles and die size. Signed-off-by: Takahiro Kuwano Reviewed-by: Pratyush Yadav --- Changes in v5: - No change Changes in v4: - Reword 'legacy' to 'default' in function header comments Changes in v3: - New in v3 drivers/mtd/spi-nor/spansion.c | 46 ++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/drivers/mtd/spi-nor/spansion.c b/drivers/mtd/spi-nor/spansion.c index 0eac092f6c95..79d3249ed0aa 100644 --- a/drivers/mtd/spi-nor/spansion.c +++ b/drivers/mtd/spi-nor/spansion.c @@ -10,6 +10,7 @@ #define SPINOR_OP_RD_ANY_REG 0x65 /* Read any register */ #define SPINOR_OP_WR_ANY_REG 0x71 /* Write any register */ +#define SPINOR_REG_CYPRESS_STR1V 0x00800000 #define SPINOR_REG_CYPRESS_CFR1V 0x00800002 #define SPINOR_REG_CYPRESS_CFR1V_QUAD_EN BIT(1) /* Quad Enable */ #define SPINOR_REG_CYPRESS_CFR2V 0x00800003 @@ -183,6 +184,51 @@ static int spansion_quad_enable_volatile(struct spi_nor *nor, u8 reg_dummy, return 0; } +/** + * spansion_mdp_ready() - Query the Status Register via Read Any Register + * command for multi-die package parts that do not + * support default RDSR(05h) + * @nor: pointer to 'struct spi_nor'. + * @reg_dummy: number of dummy cycles for register read + * @die_size: size of each die to determine the number of dies + * + * Return: 1 if ready, 0 if not ready, -errno on errors. + */ +static int spansion_mdp_ready(struct spi_nor *nor, u8 reg_dummy, u32 die_size) +{ + int ret; + u32 base; + u8 sr; + + for (base = 0; base < nor->params->size; base += die_size) { + ret = spansion_read_any_reg(nor, + base + SPINOR_REG_CYPRESS_STR1V, + reg_dummy, &sr); + if (ret) + return ret; + + if (sr & (SR_E_ERR | SR_P_ERR)) { + if (sr & SR_E_ERR) + dev_err(nor->dev, "Erase Error occurred\n"); + else + dev_err(nor->dev, "Programming Error occurred\n"); + + spi_nor_clear_sr(nor); + + ret = spi_nor_write_disable(nor); + if (ret) + return ret; + + return -EIO; + } + + if (sr & SR_WIP) + return 0; + } + + return 1; +} + /** * spi_nor_cypress_octal_dtr_enable() - Enable octal DTR on Cypress flashes. * @nor: pointer to a 'struct spi_nor' From patchwork Tue Apr 27 07:09:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takahiro Kuwano X-Patchwork-Id: 1470582 X-Patchwork-Delegate: tudor.ambarus@gmail.com 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.infradead.org (client-ip=2001:8b0:10b:1:d65d:64ff:fe57:4e05; helo=desiato.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=desiato.20200630 header.b=HNImj98o; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=infradead.org header.i=@infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=S/VQ3CcB; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=m6W2L3Wa; dkim-atps=neutral Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FTtQv2RCFz9sX2 for ; Tue, 27 Apr 2021 17:18:30 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=XYZPQLGsCvEUL9oLJGVPkkkv+jiVdaVo3GcBLuV9xRs=; b=HNImj98oLxmLqPDLbnPuluOF0 WqSOZfIKP1SkfX+p3CrgOCPOeU7wiNNsOwp/CuKtH0FC2uyEaZvv2YOovrJxiizV9xwRujupHo3+d TyBpcMIJKpnVUokL28TwiVk6VRGgIHVwl8gwyovIPeWWk1seCxs5aci2/Np0UUNUxtqOEJhDRbdyR a3E9EaUkYZw519GXuJ2qLkRfXESR6jIr9wRJyvtHw568wHRyQ7DvlsTSkDzbpFQlyjuBrlP7vKV/T 6tuAy75wbuHoQ09bcvtFeshYmwlqGEBSdQ3DIFwJ0aAS4qMcOvlvmE/uGxi/5ZVn5eJOV1OUT/8Jf Nrkz/XItg==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lbHy3-000wYv-3x; Tue, 27 Apr 2021 07:17:12 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lbHqn-000vV6-CV for linux-mtd@desiato.infradead.org; Tue, 27 Apr 2021 07:09:44 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=1c9USNyud8PJeEJI49mh7QL/r1WaYoN5sOTMDFWn1zM=; b=S/VQ3CcBSu1XxWgTmlpb2L75j1 Pj72SvYZC8JigWN04yFJVfKY0c4k44ormigCN/QssLy/xPMvvE2JwESNdrWlAaOtLUvAsJq9JnlpE NRbI2Y+spbWyLOSRVz/9YbhrKhrz7+UA7JdG91xYcmA3S2AJoGD3ZDPnSD940mJhIVVtWGYvUuICi 1lfd8YcLGpGb0mTqndhBmi2lqKD00lWx6sdaCbOUQ1ncfZPKBWQFa8rQqGZGCTCoKfHVtSB4b/g8g jvudHkQy5xzjK2hrvCvC43+nVzReo133xk1/6HpkRvTlgNV6JzR4xDc3zuVOfQCwUE+1GFoK2o2yK 73i4bA0Q==; Received: from mail-pg1-x532.google.com ([2607:f8b0:4864:20::532]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lbHqk-00GUhO-K2 for linux-mtd@lists.infradead.org; Tue, 27 Apr 2021 07:09:40 +0000 Received: by mail-pg1-x532.google.com with SMTP id d10so3342598pgf.12 for ; Tue, 27 Apr 2021 00:09:37 -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=1c9USNyud8PJeEJI49mh7QL/r1WaYoN5sOTMDFWn1zM=; b=m6W2L3WalvuzzwUycUn8J7jRR5UAh+JO8xHPy3AOmNDpv7NAy/jus4AdMWsd/NiXyU Jj22Sh+H5y79w4uBCBM7bOdxHiLLiJRFGgWNrkhcWYQlXzZ7P5upWSBjG8rTP7nCMSo5 Rk4oW2xv+svNPiqMSXtvCqWvr1o4rwCLPA0dt5s5ubhD6mgt+h25VUHxHAiHWPjp8tle Rs4pkXTwdleCcExhpfIIERo9RhQ7wPQsA3C2Ho9ht6NuTgpSG2rgBtHBb+xn7p2yLzKP hRShpBlLR+FRf/8uFk7yLvd669gSD6fuaqdSOKDPLXBhXhuigQcF/4fNcjhXUh8rnTyN oF0g== 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=1c9USNyud8PJeEJI49mh7QL/r1WaYoN5sOTMDFWn1zM=; b=QVJrYREYVmmmMmazZsr8Mj4YmFmcFmC7g2xShYWNd9Oal+umRPHi7M0wO8DtSyY9aL BDUxqDq4x0WeYFACu+RRQehc1KL3YfqumFIc0Jlkuj6kS/0Q9MJgvAJrFtIjrmSgALnq IvqW6q4BMs1VPuqfGI3+PkE41DD9u4dM9FRGQv59Zdbd03uD0TGGzK1aGHeWSY99e6er cJ0bQpGMqZzaKXswS+CVQzCTWCLQ6oVFy9ccdSIqkFMfHMvCK3V88rniN7Js2bO1D5bC ULwdNfp4P5MBoITPykk3Cl5FbUaz5FxcEwkUltydmNng0GzzqvN3gbZAWqfkexBaN4ML Wv5w== X-Gm-Message-State: AOAM530VqoGw473Y0ELdiA1tuODdwnXMLuNPxHRsFnr5k4s2ERMdLewv 4m372vAHof4vHiaAPu7/j4y3Qi3z4BQ= X-Google-Smtp-Source: ABdhPJy+w373HkVYWADbiiB7QH9HOqtOm05ZoNTveV1qbc5JatqRm6EvBmDQMO6U5PWZ6R6f1BkU+A== X-Received: by 2002:a63:be08:: with SMTP id l8mr9478205pgf.438.1619507377342; Tue, 27 Apr 2021 00:09:37 -0700 (PDT) Received: from ISCNPF1JZGWX.infineon.com (zz20174137476F6254EB.userreverse.dion.ne.jp. [111.98.84.235]) by smtp.gmail.com with ESMTPSA id u189sm1589803pfb.151.2021.04.27.00.09.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Apr 2021 00:09:37 -0700 (PDT) From: tkuw584924@gmail.com X-Google-Original-From: Takahiro.Kuwano@infineon.com To: linux-mtd@lists.infradead.org Cc: tudor.ambarus@microchip.com, miquel.raynal@bootlin.com, richard@nod.at, vigneshr@ti.com, p.yadav@ti.com, tkuw584924@gmail.com, Bacem.Daassi@infineon.com, Takahiro Kuwano Subject: [PATCH v5 6/6] mtd: spi-nor: spansion: Add s25hl-t/s25hs-t IDs and fixups Date: Tue, 27 Apr 2021 16:09:01 +0900 Message-Id: <28d1a4015f37156a8bebe88959ea643e64b030f8.1619504535.git.Takahiro.Kuwano@infineon.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210427_000938_686126_D7CBB0D5 X-CRM114-Status: GOOD ( 24.97 ) X-Spam-Score: 0.1 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From: Takahiro Kuwano The S25HL-T/S25HS-T family is the Cypress Semper Flash with Quad SPI. For the single-die package parts (512Mb and 1Gb), only bottom 4KB and uniform sector sizes are supported. For the multi-die package parts (2Gb), only uniform sector sizes is supprted. This is due to m [...] Content analysis details: (0.1 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:532 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.2 FREEMAIL_ENVFROM_END_DIGIT Envelope-from freemail username ends in digit [tkuw584924[at]gmail.com] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [tkuw584924[at]gmail.com] -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: Takahiro Kuwano The S25HL-T/S25HS-T family is the Cypress Semper Flash with Quad SPI. For the single-die package parts (512Mb and 1Gb), only bottom 4KB and uniform sector sizes are supported. For the multi-die package parts (2Gb), only uniform sector sizes is supprted. This is due to missing or incorrect entries in SMPT. Fixup for other sector sizes configurations will be followed up as needed. Tested on Xilinx Zynq-7000 FPGA board. Signed-off-by: Takahiro Kuwano Reviewed-by: Pratyush Yadav --- Changes in v5: - Add NO_CHIP_ERASE flag to S25HL02GT and S25HS02GT Changes in v4: - Merge block comments about SMPT in s25hx_t_post_sfdp_fixups() - Remove USE_CLSR flags from S25HL02GT and S25HS02GT Changes in v3: - Remove S25HL256T and S25HS256T - Add S25HL02GT and S25HS02GT - Add support for multi-die package parts support - Remove erase_map fix for top/split sector layout - Set ECC data unit size (16B) to writesize drivers/mtd/spi-nor/spansion.c | 117 +++++++++++++++++++++++++++++++++ 1 file changed, 117 insertions(+) diff --git a/drivers/mtd/spi-nor/spansion.c b/drivers/mtd/spi-nor/spansion.c index 79d3249ed0aa..b3b006874b4f 100644 --- a/drivers/mtd/spi-nor/spansion.c +++ b/drivers/mtd/spi-nor/spansion.c @@ -229,6 +229,103 @@ static int spansion_mdp_ready(struct spi_nor *nor, u8 reg_dummy, u32 die_size) return 1; } +static int s25hx_t_quad_enable(struct spi_nor *nor) +{ + return spansion_quad_enable_volatile(nor, 0, SZ_128M); +} + +static int s25hx_t_mdp_ready(struct spi_nor *nor) +{ + return spansion_mdp_ready(nor, 0, SZ_128M); +} + +static int +s25hx_t_post_bfpt_fixups(struct spi_nor *nor, + const struct sfdp_parameter_header *bfpt_header, + const struct sfdp_bfpt *bfpt, + struct spi_nor_flash_parameter *params) +{ + int ret; + u32 addr; + u8 cfr3v; + + ret = spi_nor_set_4byte_addr_mode(nor, true); + if (ret) + return ret; + nor->addr_width = 4; + + /* Replace Quad Enable with volatile version */ + params->quad_enable = s25hx_t_quad_enable; + + /* + * The page_size is set to 512B from BFPT, but it actually depends on + * the configuration register. Look up the CFR3V and determine the + * page_size. For multi-die package parts, use 512B only when the all + * dies are configured to 512B buffer. + */ + for (addr = 0; addr < params->size; addr += SZ_128M) { + ret = spansion_read_any_reg(nor, + addr + SPINOR_REG_CYPRESS_CFR3V, 0, + &cfr3v); + if (ret) + return ret; + + if (!(cfr3v & SPINOR_REG_CYPRESS_CFR3V_PGSZ)) { + params->page_size = 256; + return 0; + } + } + params->page_size = 512; + + return 0; +} + +void s25hx_t_post_sfdp_fixups(struct spi_nor *nor) +{ + /* Fast Read 4B requires mode cycles */ + nor->params->reads[SNOR_CMD_READ_FAST].num_mode_clocks = 8; + + /* The writesize should be ECC data unit size */ + nor->params->writesize = 16; + + /* + * For the single-die package parts (512Mb and 1Gb), bottom 4KB and + * uniform sector maps are correctly populated in the erase_map + * structure. The table below shows all possible combinations of related + * register bits and its availability in SMPT. + * + * CFR3[3] | CFR1[6] | CFR1[2] | Sector Map | Available in SMPT? + * ------------------------------------------------------------------- + * 0 | 0 | 0 | Bottom | YES + * 0 | 0 | 1 | Top | NO (decoded as Split) + * 0 | 1 | 0 | Split | NO + * 0 | 1 | 1 | Split | NO (decoded as Top) + * 1 | 0 | 0 | Uniform | YES + * 1 | 0 | 1 | Uniform | NO + * 1 | 1 | 0 | Uniform | NO + * 1 | 1 | 1 | Uniform | NO + * ------------------------------------------------------------------- + * + * For the dual-die package parts (2Gb), SMPT parse fails due to + * incorrect SMPT entries and the erase map is populated as 4K uniform + * that does not supported the parts. So it needs to be rolled back to + * 256K uniform that is the factory default of multi-die package parts. + */ + if (nor->params->size > SZ_128M) { + spi_nor_init_uniform_erase_map(&nor->params->erase_map, + BIT(SNOR_ERASE_TYPE_MAX - 1), + nor->params->size); + + /* Need to check status of each die via RDAR command */ + nor->params->ready = s25hx_t_mdp_ready; + } +} + +static struct spi_nor_fixups s25hx_t_fixups = { + .post_bfpt = s25hx_t_post_bfpt_fixups, + .post_sfdp = s25hx_t_post_sfdp_fixups +}; + /** * spi_nor_cypress_octal_dtr_enable() - Enable octal DTR on Cypress flashes. * @nor: pointer to a 'struct spi_nor' @@ -479,6 +576,26 @@ static const struct flash_info spansion_parts[] = { { "s25fl256l", INFO(0x016019, 0, 64 * 1024, 512, SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | SPI_NOR_4B_OPCODES) }, + { "s25hl512t", INFO6(0x342a1a, 0x0f0390, 256 * 1024, 256, + SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | USE_CLSR) + .fixups = &s25hx_t_fixups }, + { "s25hl01gt", INFO6(0x342a1b, 0x0f0390, 256 * 1024, 512, + SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | USE_CLSR) + .fixups = &s25hx_t_fixups }, + { "s25hl02gt", INFO6(0x342a1c, 0x0f0090, 256 * 1024, 1024, + SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | + NO_CHIP_ERASE) + .fixups = &s25hx_t_fixups }, + { "s25hs512t", INFO6(0x342b1a, 0x0f0390, 256 * 1024, 256, + SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | USE_CLSR) + .fixups = &s25hx_t_fixups }, + { "s25hs01gt", INFO6(0x342b1b, 0x0f0390, 256 * 1024, 512, + SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | USE_CLSR) + .fixups = &s25hx_t_fixups }, + { "s25hs02gt", INFO6(0x342b1c, 0x0f0090, 256 * 1024, 1024, + SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | + NO_CHIP_ERASE) + .fixups = &s25hx_t_fixups }, { "cy15x104q", INFO6(0x042cc2, 0x7f7f7f, 512 * 1024, 1, SPI_NOR_NO_ERASE) }, { "s28hs512t", INFO(0x345b1a, 0, 256 * 1024, 256,