Message ID | 20230712-spi-nor-winbond-w25q128-v1-1-f78f3bb42a1c@linaro.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp766315vqm; Tue, 11 Jul 2023 15:04:51 -0700 (PDT) X-Google-Smtp-Source: APBJJlHcn82oe0p+OsvKKUj/tW8T3kjYInnBs6bTqh1H8+LfD2LdTg1R6u8hdPOuxvg4XqLS4SQZ X-Received: by 2002:a17:902:e54f:b0:1b8:a54c:6183 with SMTP id n15-20020a170902e54f00b001b8a54c6183mr20423559plf.46.1689113091114; Tue, 11 Jul 2023 15:04:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689113091; cv=none; d=google.com; s=arc-20160816; b=JqIYlpyobW4l0n4Zr2W3/WqcsLSwJ/8ciz9V6mn5GK0Zk637pQBqEkxK3ee6vXn4fV X+x3Af/Ak+/6imsF4nAZ1ad3bllDTHrIwtlrM5lt1nXKQoGcc+R/MVoLO6MwDmnPU0zY fGhBM5wEzzKhxPrMvy1KD64aB3T6bIMGalOAxxRFOW1NKIMZo/CmwnI1ZpYOZ9LlxoAa lFCfin3dvjMDuOl0sb/86gDYV3HzAnBoWWEhmNlE6UxtyKU0PNsYg5DHpdptkF6niiMm GJpUJqTEtHyFDPkHkjrwSR7yibP9XHPFoQ5yRDugAvZ3pWkGwY254U7FlrPNwlwPyLSS w1BA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:message-id:content-transfer-encoding :mime-version:subject:date:from:dkim-signature; bh=F0Z+tdeHGTaKzHcow1KpcWdGeQHImw6XYl8ad7qpvIU=; fh=pm4Kai/562l+lZAJZUDmzyuHZ6dwQLU6qQzAPkVpbOI=; b=ZPdB2pg1zELTuzfMDHVU3KVbTa7ET3chE8yR8TdK1nHXKWBq30GXMo6MyPyrqw9Ky3 yj53iJ+lmAfiUrdCDw2EUHfTGpjM8fRkaVOqh7bXFKe89wa4E2/tcAPOJlnBaiXiJTg6 gEJPqIGGtoaluvKuK2RDiQHwHb8qQRWdGAk6F/Pe1iJoipcesp8JTE3Ba7vJv+U1g+li LSMti1px0+tNFjsS4WJ1Dh4rhUekPM1CRexoM896Up0PdPCb6lv+n+gOt7pjbiUibV5C vMU9P3xPFGmTqqsjQLB4GTPcZSquHi5f9mmEfj6inee1cKSVOeFuhEX4knQ5LZw3SprX 7rdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=opoXvky9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n15-20020a170903110f00b001b8a4954be1si2210441plh.595.2023.07.11.15.04.36; Tue, 11 Jul 2023 15:04:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=opoXvky9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231255AbjGKWC7 (ORCPT <rfc822;gnulinuxfreebsd@gmail.com> + 99 others); Tue, 11 Jul 2023 18:02:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49348 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229551AbjGKWC6 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 11 Jul 2023 18:02:58 -0400 Received: from mail-lf1-x12b.google.com (mail-lf1-x12b.google.com [IPv6:2a00:1450:4864:20::12b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 31226170C for <linux-kernel@vger.kernel.org>; Tue, 11 Jul 2023 15:02:57 -0700 (PDT) Received: by mail-lf1-x12b.google.com with SMTP id 2adb3069b0e04-4f95bf5c493so9445104e87.3 for <linux-kernel@vger.kernel.org>; Tue, 11 Jul 2023 15:02:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1689112975; x=1691704975; h=cc:to:message-id:content-transfer-encoding:mime-version:subject :date:from:from:to:cc:subject:date:message-id:reply-to; bh=F0Z+tdeHGTaKzHcow1KpcWdGeQHImw6XYl8ad7qpvIU=; b=opoXvky99JLSERxqHP3e7AadJFBDskor1nn3ZdGiII4s5uVUMvgpRKU11dEzEghN/z qZDr31SmizAnRmueXaV4Fxasr4IaOihv27cwnrOkpneFtyPX9KuMwVk7dba9GGKMNQ/U Brw8S/N5o5pjr/XIE8yJw7Q+IvizmICzRvc+Sf1GoxHbFu0Dn4raiPX9RAHuVugZh5xN rshTpQzb4teh6teJTSa9QQ6+RMmj9zWIwMO7f3xVX5coudjLosmIZtqBPRbAXbsbS2KD K32HQtein9aaNpVh/0GhTCzZF3d113GHWiprgpyLVE6mBKQZ2kx4wVM3ge1Sj8NA673P 90Rw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689112975; x=1691704975; h=cc:to:message-id:content-transfer-encoding:mime-version:subject :date:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=F0Z+tdeHGTaKzHcow1KpcWdGeQHImw6XYl8ad7qpvIU=; b=hKTMX8isPoCsZAG5QS1ceCKS85AKFidKuvJr0oqhPkmpzP0NdwmrWJZjHTR052/YsS noory0quIhaDl19XVPkXsm7ckckrI45H+suYXgyAiQj7X25Y/Wu3YhsAQ4372z+l/MrN zw/Xd17SHPNVTqVbRrKzWEZWB4W2hG3ucv1J7R9XTv1CIMOwgYiZeQiZGeBXWBu/FhQv NK5fYiZFpaBTOnIkic5SOh8tSSQzAmkjwZUgIPTUXrHutX+7WHIeQU7X/GBA0MIZj0ob S84P3WnYRcWbGDyoXgw+pLXGKDxjQ4V3EoECXacQF1alRgUjeQ6AidGOhhHDwehJC+AU 9aww== X-Gm-Message-State: ABy/qLaWTMR+HKfz9QLQ0AR6Hss/7G6dltK55BEVUR6IX+FqtvPjfeiP 6kj7sk2A54ruoVRuZ5rZkdqHNQ== X-Received: by 2002:ac2:4c4b:0:b0:4f8:72fd:ed95 with SMTP id o11-20020ac24c4b000000b004f872fded95mr16316159lfk.22.1689112975359; Tue, 11 Jul 2023 15:02:55 -0700 (PDT) Received: from [127.0.1.1] ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id o1-20020ac24341000000b004eff1163c37sm455369lfl.308.2023.07.11.15.02.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Jul 2023 15:02:54 -0700 (PDT) From: Linus Walleij <linus.walleij@linaro.org> Date: Wed, 12 Jul 2023 00:02:53 +0200 Subject: [PATCH] mtd: spi-nor: Correct flags for Winbond w25q128 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20230712-spi-nor-winbond-w25q128-v1-1-f78f3bb42a1c@linaro.org> X-B4-Tracking: v=1; b=H4sIAIzRrWQC/x3MOQqAQAxA0atIagOTiAteRSxcoqbJ6AyoIN7dw fIV/z8QJahEaLMHgpwa1VsC5RlM22CroM7JwI4LVxNh3BXNB7zURm8zXlwexA0WTEPlWISrGlK 9B1n0/s9d/74f6ioqOWkAAAA= To: Tudor Ambarus <tudor.ambarus@linaro.org>, Pratyush Yadav <pratyush@kernel.org>, Michael Walle <michael@walle.cc>, Miquel Raynal <miquel.raynal@bootlin.com>, Richard Weinberger <richard@nod.at>, Vignesh Raghavendra <vigneshr@ti.com> Cc: linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Linus Walleij <linus.walleij@linaro.org> X-Mailer: b4 0.12.3 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771163448685042610 X-GMAIL-MSGID: 1771163448685042610 |
Series |
mtd: spi-nor: Correct flags for Winbond w25q128
|
|
Commit Message
Linus Walleij
July 11, 2023, 10:02 p.m. UTC
The Winbond W25Q128 (actual vendor name W25Q128JV)
has exactly the same flags as the sibling device
w25q128fw. The devices both require unlocking and
support dual and quad SPI transport.
The actual product naming between devices:
0xef4018: "w25q128" W25Q128JV-IM/JM
0xef7018: "w25q128fw" W25Q128JV-IN/IQ/JQ
The latter device, "w25q128fw" supports features
named DTQ and QPI, otherwise it is the same.
Not having the right flags has the annoying side
effect that write access does not work.
After this patch I can write to the flash on the
Inteno XG6846 router.
Cc: stable@vger.kernel.org
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
drivers/mtd/spi-nor/winbond.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
---
base-commit: 06c2afb862f9da8dc5efa4b6076a0e48c3fbaaa5
change-id: 20230711-spi-nor-winbond-w25q128-321a602ee267
Best regards,
Comments
Hi Linus, Am 2023-07-12 00:02, schrieb Linus Walleij: > The Winbond W25Q128 (actual vendor name W25Q128JV) Not necessarily see below. Do you know what part numbers is written on your flash? > has exactly the same flags as the sibling device > w25q128fw. The devices both require unlocking and > support dual and quad SPI transport. > > The actual product naming between devices: > > 0xef4018: "w25q128" W25Q128JV-IM/JM > 0xef7018: "w25q128fw" W25Q128JV-IN/IQ/JQ Where do you get that string? from winbond.c? Because, then it's incorrect. For 0xef7018 its actually w25q128jv. But that being said, Winbond is known to reuse the IDs among its flashes. From a quick look at various datasheets: 0x60 seems to be DW, FW and NW(Q) series 0x70 seems to be JV(M) 0x80 seems to be NW(M) 0x40 seems to be BV, JV(Q), "V" (probably the first [1]) (Q) denotes the fixed quad enable bit. Now 0x40 are the first ones who where added back in the days. I'm not sure, what kind of winbond devices there were and if they support dual/quad read. Normally, you'd use a .fixups (see w25q256_fixups for example) to dynamically detect the newer flash type and then refine the flags. But because we don't know how the older flashes look like, that would be just guessing :/ Although, I've once thought about fingerprinting the SFDP tables eg. by some hash. But that would assume the SFDP data is not changing a lot on a given device. Not sure if that is the case, we just began to collect SFDP tables of various devices. If it turns out that only SPI_NOR_HAS_LOCK and SPI_NOR_HAS_TB is needed, I'm leaning towards just adding these flags to the w25q128 entry. According to [1] this was already supported back in the days. > The latter device, "w25q128fw" supports features > named DTQ and QPI, otherwise it is the same. > > Not having the right flags has the annoying side > effect that write access does not work. This should only apply to FLAGS(SPI_NOR_HAS_LOCK | SPI_NOR_HAS_TB). I'd guess your flash supports SFDP, then the NO_SFDP_FLAGS should be automatically detected. Could you please dump the SFDP tables (described in [2])? > After this patch I can write to the flash on the > Inteno XG6846 router. > > Cc: stable@vger.kernel.org > Signed-off-by: Linus Walleij <linus.walleij@linaro.org> > --- > drivers/mtd/spi-nor/winbond.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/drivers/mtd/spi-nor/winbond.c > b/drivers/mtd/spi-nor/winbond.c > index 834d6ba5ce70..a67e1d4206f3 100644 > --- a/drivers/mtd/spi-nor/winbond.c > +++ b/drivers/mtd/spi-nor/winbond.c > @@ -121,7 +121,9 @@ static const struct flash_info winbond_nor_parts[] > = { > { "w25q80bl", INFO(0xef4014, 0, 64 * 1024, 16) > NO_SFDP_FLAGS(SECT_4K) }, > { "w25q128", INFO(0xef4018, 0, 64 * 1024, 256) > - NO_SFDP_FLAGS(SECT_4K) }, > + FLAGS(SPI_NOR_HAS_LOCK | SPI_NOR_HAS_TB) > + NO_SFDP_FLAGS(SECT_4K | SPI_NOR_DUAL_READ | > + SPI_NOR_QUAD_READ) }, As mentioned above, could you try without the DUAL_READ/QUAD_READ flags. You can have a look at the debugfs whether the detected capabilities are still the same with and without these flags. -michael [1] https://www.elinux.org/images/f/f5/Winbond-w25q32.pdf [2] https://lore.kernel.org/all/4304e19f3399a0a6e856119d01ccabe0@walle.cc/
Thanks for helping out Michael, I would never get this right without people like you! On Wed, Jul 12, 2023 at 9:04 AM Michael Walle <michael@walle.cc> wrote: > Am 2023-07-12 00:02, schrieb Linus Walleij: > > The Winbond W25Q128 (actual vendor name W25Q128JV) > > Not necessarily see below. Do you know what part numbers is > written on your flash? Yes, if I look at it with a looking glass it says Winbond 25Q128JVF > > has exactly the same flags as the sibling device > > w25q128fw. The devices both require unlocking and > > support dual and quad SPI transport. > > > > The actual product naming between devices: > > > > 0xef4018: "w25q128" W25Q128JV-IM/JM > > 0xef7018: "w25q128fw" W25Q128JV-IN/IQ/JQ > > Where do you get that string? from winbond.c? Yes > Because, > then it's incorrect. For 0xef7018 its actually w25q128jv. No I just confused things, it should be w25q128jv not fw. But the actual names to the right are from the datasheet, they are kind of both actually named "jv" :/ > But that being said, Winbond is known to reuse the IDs among its > flashes. From a quick look at various datasheets: > > 0x60 seems to be DW, FW and NW(Q) series > 0x70 seems to be JV(M) > 0x80 seems to be NW(M) > 0x40 seems to be BV, JV(Q), "V" (probably the first [1]) > > (Q) denotes the fixed quad enable bit. > > Now 0x40 are the first ones who where added back in the days. I'm > not sure, what kind of winbond devices there were and if they > support dual/quad read. > > Normally, you'd use a .fixups (see w25q256_fixups for example) to > dynamically detect the newer flash type and then refine the flags. > But because we don't know how the older flashes look like, that > would be just guessing :/ Although, I've once thought about > fingerprinting the SFDP tables eg. by some hash. But that would > assume the SFDP data is not changing a lot on a given device. Not > sure if that is the case, we just began to collect SFDP tables > of various devices. > > If it turns out that only SPI_NOR_HAS_LOCK and SPI_NOR_HAS_TB > is needed, I'm leaning towards just adding these flags to the > w25q128 entry. According to [1] this was already supported > back in the days. They are absolutely needed, else I cannot write to the flash. > > The latter device, "w25q128fw" supports features > > named DTQ and QPI, otherwise it is the same. > > > > Not having the right flags has the annoying side > > effect that write access does not work. > > This should only apply to FLAGS(SPI_NOR_HAS_LOCK | SPI_NOR_HAS_TB). > > I'd guess your flash supports SFDP, then the NO_SFDP_FLAGS should be > automatically detected. Could you please dump the SFDP tables > (described in [2])? I hope this is correct: root@OpenWrt:/sys/devices/platform/ubus/10001000.spi/spi_master/spi1/spi1.0/spi-nor# cat jedec_id ef4018 root@OpenWrt:/sys/devices/platform/ubus/10001000.spi/spi_master/spi1/spi1.0/spi-nor# cat manufacturer winbond root@OpenWrt:/sys/devices/platform/ubus/10001000.spi/spi_master/spi1/spi1.0/spi-nor# cat partname w25q128 root@OpenWrt:/sys/devices/platform/ubus/10001000.spi/spi_master/spi1/spi1.0/spi-nor# hexdump -v -C sfdp 00000000 53 46 44 50 05 01 00 ff 00 05 01 10 80 00 00 ff |SFDP............| 00000010 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................| 00000020 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................| 00000030 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................| 00000040 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................| 00000050 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................| 00000060 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................| 00000070 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................| 00000080 e5 20 f9 ff ff ff ff 07 44 eb 08 6b 08 3b 42 bb |. ......D..k.;B.| 00000090 fe ff ff ff ff ff 00 00 ff ff 40 eb 0c 20 0f 52 |..........@.. .R| 000000a0 10 d8 00 00 36 02 a6 00 82 ea 14 c9 e9 63 76 33 |....6........cv3| 000000b0 7a 75 7a 75 f7 a2 d5 5c 19 f7 4d ff e9 30 f8 80 |zuzu...\..M..0..| 000000c0 > As mentioned above, could you try without the DUAL_READ/QUAD_READ flags. It works fine but I cannot judge if it is faster or slower, I guess it mostly affects the speed right? Don't I need to set the PARSE_SFDP macro here, to turn .parse_sfdp = true? > You can have a look at the debugfs whether the detected capabilities > are still the same with and without these flags. This is with no changes: root@OpenWrt:/sys/kernel/debug/spi-nor/spi1.0# cat capabilities Supported read modes by the flash 1S-1S-1S opcode 0x03 mode cycles 0 dummy cycles 0 1S-1S-1S (fast read) opcode 0x0b mode cycles 0 dummy cycles 8 Supported page program modes by the flash 1S-1S-1S opcode 0x02 This is with PARSE_SFDP: root@OpenWrt:/sys/kernel/debug/spi-nor/spi1.0# cat capabilities Supported read modes by the flash 1S-1S-1S opcode 0x03 mode cycles 0 dummy cycles 0 1S-1S-1S (fast read) opcode 0x0b mode cycles 0 dummy cycles 8 1S-1S-2S opcode 0x3b mode cycles 0 dummy cycles 8 1S-2S-2S opcode 0xbb mode cycles 2 dummy cycles 2 1S-1S-4S opcode 0x6b mode cycles 0 dummy cycles 8 1S-4S-4S opcode 0xeb mode cycles 2 dummy cycles 4 4S-4S-4S opcode 0xeb mode cycles 2 dummy cycles 0 Supported page program modes by the flash 1S-1S-1S opcode 0x02 So indeed it works with SFDP parsing! I'll send an updated patch. I guess a lot of the chips could actually use this but someone has to test them on a 1-by-1 basis? Yours, Linus Walleij
diff --git a/drivers/mtd/spi-nor/winbond.c b/drivers/mtd/spi-nor/winbond.c index 834d6ba5ce70..a67e1d4206f3 100644 --- a/drivers/mtd/spi-nor/winbond.c +++ b/drivers/mtd/spi-nor/winbond.c @@ -121,7 +121,9 @@ static const struct flash_info winbond_nor_parts[] = { { "w25q80bl", INFO(0xef4014, 0, 64 * 1024, 16) NO_SFDP_FLAGS(SECT_4K) }, { "w25q128", INFO(0xef4018, 0, 64 * 1024, 256) - NO_SFDP_FLAGS(SECT_4K) }, + FLAGS(SPI_NOR_HAS_LOCK | SPI_NOR_HAS_TB) + NO_SFDP_FLAGS(SECT_4K | SPI_NOR_DUAL_READ | + SPI_NOR_QUAD_READ) }, { "w25q256", INFO(0xef4019, 0, 64 * 1024, 512) NO_SFDP_FLAGS(SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) .fixups = &w25q256_fixups },