Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: 9cb2ff111712 ("spi: cadence-quadspi: Disable Auto-HW polling)
Signed-off-by: Dinh Nguyen <dinguyen@kernel.org>
Reviewed-by: Pratyush Yadav <p.yadav@ti.com>
Link: https://lore.kernel.org/r/20211108200854.3616121-1-dinguyen@kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Dinh Nguyen and committed by
Mark Brown
98d948eb 28b5eaf9

+21 -3
+21 -3
drivers/spi/spi-cadence-quadspi.c
··· 37 37 #define CQSPI_NEEDS_WR_DELAY BIT(0) 38 38 #define CQSPI_DISABLE_DAC_MODE BIT(1) 39 39 #define CQSPI_SUPPORT_EXTERNAL_DMA BIT(2) 40 + #define CQSPI_NO_SUPPORT_WR_COMPLETION BIT(3) 40 41 41 42 /* Capabilities */ 42 43 #define CQSPI_SUPPORTS_OCTAL BIT(0) ··· 87 86 struct cqspi_flash_pdata f_pdata[CQSPI_MAX_CHIPSELECT]; 88 87 bool use_dma_read; 89 88 u32 pd_dev_id; 89 + bool wr_completion; 90 90 }; 91 91 92 92 struct cqspi_driver_platdata { ··· 998 996 * polling on the controller's side. spinand and spi-nor will take 999 997 * care of polling the status register. 1000 998 */ 1001 - reg = readl(reg_base + CQSPI_REG_WR_COMPLETION_CTRL); 1002 - reg |= CQSPI_REG_WR_DISABLE_AUTO_POLL; 1003 - writel(reg, reg_base + CQSPI_REG_WR_COMPLETION_CTRL); 999 + if (cqspi->wr_completion) { 1000 + reg = readl(reg_base + CQSPI_REG_WR_COMPLETION_CTRL); 1001 + reg |= CQSPI_REG_WR_DISABLE_AUTO_POLL; 1002 + writel(reg, reg_base + CQSPI_REG_WR_COMPLETION_CTRL); 1003 + } 1004 1004 1005 1005 reg = readl(reg_base + CQSPI_REG_SIZE); 1006 1006 reg &= ~CQSPI_REG_SIZE_ADDRESS_MASK; ··· 1740 1736 1741 1737 cqspi->master_ref_clk_hz = clk_get_rate(cqspi->clk); 1742 1738 master->max_speed_hz = cqspi->master_ref_clk_hz; 1739 + 1740 + /* write completion is supported by default */ 1741 + cqspi->wr_completion = true; 1742 + 1743 1743 ddata = of_device_get_match_data(dev); 1744 1744 if (ddata) { 1745 1745 if (ddata->quirks & CQSPI_NEEDS_WR_DELAY) ··· 1755 1747 cqspi->use_direct_mode = true; 1756 1748 if (ddata->quirks & CQSPI_SUPPORT_EXTERNAL_DMA) 1757 1749 cqspi->use_dma_read = true; 1750 + if (ddata->quirks & CQSPI_NO_SUPPORT_WR_COMPLETION) 1751 + cqspi->wr_completion = false; 1758 1752 1759 1753 if (of_device_is_compatible(pdev->dev.of_node, 1760 1754 "xlnx,versal-ospi-1.0")) ··· 1869 1859 .quirks = CQSPI_DISABLE_DAC_MODE, 1870 1860 }; 1871 1861 1862 + static const struct cqspi_driver_platdata socfpga_qspi = { 1863 + .quirks = CQSPI_NO_SUPPORT_WR_COMPLETION, 1864 + }; 1865 + 1872 1866 static const struct cqspi_driver_platdata versal_ospi = { 1873 1867 .hwcaps_mask = CQSPI_SUPPORTS_OCTAL, 1874 1868 .quirks = CQSPI_DISABLE_DAC_MODE | CQSPI_SUPPORT_EXTERNAL_DMA, ··· 1900 1886 { 1901 1887 .compatible = "xlnx,versal-ospi-1.0", 1902 1888 .data = (void *)&versal_ospi, 1889 + }, 1890 + { 1891 + .compatible = "intel,socfpga-qspi", 1892 + .data = (void *)&socfpga_qspi, 1903 1893 }, 1904 1894 { /* end of table */ } 1905 1895 };