Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp2221462pxm; Fri, 4 Mar 2022 11:42:08 -0800 (PST) X-Google-Smtp-Source: ABdhPJyMkboZhmBquaGZbibuOPHl6AE3wAaTnDwa7cJfRN5dukWM+4radJ7CVkbMaAlThblWSK8s X-Received: by 2002:a17:903:2285:b0:151:ae75:21c6 with SMTP id b5-20020a170903228500b00151ae7521c6mr64585plh.32.1646422927977; Fri, 04 Mar 2022 11:42:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646422927; cv=none; d=google.com; s=arc-20160816; b=WbNjAcVy76KJPDbE7DtIiqGr1lM4tbEZF8FBPbpYbv6cO5kKD1SPMPsEh0T1loI9uR /O33cGyEQ+erHrKXTg4ROoOGV3mzDqsvskjIzKUMCTpCpqOJd7+spiQu5gWnTQ07biuC oJB5vpwD9RvJiU1lzLHBdAV/8R/JvBASAZ/BiAsslXyXNtnY2i/7kOfrERLk7YbcJNYj j8x/dwBzTFXdfuUVjr6899dfIk+UdV5B+Jp1ilbBA6cVrTAmReAjUfS/BLISWcNNwl9X c+/CrURQhJOYSMmeW8Qp5ke37NcsuUHtw9jUqrf/HRDX3FFXxvJB0b3efXZilaVNUPDx u/fw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=U/LuT+rONVQX6VgKjgRIoVDXdEdfsqzHnymPhpyq4D4=; b=QgS+eXexAvNiIYrTkaft4SOxhLudv9ujlmDZd/PhN3+JOE0NndbjVrwEyWt/xu04To kSS9j4M/oj+jntsoqH9+aS6qJjAsHvAC3byhhAEsoFk+MxGfCIVylIB/x47Euby3nzSl pnE0qn+7elPpLwsb+Lr78ZGVh1WeasvvyzzSP6dYOxTfa1NGqqQzeVNJBr7rHCzZjO6e PnNyX4ZUxV0uExD0aPMFmNeevr9TKC76TAV+BE51bE1oZkueGawdGcpi/eJGeqzHciax iP2od9HLZiXYKs5+E/HSMHS7xm7hUO/t4v3vEzaVyyZuN9zUfr2vdAxVtG4NY/9T45Cx pcjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2016061301 header.b=p0ydG4ZH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id t4-20020a6549c4000000b00374509c478csi5478626pgs.456.2022.03.04.11.42.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Mar 2022 11:42:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2016061301 header.b=p0ydG4ZH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3D3982318F5; Fri, 4 Mar 2022 11:17:20 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241843AbiCDSwl (ORCPT + 99 others); Fri, 4 Mar 2022 13:52:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54472 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236781AbiCDSwj (ORCPT ); Fri, 4 Mar 2022 13:52:39 -0500 Received: from ssl.serverraum.org (ssl.serverraum.org [176.9.125.105]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3EA491C1ECC for ; Fri, 4 Mar 2022 10:51:51 -0800 (PST) Received: from mwalle01.kontron.local. (unknown [213.135.10.150]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by ssl.serverraum.org (Postfix) with ESMTPSA id 1D1E722175; Fri, 4 Mar 2022 19:51:48 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2016061301; t=1646419909; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=U/LuT+rONVQX6VgKjgRIoVDXdEdfsqzHnymPhpyq4D4=; b=p0ydG4ZHJrTNCFyMchvneiY8zMwWkmVxx/Crv8uDPltk8wA868yjn3+C+ogMxsPWIqyZlX 3WGQ5xnDiiHt6H6+nYQVbXNm6V6n/J9FEb8/fnnusNo32FOXZdXZF8SH/aWKi4MJLQeFi3 oou8fMQmz8o7w/t8FNtIYMTAGlzP2sc= From: Michael Walle To: Tudor Ambarus , Pratyush Yadav , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra Cc: linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org, heiko.thiery@gmail.com, Michael Walle Subject: [PATCH v1] mtd: spi-nor: unset quad_enable if SFDP doesn't specify it Date: Fri, 4 Mar 2022 19:51:37 +0100 Message-Id: <20220304185137.3376011-1-michael@walle.cc> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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: X-Mailing-List: linux-kernel@vger.kernel.org While the first version of JESD216 specify the opcode for 4 bit I/O accesses, it lacks information on how to actually enable this mode. For now, the one set in spi_nor_init_default_params() will be used. But this one is likely wrong for some flashes, in particular the Macronix MX25L12835F. Thus we need to clear the enable method when parsing the SFDP. Flashes with such an SFDP revision will have to use a flash (and SFDP revision) specific fixup. This might break quad I/O for some flashes which relied on the spi_nor_sr2_bit1_quad_enable() that was formerly set. If your bisect turns up this commit, you'll probably have to set the proper quad_enable method in a post_bfpt() fixup for your flash. Signed-off-by: Michael Walle Tested-by: Heiko Thiery --- changes since RFC: - reworded commit message - added comment about post_bfpt hook Tudor, I'm not sure what you meant with Maybe you can update the commit message and explain why would some flashes fail to enable quad mode, similar to what I did. It doesn't work because the wrong method is chosen? ;) drivers/mtd/spi-nor/sfdp.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/mtd/spi-nor/sfdp.c b/drivers/mtd/spi-nor/sfdp.c index a5211543d30d..6bba9b601846 100644 --- a/drivers/mtd/spi-nor/sfdp.c +++ b/drivers/mtd/spi-nor/sfdp.c @@ -549,6 +549,16 @@ static int spi_nor_parse_bfpt(struct spi_nor *nor, map->uniform_erase_type = map->uniform_region.offset & SNOR_ERASE_TYPE_MASK; + /* + * The first JESD216 revision doesn't specify a method to enable + * quad mode. spi_nor_init_default_params() will set a legacy + * default method to enable quad mode. We have to disable it + * again. + * Flashes with this JESD216 revision need to set the quad_enable + * method in their post_bfpt() fixup if they want to use quad I/O. + */ + params->quad_enable = NULL; + /* Stop here if not JESD216 rev A or later. */ if (bfpt_header->length == BFPT_DWORD_MAX_JESD216) return spi_nor_post_bfpt_fixups(nor, bfpt_header, &bfpt); @@ -562,7 +572,6 @@ static int spi_nor_parse_bfpt(struct spi_nor *nor, /* Quad Enable Requirements. */ switch (bfpt.dwords[BFPT_DWORD(15)] & BFPT_DWORD15_QER_MASK) { case BFPT_DWORD15_QER_NONE: - params->quad_enable = NULL; break; case BFPT_DWORD15_QER_SR2_BIT1_BUGGY: -- 2.30.2