Skip to content

Commit ba257e7

Browse files
committed
spi: cadence-quadspi: Add support for device reset
Merge series from Srikanth Boyapally <[email protected]>: Add support for device reset via OSPI on Versal Gen 2 platform.
2 parents e395313 + 707080d commit ba257e7

File tree

2 files changed

+44
-4
lines changed

2 files changed

+44
-4
lines changed

Documentation/devicetree/bindings/spi/cdns,qspi-nor.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ properties:
6868
- items:
6969
- enum:
7070
- amd,pensando-elba-qspi
71+
- amd,versal2-ospi
7172
- intel,lgm-qspi
7273
- intel,socfpga-qspi
7374
- mobileye,eyeq5-ospi

drivers/spi/spi-cadence-quadspi.c

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ static_assert(CQSPI_MAX_CHIPSELECT <= SPI_CS_CNT_MAX);
4343
#define CQSPI_SLOW_SRAM BIT(4)
4444
#define CQSPI_NEEDS_APB_AHB_HAZARD_WAR BIT(5)
4545
#define CQSPI_RD_NO_IRQ BIT(6)
46+
#define CQSPI_DMA_SET_MASK BIT(7)
47+
#define CQSPI_SUPPORT_DEVICE_RESET BIT(8)
4648

4749
/* Capabilities */
4850
#define CQSPI_SUPPORTS_OCTAL BIT(0)
@@ -109,7 +111,7 @@ struct cqspi_st {
109111

110112
struct cqspi_driver_platdata {
111113
u32 hwcaps_mask;
112-
u8 quirks;
114+
u16 quirks;
113115
int (*indirect_read_dma)(struct cqspi_flash_pdata *f_pdata,
114116
u_char *rxbuf, loff_t from_addr, size_t n_rx);
115117
u32 (*get_dma_status)(struct cqspi_st *cqspi);
@@ -144,6 +146,8 @@ struct cqspi_driver_platdata {
144146
#define CQSPI_REG_CONFIG_IDLE_LSB 31
145147
#define CQSPI_REG_CONFIG_CHIPSELECT_MASK 0xF
146148
#define CQSPI_REG_CONFIG_BAUD_MASK 0xF
149+
#define CQSPI_REG_CONFIG_RESET_PIN_FLD_MASK BIT(5)
150+
#define CQSPI_REG_CONFIG_RESET_CFG_FLD_MASK BIT(6)
147151

148152
#define CQSPI_REG_RD_INSTR 0x04
149153
#define CQSPI_REG_RD_INSTR_OPCODE_LSB 0
@@ -830,6 +834,25 @@ static int cqspi_indirect_read_execute(struct cqspi_flash_pdata *f_pdata,
830834
return ret;
831835
}
832836

837+
static void cqspi_device_reset(struct cqspi_st *cqspi)
838+
{
839+
u32 reg;
840+
841+
reg = readl(cqspi->iobase + CQSPI_REG_CONFIG);
842+
reg |= CQSPI_REG_CONFIG_RESET_CFG_FLD_MASK;
843+
writel(reg, cqspi->iobase + CQSPI_REG_CONFIG);
844+
/*
845+
* NOTE: Delay timing implementation is derived from
846+
* spi_nor_hw_reset()
847+
*/
848+
writel(reg & ~CQSPI_REG_CONFIG_RESET_PIN_FLD_MASK, cqspi->iobase + CQSPI_REG_CONFIG);
849+
usleep_range(1, 5);
850+
writel(reg | CQSPI_REG_CONFIG_RESET_PIN_FLD_MASK, cqspi->iobase + CQSPI_REG_CONFIG);
851+
usleep_range(100, 150);
852+
writel(reg & ~CQSPI_REG_CONFIG_RESET_PIN_FLD_MASK, cqspi->iobase + CQSPI_REG_CONFIG);
853+
usleep_range(1000, 1200);
854+
}
855+
833856
static void cqspi_controller_enable(struct cqspi_st *cqspi, bool enable)
834857
{
835858
void __iomem *reg_base = cqspi->iobase;
@@ -1881,8 +1904,7 @@ static int cqspi_probe(struct platform_device *pdev)
18811904
goto probe_reset_failed;
18821905
}
18831906

1884-
if (of_device_is_compatible(pdev->dev.of_node,
1885-
"xlnx,versal-ospi-1.0")) {
1907+
if (ddata->quirks & CQSPI_DMA_SET_MASK) {
18861908
ret = dma_set_mask(&pdev->dev, DMA_BIT_MASK(64));
18871909
if (ret)
18881910
goto probe_reset_failed;
@@ -1912,6 +1934,9 @@ static int cqspi_probe(struct platform_device *pdev)
19121934

19131935
host->num_chipselect = cqspi->num_chipselect;
19141936

1937+
if (ddata->quirks & CQSPI_SUPPORT_DEVICE_RESET)
1938+
cqspi_device_reset(cqspi);
1939+
19151940
if (cqspi->use_direct_mode) {
19161941
ret = cqspi_request_mmap_dma(cqspi);
19171942
if (ret == -EPROBE_DEFER)
@@ -2048,7 +2073,17 @@ static const struct cqspi_driver_platdata socfpga_qspi = {
20482073

20492074
static const struct cqspi_driver_platdata versal_ospi = {
20502075
.hwcaps_mask = CQSPI_SUPPORTS_OCTAL,
2051-
.quirks = CQSPI_DISABLE_DAC_MODE | CQSPI_SUPPORT_EXTERNAL_DMA,
2076+
.quirks = CQSPI_DISABLE_DAC_MODE | CQSPI_SUPPORT_EXTERNAL_DMA
2077+
| CQSPI_DMA_SET_MASK,
2078+
.indirect_read_dma = cqspi_versal_indirect_read_dma,
2079+
.get_dma_status = cqspi_get_versal_dma_status,
2080+
};
2081+
2082+
static const struct cqspi_driver_platdata versal2_ospi = {
2083+
.hwcaps_mask = CQSPI_SUPPORTS_OCTAL,
2084+
.quirks = CQSPI_DISABLE_DAC_MODE | CQSPI_SUPPORT_EXTERNAL_DMA
2085+
| CQSPI_DMA_SET_MASK
2086+
| CQSPI_SUPPORT_DEVICE_RESET,
20522087
.indirect_read_dma = cqspi_versal_indirect_read_dma,
20532088
.get_dma_status = cqspi_get_versal_dma_status,
20542089
};
@@ -2105,6 +2140,10 @@ static const struct of_device_id cqspi_dt_ids[] = {
21052140
.compatible = "mobileye,eyeq5-ospi",
21062141
.data = &mobileye_eyeq5_ospi,
21072142
},
2143+
{
2144+
.compatible = "amd,versal2-ospi",
2145+
.data = &versal2_ospi,
2146+
},
21082147
{ /* end of table */ }
21092148
};
21102149

0 commit comments

Comments
 (0)