From patchwork Thu Nov 30 08:38:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: liao jaime X-Patchwork-Id: 1869993 X-Patchwork-Delegate: michael@walle.cc 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=2Y08W1QH; 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=a4VYPoQj; 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 4SgqPs0Hl2z23nw for ; Thu, 30 Nov 2023 19:39:58 +1100 (AEDT) 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=e06xr4jsutLxJQs1gB1vBkPr3A7RgpI6p4eD9xZWnkw=; b=2Y08W1QHs/rFDe WdHfBtILYe/CknpDJYLFEoJUvHVP6XECtpArvfAnBxmZueYzCKjukGsxk6QZqvrDgqcUDTazodfZ7 5uni/yHkHG5qfrWiCFXfQqMD4y4z6pSer6cs2hwutYCy5t78g2VB8ewcFb9Lty9UUhtQnVYSNVESy 1qodeNOmiVv7vBto3PQluCIhKheTpkhEUrBIuvaFMYy6c9VRtxq/Lt+8FMBuvKi8Q/eR+rOS8uvvm Br2+uWkphRpBGI8GdZ6aun9eQLg/Z1wSLPkVCBz3cjD3lsiOfjJTAZk1X4EQyKaB3mxjyT9oxGI8Q ASz/YoD16H8mqWjqB7OA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r8cZm-00AEUr-2v; Thu, 30 Nov 2023 08:39:14 +0000 Received: from mail-pj1-x102f.google.com ([2607:f8b0:4864:20::102f]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r8cZi-00AES5-3D for linux-mtd@lists.infradead.org; Thu, 30 Nov 2023 08:39:12 +0000 Received: by mail-pj1-x102f.google.com with SMTP id 98e67ed59e1d1-285bcb577d6so724424a91.3 for ; Thu, 30 Nov 2023 00:39:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701333547; x=1701938347; 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=h1fVaQ8xpYXerpjyXRXvWiYuEY8K4e6Teiic9m4/R+I=; b=a4VYPoQjTc3MZjcEeCjeb5UO+lhA9p+kqllDE39oGqmK7LNAYbdIIY1y1KGoFgoOHq B6GDvxhJETsTsJlrVS3a1pWm0mWy8/1t7YkMSlw3FmviPR4y/+bEIDKe6BF8ZSZA7RWY D3EJKnlCUom4pFLIJSLlgxL7LvaOZatKx8aZi2DgThawGBn4JPmanJErDC8SkB7UPeq1 oXLVuIFlJ9iTfLYHRNFCH/mispqRQwUn5u6fV0RwUMjM2mBhUW5lC8fuLm7goVQ9H/hJ /TtRgdBdqQP6RChseewTK0vJua6acH2+6g48tKb3xFab3wQJfyWuIGNTDkx6TTJ/QJXu ppZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701333547; x=1701938347; 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=h1fVaQ8xpYXerpjyXRXvWiYuEY8K4e6Teiic9m4/R+I=; b=nP5rniYqbaBo7/GqLi9g2i0iiWvWwuUKfBDQ/flMLXAe0r1WReNhJMPfIWLYODwYS+ cp5WKHbH+2+0ms1kvs3LZmJDv6fAfclColhJv+wjILLU49eGmVkBtSZ7LWcxz+YqDAwH MP8F5Ykqkj+Vq2xXSaTAW2cBTuJP0bJbpBwx/hSd0np7AiSSpKyWcOLtYlFTU/qLHA36 hRr/MZqCpRpDPMHoTtS3xvv/Cy8WHsn21o2kSWSw4TkfoWi6jGJf8FDpeOwy1cEWB7HX 348dbGwLDsepd4tV20mA2tAYpRc2yctB+x/vhBufWfqTmJ+d4brOpEmD/mnpN1SwDKYi w6xw== X-Gm-Message-State: AOJu0YyPWcWWFxouS1raUk47OMvHXytLXxfzCjIFPdcpKE0ENEyyG4KZ RpJzlXDwNsG9V3BDcsaVh4PeEPBGRmA= X-Google-Smtp-Source: AGHT+IHkhzlogwMZZLPPhWxBDKCYyWjefs8h5yd76sRSXh0Gtdc4S3+1S6yMzKaH0igkF0MEz8EqFA== X-Received: by 2002:a17:90a:e7cf:b0:280:9074:eb36 with SMTP id kb15-20020a17090ae7cf00b002809074eb36mr22186446pjb.14.1701333547159; Thu, 30 Nov 2023 00:39:07 -0800 (PST) Received: from twhmp6px (mxsmtp211.mxic.com.tw. [211.75.127.162]) by smtp.gmail.com with ESMTPSA id nt9-20020a17090b248900b002802d264240sm2752517pjb.29.2023.11.30.00.39.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 00:39:06 -0800 (PST) Received: from hqs-appsw-appswa2.mp600.macronix.com (linux-patcher [172.17.236.35]) by twhmp6px (Postfix) with ESMTPS id E772E80527; Thu, 30 Nov 2023 16:38:44 +0800 (CST) From: Jaime Liao To: linux-mtd@lists.infradead.org, tudor.ambarus@linaro.org, pratyush@kernel.org, michael@walle.cc, miquel.raynal@bootlin.com Cc: leoyu@mxic.com.tw, jaimeliao@mxic.com.tw Subject: [PATCH v6 1/7] mtd: spi-nor: add Octal DTR support for Macronix flash Date: Thu, 30 Nov 2023 16:38:48 +0800 Message-Id: <20231130083854.55221-2-jaimeliao.tw@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231130083854.55221-1-jaimeliao.tw@gmail.com> References: <20231130083854.55221-1-jaimeliao.tw@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231130_003911_036638_B72C1BE8 X-CRM114-Status: GOOD ( 20.40 ) X-Spam-Score: -0.2 (/) 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: JaimeLiao 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: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:102f listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [jaimeliao.tw[at]gmail.com] -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 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 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: JaimeLiao 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/diabling 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. Signed-off-by: JaimeLiao Co-developed-by: Tudor Ambarus --- drivers/mtd/spi-nor/macronix.c | 100 +++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) diff --git a/drivers/mtd/spi-nor/macronix.c b/drivers/mtd/spi-nor/macronix.c index ea6be95e75a5..dee71776b1a8 100644 --- a/drivers/mtd/spi-nor/macronix.c +++ b/drivers/mtd/spi-nor/macronix.c @@ -8,6 +8,24 @@ #include "core.h" +#define SPINOR_OP_MXIC_RD_ANY_REG 0x71 /* Read volatile configuration register 2 */ +#define SPINOR_OP_MXIC_WR_ANY_REG 0x72 /* Write volatile configuration register 2 */ +#define SPINOR_REG_MXIC_CR2_MODE 0x00000000 /* CR2 address for setting octal DTR mode */ +#define SPINOR_REG_MXIC_CR2_DC 0x00000300 /* CR2 address for setting dummy cycles */ +#define SPINOR_REG_MXIC_OPI_DTR_EN 0x2 /* Enable Octal DTR */ +#define SPINOR_REG_MXIC_SPI_EN 0x0 /* Enable SPI */ +#define SPINOR_REG_MXIC_ADDR_BYTES 4 /* Fixed R/W volatile address bytes to 4 */ +/* Convert dummy cycles to bit pattern */ +#define SPINOR_REG_MXIC_DC(p) \ + ((20 - p)/2) + +/* Macronix SPI NOR flash operations. */ +#define MXIC_NOR_WR_ANY_REG_OP(naddr, addr, ndata, buf) \ + SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_MXIC_WR_ANY_REG, 0), \ + SPI_MEM_OP_ADDR(naddr, 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,87 @@ 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] = SPINOR_REG_MXIC_DC(nor->params->reads[SNOR_CMD_READ_8_8_8_DTR].num_wait_states); + op = (struct spi_mem_op) + MXIC_NOR_WR_ANY_REG_OP(SPINOR_REG_MXIC_ADDR_BYTES, + SPINOR_REG_MXIC_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] = SPINOR_REG_MXIC_OPI_DTR_EN; + op = (struct spi_mem_op) + MXIC_NOR_WR_ANY_REG_OP(SPINOR_REG_MXIC_ADDR_BYTES, + SPINOR_REG_MXIC_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] = SPINOR_REG_MXIC_SPI_EN; + buf[1] = 0x0; + op = (struct spi_mem_op) + MXIC_NOR_WR_ANY_REG_OP(SPINOR_REG_MXIC_ADDR_BYTES, + SPINOR_REG_MXIC_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 +293,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 Nov 30 08:38:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: liao jaime X-Patchwork-Id: 1869991 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=ags4R9Mq; 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=kDw9HjtC; 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 4SgqPs0hK5z23nx for ; Thu, 30 Nov 2023 19:39:58 +1100 (AEDT) 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=P6+UXeMq4e4PNMQbjI3e68QiG++Pv4YKTFVrJFYjv94=; b=ags4R9MqTO2EBZ whuN7x7eXykavdKrKl8HBw+cUf92amt/MS2evPaPMh/lSu+KC3P5lWljojzucW+YICwwk5QY93xyx lXe5wkB0X8sPd6bjSiYB9XU+4lx398BH2Q6xwoU+he6zbAu8CT73bHtqUBC2xgaioO7ObAZKVJI+Q 4kdv2jhxP34qd7EOx3V2d0OIlwwzd2fDisD1pkim08oVzzsTpj7ZqqbNQt/MoYLIo4pE0sFVJ1lCk pjkeJpYlK8EwD5Q11+VjrpcZSjxOezDj8eoVt0aZ/R2ysPKxplTkKZPDFR2BDYSb07uaVJnYDU6EE UHlA8EwMu9BdkvDL/QuQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r8cZo-00AEVX-0q; Thu, 30 Nov 2023 08:39:16 +0000 Received: from mail-pf1-x435.google.com ([2607:f8b0:4864:20::435]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r8cZj-00AES9-0h for linux-mtd@lists.infradead.org; Thu, 30 Nov 2023 08:39:13 +0000 Received: by mail-pf1-x435.google.com with SMTP id d2e1a72fcca58-6cbe716b511so687935b3a.3 for ; Thu, 30 Nov 2023 00:39:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701333548; x=1701938348; 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=T3GyXJb1Q6IVqZm+jxYBDPVvW6P1FYJdkXuzb8mhWu8=; b=kDw9HjtCju8yjK0YbvMjzV1VkEXyE4UBIx/Un+V7uPPOdOMQXkX2YkC8wlZcpb8zgO EpxEfzX8Daml8YcNnQ+vgRf2Q2i2LT6HBIJExvcQI7qm5bmDCgwnhcfeCNDMOJkFpnFN ry5eIeeF2cQiqs7Y7tBZT4nozzuUkwec2eFD1cTJHv+MI/VAlOhdYdJieCIfofS0oVl1 gXuu5jdbHv1cKCCFRH6i0VlAjmqGprzN+IFdO5g/Cw/Clt892QzPhj81603wZVKt4aWH /vdcsAfwMzXs6cwbaFobc0/p3exEkwK3JPyAo9aqTmQxIFndIM2bSVM4RkNVo/XxvNAv 733w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701333548; x=1701938348; 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=T3GyXJb1Q6IVqZm+jxYBDPVvW6P1FYJdkXuzb8mhWu8=; b=soaeyNCsMAG7XS51dMM6fFCJ4rCra+zaVEiwdDnzjwHA47j4j1IdqYvUfb4HjWISbK by+eFQ0MWmn3GNqG/K1LFlX3ea+gAiiTYDamMt1MAaOUkcYbXzW8HkFe9s0ytg9SPh5p dTTA0GOSEL/F1agD7aKUodltdxImf4X4gQ0AJHyc2uR2Gi3FfIjsocZ37Qe2R76eMa7/ 7tWtrfOewupj1SGqVZHJS5XHNGKn3o8vPbQPpgeREMmP5IdTTqsUDWW0WS2dfRnYRGMT rkPlj9bMZlL+ZlvU+VK4p4beXfglDJsCAe7hutMZ9nj1hY9cwM3v6Mby4biB0+PbCxNx 7ZzA== X-Gm-Message-State: AOJu0YxjODYnOJ+KlwjR1dCnwXhMrDowIWjivAGAJBobaKlFsM4nvJhp OQJpSn80XIXNsEIhRgAIF+c= X-Google-Smtp-Source: AGHT+IGlZNH2tfX2tE3ddQ9MUvXUv/kBAmEj9VJ4IyBbqrKjUfwFdfx1xIfNaJF9V3C++nZwOB5zRQ== X-Received: by 2002:a05:6a21:2711:b0:187:8eca:8dc6 with SMTP id rm17-20020a056a21271100b001878eca8dc6mr20143835pzb.34.1701333547633; Thu, 30 Nov 2023 00:39:07 -0800 (PST) Received: from twhmp6px (mxsmtp211.mxic.com.tw. [211.75.127.162]) by smtp.gmail.com with ESMTPSA id fe25-20020a056a002f1900b006cdda8519a6sm697328pfb.170.2023.11.30.00.39.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 00:39:07 -0800 (PST) Received: from hqs-appsw-appswa2.mp600.macronix.com (linux-patcher [172.17.236.35]) by twhmp6px (Postfix) with ESMTPS id 723DD8056E; Thu, 30 Nov 2023 16:38:45 +0800 (CST) From: Jaime Liao To: linux-mtd@lists.infradead.org, tudor.ambarus@linaro.org, pratyush@kernel.org, michael@walle.cc, miquel.raynal@bootlin.com Cc: leoyu@mxic.com.tw, jaimeliao@mxic.com.tw Subject: [PATCH v6 2/7] spi: spi-mem: Allow specifying the byte order in DTR mode Date: Thu, 30 Nov 2023 16:38:49 +0800 Message-Id: <20231130083854.55221-3-jaimeliao.tw@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231130083854.55221-1-jaimeliao.tw@gmail.com> References: <20231130083854.55221-1-jaimeliao.tw@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231130_003911_252266_DDE771A5 X-CRM114-Status: GOOD ( 16.11 ) X-Spam-Score: -0.2 (/) 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: JaimeLiao 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: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:435 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [jaimeliao.tw[at]gmail.com] -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 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 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: JaimeLiao 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. So we must swap the bytes back to have the same byte order as in STR modes. Fortunately there are controllers that could swap the bytes back at runtime, addressing the flash's endiannesses 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. Signed-off-by: Tudor Ambarus Signed-off-by: JaimeLiao --- drivers/spi/spi-mem.c | 4 ++++ include/linux/spi/spi-mem.h | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/drivers/spi/spi-mem.c b/drivers/spi/spi-mem.c index edd7430d4c05..9c03b5617fff 100644 --- a/drivers/spi/spi-mem.c +++ b/drivers/spi/spi-mem.c @@ -172,6 +172,10 @@ bool spi_mem_default_supports_op(struct spi_mem *mem, if (!spi_mem_controller_is_capable(ctlr, dtr)) return false; + if (op->data.dtr_swab16 && + !(spi_mem_controller_is_capable(ctlr, dtr_swab16))) + 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 6b0a7dc48a4b..d4935c5c3c7a 100644 --- a/include/linux/spi/spi-mem.h +++ b/include/linux/spi/spi-mem.h @@ -89,6 +89,8 @@ enum spi_mem_data_dir { * @dummy.dtr: whether the dummy bytes should be sent in DTR mode or not * @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.dtr_swab16: whether the byte order of 16-bit words is swapped when read + * or written in Octal DTR mode compared to STR mode. * @data.ecc: whether error correction is required or not * @data.dir: direction of the transfer * @data.nbytes: number of data bytes to send/receive. Can be zero if the @@ -123,6 +125,7 @@ struct spi_mem_op { struct { u8 buswidth; u8 dtr : 1; + u8 dtr_swab16 : 1; u8 ecc : 1; u8 __pad : 6; enum spi_mem_data_dir dir; @@ -294,10 +297,13 @@ struct spi_controller_mem_ops { /** * struct spi_controller_mem_caps - SPI memory controller capabilities * @dtr: Supports DTR operations + * @dtr_swab16: Supports swapping bytes on a 16 bit boundary when configured in + * Octal DTR * @ecc: Supports operations with error correction */ struct spi_controller_mem_caps { bool dtr; + bool dtr_swab16; bool ecc; }; From patchwork Thu Nov 30 08:38:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: liao jaime X-Patchwork-Id: 1869994 X-Patchwork-Delegate: michael@walle.cc 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=O1VVxEYA; 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=FMgn/zFi; 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 4SgqPw1DMhz24DS for ; Thu, 30 Nov 2023 19:40:02 +1100 (AEDT) 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=sTSaaKKVXyTRkp9c0D6YEiM58kDiRq5yIJGh3Q7KSqo=; b=O1VVxEYAow5b9e YXaCPlWMAqC+szRyt3pPY6+DozwmTcjflVnjp7CxrAQCBCnMDkqUiVGbQrWi/bK+wVEAyPw/YoL6r hTZwU9pXXZz1ozy7INtkjrFDcRJaKNOXf0xYLhtrLu8gu9gZAU61HRV/XPuU57tdEDAKFvAS5/egE bdcDYDJTY/arYwUqce3VR8H1dr3S+aqKVe9pJNGdq4pig9IawVjLRRNexUibXd8QGU2p+WevI3c04 DN/b0vYcDvuxDAQR0PIO++07AZbVPCMxYpACK1nCgRi/NBQ/gX0lk5ITztQ04Gs50na6cmTctGEDL XDyJ14E+gU0AImrem/ZA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r8cZo-00AEVx-32; Thu, 30 Nov 2023 08:39:16 +0000 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r8cZj-00AESA-2L for linux-mtd@lists.infradead.org; Thu, 30 Nov 2023 08:39:13 +0000 Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-1cfc35090b0so6471465ad.1 for ; Thu, 30 Nov 2023 00:39:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701333548; x=1701938348; 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=hVTTWWtZhFqG9GH7YEwD3bL8dviTGVgBf2t5fcazJks=; b=FMgn/zFiyHFKocDcIU9b1NpovOVQOr0HiuLP8QKrb42sFWOA7dFOmgfg8TJJdKKW59 3r/EZhcKrMjmpW6A1jl/uYtLf+zB3Vr/JVYB7EQXzgk1Ug1l92syVNvyByved7C5CpV0 PvuVMFguilb49cboYzqioXiaRGbJse8SU/URFKk7qCxGrXxsV8FQSU2zVNbTWL93yTE6 uIiLCo2A0U8NFqni4qV75+8I9uB6mH38WVaZ6jEhfw5vdf1VBrJ34bq4PhlHk2nxX4uE WOPvWunaL4RdTdQMyiQSZHbbpJCtuBxanXaM+6rZQSy1jPx4lHyK4lwHEptCqkk6TFFs xJjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701333548; x=1701938348; 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=hVTTWWtZhFqG9GH7YEwD3bL8dviTGVgBf2t5fcazJks=; b=d+IgPlp8XohboBBrkajKesJDD8tRVeuG9tW2yJ30L+v78TKQXUdFBdgEQRzupujPqC /wF/e+B9HaYD301frshDzOBig7omGi/doCd9N0bHec23AP8K6VQRYhdw/zvEgg6VXVtm vSVRwLiM00RPzpRbHncx7BntLQa382BEoRMdtKU3B7x9vtyM25RdOcQ8HoiE5QxwRJVe qVqCTwc7tEuvpzIw9uWvY+yAHPFsB+FshSqdeJmTAosbJSJegrydQNFCKceB+wY6w6SI owjaUQbiwK3NTcA7PcI7Jg6KX4g6gsJYYy2ZImj/kUj3I3P7pgiHbJptmgRe3vWnlomF 4wQA== X-Gm-Message-State: AOJu0YyESDsX7UGX71mSxzIkJ2WrmSu1DJOT57j69USO0zL0f81GD7/X lnDHPmf9FnlsbagSdv2JVQU= X-Google-Smtp-Source: AGHT+IHCvPcZKZxT3vJt/Tlpr6uavRwolz/TAQOyaS5sc6voxNkev1XbIWdAKQW3wJhCtL1hmn7vSg== X-Received: by 2002:a17:902:f68d:b0:1cf:fc5c:75c4 with SMTP id l13-20020a170902f68d00b001cffc5c75c4mr9442055plg.55.1701333548074; Thu, 30 Nov 2023 00:39:08 -0800 (PST) Received: from twhmp6px (mxsmtp211.mxic.com.tw. [211.75.127.162]) by smtp.gmail.com with ESMTPSA id y11-20020a170902b48b00b001cfa4178981sm736641plr.309.2023.11.30.00.39.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 00:39:07 -0800 (PST) Received: from hqs-appsw-appswa2.mp600.macronix.com (linux-patcher [172.17.236.35]) by twhmp6px (Postfix) with ESMTPS id EC2DB80650; Thu, 30 Nov 2023 16:38:45 +0800 (CST) From: Jaime Liao To: linux-mtd@lists.infradead.org, tudor.ambarus@linaro.org, pratyush@kernel.org, michael@walle.cc, miquel.raynal@bootlin.com Cc: leoyu@mxic.com.tw, jaimeliao@mxic.com.tw Subject: [PATCH v6 3/7] mtd: spi-nor: core: Allow specifying the byte order in DTR mode Date: Thu, 30 Nov 2023 16:38:50 +0800 Message-Id: <20231130083854.55221-4-jaimeliao.tw@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231130083854.55221-1-jaimeliao.tw@gmail.com> References: <20231130083854.55221-1-jaimeliao.tw@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231130_003911_760445_5D98ED14 X-CRM114-Status: GOOD ( 13.35 ) X-Spam-Score: -0.2 (/) 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: JaimeLiao 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: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:635 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [jaimeliao.tw[at]gmail.com] -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 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 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: JaimeLiao 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 controllers are 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 we 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. Signed-off-by: Tudor Ambarus Signed-off-by: JaimeLiao --- drivers/mtd/spi-nor/core.c | 8 ++++++++ drivers/mtd/spi-nor/core.h | 1 + 2 files changed, 9 insertions(+) diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c index 1c443fe568cf..f659dd037a25 100644 --- a/drivers/mtd/spi-nor/core.c +++ b/drivers/mtd/spi-nor/core.c @@ -70,6 +70,13 @@ static u8 spi_nor_get_cmd_ext(const struct spi_nor *nor, } } +static inline bool spi_nor_is_octal_dtr_swab16(const struct spi_nor *nor, + enum spi_nor_protocol proto) +{ + return (proto == SNOR_PROTO_8_8_8_DTR) && + (nor->flags & SNOR_F_DTR_SWAB16); +} + /** * spi_nor_spimem_setup_op() - Set up common properties of a spi-mem op. * @nor: pointer to a 'struct spi_nor' @@ -105,6 +112,7 @@ void spi_nor_spimem_setup_op(const struct spi_nor *nor, op->addr.dtr = true; op->dummy.dtr = true; op->data.dtr = true; + op->data.dtr_swab16 = spi_nor_is_octal_dtr_swab16(nor, proto); /* 2 bytes per clock cycle in DTR mode. */ op->dummy.nbytes *= 2; diff --git a/drivers/mtd/spi-nor/core.h b/drivers/mtd/spi-nor/core.h index 93cd2fc3606d..fe1259b32110 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_DTR_SWAB16 = BIT(17), }; struct spi_nor_read_command { From patchwork Thu Nov 30 08:38:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: liao jaime X-Patchwork-Id: 1869995 X-Patchwork-Delegate: michael@walle.cc 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=Gr1qHLiz; 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=FTmGK9uy; 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 4SgqPq6gmRz1yST for ; Thu, 30 Nov 2023 19:39:58 +1100 (AEDT) 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=xfWN4RmNv/EBmg2Yhf2oRYk3E/0cPto1i9+Tosv92jM=; b=Gr1qHLizkHjDlg NYSRaaVek+eroJge4Kj1pDpCmO+xXHwHp8R7QaUpqXuvPLQfgWPGNA/DL6bJle1LXQW7iLWZpzKIL NTiWCuPaWDVEUnoxYExLzEt7UaeLUS7wFyRsQizOR3bR4LfTdM8rUg0dfaojO2gdvyQeME6yx9Yl1 vlL6UBBdDIqPiKFe7JC/rwLCE64UuyqzsrxWHaicyczWenV5iyJL2febwtU2R8Df0gVsivaBxPjlI WqE/bYf3NLfutGLizpX8btk++8B+kbwg3u6w11uT7l++9BxS0mp0NtBNGK6HshUSWocazx0j/lI+/ Ry7ys9gHY8C4GgAGgR+g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r8cZq-00AEX1-26; Thu, 30 Nov 2023 08:39:18 +0000 Received: from mail-il1-x130.google.com ([2607:f8b0:4864:20::130]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r8cZj-00AESI-25 for linux-mtd@lists.infradead.org; Thu, 30 Nov 2023 08:39:13 +0000 Received: by mail-il1-x130.google.com with SMTP id e9e14a558f8ab-35cb61de347so1670315ab.1 for ; Thu, 30 Nov 2023 00:39:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701333549; x=1701938349; 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=GGIOPjWsWXffU/sU+xJxvsbx/tJ6sjXRamjNWghiIh8=; b=FTmGK9uywrTRqG6QjWl25PqtDZLCkO3goOOADE7GXMsyIj40BA0SHw6LdzyGjT7dbC DDpjXkC0xjLf6hIYOXKUDHZpZ+YtXfJZQAyoB7sMo7/HVx0bWoRg/aZs7KXol/QvKRw8 gIaK2dvYU20A/L0CPuV0UH8V1NHTSyBWNWtR++2hmYvbVeIJ7ceNEpkyznradhLdj4xz x3MF0wIzaAZW6PE2vXyXs/d8d5sOU+i6fgMMrvvxDesnVQkJSXl0CiBXa9UELpmdNepO WyvN293QmlsUaylILFQ9gNpSNR2sGTU8wHniECin+AWU65i1yiszkd1a9xFcAFMMipuB hsMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701333549; x=1701938349; 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=GGIOPjWsWXffU/sU+xJxvsbx/tJ6sjXRamjNWghiIh8=; b=c/w5m8AMb/RTH1AwBPki/86ULvW5+iERLC4cs5TMxDeV86Ls7zcDWwCySSdh4UUT4l tqgIhIliwlb8w7safJi7BqpNpaPE9BO9CTu8dbnG2m6hQRglvqE5L4BifUES22i9UUbR eYQ2XlaMC9cgPYOu0IjQ3ozYIHaeThUS/UveZqxHJsa8G8N0z8xjjVfTTR9GRXcUcsnw yR0kywrjgOhYXUHyAh6TLrM5BgzxGTfsimGka/QWnBOeKJ+VsBS2ALFZJWMgZ++fsUl4 k3q7Ly0alY1QcR7u52XyVugZskvIHdIWYiS/bz4+iTgTaDBLxBa9m/TWWX40AuHBNfG7 tOZA== X-Gm-Message-State: AOJu0Yy++Qg8TXYfKWu3F9RfEHRd2tQIPBatC5DmyliJo3HxLcUAY3cK r8O7YXILprVMmXT958GYDjw= X-Google-Smtp-Source: AGHT+IEhJK7dGIr7sNeAvFO9CyCm05o0U9nWHQMJJnzsx8bbwIaYMSzegHPRpPEQ1VTFLHNJGaOZPw== X-Received: by 2002:a92:cd4a:0:b0:35c:df90:a7d with SMTP id v10-20020a92cd4a000000b0035cdf900a7dmr12719532ilq.25.1701333549473; Thu, 30 Nov 2023 00:39:09 -0800 (PST) Received: from twhmp6px (mxsmtp211.mxic.com.tw. [211.75.127.162]) by smtp.gmail.com with ESMTPSA id ff11-20020a056a002f4b00b00690ca67d429sm680814pfb.100.2023.11.30.00.39.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 00:39:09 -0800 (PST) Received: from hqs-appsw-appswa2.mp600.macronix.com (linux-patcher [172.17.236.35]) by twhmp6px (Postfix) with ESMTPS id 6C69680697; Thu, 30 Nov 2023 16:38:46 +0800 (CST) From: Jaime Liao To: linux-mtd@lists.infradead.org, tudor.ambarus@linaro.org, pratyush@kernel.org, michael@walle.cc, miquel.raynal@bootlin.com Cc: leoyu@mxic.com.tw, jaimeliao@mxic.com.tw Subject: [PATCH v6 4/7] mtd: spi-nor: sfdp: Get the 8D-8D-8D byte order from BFPT Date: Thu, 30 Nov 2023 16:38:51 +0800 Message-Id: <20231130083854.55221-5-jaimeliao.tw@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231130083854.55221-1-jaimeliao.tw@gmail.com> References: <20231130083854.55221-1-jaimeliao.tw@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231130_003911_679708_BC63E6C6 X-CRM114-Status: GOOD ( 13.76 ) X-Spam-Score: -0.2 (/) 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: JaimeLiao 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. Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:130 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [jaimeliao.tw[at]gmail.com] -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 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 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: JaimeLiao 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 determin whether the corresponding operation are supported, thus avoiding the generation of unexpected data order. Signed-off-by: Tudor Ambarus Signed-off-by: JaimeLiao --- 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 b3b11dfed789..2241207556bf 100644 --- a/drivers/mtd/spi-nor/sfdp.c +++ b/drivers/mtd/spi-nor/sfdp.c @@ -650,6 +650,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_DTR_SWAB16; + 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 6eb99e1cdd61..eba760941d43 100644 --- a/drivers/mtd/spi-nor/sfdp.h +++ b/drivers/mtd/spi-nor/sfdp.h @@ -123,6 +123,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 order of 16-bit words in 8D-8D-8D mode */ struct sfdp_parameter_header { u8 id_lsb; From patchwork Thu Nov 30 08:38:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: liao jaime X-Patchwork-Id: 1869988 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=Y+QUj1rf; 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=CZA6HFNn; 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 4SgqPs1yjwz24DR for ; Thu, 30 Nov 2023 19:39:58 +1100 (AEDT) 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=VhsVAxspJnpoeYYbHFy9DlpxBGDNkf1SNodT7tWMFJs=; b=Y+QUj1rfmR2FAQ OxEC4eXViYZdUJy6ft1XCZ0zStZdLr+ykVQmZ3JxNEiSw12nUY6Z5y4pU/wulj1iG3N8wGyU9Zw8u RPgCKrk3hdzfg2bqDeZp3a5F6qpJyAKsIXL2W5+zLSNufzrEqtppow1yiD1c1iQo6QgrG5mNQiUY5 3991Zxj1iR7wQeRuNu8e/eDeMFEXHZollEvm+2e9En+kqfKkGCVDUzKpDpFHkx6itFF7XmjLcC5u4 yifXNvp/CBEpjwq46JgblMRTH8foN0SG8AAv97gwvluVc6y2L2xPqJ9CEzO5Dw/8RKf95zq+5Wt+z 4J29fUN3WlE7VWJTHwZA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r8cZp-00AEWZ-21; Thu, 30 Nov 2023 08:39:17 +0000 Received: from mail-pf1-x42d.google.com ([2607:f8b0:4864:20::42d]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r8cZk-00AESH-0d for linux-mtd@lists.infradead.org; Thu, 30 Nov 2023 08:39:13 +0000 Received: by mail-pf1-x42d.google.com with SMTP id d2e1a72fcca58-6cdd584591eso692361b3a.2 for ; Thu, 30 Nov 2023 00:39:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701333549; x=1701938349; 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=R7EQrS0NRCQ0ONglNsAAgM/GE2mdcSW8vl/ECGXjYAs=; b=CZA6HFNnJNpDKB5uCUM/m8ovQm97OkdRLgnijdWn/XfrZKgSGeMKOpXYdfRKtk/m2v XZ20mRaA+bPktNRDQXMa2rVVPebhVa0fT8gUlTnFaV2PdVawlwcxfechIYbD0LerX8p/ 7wqa3n1ZubzpaFVUk/nG0kbY0uQ8VX+O6GDQD80N2FhDfu8M5Dc0d2+ctY6bkuM4/i6R c99LdlGC4thrSSGpJAoPbi3FuypPIFnPIAezGW3XhHwgkmWKk20uX1yT0RekzL17avgR tc2zGxvgkbRrp6a/jmr3n0hq7NPsFhuekx6uH2K7InzM7WQARJtiGeokyQHQvdnLGVWK VE6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701333549; x=1701938349; 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=R7EQrS0NRCQ0ONglNsAAgM/GE2mdcSW8vl/ECGXjYAs=; b=HmRtwuWLJ8IYW7xv91yTI3GQ7DI7P8Qlz2tol5ENlVPtyJufBhoulmZEQp8Sgi6J6o 2nx+YaQMcnXzcw4f0eJ/87qV0wqcbC9Vni+6e29bxncU1B+A5M2Ir3jvwMt0ruL/Jtda VLiB1zOUkQd3g6LZixRByrqsGFbc7eu8ZD0Y8eZTyxtHgHNf8k0NGO5fD4gjEpV8cbXh qPMSsYFa6Uf2eNCn0DWJ6MfYJAMuDdj/T/uksJso9BS1LqM2dghtFC3wpp2nijkMYIt+ YbsYnk45dkv6lZBQ5H8Ieu48LKnOEa1rDvbDXd85RR9otWsximy58F+zSRZ+UE01pKq/ Rq7g== X-Gm-Message-State: AOJu0Yx2rnRX+CoWvs4ochR9JY137KyvJ4q0kmlYg43FGBxSfNmuvEog AxUtwAKnIdUIthKHn8gv/ZY= X-Google-Smtp-Source: AGHT+IEM7dVfs9f/ErOZjIsIuxVvCbgACKkLNLIi3ltnMuBRfxOPXSFrTgBEXmVRLXwYfhqqwM888w== X-Received: by 2002:a05:6a20:438a:b0:18a:e176:5283 with SMTP id i10-20020a056a20438a00b0018ae1765283mr21025969pzl.39.1701333549265; Thu, 30 Nov 2023 00:39:09 -0800 (PST) Received: from twhmp6px (mxsmtp211.mxic.com.tw. [211.75.127.162]) by smtp.gmail.com with ESMTPSA id t7-20020a62d147000000b006cb60b188bdsm698069pfl.196.2023.11.30.00.39.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 00:39:08 -0800 (PST) Received: from hqs-appsw-appswa2.mp600.macronix.com (linux-patcher [172.17.236.35]) by twhmp6px (Postfix) with ESMTPS id D1FC18050C; Thu, 30 Nov 2023 16:38:46 +0800 (CST) From: Jaime Liao To: linux-mtd@lists.infradead.org, tudor.ambarus@linaro.org, pratyush@kernel.org, michael@walle.cc, miquel.raynal@bootlin.com Cc: leoyu@mxic.com.tw, jaimeliao@mxic.com.tw Subject: [PATCH v6 5/7] spi: mxic: Add support for swapping byte Date: Thu, 30 Nov 2023 16:38:52 +0800 Message-Id: <20231130083854.55221-6-jaimeliao.tw@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231130083854.55221-1-jaimeliao.tw@gmail.com> References: <20231130083854.55221-1-jaimeliao.tw@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231130_003912_262387_2F454937 X-CRM114-Status: GOOD ( 10.63 ) X-Spam-Score: -0.2 (/) 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: JaimeLiao 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: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:42d listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [jaimeliao.tw[at]gmail.com] -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 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 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: JaimeLiao 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 dirver. Signed-off-by: JaimeLiao --- drivers/spi/spi-mxic.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/spi/spi-mxic.c b/drivers/spi/spi-mxic.c index 60c9f3048ac9..085c9037d6f5 100644 --- a/drivers/spi/spi-mxic.c +++ b/drivers/spi/spi-mxic.c @@ -572,6 +572,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, + .dtr_swab16 = true, .ecc = true, }; From patchwork Thu Nov 30 08:38:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: liao jaime X-Patchwork-Id: 1869990 X-Patchwork-Delegate: michael@walle.cc 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=19ZEA7Lh; 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=dozcG6Ve; 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 4SgqPs1BrZz24DP for ; Thu, 30 Nov 2023 19:39:58 +1100 (AEDT) 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=E2VqlDaI87z7jkkJhgExkok//YWhhblg8ro4dwqMVzE=; b=19ZEA7LhbVvc2A ArZJkdzmmk5eOe5EFmZHGGIQlWqIvbHjkF4gG0Qw7v/lDZ31JQg3MYzCpuURJfOZZXQsCvWt1IohM Lhw9dD71qyANv9XL0Ox95yhoyfmuqHtZfOJS9frBmpKCwCzeCag3qELjna/D9IE9/zi/CF0l9ZbOu 9SleUaIObhld0NjF9X80a4HTYM0lolD7oI5/c+ZDSxJkB6BRlGzvP31VSd2fHWKDlwjpdA/isasDm TEHWZK7QiovtHp8kHhlBVyS+S7p7G7wf24y2tL9U0FlQLz/MsclHJep1G/lutfaRyaDkf2Aoetaw+ dWu6XpbYhpCRe3sPNI0g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r8cZu-00AEZ6-0e; Thu, 30 Nov 2023 08:39:22 +0000 Received: from mail-pg1-x533.google.com ([2607:f8b0:4864:20::533]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r8cZl-00AESK-0p for linux-mtd@lists.infradead.org; Thu, 30 Nov 2023 08:39:16 +0000 Received: by mail-pg1-x533.google.com with SMTP id 41be03b00d2f7-5c625e98380so317761a12.0 for ; Thu, 30 Nov 2023 00:39:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701333550; x=1701938350; 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=v2FwjmzNQbjvTPCP0OFopwYTGeima63fp13M8qzBasg=; b=dozcG6VekyuNBfx+th2gp61Nrx1WxG419qld/0vCQHpFjnaFodFp2jitq6rCU3+FLv CohCHO83/tqkVsRQmGHlbIw9NeVlVf1kBbE2/J1GueU+WdseROoCIPRkVJNmgbA00evv goQCk49T3qxW9Fkzk32o+1Wru/2EcAt8XaALSv4pxvY9fMN7f5a2WgJgUVUW5a8iOQR8 bp67zg1OdfNwgCIY9FKn4Zi4cWzsfgzwnFvRWQTtVP58QfdfBtgxRjzYSdagCbW7q109 WXOQHNVfBGutsdy5Oy7LOzHzLjiWntjuIt7/83Qc3VzkGMFpRWI1AFPG9P4nwYBU9K6x dXYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701333550; x=1701938350; 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=v2FwjmzNQbjvTPCP0OFopwYTGeima63fp13M8qzBasg=; b=sl8HcEhpGkxfTAM6vr1n9IDWh4UwLCfclsC3y/rl6VFMSQa6gEIRHfajU9B4brYPpy tr7lZ6XK27m8FyN2u5S1N82XxCPwS77qU2RFtZlczio3UH0ogouI3cqxICNdDrJZgQDR ac6A7wcnCfVN/Ld/OvXXxP6GcI52RsZQM9EuBU76Qo40UaB4azmTrafn6b3nwFFJHiX8 /Q5NW8O4C+BxMgLisvCJRaaWUR3QgK4aa44JlaR2ULp8I2W1PKQf6FkGim+Y6ZMiPMrO jlpV6AzB5xOzGAtXCeBhKGlaq/nYHXHIYqpsgNYqlmPf3DfU7T8R0vbXmXj8ok3yHlCU kOIA== X-Gm-Message-State: AOJu0YxdxvrjVyqgUMeCjhahM2F5xus8hF68y5fZ2AGMzTpfQG/cL1Z/ /pb3m23+9gL0m0FkjL5ECuI= X-Google-Smtp-Source: AGHT+IHHu6DV7OaIeyvkFcJOco+sISbiZGUVigP66sBxS1lx68dlW4RVH7+SqNT/aXXrzENXa+wW4w== X-Received: by 2002:a17:90b:3009:b0:27f:fcdb:89c1 with SMTP id hg9-20020a17090b300900b0027ffcdb89c1mr18836477pjb.41.1701333550185; Thu, 30 Nov 2023 00:39:10 -0800 (PST) Received: from twhmp6px (mxsmtp211.mxic.com.tw. [211.75.127.162]) by smtp.gmail.com with ESMTPSA id q4-20020a170902dac400b001cfbda0401asm755321plx.130.2023.11.30.00.39.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 00:39:09 -0800 (PST) Received: from hqs-appsw-appswa2.mp600.macronix.com (linux-patcher [172.17.236.35]) by twhmp6px (Postfix) with ESMTPS id 4935380527; Thu, 30 Nov 2023 16:38:47 +0800 (CST) From: Jaime Liao To: linux-mtd@lists.infradead.org, tudor.ambarus@linaro.org, pratyush@kernel.org, michael@walle.cc, miquel.raynal@bootlin.com Cc: leoyu@mxic.com.tw, jaimeliao@mxic.com.tw Subject: [PATCH v6 6/7] mtd: spi-nor: add support for Macronix Octal flash with RWW feature Date: Thu, 30 Nov 2023 16:38:53 +0800 Message-Id: <20231130083854.55221-7-jaimeliao.tw@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231130083854.55221-1-jaimeliao.tw@gmail.com> References: <20231130083854.55221-1-jaimeliao.tw@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231130_003913_294121_0EAE8525 X-CRM114-Status: UNSURE ( 5.99 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.2 (/) 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: JaimeLiao Adding Macronix Octal flash for Octal DTR support. The octaflash series can be divided into the following types: Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:533 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [jaimeliao.tw[at]gmail.com] -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 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 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: JaimeLiao Adding Macronix Octal flash for Octal DTR support. The octaflash series can be divided into the following types: MX25 series : Serial NOR Flash. MX66 series : Serial NOR Flash with stacked die.(Size larger than 1Gb) LM/UM series : Up to 250MHz clock frequency with both DTR/STR operation. LW/UW series : Support simultaneous Read-while-Write operation in multiple bank architecture. Read-while-write feature which means read data one bank while another bank is programing or erasing. MX25LM : 3.0V Octal I/O -https://www.mxic.com.tw/Lists/Datasheet/Attachments/8729/MX25LM51245G,%203V,%20512Mb,%20v1.1.pdf MX25UM : 1.8V Octal I/O -https://www.mxic.com.tw/Lists/Datasheet/Attachments/8967/MX25UM51245G,%201.8V,%20512Mb,%20v1.5.pdf MX66LM : 3.0V Octal I/O with stacked die -https://www.mxic.com.tw/Lists/Datasheet/Attachments/8748/MX66LM1G45G,%203V,%201Gb,%20v1.1.pdf MX66UM : 1.8V Octal I/O with stacked die -https://www.mxic.com.tw/Lists/Datasheet/Attachments/8711/MX66UM1G45G,%201.8V,%201Gb,%20v1.1.pdf MX25LW : 3.0V Octal I/O with Read-while-Write MX25UW : 1.8V Octal I/O with Read-while-Write MX66LW : 3.0V Octal I/O with Read-while-Write and stack die MX66UW : 1.8V Octal I/O with Read-while-Write and stack die As below are the SFDP table dump. zynq> cat jedec_id c28437 zynq> cat manufacturer macronix zynq> cat partname mx25uw6345g zynq> xxd -p sfdp 53464450080104fd00070114400000ff8701011c900000ff0a0001080001 00ff05000105200100ff84000102340100ff0000000000000000ffffffff ffffffffe5208affffffff0300ff00ff00ff00ffeeffffffffff00ffffff 00ff0c2010d800ff00ff8b7901008f1200c4cc04674630b030b0f4bdd55c 000000ff101000200000000000007c234800000000008888000000000000 00400fd1fff30fd1fff300050090000500b1002b0095002b0096727103b8 727103b80000000090a3188200c069960000000000000000727100987271 00b8727100990000000072710098727100f872710099727100f900000000 00000000011501d0727106d8000086500000060100000000020001030002 00000000060100000000000072060002000000eec0697272717100d8f7f6 000a00001445988043060f0021dcffff zynq> md5sum sfdp c6fb57b8fdd4c35b5f0dacc4a1f7d4f4 sfdp zynq> mtd_debug info /dev/mtd0 mtd.type = MTD_NORFLASH mtd.flags = MTD_CAP_NORFLASH mtd.size = 8388608 (8M) mtd.erasesize = 4096 (4K) mtd.writesize = 1 mtd.oobsize = 0 regions = 0 zynq> cat jedec_id c28137 zynq> cat manufacturer macronix zynq> cat partname mx25uw6445g zynq> xxd -p sfdp 53464450080104fd00070114400000ff8701011c900000ff0a0001080001 00ff05000105200100ff84000102340100ff0000000000000000ffffffff ffffffffe5208affffffff0300ff00ff00ff00ffeeffffffffff00ffffff 00ff0c2010d800ff00ff897901008d1200c4cc04674630b030b0f4bdd55c 000000ff101000200000000000007ca34800000000008888000000000000 00400fd1fff30fd1fff300050090000500b1002b0095002b0096727103b8 727103b80000000090a3188200c069960000000000000000727100987271 00b8727100990000000072710098727100f872710099727100f900000000 00000000011501d0727106d8000086500000060100000000020001030002 00000000060100000000000072060002000000eec0697272717100d8f7f6 000a00001445988043060f0021dcffff zynq> md5sum sfdp b09aeedb0cfd0f77adc7e08592d295a9 sfdp zynq> mtd_debug info /dev/mtd0 mtd.type = MTD_NORFLASH mtd.flags = MTD_CAP_NORFLASH mtd.size = 8388608 (8M) mtd.erasesize = 4096 (4K) mtd.writesize = 1 mtd.oobsize = 0 regions = 0 zynq> cat jedec_id c28438 zynq> cat manufacturer macronix zynq> cat partname mx25uw12345g zynq> xxd -p sfdp 53464450080104fd00070114400000ff8701011c900000ff0a0001080001 00ff05000105200100ff84000102340100ff0000000000000000ffffffff ffffffffe5208affffffff0700ff00ff00ff00ffeeffffffffff00ffffff 00ff0c2010d800ff00ff8b7901008f1200c9cc04674630b030b0f4bdd55c 000000ff101000200000000000007c234800000000008888000000000000 00400fd1fff30fd1fff300050090000500b1002b0095002b0096727103b8 727103b80000000090a3188200c069960000000000000000727100987271 00b8727100990000000072710098727100f872710099727100f900000000 00000000011501d0727106d8000086500000060100000000020001030002 00000000060100000000000072060002000000eec0697272717100d8f7f6 000a00001445988043060f0021dcffff zynq> md5sum sfdp a3eb609c08894c84270ad06efc03766c sfdp zynq> mtd_debug info /dev/mtd0 mtd.type = MTD_NORFLASH mtd.flags = MTD_CAP_NORFLASH mtd.size = 16777216 (16M) mtd.erasesize = 4096 (4K) mtd.writesize = 1 mtd.oobsize = 0 regions = 0 zynq> cat jedec_id c28138 zynq> cat manufacturer macronix zynq> cat partname mx25uw12845g zynq> xxd -p sfdp 53464450080104fd00070114400000ff8701011c900000ff0a0001080001 00ff05000105200100ff84000102340100ff000000000000000000000000 00000000e5208affffffff0700ff00ff00ff00ffeeffffffffff00ffffff 00ff0c2010d800ff00ff8b7901008f1200c9cc04674630b030b0f4bdd55c 000000ff101000200000000000007ca34800000000008888000000000000 00400fd1fff30fd1fff300050090000500b1002b0095002b0096727103b8 727103b80000000090a3188200c069960000000000000000727100987271 00b8727100990000000072710098727100f872710099727100f900000000 00000000011501d0727106d8000086500000060100000000020001030002 00000000060100000000000072060002000000eec0697272717100d8f7f6 000a00001445988043060f0021dcffff zynq> md5sum sfdp 9eacff90d7aa7cf737b970e0f2a7f2c6 sfdp zynq> mtd_debug info /dev/mtd0 mtd.type = MTD_NORFLASH mtd.flags = MTD_CAP_NORFLASH mtd.size = 16777216 (16M) mtd.erasesize = 4096 (4K) mtd.writesize = 1 mtd.oobsize = 0 regions = 0 zynq> cat jedec_id c28439 zynq> cat manufacturer macronix zynq> cat partname mx25uw25345g zynq> xxd -p sfdp 53464450080104fd00070114400000ff8701011c900000ff0a0001080001 00ff05000105200100ff84000102340100ff0000000000000000ffffffff ffffffffe5208affffffff0f00ff00ff00ff00ffeeffffffffff00ffffff 00ff0c2010d800ff00ff897901008d1200d2cc04674630b030b0f4bdd55c 000000ff101000200000147c00007c234800000000008888000000000000 00400fd1fff30fd1fff300050090060500b1002b0095002b0096727103b8 727103b80000000090a3188200c069960000000000000000000000000000 0000000000000000000072710098727100f872710099727100f900000000 00000000011501d0727106d8000086500000060100000000020001030002 00000000060100000000000072060002000000eec0697272717100d8f7f6 000a00001445988043061f0021dcffff zynq> md5sum sfdp 765e310356fb92fdd77b2af1c725fbcb sfdp zynq> mtd_debug info /dev/mtd0 mtd.type = MTD_NORFLASH mtd.flags = MTD_CAP_NORFLASH mtd.size = 33554432 (32M) mtd.erasesize = 4096 (4K) mtd.writesize = 1 mtd.oobsize = 0 regions = 0 zynq> cat jedec_id c28139 zynq> cat manufacturer macronix zynq> cat partname mx25uw25645g zynq> xxd -p sfdp 53464450080104fd00070114400000ff8701011c900000ff0a0001080001 00ff05000105200100ff84000102340100ff0000000000000000ffffffff ffffffffe5208affffffff0f00ff00ff00ff00ffeeffffffffff00ffffff 00ff0c2010d800ff00ff897901008d1200d2cc04674630b030b0f4bdd55c 000000ff101000200000000000007ca34800000000008888000000000000 00400fd1fff30fd1fff300050090000500b1002b0095002b0096727103b8 727103b80000000090a3188200c069960000000000000000727100987271 00b8727100990000000072710098727100f872710099727100f900000000 00000000011501d0727106d8000086500000060100000000020001030002 00000000060100000000000072060002000000eec0697272717100d8f7f6 000a00001445988043060f0021dcffff zynq> md5sum sfdp e43ab2dbcbcf99cebc74964c5dcf3ee2 sfdp zynq> mtd_debug info /dev/mtd0 mtd.type = MTD_NORFLASH mtd.flags = MTD_CAP_NORFLASH mtd.size = 33554432 (32M) mtd.erasesize = 4096 (4K) mtd.writesize = 1 mtd.oobsize = 0 regions = 0 zynq> cat jedec_id c28639 zynq> cat manufacturer macronix zynq> cat partname mx25lw25645g zynq> xxd -p sfdp 53464450080104fd00070114400000ff8701011c900000ff0a0001080001 00ff05000105200100ff84000102340100ff0000000000000000ffffffff ffffffffe5208affffffff0f00ff00ff00ff00ffeeffffffffff00ffffff 00ff0c2010d800ff00ff897901008d1200d2cc04674630b030b0f4bdd55c 000000ff101000200000000000007ca34800000000006666000000000000 00400fd1fff30fd1fff300050090000500b1002b0095002b0096727103b8 727103b80000000090a3188200c069960000000000000000727100987271 00b8727100990000000072710098727100f872710099727100f900000000 00000000011501d0727106d8000086500000060100000000020001030002 00000000060100000000000072060002000000eec0697272717100d8f7f6 0000000014351c0043060f0021dcffff zynq> md5sum sfdp b5db9fe24f814b5cc6a392c4c56ed331 sfdp zynq> mtd_debug info /dev/mtd0 mtd.type = MTD_NORFLASH mtd.flags = MTD_CAP_NORFLASH mtd.size = 33554432 (32M) mtd.erasesize = 4096 (4K) mtd.writesize = 1 mtd.oobsize = 0 regions = 0 zynq> cat jedec_id c2843a zynq> cat manufacturer macronix zynq> cat partname mx25uw51345g zynq> xxd -p sfdp 53464450080104fd00070114400000ff8701011c900000ff0a0001080001 00ff05000105200100ff84000102340100ff0000000000000000ffffffff ffffffffe5208affffffff1f00ff00ff00ff00ffeeffffffffff00ffffff 00ff0c2010d800ff00ff8b7901008f1200e2cc04674630b030b0f4bdd55c 000000ff101000200000000000007c234800000000008888000000000000 00400fd1fff30fd1fff300050090000500b1002b0095002b0096727103b8 727103b80000000090a3188200c069960000000000000000727100987271 00b8727100990000000072710098727100f872710099727100f900000000 00000000011501d0727106d8000086500000060100000000020001030002 00000000060100000000000072060002000000eec0697272717100d8f7f6 000a00001445988043060f0021dcffff zynq> md5sum sfdp cdccbfad3c384e77f3a5f7847b57b148 sfdp zynq> mtd_debug info /dev/mtd0 mtd.type = MTD_NORFLASH mtd.flags = MTD_CAP_NORFLASH mtd.size = 67108864 (64M) mtd.erasesize = 4096 (4K) mtd.writesize = 1 mtd.oobsize = 0 regions = 0 zynq> cat jedec_id c2863a zynq> cat manufacturer macronix zynq> cat partname mx25lw51245g zynq> xxd -p sfdp 53464450080104fd00070114400000ff8701011c900000ff0a0001080001 00ff05000105200100ff84000102340100ff000000000000000000000000 00000000e5208affffffff1f00ff00ff00ff00ffeeffffffffff00ffffff 00ff0c2010d800ff00ff8b7901008f1200e2cc04674630b030b0f4bdd55c 000000ff101000200000000000007ca34800000000006666000000000000 00400fd1fff30fd1fff300050090000500b1002b0095002b0096727103b8 727103b80000000090a3188200c069960000000000000000727100987271 00b8727100990000000072710098727100f872710099727100f900000000 00000000011501d0727106d8000086500000060100000000020001030002 00000000060100000000000072060002000000eec0697272717100d8f7f6 0000000014351c0043060f0021dcffff zynq> md5sum sfdp bb32ccaca6814f3104b985ac91bd65ac sfdp zynq> mtd_debug info /dev/mtd0 mtd.type = MTD_NORFLASH mtd.flags = MTD_CAP_NORFLASH mtd.size = 67108864 (64M) mtd.erasesize = 4096 (4K) mtd.writesize = 1 mtd.oobsize = 0 regions = 0 zynq> cat jedec_id c2843b zynq> cat manufacturer macronix zynq> cat partname mx66uw1g345g zynq> xxd -p sfdp 53464450080104fd00070114400000ff8701011c900000ff0a0001080001 00ff05000105200100ff84000102340100ff0000000000000000ffffffff ffffffffe5208affffffff3f00ff00ff00ff00ffeeffffffffff00ffffff 00ff0c2010d800ff00ff8b7901008f1200e2cc04674630b030b0f4bdd55c 000000ff101000200000147c00007c234800000000008888000000000000 00400fd1fff30fd1fff300050090060500b1002b0095002b0096727103b8 727103b80000000090a3188200c069960000000000000000000000000000 0000000000000000000072710098727100f872710099727100f900000000 00000000011501d0727106d8000086500000060100000000020001030002 00000000060100000000000072060002000000eec0697272717100d8f7f6 000a00001445988043061f0021dcffff zynq> md5sum sfdp dd3ef0a8d22ee81fc5bccdcb67dee6ca sfdp zynq> mtd_debug info /dev/mtd0 mtd.type = MTD_NORFLASH mtd.flags = MTD_CAP_NORFLASH mtd.size = 134217728 (128M) mtd.erasesize = 4096 (4K) mtd.writesize = 1 mtd.oobsize = 0 regions = 0 zynq> cat jedec_id c2813b zynq> cat manufacturer macronix zynq> cat partname mx66uw1g45g zynq> xxd -p sfdp 53464450080104fd00070114400000ff8701011c900000ff0a0001080001 00ff05000105200100ff84000102340100ff0000000000000000ffffffff ffffffffe5208affffffff3f00ff00ff00ff00ffeeffffffffff00ffffff 00ff0c2010d800ff00ff8b7901008f1200e2cc04674630b030b0f4bdd55c 000000ff101000200000000000007ca34800000000008888000000000000 00400fd1fff30fd1fff300050090000500b1002b0095002b0096727103b8 727103b80000000090a3188200c069960000000000000000727100987271 00b8727100990000000072710098727100f872710099727100f900000000 00000000011501d0727106d8000086500000060100000000020001030002 00000000060100000000000072060002000000eec0697272717100d8f7f6 000a00001445988043060f0021dcffff zynq> md5sum sfdp b89a53266007fce06ba7cc4c0956f917 sfdp zynq> mtd_debug info /dev/mtd0 mtd.type = MTD_NORFLASH mtd.flags = MTD_CAP_NORFLASH mtd.size = 134217728 (128M) mtd.erasesize = 4096 (4K) mtd.writesize = 1 mtd.oobsize = 0 regions = 0 zynq> cat jedec_id c2843c zynq> cat manufacturer macronix zynq> cat partname mx66uw2g345g zynq> xxd -p sfdp 53464450080104fd00070114400000ff8701011c900000ff0a0001080001 00ff05000105200100ff84000102340100ff0000000000000000ffffffff ffffffffe5208affffffff7f00ff00ff00ff00ffeeffffffffff00ffffff 00ff0c2010d800ff00ff87790100841200e2cc04674630b030b0f4bdd55c 000000ff101000200000147c00007c234800000000007777000000000000 00400fd1fff30fd1fff300050090000500b1002b0095002b0096727103b8 727103b80000000090a3188200c069960000000000000000727100987271 00b8727100990000000072710098727100f872710099727100f900000000 00000000011501d0727106d8000086500000060100000000020001030002 00000000060100000000000072060002000000eec0697272717100d8f7f6 000000001445988043061f0021dcffff zynq> md5sum sfdp 00447475e039e67c256a8d75d5885ae8 sfdp zynq> mtd_debug info /dev/mtd0 mtd.type = MTD_NORFLASH mtd.flags = MTD_CAP_NORFLASH mtd.size = 268435456 (256M) mtd.erasesize = 4096 (4K) mtd.writesize = 1 mtd.oobsize = 0 regions = 0 zynq> cat jedec_id c2943c zynq> cat manufacturer macronix zynq> cat partname mx66uw2g345gx0 zynq> xxd -p sfdp 53464450080104fd00070114400000ff8701011c900000ff0a0001080001 00ff05000105200100ff84000102340100ff0000000000000000ffffffff ffffffffe5208affffffff7f00ff00ff00ff00ffeeffffffffff00ffffff 00ff0c2010d800ff00ff87790100841200e2cc04674630b030b0f4bdd55c 000000ff101000200000000000007c234800000000008888000000000000 00400fd1fff30fd1fff300050090000500b1002b0095002b0096727103b8 727103b80000000090a3188200c069960000000000000000727100987271 00b8727100990000000072710098727100f872710099727100f900000000 00000000011501d0727106d8000086500000060100000000020001030002 00000000060100000000000072060002000000eec0697272717100d8f7f6 000a00001445988043061f0021dcffff zynq> md5sum sfdp 839ad44d1e758bea30bd9917ba763ba6 sfdp zynq> mtd_debug info /dev/mtd0 mtd.type = MTD_NORFLASH mtd.flags = MTD_CAP_NORFLASH mtd.size = 268435456 (256M) mtd.erasesize = 4096 (4K) mtd.writesize = 1 mtd.oobsize = 0 regions = 0 Signed-off-by: JaimeLiao --- drivers/mtd/spi-nor/macronix.c | 52 ++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/drivers/mtd/spi-nor/macronix.c b/drivers/mtd/spi-nor/macronix.c index dee71776b1a8..29bd5f0b32ec 100644 --- a/drivers/mtd/spi-nor/macronix.c +++ b/drivers/mtd/spi-nor/macronix.c @@ -200,6 +200,58 @@ static const struct flash_info macronix_nor_parts[] = { .name = "mx25l3255e", .size = SZ_4M, .no_sfdp_flags = SECT_4K, + }, { + .id = SNOR_ID(0xc2, 0x84, 0x37), + .n_banks = 4, + .flags = SPI_NOR_RWW, + }, { + .id = SNOR_ID(0xc2, 0x81, 0x37), + .n_banks = 4, + .flags = SPI_NOR_RWW, + }, { + .id = SNOR_ID(0xc2, 0x84, 0x38), + .n_banks = 4, + .flags = SPI_NOR_RWW, + }, { + .id = SNOR_ID(0xc2, 0x81, 0x38), + .n_banks = 4, + .flags = SPI_NOR_RWW, + }, { + .id = SNOR_ID(0xc2, 0x84, 0x39), + .n_banks = 4, + .flags = SPI_NOR_RWW, + }, { + .id = SNOR_ID(0xc2, 0x81, 0x39), + .n_banks = 4, + .flags = SPI_NOR_RWW, + }, { + .id = SNOR_ID(0xc2, 0x86, 0x39), + .n_banks = 4, + .flags = SPI_NOR_RWW, + }, { + .id = SNOR_ID(0xc2, 0x84, 0x3a), + .n_banks = 4, + .flags = SPI_NOR_RWW, + }, { + .id = SNOR_ID(0xc2, 0x86, 0x3a), + .n_banks = 4, + .flags = SPI_NOR_RWW, + }, { + .id = SNOR_ID(0xc2, 0x84, 0x3b), + .n_banks = 4, + .flags = SPI_NOR_RWW, + }, { + .id = SNOR_ID(0xc2, 0x81, 0x3b), + .n_banks = 4, + .flags = SPI_NOR_RWW, + }, { + .id = SNOR_ID(0xc2, 0x84, 0x3c), + .n_banks = 4, + .flags = SPI_NOR_RWW, + }, { + .id = SNOR_ID(0xc2, 0x94, 0x3c), + .n_banks = 4, + .flags = SPI_NOR_RWW, } }; From patchwork Thu Nov 30 08:38:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: liao jaime X-Patchwork-Id: 1869992 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=BAgpjPoV; 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=Ddxvkk56; 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 4SgqPs1Xwxz24DQ for ; Thu, 30 Nov 2023 19:39:58 +1100 (AEDT) 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=H5jE4/jP0XfJXfwjHRwFkDEhIf4BWKX+A13bnLD+Nu4=; b=BAgpjPoVUwEUmt Hz5EMRJ0etkGHCtq7UlS/cpZpRAp95Hd5VMspE1FlWmUFsc5doBFM2Zjtdx/NUge+HNtrUD/0nXPL tXJvOuHEbPn01CH3R/AvYTdEsGJlmAKS/IMtrL9N8EovQgMzuiaLogmMuG770+obrkfGmmNN4sMbN zIeXAlkrrUgNZnd4rAMMqyaiCZQyLDp/lhYewplXoVaEE+8HMl3UEvCA3tIsi02rk46hvX912YOlM xfCDYhrJ4jcPhe+01KDMigCWphWn/4ZY3vYRv6m0dHuSAd3neQ48UigO8R9whiBga4/y9vt2lVfcV 9F8LM4EcMz+045HdPUfw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r8cZt-00AEYZ-0l; Thu, 30 Nov 2023 08:39:21 +0000 Received: from mail-oi1-x236.google.com ([2607:f8b0:4864:20::236]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r8cZk-00AESZ-2q for linux-mtd@lists.infradead.org; Thu, 30 Nov 2023 08:39:15 +0000 Received: by mail-oi1-x236.google.com with SMTP id 5614622812f47-3b898c9b4cbso363616b6e.2 for ; Thu, 30 Nov 2023 00:39:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701333550; x=1701938350; 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=FpstY/5jC1i/LN5PLekCWmoTqoQ8Q07qdfpUTFYBoWw=; b=Ddxvkk56fI4kPYfEML2OPX4YIFkYAU4FVZOj59Te8a6FuzOH4Lp1uFSeLiGNGjdyaA LwL5JLBtfcKocmsmp9LXb5Dse6wuW0vtYAAUXF1JIwcZ5wuAW4940MoziwnPylcIoCNj BfvEcZcc5xmP8teXac+wGMa9Gm2VeqJkRp7N18zg6zxBSo5KD668aOCrviWa8aK4LPNV yQ/xjy3NXzYeq8Z9xUHwoym+LATK8M1C3j1QtIPTaW41AoTg5scqEqXYEd9psHieOcpW L90UYZfBfNdmTyXDmboOk0e9rb5RcVKAyBpPfPGbLk/Il6pGooDTNdUu5l+r2kqe/ERm klKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701333550; x=1701938350; 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=FpstY/5jC1i/LN5PLekCWmoTqoQ8Q07qdfpUTFYBoWw=; b=Wdt8K4IBJ+uY2Ib/E4Nm7zxq71//xtod0CvqpyUMs+SHYtlGkkaYMFlCO6+7ve+K8S u64IkvxYfa1LsX0JFtXmPSmxvpJJjv8VD+8msJ58faVGfPPUSptYfYZ0SAp6S00/r+TF 2EHIM4QTQxxkbMvkk5isGrNiYoPG9bb1cKMAlNEtRyQ6/Lsh4YtVS8guiixDrvDh9Tnw 0SvKxQwkvO+KOUvS6FSk7567Swgf58SudM7k3UVX3UwDnITS+qb8aRKREQ/f3ouzubyF IRsrczAvPW+xULHjLy5/476N7ta0Uxrc7+KxtKj2uF0K5V5gMi++JZkVr4bL8/N8zUyt t3bQ== X-Gm-Message-State: AOJu0Yx8925qLDKmNShSN20ZNQ6JKQMVG8mTtpsATn37llY2VdjsWPJm rN5gzhm8koF2IvWHGX4l2wI= X-Google-Smtp-Source: AGHT+IEkiZ/m2NEzfGulRcxEQcxBZ9XTpM+6AaclWWAfue/eI6OhjW0S9GzN+CkJLImsqBjuiPZ5+A== X-Received: by 2002:a05:6808:1188:b0:3a9:bc8d:42ed with SMTP id j8-20020a056808118800b003a9bc8d42edmr22393451oil.43.1701333550613; Thu, 30 Nov 2023 00:39:10 -0800 (PST) Received: from twhmp6px (mxsmtp211.mxic.com.tw. [211.75.127.162]) by smtp.gmail.com with ESMTPSA id e13-20020a63f54d000000b005ab46970aaasm703421pgk.17.2023.11.30.00.39.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 00:39:10 -0800 (PST) Received: from hqs-appsw-appswa2.mp600.macronix.com (linux-patcher [172.17.236.35]) by twhmp6px (Postfix) with ESMTPS id A8E7D806B0; Thu, 30 Nov 2023 16:38:47 +0800 (CST) From: Jaime Liao To: linux-mtd@lists.infradead.org, tudor.ambarus@linaro.org, pratyush@kernel.org, michael@walle.cc, miquel.raynal@bootlin.com Cc: leoyu@mxic.com.tw, jaimeliao@mxic.com.tw Subject: [PATCH v6 7/7] mtd: spi-nor: add support for Macronix Octal flash Date: Thu, 30 Nov 2023 16:38:54 +0800 Message-Id: <20231130083854.55221-8-jaimeliao.tw@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231130083854.55221-1-jaimeliao.tw@gmail.com> References: <20231130083854.55221-1-jaimeliao.tw@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231130_003912_921871_21744496 X-CRM114-Status: UNSURE ( 9.96 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.2 (/) 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: JaimeLiao Adding Macronix Octal flash for Octal DTR support. The octaflash series can be divided into the following types: Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:236 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [jaimeliao.tw[at]gmail.com] -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 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 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: JaimeLiao Adding Macronix Octal flash for Octal DTR support. The octaflash series can be divided into the following types: MX25 series : Serial NOR Flash. MX66 series : Serial NOR Flash with stacked die.(Size larger than 1Gb) LM/UM series : Up to 250MHz clock frequency with both DTR/STR operation. LW/UW series : Support simultaneous Read-while-Write operation in multiple bank architecture. Read-while-write feature which means read data one bank while another bank is programing or erasing. MX25LM : 3.0V Octal I/O -https://www.mxic.com.tw/Lists/Datasheet/Attachments/8729/MX25LM51245G,%203V,%20512Mb,%20v1.1.pdf MX25UM : 1.8V Octal I/O -https://www.mxic.com.tw/Lists/Datasheet/Attachments/8967/MX25UM51245G,%201.8V,%20512Mb,%20v1.5.pdf MX66LM : 3.0V Octal I/O with stacked die -https://www.mxic.com.tw/Lists/Datasheet/Attachments/8748/MX66LM1G45G,%203V,%201Gb,%20v1.1.pdf MX66UM : 1.8V Octal I/O with stacked die -https://www.mxic.com.tw/Lists/Datasheet/Attachments/8711/MX66UM1G45G,%201.8V,%201Gb,%20v1.1.pdf MX25LW : 3.0V Octal I/O with Read-while-Write MX25UW : 1.8V Octal I/O with Read-while-Write MX66LW : 3.0V Octal I/O with Read-while-Write and stack die MX66UW : 1.8V Octal I/O with Read-while-Write and stack die As below are the SFDP table dump. zynq> cat jedec_id c28339 zynq> cat manufacturer macronix zynq> cat partname mx25um25345g zynq> xxd -p sfdp 53464450080104fd00070114400000ff8701011c900000ff0a0001080001 00ff05000105200100ff84000102340100ff0000000000000000ffffffff ffffffffe5208affffffff0f00ff00ff00ff00ffeeffffffffff00ffffff 00ff0c2010d800ff00ff87690100821200d2cc02673830b030b0f4bdd55c 000000ff101000200000000000007c234800000000008888000000000000 00400fd1fff30fd1fff300050090000500b1002b0095002b0096727103b8 727103b80000000090a3188200c069960000000000000000727100987271 00b8727100990000000072710098727100f872710099727100f900000000 00000000011501d0727106d8000086500000060100000000020001030002 00000000060100000000000072060002000000eec0697272717100d8f7f6 040900001445988043060f0021dcffff zynq> md5sum sfdp 950e623745a002e1747008592e6dbdf9 sfdp zynq> mtd_debug info /dev/mtd0 mtd.type = MTD_NORFLASH mtd.flags = MTD_CAP_NORFLASH mtd.size = 33554432 (32M) mtd.erasesize = 4096 (4K) mtd.writesize = 1 mtd.oobsize = 0 regions = 0 zynq> cat jedec_id c28039 zynq> cat manufacturer macronix zynq> cat partname mx25um25645g zynq> xxd -p sfdp 53464450080104fd00070114400000ff8701011c900000ff0a0001080001 00ff05000105200100ff84000102340100ff0000000000000000ffffffff ffffffffe5208affffffff0f00ff00ff00ff00ffeeffffffffff00ffffff 00ff0c2010d800ff00ff87790100841200d2cc02673830b030b0f4bdd55c 000000ff101000200000000000007ca34800000000008888000000000000 00400fd1fff30fd1fff300050090000500b1002b0095002b0096727103b8 727103b80000000090a3188200c069960000000000000000727100987271 00b8727100990000000072710098727100f872710099727100f900000000 00000000011501d0727106d8000086500000060100000000020001030002 00000000060100000000000072060002000000eec0697272717100d8f7f6 000a000014359c8043060f0021dcffff zynq> md5sum sfdp d652779f17770dc833cd96262cb2a620 sfdp zynq> mtd_debug info /dev/mtd0 mtd.type = MTD_NORFLASH mtd.flags = MTD_CAP_NORFLASH mtd.size = 33554432 (32M) mtd.erasesize = 4096 (4K) mtd.writesize = 1 mtd.oobsize = 0 regions = 0 zynq> cat jedec_id c28539 zynq> cat manufacturer macronix zynq> cat partname mx25lm25645g zynq> xxd -p sfdp 53464450080104fd00070114400000ff8701011c900000ff0a0001080001 00ff05000105200100ff84000102340100ff0000000000000000ffffffff ffffffffe5208affffffff0f00ff00ff00ff00ffeeffffffffff00ffffff 00ff0c2010d800ff00ff87690100821200d2cc02673830b030b0f4bdd55c 000000ff101000200000000000007ca34800000000006666000000000000 00400fd1fff30fd1fff300050090000500b1002b0095002b0096727103b8 727103b80000000090a3188200c069960000000000000000727100987271 00b8727100990000000072710098727100f872710099727100f900000000 00000000011501d0727106d8000086500000060100000000020001030002 00000000060100000000000072060002000000eec0697272717100d8f7f6 0000000014351c0043060f0021dcffff zynq> md5sum sfdp ec258f831ac737454c7eb9f6a8a4495a sfdp zynq> mtd_debug info /dev/mtd0 mtd.type = MTD_NORFLASH mtd.flags = MTD_CAP_NORFLASH mtd.size = 33554432 (32M) mtd.erasesize = 4096 (4K) mtd.writesize = 1 mtd.oobsize = 0 regions = 0 zynq> cat jedec_id c2803a zynq> cat manufacturer macronix zynq> cat partname mx25um51245g zynq> xxd -p sfdp 53464450080104fd00070114400000ff8701011c900000ff0a0001080001 00ff05000105200100ff84000102340100ff0000000000000000ffffffff ffffffffe5208affffffff1f00ff00ff00ff00ffeeffffffffff00ffffff 00ff0c2010d800ff00ff8b7901008f1200e2cc04674630b030b0f4bdd55c 000000ff101000200000000000007ca34800000000008888000000000000 00400fd1fff30fd1fff300050090000500b1002b0095002b0096727103b8 727103b80000000090a3188200c069960000000000000000727100987271 00b8727100990000000072710098727100f872710099727100f900000000 00000000011501d0727106d8000086500000060100000000020001030002 00000000060100000000000072060002000000eec0697272717100d8f7f6 000a000014359c8043060f0021dcffff zynq> md5sum sfdp 75d81c1eb2fd2767634f1d0dfbb3be35 sfdp zynq> mtd_debug info /dev/mtd0 mtd.type = MTD_NORFLASH mtd.flags = MTD_CAP_NORFLASH mtd.size = 67108864 (64M) mtd.erasesize = 4096 (4K) mtd.writesize = 1 mtd.oobsize = 0 regions = 0 zynq> cat jedec_id c2853a zynq> cat manufacturer macronix zynq> cat partname mx25lm51245g zynq> xxd -p sfdp 53464450080104fd00070114400000ff8701011c900000ff0a0001080001 00ff05000105200100ff84000102340100ff0000000000000000ffffffff ffffffffe5208affffffff1f00ff00ff00ff00ffeeffffffffff00ffffff 00ff0c2010d800ff00ff897901008d1200e2cc02674430b030b0f4bdd55c 000000ff101000200000000000007ca34800000000006666000000000000 00400fd1fff30fd1fff300050090000500b1002b0095002b0096727103b8 727103b80000000090a3188200c069960000000000000000727100987271 00b8727100990000000072710098727100f872710099727100f900000000 00000000011501d0727106d8000086500000060100000000020001030002 00000000060100000000000072060002000000eec0697272717100d8f7f6 0000000014351c0043060f0021dcffff zynq> md5sum sfdp 214868617d74e6bfb2c45444d5d6fff0 sfdp zynq> mtd_debug info /dev/mtd0 mtd.type = MTD_NORFLASH mtd.flags = MTD_CAP_NORFLASH mtd.size = 67108864 (64M) mtd.erasesize = 4096 (4K) mtd.writesize = 1 mtd.oobsize = 0 regions = 0 zynq> cat jedec_id c2803b zynq> cat manufacturer macronix zynq> cat partname mx66um1g45g zynq> xxd -p sfdp 53464450080104fd00070114400000ff8701011c900000ff0a0001080001 00ff05000105200100ff84000102340100ff0000000000000000ffffffff ffffffffe5208affffffff3f00ff00ff00ff00ffeeffffffffff00ffffff 00ff0c2010d800ff00ff897901008d1200e2cc02674430b030b0f4bdd55c 000000ff101000200000000000007ca34800000000008888000000000000 00400fd1fff30fd1fff300050090000500b1002b0095002b0096727103b8 727103b80000000090a3188200c069960000000000000000727100987271 00b8727100990000000072710098727100f872710099727100f900000000 00000000011501d0727106d8000086500000060100000000020001030002 00000000060100000000000072060002000000eec0697272717100d8f7f6 000a000014359c8043060f0021dcffff zynq> md5sum sfdp eea09d64679e64f627402b39a177e356 sfdp zynq> mtd_debug info /dev/mtd0 mtd.type = MTD_NORFLASH mtd.flags = MTD_CAP_NORFLASH mtd.size = 134217728 (128M) mtd.erasesize = 4096 (4K) mtd.writesize = 1 mtd.oobsize = 0 regions = 0 zynq> cat jedec_id c2853b zynq> cat manufacturer macronix zynq> cat partname mx66lm1g45g zynq> xxd -p sfdp 53464450080104fd00070114400000ff8701011c900000ff0a0001080001 00ff05000105200100ff84000102340100ff0000000000000000ffffffff ffffffffe5208affffffff3f00ff00ff00ff00ffeeffffffffff00ffffff 00ff0c2010d800ff00ff87690100821200e2cc02673830b030b0f4bdd55c 000000ff101000200000000000007ca34800000000006666000000000000 00400fd1fff30fd1fff300050090000500b1002b0095002b0096727103b8 727103b80000000090a3188200c069960000000000000000727100987271 00b8727100990000000072710098727100f872710099727100f900000000 00000000011501d0727106d8000086500000060100000000020001030002 00000000060100000000000072060002000000eec0697272717100d8f7f6 0000000014351c0043060f0021dcffff zynq> md5sum sfdp 7b46113b529d58a6335531a10f14a76e sfdp zynq> mtd_debug info /dev/mtd0 mtd.type = MTD_NORFLASH mtd.flags = MTD_CAP_NORFLASH mtd.size = 134217728 (128M) mtd.erasesize = 4096 (4K) mtd.writesize = 1 mtd.oobsize = 0 regions = 0 Signed-off-by: JaimeLiao --- drivers/mtd/spi-nor/macronix.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/mtd/spi-nor/macronix.c b/drivers/mtd/spi-nor/macronix.c index 29bd5f0b32ec..04d4ed6c1245 100644 --- a/drivers/mtd/spi-nor/macronix.c +++ b/drivers/mtd/spi-nor/macronix.c @@ -252,6 +252,20 @@ static const struct flash_info macronix_nor_parts[] = { .id = SNOR_ID(0xc2, 0x94, 0x3c), .n_banks = 4, .flags = SPI_NOR_RWW, + }, { + .id = SNOR_ID(0xc2, 0x83, 0x39), + }, { + .id = SNOR_ID(0xc2, 0x80, 0x39), + }, { + .id = SNOR_ID(0xc2, 0x85, 0x39), + }, { + .id = SNOR_ID(0xc2, 0x80, 0x3a), + }, { + .id = SNOR_ID(0xc2, 0x85, 0x3a), + }, { + .id = SNOR_ID(0xc2, 0x80, 0x3b), + }, { + .id = SNOR_ID(0xc2, 0x85, 0x3b), } };