Skip to contentSkip to conversation

spi: cadence-qspi: Add disable STIG mode quikrs.

PATCH Superseded Boon Khai Ng 2 participants 4 messages Mar 12, 2025 – Apr 16, 2025 SPI

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 spi: cadence-qspi: Add disable STIG mode quikrs.

Adding quirk to disable STIG mode since cadence controller has issue for read/write using the STIG mode. STIG mode is enabled by default since 2023.04 for small read/write(<8bytes).

Updated STIG mode reading from dev_get_driver_data by assigning to platdata struct before read quirks variable.

The STIG mode is disabled for normal read case and enabled for QSPI Jedec ID read/write since it requires STIG read/write.

---
 drivers/spi/cadence_qspi.c | 29 +++++++++++++++++++++++++----
 drivers/spi/cadence_qspi.h |  7 +++++++
 2 files changed, 32 insertions(+), 4 deletions(-)
drivers/spi/cadence_qspi.c +25 -4
index 623904ecda..c2990ac833 100644
@@ -27,6 +27,9 @@
 #define CQSPI_READ			2
 #define CQSPI_WRITE			3
 
+/* Quirks */
+#define CQSPI_DISABLE_STIG_MODE		BIT(0)
+
 __weak int cadence_qspi_apb_dma_read(struct cadence_spi_priv *priv,
 				     const struct spi_mem_op *op)
 {
@@ -217,6 +220,7 @@ static int cadence_spi_probe(struct udevice *bus)
 	priv->tsd2d_ns		= plat->tsd2d_ns;
 	priv->tchsh_ns		= plat->tchsh_ns;
 	priv->tslch_ns		= plat->tslch_ns;
+	priv->quirks		= plat->quirks;
 
 	if (IS_ENABLED(CONFIG_ZYNQMP_FIRMWARE))
 		xilinx_pm_request(PM_REQUEST_NODE, PM_DEV_OSPI,
@@ -307,12 +311,16 @@ static int cadence_spi_mem_exec_op(struct spi_slave *spi,
 		 * which is unsupported on some flash devices during register
 		 * reads, prefer STIG mode for such small reads.
 		 */
-		if (op->data.nbytes <= CQSPI_STIG_DATA_LEN_MAX)
+		if (!op->addr.nbytes ||
+		    (op->data.nbytes <= CQSPI_STIG_DATA_LEN_MAX &&
+		     !(priv->quirks & CQSPI_DISABLE_STIG_MODE)))
 			mode = CQSPI_STIG_READ;
 		else
 			mode = CQSPI_READ;
 	} else {
-		if (op->data.nbytes <= CQSPI_STIG_DATA_LEN_MAX)
+		if (!op->addr.nbytes || !op->data.buf.out ||
+		    (op->data.nbytes <= CQSPI_STIG_DATA_LEN_MAX &&
+		     !(priv->quirks & CQSPI_DISABLE_STIG_MODE)))
 			mode = CQSPI_STIG_WRITE;
 		else
 			mode = CQSPI_WRITE;
@@ -427,6 +435,10 @@ static int cadence_spi_of_to_plat(struct udevice *bus)
 	plat->read_delay = ofnode_read_s32_default(subnode, "cdns,read-delay",
 						   -1);
 
+	const struct cqspi_driver_platdata *drvdata =
+		(struct cqspi_driver_platdata *)dev_get_driver_data(bus);
+	plat->quirks = drvdata->quirks;
+
 	debug("%s: regbase=%p ahbbase=%p max-frequency=%d page-size=%d\n",
 	      __func__, plat->regbase, plat->ahbbase, plat->max_hz,
 	      plat->page_size);
@@ -449,9 +461,18 @@ static const struct dm_spi_ops cadence_spi_ops = {
 	 */
 };
 
+static const struct cqspi_driver_platdata cdns_qspi = {
+	.quirks = CQSPI_DISABLE_STIG_MODE,
+};
+
 static const struct udevice_id cadence_spi_ids[] = {
-	{ .compatible = "cdns,qspi-nor" },
-	{ .compatible = "ti,am654-ospi" },
+	{
+		.compatible = "cdns,qspi-nor",
+		.data = (ulong)&cdns_qspi,
+	},
+	{
+		.compatible = "ti,am654-ospi"
+	},
 	{ }
 };
 
drivers/spi/cadence_qspi.h +7 -0
index 1f9125cd23..e6ea9e6c1f 100644
@@ -220,6 +220,7 @@ struct cadence_spi_plat {
 	u32		tsd2d_ns;
 	u32		tchsh_ns;
 	u32		tslch_ns;
+	u32		quirks;
 
 	bool            is_dma;
 };
@@ -251,6 +252,7 @@ struct cadence_spi_priv {
 	u32		tsd2d_ns;
 	u32		tchsh_ns;
 	u32		tslch_ns;
+	u32		quirks;
 	u8              edge_mode;
 	u8              dll_mode;
 	bool		extra_dummy;
@@ -266,6 +268,11 @@ struct cadence_spi_priv {
 	bool		dtr;
 };
 
+struct cqspi_driver_platdata {
+	u32 hwcaps_mask;
+	u32 quirks;
+};
+
 /* Functions call declaration */
 void cadence_qspi_apb_controller_init(struct cadence_spi_priv *priv);
 void cadence_qspi_apb_controller_enable(void *reg_base_addr);
Signature · 1 line
2.25.1
#1 lore raw

Hi Tom, Jagan

I hope you're doing well. I just wanted to follow up on the patch I submitted for review some time ago. I understand you're likely busy, but I would really appreciate it if you could take a look when you get a chance.

If there's anything you need from my side to facilitate
the review process, feel free to let me know.

Thank you in advance for your time and assistance!

Regards,
Boon Khai

#2 lore raw
In reply to Boon Khai Ng

Hi Boon Khai,

Quoted 25 lines

-----Original Message-----
From: Ng, Boon Khai <[email protected]>
Sent: Wednesday, March 12, 2025 5:10 PM
To: Jagan Teki <[email protected]>; Tom Rini <[email protected]>; Michal Simek <[email protected]>; Venkatesh Yadav Abbarapu <[email protected]>; Tejas Bhumkar <[email protected]>; Cédric Le Goater <[email protected]> William Zhang <[email protected]>; U-boot Openlist <u- [email protected]>
Cc: Hea, Kok Kiang <[email protected]>; Maniyam, Dinesh <[email protected]>; Chee, Tien Fong <[email protected]>; Zamri, Muhammad Hazim Izzat <[email protected]>; Meng, Tingting <[email protected]>; Yuslaimi, Alif Zakuan <[email protected]>; Ng, Boon Khai <[email protected]>
Subject: [CAD QSPI v1] spi: cadence-qspi: Add disable STIG mode quikrs.

Adding quirk to disable STIG mode since cadence controller has issue for read/write using the STIG mode. STIG mode is enabled by default since 2023.04 for small read/write(<8bytes).

Updated STIG mode reading from dev_get_driver_data by assigning to platdata struct before read quirks variable.

Quoted 9 lines

The STIG mode is disabled for normal read case and enabled for QSPI Jedec ID read/write since it requires STIG read/write.

---
 drivers/spi/cadence_qspi.c | 29 +++++++++++++++++++++++++----
drivers/spi/cadence_qspi.h |  7 +++++++
 2 files changed, 32 insertions(+), 4 deletions(-)

I think you can add the reference of the kernel patch https://lore.kernel.org/all/[email protected]/T/ you ported to this patch in commit message.

[...]

Best regards,
Tien Fong