Skip to content

Commit 27cf57f

Browse files
SrikanthGoud123broonie
authored andcommitted
spi: cadence-quadspi: Support for device reset via OSPI controller
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 <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 2e4d9f5 commit 27cf57f

File tree

1 file changed

+39
-1
lines changed

1 file changed

+39
-1
lines changed

drivers/spi/spi-cadence-quadspi.c

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ static_assert(CQSPI_MAX_CHIPSELECT <= SPI_CS_CNT_MAX);
4444
#define CQSPI_NEEDS_APB_AHB_HAZARD_WAR BIT(5)
4545
#define CQSPI_RD_NO_IRQ BIT(6)
4646
#define CQSPI_DMA_SET_MASK BIT(7)
47+
#define CQSPI_SUPPORT_DEVICE_RESET BIT(8)
4748

4849
/* Capabilities */
4950
#define CQSPI_SUPPORTS_OCTAL BIT(0)
@@ -110,7 +111,7 @@ struct cqspi_st {
110111

111112
struct cqspi_driver_platdata {
112113
u32 hwcaps_mask;
113-
u8 quirks;
114+
u16 quirks;
114115
int (*indirect_read_dma)(struct cqspi_flash_pdata *f_pdata,
115116
u_char *rxbuf, loff_t from_addr, size_t n_rx);
116117
u32 (*get_dma_status)(struct cqspi_st *cqspi);
@@ -145,6 +146,8 @@ struct cqspi_driver_platdata {
145146
#define CQSPI_REG_CONFIG_IDLE_LSB 31
146147
#define CQSPI_REG_CONFIG_CHIPSELECT_MASK 0xF
147148
#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)
148151

149152
#define CQSPI_REG_RD_INSTR 0x04
150153
#define CQSPI_REG_RD_INSTR_OPCODE_LSB 0
@@ -831,6 +834,25 @@ static int cqspi_indirect_read_execute(struct cqspi_flash_pdata *f_pdata,
831834
return ret;
832835
}
833836

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+
834856
static void cqspi_controller_enable(struct cqspi_st *cqspi, bool enable)
835857
{
836858
void __iomem *reg_base = cqspi->iobase;
@@ -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)
@@ -2054,6 +2079,15 @@ static const struct cqspi_driver_platdata versal_ospi = {
20542079
.get_dma_status = cqspi_get_versal_dma_status,
20552080
};
20562081

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,
2087+
.indirect_read_dma = cqspi_versal_indirect_read_dma,
2088+
.get_dma_status = cqspi_get_versal_dma_status,
2089+
};
2090+
20572091
static const struct cqspi_driver_platdata jh7110_qspi = {
20582092
.quirks = CQSPI_DISABLE_DAC_MODE,
20592093
.jh7110_clk_init = cqspi_jh7110_clk_init,
@@ -2106,6 +2140,10 @@ static const struct of_device_id cqspi_dt_ids[] = {
21062140
.compatible = "mobileye,eyeq5-ospi",
21072141
.data = &mobileye_eyeq5_ospi,
21082142
},
2143+
{
2144+
.compatible = "amd,versal2-ospi",
2145+
.data = &versal2_ospi,
2146+
},
21092147
{ /* end of table */ }
21102148
};
21112149

0 commit comments

Comments
 (0)