@@ -43,6 +43,8 @@ static_assert(CQSPI_MAX_CHIPSELECT <= SPI_CS_CNT_MAX);
43
43
#define CQSPI_SLOW_SRAM BIT(4)
44
44
#define CQSPI_NEEDS_APB_AHB_HAZARD_WAR BIT(5)
45
45
#define CQSPI_RD_NO_IRQ BIT(6)
46
+ #define CQSPI_DMA_SET_MASK BIT(7)
47
+ #define CQSPI_SUPPORT_DEVICE_RESET BIT(8)
46
48
47
49
/* Capabilities */
48
50
#define CQSPI_SUPPORTS_OCTAL BIT(0)
@@ -109,7 +111,7 @@ struct cqspi_st {
109
111
110
112
struct cqspi_driver_platdata {
111
113
u32 hwcaps_mask ;
112
- u8 quirks ;
114
+ u16 quirks ;
113
115
int (* indirect_read_dma )(struct cqspi_flash_pdata * f_pdata ,
114
116
u_char * rxbuf , loff_t from_addr , size_t n_rx );
115
117
u32 (* get_dma_status )(struct cqspi_st * cqspi );
@@ -144,6 +146,8 @@ struct cqspi_driver_platdata {
144
146
#define CQSPI_REG_CONFIG_IDLE_LSB 31
145
147
#define CQSPI_REG_CONFIG_CHIPSELECT_MASK 0xF
146
148
#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)
147
151
148
152
#define CQSPI_REG_RD_INSTR 0x04
149
153
#define CQSPI_REG_RD_INSTR_OPCODE_LSB 0
@@ -830,6 +834,25 @@ static int cqspi_indirect_read_execute(struct cqspi_flash_pdata *f_pdata,
830
834
return ret ;
831
835
}
832
836
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
+
833
856
static void cqspi_controller_enable (struct cqspi_st * cqspi , bool enable )
834
857
{
835
858
void __iomem * reg_base = cqspi -> iobase ;
@@ -1881,8 +1904,7 @@ static int cqspi_probe(struct platform_device *pdev)
1881
1904
goto probe_reset_failed ;
1882
1905
}
1883
1906
1884
- if (of_device_is_compatible (pdev -> dev .of_node ,
1885
- "xlnx,versal-ospi-1.0" )) {
1907
+ if (ddata -> quirks & CQSPI_DMA_SET_MASK ) {
1886
1908
ret = dma_set_mask (& pdev -> dev , DMA_BIT_MASK (64 ));
1887
1909
if (ret )
1888
1910
goto probe_reset_failed ;
@@ -1912,6 +1934,9 @@ static int cqspi_probe(struct platform_device *pdev)
1912
1934
1913
1935
host -> num_chipselect = cqspi -> num_chipselect ;
1914
1936
1937
+ if (ddata -> quirks & CQSPI_SUPPORT_DEVICE_RESET )
1938
+ cqspi_device_reset (cqspi );
1939
+
1915
1940
if (cqspi -> use_direct_mode ) {
1916
1941
ret = cqspi_request_mmap_dma (cqspi );
1917
1942
if (ret == - EPROBE_DEFER )
@@ -2048,7 +2073,17 @@ static const struct cqspi_driver_platdata socfpga_qspi = {
2048
2073
2049
2074
static const struct cqspi_driver_platdata versal_ospi = {
2050
2075
.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 ,
2052
2087
.indirect_read_dma = cqspi_versal_indirect_read_dma ,
2053
2088
.get_dma_status = cqspi_get_versal_dma_status ,
2054
2089
};
@@ -2105,6 +2140,10 @@ static const struct of_device_id cqspi_dt_ids[] = {
2105
2140
.compatible = "mobileye,eyeq5-ospi" ,
2106
2141
.data = & mobileye_eyeq5_ospi ,
2107
2142
},
2143
+ {
2144
+ .compatible = "amd,versal2-ospi" ,
2145
+ .data = & versal2_ospi ,
2146
+ },
2108
2147
{ /* end of table */ }
2109
2148
};
2110
2149
0 commit comments