From nobody Mon Jun 8 16:30:31 2026 Received: from mail-pj1-f53.google.com (mail-pj1-f53.google.com [209.85.216.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4B0DF31618C for ; Thu, 28 May 2026 05:20:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779945628; cv=none; b=dRRO5noNFws3Cgm827XqzKLWZ+l6fodUMip8C32Xk5muzA/qim6Dq+bHhDZrK7krXUYVJRk57wVfSBUC35XSZDKJ59Furjl1TR96eoTNYHEb9VuBcBvcS6zcs0BaXImYBeXJaPt0nl+WyDLKQQ3u51kbf+qO5+2TvIC62iv9V8A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779945628; c=relaxed/simple; bh=V63E64kPCX4S4EOlLC6momdwT/1Cvvi7FPEAASxR2Qc=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=MBZNwlc5RbiDjxySYuKAEEXeMbEK1Y+ukdYI+qq0/fVGVJjUx5B/zSE3nEOpRZQ0iNNJu73CGME3viwlAxPAloVE55FOrVZyHlUDDDn1UVesizXwaRQKPIqdikpR3N1MsEps5pNfiGTfo/kUtclu8/R18ahg39JhCH2gS5b9ruA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=cABM9frD; arc=none smtp.client-ip=209.85.216.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="cABM9frD" Received: by mail-pj1-f53.google.com with SMTP id 98e67ed59e1d1-369002b26f4so7302041a91.3 for ; Wed, 27 May 2026 22:20:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1779945625; x=1780550425; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=ZjGtLzO2HanIiK43HgLOPftGVf4OR0HNAd0NSMfxuBo=; b=cABM9frDZ4yYzZqMB1hMbN3PF0m5axLFKQMtKNDR1Yj/sQLrUEfDvJmRy4WIw4rV1F BD7BYNPbylqRbVkLFTE34BtRyJAjOBG5jGtKDggydo5war3IACPhFFi3roH6fmR4ptB+ HAt3OeBdfsgrsfRiKT9DzUna7KGhDja5srCOtL8/x3uPkq/W/tH6w8clm32wm0nePeXF MFXuPJjrmt1AVcPEeMSnBPW88wM7wGatMHIAelSo66vybFqxY4P2CNz3/9rPyr+s+O3L zU9/Dht2yWFPppAFFLYljYTTfw+dwE1cSHgt2+fHqwwiO7Qb6oyKgAXh0qwtJTaMggtF VjyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779945625; x=1780550425; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=ZjGtLzO2HanIiK43HgLOPftGVf4OR0HNAd0NSMfxuBo=; b=Huaoftlgs914CIDR0tarzrTbKmCfFVBc6MzkftVF2/q1WHoJ5o3UbLfsxiky2R6YgS Jbqz3PWtctgy4uy1EZ/OmpCRQjUhpzu31f+NbnVTDdp3+a4x+vnT62R6BR8U8ApO4e/v MotFdfdZiOO2q1xryThVyc0YecqxMF0VMpQdk6/P37MqT7DcHSTQ/B8YVVxqIJ1TdRV8 DDmGs6M8MY0zo+/5H/O+oGtIZHkI6s65qdMdcmwygMON8VP3scgcKBAfiFepp8MA4CiQ oktjpzgiiseeXHIAiE+ZSfX//2mEJbq3Sxbww5bNZowEx5hW+83DM13Ab/jcnDh1w1ci SuuQ== X-Forwarded-Encrypted: i=1; AFNElJ/mVFEJKXW0gTRsDEmZEPe8zkmGF5H7mbwleAvIl3vR1qubWSFZ402Idmacj2WotSD3vRtVLWU0vOjyyUA=@vger.kernel.org X-Gm-Message-State: AOJu0YyMAju5spUlDpQOJzjjPVsiTxpm2GxBX8/8DRUybhj+wmF3d62j 6THEWEFZuEFOcNBXOyMaqTazsS2EvTUBY75t6DXNpg9MjYK67FWYzYWg X-Gm-Gg: Acq92OFT2qMftoBOyGz219yhBYzgTJdMsMdJPFfqxLDE5JGkbhI5ba2KRqpbFrHiS8o 98w0GeknnB9ITPw5+JqOHMhQjMgGoTrE+v6MWzsxAfCc8GOonIU3rnCnyUrqbyAGcjQxN7gR//T keCQYnV9RtMsolL2ufYzzYdPn3mQIPNxDSqpNKYU3NA5GlIM+eYziv+6qwupuF3fvm3M92fjHbI 6jQrquhFjwGw/5imLLuRR+uu96xKg67FzdpeQNCzcSu0DOmVb57O0uiOvvB0q3WE0p0ne5oXt6H 4pa9FJ+a73dUbS6INSeHedkevoAHavTKZXB0XO+koBmmXoFJc3KaU6yDfnP4S9ZxgPEQkLtoL78 8Z3aoWicCIEc0AQeWPG9kkYUrEBNMFK6u/GxdPndJYg2fWrncgQlNSjH4cHL5Dwp8g+fmfWn7Hx uZxgx4kFWkLvHrNUW1oqpFHN8fXPOUmBbemSy9/8fg2WU05Gal5DlOHOpf X-Received: by 2002:a17:90b:2b4e:b0:35f:d56d:1c45 with SMTP id 98e67ed59e1d1-36a6772ff38mr27327004a91.12.1779945625363; Wed, 27 May 2026 22:20:25 -0700 (PDT) Received: from twhmp6px (mxsmtp211.mxic.com.tw. [211.75.127.162]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-36b9096dc30sm581434a91.17.2026.05.27.22.20.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 May 2026 22:20:16 -0700 (PDT) Received: from hqs-appsw-a2o.mp600.macronix.com (unknown [172.17.236.67]) by twhmp6px (Postfix) with ESMTPS id 2708D4163B6F; Thu, 28 May 2026 13:20:14 +0800 (CST) From: Cheng Ming Lin To: Pratyush Yadav , Michael Walle , Takahiro Kuwano , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra Cc: linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org, alvinzhou@mxic.com.tw, Cheng Ming Lin Subject: [PATCH] mtd: spi-nor: Add support for MX25L12833F and MX25L12845G Date: Thu, 28 May 2026 13:17:51 +0800 Message-Id: <20260528051751.1648246-1-linchengming884@gmail.com> X-Mailer: git-send-email 2.25.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Cheng Ming Lin Add support for Macronix MX25L12833F and MX25L12845G. The SFDP tables for these flashes only declare 1-4-4 Page Program support in 4-byte address mode. However, since these parts operate in 3-byte address mode, the standard SFDP parsing does not automatically enable this capability. To address this, this patch introduces macronix_4pp3b_late_init_fixups() to explicitly enable the 1-4-4 Page Program. Signed-off-by: Cheng Ming Lin --- - mx25l12833f zynq> cat /sys/bus/spi/devices/spi0.0/spi-nor/jedec_id=20 c22018 zynq> cat /sys/bus/spi/devices/spi0.0/spi-nor/manufacturer=20 macronix zynq> xxd -p /sys/bus/spi/devices/spi0.0/spi-nor/sfdp 53464450060102ff00060110300000ffc2000104100100ff84000102c000 00ffffffffffffffffffffffffffffffffffe520f1ffffffff0744eb086b 083b04bbfeffffffffff00ffffff44eb0c200f5210d800ff8241bd0081e5 7bc64403673830b030b0f7bdd55c4abe29ffe1d0ffffffffffffffffffff ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ffffffffffffffffffffffff0000ffffffffffffffffffffffffffffffff ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ffff003600279df9c06485cbffffffffffff zynq> sha256sum /sys/bus/spi/devices/spi0.0/spi-nor/sfdp=20 c7c4287a584fa23f4f5037a90ab0ee6ddc6ff3f0cee89889e54465e86542c85e /sys/bus/= spi/devices/spi0.0/spi-nor/sfdp zynq> cat /sys/kernel/debug/spi-nor/spi0.0/capabilities=20 Supported read modes by the flash 1S-1S-1S opcode 0x03 mode cycles 0 dummy cycles 0 1S-1S-2S opcode 0x3b mode cycles 0 dummy cycles 8 1S-2S-2S opcode 0xbb mode cycles 0 dummy cycles 4 1S-1S-4S opcode 0x6b mode cycles 0 dummy cycles 8 1S-4S-4S opcode 0xeb mode cycles 2 dummy cycles 4 4S-4S-4S opcode 0xeb mode cycles 2 dummy cycles 4 Supported page program modes by the flash 1S-1S-1S opcode 0x02 1S-4S-4S opcode 0x38 zynq> cat /sys/kernel/debug/spi-nor/spi0.0/params=20 name (null) id c2 20 18 c2 20 18 size 16.0 MiB write size 1 page size 256 address nbytes 3 flags HAS_LOCK | HAS_4BIT_BP | SOFT_RESET opcodes read 0xeb dummy cycles 6 erase 0xd8 program 0x38 8D extension none protocols read 1S-4S-4S write 1S-4S-4S register 1S-1S-1S erase commands 20 (4.00 KiB) [1] 52 (32.0 KiB) [2] d8 (64.0 KiB) [3] c7 (16.0 MiB) sector map region (in hex) | erase mask | overlaid ------------------+------------+---------- 00000000-00ffffff | [ 3] | no zynq> dd if=3D/dev/urandom of=3D/tmp/spi_test bs=3D1M count=3D2 2+0 records in 2+0 records out 2097152 bytes (2.0MB) copied, 0.085447 seconds, 23.4MB/s zynq> mtd_debug erase /dev/mtd0 0 2097152 Erased 2097152 bytes from address 0x00000000 in flash zynq> mtd_debug read /dev/mtd0 0 2097152 /tmp/spi_read Copied 2097152 bytes from address 0x00000000 in flash to /tmp/spi_read zynq> hexdump /tmp/spi_read=20 0000000 ffff ffff ffff ffff ffff ffff ffff ffff * 0200000 zynq> sha256sum /tmp/spi_read=20 4bda3a28f4ffe603c0ec1258c0034d65a1a0d35ab7bd523a834608adabf03cc5 /tmp/spi_= read zynq> mtd_debug write /dev/mtd0 0 2097152 /tmp/spi_test Copied 2097152 bytes from /tmp/spi_test to address 0x00000000 in flash zynq> mtd_debug read /dev/mtd0 0 2097152 /tmp/spi_read Copied 2097152 bytes from address 0x00000000 in flash to /tmp/spi_read zynq> sha256sum /tmp/spi* 847f8009f10c04d3664098f210f5eb5a54cf9e08bd24dbdb1a983c56e3f89256 /tmp/spi_= read 847f8009f10c04d3664098f210f5eb5a54cf9e08bd24dbdb1a983c56e3f89256 /tmp/spi_= test zynq> mtd_debug erase /dev/mtd0 0 2097152 Erased 2097152 bytes from address 0x00000000 in flash zynq> mtd_debug read /dev/mtd0 0 2097152 /tmp/spi_read Copied 2097152 bytes from address 0x00000000 in flash to /tmp/spi_read zynq> sha256sum /tmp/spi* 4bda3a28f4ffe603c0ec1258c0034d65a1a0d35ab7bd523a834608adabf03cc5 /tmp/spi_= read 847f8009f10c04d3664098f210f5eb5a54cf9e08bd24dbdb1a983c56e3f89256 /tmp/spi_= test zynq> mtd_debug info /dev/mtd0 mtd.type =3D MTD_NORFLASH mtd.flags =3D MTD_CAP_NORFLASH mtd.size =3D 16777216 (16M) mtd.erasesize =3D 65536 (64K) mtd.writesize =3D 1=20 mtd.oobsize =3D 0=20 regions =3D 0 - mx25l12845g zynq> cat /sys/bus/spi/devices/spi0.0/spi-nor/jedec_id=20 c22018 zynq> cat /sys/bus/spi/devices/spi0.0/spi-nor/manufacturer=20 macronix zynq> xxd -p /sys/bus/spi/devices/spi0.0/spi-nor/sfdp 53464450060102ff00060110300000ffc2000104100100ff84000102c000 00ffffffffffffffffffffffffffffffffffe520f9ffffffff0744eb086b 083b04bbfeffffffffff00ffffff44eb0c200f5210d800ffd659dd00829f 03cd4403673830b030b0f7bdd55c4abe29fff0d0ffffffffffffffffffff ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ffffffffffffffffffffffff0000ffffffffffffffffffffffffffffffff ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ffff003600279df9c06485cbffffffffffff zynq> sha256sum /sys/bus/spi/devices/spi0.0/spi-nor/sfdp=20 b8b7ec394194bb45effdfa2cd4de23f6a7d05a16ff44a23f86e6d10bc9a83375 /sys/bus/= spi/devices/spi0.0/spi-nor/sfdp zynq> cat /sys/kernel/debug/spi-nor/spi0.0/capabilities=20 Supported read modes by the flash 1S-1S-1S opcode 0x03 mode cycles 0 dummy cycles 0 1S-1S-2S opcode 0x3b mode cycles 0 dummy cycles 8 1S-2S-2S opcode 0xbb mode cycles 0 dummy cycles 4 1S-1S-4S opcode 0x6b mode cycles 0 dummy cycles 8 1S-4S-4S opcode 0xeb mode cycles 2 dummy cycles 4 4S-4S-4S opcode 0xeb mode cycles 2 dummy cycles 4 Supported page program modes by the flash 1S-1S-1S opcode 0x02 1S-4S-4S opcode 0x38 zynq> cat /sys/kernel/debug/spi-nor/spi0.0/params name (null) id c2 20 18 c2 20 18 size 16.0 MiB write size 1 page size 256 address nbytes 3 flags HAS_LOCK | HAS_4BIT_BP | SOFT_RESET opcodes read 0xeb dummy cycles 6 erase 0xd8 program 0x38 8D extension none protocols read 1S-4S-4S write 1S-4S-4S register 1S-1S-1S erase commands 20 (4.00 KiB) [1] 52 (32.0 KiB) [2] d8 (64.0 KiB) [3] c7 (16.0 MiB) sector map region (in hex) | erase mask | overlaid ------------------+------------+---------- 00000000-00ffffff | [ 3] | no zynq> dd if=3D/dev/urandom of=3D/tmp/spi_test bs=3D1M count=3D2 2+0 records in 2+0 records out 2097152 bytes (2.0MB) copied, 0.083618 seconds, 23.9MB/s zynq> mtd_debug erase /dev/mtd0 0 2097152 Erased 2097152 bytes from address 0x00000000 in flash zynq> mtd_debug read /dev/mtd0 0 2097152 /tmp/spi_read Copied 2097152 bytes from address 0x00000000 in flash to /tmp/spi_read zynq> hexdump /tmp/spi_read=20 0000000 ffff ffff ffff ffff ffff ffff ffff ffff * 0200000 zynq> sha256sum /tmp/spi_read 4bda3a28f4ffe603c0ec1258c0034d65a1a0d35ab7bd523a834608adabf03cc5 /tmp/spi_= read zynq> mtd_debug write /dev/mtd0 0 2097152 /tmp/spi_test Copied 2097152 bytes from /tmp/spi_test to address 0x00000000 in flash zynq> mtd_debug read /dev/mtd0 0 2097152 /tmp/spi_read Copied 2097152 bytes from address 0x00000000 in flash to /tmp/spi_read zynq> sha256sum /tmp/spi* ec344b7d2b0022ee54bf94de71b889e5fd3087a5487dcee789e0a0b056bfc6ae /tmp/spi_= read ec344b7d2b0022ee54bf94de71b889e5fd3087a5487dcee789e0a0b056bfc6ae /tmp/spi_= test zynq> mtd_debug erase /dev/mtd0 0 2097152 Erased 2097152 bytes from address 0x00000000 in flash zynq> mtd_debug read /dev/mtd0 0 2097152 /tmp/spi_read Copied 2097152 bytes from address 0x00000000 in flash to /tmp/spi_read zynq> sha256sum /tmp/spi* 4bda3a28f4ffe603c0ec1258c0034d65a1a0d35ab7bd523a834608adabf03cc5 /tmp/spi_= read ec344b7d2b0022ee54bf94de71b889e5fd3087a5487dcee789e0a0b056bfc6ae /tmp/spi_= test zynq> mtd_debug info /dev/mtd0 mtd.type =3D MTD_NORFLASH mtd.flags =3D MTD_CAP_NORFLASH mtd.size =3D 16777216 (16M) mtd.erasesize =3D 65536 (64K) mtd.writesize =3D 1=20 mtd.oobsize =3D 0=20 regions =3D 0 drivers/mtd/spi-nor/macronix.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/drivers/mtd/spi-nor/macronix.c b/drivers/mtd/spi-nor/macronix.c index e97f5cbd9..e91808ad1 100644 --- a/drivers/mtd/spi-nor/macronix.c +++ b/drivers/mtd/spi-nor/macronix.c @@ -83,6 +83,18 @@ mx25l3255e_late_init_fixups(struct spi_nor *nor) return 0; } =20 +static int +macronix_4pp3b_late_init_fixups(struct spi_nor *nor) +{ + struct spi_nor_flash_parameter *params =3D nor->params; + + params->hwcaps.mask |=3D SNOR_HWCAPS_PP_1_4_4; + spi_nor_set_pp_settings(¶ms->page_programs[SNOR_CMD_PP_1_4_4], + SPINOR_OP_PP_1_4_4, SNOR_PROTO_1_4_4); + + return 0; +} + static const struct spi_nor_fixups mx25l25635_fixups =3D { .post_bfpt =3D mx25l25635_post_bfpt_fixups, .post_sfdp =3D macronix_qpp4b_post_sfdp_fixups, @@ -96,6 +108,10 @@ static const struct spi_nor_fixups mx25l3255e_fixups = =3D { .late_init =3D mx25l3255e_late_init_fixups, }; =20 +static const struct spi_nor_fixups macronix_4pp3b_fixups =3D { + .late_init =3D macronix_4pp3b_late_init_fixups, +}; + static const struct flash_info macronix_nor_parts[] =3D { { .id =3D SNOR_ID(0xc2, 0x20, 0x10), @@ -130,9 +146,10 @@ static const struct flash_info macronix_nor_parts[] = =3D { .size =3D SZ_8M, .no_sfdp_flags =3D SECT_4K, }, { - /* MX25L12805D */ + /* MX25L12805D, MX25L12833F, MX25L12845G */ .id =3D SNOR_ID(0xc2, 0x20, 0x18), .flags =3D SPI_NOR_HAS_LOCK | SPI_NOR_4BIT_BP, + .fixups =3D ¯onix_4pp3b_fixups, }, { /* MX25L25635E, MX25L25645G */ .id =3D SNOR_ID(0xc2, 0x20, 0x19), --=20 2.25.1