Skip to content

Commit 98d948e

Browse files
Dinh Nguyenbroonie
authored andcommitted
spi: cadence-quadspi: fix write completion support
Some versions of the Cadence QSPI controller does not have the write completion register implemented(CQSPI_REG_WR_COMPLETION_CTRL). On the Intel SoCFPGA platform the CQSPI_REG_WR_COMPLETION_CTRL register is not configured. Add a quirk to not write to the CQSPI_REG_WR_COMPLETION_CTRL register. Fixes: 9cb2ff1 ("spi: cadence-quadspi: Disable Auto-HW polling) Signed-off-by: Dinh Nguyen <[email protected]> Reviewed-by: Pratyush Yadav <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 28b5eaf commit 98d948e

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

drivers/spi/spi-cadence-quadspi.c

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#define CQSPI_NEEDS_WR_DELAY BIT(0)
3838
#define CQSPI_DISABLE_DAC_MODE BIT(1)
3939
#define CQSPI_SUPPORT_EXTERNAL_DMA BIT(2)
40+
#define CQSPI_NO_SUPPORT_WR_COMPLETION BIT(3)
4041

4142
/* Capabilities */
4243
#define CQSPI_SUPPORTS_OCTAL BIT(0)
@@ -86,6 +87,7 @@ struct cqspi_st {
8687
struct cqspi_flash_pdata f_pdata[CQSPI_MAX_CHIPSELECT];
8788
bool use_dma_read;
8889
u32 pd_dev_id;
90+
bool wr_completion;
8991
};
9092

9193
struct cqspi_driver_platdata {
@@ -996,9 +998,11 @@ static int cqspi_write_setup(struct cqspi_flash_pdata *f_pdata,
996998
* polling on the controller's side. spinand and spi-nor will take
997999
* care of polling the status register.
9981000
*/
999-
reg = readl(reg_base + CQSPI_REG_WR_COMPLETION_CTRL);
1000-
reg |= CQSPI_REG_WR_DISABLE_AUTO_POLL;
1001-
writel(reg, reg_base + CQSPI_REG_WR_COMPLETION_CTRL);
1001+
if (cqspi->wr_completion) {
1002+
reg = readl(reg_base + CQSPI_REG_WR_COMPLETION_CTRL);
1003+
reg |= CQSPI_REG_WR_DISABLE_AUTO_POLL;
1004+
writel(reg, reg_base + CQSPI_REG_WR_COMPLETION_CTRL);
1005+
}
10021006

10031007
reg = readl(reg_base + CQSPI_REG_SIZE);
10041008
reg &= ~CQSPI_REG_SIZE_ADDRESS_MASK;
@@ -1736,6 +1740,10 @@ static int cqspi_probe(struct platform_device *pdev)
17361740

17371741
cqspi->master_ref_clk_hz = clk_get_rate(cqspi->clk);
17381742
master->max_speed_hz = cqspi->master_ref_clk_hz;
1743+
1744+
/* write completion is supported by default */
1745+
cqspi->wr_completion = true;
1746+
17391747
ddata = of_device_get_match_data(dev);
17401748
if (ddata) {
17411749
if (ddata->quirks & CQSPI_NEEDS_WR_DELAY)
@@ -1747,6 +1755,8 @@ static int cqspi_probe(struct platform_device *pdev)
17471755
cqspi->use_direct_mode = true;
17481756
if (ddata->quirks & CQSPI_SUPPORT_EXTERNAL_DMA)
17491757
cqspi->use_dma_read = true;
1758+
if (ddata->quirks & CQSPI_NO_SUPPORT_WR_COMPLETION)
1759+
cqspi->wr_completion = false;
17501760

17511761
if (of_device_is_compatible(pdev->dev.of_node,
17521762
"xlnx,versal-ospi-1.0"))
@@ -1859,6 +1869,10 @@ static const struct cqspi_driver_platdata intel_lgm_qspi = {
18591869
.quirks = CQSPI_DISABLE_DAC_MODE,
18601870
};
18611871

1872+
static const struct cqspi_driver_platdata socfpga_qspi = {
1873+
.quirks = CQSPI_NO_SUPPORT_WR_COMPLETION,
1874+
};
1875+
18621876
static const struct cqspi_driver_platdata versal_ospi = {
18631877
.hwcaps_mask = CQSPI_SUPPORTS_OCTAL,
18641878
.quirks = CQSPI_DISABLE_DAC_MODE | CQSPI_SUPPORT_EXTERNAL_DMA,
@@ -1887,6 +1901,10 @@ static const struct of_device_id cqspi_dt_ids[] = {
18871901
.compatible = "xlnx,versal-ospi-1.0",
18881902
.data = (void *)&versal_ospi,
18891903
},
1904+
{
1905+
.compatible = "intel,socfpga-qspi",
1906+
.data = (void *)&socfpga_qspi,
1907+
},
18901908
{ /* end of table */ }
18911909
};
18921910

0 commit comments

Comments
 (0)