From patchwork Thu Sep 26 14:19:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alvin Zhou X-Patchwork-Id: 1989846 X-Patchwork-Delegate: tudor.ambarus@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=R2MRmchD; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=hnsTG+f+; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XDwqZ173dz1xt6 for ; Fri, 27 Sep 2024 00:25:28 +1000 (AEST) 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: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=kp20bLaA25icVHCTxEZh+6D6n3neAm7P/axMYMnJtUU=; b=R2MRmchDHjXbyn v5vhoTpCTN5Y/AfTFyhKRoj/7O6RkxBSn9uh888Imp53521lkmJRvursQa/u7YejCnKOFakPcX8AG f/NVStkqTyY3XumLlhgHhWD86hzCQZrWMLCEpcA2MTrPmuXT0bS7IQo+hsN+XirghP5nIfFPievV8 ffy1VXA9zhUk5XeG+v5qb5kjQP2N8wRvowM6A/FLNkkuyYpzUM6y6bxUPK+Ix5BH5Sbs8Bnezybqa qOlfTYNcJR2UtavK5oc+nkqNL7OTkB5iDcQr6uEvZNZNEoi5/gjm/eHBjmkejBj1cHxeMKOlUwupe dVRYif/gmo7KB22IUYrw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1stpQj-00000008aOS-3epC; Thu, 26 Sep 2024 14:25:17 +0000 Received: from mail-pj1-x1029.google.com ([2607:f8b0:4864:20::1029]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1stpQg-00000008aMG-1ork for linux-mtd@lists.infradead.org; Thu, 26 Sep 2024 14:25:15 +0000 Received: by mail-pj1-x1029.google.com with SMTP id 98e67ed59e1d1-2e0a950e2f2so391150a91.2 for ; Thu, 26 Sep 2024 07:25:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727360713; x=1727965513; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=7MNbHUjaElO2sctpFFvlUsXRoBevroY7p0SuuxxIX0Q=; b=hnsTG+f+6CTB5X8fvy4RTOXc0L2aV7xxrv0JeWYbAyYAngvYz0FlQ16sHEou/0zhwa RBofWq8I/9EAb7hfV2GhfsIE3AW/BF5wWVoLfwU0tmjQxYdqDakjbKMDTaOuGzF1XU53 WsDqfLD9VaMfOAyxoAbeNdjzl1Hjx8KzL0/uk7sM5ZgsKc2v9i1jCsO79dr3zEmb0Fdx wwgi2PZ0tPLx+dz02mRnr7MzvWAK1Xj5Cka6o91P+Et8A14H80iXmyIOA+2G6+FqoncX sofzUjrVkB3AIFTBJafHR+d/NZqgYku+Fby4xz3Y1/0lmwRIw7dnL58fGj3iixmCmXP8 WdRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727360713; x=1727965513; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7MNbHUjaElO2sctpFFvlUsXRoBevroY7p0SuuxxIX0Q=; b=nXRyH9Aqiz9xZdCxHRq8kTjTgSpOjdhPVFU9VPJbD8s6bHYPGGqzkcdmsjgq3h6Ft8 5D30t35GUGf6xJUS66l/nZ1etlHQNruKKcAMQ9Xjrm9WMeP8nq2UxkFundOX7Of+Xl2x WBLAY+dKP8vtfBH+SeJN1P2ORyaRORcb3EkZnNlwgtbwtVTOMBNZehojU7OoxQKFWxuf 7UkRf7ggh12v3RS53yQLXjBPTrxCoriQZ0pDjraamY7MpKL7MIrzm99fooqm6yPRjsnx BJy6KGJ/FLQTZcWxL4wTix69UfxJ8d0qcjoU32OseaxLryjoyhqiNCkPSHlCy53yi/2j kWZA== X-Gm-Message-State: AOJu0YxOdqEIztJ8SsyN1vKCEZT/h4qkrJumA6hnNG5NqsYwc9RkQDWV j+krbRNvpVHqWryUzX8y4W6cPRyIdXi5nEt5wkfDPX94cn6TGAUG X-Google-Smtp-Source: AGHT+IGQ8aXlt5Srv+G0rBaxkopWyRA/YJw8UA5n/oKow7VUx+iht7yecIrSrolBtJ5uPPIGKRmQSg== X-Received: by 2002:a17:90b:30ca:b0:2e0:90fe:cc2c with SMTP id 98e67ed59e1d1-2e090feee89mr3719879a91.26.1727360713363; Thu, 26 Sep 2024 07:25:13 -0700 (PDT) Received: from twhmp6px (mxsmtp211.mxic.com.tw. [211.75.127.162]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e0b6c4bc3bsm49136a91.2.2024.09.26.07.25.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Sep 2024 07:25:12 -0700 (PDT) Received: from hqs-appsw-a2o.mp600.macronix.com (linux-patcher [172.17.236.67]) by twhmp6px (Postfix) with ESMTPS id A847E802C9; Thu, 26 Sep 2024 22:32:59 +0800 (CST) From: AlvinZhou To: linux-mtd@lists.infradead.org, linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, tudor.ambarus@linaro.org, pratyush@kernel.org, mwalle@kernel.org, miquel.raynal@bootlin.com, richard@nod.at, vigneshr@ti.com, broonie@kernel.org Cc: chengminglin@mxic.com.tw, leoyu@mxic.com.tw, AlvinZhou , JaimeLiao Subject: [PATCH v10 1/6] mtd: spi-nor: add Octal DTR support for Macronix flash Date: Thu, 26 Sep 2024 22:19:51 +0800 Message-Id: <20240926141956.2386374-2-alvinzhou.tw@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240926141956.2386374-1-alvinzhou.tw@gmail.com> References: <20240926141956.2386374-1-alvinzhou.tw@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240926_072514_506508_0D3788F7 X-CRM114-Status: GOOD ( 20.22 ) X-Spam-Score: -2.1 (--) X-Spam-Report: Spam detection software, running on the system "bombadil.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: AlvinZhou Create Macronix specify method for enable Octal DTR mode and set 20 dummy cycles to allow running at the maximum supported frequency for Macronix Octal flash. Use number of dummy cycles which is parse by SFDP then convert it to bit pattern and set in CR2 register. Set CR2 register for enable octal DTR mode. Content analysis details: (-2.1 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [alvinzhou.tw(at)gmail.com] 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: AlvinZhou Create Macronix specify method for enable Octal DTR mode and set 20 dummy cycles to allow running at the maximum supported frequency for Macronix Octal flash. Use number of dummy cycles which is parse by SFDP then convert it to bit pattern and set in CR2 register. Set CR2 register for enable octal DTR mode. Use Read ID to confirm that enabling/disabling octal DTR mode was successful. Macronix ID format is A-A-B-B-C-C in octal DTR mode. To ensure the successful enablement of octal DTR mode, confirm that the 6-byte data is entirely correct. Co-developed-by: Tudor Ambarus Signed-off-by: Tudor Ambarus Signed-off-by: JaimeLiao Signed-off-by: AlvinZhou --- drivers/mtd/spi-nor/macronix.c | 91 ++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) diff --git a/drivers/mtd/spi-nor/macronix.c b/drivers/mtd/spi-nor/macronix.c index ea6be95e75a5..f039819a5252 100644 --- a/drivers/mtd/spi-nor/macronix.c +++ b/drivers/mtd/spi-nor/macronix.c @@ -8,6 +8,24 @@ #include "core.h" +#define MXIC_NOR_OP_RD_CR2 0x71 /* Read configuration register 2 opcode */ +#define MXIC_NOR_OP_WR_CR2 0x72 /* Write configuration register 2 opcode */ +#define MXIC_NOR_ADDR_CR2_MODE 0x00000000 /* CR2 address for setting spi/sopi/dopi mode */ +#define MXIC_NOR_ADDR_CR2_DC 0x00000300 /* CR2 address for setting dummy cycles */ +#define MXIC_NOR_REG_DOPI_EN 0x2 /* Enable Octal DTR */ +#define MXIC_NOR_REG_SPI_EN 0x0 /* Enable SPI */ + +/* Convert dummy cycles to bit pattern */ +#define MXIC_NOR_REG_DC(p) \ + ((20 - (p)) >> 1) + +/* Macronix write CR2 operations */ +#define MXIC_NOR_WR_CR2(addr, ndata, buf) \ + SPI_MEM_OP(SPI_MEM_OP_CMD(MXIC_NOR_OP_WR_CR2, 0), \ + SPI_MEM_OP_ADDR(4, addr, 0), \ + SPI_MEM_OP_NO_DUMMY, \ + SPI_MEM_OP_DATA_OUT(ndata, buf, 0)) + static int mx25l25635_post_bfpt_fixups(struct spi_nor *nor, const struct sfdp_parameter_header *bfpt_header, @@ -185,6 +203,78 @@ static const struct flash_info macronix_nor_parts[] = { } }; +static int macronix_nor_octal_dtr_en(struct spi_nor *nor) +{ + struct spi_mem_op op; + u8 *buf = nor->bouncebuf, i; + int ret; + + /* Use dummy cycles which is parse by SFDP and convert to bit pattern. */ + buf[0] = MXIC_NOR_REG_DC(nor->params->reads[SNOR_CMD_READ_8_8_8_DTR].num_wait_states); + op = (struct spi_mem_op)MXIC_NOR_WR_CR2(MXIC_NOR_ADDR_CR2_DC, 1, buf); + ret = spi_nor_write_any_volatile_reg(nor, &op, nor->reg_proto); + if (ret) + return ret; + + /* Set the octal and DTR enable bits. */ + buf[0] = MXIC_NOR_REG_DOPI_EN; + op = (struct spi_mem_op)MXIC_NOR_WR_CR2(MXIC_NOR_ADDR_CR2_MODE, 1, buf); + ret = spi_nor_write_any_volatile_reg(nor, &op, nor->reg_proto); + if (ret) + return ret; + + /* Read flash ID to make sure the switch was successful. */ + ret = spi_nor_read_id(nor, 4, 4, buf, SNOR_PROTO_8_8_8_DTR); + if (ret) { + dev_dbg(nor->dev, "error %d reading JEDEC ID after enabling 8D-8D-8D mode\n", ret); + return ret; + } + + /* Macronix SPI-NOR flash 8D-8D-8D read ID would get 6 bytes data A-A-B-B-C-C */ + for (i = 0; i < nor->info->id->len; i++) + if (buf[i * 2] != buf[(i * 2) + 1] || buf[i * 2] != nor->info->id->bytes[i]) + return -EINVAL; + + return 0; +} + +static int macronix_nor_octal_dtr_dis(struct spi_nor *nor) +{ + struct spi_mem_op op; + u8 *buf = nor->bouncebuf; + int ret; + + /* + * The register is 1-byte wide, but 1-byte transactions are not + * allowed in 8D-8D-8D mode. Since there is no register at the + * next location, just initialize the value to 0 and let the + * transaction go on. + */ + buf[0] = MXIC_NOR_REG_SPI_EN; + buf[1] = 0x0; + op = (struct spi_mem_op)MXIC_NOR_WR_CR2(MXIC_NOR_ADDR_CR2_MODE, 2, buf); + ret = spi_nor_write_any_volatile_reg(nor, &op, SNOR_PROTO_8_8_8_DTR); + if (ret) + return ret; + + /* Read flash ID to make sure the switch was successful. */ + ret = spi_nor_read_id(nor, 0, 0, buf, SNOR_PROTO_1_1_1); + if (ret) { + dev_dbg(nor->dev, "error %d reading JEDEC ID after disabling 8D-8D-8D mode\n", ret); + return ret; + } + + if (memcmp(buf, nor->info->id->bytes, nor->info->id->len)) + return -EINVAL; + + return 0; +} + +static int macronix_nor_set_octal_dtr(struct spi_nor *nor, bool enable) +{ + return enable ? macronix_nor_octal_dtr_en(nor) : macronix_nor_octal_dtr_dis(nor); +} + static void macronix_nor_default_init(struct spi_nor *nor) { nor->params->quad_enable = spi_nor_sr1_bit6_quad_enable; @@ -194,6 +284,7 @@ static int macronix_nor_late_init(struct spi_nor *nor) { if (!nor->params->set_4byte_addr_mode) nor->params->set_4byte_addr_mode = spi_nor_set_4byte_addr_mode_en4b_ex4b; + nor->params->set_octal_dtr = macronix_nor_set_octal_dtr; return 0; } From patchwork Thu Sep 26 14:19:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alvin Zhou X-Patchwork-Id: 1989847 X-Patchwork-Delegate: tudor.ambarus@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=oTewLIWm; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=LzBVGAfh; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XDwqZ2Ydlz1xtB for ; Fri, 27 Sep 2024 00:25:29 +1000 (AEST) 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: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=dXU2uWX/i5EAGvENQks/B1aAu1FsnPR2podXW5HiGhs=; b=oTewLIWmSRuYVz ly9MZ6fwG8KylkG6mRbw+7nR1/zSljBm2bgXLRFsyzcrHwHcIqm6mDqELvVL8YCuxBMdJSMiLPu4Q IUrb/OubcZd/k9XqLNSPUFohVb/2/J8oIUF3+fTCtLUivNY6uUMU89fohtqxIzfiHJ3jQV5Px45IM XVGQdmDmwEd45KtJhsVqJPobPB1EcNJhoVwCSQfHQSJZX1yqvIwLyOZzW7KQn6Xxh7apZSy/JqmYN +Kx0dCItVnY9Wt/b25tF/8e5QlB7a9Qvi319LKw/JtO5pcDIgRfkQ19NrvVzywtFHd30i2BDn5VoW JbNwlhxvGBK3ySj6GuSA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1stpQl-00000008aPL-0aJS; Thu, 26 Sep 2024 14:25:19 +0000 Received: from mail-pf1-x429.google.com ([2607:f8b0:4864:20::429]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1stpQh-00000008aMe-2n3z for linux-mtd@lists.infradead.org; Thu, 26 Sep 2024 14:25:17 +0000 Received: by mail-pf1-x429.google.com with SMTP id d2e1a72fcca58-717934728adso814927b3a.2 for ; Thu, 26 Sep 2024 07:25:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727360715; x=1727965515; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=r/MUwzKscwhtX7s3jSH4IlHx8F0q+vgLMrLzXFhkBRw=; b=LzBVGAfhlOzljhgBd/8DRBtCEZwUUITUoCIDIZfyd5irYYIJhQtjLbLRHS7FYXWx7R lgJYNKkC5p7W0r2UoADVdCa1XKDtqrnA4NoaLPDibDRj/CwGUvbtqJiomHiH6eyUvHYF p5GT+of+JY/CtbX/mWXyC1kkg0f8VZUOI1/9PblRX3gfoQjUhg/D75EwKpg8gm7+DeQM LMuyAEzZm2+dnUMPxKhZsacpHbzzVvXsI9U8D/Zzad4UYfuU7b+OauNz7FaIZVr+TqEV 6jA8vW2EkMWTqdrFuDwnakm5r9K8O6ZwVRnaFGUu/piZSar1rRpgvhoSkFdsZW9+IZ89 2LZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727360715; x=1727965515; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=r/MUwzKscwhtX7s3jSH4IlHx8F0q+vgLMrLzXFhkBRw=; b=ZhwZYWRSyb3JLEuOWYkUs1902JSx9U/Uem5l3USiJquvU5nf1nZij51l2nsbQNoeTS 0frjAaV4W1Z1qgeTCd8svNLdpCZWfJA2Pvr5cido2dHLaa4jXrjsWw7sMBFNXYLIclCZ uG++ZtbzTPUktPwSSSN4vxxS3yy6Eau0C+3LVcniB1ofHujjYrH16EzoGMML0RJ6OVC1 bn9W+fD8IyVJo49TxYdUqnSS8OMx3xN0XzY7SRyRq+vK8zBe8Q2VjTl+TP4mAUiSXG6y wNaaoSoaIC5+EthgKor2I3B0F6ulTSj303tjBmo/z1IxGOntOVL0gO9FEyVbIjh6z6oA bM1w== X-Gm-Message-State: AOJu0YySmc+QjIPrk5rr/uiEz089u4EsKQ37xztfe5pec13CZJf7/g/j kUxgvFLtvU3tnK38u9R2bJW6nRZlVEi1HO08QZQPzw8i9MhCL9CT X-Google-Smtp-Source: AGHT+IGS0nM82au/EzeP06wausitoOEDIM3uRThhNjvR3ugckuZHWCaNJRiYUN2+/U97e/3zZ/d4TA== X-Received: by 2002:a05:6a00:9284:b0:718:db7c:3a49 with SMTP id d2e1a72fcca58-71b0ac993b2mr8763854b3a.27.1727360714488; Thu, 26 Sep 2024 07:25:14 -0700 (PDT) Received: from twhmp6px (mxsmtp211.mxic.com.tw. [211.75.127.162]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7e6b7c732c8sm4360707a12.71.2024.09.26.07.25.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Sep 2024 07:25:14 -0700 (PDT) Received: from hqs-appsw-a2o.mp600.macronix.com (linux-patcher [172.17.236.67]) by twhmp6px (Postfix) with ESMTPS id 2374780529; Thu, 26 Sep 2024 22:33:01 +0800 (CST) From: AlvinZhou To: linux-mtd@lists.infradead.org, linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, tudor.ambarus@linaro.org, pratyush@kernel.org, mwalle@kernel.org, miquel.raynal@bootlin.com, richard@nod.at, vigneshr@ti.com, broonie@kernel.org Cc: chengminglin@mxic.com.tw, leoyu@mxic.com.tw, AlvinZhou , JaimeLiao Subject: [PATCH v10 2/6] spi: spi-mem: Allow specifying the byte order in Octal DTR mode Date: Thu, 26 Sep 2024 22:19:52 +0800 Message-Id: <20240926141956.2386374-3-alvinzhou.tw@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240926141956.2386374-1-alvinzhou.tw@gmail.com> References: <20240926141956.2386374-1-alvinzhou.tw@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240926_072515_774096_EA7646F4 X-CRM114-Status: GOOD ( 17.07 ) X-Spam-Score: -2.1 (--) X-Spam-Report: Spam detection software, running on the system "bombadil.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: AlvinZhou From: Tudor Ambarus There are NOR flashes (Macronix) that swap the bytes on a 16-bit boundary when configured in Octal DTR mode. The byte order of 16-bit words is swapped when read or written in Octal Double Transfer Rat [...] Content analysis details: (-2.1 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [alvinzhou.tw(at)gmail.com] 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: AlvinZhou From: Tudor Ambarus There are NOR flashes (Macronix) that swap the bytes on a 16-bit boundary when configured in Octal DTR mode. The byte order of 16-bit words is swapped when read or written in Octal Double Transfer Rate (DTR) mode compared to Single Transfer Rate (STR) modes. If one writes D0 D1 D2 D3 bytes using 1-1-1 mode, and uses 8D-8D-8D SPI mode for reading, it will read back D1 D0 D3 D2. Swapping the bytes may introduce some endianness problems. It can affect the boot sequence if the entire boot sequence is not handled in either 8D-8D-8D mode or 1-1-1 mode. Therefore, it is necessary to swap the bytes back to ensure the same byte order as in STR modes. Fortunately there are controllers that could swap the bytes back at runtime, addressing the flash's endianness requirements. Provide a way for the upper layers to specify the byte order in Octal DTR mode. Merge Tudor's patch and add modifications for suiting newer version of Linux kernel. Suggested-by: Michael Walle Signed-off-by: Tudor Ambarus Signed-off-by: JaimeLiao Signed-off-by: AlvinZhou Acked-by: Mark Brown --- drivers/spi/spi-mem.c | 3 +++ include/linux/spi/spi-mem.h | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/spi/spi-mem.c b/drivers/spi/spi-mem.c index 17b8baf749e6..abc6792e738c 100644 --- a/drivers/spi/spi-mem.c +++ b/drivers/spi/spi-mem.c @@ -172,6 +172,9 @@ bool spi_mem_default_supports_op(struct spi_mem *mem, if (!spi_mem_controller_is_capable(ctlr, dtr)) return false; + if (op->data.swap16 && !spi_mem_controller_is_capable(ctlr, swap16)) + return false; + if (op->cmd.nbytes != 2) return false; } else { diff --git a/include/linux/spi/spi-mem.h b/include/linux/spi/spi-mem.h index f866d5c8ed32..c46d2b8029be 100644 --- a/include/linux/spi/spi-mem.h +++ b/include/linux/spi/spi-mem.h @@ -90,6 +90,8 @@ enum spi_mem_data_dir { * @data.buswidth: number of IO lanes used to send/receive the data * @data.dtr: whether the data should be sent in DTR mode or not * @data.ecc: whether error correction is required or not + * @data.swap16: whether the byte order of 16-bit words is swapped when read + * or written in Octal DTR mode compared to STR mode. * @data.dir: direction of the transfer * @data.nbytes: number of data bytes to send/receive. Can be zero if the * operation does not involve transferring data @@ -124,7 +126,8 @@ struct spi_mem_op { u8 buswidth; u8 dtr : 1; u8 ecc : 1; - u8 __pad : 6; + u8 swap16 : 1; + u8 __pad : 5; enum spi_mem_data_dir dir; unsigned int nbytes; union { @@ -297,10 +300,13 @@ struct spi_controller_mem_ops { * struct spi_controller_mem_caps - SPI memory controller capabilities * @dtr: Supports DTR operations * @ecc: Supports operations with error correction + * @swap16: Supports swapping bytes on a 16 bit boundary when configured in + * Octal DTR */ struct spi_controller_mem_caps { bool dtr; bool ecc; + bool swap16; }; #define spi_mem_controller_is_capable(ctlr, cap) \ From patchwork Thu Sep 26 14:19:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alvin Zhou X-Patchwork-Id: 1989844 X-Patchwork-Delegate: tudor.ambarus@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=acNNc/YY; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=TK6gqmYf; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XDwqZ4khjz1xtC for ; Fri, 27 Sep 2024 00:25:30 +1000 (AEST) 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: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=shIzYCBPwz5/+gNzpqGbhCXbs/rirNr0LthVh+/GwhY=; b=acNNc/YYTHRSlA /apb34bfr69gad7taBQsUY0MvKPxEJ/2iAOmsJa2rcEB5eD665dn3yFmhXaKDjRNVxachYoo7H0oz xqYdRUGBeM8mmW3vBiatOpHJ+8hsADuTLvyx5WtDQvx1KBG71UTYiqO+o5UbFlvbJXjpuSJ0NismH SFMKD0wVSTGYk9bW/WpD0uE50PIlWXdAZDRaBZbourc+I3UsfQEbj1ZXS2uFTmiFLoUZRHqC7MfTJ RTNVmw8Pm0vt8nddLmBE/kqEH0vGwHTIzUuN4fanHfda10XMYoDlUz2SgUWMCPETz3oEDS3g+82Ig m03fSnsXHGCI3FAxBDXQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1stpQm-00000008aQG-1xZI; Thu, 26 Sep 2024 14:25:20 +0000 Received: from mail-pg1-x52e.google.com ([2607:f8b0:4864:20::52e]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1stpQh-00000008aMh-37eZ for linux-mtd@lists.infradead.org; Thu, 26 Sep 2024 14:25:17 +0000 Received: by mail-pg1-x52e.google.com with SMTP id 41be03b00d2f7-7d4f85766f0so808948a12.2 for ; Thu, 26 Sep 2024 07:25:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727360715; x=1727965515; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=RGxTXo990ti5lAyVI8ZehxzUFXPwz6MqQx7qAzjMfhw=; b=TK6gqmYfUPT7RaXSlj/mKZdovjf1dsvuiCdwabUW916dGQNADh0lMFeOMQvWXld+po EiC9HuFJekitjgUEgKmPwJHOEZhTxHHohV4xGww4+JPZPRarOV3/PskMZuG5FEO8HVrJ 2JiMovwNKyBcUwhXKKiCjLfgTMc4YUta/wjb9vM3m7PF1nb6flawkkP2hRFlstvxPg0w GMcy4XSc4/8xGAjkaC4vCALzsO7GTjnUe72RkcvVBU8hED06Q/cnE6P57JktJthtJrL9 RNTsoqsiWoi8KrQQdeBfkVntEGN7KCvSeOAbbUCcUcUGZZM/ewgT9le6Pk9mBtrR3UVS hNdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727360715; x=1727965515; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=RGxTXo990ti5lAyVI8ZehxzUFXPwz6MqQx7qAzjMfhw=; b=mSvbOwAumFran2F5xboEyuSII0oOcl2lP7TLQ1da0QcJlQDLaCpPUntfk7kL89NIfe k+aGx8C+LcolffLHzIkbBKjeEAyAdHzmA/20/NA42xDEkNyffMlaAYJyc3l/88gDCAI5 Wq2FrPW5Kdr0IRl63vad7TTjsIwtjtXW4ncb0efiwgQtKcUJJZrAGHsfpP7a294zoiLS ZsrpV2zg9sowwVQlWv2rtLueEALF6kle8FKe2aEu6pEyPW0N5QHhJn6eAerBdURHh7KZ u7EknbEw5Haj9uVlir2cN3p81X50Q38pT2FtIEweM1AYWbbeCeetcJUzONHCJx20ZbxP 0wXw== X-Gm-Message-State: AOJu0YzbvXXM0TN1jaMdneWqxB3k6BxRjVDWCTfPOJvVmpTFfpVvzm7x L2xRnNeU0LVhuPO9Z77pHeFFAf5LpjA8Nk3EvQC4X4qb04Aa1i6e X-Google-Smtp-Source: AGHT+IGJwQwDCJBexl9tEe801nzR8/z6arvXHTxHSnx3fsr9XAE3/M0h4vZLwCeKudo7PtJWcCWLpw== X-Received: by 2002:a05:6a21:78e:b0:1d2:e1cc:649c with SMTP id adf61e73a8af0-1d4d4aaf073mr8517160637.15.1727360714640; Thu, 26 Sep 2024 07:25:14 -0700 (PDT) Received: from twhmp6px (mxsmtp211.mxic.com.tw. [211.75.127.162]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71afc985c99sm4374462b3a.180.2024.09.26.07.25.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Sep 2024 07:25:14 -0700 (PDT) Received: from hqs-appsw-a2o.mp600.macronix.com (linux-patcher [172.17.236.67]) by twhmp6px (Postfix) with ESMTPS id 0432080580; Thu, 26 Sep 2024 22:33:02 +0800 (CST) From: AlvinZhou To: linux-mtd@lists.infradead.org, linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, tudor.ambarus@linaro.org, pratyush@kernel.org, mwalle@kernel.org, miquel.raynal@bootlin.com, richard@nod.at, vigneshr@ti.com, broonie@kernel.org Cc: chengminglin@mxic.com.tw, leoyu@mxic.com.tw, AlvinZhou , JaimeLiao Subject: [PATCH v10 3/6] mtd: spi-nor: core: Allow specifying the byte order in Octal DTR mode Date: Thu, 26 Sep 2024 22:19:53 +0800 Message-Id: <20240926141956.2386374-4-alvinzhou.tw@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240926141956.2386374-1-alvinzhou.tw@gmail.com> References: <20240926141956.2386374-1-alvinzhou.tw@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240926_072515_850388_913CC4B8 X-CRM114-Status: GOOD ( 14.16 ) X-Spam-Score: -2.1 (--) X-Spam-Report: Spam detection software, running on the system "bombadil.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: AlvinZhou From: Tudor Ambarus Macronix swaps bytes on a 16-bit boundary when configured in Octal DTR. The byte order of 16-bit words is swapped when read or written in 8D-8D-8D mode compared to STR modes. Allow operations to speci [...] Content analysis details: (-2.1 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [alvinzhou.tw(at)gmail.com] 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: AlvinZhou From: Tudor Ambarus Macronix swaps bytes on a 16-bit boundary when configured in Octal DTR. The byte order of 16-bit words is swapped when read or written in 8D-8D-8D mode compared to STR modes. Allow operations to specify the byte order in DTR mode, so that controllers can swap the bytes back at run-time to address the flash's endianness requirements, if they are capable. If the controller is not capable of swapping the bytes, the protocol is downgrade via spi_nor_spimem_adjust_hwcaps(). When available, the swapping of the bytes is always done regardless if it's a data or register access, so that it comply with the JESD216 requirements: "Byte order of 16-bit words is swapped when read in 8D-8D-8D mode compared to 1-1-1". Merge Tudor's patch and add modifications for suiting newer version of Linux kernel. Suggested-by: Michael Walle Signed-off-by: Tudor Ambarus Signed-off-by: JaimeLiao Signed-off-by: AlvinZhou --- drivers/mtd/spi-nor/core.c | 4 ++++ drivers/mtd/spi-nor/core.h | 1 + 2 files changed, 5 insertions(+) diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c index 028514c6996f..31f57b17023f 100644 --- a/drivers/mtd/spi-nor/core.c +++ b/drivers/mtd/spi-nor/core.c @@ -113,6 +113,10 @@ void spi_nor_spimem_setup_op(const struct spi_nor *nor, op->cmd.opcode = (op->cmd.opcode << 8) | ext; op->cmd.nbytes = 2; } + + /* SWAP16 is only applicable when Octal DTR mode */ + if (proto == SNOR_PROTO_8_8_8_DTR && nor->flags & SNOR_F_SWAP16) + op->data.swap16 = true; } /** diff --git a/drivers/mtd/spi-nor/core.h b/drivers/mtd/spi-nor/core.h index 442786685515..baf6c4b5912b 100644 --- a/drivers/mtd/spi-nor/core.h +++ b/drivers/mtd/spi-nor/core.h @@ -140,6 +140,7 @@ enum spi_nor_option_flags { SNOR_F_RWW = BIT(14), SNOR_F_ECC = BIT(15), SNOR_F_NO_WP = BIT(16), + SNOR_F_SWAP16 = BIT(17), }; struct spi_nor_read_command { From patchwork Thu Sep 26 14:19:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alvin Zhou X-Patchwork-Id: 1989848 X-Patchwork-Delegate: tudor.ambarus@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=tA4dLmpu; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=mFIab70F; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XDwqd1hzcz1xtD for ; Fri, 27 Sep 2024 00:25:33 +1000 (AEST) 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: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=3hE/OuJ7pt+58ErsRc1oOhqjFIrzT2MORLZ1tB52uEk=; b=tA4dLmpuo+0Z21 VVFKRVhGI7aYoOKCHa/IOaSQ41A8YFF61y9Z6ruyilSCuMq17KPdiJIG9uzG1qx5KFmyl9MVpKqoj 0L3e7lG2Jkmsigcm7NcphcFv6M34F5joQAZq0TdLPnn30YD0ZNo/wUBqiu9WdEfTiCDZotU7GnItu TaRcLw/hfn9ftudK3uPpoMuuKrr1nySH4hMB1/1HIxpyFIYPs+s5166LW4FZKNvQZ/mscteHQ3t5i vTSf2VoGeRLJTPMmSqQzp7Ugy3w5/bszpeoJEFL7aTBhkAHtuxQMyQrubka1f7hMDPhIlsEZC1uxL j4elRFxTw4B0ZGy2dzew==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1stpQo-00000008aRx-1ZMP; Thu, 26 Sep 2024 14:25:22 +0000 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1stpQk-00000008aO6-2b56 for linux-mtd@lists.infradead.org; Thu, 26 Sep 2024 14:25:20 +0000 Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-2053525bd90so9836595ad.0 for ; Thu, 26 Sep 2024 07:25:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727360716; x=1727965516; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=tMuWBEdI2HIbFrXrh9xxcobW8DMR1fI820uWrVQpyfU=; b=mFIab70F4dz1Ga1PqW5pUB2jXVC6OLqpfLAEDUGjwFnf7jHY4s5jujN0unxLCYPCrj 1hqFJi0vL9/fQeCaKRB720ptomlbFSLpZegTMTPfU5uhSHcMxalMjq1NDkR+2YvFImgG 4a3oNbh7F9ODW05tMNFJFpSJAqnF8W3ppoy06VoG7QNWsse3CpbL0GahbIXwdIUDPzlO Nm1OT6z4aan4nYNIY+9JMEecXpr8UZeHeokAlLVtxaiN9Z3jy4aFJjQsZldFTToVffmn WUjssxCnV5liYiDXEW1o8lRfymWd8XTIQC3cVEBxXxrTfKECie06jb2dIMU1EFrhxrSg Kb5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727360716; x=1727965516; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=tMuWBEdI2HIbFrXrh9xxcobW8DMR1fI820uWrVQpyfU=; b=guyrYCh0tELTBKPj+WraOkSgfr3uTdTepQqgbcFPixy1JZFn1VPO81F84cTO8yV/0i JGRK9eJm38pTGWE7lVYWRqyEzsQa8FPQ36/qsF4LM5N4b+qChqAeFBkTh3Vhx+gnpp7+ +Y0B31olFt/1BQiLzRj4Bc/MDnsYJrHw/gSTGdruCKB8HA0jbTAGTSTbZdiqFwRFVECC KeRoFH7yr3MdvCqApTRp9WQOXii4AlaKFqAg+pevVasXRO3eFN30YXOziR0Kg6H/dHj2 5RY8GfWvwNGLtQLEw73yXtm0bmWpbi8apOagmx8SVNePybeF3TVVXu85rPi2xFQxhlAq jxyg== X-Gm-Message-State: AOJu0YyVCKMZcRDiJFOegUUloEoI5rUsohznS0PZ4sGw/i7xNc5c3zv1 V1ccLXv3adHWI2PdViEHu16EkDw8uMOoEG2Dyxy8liXSdPO/fAYq X-Google-Smtp-Source: AGHT+IGEtc58T5kAWxd3ejQeAnShG9qd/qn85zhZjLVapG+1Ibu8ePMvELjY8JENDMiHASpawvBTgw== X-Received: by 2002:a17:902:cf4a:b0:207:3a46:345 with SMTP id d9443c01a7336-20afc5f2830mr75735065ad.51.1727360716485; Thu, 26 Sep 2024 07:25:16 -0700 (PDT) Received: from twhmp6px (mxsmtp211.mxic.com.tw. [211.75.127.162]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20af1856f27sm39332645ad.262.2024.09.26.07.25.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Sep 2024 07:25:16 -0700 (PDT) Received: from hqs-appsw-a2o.mp600.macronix.com (linux-patcher [172.17.236.67]) by twhmp6px (Postfix) with ESMTPS id BA021802C9; Thu, 26 Sep 2024 22:33:03 +0800 (CST) From: AlvinZhou To: linux-mtd@lists.infradead.org, linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, tudor.ambarus@linaro.org, pratyush@kernel.org, mwalle@kernel.org, miquel.raynal@bootlin.com, richard@nod.at, vigneshr@ti.com, broonie@kernel.org Cc: chengminglin@mxic.com.tw, leoyu@mxic.com.tw, AlvinZhou , JaimeLiao Subject: [PATCH v10 4/6] mtd: spi-nor: sfdp: Get the 8D-8D-8D byte order from BFPT Date: Thu, 26 Sep 2024 22:19:54 +0800 Message-Id: <20240926141956.2386374-5-alvinzhou.tw@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240926141956.2386374-1-alvinzhou.tw@gmail.com> References: <20240926141956.2386374-1-alvinzhou.tw@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240926_072518_782513_0F4C4E58 X-CRM114-Status: GOOD ( 13.89 ) X-Spam-Score: -2.1 (--) X-Spam-Report: Spam detection software, running on the system "bombadil.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: AlvinZhou From: Tudor Ambarus Parse BFPT in order to retrieve the byte order in 8D-8D-8D mode. Content analysis details: (-2.1 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [alvinzhou.tw(at)gmail.com] 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: AlvinZhou From: Tudor Ambarus Parse BFPT in order to retrieve the byte order in 8D-8D-8D mode. This info flag will be used as a basis to determine whether there is byte swapping of data for SPI NOR flash in octal DTR mode. The controller driver will check whether byte swapping is supported to determine whether the corresponding operation are supported, thus avoiding the generation of unexpected data order. Merge Tudor's patch and add modifications for suiting newer version of Linux kernel. Reviewed-by: Michael Walle Signed-off-by: Tudor Ambarus Signed-off-by: JaimeLiao Signed-off-by: AlvinZhou --- drivers/mtd/spi-nor/sfdp.c | 4 ++++ drivers/mtd/spi-nor/sfdp.h | 1 + 2 files changed, 5 insertions(+) diff --git a/drivers/mtd/spi-nor/sfdp.c b/drivers/mtd/spi-nor/sfdp.c index 5b1117265bd2..21727f9a4ac6 100644 --- a/drivers/mtd/spi-nor/sfdp.c +++ b/drivers/mtd/spi-nor/sfdp.c @@ -671,6 +671,10 @@ static int spi_nor_parse_bfpt(struct spi_nor *nor, return -EOPNOTSUPP; } + /* Byte order in 8D-8D-8D mode */ + if (bfpt.dwords[SFDP_DWORD(18)] & BFPT_DWORD18_BYTE_ORDER_SWAPPED) + nor->flags |= SNOR_F_SWAP16; + return spi_nor_post_bfpt_fixups(nor, bfpt_header, &bfpt); } diff --git a/drivers/mtd/spi-nor/sfdp.h b/drivers/mtd/spi-nor/sfdp.h index da0fe5aa9bb0..d90cbd7331f7 100644 --- a/drivers/mtd/spi-nor/sfdp.h +++ b/drivers/mtd/spi-nor/sfdp.h @@ -130,6 +130,7 @@ struct sfdp_bfpt { #define BFPT_DWORD18_CMD_EXT_INV (0x1UL << 29) /* Invert */ #define BFPT_DWORD18_CMD_EXT_RES (0x2UL << 29) /* Reserved */ #define BFPT_DWORD18_CMD_EXT_16B (0x3UL << 29) /* 16-bit opcode */ +#define BFPT_DWORD18_BYTE_ORDER_SWAPPED BIT(31) /* Byte sawp of 16-bit in 8D-8D-8D mode */ struct sfdp_parameter_header { u8 id_lsb; From patchwork Thu Sep 26 14:19:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alvin Zhou X-Patchwork-Id: 1989849 X-Patchwork-Delegate: tudor.ambarus@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=yvC+qKWA; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=WJT0eTcg; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XDwqf5pxxz1xtG for ; Fri, 27 Sep 2024 00:25:34 +1000 (AEST) 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: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=H03aBYu8dkGZWeHALR6SSvd9tC4E0BOhQTs/Zk1nWH4=; b=yvC+qKWA8039yI mXq0o/PhUCsvcW9Iq0CuBeew/O4D3tWAP7/sq8NIvh3TOOUykMW0+c1+5kP3Yi2509IYG1PQ+ktxv ctthlHfbN0foYBnuYdC1ZdSDe1qmseGvyZLygAOEB4gK4fjRpxkGkszMSV8g7iM6iF26uG1UmsDa8 Rxdtwn73FlK3eh5G9IZcSwWeqSY1nUDMWI6zrp2479k4/FrkE1MYD3tdjlzCIkAmYDqlW4F/OxDIM zRx7jOkAhQbaCTkowT+THMbljL7C4CX6Nz2bJPodFTtSOfMm37yKF3Htko6eyE7gGZIHP0sGmFN7M ui4gdqgE1n9fNmeyg0ZA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1stpQq-00000008aT7-1svp; Thu, 26 Sep 2024 14:25:24 +0000 Received: from mail-pl1-x62f.google.com ([2607:f8b0:4864:20::62f]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1stpQl-00000008aP3-1jcb for linux-mtd@lists.infradead.org; Thu, 26 Sep 2024 14:25:20 +0000 Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-2059204f448so9548405ad.0 for ; Thu, 26 Sep 2024 07:25:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727360718; x=1727965518; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=xaggZDdeca0MsYHdusDRGfZ6Se8lg/cciHsG3Hst56A=; b=WJT0eTcgkBvfYvo2U6oA0qE6zrjZNfItw0aFf1863I0PNQu9cVFuQNP5g7BAycjQdP QlDeVrlJFXaY5yHMvdQ5QnI7QUN4XzvPrxRVQJxQRZy7sBxWqA/OdqoCd7VmAJT65Rhn ZV6Zheer3RwiSTpSVjd5HhsezsMNjP4LLzsQt0DQDqkABd2G5aDS0RIFAWK6yEXFvMzG j73XuKDRzCIIwz6bVcasilykZwhINsDfzGm+w/Nql68udEThCmJ7nMGhWuw0SHeMPmS7 M7G/PcR7WMxcV3fX/8T+1lg+vqzuSa8reSKZYaosajIKh7CTGpLNHrsoBdqMsHr2XRAX MCcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727360718; x=1727965518; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xaggZDdeca0MsYHdusDRGfZ6Se8lg/cciHsG3Hst56A=; b=XnYLsvoMED0V5oKi0p8lwFKQRxh8ie5cMvVcnH3LnFMsEDiDksfU8U2E+xfxqh4L2R o1i/5QhzuHFsjOEY/YMUQ3AK+F4a2fKZkxtjl3dEQbUZbL+xhkvNMY3VLn5ZnD1bn+UM 0eKSS8+MasguCyWm09uwusZ85JFgJAC4hA7ifg1cwZOoIl6YAjYcyGNDbI/sGwO11tgd riaJ2705RfVWrw1a6b0+uf0uh0qXokTB8Rdk3/g4PqkP+sM5Kly5A7qX1s0mVcyLcMIz LNT+iCYML4O7pcwGSXWtWeTDSpHx+rqpt2pK5/CS1aaIjZNRFw45OF4vHzYgPiDCMzKu mLCg== X-Gm-Message-State: AOJu0Ywhk03Ld8/L0kbnmAf0086VNx5C9XgJNBf/CG5I8BkCw5vZ2Z21 O49rqtLmvZBEryPyQHIl+s9s+2UO3hcF4dUpMOM0iFUsrJtIPklXsX19yQ== X-Google-Smtp-Source: AGHT+IFflt3eoiy3X+/8w5aFqI4rEO+u5APN62XJUblKYDy3GPC4kjSQk0j2eANYngkz5DwsNxMibg== X-Received: by 2002:a17:902:ce02:b0:205:56e8:4a4b with SMTP id d9443c01a7336-20afc42ad4fmr88493905ad.2.1727360717974; Thu, 26 Sep 2024 07:25:17 -0700 (PDT) Received: from twhmp6px (mxsmtp211.mxic.com.tw. [211.75.127.162]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20af17e2db1sm39450795ad.178.2024.09.26.07.25.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Sep 2024 07:25:17 -0700 (PDT) Received: from hqs-appsw-a2o.mp600.macronix.com (linux-patcher [172.17.236.67]) by twhmp6px (Postfix) with ESMTPS id 44A7A80529; Thu, 26 Sep 2024 22:33:05 +0800 (CST) From: AlvinZhou To: linux-mtd@lists.infradead.org, linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, tudor.ambarus@linaro.org, pratyush@kernel.org, mwalle@kernel.org, miquel.raynal@bootlin.com, richard@nod.at, vigneshr@ti.com, broonie@kernel.org Cc: chengminglin@mxic.com.tw, leoyu@mxic.com.tw, AlvinZhou , JaimeLiao Subject: [PATCH v10 5/6] spi: mxic: Add support for swapping byte Date: Thu, 26 Sep 2024 22:19:55 +0800 Message-Id: <20240926141956.2386374-6-alvinzhou.tw@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240926141956.2386374-1-alvinzhou.tw@gmail.com> References: <20240926141956.2386374-1-alvinzhou.tw@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240926_072519_566265_237F7DFE X-CRM114-Status: GOOD ( 15.10 ) X-Spam-Score: -2.1 (--) X-Spam-Report: Spam detection software, running on the system "bombadil.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: AlvinZhou Some SPI-NOR flash swap the bytes on a 16-bit boundary when configured in Octal DTR mode. It means data format D0 D1 D2 D3 would be swapped to D1 D0 D3 D2. So that whether controller support swapping [...] Content analysis details: (-2.1 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [alvinzhou.tw(at)gmail.com] 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: AlvinZhou Some SPI-NOR flash swap the bytes on a 16-bit boundary when configured in Octal DTR mode. It means data format D0 D1 D2 D3 would be swapped to D1 D0 D3 D2. So that whether controller support swapping bytes should be checked before enable Octal DTR mode. Add swap byte support on a 16-bit boundary when configured in Octal DTR mode for Macronix xSPI host controller driver. According dtr_swab in operation to enable/disable Macronix xSPI host controller swap byte feature. To make sure swap byte feature is working well, program data in 1S-1S-1S mode then read back and compare read data in 8D-8D-8D mode. This feature have been validated on byte-swap flash and non-byte-swap flash. Macronix xSPI host controller bit "HC_CFG_DATA_PASS" determine the byte swap feature disabled/enabled and swap byte feature is working on 8D-8D-8D mode only. Suggested-by: Michael Walle Signed-off-by: JaimeLiao Signed-off-by: AlvinZhou Acked-by: Mark Brown --- drivers/spi/spi-mxic.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/drivers/spi/spi-mxic.c b/drivers/spi/spi-mxic.c index 6156d691630a..a669ffa27b65 100644 --- a/drivers/spi/spi-mxic.c +++ b/drivers/spi/spi-mxic.c @@ -294,7 +294,8 @@ static void mxic_spi_hw_init(struct mxic_spi *mxic) mxic->regs + HC_CFG); } -static u32 mxic_spi_prep_hc_cfg(struct spi_device *spi, u32 flags) +static u32 mxic_spi_prep_hc_cfg(struct spi_device *spi, u32 flags, + bool swap16) { int nio = 1; @@ -305,6 +306,11 @@ static u32 mxic_spi_prep_hc_cfg(struct spi_device *spi, u32 flags) else if (spi->mode & (SPI_TX_DUAL | SPI_RX_DUAL)) nio = 2; + if (swap16) + flags &= ~HC_CFG_DATA_PASS; + else + flags |= HC_CFG_DATA_PASS; + return flags | HC_CFG_NIO(nio) | HC_CFG_TYPE(spi_get_chipselect(spi, 0), HC_CFG_TYPE_SPI_NOR) | HC_CFG_SLV_ACT(spi_get_chipselect(spi, 0)) | HC_CFG_IDLE_SIO_LVL(1); @@ -397,7 +403,8 @@ static ssize_t mxic_spi_mem_dirmap_read(struct spi_mem_dirmap_desc *desc, if (WARN_ON(offs + desc->info.offset + len > U32_MAX)) return -EINVAL; - writel(mxic_spi_prep_hc_cfg(desc->mem->spi, 0), mxic->regs + HC_CFG); + writel(mxic_spi_prep_hc_cfg(desc->mem->spi, 0, desc->info.op_tmpl.data.swap16), + mxic->regs + HC_CFG); writel(mxic_spi_mem_prep_op_cfg(&desc->info.op_tmpl, len), mxic->regs + LRD_CFG); @@ -441,7 +448,8 @@ static ssize_t mxic_spi_mem_dirmap_write(struct spi_mem_dirmap_desc *desc, if (WARN_ON(offs + desc->info.offset + len > U32_MAX)) return -EINVAL; - writel(mxic_spi_prep_hc_cfg(desc->mem->spi, 0), mxic->regs + HC_CFG); + writel(mxic_spi_prep_hc_cfg(desc->mem->spi, 0, desc->info.op_tmpl.data.swap16), + mxic->regs + HC_CFG); writel(mxic_spi_mem_prep_op_cfg(&desc->info.op_tmpl, len), mxic->regs + LWR_CFG); @@ -518,7 +526,7 @@ static int mxic_spi_mem_exec_op(struct spi_mem *mem, if (ret) return ret; - writel(mxic_spi_prep_hc_cfg(mem->spi, HC_CFG_MAN_CS_EN), + writel(mxic_spi_prep_hc_cfg(mem->spi, HC_CFG_MAN_CS_EN, op->data.swap16), mxic->regs + HC_CFG); writel(HC_EN_BIT, mxic->regs + HC_EN); @@ -573,6 +581,7 @@ static const struct spi_controller_mem_ops mxic_spi_mem_ops = { static const struct spi_controller_mem_caps mxic_spi_mem_caps = { .dtr = true, .ecc = true, + .swap16 = true, }; static void mxic_spi_set_cs(struct spi_device *spi, bool lvl) From patchwork Thu Sep 26 14:19:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alvin Zhou X-Patchwork-Id: 1989850 X-Patchwork-Delegate: tudor.ambarus@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=Zeq6FboX; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=IBcLyRdJ; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XDwqp0NKcz1xt6 for ; Fri, 27 Sep 2024 00:25:42 +1000 (AEST) 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: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=jXjqo1gFCNCkV0MpCjPxWbacsdwrUXdp37D9lpwdiT4=; b=Zeq6FboX9GE5+x nL1pAsrsmpIP2l3nKAIM4CBrq5cWHdADj55UJ6RSH1cZ2hBEAp79WqUVxwHL7bd3mOjNZr2+PI2Sa Soo/Syek3bz9oECeu0TLgghM0DBdTiLFVRMTtoid7Enhued079Gv1QU/zVdUqc0g4STr8H/K053KS Lf/FUici8yq2gx6oIRdL5lSwrd4imaGBbiBAvW29GVpZr7DRjSCkt+J78FPLxPDAoZiiw0h+FOioS 5cRWvky3HrAkB8ETPlb+aazeO1meiL/8jCcIBXev7F8ZPCe+XfefvyeHzZATS0QbEHpwcFVvt/cKT Dk0WVtOOh8wm+/wLmhmA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1stpQy-00000008aaU-35v6; Thu, 26 Sep 2024 14:25:32 +0000 Received: from mail-pg1-x531.google.com ([2607:f8b0:4864:20::531]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1stpQo-00000008aQE-0Rqy for linux-mtd@lists.infradead.org; Thu, 26 Sep 2024 14:25:23 +0000 Received: by mail-pg1-x531.google.com with SMTP id 41be03b00d2f7-7e6cbf6cd1dso770081a12.3 for ; Thu, 26 Sep 2024 07:25:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727360720; x=1727965520; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=LbPIZJpcVIEhpHEVG/j37aleyqQqnMhNui3ve62e6y8=; b=IBcLyRdJWuJR9ABqsMRxreBojpJEGowyoAoSaZGUzMF3QrwpvTnuaRtawKBIk6kzXq gk2+EY7GqOZclGX0W82SnH1X3GBNqO2H+hSEmHRKleTbVcUkzkf3JTsghn6Vf1XC7TGp ybDdpDmyyzeXT8Jws6fXs5PslKDbqC22nhKLePaRuuatLHJcmdIkVoSpp8xhZqksx3FB DuqKGlhG7jl52kCnLF8pD/Tg9aKL7oYnbYINwJoMbFgNeI92avpy6ZlceqMos21PpBDq zzsQtbxrbtHh9d5lRor1cRzepSFW4uRojt8VIS6OvwQUU295MRt3lkNLggXZvwG94r+o Ln1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727360720; x=1727965520; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LbPIZJpcVIEhpHEVG/j37aleyqQqnMhNui3ve62e6y8=; b=pcu/1u4eOTTDhi2bBYFv6FqBtlWvnrI8YS53QxuY502Ib+kkTfgMNxnCDEz4JOogSR Yqe/CeoxNQANpuUzfNabaa5M6MztoSXkhxqkbpViggsiQF1UMqxNPxnmKmxED16TrtCD ta9mM4PnnfNBoaTwp6rw2wXsXyDGjuIsUfI4bq0JN5YQ7zwzKgnR9cS6/IJdAVynXr9q KPT6zhSG17J8S4BKHIxhqPqo5CDF6pREwKgw+Sgc3mzdjripyIUYqQwU3prDztx+1CN1 0I72JmHNDu22Z0IlQsBhDkmVLNUZtYg2wJkqeh3MxQI0xQIyAynlIcmPSOm+7j5+oWOi J6Ag== X-Gm-Message-State: AOJu0YzJA9E0k0omABIrV2IUTbWBm0SZBq2nQdfPSFJVFwHGIQj7lFnH uuSEyOOqUmG7NnKw8Uk3NNAvutoWwupI8CEY5SZrOPmS+5+m0fLI X-Google-Smtp-Source: AGHT+IHisqnk7KIiPORJnFsqOHN+dwrtS5lGQysFzmZKGyTwiAq/CDdvSpjHomonSIfnNNGUcrdOyg== X-Received: by 2002:a17:90b:3e82:b0:2d8:dd14:79ed with SMTP id 98e67ed59e1d1-2e06afbe5c7mr7237287a91.31.1727360719702; Thu, 26 Sep 2024 07:25:19 -0700 (PDT) Received: from twhmp6px (mxsmtp211.mxic.com.tw. [211.75.127.162]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e085341490sm2751779a91.21.2024.09.26.07.25.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Sep 2024 07:25:19 -0700 (PDT) Received: from hqs-appsw-a2o.mp600.macronix.com (linux-patcher [172.17.236.67]) by twhmp6px (Postfix) with ESMTPS id CB751802C9; Thu, 26 Sep 2024 22:33:06 +0800 (CST) From: AlvinZhou To: linux-mtd@lists.infradead.org, linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, tudor.ambarus@linaro.org, pratyush@kernel.org, mwalle@kernel.org, miquel.raynal@bootlin.com, richard@nod.at, vigneshr@ti.com, broonie@kernel.org Cc: chengminglin@mxic.com.tw, leoyu@mxic.com.tw, AlvinZhou , JaimeLiao Subject: [PATCH v10 6/6] mtd: spi-nor: add support for Macronix Octal flash Date: Thu, 26 Sep 2024 22:19:56 +0800 Message-Id: <20240926141956.2386374-7-alvinzhou.tw@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240926141956.2386374-1-alvinzhou.tw@gmail.com> References: <20240926141956.2386374-1-alvinzhou.tw@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240926_072522_256753_D5ECF7F3 X-CRM114-Status: GOOD ( 12.67 ) X-Spam-Score: -2.1 (--) X-Spam-Report: Spam detection software, running on the system "bombadil.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: AlvinZhou Adding manufacturer ID 0xC2 at the end of ID table to allow manufacturer fixup to be applied for any Macronix flashes instead of needing to list each flash ID in the ID table. Such as macronix_nor_set_octal_dtr function in the manufacturer fixup can be applied to any Macronix Octal Flashes without the need to add the specific ID in the ID table. Content analysis details: (-2.1 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [alvinzhou.tw(at)gmail.com] 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: AlvinZhou Adding manufacturer ID 0xC2 at the end of ID table to allow manufacturer fixup to be applied for any Macronix flashes instead of needing to list each flash ID in the ID table. Such as macronix_nor_set_octal_dtr function in the manufacturer fixup can be applied to any Macronix Octal Flashes without the need to add the specific ID in the ID table. Suggested-by: Michael Walle Signed-off-by: JaimeLiao Signed-off-by: AlvinZhou --- drivers/mtd/spi-nor/macronix.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/mtd/spi-nor/macronix.c b/drivers/mtd/spi-nor/macronix.c index f039819a5252..1a8ccebdfe0e 100644 --- a/drivers/mtd/spi-nor/macronix.c +++ b/drivers/mtd/spi-nor/macronix.c @@ -200,7 +200,9 @@ static const struct flash_info macronix_nor_parts[] = { .name = "mx25l3255e", .size = SZ_4M, .no_sfdp_flags = SECT_4K, - } + }, + /* Need the manufacturer fixups, Keep this last */ + { .id = SNOR_ID(0xc2) } }; static int macronix_nor_octal_dtr_en(struct spi_nor *nor)