From patchwork Fri Mar 19 06:53:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takahiro Kuwano X-Patchwork-Id: 1455657 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=p/wqDZJE; 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=pmJ18/5n; 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 4F1vlm2fKNz9sWP for ; Fri, 19 Mar 2021 17:55:00 +1100 (AEDT) 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=iSLjm6TPTrdgL5J8ya9tSgBGfDdlLxHNLp+9WNTWi1s=; b=p/wqDZJE2r1ZcPd+NgFLMlpgg iMihKut0YIerYmTGW/nS7siBMLQlf47kaQLLhvA+BLSbnw6Cy8WeMQhgxPMlxy3PVxQo15FwguR6h HiKl+SD3CTWDgiDNwZItcmidqNiSAzkIgWPT1jCLOXCnW/3Fwr/Tj8K2LLwYQ4Ao7yzSG6FR7yWel 9g1ovzfRzVuIgBtwWRtUkNAPAYq6Aga5VzMn9vgDRfaSTWl3y/8uiijnAci5soF5Erb8WxY3iMCZ1 1w+cFReqeSeg0M6POS/Xg4Oy1r/TfuDKHI6o5BnQrigZfc9nK6UhDwUFlnOpKrTldOJ8LYi6OYrql zVZ0AwCpw==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lN91U-006jam-Hv; Fri, 19 Mar 2021 06:54:16 +0000 Received: from mail-pj1-x102e.google.com ([2607:f8b0:4864:20::102e]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lN91Q-006jZm-30 for linux-mtd@lists.infradead.org; Fri, 19 Mar 2021 06:54:14 +0000 Received: by mail-pj1-x102e.google.com with SMTP id q6-20020a17090a4306b02900c42a012202so4370942pjg.5 for ; Thu, 18 Mar 2021 23:54:11 -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=4Yg/eGXImxTvnSrwDgFoFqHzX5c9qLEci19XioMhm7I=; b=pmJ18/5noSHZcAPcTuI0R8lA7xeC2qEAQToQTpLKdC3w8SYaQoGW8r5RXnSTbuYp/H BQP9sokM4pBbIb2YmDZLFoiIjqHOSqjNKItiThioisyvvOwpwk0xmjSeZPytUvlFPzBa 1q6Ftd/L3NPgmr99NHcLBs8CBk2aqz2Ub6f8Onu7+TA0qc2lSptJV8PkCC/JkEr4eSG1 7NAtF3K22wSYCfV171BCJ2B5bNOazf5JZi3uVtVlrByWR0PZDL+B3+skQicmQTcKOUxP U0Z7oVpOjRtnwfZctyerLae9nNYrhRdGVIbDNYl3n0XyuNoKoNDlNhnpFboajWFVvOOe TWhw== 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=4Yg/eGXImxTvnSrwDgFoFqHzX5c9qLEci19XioMhm7I=; b=OHCg9RjeIOpyfY5RCxaiPjlPj2Sqv5rgR68LKt5ZHzIvLHu29/i2fBoHbXS6NQx3bm UHCNTyjt+gczv6cgFO+8mUIzuRDbPkHzNWXmp3OZ4PS+cr9gmTte8Wn7Uk04yojDPDug 9b9GJanzQUpFfZQT9IsCeTrk5WbTg/FV01HgxwQDywSEdQixUqlIP58hAbw/xX+93nAo qO6AGbHWMp4HmM6itIfC17xLIoiIWYohg+ornd4orrlQlMV4UwXDvhb9+4q3FXkTDZsW zBtUdP52py836MdKoH9d1mzD76IbKM9m2uhbibdK6Zv5G3z+eO3yb06msx5dh3jpVcQA xmXw== X-Gm-Message-State: AOAM531zSjDWFh8wDWngEr4ztaTmas+PSJfEHT1s8y9+Y9OafIhETMR/ i9XomRv7N06SoS1TvTNcjcmQa1i1PsGnDg== X-Google-Smtp-Source: ABdhPJxsXJDWBZCvzvqZ6NOYMsw1vgYUvEWaRP5dCPwskvGR0v5GM72GRwvtJKdoaRVe10GFU2NXTg== X-Received: by 2002:a17:902:eb11:b029:e4:a5c3:4328 with SMTP id l17-20020a170902eb11b02900e4a5c34328mr13427047plb.7.1616136850540; Thu, 18 Mar 2021 23:54:10 -0700 (PDT) Received: from ISCNPF1JZGWX.infineon.com (zz20174137476F6254EB.userreverse.dion.ne.jp. [111.98.84.235]) by smtp.gmail.com with ESMTPSA id m5sm4410901pfd.96.2021.03.18.23.54.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Mar 2021 23:54:10 -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, Yaliang.Wang@windriver.com, tkuw584924@gmail.com, Bacem.Daassi@infineon.com, Takahiro Kuwano Subject: [PATCH v4 1/6] mtd: spi-nor: core: Add the ->ready() hook Date: Fri, 19 Mar 2021 15:53:46 +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-20210319_065412_301908_7B0465A8 X-CRM114-Status: GOOD ( 16.73 ) X-Spam-Score: 0.1 (/) X-Spam-Report: Spam detection software, running on the system "desiato.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 v4: - Reword 'legacy' to 'default' in commit description - Rename spi_nor_read() to spi_nor_default_ready() 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:102e listed in] [list.dnswl.org] 0.2 FREEMAIL_ENVFROM_END_DIGIT Envelope-from freemail username ends in digit [tkuw584924[at]gmail.com] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -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_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's 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 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 Fri Mar 19 06:54:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takahiro Kuwano X-Patchwork-Id: 1455658 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=ijLUc5T6; 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=g2OF1YOc; 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 4F1vmr2m16z9sWP for ; Fri, 19 Mar 2021 17:55:56 +1100 (AEDT) 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=1rcb8AJq7UfJwxHCJaD5xTcRZkdnYZ60mFbiPTvQvog=; b=ijLUc5T6w4hSvpZrWtr3vP4gn CKmM9Wzcq6Ah7mx/nb4IiHFIp/WaW62s4DB6NPtQwI+tC1qklhFaXx/0nWgEKCX9dFNth3qCbSTPg qDxUCfEcLEi/zXH9GaL/Yoj3H45XPFQcGuRTmW6xTEdfv/iCFVa4UkOTQYsDyik2YuxorRFNNUZ7m gz2uIdmOR6gJOjV++ua/rRjr2kfRYELRzMUpqBp6p/LICFoWgYlIqkC/VlavTgrvjSxaYlki39Vo0 ZT0CmoxiZWWa5mgFoKtQokL4LnVEBTAuXJcGrmjJSByYdNJaGFUXRILtLq7Clf+Z2KZ3hTHGzKatx cyLHkOIIQ==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lN92D-006jfl-8l; Fri, 19 Mar 2021 06:55:01 +0000 Received: from mail-pf1-x42f.google.com ([2607:f8b0:4864:20::42f]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lN928-006jev-GC for linux-mtd@lists.infradead.org; Fri, 19 Mar 2021 06:54:58 +0000 Received: by mail-pf1-x42f.google.com with SMTP id y200so5215736pfb.5 for ; Thu, 18 Mar 2021 23:54:56 -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=FjJFKSBNtgpb7z1WJLLhkY281cgaWBDGouXCklMUp9Y=; b=g2OF1YOc4d/iypX3B3xhBWyg3Tf5KRGtzl1l8JP57aJRa9oq6uCpx+CkImrXDN2lFa r/2Q9XHMYzbDrESJ/sjO0ffBLXyR+PDaADVRPWlMHmBTRt5HpavAIw45ju6n3qv0McGm 1dTx8Y360WIOJijmKYd3gCvAbnzMHFhJbafaoF1EtM1emi1n9MCB+PaCrMeR4nKvhPAn U8qcKxNS66k0MyG5oR20hNpK0l60lq7gnPezv4fyLbaysK7M9weUQYwP3uU5eZ7YSg71 3Ti95v3MX+K8q8qEI7d9QarKAqje6J5zP4AnNyFiPxstCEd2GgW4/WWwbhdGa56KYWFt nUsA== 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=FjJFKSBNtgpb7z1WJLLhkY281cgaWBDGouXCklMUp9Y=; b=JOjxiwbncYsyw/dvdR8Ebz32kDuvt6ZozRXxAfRdFyRgATr1nW8E9OQiEF20pG2fM/ gtn5zK1bfJzPZTs2TW+jigPv84yO5VBQEqckArHybEUfkJ/3vbVWmn2NPX7nEKZzeaAc iEbYKHsrLNWR+3Wn2miPxv48IlKupx76ASigyMd7qcJjpurrQPwsWbu51setYjaAo+ZY nndacowfNBgNnEgUsvd74MsYY7/uiom4XMjJcHmimX0mMh0huVtk4v9nuEESg7IykQos qXG9Yi2BAGzElYEi83lM5o1L4cBqHEk2pHIA//MZA1ZkihLFgFjovfbT24RmAiQrYzHf PcOQ== X-Gm-Message-State: AOAM533Se5ecG/pWGfOVRpnfCiCnyKNbA8+UTw1UfNnTthSff671MMRC w3K9Oh8KD90U3IsvSBBRfWxRu7GW1f31SQ== X-Google-Smtp-Source: ABdhPJzTtEdLxRNmE9LRzoMxjG2WTQWuR/y3mGmTdCBJWDqNiwW3NoToYM9eufUj+OvNuhAv2rwStg== X-Received: by 2002:a62:dd89:0:b029:1fd:d370:7a5e with SMTP id w131-20020a62dd890000b02901fdd3707a5emr7863843pff.61.1616136894896; Thu, 18 Mar 2021 23:54:54 -0700 (PDT) Received: from ISCNPF1JZGWX.infineon.com (zz20174137476F6254EB.userreverse.dion.ne.jp. [111.98.84.235]) by smtp.gmail.com with ESMTPSA id fa21sm4490145pjb.41.2021.03.18.23.54.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Mar 2021 23:54:54 -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, Yaliang.Wang@windriver.com, tkuw584924@gmail.com, Bacem.Daassi@infineon.com, Takahiro Kuwano Subject: [PATCH v4 2/6] mtd: spi-nor: core: Expose spi_nor_clear_sr() to manufacturer drivers Date: Fri, 19 Mar 2021 15:54:39 +0900 Message-Id: <791ae06b79cf0229e3dea332f2b0b136c229ec4a.1616130675.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-20210319_065456_824156_A532584D X-CRM114-Status: GOOD ( 11.80 ) X-Spam-Score: 0.1 (/) X-Spam-Report: Spam detection software, running on the system "desiato.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 v4: - 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:42f listed in] [list.dnswl.org] 0.2 FREEMAIL_ENVFROM_END_DIGIT Envelope-from freemail username ends in digit [tkuw584924[at]gmail.com] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -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_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's 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 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 Fri Mar 19 06:56:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takahiro Kuwano X-Patchwork-Id: 1455659 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=o58SNdf4; 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=soKsbpgx; 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 4F1vqS0frwz9sWP for ; Fri, 19 Mar 2021 17:58:12 +1100 (AEDT) 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=lObY9u70KhBdo7+WKoX552sHhlmI1D8JfS6p+EsK5IY=; b=o58SNdf4Wy7pWtje8fA9E1RI5 kg3M0T5+VoVymQxbHWKlY31TZ6sXigmnMiVJ4PlMcDefBOYc0SIW1HNTb/jGkro0O/3NoQQSiSr+b XOxCRaryiplti6SFdYCwh2pmqo2vvvgXOAs1VyUibcapVj1+VPsCcVdd6o7msQv/ADLRr0L5Ae7Jn cM8qKNGHIlzm1oF5iCjWuDKU3i+KqoavfJ+BbiQ9T7lZQ09lhvlRh5nGDNPUB5/tq5wGtiySYugw7 RncursQ/9/H84Uqs0JjuwrgP2vxheg+zcdlej6VrEkEqNiJWkD6UsIgXd8WqDvmMxlngjQpv9g8pt LmDfQLvfQ==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lN94A-006jxS-Po; Fri, 19 Mar 2021 06:57:02 +0000 Received: from mail-pj1-x102c.google.com ([2607:f8b0:4864:20::102c]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lN942-006jwc-UV for linux-mtd@lists.infradead.org; Fri, 19 Mar 2021 06:56:57 +0000 Received: by mail-pj1-x102c.google.com with SMTP id kr3-20020a17090b4903b02900c096fc01deso4374655pjb.4 for ; Thu, 18 Mar 2021 23:56:54 -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=DT3o+vyjq5h9JvVM7AnYK9reB4mzHg6A95AtdiN7zdA=; b=soKsbpgxseEo9IcXxEmag6c+08vzytKO+JBqvUJU60ihq+yTcoIdqeZv764TlpH4yv 2f86+5DEQs+DEfslUsc7igQNG2sGSWzMV5wL0xg2oFFs6O2xi1lM2VolY6KKGOvPM+yV b2nG0L7kt231lGQlLQ4gCDuMAKcwHhkKlNU4FeOjMCpZN1glQ6iL9WQ24Sl/Wd8KoIAY +2YUSw8Q+Ixwti1X72onf5ujkXNTYcGX/ECVi8eEHat0xNHwOwrvU17BgFafPJkHWsvx q5OOgKZYY28f6U3L4RXLkPoVMVC6+yZ8WygvwWqNnvEGdrn+qGeMSbf9opvHnoX4DHWE 0dmA== 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=DT3o+vyjq5h9JvVM7AnYK9reB4mzHg6A95AtdiN7zdA=; b=VlXErqovWdXlm8BSF+eq+8rNG2+u2VdPCGIsf+3aobFex03/stiT/2oYn+JkuM4hiE lylO71+qgMmRgl3IUEkTqKXxyHy4toCILXa+E8JsLFFk/bT+ECWQ4WjXguSxUmfwHabW cNUm2GdrZBbzJCD7M9nQWmZaPE8s86R8D58z7y1HmfU8EFtIWgypDgiSrv0+4F/0KC5z L1S7+cS7mezIA4yndEvapnQaj7hoEnEnhKliA8HrF697d23gpNcKXw4HO/O8gKXxr3MT HUgTS8NOtVfI3WI5TmG828qmoL+q4Abwu7CW/FOULBDnCtV01Qe7zKrbhd8V0B0gngdF 4/FA== X-Gm-Message-State: AOAM5300lFnK2DVOHPC+4XsxKwdx48DHkigdLczDDZvfGxGsUMMsi5Iw QS88SCPldaOIhINo3QHILt3U+m61Wo8IFQ== X-Google-Smtp-Source: ABdhPJxzL9wWZkh2j9Ylrs6MYK+eFIz1aee84GYFCso7eNH49cBW9zhqyDma/mx+NtSxfBeDT22pXA== X-Received: by 2002:a17:902:bd82:b029:e6:1ef0:82dd with SMTP id q2-20020a170902bd82b02900e61ef082ddmr13201940pls.43.1616137012797; Thu, 18 Mar 2021 23:56:52 -0700 (PDT) Received: from ISCNPF1JZGWX.infineon.com (zz20174137476F6254EB.userreverse.dion.ne.jp. [111.98.84.235]) by smtp.gmail.com with ESMTPSA id o123sm4333414pfb.16.2021.03.18.23.56.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Mar 2021 23:56:52 -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 v4 3/6] mtd: spi-nor: spansion: Add support for Read/Write Any Register Date: Fri, 19 Mar 2021 15:56:31 +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-20210319_065655_917576_1EC6CD88 X-CRM114-Status: GOOD ( 16.14 ) X-Spam-Score: 0.1 (/) X-Spam-Report: Spam detection software, running on the system "desiato.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:102c listed in] [list.dnswl.org] 0.2 FREEMAIL_ENVFROM_END_DIGIT Envelope-from freemail username ends in digit [tkuw584924[at]gmail.com] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -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_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's 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 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..52a427d0af02 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 == 1) + 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 Fri Mar 19 06:57: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: 1455660 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=DyKpKDkm; 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=YWmiDECE; 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 4F1vrn6xHFz9sWP for ; Fri, 19 Mar 2021 17:59:21 +1100 (AEDT) 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=uguXxXFhcSJKQkXIJo83lr3WCnlLUEu/2HiYD2qoRdA=; b=DyKpKDkmAhDxqFoUuI74mCd9v iqP0fYtqKUaQtGn8vnMC52D1x390COM+ynzeC+i/YeJ2P/lTb2EVeGtS97MFhZ9i0KNnLIqAmHheP XYYILfTi7YMTxQ6mhDoH/1A3guNJbeISv5kk1qGCQIDTZdwltVp037BMvytMl3NZD+zGBXlon3QWW WIjD4ecB/7xacB+DiBCjipIRAFHdeaxrivcx82m9ncVRG6YlwrWDYpAcWAZVSpLIPNbH9KA3y3uVE oQ0CNrECF1oAkB312FXEXKCbCu4AcCBNSm72OoH7pX87OozhvimjRL6FfibO0Fkg8jaj8sM0SsqfG HXc3psNjw==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lN95N-006kCb-82; Fri, 19 Mar 2021 06:58:17 +0000 Received: from mail-pf1-x42d.google.com ([2607:f8b0:4864:20::42d]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lN95H-006kBP-M5 for linux-mtd@lists.infradead.org; Fri, 19 Mar 2021 06:58:14 +0000 Received: by mail-pf1-x42d.google.com with SMTP id h3so5218886pfr.12 for ; Thu, 18 Mar 2021 23:58:11 -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=OqKaSa2/R0uh8r7F2ABsUnuB/YWHoPmw1b8CwDU3yfE=; b=YWmiDECEsVNLVURk42mbFRY7UOnOnOCR/rlrZB7vIR80slo1uq/1Nn3vN3nHmpKLxm ZfquPlbupjwWxI1JIdyCbA1wIp78deldEft0eCXsNlS1mo+uQ0Fqo4P1terDmHwck1LD /DhPicB9RBjVwtOKcUAFUNWAX48UinzMDvEKqtUAXckH/P4IEyUwD9lEWSZbMhgpiws0 jziEUMet0fBKM7l4xDIMFWftULXELvTzOETEBTSUvZThulLp5GY9kSV9Buo3KwUs1+C2 54KK8LsqZW0s/6O59C3bPIEsarEZitM7n2WecTsnFLEBB2hWXxSMsqS76uIKNWPnoEjP AGEg== 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=OqKaSa2/R0uh8r7F2ABsUnuB/YWHoPmw1b8CwDU3yfE=; b=Qe+kyvzxleVLm270nEOFaqSmI66VCyqYRZc8mPNfv3DlW/8oCpqJIf1Iu+EWB92gUI joA4q4IfGobT0rwy/V9N4LLn1KiZPPmOGwl9I/prGrJKKp/bNu4bDq6L3mo1/6WvO5L/ nqJgfTKPwjbTDzP1xcYIYdE4U4VRRuZ2Orw3ZiksXreTpPIOjPk6HUxHaC10MoW91wON Cb8T+KIP42mKhpVeh+BSrReMnXDeMXhkhHBTklDvJiwqj9YiLxG6hQiEyUpdDt20mvwU 6DhPg/apEGqZvLM+Zn0emeMVh6H1Sb/I5olL7AsmtHnrFw0bcCi/DReiZcWzB6yknlYF dMRQ== X-Gm-Message-State: AOAM532Q+IHDksK+kVI+EwsMaBUeEzwui1FnPLKz4joKslN3ZJ4pyx9+ jV0gDT5gJ1/+KFTk+/cYf+KUJ4UEBqEpbA== X-Google-Smtp-Source: ABdhPJwX5XeZo6gj6T9YJPWRPk9K7//m+bVwSUaLpoVStg3xpK14Z5jefFd4STgUDAQPbYLmwNbaYw== X-Received: by 2002:a63:fa07:: with SMTP id y7mr10400178pgh.213.1616137089832; Thu, 18 Mar 2021 23:58:09 -0700 (PDT) Received: from ISCNPF1JZGWX.infineon.com (zz20174137476F6254EB.userreverse.dion.ne.jp. [111.98.84.235]) by smtp.gmail.com with ESMTPSA id q95sm4400332pjq.20.2021.03.18.23.58.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Mar 2021 23:58:09 -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 v4 4/6] mtd: spi-nor: spansion: Add support for volatile QE bit Date: Fri, 19 Mar 2021 15:57:56 +0900 Message-Id: <6beb496c47d2521c68f8b4d0867cd77c7f8a2821.1616130675.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-20210319_065812_002465_73350EF4 X-CRM114-Status: GOOD ( 17.95 ) X-Spam-Score: 0.1 (/) X-Spam-Report: Spam detection software, running on the system "desiato.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:42d listed in] [list.dnswl.org] 0.2 FREEMAIL_ENVFROM_END_DIGIT Envelope-from freemail username ends in digit [tkuw584924[at]gmail.com] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -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_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's 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 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 52a427d0af02..fdbf43bccc21 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 Fri Mar 19 06:58:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takahiro Kuwano X-Patchwork-Id: 1455661 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=lr7FAOd6; 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=n3qKLu/s; 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 4F1vsM2QtRz9sWb for ; Fri, 19 Mar 2021 17:59:51 +1100 (AEDT) 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=H3FRQuMRuwYnIWzAiBDNKhEbSN4recTNk5dsWsHVWbI=; b=lr7FAOd60/ntlmWIRw3ThCA9p 7CrLOA7nTblY4tF/qLTaD4l5CvgE2MwoUBSV2utWztId1uaKqTjZrLSSOLKUhYD/Uu9B+LCXXTXB1 50/6J6Lx5qomOzZqJmXUep03O0Bq+z0LxI100mfbnSQPlSFdOhcIiQRdUc7ArdXUFAhKiE231dRPK l7GtPoVGx70D9UylpfRDm1khqsEpfD2Wfi2gIXsCxpf5xGYD0xzyMW9F2kHp9HqIidTXprJpThXOr Bwetm4pd3UfLaVSWQHcMQYLgmwew6cmRpCKH9UhFgJzZMbxGEnxzqgSWrF0YZPw+i1Qam+0igYyOj em8kI9ukQ==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lN95v-006kLy-Cb; Fri, 19 Mar 2021 06:58:51 +0000 Received: from mail-pg1-x534.google.com ([2607:f8b0:4864:20::534]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lN95g-006kHG-F7 for linux-mtd@lists.infradead.org; Fri, 19 Mar 2021 06:58:39 +0000 Received: by mail-pg1-x534.google.com with SMTP id n11so3050608pgm.12 for ; Thu, 18 Mar 2021 23:58:35 -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=yHH1vdfwbcRbKBolNPXvtpwqypEwoTjxM2CXH/C+xiY=; b=n3qKLu/sB5fxXLsNKg5H3oE7EAuYwlWkMaVk9r9Vh61UYFXUld30V8BkK8y5tf0TMt IFtV+E0VdJCB99H2qs4/211sC+JTgFELtOBwl8E9Da+AdWc7U3qHMqqF3fnIivy7ExbC CL6k5Sc4mgYsVPMVXJf3p2zfe177PyjIRrv4ApR7Y/2fY16iKlD5qLZTZn2W7cHgwofe 0v0M6yCNCKZyj941BiYug0ZjQQE54sET5wcDISVYlZ8fv5lDPSRu7ILNv1XGVfSk4Suj 16bA87tAfPro7UZV4nXOQkKXd2uJwLHP7tSrbI+USE/dGF//3dLWFxqRG//uwbdPHHVQ 0lKQ== 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=yHH1vdfwbcRbKBolNPXvtpwqypEwoTjxM2CXH/C+xiY=; b=YbVV85RGDuorHszeQG4rdy/RrznW+oegmk74A198S+ADj8nzjX5W+7QAqOEM6dSSHi jufz6DaPO1ihKH089vM5WGuWU550hN1k7APN2l0X2wGHB15kX3qrD0uMbkZHuK4MznXA nyLDOfEC0bpI12aJiWlEx4b6BSpoVZLShcPWcL7mLphHKjVP541BfoDdKEpglIgqntOC 9489DsLTNv+X7wfcRdnSofXcjg8ZyvwzTkxBkrkObyy8qWMMFcSqAGQYCSBDqlN38n1f mX3N47Btm+dSBiBAUdg+uaTYp0TghNLc+qb2VCFMayQDZzq6aukPL7y4h1N7V5H1xQ8W HKBQ== X-Gm-Message-State: AOAM533oFj5Ou2n2gepeBRqca2i+99vtN0nubYSfjuBPNDTM1X1Zs+4r lbNYuszgBBg8OqOSHku9aMH38Gz6YsXLgw== X-Google-Smtp-Source: ABdhPJw4HFY12k/wN6O+l2d2sF5Lcbe+lEjT8cX9mt4Wt0Udg0bL/+ariMFNX7mN5ORaUXd18yb2VQ== X-Received: by 2002:aa7:9804:0:b029:1f1:5340:77c1 with SMTP id e4-20020aa798040000b02901f1534077c1mr7715954pfl.72.1616137114625; Thu, 18 Mar 2021 23:58:34 -0700 (PDT) Received: from ISCNPF1JZGWX.infineon.com (zz20174137476F6254EB.userreverse.dion.ne.jp. [111.98.84.235]) by smtp.gmail.com with ESMTPSA id s62sm4399721pfb.148.2021.03.18.23.58.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Mar 2021 23:58:34 -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 v4 5/6] mtd: spi-nor: spansion: Add status check for multi-die parts Date: Fri, 19 Mar 2021 15:58:22 +0900 Message-Id: <11d5b49f3710fa6a753389012d8a2b56d2791e59.1616130675.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-20210319_065837_791811_0F811C2F X-CRM114-Status: GOOD ( 16.76 ) X-Spam-Score: 0.1 (/) X-Spam-Report: Spam detection software, running on the system "desiato.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:534 listed in] [list.dnswl.org] 0.2 FREEMAIL_ENVFROM_END_DIGIT Envelope-from freemail username ends in digit [tkuw584924[at]gmail.com] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -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_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's 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 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 fdbf43bccc21..04ad8f83dae0 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 Fri Mar 19 06:58:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takahiro Kuwano X-Patchwork-Id: 1455662 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=XkVlVuzg; 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=LqTkTUHr; 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 4F1vtG3C4qz9sWP for ; Fri, 19 Mar 2021 18:00:38 +1100 (AEDT) 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=7Kp/b1gumh39RW2CtxXNYB44znD9JhAC7hPpudqyvF8=; b=XkVlVuzg1vOSt1X+8W6GIfv8Y W8f0WxYyclheKkr1k9ZZhTUGJEVAJldrIXgfsMQM5qcC/Gac9nbNJESdeiPnGxQgoIapgfFoyHVCP ajzvdSGhEdmz/PyuX3xTImEveS8N40orFoLjv/CrBJS3GrUwqRKXNIDVOkdZOKg08hjp8KXh/4r7g nPLS3oIzbTGGHBsWptbL4iSJ4ViYsiLwcRKUCfTfuWhwd67I2s6Pjo3HtSsWPvPB/nChNcdwGTdrQ rSnOeFcjENfXgIVbJecQgvECzhuuAyUgyW5272Cq4Ev5YmuZP2cQMnV/iaylZeQN33E3CL/APdOYh UTvZZlnvw==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lN96b-006kWj-EK; Fri, 19 Mar 2021 06:59:34 +0000 Received: from mail-pf1-x42d.google.com ([2607:f8b0:4864:20::42d]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lN965-006kNn-TE for linux-mtd@lists.infradead.org; Fri, 19 Mar 2021 06:59:05 +0000 Received: by mail-pf1-x42d.google.com with SMTP id h3so5220248pfr.12 for ; Thu, 18 Mar 2021 23:59:01 -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=fHwkrvgQnotmq3yDwvCGVU4YeoM/kdXawY4oQr8aKFQ=; b=LqTkTUHrxjBoBnDSt4uU9YGzu2V9A8TKsaXitFu8hlYWdi30nBDsf4h8zVS+DOhqwf uZZ0hKdDn0EBu86YOQA0b/zpa/ush+egTFmGS71MOyXky5T5XUE/c/K/YEyAog8zCVRm G0lMrRU6vR1tcyGU3AvASxm7ur50bSeYOL1JOjgk6AurgKDyFGF36b43DiV0F6qDZdCE IbF3EBEtV1cVT0qBBqjpZ82MQ2sDUhanHN03pZ7ed8oND62455W99WueV/86fvZ5Z+uL vJVEhmA9F3fsVr4yt9xMH5asRX2e8+xPhagz7Uui4nae1XE6z4AaW/wD6X65OPUY28VC AIug== 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=fHwkrvgQnotmq3yDwvCGVU4YeoM/kdXawY4oQr8aKFQ=; b=ib7I0UwH3O7iji0BzBrQ5InIF6S3Lks0G6DWOnUGa6kCEuqkuN+lJZWTc0/1ihgzlf y8R/RKDQ/qGJ/hMsq7ntF8KZwUcfdaTgsG3ANlNDp/HZdCH08XwlPClTzih5/7rQsVvj fhtH1rjVCYXNUs2c88Usrf1ZFxkWPcuPCoSeCJVCrz/Swc1yQJYhrFj9A5HInvrPDNKD pm0ztwG2HKvrT9HDTfqdao9z9hUseYPbq+4LhF7jxdL2OQ8eiatV8MHCBGl2wGZOgGlM 054+Je8iWzBbvLirmnbvHYcCNm5P9UGLM/dmhMNHSUCmOxQXFdILduwRD6E6QCtjTBQ1 DpTw== X-Gm-Message-State: AOAM530hbsiqaAuaX4pEAu56AKoy4muv9gnRPfMF4SyGhAA+AG6R0Fo+ ryZ6RgHshPprVgZNcWzMV5K5D5nwTcs4FQ== X-Google-Smtp-Source: ABdhPJxnUGJsWNy1p+d6XFNF/Mb+PKLsWHCQTmbNZkMxmgMHGw2hO3q/iiHJZ+6C04/7ZTGY2z9ixA== X-Received: by 2002:a63:5a50:: with SMTP id k16mr10192529pgm.155.1616137140243; Thu, 18 Mar 2021 23:59:00 -0700 (PDT) Received: from ISCNPF1JZGWX.infineon.com (zz20174137476F6254EB.userreverse.dion.ne.jp. [111.98.84.235]) by smtp.gmail.com with ESMTPSA id y7sm4424859pfq.70.2021.03.18.23.58.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Mar 2021 23:58:59 -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 v4 6/6] mtd: spi-nor: spansion: Add s25hl-t/s25hs-t IDs and fixups Date: Fri, 19 Mar 2021 15:58:46 +0900 Message-Id: <76a55d9be126067c631065f31e3e970f90b2c080.1616130675.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-20210319_065903_193353_53DDB081 X-CRM114-Status: GOOD ( 24.17 ) X-Spam-Score: 0.1 (/) X-Spam-Report: Spam detection software, running on the system "desiato.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:42d listed in] [list.dnswl.org] 0.2 FREEMAIL_ENVFROM_END_DIGIT Envelope-from freemail username ends in digit [tkuw584924[at]gmail.com] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -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_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's 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 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 | 115 +++++++++++++++++++++++++++++++++ 1 file changed, 115 insertions(+) diff --git a/drivers/mtd/spi-nor/spansion.c b/drivers/mtd/spi-nor/spansion.c index 04ad8f83dae0..63a10ba28fc1 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,24 @@ 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) + .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) + .fixups = &s25hx_t_fixups }, { "cy15x104q", INFO6(0x042cc2, 0x7f7f7f, 512 * 1024, 1, SPI_NOR_NO_ERASE) }, { "s28hs512t", INFO(0x345b1a, 0, 256 * 1024, 256,