From patchwork Mon Feb 28 13:45:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tudor Ambarus X-Patchwork-Id: 12763324 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B1D00C4332F for ; Mon, 28 Feb 2022 13:49:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=oqg3jNNlShU8/E7dwes4jGkngus7gyqLteoz0Wem7Lo=; b=YCDnfa3dXNHASe 5n7QrZIplBKMcNFwM/+WFoCaGTV1zJmB15Pi/o7ccu0J/W2bF2CN820fjp23/AmAnUKnnln/BOl3K Stb0frDz0gl5pshYqyu5Qakn3Vr964LQnusZHvfKqXeBR+z49fjxaG1PlCo9FrNGXR0vy27BKsG65 CU0QVND3KRyUOk+vxUP0Jx3vmKO+FxueuTP1qGFgt2K//nevuUtvqq7FDG0LjP79OUjLgeAXPzh3u HPnu1Va37sePufSwbZRY9xnDGsUqrz9Vu1wpWBIcwQJH172DW43QmH1Oe1z7956bH3hvVDQtuLmay MeRkXtCq/jtKl6slU+hA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nOgNU-00CfZI-Ts; Mon, 28 Feb 2022 13:47:53 +0000 Received: from esa.microchip.iphmx.com ([68.232.153.233]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nOgL8-00Cec7-M7; Mon, 28 Feb 2022 13:45:28 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1646055926; x=1677591926; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=O51lybEN0s6N++OrOWdENx455gBXcB/cLNp+s4cJKHQ=; b=nqQgwV3gEqiEMUA4JcxmZ7gFQs88aWtx1EdFsFwvrIHSgTM5bGGrFjw8 KyPIdJ9xRqVnLmZ8RuVSBjGauknBBVWqY9KrA03jN7lC14NKStO5aRgA9 ahr5SqGnsDENgESJ765WR+9gnDae/8DlFD8IwfvNXku/uqlHwHurXbn// mYI3t5frSBenwTOnXTk1arOiwcoveM6Lpw+rxSqyteSCzoDdOW+sHxQLO EmNi83fX4OQ/AZVG+ytx+XZhVAynt6B9Pqmb/5x91HFaLcSqf9YvoRmiv jGzCyr93oKMw5N2MqPV+BOkuoVny97f8lQjm2eUZ1IcbHFc4B0Qd9f9aQ A==; X-IronPort-AV: E=Sophos;i="5.90,142,1643698800"; d="scan'208";a="163872939" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa1.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 28 Feb 2022 06:45:25 -0700 Received: from chn-vm-ex01.mchp-main.com (10.10.85.143) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.17; Mon, 28 Feb 2022 06:45:25 -0700 Received: from ROB-ULT-M18064N.mchp-main.com (10.10.115.15) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server id 15.1.2375.17 via Frontend Transport; Mon, 28 Feb 2022 06:45:21 -0700 From: Tudor Ambarus To: , , , , , , Subject: [PATCH v4 3/6] mtd: spi-nor: macronix: Handle ID collision b/w MX25L3233F and MX25L3205D Date: Mon, 28 Feb 2022 15:45:02 +0200 Message-ID: <20220228134505.203270-4-tudor.ambarus@microchip.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220228134505.203270-1-tudor.ambarus@microchip.com> References: <20220228134505.203270-1-tudor.ambarus@microchip.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220228_054526_760796_1BE8B2E0 X-CRM114-Status: GOOD ( 12.07 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jaimeliao@mxic.com.tw, Tudor Ambarus , vigneshr@ti.com, richard@nod.at, linux@rasmusvillemoes.dk, knaerzche@gmail.com, linux-mtd@lists.infradead.org, code@reto-schneider.ch, miquel.raynal@bootlin.com, sr@denx.de, linux-arm-kernel@lists.infradead.org, zhengxunli@mxic.com.tw Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Macronix has a bad habbit of reusing flash IDs. While MX25L3233F supports RDSFDP opcode, MX25L3205D does not support it and does not recommend issuing opcodes that are not supported ("It is not recommended to adopt any other code not in the command definition table, which will potentially enter the hidden mode."). We tested the RDSFDP on the MX25L3205D and the conclusion is that the flash didn't reply anything. Given that it is unlikely that RDSFDP will cause any problems for the old MX25L3205D, differentiate between the two flashes by parsing SFDP. Tested MX25L3233F. Generated a 256 Kbyte random data and did an erase, write, read back and compare test. The flash uses for reads SPINOR_OP_READ_1_4_4 0xeb, for erases SPINOR_OP_BE_4K 0x20, and for writes SPINOR_OP_PP 0x02. Signed-off-by: Tudor Ambarus Acked-by: Pratyush Yadav --- # cat /sys/devices/platform/ahb/ahb:apb/f0020000.spi/spi_master/spi1/spi1.0/spi-nor/jedec_id c22016 # cat /sys/devices/platform/ahb/ahb:apb/f0020000.spi/spi_master/spi1/spi1.0/spi-nor/manufacturer macronix # cat /sys/devices/platform/ahb/ahb:apb/f0020000.spi/spi_master/spi1/spi1.0/spi-nor/partname mx25l3233f # cat /sys/devices/platform/ahb/ahb:apb/f0020000.spi/spi_master/spi1/spi1.0/spi-nor/sfdp > mx25l3233f-sfdp # xxd -p mx25l3233f-sfdp 53464450000101ff00000109300000ffc2000104600000ffffffffffffff ffffffffffffffffffffffffffffffffffffe520f1ffffffff0144eb086b 083b04bbeeffffffffff00ffffff00ff0c200f5210d800ffffffffffffff ffffffffffff003650269cf97764fecfffffffffffff # sha1sum mx25l3233f-sfdp 1b6e0f75b4a6d08d570082992455affa72b2dc81 mx25l3233f-sfdp drivers/mtd/spi-nor/macronix.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/drivers/mtd/spi-nor/macronix.c b/drivers/mtd/spi-nor/macronix.c index d81a4cb2812b..2754bbef3d2e 100644 --- a/drivers/mtd/spi-nor/macronix.c +++ b/drivers/mtd/spi-nor/macronix.c @@ -8,6 +8,24 @@ #include "core.h" +static int mx25l3205d_post_bfpt_fixups(struct spi_nor *nor, + const struct sfdp_parameter_header *bfpt_header, + const struct sfdp_bfpt *bfpt) +{ + /* + * Macronix has a bad habit of reusing flash IDs: MX25L3233F collides + * with MX25L3205D. MX25L3233F defines SFDP tables, while the older + * variant does not. + */ + nor->name = "mx25l3233f"; + + return 0; +} + +static const struct spi_nor_fixups mx25l3205d_fixups = { + .post_bfpt = mx25l3205d_post_bfpt_fixups, +}; + static int mx25l25635_post_bfpt_fixups(struct spi_nor *nor, const struct sfdp_parameter_header *bfpt_header, @@ -44,7 +62,10 @@ static const struct flash_info macronix_nor_parts[] = { { "mx25l1606e", INFO(0xc22015, 0, 64 * 1024, 32) NO_SFDP_FLAGS(SECT_4K) }, { "mx25l3205d", INFO(0xc22016, 0, 64 * 1024, 64) - NO_SFDP_FLAGS(SECT_4K) }, + /* ID collision with mx25l3233f. */ + PARSE_SFDP + NO_SFDP_FLAGS(SECT_4K) + .fixups = &mx25l3205d_fixups }, { "mx25l3255e", INFO(0xc29e16, 0, 64 * 1024, 64) NO_SFDP_FLAGS(SECT_4K) }, { "mx25l6405d", INFO(0xc22017, 0, 64 * 1024, 128)