public inbox for devicetree@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] spi: cadence-quadspi: Add support for device reset
@ 2024-11-20 12:09 Srikanth Boyapally
  2024-11-20 12:09 ` [PATCH 1/3] dt-bindings: qspi: cdns,qspi-nor: Add compatible string to support OSPI controller on Versal Gen2 platform Srikanth Boyapally
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Srikanth Boyapally @ 2024-11-20 12:09 UTC (permalink / raw)
  To: broonie, robh, krzk+dt, conor+dt, vaishnav.a
  Cc: linux-spi, devicetree, linux-kernel, git, srinivas.goud,
	radhey.shyam.pandey, srikanthboyapally2016, srikanth.boyapally,
	sai.krishna.potthuri

Add support for device reset via OSPI on Versal Gen 2 platform.

Srikanth Boyapally (3):
  dt-bindings: qspi: cdns,qspi-nor: Add compatible string to support
    OSPI controller on Versal Gen2 platform
  spi: cadence-quadspi: Use quirks to set dma_set_mask instead of
    compatible string for 64-bit DMA support
  spi: cadence-quadspi: Support for device reset via OSPI controller

 .../bindings/spi/cdns,qspi-nor.yaml           |  1 +
 drivers/spi/spi-cadence-quadspi.c             | 47 +++++++++++++++++--
 2 files changed, 44 insertions(+), 4 deletions(-)

-- 
2.34.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/3] dt-bindings: qspi: cdns,qspi-nor: Add compatible string to support OSPI controller on Versal Gen2 platform
  2024-11-20 12:09 [PATCH 0/3] spi: cadence-quadspi: Add support for device reset Srikanth Boyapally
@ 2024-11-20 12:09 ` Srikanth Boyapally
  2024-11-20 16:33   ` Conor Dooley
  2024-11-20 12:09 ` [PATCH 2/3] spi: cadence-quadspi: Use quirks to set dma_set_mask instead of compatible string for 64-bit DMA support Srikanth Boyapally
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 6+ messages in thread
From: Srikanth Boyapally @ 2024-11-20 12:09 UTC (permalink / raw)
  To: broonie, robh, krzk+dt, conor+dt, vaishnav.a
  Cc: linux-spi, devicetree, linux-kernel, git, srinivas.goud,
	radhey.shyam.pandey, srikanthboyapally2016, srikanth.boyapally,
	sai.krishna.potthuri

Add compatible string to support OSPI controller device reset IP
feature on Versal Gen2 platform.

Signed-off-by: Srikanth Boyapally <srikanth.boyapally@amd.com>
---
 Documentation/devicetree/bindings/spi/cdns,qspi-nor.yaml | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/spi/cdns,qspi-nor.yaml b/Documentation/devicetree/bindings/spi/cdns,qspi-nor.yaml
index d48ecd6cd5ad..b6bc71d19286 100644
--- a/Documentation/devicetree/bindings/spi/cdns,qspi-nor.yaml
+++ b/Documentation/devicetree/bindings/spi/cdns,qspi-nor.yaml
@@ -68,6 +68,7 @@ properties:
       - items:
           - enum:
               - amd,pensando-elba-qspi
+              - amd,versal2-ospi
               - intel,lgm-qspi
               - intel,socfpga-qspi
               - mobileye,eyeq5-ospi
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/3] spi: cadence-quadspi: Use quirks to set dma_set_mask instead of compatible string for 64-bit DMA support
  2024-11-20 12:09 [PATCH 0/3] spi: cadence-quadspi: Add support for device reset Srikanth Boyapally
  2024-11-20 12:09 ` [PATCH 1/3] dt-bindings: qspi: cdns,qspi-nor: Add compatible string to support OSPI controller on Versal Gen2 platform Srikanth Boyapally
@ 2024-11-20 12:09 ` Srikanth Boyapally
  2024-11-20 12:09 ` [PATCH 3/3] spi: cadence-quadspi: Support for device reset via OSPI controller Srikanth Boyapally
  2024-12-02 17:36 ` [PATCH 0/3] spi: cadence-quadspi: Add support for device reset Mark Brown
  3 siblings, 0 replies; 6+ messages in thread
From: Srikanth Boyapally @ 2024-11-20 12:09 UTC (permalink / raw)
  To: broonie, robh, krzk+dt, conor+dt, vaishnav.a
  Cc: linux-spi, devicetree, linux-kernel, git, srinivas.goud,
	radhey.shyam.pandey, srikanthboyapally2016, srikanth.boyapally,
	sai.krishna.potthuri

Remove device compatible property check and instead use
quirks to program DMA addressing.

Signed-off-by: Srikanth Boyapally <srikanth.boyapally@amd.com>
---
 drivers/spi/spi-cadence-quadspi.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/spi/spi-cadence-quadspi.c b/drivers/spi/spi-cadence-quadspi.c
index 1755ca026f08..fb75400518e0 100644
--- a/drivers/spi/spi-cadence-quadspi.c
+++ b/drivers/spi/spi-cadence-quadspi.c
@@ -43,6 +43,7 @@ static_assert(CQSPI_MAX_CHIPSELECT <= SPI_CS_CNT_MAX);
 #define CQSPI_SLOW_SRAM		BIT(4)
 #define CQSPI_NEEDS_APB_AHB_HAZARD_WAR	BIT(5)
 #define CQSPI_RD_NO_IRQ			BIT(6)
+#define CQSPI_DMA_SET_MASK		BIT(7)
 
 /* Capabilities */
 #define CQSPI_SUPPORTS_OCTAL		BIT(0)
@@ -1881,8 +1882,7 @@ static int cqspi_probe(struct platform_device *pdev)
 				goto probe_reset_failed;
 		}
 
-		if (of_device_is_compatible(pdev->dev.of_node,
-					    "xlnx,versal-ospi-1.0")) {
+		if (ddata->quirks & CQSPI_DMA_SET_MASK) {
 			ret = dma_set_mask(&pdev->dev, DMA_BIT_MASK(64));
 			if (ret)
 				goto probe_reset_failed;
@@ -2048,7 +2048,8 @@ static const struct cqspi_driver_platdata socfpga_qspi = {
 
 static const struct cqspi_driver_platdata versal_ospi = {
 	.hwcaps_mask = CQSPI_SUPPORTS_OCTAL,
-	.quirks = CQSPI_DISABLE_DAC_MODE | CQSPI_SUPPORT_EXTERNAL_DMA,
+	.quirks = CQSPI_DISABLE_DAC_MODE | CQSPI_SUPPORT_EXTERNAL_DMA
+			| CQSPI_DMA_SET_MASK,
 	.indirect_read_dma = cqspi_versal_indirect_read_dma,
 	.get_dma_status = cqspi_get_versal_dma_status,
 };
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 3/3] spi: cadence-quadspi: Support for device reset via OSPI controller
  2024-11-20 12:09 [PATCH 0/3] spi: cadence-quadspi: Add support for device reset Srikanth Boyapally
  2024-11-20 12:09 ` [PATCH 1/3] dt-bindings: qspi: cdns,qspi-nor: Add compatible string to support OSPI controller on Versal Gen2 platform Srikanth Boyapally
  2024-11-20 12:09 ` [PATCH 2/3] spi: cadence-quadspi: Use quirks to set dma_set_mask instead of compatible string for 64-bit DMA support Srikanth Boyapally
@ 2024-11-20 12:09 ` Srikanth Boyapally
  2024-12-02 17:36 ` [PATCH 0/3] spi: cadence-quadspi: Add support for device reset Mark Brown
  3 siblings, 0 replies; 6+ messages in thread
From: Srikanth Boyapally @ 2024-11-20 12:09 UTC (permalink / raw)
  To: broonie, robh, krzk+dt, conor+dt, vaishnav.a
  Cc: linux-spi, devicetree, linux-kernel, git, srinivas.goud,
	radhey.shyam.pandey, srikanthboyapally2016, srikanth.boyapally,
	sai.krishna.potthuri

Add support for flash device reset via ospi controller, instead of
using GPIO, as ospi IP has device reset feature on Versal Gen2 platform.

Signed-off-by: Srikanth Boyapally <srikanth.boyapally@amd.com>
---
 drivers/spi/spi-cadence-quadspi.c | 40 ++++++++++++++++++++++++++++++-
 1 file changed, 39 insertions(+), 1 deletion(-)

diff --git a/drivers/spi/spi-cadence-quadspi.c b/drivers/spi/spi-cadence-quadspi.c
index fb75400518e0..82df3d0683d6 100644
--- a/drivers/spi/spi-cadence-quadspi.c
+++ b/drivers/spi/spi-cadence-quadspi.c
@@ -44,6 +44,7 @@ static_assert(CQSPI_MAX_CHIPSELECT <= SPI_CS_CNT_MAX);
 #define CQSPI_NEEDS_APB_AHB_HAZARD_WAR	BIT(5)
 #define CQSPI_RD_NO_IRQ			BIT(6)
 #define CQSPI_DMA_SET_MASK		BIT(7)
+#define CQSPI_SUPPORT_DEVICE_RESET	BIT(8)
 
 /* Capabilities */
 #define CQSPI_SUPPORTS_OCTAL		BIT(0)
@@ -110,7 +111,7 @@ struct cqspi_st {
 
 struct cqspi_driver_platdata {
 	u32 hwcaps_mask;
-	u8 quirks;
+	u16 quirks;
 	int (*indirect_read_dma)(struct cqspi_flash_pdata *f_pdata,
 				 u_char *rxbuf, loff_t from_addr, size_t n_rx);
 	u32 (*get_dma_status)(struct cqspi_st *cqspi);
@@ -145,6 +146,8 @@ struct cqspi_driver_platdata {
 #define CQSPI_REG_CONFIG_IDLE_LSB		31
 #define CQSPI_REG_CONFIG_CHIPSELECT_MASK	0xF
 #define CQSPI_REG_CONFIG_BAUD_MASK		0xF
+#define CQSPI_REG_CONFIG_RESET_PIN_FLD_MASK    BIT(5)
+#define CQSPI_REG_CONFIG_RESET_CFG_FLD_MASK    BIT(6)
 
 #define CQSPI_REG_RD_INSTR			0x04
 #define CQSPI_REG_RD_INSTR_OPCODE_LSB		0
@@ -831,6 +834,25 @@ static int cqspi_indirect_read_execute(struct cqspi_flash_pdata *f_pdata,
 	return ret;
 }
 
+static void cqspi_device_reset(struct cqspi_st *cqspi)
+{
+	u32 reg;
+
+	reg = readl(cqspi->iobase + CQSPI_REG_CONFIG);
+	reg |= CQSPI_REG_CONFIG_RESET_CFG_FLD_MASK;
+	writel(reg, cqspi->iobase + CQSPI_REG_CONFIG);
+	/*
+	 * NOTE: Delay timing implementation is derived from
+	 * spi_nor_hw_reset()
+	 */
+	writel(reg & ~CQSPI_REG_CONFIG_RESET_PIN_FLD_MASK, cqspi->iobase + CQSPI_REG_CONFIG);
+	usleep_range(1, 5);
+	writel(reg | CQSPI_REG_CONFIG_RESET_PIN_FLD_MASK, cqspi->iobase + CQSPI_REG_CONFIG);
+	usleep_range(100, 150);
+	writel(reg & ~CQSPI_REG_CONFIG_RESET_PIN_FLD_MASK, cqspi->iobase + CQSPI_REG_CONFIG);
+	usleep_range(1000, 1200);
+}
+
 static void cqspi_controller_enable(struct cqspi_st *cqspi, bool enable)
 {
 	void __iomem *reg_base = cqspi->iobase;
@@ -1912,6 +1934,9 @@ static int cqspi_probe(struct platform_device *pdev)
 
 	host->num_chipselect = cqspi->num_chipselect;
 
+	if (ddata->quirks & CQSPI_SUPPORT_DEVICE_RESET)
+		cqspi_device_reset(cqspi);
+
 	if (cqspi->use_direct_mode) {
 		ret = cqspi_request_mmap_dma(cqspi);
 		if (ret == -EPROBE_DEFER)
@@ -2054,6 +2079,15 @@ static const struct cqspi_driver_platdata versal_ospi = {
 	.get_dma_status = cqspi_get_versal_dma_status,
 };
 
+static const struct cqspi_driver_platdata versal2_ospi = {
+	.hwcaps_mask = CQSPI_SUPPORTS_OCTAL,
+	.quirks = CQSPI_DISABLE_DAC_MODE | CQSPI_SUPPORT_EXTERNAL_DMA
+			| CQSPI_DMA_SET_MASK
+			| CQSPI_SUPPORT_DEVICE_RESET,
+	.indirect_read_dma = cqspi_versal_indirect_read_dma,
+	.get_dma_status = cqspi_get_versal_dma_status,
+};
+
 static const struct cqspi_driver_platdata jh7110_qspi = {
 	.quirks = CQSPI_DISABLE_DAC_MODE,
 	.jh7110_clk_init = cqspi_jh7110_clk_init,
@@ -2106,6 +2140,10 @@ static const struct of_device_id cqspi_dt_ids[] = {
 		.compatible = "mobileye,eyeq5-ospi",
 		.data = &mobileye_eyeq5_ospi,
 	},
+	{
+		.compatible = "amd,versal2-ospi",
+		.data = &versal2_ospi,
+	},
 	{ /* end of table */ }
 };
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/3] dt-bindings: qspi: cdns,qspi-nor: Add compatible string to support OSPI controller on Versal Gen2 platform
  2024-11-20 12:09 ` [PATCH 1/3] dt-bindings: qspi: cdns,qspi-nor: Add compatible string to support OSPI controller on Versal Gen2 platform Srikanth Boyapally
@ 2024-11-20 16:33   ` Conor Dooley
  0 siblings, 0 replies; 6+ messages in thread
From: Conor Dooley @ 2024-11-20 16:33 UTC (permalink / raw)
  To: Srikanth Boyapally
  Cc: broonie, robh, krzk+dt, conor+dt, vaishnav.a, linux-spi,
	devicetree, linux-kernel, git, srinivas.goud, radhey.shyam.pandey,
	srikanthboyapally2016, sai.krishna.potthuri

[-- Attachment #1: Type: text/plain, Size: 298 bytes --]

On Wed, Nov 20, 2024 at 05:39:49PM +0530, Srikanth Boyapally wrote:
> Add compatible string to support OSPI controller device reset IP
> feature on Versal Gen2 platform.
> 
> Signed-off-by: Srikanth Boyapally <srikanth.boyapally@amd.com>

Acked-by: Conor Dooley <conor.dooley@microchip.com>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 0/3] spi: cadence-quadspi: Add support for device reset
  2024-11-20 12:09 [PATCH 0/3] spi: cadence-quadspi: Add support for device reset Srikanth Boyapally
                   ` (2 preceding siblings ...)
  2024-11-20 12:09 ` [PATCH 3/3] spi: cadence-quadspi: Support for device reset via OSPI controller Srikanth Boyapally
@ 2024-12-02 17:36 ` Mark Brown
  3 siblings, 0 replies; 6+ messages in thread
From: Mark Brown @ 2024-12-02 17:36 UTC (permalink / raw)
  To: robh, krzk+dt, conor+dt, vaishnav.a, Srikanth Boyapally
  Cc: linux-spi, devicetree, linux-kernel, git, srinivas.goud,
	radhey.shyam.pandey, srikanthboyapally2016, sai.krishna.potthuri

On Wed, 20 Nov 2024 17:39:48 +0530, Srikanth Boyapally wrote:
> Add support for device reset via OSPI on Versal Gen 2 platform.
> 
> Srikanth Boyapally (3):
>   dt-bindings: qspi: cdns,qspi-nor: Add compatible string to support
>     OSPI controller on Versal Gen2 platform
>   spi: cadence-quadspi: Use quirks to set dma_set_mask instead of
>     compatible string for 64-bit DMA support
>   spi: cadence-quadspi: Support for device reset via OSPI controller
> 
> [...]

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-next

Thanks!

[1/3] dt-bindings: qspi: cdns,qspi-nor: Add compatible string to support OSPI controller on Versal Gen2 platform
      commit: 707080d4fea8f6b8319ceead569f34c2be5bf1d5
[2/3] spi: cadence-quadspi: Use quirks to set dma_set_mask instead of compatible string for 64-bit DMA support
      commit: 2e4d9f5111a3b3c24550e34710efa690c03b3ea1
[3/3] spi: cadence-quadspi: Support for device reset via OSPI controller
      commit: 27cf57f65bea55d985f0ad0dc1737ce1d01f05dc

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-12-02 17:36 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-20 12:09 [PATCH 0/3] spi: cadence-quadspi: Add support for device reset Srikanth Boyapally
2024-11-20 12:09 ` [PATCH 1/3] dt-bindings: qspi: cdns,qspi-nor: Add compatible string to support OSPI controller on Versal Gen2 platform Srikanth Boyapally
2024-11-20 16:33   ` Conor Dooley
2024-11-20 12:09 ` [PATCH 2/3] spi: cadence-quadspi: Use quirks to set dma_set_mask instead of compatible string for 64-bit DMA support Srikanth Boyapally
2024-11-20 12:09 ` [PATCH 3/3] spi: cadence-quadspi: Support for device reset via OSPI controller Srikanth Boyapally
2024-12-02 17:36 ` [PATCH 0/3] spi: cadence-quadspi: Add support for device reset Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox