From patchwork Mon Feb 28 13:45:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tudor Ambarus X-Patchwork-Id: 12763318 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 5AFFFC433F5 for ; Mon, 28 Feb 2022 13:47: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=hIR1iLVMJ1Z02hqlfJzyFxBhJXO6FufcrZmKR13E534=; b=AXYt6sqLvgPiT+ y4Yj2xjuJCZFHHunJwiw3nxM7VxNBaasIeE8ghc0aHY2e7WsNmi0pIB+DqLU0b35lywwt4OOeGg27 GgtUuGWnHwXKAHnsdwrbQZayyEiPAq5vJZE7HCV6VSk2ryVjZye4NFp7usBVhVWMoTyjus2zSJ4qQ GYP1bhp2w6Qv1Kk3jexgtyzXrNTLszX6mR96sASoPv79UApLtXx3g5NZzGHOADnQ2c3WpobPX9XwH CX9I80L2WQqSQ2z6Wu9dkA+I1/fwF1pCmmAeyRzMGRWBu6WsjXp0E5vaBsnx692We9OETSc39YTT5 xKf8vbc91ZlmsSrob1VQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nOgLq-00Ceq9-0B; Mon, 28 Feb 2022 13:46:10 +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 1nOgKz-00Ceag-F2; Mon, 28 Feb 2022 13:45:19 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1646055917; x=1677591917; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=VrrZ+KGenArnCpqI9TOTAE/3rDVOVu2isEdcFVmKnR4=; b=H1w1nRpAk2+7h6Nfd2DDNlI2REZ/zstklwaWxwajTjF/vaICt5LIWcHG z/drykqOCTzFACxwEw99IgE9oxZTt6Q+5WpBgve1DxTfUOUt35Z6jS0pE /zOHyyLcnXAt+FWlJFD+zuM1KCp/RKFgcP0PdkFl8zzAM5Fje+kod8Ev3 UBWzsdAuN3zwvAJYfUx5T5RHuDA+I8xIB5HcB3MtMeJr7YlP4KmD8jSsa xH7dmiorty3Ik1rXK1CPQ7feuNjzEeVxchtM/RY7KuoMHe2DbChCF7ik4 EFEHK2+YC14/WnA8XY3Nd949oslVlemVa7nhSQ/ExFCH+KDMWhS2JDXhj g==; X-IronPort-AV: E=Sophos;i="5.90,142,1643698800"; d="scan'208";a="155113048" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa3.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 28 Feb 2022 06:45:16 -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:16 -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:12 -0700 From: Tudor Ambarus To: , , , , , , Subject: [PATCH v4 1/6] mtd: spi-nor: core: Report correct name in case of ID collisions Date: Mon, 28 Feb 2022 15:45:00 +0200 Message-ID: <20220228134505.203270-2-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_054517_550104_A77F402E X-CRM114-Status: GOOD ( 13.54 ) 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 Provide a way to report the correct flash name in case of ID collisions. There will be a single flash_info entry when flash IDs collide, and the differentiation between the flash types will be made at runtime if possible. Signed-off-by: Tudor Ambarus Reviewed-by: Michael Walle Reviewed-by: Pratyush Yadav --- drivers/mtd/spi-nor/core.c | 5 ++++- drivers/mtd/spi-nor/sysfs.c | 2 +- include/linux/mtd/spi-nor.h | 2 ++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c index 9014008e60b3..fbf3278ba29a 100644 --- a/drivers/mtd/spi-nor/core.c +++ b/drivers/mtd/spi-nor/core.c @@ -3026,7 +3026,10 @@ int spi_nor_scan(struct spi_nor *nor, const char *name, /* No mtd_info fields should be used up to this point. */ spi_nor_set_mtd_info(nor); - dev_info(dev, "%s (%lld Kbytes)\n", info->name, + if (!nor->name) + nor->name = info->name; + + dev_info(dev, "%s (%lld Kbytes)\n", nor->name, (long long)mtd->size >> 10); dev_dbg(dev, diff --git a/drivers/mtd/spi-nor/sysfs.c b/drivers/mtd/spi-nor/sysfs.c index 9aec9d8a98ad..017119768f32 100644 --- a/drivers/mtd/spi-nor/sysfs.c +++ b/drivers/mtd/spi-nor/sysfs.c @@ -25,7 +25,7 @@ static ssize_t partname_show(struct device *dev, struct spi_mem *spimem = spi_get_drvdata(spi); struct spi_nor *nor = spi_mem_get_drvdata(spimem); - return sysfs_emit(buf, "%s\n", nor->info->name); + return sysfs_emit(buf, "%s\n", nor->name); } static DEVICE_ATTR_RO(partname); diff --git a/include/linux/mtd/spi-nor.h b/include/linux/mtd/spi-nor.h index 5e25a7b75ae2..449496b57acb 100644 --- a/include/linux/mtd/spi-nor.h +++ b/include/linux/mtd/spi-nor.h @@ -351,6 +351,7 @@ struct spi_nor_flash_parameter; * @bouncebuf: bounce buffer used when the buffer passed by the MTD * layer is not DMA-able * @bouncebuf_size: size of the bounce buffer + * @name: used to point to correct name in case of ID collisions. * @info: SPI NOR part JEDEC MFR ID and other info * @manufacturer: SPI NOR manufacturer * @addr_width: number of address bytes @@ -380,6 +381,7 @@ struct spi_nor { struct spi_mem *spimem; u8 *bouncebuf; size_t bouncebuf_size; + const char *name; const struct flash_info *info; const struct spi_nor_manufacturer *manufacturer; u8 addr_width; From patchwork Mon Feb 28 13:45:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tudor Ambarus X-Patchwork-Id: 12763319 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 F047DC433F5 for ; Mon, 28 Feb 2022 13:48:09 +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=1UCZyX1ZXvCZAEpU4zEx9J3GMmdmPe1Tf/miHRtIMzQ=; b=CjkfhdGkG9eKgC oepaKeBGaB0Ds/s048RK2GIHjt51vmOdqIDKpmrLhXDAYMJJoeOU+nS+D7HzDeYtWZFqG3XYZBCpW VbPIwtZBCqwP/tFsIeMa7CZ2t00hH0d8XDXUm3sHV9jMepQQKcGDNvD2A698kULMdHamrBofCYbP1 STVittZxYX3+vKHXRp/JHZMiQHEIuih1HW6LtTfGpJ9YtVEY1vpWjQa5HjDnNmGfIU1PQ+MZgxVnc TSTWuiK6Emg9MuZ6APQjjXSdT/JhaP5v7nkitHjCcLMO/uzBayy7ZQzjyUSTcH33w1URfLNf5Rjkz E1gWw5QkiRAcz5H6Y5yQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nOgMU-00Cf65-21; Mon, 28 Feb 2022 13:46:50 +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 1nOgL3-00Ceag-ND; Mon, 28 Feb 2022 13:45:22 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1646055921; x=1677591921; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=J/WuqtnG33l8BdsT5MMNAXqtTubyZUv6CjU6g24KWa0=; b=U8HBg+I/UeTP/A9IcLCJrO5kAjQjiSdvpyj8paayGbOl+dkKnU7qEL3U N7IPVfNH/Dz5Pmlv1nLVHymxdyOXC3fFonxGsoIl7V2t5R/lXygOFpSuT fnmrMV+xBaW75CyCzZT/Wghz/cIhvRhi0CRwqkxSyIgqckjiokvKGgMle nAWhWxm9MTE8sfjO+2mY81ls9Yoi3SkzX6vjDRKQkZaTgB6ZLM/TmOKQn /M5ub/UBf8tM7b4XPAdSC1Qt47cXQenWxIVxXUXGY0E6fCSZDZDJqQ+ft zhXhlUBC6uQDIRldaOgIzPFgrubr/N2PS4Um3T+CV7pMcKv7530j7fMZa w==; X-IronPort-AV: E=Sophos;i="5.90,142,1643698800"; d="scan'208";a="155113054" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa3.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 28 Feb 2022 06:45:21 -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:20 -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:16 -0700 From: Tudor Ambarus To: , , , , , , Subject: [PATCH v4 2/6] mtd: spi-nor: core: Handle ID collisions between SFDP & non-SFDP flashes Date: Mon, 28 Feb 2022 15:45:01 +0200 Message-ID: <20220228134505.203270-3-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_054521_798417_443F856A X-CRM114-Status: GOOD ( 13.09 ) 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 A typical differentiator between flashes whose ID collide is whether they support SFDP or not. For such a collision there will be a single flash_info entry where the developer should specify: 1/ PARSE_SFDP - so that the flash that supports SFDP to initialize its parameters by parsing the SFDP tables 2/ any of the no_sfdp_flags less SPI_NOR_SKIP_SFDP, to initialize the flash parameters via the static no_sfdp_flags for the flash that doesn't support SFDP. Use the logic the above to handle ID collisions between SFDP & non-SFDP flashes. Signed-off-by: Tudor Ambarus --- drivers/mtd/spi-nor/core.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c index fbf3278ba29a..aef00151c116 100644 --- a/drivers/mtd/spi-nor/core.c +++ b/drivers/mtd/spi-nor/core.c @@ -2639,8 +2639,17 @@ static int spi_nor_init_params(struct spi_nor *nor) if (nor->info->parse_sfdp) { ret = spi_nor_parse_sfdp(nor); if (ret) { - dev_err(nor->dev, "BFPT parsing failed. Please consider using SPI_NOR_SKIP_SFDP when declaring the flash\n"); - return ret; + /* + * Handle ID collisions between flashes that support + * SFDP and flashes that don't. Initialize parameters + * for the flash that doesn't support SFDP. + */ + if (nor->info->no_sfdp_flags & ~SPI_NOR_SKIP_SFDP) { + spi_nor_no_sfdp_init_params(nor); + } else { + dev_err(nor->dev, "BFPT parsing failed. Please consider using SPI_NOR_SKIP_SFDP when declaring the flash\n"); + return ret; + } } } else if (nor->info->no_sfdp_flags & SPI_NOR_SKIP_SFDP) { spi_nor_no_sfdp_init_params(nor); 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) From patchwork Mon Feb 28 13:45:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tudor Ambarus X-Patchwork-Id: 12763325 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 B29F4C433EF for ; Mon, 28 Feb 2022 13:50:24 +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=WdpqAcIgnfLMDNii26vgbfzM88zP1SXREeteV3fa7DY=; b=rSq60ghbWxUDjJ GH/3gssyzJpHSewYmxIF+oDXc3ONkBEW4LMe1i2BcCUUZFcOcBiMR2AI8S0emWhYjOMTwiU0s8baP W4K1hR3g7vWD9Yh1LI1gk9M/JLEJRifFRFRpVfue1JQCfEGS7tcYRTDJjFyn+GOgwC71LM8hA5BJ/ K10TgNYxO6PEtgmquCR6apSxP3Mr4oRllYCRfpWN4bitw3V1fXdZReGKQ4LE0UBDmbFV19t7CrHV0 DcmSKfVETdrEGzzZyqV05VscFT8ooZIkXmFzdFJQKqkl8bzF8xWcgK0GzmzJTtojCdC525ozFnJ85 dtCP43HYUra3QnbNihVQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nOgOS-00Cfwn-Rs; Mon, 28 Feb 2022 13:48: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 1nOgLD-00Cec7-DZ; Mon, 28 Feb 2022 13:45:32 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1646055931; x=1677591931; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Gccul47yRy9Y9vzsi27KwhQ7Bx4nV7g9umfHMvg/wOc=; b=2LgBUvg0BOl7eH67sfQ75BBsGTKHjO4kWtc1RJj818sLceUJTS/R9Rho s9ZjE9vQqDyfr2UN27j55EoyuJhNXC1lnwJ6sGhjTO5bpIZEmjdanySBk zrOLcrrM/6EtDBv2aHe+7touu26nJ8F0CzXWqmKTsezh5r8u+8BPFlrj4 NsB9wZGOkguxFEJPQkvuJnOnc0tStEWxDa8v98fLRGG4xwPXiJHjMuNOL sOj8yfNumMt+B0sJoD/LyzQoecYtG8tnSew/P8KllMCfwmwNqstRmQJ9f EX3cgUPj4olz0/ZJuvxDT16xXedtynEESn6N1UHmRdnZ0TnN9S5QiJe9m g==; X-IronPort-AV: E=Sophos;i="5.90,142,1643698800"; d="scan'208";a="163872969" 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:30 -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:29 -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:25 -0700 From: Tudor Ambarus To: , , , , , , Subject: [PATCH v4 4/6] mtd: spi-nor: macronix: Handle ID collision b/w MX25L12805D and MX25L12835F Date: Mon, 28 Feb 2022 15:45:03 +0200 Message-ID: <20220228134505.203270-5-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_054531_504434_C08A3577 X-CRM114-Status: GOOD ( 11.03 ) 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 MX25L12835F supports RDSFDP opcode, MX25L12805D does not. Given that it is unlikely that RDSFDP will cause any problems for the old MX25L12805D, differentiate between the two flashes by parsing SFDP. cc: Heiko Thiery Signed-off-by: Tudor Ambarus Acked-by: Pratyush Yadav --- # cat /sys/devices/platform/soc@0/30800000.bus/30bb0000.spi/spi_master/spi0/spi0 .0/spi-nor/sfdp | xxd -p 53464450000101ff00000109300000ffc2000104600000ffffffffffffff ffffffffffffffffffffffffffffffffffffe520f1ffffffff0744eb086b 083b04bbfeffffffffff00ffffff44eb0c200f5210d800ffffffffffffff ffffffffffff003600279df9c06485cbffffffffffff 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 2754bbef3d2e..45c2f2c50e56 100644 --- a/drivers/mtd/spi-nor/macronix.c +++ b/drivers/mtd/spi-nor/macronix.c @@ -26,6 +26,24 @@ static const struct spi_nor_fixups mx25l3205d_fixups = { .post_bfpt = mx25l3205d_post_bfpt_fixups, }; +static int mx25l12805d_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: MX25L12835F collides + * with MX25L12805D. MX25L12835F defines SFDP tables, while the older + * variant does not. + */ + nor->name = "mx25l12835f"; + + return 0; +} + +static const struct spi_nor_fixups mx25l12805d_fixups = { + .post_bfpt = mx25l12805d_post_bfpt_fixups, +}; + static int mx25l25635_post_bfpt_fixups(struct spi_nor *nor, const struct sfdp_parameter_header *bfpt_header, @@ -82,8 +100,11 @@ static const struct flash_info macronix_nor_parts[] = { { "mx25u6435f", INFO(0xc22537, 0, 64 * 1024, 128) NO_SFDP_FLAGS(SECT_4K) }, { "mx25l12805d", INFO(0xc22018, 0, 64 * 1024, 256) + /* ID collision with mx25l12835f. */ + PARSE_SFDP FLAGS(SPI_NOR_HAS_LOCK | SPI_NOR_4BIT_BP) - NO_SFDP_FLAGS(SECT_4K) }, + NO_SFDP_FLAGS(SECT_4K) + .fixups = &mx25l12805d_fixups }, { "mx25l12855e", INFO(0xc22618, 0, 64 * 1024, 256) }, { "mx25r1635f", INFO(0xc22815, 0, 64 * 1024, 32) NO_SFDP_FLAGS(SECT_4K | SPI_NOR_DUAL_READ | From patchwork Mon Feb 28 13:45:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tudor Ambarus X-Patchwork-Id: 12763326 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 A2C38C433EF for ; Mon, 28 Feb 2022 13:51:52 +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=q66werd0yaTXLt+EPYmccsYqay21c52H1rbp1ztym2A=; b=f3aaiDrdA3PZtn z0DwOl9mJY1I3x2vt/4y4N3e8cEdridcQo7mQ4wt4chXuM+shu0GwtO0noIOYDlWjT8VnpukH+MfV zScrguhRsCu+Zl5oiKh6htk6Zt3mwIQLTpSAU58amOFaNSKSovnc23Dp/Hip+84X7azIcpzQyO2yj 1szusapkTuwKX0aRBHMgP3b7LAogjzsWN6bc0+xV53whJqEYSyWrQgGDYPVUGEuxIUD0MV9BAHWWX sIIkSUdSK3DZKMm1k8C9sWkr15uE4jqlArsaZL1ltDzpgZDFZ/2YTeOzuju/5T0pxR9h34XwrJCcM vsnxhyMTjRZA4YbG7vCA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nOgPy-00CgXn-Vi; Mon, 28 Feb 2022 13:50:27 +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 1nOgLH-00Cedt-G0; Mon, 28 Feb 2022 13:45:37 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1646055935; x=1677591935; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=hPf+N49vb4FBg7SMEOq7pUm2eOcxiFBSj32THyvL1XI=; b=Zznn9awRyO3vH/sd/L7om0IFCFWqABNy/WK1Y+ujzDF9wRSU2spkbxQo kWKOEsEk+shnjjMj0i/MWDZK4MhebO2dSFKkq/YOYmV7X6iwhRGzgJCDt X8sxm4BBJRItbVm0kOBASsQ9nkDO9Iml4yXFMxltzgAajazpwKMl340mb GNwoMdAEQ/d7PePwSORyNShJx2VBcCawpHl05IVuTKIOQCYVslKHeg2US AbOqNzXSBxLt/3YH1GSIMdsrMetYqWQIj7bLzz9Xfd3RW5deceJ21F6HL l+j/qR/Jq4ouiC/FbYnWvYMthKIbZvjRtSI/Xsld+4huPE+fnVooVg2p2 Q==; X-IronPort-AV: E=Sophos;i="5.90,142,1643698800"; d="scan'208";a="155113072" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa3.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 28 Feb 2022 06:45:34 -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:34 -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:30 -0700 From: Tudor Ambarus To: , , , , , , Subject: [PATCH v4 5/6] mtd: spi-nor: Introduce Manufacturer ID collisions driver Date: Mon, 28 Feb 2022 15:45:04 +0200 Message-ID: <20220228134505.203270-6-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_054535_588475_9B60D3D4 X-CRM114-Status: GOOD ( 21.20 ) 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 Some manufacturers completely ignore the manufacturer's identification code standard (JEP106) and do not define the manufacturer ID continuation scheme. This will result in manufacturer ID collisions. An an example, JEP106BA requires Boya that it's manufacturer ID to be preceded by 8 continuation codes. Boya's identification code must be: 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x68. But Boya ignores the continuation scheme and its ID collides with the manufacturer defined in bank one: Convex Computer. Introduce the manuf-id-collisions driver in order to address ID collisions between manufacturers. flash_info entries will be added in a first come, first served manner. Differentiation between flashes will be done at runtime if possible. Where runtime differentiation is not possible, new compatibles will be introduced, but this will be done as a last resort. Every new flash addition that define the SFDP tables, should dump its SFDP tables in the patch's comment section below the --- line, so that we can reference it in case of collisions. Signed-off-by: Tudor Ambarus Tested-by: George Brooke --- drivers/mtd/spi-nor/Makefile | 1 + drivers/mtd/spi-nor/core.c | 3 +++ drivers/mtd/spi-nor/core.h | 1 + drivers/mtd/spi-nor/manuf-id-collisions.c | 32 +++++++++++++++++++++++ drivers/mtd/spi-nor/sysfs.c | 2 +- include/linux/mtd/spi-nor.h | 6 ++++- 6 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 drivers/mtd/spi-nor/manuf-id-collisions.c diff --git a/drivers/mtd/spi-nor/Makefile b/drivers/mtd/spi-nor/Makefile index 6b904e439372..48763d10daad 100644 --- a/drivers/mtd/spi-nor/Makefile +++ b/drivers/mtd/spi-nor/Makefile @@ -1,6 +1,7 @@ # SPDX-License-Identifier: GPL-2.0 spi-nor-objs := core.o sfdp.o swp.o otp.o sysfs.o +spi-nor-objs += manuf-id-collisions.o spi-nor-objs += atmel.o spi-nor-objs += catalyst.o spi-nor-objs += eon.o diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c index aef00151c116..80d6ce41122a 100644 --- a/drivers/mtd/spi-nor/core.c +++ b/drivers/mtd/spi-nor/core.c @@ -1610,6 +1610,7 @@ int spi_nor_sr2_bit7_quad_enable(struct spi_nor *nor) } static const struct spi_nor_manufacturer *manufacturers[] = { + &spi_nor_manuf_id_collisions, &spi_nor_atmel, &spi_nor_catalyst, &spi_nor_eon, @@ -3037,6 +3038,8 @@ int spi_nor_scan(struct spi_nor *nor, const char *name, if (!nor->name) nor->name = info->name; + if (!nor->manufacturer_name) + nor->manufacturer_name = nor->manufacturer->name; dev_info(dev, "%s (%lld Kbytes)\n", nor->name, (long long)mtd->size >> 10); diff --git a/drivers/mtd/spi-nor/core.h b/drivers/mtd/spi-nor/core.h index b7fd760e3b47..f727e632c0ee 100644 --- a/drivers/mtd/spi-nor/core.h +++ b/drivers/mtd/spi-nor/core.h @@ -500,6 +500,7 @@ struct sfdp { }; /* Manufacturer drivers. */ +extern const struct spi_nor_manufacturer spi_nor_manuf_id_collisions; extern const struct spi_nor_manufacturer spi_nor_atmel; extern const struct spi_nor_manufacturer spi_nor_catalyst; extern const struct spi_nor_manufacturer spi_nor_eon; diff --git a/drivers/mtd/spi-nor/manuf-id-collisions.c b/drivers/mtd/spi-nor/manuf-id-collisions.c new file mode 100644 index 000000000000..75c5ad6480ee --- /dev/null +++ b/drivers/mtd/spi-nor/manuf-id-collisions.c @@ -0,0 +1,32 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Used to handle collisions between manufacturers, where manufacturers are + * ignorant enough to not implement the ID continuation scheme described in the + * JEP106 JEDEC standard. + */ + +#include +#include "core.h" + +static void boya_nor_late_init(struct spi_nor *nor) +{ + nor->manufacturer_name = "boya"; +} + +static const struct spi_nor_fixups boya_nor_fixups = { + .late_init = boya_nor_late_init, +}; + +static const struct flash_info id_collision_parts[] = { + /* Boya */ + { "by25q128as", INFO(0x684018, 0, 64 * 1024, 256) + FLAGS(SPI_NOR_HAS_LOCK | SPI_NOR_HAS_TB) + NO_SFDP_FLAGS(SPI_NOR_SKIP_SFDP | SECT_4K | SPI_NOR_DUAL_READ | + SPI_NOR_QUAD_READ) + .fixups = &boya_nor_fixups }, +}; + +const struct spi_nor_manufacturer spi_nor_manuf_id_collisions = { + .parts = id_collision_parts, + .nparts = ARRAY_SIZE(id_collision_parts), +}; diff --git a/drivers/mtd/spi-nor/sysfs.c b/drivers/mtd/spi-nor/sysfs.c index 017119768f32..fa0cf1a96797 100644 --- a/drivers/mtd/spi-nor/sysfs.c +++ b/drivers/mtd/spi-nor/sysfs.c @@ -14,7 +14,7 @@ static ssize_t manufacturer_show(struct device *dev, struct spi_mem *spimem = spi_get_drvdata(spi); struct spi_nor *nor = spi_mem_get_drvdata(spimem); - return sysfs_emit(buf, "%s\n", nor->manufacturer->name); + return sysfs_emit(buf, "%s\n", nor->manufacturer_name); } static DEVICE_ATTR_RO(manufacturer); diff --git a/include/linux/mtd/spi-nor.h b/include/linux/mtd/spi-nor.h index 449496b57acb..3087589d01ac 100644 --- a/include/linux/mtd/spi-nor.h +++ b/include/linux/mtd/spi-nor.h @@ -351,7 +351,10 @@ struct spi_nor_flash_parameter; * @bouncebuf: bounce buffer used when the buffer passed by the MTD * layer is not DMA-able * @bouncebuf_size: size of the bounce buffer - * @name: used to point to correct name in case of ID collisions. + * @name: used to point to correct flash name in case of ID + * collisions. + * @manufacturer_name: used to point to correct manufacturer name in case of + * ID collisions. * @info: SPI NOR part JEDEC MFR ID and other info * @manufacturer: SPI NOR manufacturer * @addr_width: number of address bytes @@ -382,6 +385,7 @@ struct spi_nor { u8 *bouncebuf; size_t bouncebuf_size; const char *name; + const char *manufacturer_name; const struct flash_info *info; const struct spi_nor_manufacturer *manufacturer; u8 addr_width; From patchwork Mon Feb 28 13:45:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tudor Ambarus X-Patchwork-Id: 12763327 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 CB7B3C433EF for ; Mon, 28 Feb 2022 13:53:50 +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=yJGMRXhVQQbGbuaSss734zEMb7jVxGSNsWvR3Cj2Lw0=; b=VMQLlglfwU6olZ 1p4Numh9cQQbNA5JvXbWbrxTj4YoLupBao89iuL9m+Twkad1p0xkqONhP2yJFT0PJ2A4gajrPVIkJ H7H/zn2bxGuua0AEgaIBJ/TYKeFojq9ZPLOsWUBo9a2C6tiI1jtcKpOJFNXRPv7K7h85FkN/Plpb2 T9eg2ldf2kHEnNe1hDGKO3nSBCeGEcXAGkFQ8wID9VTq1NGeYy+Q9nMNqAd08vbU+DKXHkEsVnxM9 id78h3O3jl45LqUNcowXgU0oM+xCVw/ADv12lVrH/SAHh28P3u7tfi0WNXAWvwXOX1tEIQ1L7M24V iwls9p0O9pTLwSrY/Img==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nOgRc-00Ch46-Uw; Mon, 28 Feb 2022 13:52:10 +0000 Received: from esa.microchip.iphmx.com ([68.232.154.123]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nOgLN-00Cefj-LQ; Mon, 28 Feb 2022 13:45:43 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1646055941; x=1677591941; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=+uh6n1H0rQZDj/XVLiHcHjDe8r47+9/28l+o2v37pSs=; b=0sDhWAIdXo89bwor00Ai1NHZdKKUi00L3kiSnLqBRVtvpKh6mhdblzhg 0W2yKk+SJedjrMhcFTqsZOe2sCaWm1luHNNDKb8F6zA5yfay2JSKryoTF rXwRw4GjISLQW6Sk8hMrJikfDwqZN7BLXYMJ8VNs3yMzQmUSMBTF/MWPD WY7OFWAuJ+H4XUi97bKCWvpZ9qCLBHUgfwG2bgj9uzFj9cFD/Oehgfois RbxgAPuXCNpTRvBNRvanCIlX983rSL7QbweMqbeoCCwnCV+50PViz/yP6 ULCX5zyHQS+FiLDUaaqIKntZQ080xNHhudsVVJuIXGebKM7z+VVa1iRBB w==; X-IronPort-AV: E=Sophos;i="5.90,142,1643698800"; d="scan'208";a="147499224" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa4.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 28 Feb 2022 06:45:39 -0700 Received: from chn-vm-ex01.mchp-main.com (10.10.85.143) by chn-vm-ex01.mchp-main.com (10.10.85.143) 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:38 -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:34 -0700 From: Tudor Ambarus To: , , , , , , Subject: [PATCH v4 6/6] mtd: spi-nor: manuf-id-collisions: Add support for xt25f128b Date: Mon, 28 Feb 2022 15:45:05 +0200 Message-ID: <20220228134505.203270-7-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_054541_831076_B7D95D5F X-CRM114-Status: UNSURE ( 9.09 ) X-CRM114-Notice: Please train this message. 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 Flash does not support continuation codes and may collide with a flash of other manufacturer, Intersil being an example. Add support for xt25f128b. Signed-off-by: Tudor Ambarus Tested-by: Chris Morgan --- 0000000 4653 5044 0100 ff01 0000 0901 0030 ff00 0000010 000b 0301 0060 ff00 ffff ffff ffff ffff 0000020 ffff ffff ffff ffff ffff ffff ffff ffff 0000030 20e5 fff1 ffff 07ff eb44 6b08 3b08 bb42 0000040 ffee ffff ffff ff00 ffff ff00 200c 520f 0000050 d810 ff00 ffff ffff ffff ffff ffff ffff 0000060 3600 2700 f99f 6477 e8d9 ffff drivers/mtd/spi-nor/manuf-id-collisions.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/mtd/spi-nor/manuf-id-collisions.c b/drivers/mtd/spi-nor/manuf-id-collisions.c index 75c5ad6480ee..0447e245f4b1 100644 --- a/drivers/mtd/spi-nor/manuf-id-collisions.c +++ b/drivers/mtd/spi-nor/manuf-id-collisions.c @@ -17,6 +17,15 @@ static const struct spi_nor_fixups boya_nor_fixups = { .late_init = boya_nor_late_init, }; +static void xtx_nor_late_init(struct spi_nor *nor) +{ + nor->manufacturer_name = "xtx"; +} + +static const struct spi_nor_fixups xtx_nor_fixups = { + .late_init = xtx_nor_late_init, +}; + static const struct flash_info id_collision_parts[] = { /* Boya */ { "by25q128as", INFO(0x684018, 0, 64 * 1024, 256) @@ -24,6 +33,11 @@ static const struct flash_info id_collision_parts[] = { NO_SFDP_FLAGS(SPI_NOR_SKIP_SFDP | SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) .fixups = &boya_nor_fixups }, + + /* XTX (XTX Technology Limited) */ + { "xt25f128b", INFO(0x0b4018, 0, 64 * 1024, 256) + PARSE_SFDP + .fixups = &xtx_nor_fixups }, }; const struct spi_nor_manufacturer spi_nor_manuf_id_collisions = {