Skip to contentSkip to conversation

mtd: hyperbus: Add support for Infineon S26Hx-T

PATCH In review [email protected] 4 participants 16 messages Apr 7, 2023 – Feb 1, 2024

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover mtd: hyperbus: Add support for Infineon S26Hx-T

From: Takahiro Kuwano <[email protected]>

This sereis adds support for Infineon S26HL-T/S26HS-T flash family.
https://www.infineon.com/dgdl/Infineon-S26HS01GTGABHM020-DataSheet-v01_00-EN.pdf?fileId=8ac78c8c7f2a768a017f52f2f5182c91

This family supports two interface modes, SPI mode and Hyperbus mode. The mode can be switched at rutime. The default mode is selected by ordering option and non-volatile user configuration. In hyperbus mode, the device is compatible with S26KL-S/S26KS-S hyperflash family that supports hyperbus only so one of use cases of S26Hx-T is replacement of (or migration from) S26Kx-S. This patch set focuses on particular usage that the device is pre-configured as hyperbus mode for compatibility with S26Kx-S.

Runtime mode switch between SPI and Hyperbus may be added as needed basis with spi-mem framework and controller support.

Takahiro Kuwano (2):
mtd: hyperbus: Introduce SFDP probe
mtd: chips: cfi_cmdset0002: Fixups for Infineon(Cypress) S26Hx

 drivers/mtd/chips/cfi_cmdset_0002.c  |  25 ++
 drivers/mtd/hyperbus/Makefile        |   4 +-
 drivers/mtd/hyperbus/hyperbus-core.c |  15 +-
 drivers/mtd/hyperbus/hyperbus-sfdp.c | 346 +++++++++++++++++++++++++++
 include/linux/mtd/cfi.h              |   1 +
 5 files changed, 389 insertions(+), 2 deletions(-)
 create mode 100644 drivers/mtd/hyperbus/hyperbus-sfdp.c
Signature · 6 lines
2.34.1


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
#1 lore raw

PATCH 1/2 mtd: hyperbus: Introduce SFDP probe

From: Takahiro Kuwano <[email protected]>

Infineon(Cypress) S26HL-T/S26HS-T family of flash devices support both legacy SPI mode and HyperBus (JESD251C xSPI profile 2.0) mode. In HyperBus mode, it is compatible with Cypress S26KL-S/S26KS-S HyperFlash family with some exceptions. One significant difference is that the CFI is replaced by SFDP. This patch intends to support Hyperbus devices that has SFDP instead of CFI, by adding new probing method that detects SFDP signature and setting up CFI structure to make SFDP chips work with cfi_cmdset_xxxx.

The probe flow implemented in hyperbus_sfdp_probe_chip() is same as cfi_probe_chip() in chips/cfi_probe.c. The CFI "QRY" detection is replaced by "SFDP" signature detection.

Device identification and setup functions specific for S26Hx-T are also implemented in the same source file as SFDP probe and called from probe function. Once other devices that supports SFDP come up, we will implemet generic detection and setup flow.

---
 drivers/mtd/hyperbus/Makefile        |   4 +-
 drivers/mtd/hyperbus/hyperbus-core.c |  15 +-
 drivers/mtd/hyperbus/hyperbus-sfdp.c | 346 +++++++++++++++++++++++++++
 3 files changed, 363 insertions(+), 2 deletions(-)
 create mode 100644 drivers/mtd/hyperbus/hyperbus-sfdp.c
drivers/mtd/hyperbus/Makefile +3 -1
index 26386158bd1c..03132bc05853 100644
@@ -1,9 +1,11 @@
 # SPDX-License-Identifier: GPL-2.0
 
-obj-$(CONFIG_MTD_HYPERBUS)	+= hyperbus-core.o
+obj-$(CONFIG_MTD_HYPERBUS)	+= hyperbus.o
 obj-$(CONFIG_HBMC_AM654)	+= hbmc-am654.o
 obj-$(CONFIG_RPCIF_HYPERBUS)	+= rpc-if.o
 
+hyperbus-objs	:= hyperbus-core.o hyperbus-sfdp.o
+
 
 
 obj-y += ifx-hyperbus.o
drivers/mtd/hyperbus/hyperbus-core.c +14 -1
index 4d8047d43e48..b31a8bea3995 100644
@@ -12,6 +12,19 @@
 #include <linux/of.h>
 #include <linux/types.h>
 
+struct mtd_info *hyperbus_sfdp_probe(struct map_info *map);
+
+static struct mtd_info *hyperbus_map_probe(struct map_info *map)
+{
+	struct mtd_info *mtd;
+
+	mtd = do_map_probe("cfi_probe", map);
+	if (!mtd)
+		mtd = hyperbus_sfdp_probe(map);
+
+	return mtd;
+}
+
 static struct hyperbus_device *map_to_hbdev(struct map_info *map)
 {
 	return container_of(map, struct hyperbus_device, map);
@@ -106,7 +119,7 @@ int hyperbus_register_device(struct hyperbus_device *hbdev)
 		}
 	}
 
-	hbdev->mtd = do_map_probe("cfi_probe", map);
+	hbdev->mtd = hyperbus_map_probe(map);
 	if (!hbdev->mtd) {
 		dev_err(dev, "probing of hyperbus device failed\n");
 		return -ENODEV;
drivers/mtd/hyperbus/hyperbus-sfdp.c new file +346 -0

346 lines not on this page · raw message

Signature · 6 lines
2.34.1


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
reviewer
#2 lore raw

Re: [PATCH 1/2] mtd: hyperbus: Introduce SFDP probe

Hi, Takahiro!

Quoted 11 lines · On 07.04.2023 09:11, [email protected] wrote:

From: Takahiro Kuwano <[email protected]>

Infineon(Cypress) S26HL-T/S26HS-T family of flash devices support both legacy SPI mode and HyperBus (JESD251C xSPI profile 2.0) mode. In HyperBus mode, it is compatible with Cypress S26KL-S/S26KS-S HyperFlash family with some exceptions. One significant difference is that the CFI is replaced by SFDP. This patch intends to support Hyperbus devices that has SFDP instead of CFI, by adding new probing method that detects SFDP signature and setting up CFI structure to make SFDP chips work with cfi_cmdset_xxxx.

By SFDP you mean the JESD216 SFDP standard, right? Would it make sense to pull out the SFDP parsing from SPI NOR into its own dedicated entity so that it's used by hyperbus as well?

Quoted 8 lines

The probe flow implemented in hyperbus_sfdp_probe_chip() is same as cfi_probe_chip() in chips/cfi_probe.c. The CFI "QRY" detection is replaced by "SFDP" signature detection.

Device identification and setup functions specific for S26Hx-T are also implemented in the same source file as SFDP probe and called from probe function. Once other devices that supports SFDP come up, we will implemet generic detection and setup flow.

What other hyperflash devices are out in the market and which of them support SFDP? I saw ISSI has hyperflashes:
https://www.issi.com/us/product-flash.shtml

In SPI NOR we worked a lot to separate the core from the manufacturer drivers. I'd make the split here since the beginning, the code will become cleaner and easier to maintain.

Quoted 14 lines
---
 drivers/mtd/hyperbus/Makefile        |   4 +-
 drivers/mtd/hyperbus/hyperbus-core.c |  15 +-
 drivers/mtd/hyperbus/hyperbus-sfdp.c | 346 +++++++++++++++++++++++++++
 3 files changed, 363 insertions(+), 2 deletions(-)
 create mode 100644 drivers/mtd/hyperbus/hyperbus-sfdp.c
drivers/mtd/hyperbus/Makefile +0 -0
index 26386158bd1c..03132bc05853 100644

drivers/mtd/hyperbus/Makefile line 7

Quoted 8 lines
drivers/mtd/hyperbus/Makefile +2 -1
@@ -1,9 +1,11 @@
 # SPDX-License-Identifier: GPL-2.0
 
-obj-$(CONFIG_MTD_HYPERBUS)	+= hyperbus-core.o
+obj-$(CONFIG_MTD_HYPERBUS)	+= hyperbus.o
 obj-$(CONFIG_HBMC_AM654)	+= hbmc-am654.o
 obj-$(CONFIG_RPCIF_HYPERBUS)	+= rpc-if.o
 
+hyperbus-objs	:= hyperbus-core.o hyperbus-sfdp.o

maybe rename hyperbus-core to core, as we're already in a hyperbus directory

Quoted 64 lines
drivers/mtd/hyperbus/Makefile +1 -0
+
 
 
 obj-y += ifx-hyperbus.o
drivers/mtd/hyperbus/hyperbus-core.c +14 -1
index 4d8047d43e48..b31a8bea3995 100644
@@ -12,6 +12,19 @@
 #include <linux/of.h>
 #include <linux/types.h>
 
+struct mtd_info *hyperbus_sfdp_probe(struct map_info *map);
+
+static struct mtd_info *hyperbus_map_probe(struct map_info *map)
+{
+	struct mtd_info *mtd;
+
+	mtd = do_map_probe("cfi_probe", map);
+	if (!mtd)
+		mtd = hyperbus_sfdp_probe(map);
+
+	return mtd;
+}
+
 static struct hyperbus_device *map_to_hbdev(struct map_info *map)
 {
 	return container_of(map, struct hyperbus_device, map);
@@ -106,7 +119,7 @@ int hyperbus_register_device(struct hyperbus_device *hbdev)
 		}
 	}
 
-	hbdev->mtd = do_map_probe("cfi_probe", map);
+	hbdev->mtd = hyperbus_map_probe(map);
 	if (!hbdev->mtd) {
 		dev_err(dev, "probing of hyperbus device failed\n");
 		return -ENODEV;
drivers/mtd/hyperbus/hyperbus-sfdp.c new file +21 -0
new file mode 100644
index 000000000000..f292e39856cb
@@ -0,0 +1,346 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2023, Infineon Technologies.
+ */
+#include <linux/mtd/xip.h>
+#include <linux/mtd/gen_probe.h>
+
+#ifdef CONFIG_MTD_XIP
+
+/* only needed for short periods, so this is rather simple */
+#define xip_disable()	local_irq_disable()
+
+#define xip_allowed(base, map) \
+do { \
+	(void) map_read(map, base); \
+	xip_iprefetch(); \
+	local_irq_enable(); \
+} while (0)
+
+#define xip_enable(base, map, cfi) \
+do { \

drivers/mtd/hyperbus/hyperbus-sfdp.c line 31

Quoted 10 lines
drivers/mtd/hyperbus/hyperbus-sfdp.c new file +10 -0
+	hyperbus_sfdp_mode_off(base, map, cfi);		\
+	xip_allowed(base, map); \
+} while (0)
+
+#else
+
+#define xip_disable()				do { } while (0)
+#define xip_allowed(base, map)			do { } while (0)
+#define xip_enable(base, map, cfi)		do { } while (0)
+> +#endif

Is the xip tested? You haven't specified anything about it in the commit message. I would get rid of it if possible, and come with a dedicated patch on top. The simpler a patch is, the more chances it gets to get integrated.

drivers/mtd/hyperbus/hyperbus-sfdp.c line 43

Quoted 11 lines
drivers/mtd/hyperbus/hyperbus-sfdp.c new file +11 -0
+
+/* HyperBus Commands */
+#define HYPERBUS_ADDR_UNLOCK1	0x555
+#define HYPERBUS_ADDR_UNLOCK2	0x2AA
+#define HYPERBUS_CMD_UNLOCK1	0xAA
+#define HYPERBUS_CMD_UNLOCK2	0x55
+#define HYPERBUS_CMD_RDSFDP	0x90
+#define HYPERBUS_CMD_RDVCR1	0xC7
+#define HYPERBUS_CMD_RDVCR2	0xC9
+#define HYPERBUS_CMD_ASOEXT	0xF0
+#define HYPERBUS_CMD_ERSCTR	0x30

these shall be moved to include/linux/mtd/hyperbus.h

drivers/mtd/hyperbus/hyperbus-sfdp.c line 55

Quoted 12 lines
drivers/mtd/hyperbus/hyperbus-sfdp.c new file +12 -0
+
+/* For Infineon S26Hx family */
+#define S26HX_ADDR_MFR_ID	0x800
+#define S26HX_ADDR_DEV_ID1	0x801
+#define S26HX_ADDR_DEV_ID2	0x802
+#define S26HX_DEV_ID1_3V0	0x006A
+#define S26HX_DEV_ID1_1V8	0x007B
+#define S26HX_DEV_ID2_512	0x001A
+#define S26HX_DEV_ID2_01G	0x001B
+#define S26HX_CFR1_UNIFORM	BIT(9)
+#define S26HX_CFR1_TP4KBS	BIT(8)
+#define S26HX_CFR2_SP4KBS	BIT(2)

and these to thier own manufacturer file

drivers/mtd/hyperbus/hyperbus-sfdp.c line 56

Quoted 1 line
drivers/mtd/hyperbus/hyperbus-sfdp.c new file +1 -0
+#define ERASEINFO(s, b)		(((s) << 8) | ((b) - 1))

can we use FIELD_GET/FIELD_SET for eraseinfo?

drivers/mtd/hyperbus/hyperbus-sfdp.c line 65

Quoted 9 lines
drivers/mtd/hyperbus/hyperbus-sfdp.c new file +9 -0
+
+static inline u16 hyperbus_read(u32 addr, struct map_info *map,
+				struct cfi_private *cfi)
+{
+	return cfi_read_query16(map, addr * cfi->interleave * cfi->device_type);
+}
+
+static inline void hyperbus_write(u8 cmd, u32 addr, struct map_info *map,
+				  struct cfi_private *cfi)

here you ignore the return value of cfi_send_gen_cmd. Shall we change the return type to u32?

Quoted 5 lines
drivers/mtd/hyperbus/hyperbus-sfdp.c new file +5 -0
+{
+	cfi_send_gen_cmd(cmd, addr, 0, map, cfi, cfi->device_type, NULL);> +}
+
+static int __xipram hyperbus_sfdp_present(struct map_info *map, __u32 base,
+					  struct cfi_private *cfi)

drivers/mtd/hyperbus/hyperbus-sfdp.c line 81

Quoted 10 lines
drivers/mtd/hyperbus/hyperbus-sfdp.c new file +10 -0
+{
+	int osf = cfi->interleave * cfi->device_type; /* scale factor */
+	map_word val[2];
+	map_word sfdp[2];
+
+	sfdp[0] = cfi_build_cmd(0x4653, map, cfi); /* "SF" */
+	sfdp[1] = cfi_build_cmd(0x5044, map, cfi); /* "DP" */
+
+	val[0] = map_read(map, base + osf * 0x0);
+	val[1] = map_read(map, base + osf * 0x1);

can we read the entire SFDP in one shot?

drivers/mtd/hyperbus/hyperbus-sfdp.c line 89

Quoted 8 lines
drivers/mtd/hyperbus/hyperbus-sfdp.c new file +8 -0
+
+	if (!map_word_equal(map, sfdp[0], val[0]))
+		return 0;
+
+	if (!map_word_equal(map, sfdp[1], val[1]))
+		return 0;
+
+	return 1; /* "SFDP" found */

return -EINVAL for error and zero for success

drivers/mtd/hyperbus/hyperbus-sfdp.c line 93

Quoted 4 lines
drivers/mtd/hyperbus/hyperbus-sfdp.c new file +4 -0
+}
+
+static int __xipram hyperbus_sfdp_mode_on(u32 base, struct map_info *map,
+					  struct cfi_private *cfi)

base is unused

drivers/mtd/hyperbus/hyperbus-sfdp.c line 103

Quoted 10 lines
drivers/mtd/hyperbus/hyperbus-sfdp.c new file +10 -0
+{
+	hyperbus_write(HYPERBUS_CMD_ASOEXT, 0, map, cfi);
+	hyperbus_write(HYPERBUS_CMD_UNLOCK1, HYPERBUS_ADDR_UNLOCK1, map, cfi);
+	hyperbus_write(HYPERBUS_CMD_UNLOCK2, HYPERBUS_ADDR_UNLOCK2, map, cfi);
+	hyperbus_write(HYPERBUS_CMD_RDSFDP, HYPERBUS_ADDR_UNLOCK1, map, cfi);
+	return hyperbus_sfdp_present(map, 0, cfi);
+}
+
+static void __xipram hyperbus_sfdp_mode_off(u32 base, struct map_info *map,
+					    struct cfi_private *cfi)

base in unused

Quoted 114 lines
drivers/mtd/hyperbus/hyperbus-sfdp.c new file +114 -0
+{
+	hyperbus_write(HYPERBUS_CMD_ASOEXT, 0, map, cfi);
+}
+
+static u16 __xipram hyperbus_s26hx_rdvcr1(struct map_info *map,
+					  struct cfi_private *cfi)
+{
+	hyperbus_write(HYPERBUS_CMD_UNLOCK1, HYPERBUS_ADDR_UNLOCK1, map, cfi);
+	hyperbus_write(HYPERBUS_CMD_UNLOCK2, HYPERBUS_ADDR_UNLOCK2, map, cfi);
+	hyperbus_write(HYPERBUS_CMD_RDVCR1, HYPERBUS_ADDR_UNLOCK1, map, cfi);
+	return hyperbus_read(0, map, cfi);
+}
+
+static u16 __xipram hyperbus_s26hx_rdvcr2(struct map_info *map,
+					  struct cfi_private *cfi)
+{
+	hyperbus_write(HYPERBUS_CMD_UNLOCK1, HYPERBUS_ADDR_UNLOCK1, map, cfi);
+	hyperbus_write(HYPERBUS_CMD_UNLOCK2, HYPERBUS_ADDR_UNLOCK2, map, cfi);
+	hyperbus_write(HYPERBUS_CMD_RDVCR2, HYPERBUS_ADDR_UNLOCK1, map, cfi);
+	return hyperbus_read(0, map, cfi);
+}
+
+static int __xipram hyperbus_s26hx_chip_setup(struct map_info *map,
+					      struct cfi_private *cfi)
+{
+	u16 mfr_id, dev_id1, dev_id2, cfr1v, cfr2v;
+	u8 nregions, nbtm4ks, ntop4ks, n256ks;
+	u32 *erase;
+
+	/* Read manufacturer and Device ID */
+	mfr_id = hyperbus_read(S26HX_ADDR_MFR_ID, map, cfi);
+	dev_id1 = hyperbus_read(S26HX_ADDR_DEV_ID1, map, cfi);
+	dev_id2 = hyperbus_read(S26HX_ADDR_DEV_ID2, map, cfi);
+
+	if ((mfr_id != CFI_MFR_CYPRESS) ||
+	    (dev_id1 != S26HX_DEV_ID1_3V0 && dev_id1 != S26HX_DEV_ID1_1V8) ||
+	    (dev_id2 != S26HX_DEV_ID2_512 && dev_id2 != S26HX_DEV_ID2_01G)) {
+		xip_enable(0, map, cfi);
+		return 0;
+	}
+
+	/* Exit SFDP ASO then read CFR1V and CFR2V */
+	hyperbus_sfdp_mode_off(0, map, cfi);
+	cfr1v = hyperbus_s26hx_rdvcr1(map, cfi);
+	cfr2v = hyperbus_s26hx_rdvcr2(map, cfi);
+
+	xip_enable(0, map, cfi);
+
+	/*
+	 * Determine number of regions (nregions), number of bottom 4KB sectors
+	 * (nbtm4ks), and number of top 4KB sectors (ntop4ks)
+	 */
+	if (cfr1v & S26HX_CFR1_UNIFORM) {
+		nregions = 1;
+		nbtm4ks = 0;
+		ntop4ks = 0;
+	} else if (cfr2v & S26HX_CFR2_SP4KBS) {
+		nregions = 5;
+		nbtm4ks = 16;
+		ntop4ks = 16;
+	} else if (cfr1v & S26HX_CFR1_TP4KBS) {
+		nregions = 3;
+		nbtm4ks = 0;
+		ntop4ks = 32;
+	} else {
+		nregions = 3;
+		nbtm4ks = 32;
+		ntop4ks = 0;
+	}
+
+	cfi->cfiq = kmalloc(sizeof(struct cfi_ident) + nregions * sizeof(u32),
+			    GFP_KERNEL);
+	if (!cfi->cfiq)
+		return 0;
+
+	memset(cfi->cfiq, 0, sizeof(struct cfi_ident));
+
+	cfi->mfr = mfr_id;
+	cfi->id = dev_id1 << 8 | dev_id2;
+	cfi->cfi_mode = CFI_MODE_CFI;
+	cfi->addr_unlock1 = HYPERBUS_ADDR_UNLOCK1;
+	cfi->addr_unlock2 = HYPERBUS_ADDR_UNLOCK2;
+	cfi->sector_erase_cmd = CMD(HYPERBUS_CMD_ERSCTR);
+
+	cfi->cfiq->P_ID = P_ID_AMD_STD;
+	cfi->cfiq->DevSize = dev_id2; /* dev_id2 indicates size in 2^N */
+	cfi->cfiq->MaxBufWriteSize = 9; /* 2^9 = 512 */
+
+	/*
+	 * cfi_cmdset_0002 uses fixed timeout for word write (1ms + 1 jiffies)
+	 * and sector erase (20s) that should be enough for s26hx. For buffer
+	 * write, 2000us is used if cfiq->BufWriteTimeoutXXX is 0. The typical
+	 * and maximum 512B page programming times are 680us and 2175us
+	 * respectively. Specify proper values here to extend buffer write
+	 * timeout.
+	 */
+	cfi->cfiq->BufWriteTimeoutTyp = 10; /* 2^10 = 1024 */
+	cfi->cfiq->BufWriteTimeoutMax = 2; /* 1024 x 2^2 = 4096 */
+
+	/* Setup erase region info */
+	cfi->cfiq->NumEraseRegions = nregions;
+	erase = cfi->cfiq->EraseRegionInfo;
+
+	/* Bottom 4KB sectors and remaining portion */
+	if (nbtm4ks) {
+		*erase++ = ERASEINFO(SZ_4K, nbtm4ks);
+		*erase++ = ERASEINFO(SZ_256K - (SZ_4K * nbtm4ks), 1);
+	}
+
+	/*
+	 * The number of uniform 256KB sectors is obtained by dividing 'device
+	 * size' by 256K(=2^18). Deduct overlaid sector(s) from uniform number
+	 * if top and/or bottom 4KB sectors exist.
+	 */

drivers/mtd/hyperbus/hyperbus-sfdp.c line 227

Quoted 10 lines
drivers/mtd/hyperbus/hyperbus-sfdp.c new file +10 -0
+	n256ks = (1 << (cfi->cfiq->DevSize - 18)) - !!(nbtm4ks) - !!(ntop4ks);
+	*erase++ = ERASEINFO(SZ_256K, n256ks);
+
+	/* Top 4KB sectors and remaining portion */
+	if (ntop4ks) {
+		*erase++ = ERASEINFO(SZ_256K - (SZ_4K * ntop4ks), 1);
+		*erase = ERASEINFO(SZ_4K, ntop4ks);
+	}
+
+	return 1;

please return 0 for success, -errno in case of others. Is this method entirely IFX specific? Let's move it in its own cypress/ifx manufacturer file.

Quoted 35 lines
drivers/mtd/hyperbus/hyperbus-sfdp.c new file +35 -0
+}
+
+static int __xipram hyperbus_sfdp_chip_setup(struct map_info *map,
+					     struct cfi_private *cfi)
+{
+	/*
+	 * Just call setup for S26Hx since it is only chip supported.
+	 * Once other devices come up, we will implement vendor/chip specific
+	 * detection and setup flow here.
+	 */
+	return hyperbus_s26hx_chip_setup(map, cfi);
+}
+
+static int __xipram hyperbus_sfdp_probe_chip(struct map_info *map, __u32 base,
+					     unsigned long *chip_map,
+					     struct cfi_private *cfi)
+{
+	u32 probe_addr;
+	int i;
+
+	if (base >= map->size) {
+		pr_notice("Probe at base(0x%08x) past the end of the map(0x%08lx)\n",
+			  base, map->size - 1);
+		return 0;
+	}
+
+	probe_addr = base + cfi_build_cmd_addr(HYPERBUS_ADDR_UNLOCK1, map, cfi);
+	if (probe_addr >= map->size) {
+		pr_notice("Probe at base[unlock](0x%08x) past the end of the map(0x%08lx)\n",
+			  probe_addr, map->size - 1);
+		return 0;
+	}
+
+	xip_disable();
+	if (!hyperbus_sfdp_mode_on(base, map, cfi)) {

drivers/mtd/hyperbus/hyperbus-sfdp.c line 272

Quoted 10 lines
drivers/mtd/hyperbus/hyperbus-sfdp.c new file +10 -0
+		xip_enable(base, map, cfi);
+		return 0;
+	}
+
+	/*
+	 * This is the first time we're called. Set up the CFI stuff accordingly
+	 * and return
+	 */
+	if (!cfi->numchips)
+		return hyperbus_sfdp_chip_setup(map, cfi);

Ah, I need to study more. Would you please speed me up a little and tell me more about the multi chip handling? Why is the probe called multiple times?

Thanks!
ta

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

#3 lore raw

Re: [PATCH 1/2] mtd: hyperbus: Introduce SFDP probe

Quoted 15 lines · Tudor Ambarus

Hi, Takahiro!

Quoted 11 lines · On 07.04.2023 09:11, [email protected] wrote:

From: Takahiro Kuwano <[email protected]>

Infineon(Cypress) S26HL-T/S26HS-T family of flash devices support both legacy SPI mode and HyperBus (JESD251C xSPI profile 2.0) mode. In HyperBus mode, it is compatible with Cypress S26KL-S/S26KS-S HyperFlash family with some exceptions. One significant difference is that the CFI is replaced by SFDP. This patch intends to support Hyperbus devices that has SFDP instead of CFI, by adding new probing method that detects SFDP signature and setting up CFI structure to make SFDP chips work with cfi_cmdset_xxxx.

Quoted 4 lines

By SFDP you mean the JESD216 SFDP standard, right? Would it make sense to pull out the SFDP parsing from SPI NOR into its own dedicated entity so that it's used by hyperbus as well?

Right, it's JESD216. However, it doesn't have much information that needed to set up CFI structure. I just verify "SFDP" signature and read device IDs that mapped in SFDP address space. So far, I don't see benefit from dedicated SFDP parser.

Quoted 4 lines
Quoted 4 lines

The probe flow implemented in hyperbus_sfdp_probe_chip() is same as cfi_probe_chip() in chips/cfi_probe.c. The CFI "QRY" detection is replaced by "SFDP" signature detection.

Quoted 9 lines
Quoted 4 lines

Device identification and setup functions specific for S26Hx-T are also implemented in the same source file as SFDP probe and called from probe function. Once other devices that supports SFDP come up, we will implemet generic detection and setup flow.

What other hyperflash devices are out in the market and which of them support SFDP? I saw ISSI has hyperflashes:
https://www.issi.com/us/product-flash.shtml

This is CFI based, equivalent to Infineon S26KL-S/S26KS-S. There is no other HyperFlash device that supports SFDP.

Quoted 4 lines

In SPI NOR we worked a lot to separate the core from the manufacturer drivers. I'd make the split here since the beginning, the code will become cleaner and easier to maintain.

Understood. I will try to split.

Quoted 16 lines
Quoted 16 lines
---
 drivers/mtd/hyperbus/Makefile        |   4 +-
 drivers/mtd/hyperbus/hyperbus-core.c |  15 +-
 drivers/mtd/hyperbus/hyperbus-sfdp.c | 346 +++++++++++++++++++++++++++
 3 files changed, 363 insertions(+), 2 deletions(-)
 create mode 100644 drivers/mtd/hyperbus/hyperbus-sfdp.c
drivers/mtd/hyperbus/Makefile +0 -0
index 26386158bd1c..03132bc05853 100644
@@ -1,9 +1,11 @@
 # SPDX-License-Identifier: GPL-2.0
 
Quoted 9 lines

drivers/mtd/hyperbus/Makefile line 7

Quoted 6 lines
drivers/mtd/hyperbus/Makefile +2 -1
-obj-$(CONFIG_MTD_HYPERBUS)	+= hyperbus-core.o
+obj-$(CONFIG_MTD_HYPERBUS)	+= hyperbus.o
 obj-$(CONFIG_HBMC_AM654)	+= hbmc-am654.o
 obj-$(CONFIG_RPCIF_HYPERBUS)	+= rpc-if.o
 
+hyperbus-objs	:= hyperbus-core.o hyperbus-sfdp.o

maybe rename hyperbus-core to core, as we're already in a hyperbus directory

Noted.

Quoted 72 lines
Quoted 72 lines
drivers/mtd/hyperbus/Makefile +1 -0
+
 
 
 obj-y += ifx-hyperbus.o
drivers/mtd/hyperbus/hyperbus-core.c +14 -1
index 4d8047d43e48..b31a8bea3995 100644
@@ -12,6 +12,19 @@
 #include <linux/of.h>
 #include <linux/types.h>
 
+struct mtd_info *hyperbus_sfdp_probe(struct map_info *map);
+
+static struct mtd_info *hyperbus_map_probe(struct map_info *map)
+{
+	struct mtd_info *mtd;
+
+	mtd = do_map_probe("cfi_probe", map);
+	if (!mtd)
+		mtd = hyperbus_sfdp_probe(map);
+
+	return mtd;
+}
+
 static struct hyperbus_device *map_to_hbdev(struct map_info *map)
 {
 	return container_of(map, struct hyperbus_device, map);
@@ -106,7 +119,7 @@ int hyperbus_register_device(struct hyperbus_device *hbdev)
 		}
 	}
 
-	hbdev->mtd = do_map_probe("cfi_probe", map);
+	hbdev->mtd = hyperbus_map_probe(map);
 	if (!hbdev->mtd) {
 		dev_err(dev, "probing of hyperbus device failed\n");
 		return -ENODEV;
drivers/mtd/hyperbus/hyperbus-sfdp.c new file +29 -0
new file mode 100644
index 000000000000..f292e39856cb
@@ -0,0 +1,346 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2023, Infineon Technologies.
+ */
+#include <linux/mtd/xip.h>
+#include <linux/mtd/gen_probe.h>
+
+#ifdef CONFIG_MTD_XIP
+
+/* only needed for short periods, so this is rather simple */
+#define xip_disable()	local_irq_disable()
+
+#define xip_allowed(base, map) \
+do { \
+	(void) map_read(map, base); \
+	xip_iprefetch(); \
+	local_irq_enable(); \
+} while (0)
+
+#define xip_enable(base, map, cfi) \
+do { \
+	hyperbus_sfdp_mode_off(base, map, cfi);		\
+	xip_allowed(base, map); \
+} while (0)
+
+#else
+
+#define xip_disable()				do { } while (0)
+#define xip_allowed(base, map)			do { } while (0)
Quoted 9 lines

drivers/mtd/hyperbus/hyperbus-sfdp.c line 31

Quoted 2 lines
drivers/mtd/hyperbus/hyperbus-sfdp.c new file +2 -0
+#define xip_enable(base, map, cfi)		do { } while (0)
+> +#endif

Is the xip tested? You haven't specified anything about it in the commit message. I would get rid of it if possible, and come with a dedicated patch on top. The simpler a patch is, the more chances it gets to get integrated.

Not tested. Let's remove.

Quoted 5 lines
Quoted 5 lines
drivers/mtd/hyperbus/hyperbus-sfdp.c new file +5 -0
+
+/* HyperBus Commands */
+#define HYPERBUS_ADDR_UNLOCK1	0x555
+#define HYPERBUS_ADDR_UNLOCK2	0x2AA
+#define HYPERBUS_CMD_UNLOCK1	0xAA
Quoted 9 lines

drivers/mtd/hyperbus/hyperbus-sfdp.c line 43

Quoted 6 lines
drivers/mtd/hyperbus/hyperbus-sfdp.c new file +6 -0
+#define HYPERBUS_CMD_UNLOCK2	0x55
+#define HYPERBUS_CMD_RDSFDP	0x90
+#define HYPERBUS_CMD_RDVCR1	0xC7
+#define HYPERBUS_CMD_RDVCR2	0xC9
+#define HYPERBUS_CMD_ASOEXT	0xF0
+#define HYPERBUS_CMD_ERSCTR	0x30

these shall be moved to include/linux/mtd/hyperbus.h

Noted.

Quoted 6 lines
Quoted 6 lines
drivers/mtd/hyperbus/hyperbus-sfdp.c new file +6 -0
+
+/* For Infineon S26Hx family */
+#define S26HX_ADDR_MFR_ID	0x800
+#define S26HX_ADDR_DEV_ID1	0x801
+#define S26HX_ADDR_DEV_ID2	0x802
+#define S26HX_DEV_ID1_3V0	0x006A
Quoted 9 lines

drivers/mtd/hyperbus/hyperbus-sfdp.c line 55

Quoted 6 lines
drivers/mtd/hyperbus/hyperbus-sfdp.c new file +6 -0
+#define S26HX_DEV_ID1_1V8	0x007B
+#define S26HX_DEV_ID2_512	0x001A
+#define S26HX_DEV_ID2_01G	0x001B
+#define S26HX_CFR1_UNIFORM	BIT(9)
+#define S26HX_CFR1_TP4KBS	BIT(8)
+#define S26HX_CFR2_SP4KBS	BIT(2)

and these to thier own manufacturer file

OK.

Quoted 4 lines

drivers/mtd/hyperbus/hyperbus-sfdp.c line 56

Quoted 1 line
drivers/mtd/hyperbus/hyperbus-sfdp.c new file +1 -0
+#define ERASEINFO(s, b)		(((s) << 8) | ((b) - 1))

can we use FIELD_GET/FIELD_SET for eraseinfo?

Yes, we can.

Quoted 4 lines
Quoted 4 lines
drivers/mtd/hyperbus/hyperbus-sfdp.c new file +4 -0
+
+static inline u16 hyperbus_read(u32 addr, struct map_info *map,
+				struct cfi_private *cfi)
+{
Quoted 9 lines

drivers/mtd/hyperbus/hyperbus-sfdp.c line 65

Quoted 5 lines
drivers/mtd/hyperbus/hyperbus-sfdp.c new file +5 -0
+	return cfi_read_query16(map, addr * cfi->interleave * cfi->device_type);
+}
+
+static inline void hyperbus_write(u8 cmd, u32 addr, struct map_info *map,
+				  struct cfi_private *cfi)

here you ignore the return value of cfi_send_gen_cmd. Shall we change the return type to u32?

It looks to me that nobody else takes return value of cfi_send_gen_cmd. Does it make sense to change the return type of cfi_send_gen_cmd instead?

Quoted 9 lines
Quoted 9 lines
drivers/mtd/hyperbus/hyperbus-sfdp.c new file +9 -0
+{
+	cfi_send_gen_cmd(cmd, addr, 0, map, cfi, cfi->device_type, NULL);> +}
+
+static int __xipram hyperbus_sfdp_present(struct map_info *map, __u32 base,
+					  struct cfi_private *cfi)
+{
+	int osf = cfi->interleave * cfi->device_type; /* scale factor */
+	map_word val[2];
+	map_word sfdp[2];
Quoted 9 lines

drivers/mtd/hyperbus/hyperbus-sfdp.c line 81

Quoted 6 lines
drivers/mtd/hyperbus/hyperbus-sfdp.c new file +6 -0
+
+	sfdp[0] = cfi_build_cmd(0x4653, map, cfi); /* "SF" */
+	sfdp[1] = cfi_build_cmd(0x5044, map, cfi); /* "DP" */
+
+	val[0] = map_read(map, base + osf * 0x0);
+	val[1] = map_read(map, base + osf * 0x1);

can we read the entire SFDP in one shot?

I think we can use map_copy_from, if needed.

Quoted 10 lines

drivers/mtd/hyperbus/hyperbus-sfdp.c line 89

Quoted 8 lines
drivers/mtd/hyperbus/hyperbus-sfdp.c new file +8 -0
+
+	if (!map_word_equal(map, sfdp[0], val[0]))
+		return 0;
+
+	if (!map_word_equal(map, sfdp[1], val[1]))
+		return 0;
+
+	return 1; /* "SFDP" found */

return -EINVAL for error and zero for success

OK.

Quoted 138 lines

drivers/mtd/hyperbus/hyperbus-sfdp.c line 93

Quoted 4 lines
drivers/mtd/hyperbus/hyperbus-sfdp.c new file +4 -0
+}
+
+static int __xipram hyperbus_sfdp_mode_on(u32 base, struct map_info *map,
+					  struct cfi_private *cfi)

base is unused

drivers/mtd/hyperbus/hyperbus-sfdp.c line 103

Quoted 10 lines
drivers/mtd/hyperbus/hyperbus-sfdp.c new file +10 -0
+{
+	hyperbus_write(HYPERBUS_CMD_ASOEXT, 0, map, cfi);
+	hyperbus_write(HYPERBUS_CMD_UNLOCK1, HYPERBUS_ADDR_UNLOCK1, map, cfi);
+	hyperbus_write(HYPERBUS_CMD_UNLOCK2, HYPERBUS_ADDR_UNLOCK2, map, cfi);
+	hyperbus_write(HYPERBUS_CMD_RDSFDP, HYPERBUS_ADDR_UNLOCK1, map, cfi);
+	return hyperbus_sfdp_present(map, 0, cfi);
+}
+
+static void __xipram hyperbus_sfdp_mode_off(u32 base, struct map_info *map,
+					    struct cfi_private *cfi)

base in unused

Quoted 120 lines
drivers/mtd/hyperbus/hyperbus-sfdp.c new file +120 -0
+{
+	hyperbus_write(HYPERBUS_CMD_ASOEXT, 0, map, cfi);
+}
+
+static u16 __xipram hyperbus_s26hx_rdvcr1(struct map_info *map,
+					  struct cfi_private *cfi)
+{
+	hyperbus_write(HYPERBUS_CMD_UNLOCK1, HYPERBUS_ADDR_UNLOCK1, map, cfi);
+	hyperbus_write(HYPERBUS_CMD_UNLOCK2, HYPERBUS_ADDR_UNLOCK2, map, cfi);
+	hyperbus_write(HYPERBUS_CMD_RDVCR1, HYPERBUS_ADDR_UNLOCK1, map, cfi);
+	return hyperbus_read(0, map, cfi);
+}
+
+static u16 __xipram hyperbus_s26hx_rdvcr2(struct map_info *map,
+					  struct cfi_private *cfi)
+{
+	hyperbus_write(HYPERBUS_CMD_UNLOCK1, HYPERBUS_ADDR_UNLOCK1, map, cfi);
+	hyperbus_write(HYPERBUS_CMD_UNLOCK2, HYPERBUS_ADDR_UNLOCK2, map, cfi);
+	hyperbus_write(HYPERBUS_CMD_RDVCR2, HYPERBUS_ADDR_UNLOCK1, map, cfi);
+	return hyperbus_read(0, map, cfi);
+}
+
+static int __xipram hyperbus_s26hx_chip_setup(struct map_info *map,
+					      struct cfi_private *cfi)
+{
+	u16 mfr_id, dev_id1, dev_id2, cfr1v, cfr2v;
+	u8 nregions, nbtm4ks, ntop4ks, n256ks;
+	u32 *erase;
+
+	/* Read manufacturer and Device ID */
+	mfr_id = hyperbus_read(S26HX_ADDR_MFR_ID, map, cfi);
+	dev_id1 = hyperbus_read(S26HX_ADDR_DEV_ID1, map, cfi);
+	dev_id2 = hyperbus_read(S26HX_ADDR_DEV_ID2, map, cfi);
+
+	if ((mfr_id != CFI_MFR_CYPRESS) ||
+	    (dev_id1 != S26HX_DEV_ID1_3V0 && dev_id1 != S26HX_DEV_ID1_1V8) ||
+	    (dev_id2 != S26HX_DEV_ID2_512 && dev_id2 != S26HX_DEV_ID2_01G)) {
+		xip_enable(0, map, cfi);
+		return 0;
+	}
+
+	/* Exit SFDP ASO then read CFR1V and CFR2V */
+	hyperbus_sfdp_mode_off(0, map, cfi);
+	cfr1v = hyperbus_s26hx_rdvcr1(map, cfi);
+	cfr2v = hyperbus_s26hx_rdvcr2(map, cfi);
+
+	xip_enable(0, map, cfi);
+
+	/*
+	 * Determine number of regions (nregions), number of bottom 4KB sectors
+	 * (nbtm4ks), and number of top 4KB sectors (ntop4ks)
+	 */
+	if (cfr1v & S26HX_CFR1_UNIFORM) {
+		nregions = 1;
+		nbtm4ks = 0;
+		ntop4ks = 0;
+	} else if (cfr2v & S26HX_CFR2_SP4KBS) {
+		nregions = 5;
+		nbtm4ks = 16;
+		ntop4ks = 16;
+	} else if (cfr1v & S26HX_CFR1_TP4KBS) {
+		nregions = 3;
+		nbtm4ks = 0;
+		ntop4ks = 32;
+	} else {
+		nregions = 3;
+		nbtm4ks = 32;
+		ntop4ks = 0;
+	}
+
+	cfi->cfiq = kmalloc(sizeof(struct cfi_ident) + nregions * sizeof(u32),
+			    GFP_KERNEL);
+	if (!cfi->cfiq)
+		return 0;
+
+	memset(cfi->cfiq, 0, sizeof(struct cfi_ident));
+
+	cfi->mfr = mfr_id;
+	cfi->id = dev_id1 << 8 | dev_id2;
+	cfi->cfi_mode = CFI_MODE_CFI;
+	cfi->addr_unlock1 = HYPERBUS_ADDR_UNLOCK1;
+	cfi->addr_unlock2 = HYPERBUS_ADDR_UNLOCK2;
+	cfi->sector_erase_cmd = CMD(HYPERBUS_CMD_ERSCTR);
+
+	cfi->cfiq->P_ID = P_ID_AMD_STD;
+	cfi->cfiq->DevSize = dev_id2; /* dev_id2 indicates size in 2^N */
+	cfi->cfiq->MaxBufWriteSize = 9; /* 2^9 = 512 */
+
+	/*
+	 * cfi_cmdset_0002 uses fixed timeout for word write (1ms + 1 jiffies)
+	 * and sector erase (20s) that should be enough for s26hx. For buffer
+	 * write, 2000us is used if cfiq->BufWriteTimeoutXXX is 0. The typical
+	 * and maximum 512B page programming times are 680us and 2175us
+	 * respectively. Specify proper values here to extend buffer write
+	 * timeout.
+	 */
+	cfi->cfiq->BufWriteTimeoutTyp = 10; /* 2^10 = 1024 */
+	cfi->cfiq->BufWriteTimeoutMax = 2; /* 1024 x 2^2 = 4096 */
+
+	/* Setup erase region info */
+	cfi->cfiq->NumEraseRegions = nregions;
+	erase = cfi->cfiq->EraseRegionInfo;
+
+	/* Bottom 4KB sectors and remaining portion */
+	if (nbtm4ks) {
+		*erase++ = ERASEINFO(SZ_4K, nbtm4ks);
+		*erase++ = ERASEINFO(SZ_256K - (SZ_4K * nbtm4ks), 1);
+	}
+
+	/*
+	 * The number of uniform 256KB sectors is obtained by dividing 'device
+	 * size' by 256K(=2^18). Deduct overlaid sector(s) from uniform number
+	 * if top and/or bottom 4KB sectors exist.
+	 */
+	n256ks = (1 << (cfi->cfiq->DevSize - 18)) - !!(nbtm4ks) - !!(ntop4ks);
+	*erase++ = ERASEINFO(SZ_256K, n256ks);
+
+	/* Top 4KB sectors and remaining portion */
+	if (ntop4ks) {
+		*erase++ = ERASEINFO(SZ_256K - (SZ_4K * ntop4ks), 1);
Quoted 9 lines

drivers/mtd/hyperbus/hyperbus-sfdp.c line 227

Quoted 4 lines
drivers/mtd/hyperbus/hyperbus-sfdp.c new file +4 -0
+		*erase = ERASEINFO(SZ_4K, ntop4ks);
+	}
+
+	return 1;

please return 0 for success, -errno in case of others. Is this method entirely IFX specific? Let's move it in its own cypress/ifx manufacturer file.

Yes, it's IFX specific. Will move to another file.

Quoted 41 lines
Quoted 41 lines
drivers/mtd/hyperbus/hyperbus-sfdp.c new file +41 -0
+}
+
+static int __xipram hyperbus_sfdp_chip_setup(struct map_info *map,
+					     struct cfi_private *cfi)
+{
+	/*
+	 * Just call setup for S26Hx since it is only chip supported.
+	 * Once other devices come up, we will implement vendor/chip specific
+	 * detection and setup flow here.
+	 */
+	return hyperbus_s26hx_chip_setup(map, cfi);
+}
+
+static int __xipram hyperbus_sfdp_probe_chip(struct map_info *map, __u32 base,
+					     unsigned long *chip_map,
+					     struct cfi_private *cfi)
+{
+	u32 probe_addr;
+	int i;
+
+	if (base >= map->size) {
+		pr_notice("Probe at base(0x%08x) past the end of the map(0x%08lx)\n",
+			  base, map->size - 1);
+		return 0;
+	}
+
+	probe_addr = base + cfi_build_cmd_addr(HYPERBUS_ADDR_UNLOCK1, map, cfi);
+	if (probe_addr >= map->size) {
+		pr_notice("Probe at base[unlock](0x%08x) past the end of the map(0x%08lx)\n",
+			  probe_addr, map->size - 1);
+		return 0;
+	}
+
+	xip_disable();
+	if (!hyperbus_sfdp_mode_on(base, map, cfi)) {
+		xip_enable(base, map, cfi);
+		return 0;
+	}
+
+	/*
+	 * This is the first time we're called. Set up the CFI stuff accordingly
Quoted 9 lines

drivers/mtd/hyperbus/hyperbus-sfdp.c line 272

Quoted 4 lines
drivers/mtd/hyperbus/hyperbus-sfdp.c new file +4 -0
+	 * and return
+	 */
+	if (!cfi->numchips)
+		return hyperbus_sfdp_chip_setup(map, cfi);

Ah, I need to study more. Would you please speed me up a little and tell me more about the multi chip handling? Why is the probe called multiple times?

For example, we can map 2x 1Gb(128MB) chips in single 256MB memory space. In this case, the probe is called twice. The first call is to set up CFI structure. The second call is to check if another chip really exists or not.

Quoted 2 lines

Thanks!
ta

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

reviewer
#4 lore raw

Re: [PATCH 1/2] mtd: hyperbus: Introduce SFDP probe

Quoted 9 lines · Takahiro Kuwano
Quoted 9 lines

drivers/mtd/hyperbus/hyperbus-sfdp.c line 272

Quoted 5 lines
drivers/mtd/hyperbus/hyperbus-sfdp.c new file +5 -0
+	 * This is the first time we're called. Set up the CFI stuff accordingly
+	 * and return
+	 */
+	if (!cfi->numchips)
+		return hyperbus_sfdp_chip_setup(map, cfi);

Ah, I need to study more. Would you please speed me up a little and tell me more about the multi chip handling? Why is the probe called multiple times?

Quoted 3 lines

For example, we can map 2x 1Gb(128MB) chips in single 256MB memory space. In this case, the probe is called twice. The first call is to set up CFI structure. The second call is to check if another chip really exists or not.

Do we have any hyperflash multi-chip devices upstreamed? If not, let's remove the multi-chip logic and handle it when multi-chip is introduced.

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

#5 lore raw

Re: [PATCH 1/2] mtd: hyperbus: Introduce SFDP probe

Quoted 12 lines · Tudor Ambarus
Quoted 9 lines · Takahiro Kuwano
Quoted 9 lines

drivers/mtd/hyperbus/hyperbus-sfdp.c line 272

Quoted 5 lines
drivers/mtd/hyperbus/hyperbus-sfdp.c new file +5 -0
+	 * This is the first time we're called. Set up the CFI stuff accordingly
+	 * and return
+	 */
+	if (!cfi->numchips)
+		return hyperbus_sfdp_chip_setup(map, cfi);

Ah, I need to study more. Would you please speed me up a little and tell me more about the multi chip handling? Why is the probe called multiple times?

Quoted 6 lines
Quoted 3 lines

For example, we can map 2x 1Gb(128MB) chips in single 256MB memory space. In this case, the probe is called twice. The first call is to set up CFI structure. The second call is to check if another chip really exists or not.

Do we have any hyperflash multi-chip devices upstreamed? If not, let's remove the multi-chip logic and handle it when multi-chip is introduced.

I meant multiple packages of device (different chip-select, in other words) are mapped to contiguous memory space. Not multi-chip in single package.

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

#6 lore raw

PATCH 2/2 mtd: chips: cfi_cmdset0002: Fixups for Infineon(Cypress) S26Hx

In reply to [email protected]

From: Takahiro Kuwano <[email protected]>

Infineon(Cypress) S26HL-T/S26HS-T family has AMD/Fujitsu command set in Hyperbus mode. The parts have on-die ECC that program granularity is 16 bytes data unit where we cannot word-program nor bit-walking. Fixups for these ECC related requirements are added to cfi_nopri_fixup_table[] as the parts do not have primary extended table.

The parts do not support DQ polling so we need to use status_reg.

---
 drivers/mtd/chips/cfi_cmdset_0002.c | 25 +++++++++++++++++++++++++
 include/linux/mtd/cfi.h             |  1 +
 2 files changed, 26 insertions(+)
drivers/mtd/chips/cfi_cmdset_0002.c +25 -0
index 67453f59c69c..b4e1b0d516b1 100644
@@ -124,6 +124,10 @@ static int cfi_use_status_reg(struct cfi_private *cfi)
 	struct cfi_pri_amdstd *extp = cfi->cmdset_priv;
 	u8 poll_mask = CFI_POLL_STATUS_REG | CFI_POLL_DQ;
 
+	/* DQ polling is not supported in Cypress chips (S26Hx) */
+	if (cfi->mfr == CFI_MFR_CYPRESS)
+		return 1;
+
 	return extp && extp->MinorVersion >= '5' &&
 		(extp->SoftwareFeatures & poll_mask) == CFI_POLL_STATUS_REG;
 }
@@ -450,6 +454,23 @@ static void fixup_quirks(struct mtd_info *mtd)
 		cfi->quirks |= CFI_QUIRK_DQ_TRUE_DATA;
 }
 
+static void fixup_s26hx_writesize(struct mtd_info *mtd)
+{
+	/*
+	 * Programming is supported only in 16-byte ECC data unit granularity.
+	 * Byte(word)-programming, bit-walking, or multiple program operations
+	 * to the same ECC data unit without an erase are not allowed.
+	 */
+	mtd->writesize = 16;
+	mtd->_write = cfi_amdstd_write_buffers;
+
+	/*
+	 * Unset MTD_BIT_WRITEABLE to activate JFFS2 write buffer for ECC'd NOR
+	 * flash.
+	 */
+	mtd->flags = MTD_CAP_NORFLASH & ~MTD_BIT_WRITEABLE;
+}
+
 /* Used to fix CFI-Tables of chips without Extended Query Tables */
 static struct cfi_fixup cfi_nopri_fixup_table[] = {
 	{ CFI_MFR_SST, 0x234a, fixup_sst39vf }, /* SST39VF1602 */
@@ -460,6 +481,10 @@ static struct cfi_fixup cfi_nopri_fixup_table[] = {
 	{ CFI_MFR_SST, 0x235d, fixup_sst39vf_rev_b }, /* SST39VF3201B */
 	{ CFI_MFR_SST, 0x236c, fixup_sst39vf_rev_b }, /* SST39VF6402B */
 	{ CFI_MFR_SST, 0x236d, fixup_sst39vf_rev_b }, /* SST39VF6401B */
+	{ CFI_MFR_CYPRESS, 0x6a1a, fixup_s26hx_writesize }, /* S26HL512T */
+	{ CFI_MFR_CYPRESS, 0x6a1b, fixup_s26hx_writesize }, /* S26HL01GT */
+	{ CFI_MFR_CYPRESS, 0x7b1a, fixup_s26hx_writesize }, /* S26HS512T */
+	{ CFI_MFR_CYPRESS, 0x7b1b, fixup_s26hx_writesize }, /* S26HS01GT */
 	{ 0, 0, NULL }
 };
 
include/linux/mtd/cfi.h +1 -0
index d88bb56c18e2..29668241b44e 100644
@@ -374,6 +374,7 @@ struct cfi_fixup {
 #define CFI_MFR_MICRON		0x002C /* Micron */
 #define CFI_MFR_TOSHIBA		0x0098
 #define CFI_MFR_WINBOND		0x00DA
+#define CFI_MFR_CYPRESS		0x0034
 
 void cfi_fixup(struct mtd_info *mtd, struct cfi_fixup* fixups);
 
Signature · 6 lines
2.34.1


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
reviewer
#7 lore raw
In reply to [email protected]

Hi, Takahiro, Vignesh,

Quoted 5 lines · On 07.04.2023 09:11, [email protected] wrote:

From: Takahiro Kuwano <[email protected]>

This sereis adds support for Infineon S26HL-T/S26HS-T flash family.
https://www.infineon.com/dgdl/Infineon-S26HS01GTGABHM020-DataSheet-v01_00-EN.pdf?fileId=8ac78c8c7f2a768a017f52f2f5182c91

Quoted 7 lines

This family supports two interface modes, SPI mode and Hyperbus mode. The mode can be switched at rutime. The default mode is selected by ordering option and non-volatile user configuration. In hyperbus mode, the device is compatible with S26KL-S/S26KS-S hyperflash family that supports hyperbus only so one of use cases of S26Hx-T is replacement of (or migration from) S26Kx-S. This patch set focuses on particular usage that the device is pre-configured as hyperbus mode for compatibility with S26Kx-S.

I'm questioning the overall hyperbus software architecture, not your patches per se. IMO hyperbus framework should have been written on top of SPIMEM and the controllers be placed in drivers/spi/. So I'd first address the SPIMEM adoption before adding/accepting new support. Would love to hear more from Vignesh.

Cheers,
ta

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

reviewer
#8 lore raw

+ Sergei, Geert, Mark & linux-spi

Hi, Sergei,

Quoted 17 lines · Tudor Ambarus

Hi, Takahiro, Vignesh,

Quoted 5 lines · On 07.04.2023 09:11, [email protected] wrote:

From: Takahiro Kuwano <[email protected]>

This sereis adds support for Infineon S26HL-T/S26HS-T flash family.
https://www.infineon.com/dgdl/Infineon-S26HS01GTGABHM020-DataSheet-v01_00-EN.pdf?fileId=8ac78c8c7f2a768a017f52f2f5182c91

Quoted 7 lines

This family supports two interface modes, SPI mode and Hyperbus mode. The mode can be switched at rutime. The default mode is selected by ordering option and non-volatile user configuration. In hyperbus mode, the device is compatible with S26KL-S/S26KS-S hyperflash family that supports hyperbus only so one of use cases of S26Hx-T is replacement of (or migration from) S26Kx-S. This patch set focuses on particular usage that the device is pre-configured as hyperbus mode for compatibility with S26Kx-S.

Quoted 6 lines

I'm questioning the overall hyperbus software architecture, not your patches per se. IMO hyperbus framework should have been written on top of SPIMEM and the controllers be placed in drivers/spi/. So I'd first address the SPIMEM adoption before adding/accepting new support. Would love to hear more from Vignesh.

RPC is the only multi IO SPI controller that's upstreamed and capable of dealing with hyperflashes, but there are others which are not upstreamed yet (microchip).

Struct ``struct rpcif_op`` [1] duplicates the contents of ``struct spi_mem_op`` [2] which could have been avoided if hyperflash driver was extended with SPI MEM support. This way the RPC hyperbus driver, which is an SPI controller, could have been moved to drivers/spi.

Sergei, do you remember why we haven't used SPI MEM for hyberbus since the beginning? Was it something that we aimed for in a future patch set?

Thanks,
ta

[1]
https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git/tree/include/memory/renesas-rpc-if.h?h=mtd/for-6.8#n22

[2]
https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git/tree/include/linux/spi/spi-mem.h?h=mtd/for-6.8#n99

reviewer
#9 lore raw

Ah, Sergei's email was bouncing, I updated his email address.

Sergei, would you please read the thread? Thanks!

Quoted 50 lines · Tudor Ambarus

+ Sergei, Geert, Mark & linux-spi

Hi, Sergei,

Quoted 17 lines · Tudor Ambarus

Hi, Takahiro, Vignesh,

Quoted 5 lines · On 07.04.2023 09:11, [email protected] wrote:

From: Takahiro Kuwano <[email protected]>

This sereis adds support for Infineon S26HL-T/S26HS-T flash family.
https://www.infineon.com/dgdl/Infineon-S26HS01GTGABHM020-DataSheet-v01_00-EN.pdf?fileId=8ac78c8c7f2a768a017f52f2f5182c91

Quoted 7 lines

This family supports two interface modes, SPI mode and Hyperbus mode. The mode can be switched at rutime. The default mode is selected by ordering option and non-volatile user configuration. In hyperbus mode, the device is compatible with S26KL-S/S26KS-S hyperflash family that supports hyperbus only so one of use cases of S26Hx-T is replacement of (or migration from) S26Kx-S. This patch set focuses on particular usage that the device is pre-configured as hyperbus mode for compatibility with S26Kx-S.

Quoted 6 lines

I'm questioning the overall hyperbus software architecture, not your patches per se. IMO hyperbus framework should have been written on top of SPIMEM and the controllers be placed in drivers/spi/. So I'd first address the SPIMEM adoption before adding/accepting new support. Would love to hear more from Vignesh.

RPC is the only multi IO SPI controller that's upstreamed and capable of dealing with hyperflashes, but there are others which are not upstreamed yet (microchip).

Struct ``struct rpcif_op`` [1] duplicates the contents of ``struct spi_mem_op`` [2] which could have been avoided if hyperflash driver was extended with SPI MEM support. This way the RPC hyperbus driver, which is an SPI controller, could have been moved to drivers/spi.

Sergei, do you remember why we haven't used SPI MEM for hyberbus since the beginning? Was it something that we aimed for in a future patch set?

Thanks,
ta

[1]
https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git/tree/include/memory/renesas-rpc-if.h?h=mtd/for-6.8#n22

[2]
https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git/tree/include/linux/spi/spi-mem.h?h=mtd/for-6.8#n99

#10 lore raw
In reply to Tudor Ambarus
Quoted 41 lines · Tudor Ambarus

+ Sergei, Geert, Mark & linux-spi

Hi, Sergei,

Quoted 17 lines · Tudor Ambarus

Hi, Takahiro, Vignesh,

Quoted 5 lines · On 07.04.2023 09:11, [email protected] wrote:

From: Takahiro Kuwano <[email protected]>

This sereis adds support for Infineon S26HL-T/S26HS-T flash family.
https://www.infineon.com/dgdl/Infineon-S26HS01GTGABHM020-DataSheet-v01_00-EN.pdf?fileId=8ac78c8c7f2a768a017f52f2f5182c91

Quoted 7 lines

This family supports two interface modes, SPI mode and Hyperbus mode. The mode can be switched at rutime. The default mode is selected by ordering option and non-volatile user configuration. In hyperbus mode, the device is compatible with S26KL-S/S26KS-S hyperflash family that supports hyperbus only so one of use cases of S26Hx-T is replacement of (or migration from) S26Kx-S. This patch set focuses on particular usage that the device is pre-configured as hyperbus mode for compatibility with S26Kx-S.

Quoted 6 lines

I'm questioning the overall hyperbus software architecture, not your patches per se. IMO hyperbus framework should have been written on top of SPIMEM and the controllers be placed in drivers/spi/. So I'd first address the SPIMEM adoption before adding/accepting new support. Would love to hear more from Vignesh.

RPC is the only multi IO SPI controller that's upstreamed and capable of dealing with hyperflashes, but there are others which are not upstreamed yet (microchip).

Struct ``struct rpcif_op`` [1] duplicates the contents of ``struct spi_mem_op`` [2] which could have been avoided if hyperflash driver was extended with SPI MEM support. This way the RPC hyperbus driver, which is an SPI controller, could have been moved to drivers/spi.

Sergei, do you remember why we haven't used SPI MEM for hyberbus since the beginning? Was it something that we aimed for in a future patch set?

Quoted 9 lines

Thanks,
ta

[1]
https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git/tree/include/memory/renesas-rpc-if.h?h=mtd/for-6.8#n22

[2]
https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git/tree/include/linux/spi/spi-mem.h?h=mtd/for-6.8#n99

The initial hyperflash predates opening up of HyperBus protocol and inclusion of it in xSPI spec. First gen Flashes followed CFI specification and hence made sense to make use of cfi_cmdset_0002.c

We did have a discussion on extending spi_mem to support xSPI profile 2.0 during the RPC_IF [3] [4].

Overall, both Controllers and Flashes have moved away from CFI parallel flash protocol over to xSPI / SPI NOR flash protocol (profile 2.0), so I agree with Tudor's assessment that we need to move towards spi_mem in longer term. So

a) Extend spi_mem_op to support xSPI profile 2.0 transaction template
b) HyperBus layer can then either be a adapter from CFI to spi_mem for CFI compliant devices. And be subsumed completely within SPI NOR for SFDP compliant devices.
c) Move the existing controllers over to new framework.

[3] https://lore.kernel.org/all/[email protected]/
[4] https://lore.kernel.org/all/[email protected]/

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

reviewer
#11 lore raw
Quoted 58 lines · Vignesh
Quoted 41 lines · Tudor Ambarus

+ Sergei, Geert, Mark & linux-spi

Hi, Sergei,

Quoted 17 lines · Tudor Ambarus

Hi, Takahiro, Vignesh,

Quoted 5 lines · On 07.04.2023 09:11, [email protected] wrote:

From: Takahiro Kuwano <[email protected]>

This sereis adds support for Infineon S26HL-T/S26HS-T flash family.
https://www.infineon.com/dgdl/Infineon-S26HS01GTGABHM020-DataSheet-v01_00-EN.pdf?fileId=8ac78c8c7f2a768a017f52f2f5182c91

Quoted 7 lines

This family supports two interface modes, SPI mode and Hyperbus mode. The mode can be switched at rutime. The default mode is selected by ordering option and non-volatile user configuration. In hyperbus mode, the device is compatible with S26KL-S/S26KS-S hyperflash family that supports hyperbus only so one of use cases of S26Hx-T is replacement of (or migration from) S26Kx-S. This patch set focuses on particular usage that the device is pre-configured as hyperbus mode for compatibility with S26Kx-S.

Quoted 6 lines

I'm questioning the overall hyperbus software architecture, not your patches per se. IMO hyperbus framework should have been written on top of SPIMEM and the controllers be placed in drivers/spi/. So I'd first address the SPIMEM adoption before adding/accepting new support. Would love to hear more from Vignesh.

RPC is the only multi IO SPI controller that's upstreamed and capable of dealing with hyperflashes, but there are others which are not upstreamed yet (microchip).

Struct ``struct rpcif_op`` [1] duplicates the contents of ``struct spi_mem_op`` [2] which could have been avoided if hyperflash driver was extended with SPI MEM support. This way the RPC hyperbus driver, which is an SPI controller, could have been moved to drivers/spi.

Sergei, do you remember why we haven't used SPI MEM for hyberbus since the beginning? Was it something that we aimed for in a future patch set?

Quoted 9 lines

Thanks,
ta

[1]
https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git/tree/include/memory/renesas-rpc-if.h?h=mtd/for-6.8#n22

[2]
https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git/tree/include/linux/spi/spi-mem.h?h=mtd/for-6.8#n99

The initial hyperflash predates opening up of HyperBus protocol and inclusion of it in xSPI spec. First gen Flashes followed CFI specification and hence made sense to make use of cfi_cmdset_0002.c

Quoted 8 lines

We did have a discussion on extending spi_mem to support xSPI profile 2.0 during the RPC_IF [3] [4].

Overall, both Controllers and Flashes have moved away from CFI parallel flash protocol over to xSPI / SPI NOR flash protocol (profile 2.0), so I agree with Tudor's assessment that we need to move towards spi_mem in longer term. So

Good, thanks Vignesh! I'll study a bit more and let you know about the progress on this topic.

Cheers,
ta

Quoted 10 lines

a) Extend spi_mem_op to support xSPI profile 2.0 transaction template
b) HyperBus layer can then either be a adapter from CFI to spi_mem for CFI compliant devices. And be subsumed completely within SPI NOR for SFDP compliant devices.
c) Move the existing controllers over to new framework.

[3] https://lore.kernel.org/all/[email protected]/
[4] https://lore.kernel.org/all/[email protected]/

#12 lore raw
Quoted 64 lines · Tudor Ambarus
Quoted 61 lines · Vignesh
Quoted 41 lines · Tudor Ambarus

+ Sergei, Geert, Mark & linux-spi

Hi, Sergei,

Quoted 17 lines · Tudor Ambarus

Hi, Takahiro, Vignesh,

Quoted 5 lines · On 07.04.2023 09:11, [email protected] wrote:

From: Takahiro Kuwano <[email protected]>

This sereis adds support for Infineon S26HL-T/S26HS-T flash family.
https://www.infineon.com/dgdl/Infineon-S26HS01GTGABHM020-DataSheet-v01_00-EN.pdf?fileId=8ac78c8c7f2a768a017f52f2f5182c91

Quoted 7 lines

This family supports two interface modes, SPI mode and Hyperbus mode. The mode can be switched at rutime. The default mode is selected by ordering option and non-volatile user configuration. In hyperbus mode, the device is compatible with S26KL-S/S26KS-S hyperflash family that supports hyperbus only so one of use cases of S26Hx-T is replacement of (or migration from) S26Kx-S. This patch set focuses on particular usage that the device is pre-configured as hyperbus mode for compatibility with S26Kx-S.

Quoted 6 lines

I'm questioning the overall hyperbus software architecture, not your patches per se. IMO hyperbus framework should have been written on top of SPIMEM and the controllers be placed in drivers/spi/. So I'd first address the SPIMEM adoption before adding/accepting new support. Would love to hear more from Vignesh.

RPC is the only multi IO SPI controller that's upstreamed and capable of dealing with hyperflashes, but there are others which are not upstreamed yet (microchip).

Struct ``struct rpcif_op`` [1] duplicates the contents of ``struct spi_mem_op`` [2] which could have been avoided if hyperflash driver was extended with SPI MEM support. This way the RPC hyperbus driver, which is an SPI controller, could have been moved to drivers/spi.

Sergei, do you remember why we haven't used SPI MEM for hyberbus since the beginning? Was it something that we aimed for in a future patch set?

Quoted 9 lines

Thanks,
ta

[1]
https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git/tree/include/memory/renesas-rpc-if.h?h=mtd/for-6.8#n22

[2]
https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git/tree/include/linux/spi/spi-mem.h?h=mtd/for-6.8#n99

The initial hyperflash predates opening up of HyperBus protocol and inclusion of it in xSPI spec. First gen Flashes followed CFI specification and hence made sense to make use of cfi_cmdset_0002.c

We did have a discussion on extending spi_mem to support xSPI profile 2.0 during the RPC_IF [3] [4].

Quoted 8 lines
Quoted 5 lines

Overall, both Controllers and Flashes have moved away from CFI parallel flash protocol over to xSPI / SPI NOR flash protocol (profile 2.0), so I agree with Tudor's assessment that we need to move towards spi_mem in longer term. So

Good, thanks Vignesh! I'll study a bit more and let you know about the progress on this topic.

Hi All

At STMicroelectronics we got an OSPI block which is supporting both OSPI and HyperBus protocol similarly to the mentioned RPC-IF.

This means that we intend to split our implementation in 3 drivers as RPC-IF:
_ backend driver including common source code to OSPI and HyperBus _ OSPI frontend driver
_ HyperBus frontend driver

Following this discussion thread, we are wondering if it will be the right direction to choose in order to propose this implementation to MTD mailing list.

Have you an idea about time scale regarding the HyperBus migration over spi-mem ?

Thanks
Patrice

Quoted 11 lines

Cheers,
ta

Quoted 7 lines

a) Extend spi_mem_op to support xSPI profile 2.0 transaction template
b) HyperBus layer can then either be a adapter from CFI to spi_mem for CFI compliant devices. And be subsumed completely within SPI NOR for SFDP compliant devices.
c) Move the existing controllers over to new framework.

Quoted 7 lines
Quoted 3 lines

[3] https://lore.kernel.org/all/[email protected]/
[4] https://lore.kernel.org/all/[email protected]/

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

reviewer
#13 lore raw
Quoted 73 lines · Patrice CHOTARD
Quoted 70 lines · Tudor Ambarus
Quoted 66 lines · Vignesh
Quoted 41 lines · Tudor Ambarus

+ Sergei, Geert, Mark & linux-spi

Hi, Sergei,

Quoted 17 lines · Tudor Ambarus

Hi, Takahiro, Vignesh,

Quoted 5 lines · On 07.04.2023 09:11, [email protected] wrote:

From: Takahiro Kuwano <[email protected]>

This sereis adds support for Infineon S26HL-T/S26HS-T flash family.
https://www.infineon.com/dgdl/Infineon-S26HS01GTGABHM020-DataSheet-v01_00-EN.pdf?fileId=8ac78c8c7f2a768a017f52f2f5182c91

Quoted 7 lines

This family supports two interface modes, SPI mode and Hyperbus mode. The mode can be switched at rutime. The default mode is selected by ordering option and non-volatile user configuration. In hyperbus mode, the device is compatible with S26KL-S/S26KS-S hyperflash family that supports hyperbus only so one of use cases of S26Hx-T is replacement of (or migration from) S26Kx-S. This patch set focuses on particular usage that the device is pre-configured as hyperbus mode for compatibility with S26Kx-S.

Quoted 6 lines

I'm questioning the overall hyperbus software architecture, not your patches per se. IMO hyperbus framework should have been written on top of SPIMEM and the controllers be placed in drivers/spi/. So I'd first address the SPIMEM adoption before adding/accepting new support. Would love to hear more from Vignesh.

RPC is the only multi IO SPI controller that's upstreamed and capable of dealing with hyperflashes, but there are others which are not upstreamed yet (microchip).

Struct ``struct rpcif_op`` [1] duplicates the contents of ``struct spi_mem_op`` [2] which could have been avoided if hyperflash driver was extended with SPI MEM support. This way the RPC hyperbus driver, which is an SPI controller, could have been moved to drivers/spi.

Sergei, do you remember why we haven't used SPI MEM for hyberbus since the beginning? Was it something that we aimed for in a future patch set?

Quoted 9 lines

Thanks,
ta

[1]
https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git/tree/include/memory/renesas-rpc-if.h?h=mtd/for-6.8#n22

[2]
https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git/tree/include/linux/spi/spi-mem.h?h=mtd/for-6.8#n99

The initial hyperflash predates opening up of HyperBus protocol and inclusion of it in xSPI spec. First gen Flashes followed CFI specification and hence made sense to make use of cfi_cmdset_0002.c

We did have a discussion on extending spi_mem to support xSPI profile 2.0 during the RPC_IF [3] [4].

Overall, both Controllers and Flashes have moved away from CFI parallel flash protocol over to xSPI / SPI NOR flash protocol (profile 2.0), so I agree with Tudor's assessment that we need to move towards spi_mem in longer term. So

Quoted 4 lines
Quoted 2 lines

Good, thanks Vignesh! I'll study a bit more and let you know about the progress on this topic.

Hi All

Hi,

Quoted 11 lines

At STMicroelectronics we got an OSPI block which is supporting both OSPI and HyperBus protocol similarly to the mentioned RPC-IF.

This means that we intend to split our implementation in 3 drivers as RPC-IF:
_ backend driver including common source code to OSPI and HyperBus _ OSPI frontend driver
_ HyperBus frontend driver

Following this discussion thread, we are wondering if it will be the right direction to choose in order to propose this implementation to MTD mailing list.

I think the right direction would be to have hyperflash on top of SPIMEM, and the SPI controller under drivers/spi.

Quoted 3 lines

Have you an idea about time scale regarding the HyperBus migration over spi-mem ?

No, sorry. It's at best effort from my side. Happy to review proposals though.

Quoted 22 lines

Thanks
Patrice

Quoted 18 lines

Cheers,
ta

Quoted 10 lines

a) Extend spi_mem_op to support xSPI profile 2.0 transaction template
b) HyperBus layer can then either be a adapter from CFI to spi_mem for CFI compliant devices. And be subsumed completely within SPI NOR for SFDP compliant devices.
c) Move the existing controllers over to new framework.

[3] https://lore.kernel.org/all/[email protected]/
[4] https://lore.kernel.org/all/[email protected]/

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

#14 lore raw
Quoted 92 lines · Tudor Ambarus
Quoted 73 lines · Patrice CHOTARD
Quoted 70 lines · Tudor Ambarus
Quoted 66 lines · Vignesh
Quoted 41 lines · Tudor Ambarus

+ Sergei, Geert, Mark & linux-spi

Hi, Sergei,

Quoted 17 lines · Tudor Ambarus

Hi, Takahiro, Vignesh,

Quoted 5 lines · On 07.04.2023 09:11, [email protected] wrote:

From: Takahiro Kuwano <[email protected]>

This sereis adds support for Infineon S26HL-T/S26HS-T flash family.
https://www.infineon.com/dgdl/Infineon-S26HS01GTGABHM020-DataSheet-v01_00-EN.pdf?fileId=8ac78c8c7f2a768a017f52f2f5182c91

Quoted 7 lines

This family supports two interface modes, SPI mode and Hyperbus mode. The mode can be switched at rutime. The default mode is selected by ordering option and non-volatile user configuration. In hyperbus mode, the device is compatible with S26KL-S/S26KS-S hyperflash family that supports hyperbus only so one of use cases of S26Hx-T is replacement of (or migration from) S26Kx-S. This patch set focuses on particular usage that the device is pre-configured as hyperbus mode for compatibility with S26Kx-S.

Quoted 6 lines

I'm questioning the overall hyperbus software architecture, not your patches per se. IMO hyperbus framework should have been written on top of SPIMEM and the controllers be placed in drivers/spi/. So I'd first address the SPIMEM adoption before adding/accepting new support. Would love to hear more from Vignesh.

RPC is the only multi IO SPI controller that's upstreamed and capable of dealing with hyperflashes, but there are others which are not upstreamed yet (microchip).

Struct ``struct rpcif_op`` [1] duplicates the contents of ``struct spi_mem_op`` [2] which could have been avoided if hyperflash driver was extended with SPI MEM support. This way the RPC hyperbus driver, which is an SPI controller, could have been moved to drivers/spi.

Sergei, do you remember why we haven't used SPI MEM for hyberbus since the beginning? Was it something that we aimed for in a future patch set?

Quoted 9 lines

Thanks,
ta

[1]
https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git/tree/include/memory/renesas-rpc-if.h?h=mtd/for-6.8#n22

[2]
https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git/tree/include/linux/spi/spi-mem.h?h=mtd/for-6.8#n99

The initial hyperflash predates opening up of HyperBus protocol and inclusion of it in xSPI spec. First gen Flashes followed CFI specification and hence made sense to make use of cfi_cmdset_0002.c

We did have a discussion on extending spi_mem to support xSPI profile 2.0 during the RPC_IF [3] [4].

Overall, both Controllers and Flashes have moved away from CFI parallel flash protocol over to xSPI / SPI NOR flash protocol (profile 2.0), so I agree with Tudor's assessment that we need to move towards spi_mem in longer term. So

Quoted 4 lines
Quoted 2 lines

Good, thanks Vignesh! I'll study a bit more and let you know about the progress on this topic.

Hi All

Hi,

Quoted 9 lines

At STMicroelectronics we got an OSPI block which is supporting both OSPI and HyperBus protocol similarly to the mentioned RPC-IF.

This means that we intend to split our implementation in 3 drivers as RPC-IF:
_ backend driver including common source code to OSPI and HyperBus _ OSPI frontend driver
_ HyperBus frontend driver

Quoted 5 lines
Quoted 2 lines

Following this discussion thread, we are wondering if it will be the right direction to choose in order to propose this implementation to MTD mailing list.

I think the right direction would be to have hyperflash on top of SPIMEM, and the SPI controller under drivers/spi.

To be more precise, when you say "would be to have", you mean you will NAK an implementation in 3 drivers as RPC-IF ?

Patrice

Quoted 29 lines
Quoted 3 lines

Have you an idea about time scale regarding the HyperBus migration over spi-mem ?

No, sorry. It's at best effort from my side. Happy to review proposals though.

Quoted 22 lines

Thanks
Patrice

Quoted 18 lines

Cheers,
ta

Quoted 10 lines

a) Extend spi_mem_op to support xSPI profile 2.0 transaction template
b) HyperBus layer can then either be a adapter from CFI to spi_mem for CFI compliant devices. And be subsumed completely within SPI NOR for SFDP compliant devices.
c) Move the existing controllers over to new framework.

[3] https://lore.kernel.org/all/[email protected]/
[4] https://lore.kernel.org/all/[email protected]/

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

reviewer
#15 lore raw
Quoted 98 lines · Patrice CHOTARD
Quoted 95 lines · Tudor Ambarus
Quoted 73 lines · Patrice CHOTARD
Quoted 70 lines · Tudor Ambarus
Quoted 66 lines · Vignesh
Quoted 41 lines · Tudor Ambarus

+ Sergei, Geert, Mark & linux-spi

Hi, Sergei,

Quoted 17 lines · Tudor Ambarus

Hi, Takahiro, Vignesh,

Quoted 5 lines · On 07.04.2023 09:11, [email protected] wrote:

From: Takahiro Kuwano <[email protected]>

This sereis adds support for Infineon S26HL-T/S26HS-T flash family.
https://www.infineon.com/dgdl/Infineon-S26HS01GTGABHM020-DataSheet-v01_00-EN.pdf?fileId=8ac78c8c7f2a768a017f52f2f5182c91

Quoted 7 lines

This family supports two interface modes, SPI mode and Hyperbus mode. The mode can be switched at rutime. The default mode is selected by ordering option and non-volatile user configuration. In hyperbus mode, the device is compatible with S26KL-S/S26KS-S hyperflash family that supports hyperbus only so one of use cases of S26Hx-T is replacement of (or migration from) S26Kx-S. This patch set focuses on particular usage that the device is pre-configured as hyperbus mode for compatibility with S26Kx-S.

Quoted 6 lines

I'm questioning the overall hyperbus software architecture, not your patches per se. IMO hyperbus framework should have been written on top of SPIMEM and the controllers be placed in drivers/spi/. So I'd first address the SPIMEM adoption before adding/accepting new support. Would love to hear more from Vignesh.

RPC is the only multi IO SPI controller that's upstreamed and capable of dealing with hyperflashes, but there are others which are not upstreamed yet (microchip).

Struct ``struct rpcif_op`` [1] duplicates the contents of ``struct spi_mem_op`` [2] which could have been avoided if hyperflash driver was extended with SPI MEM support. This way the RPC hyperbus driver, which is an SPI controller, could have been moved to drivers/spi.

Sergei, do you remember why we haven't used SPI MEM for hyberbus since the beginning? Was it something that we aimed for in a future patch set?

Quoted 9 lines

Thanks,
ta

[1]
https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git/tree/include/memory/renesas-rpc-if.h?h=mtd/for-6.8#n22

[2]
https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git/tree/include/linux/spi/spi-mem.h?h=mtd/for-6.8#n99

The initial hyperflash predates opening up of HyperBus protocol and inclusion of it in xSPI spec. First gen Flashes followed CFI specification and hence made sense to make use of cfi_cmdset_0002.c

We did have a discussion on extending spi_mem to support xSPI profile 2.0 during the RPC_IF [3] [4].

Overall, both Controllers and Flashes have moved away from CFI parallel flash protocol over to xSPI / SPI NOR flash protocol (profile 2.0), so I agree with Tudor's assessment that we need to move towards spi_mem in longer term. So

Quoted 4 lines
Quoted 2 lines

Good, thanks Vignesh! I'll study a bit more and let you know about the progress on this topic.

Hi All

Hi,

Quoted 11 lines

At STMicroelectronics we got an OSPI block which is supporting both OSPI and HyperBus protocol similarly to the mentioned RPC-IF.

This means that we intend to split our implementation in 3 drivers as RPC-IF:
_ backend driver including common source code to OSPI and HyperBus _ OSPI frontend driver
_ HyperBus frontend driver

Following this discussion thread, we are wondering if it will be the right direction to choose in order to propose this implementation to MTD mailing list.

Quoted 7 lines
Quoted 2 lines

I think the right direction would be to have hyperflash on top of SPIMEM, and the SPI controller under drivers/spi.

To be more precise, when you say "would be to have", you mean you will NAK an implementation in 3 drivers as RPC-IF ?

Yes. I think we should move towards SPIMEM adoption, don't you?

Quoted 30 lines
Quoted 30 lines
Quoted 4 lines

Have you an idea about time scale regarding the HyperBus migration over spi-mem ?

No, sorry. It's at best effort from my side. Happy to review proposals though.

Quoted 22 lines

Thanks
Patrice

Quoted 18 lines

Cheers,
ta

Quoted 10 lines

a) Extend spi_mem_op to support xSPI profile 2.0 transaction template
b) HyperBus layer can then either be a adapter from CFI to spi_mem for CFI compliant devices. And be subsumed completely within SPI NOR for SFDP compliant devices.
c) Move the existing controllers over to new framework.

[3] https://lore.kernel.org/all/[email protected]/
[4] https://lore.kernel.org/all/[email protected]/

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/