@@ -110,6 +110,7 @@ struct cqspi_st {
110110 bool apb_ahb_hazard ;
111111
112112 bool is_jh7110 ; /* Flag for StarFive JH7110 SoC */
113+ bool is_rzn1 ; /* Flag for Renesas RZ/N1 SoC */
113114 bool disable_stig_mode ;
114115 refcount_t refcount ;
115116 refcount_t inflight_ops ;
@@ -1337,8 +1338,9 @@ static ssize_t cqspi_write(struct cqspi_flash_pdata *f_pdata,
13371338 * mode. So, we can not use direct mode when in DTR mode for writing
13381339 * data.
13391340 */
1340- if (!op -> cmd .dtr && cqspi -> use_direct_mode &&
1341- cqspi -> use_direct_mode_wr && ((to + len ) <= cqspi -> ahb_size )) {
1341+ if ((!op -> cmd .dtr && cqspi -> use_direct_mode &&
1342+ cqspi -> use_direct_mode_wr && ((to + len ) <= cqspi -> ahb_size )) ||
1343+ (cqspi -> ddata && cqspi -> ddata -> quirks & CQSPI_NO_INDIRECT_MODE )) {
13421344 memcpy_toio (cqspi -> ahb_base + to , buf , len );
13431345 return cqspi_wait_idle (cqspi );
13441346 }
@@ -1512,6 +1514,7 @@ static int cqspi_exec_mem_op(struct spi_mem *mem, const struct spi_mem_op *op)
15121514static bool cqspi_supports_mem_op (struct spi_mem * mem ,
15131515 const struct spi_mem_op * op )
15141516{
1517+ struct cqspi_st * cqspi = spi_controller_get_devdata (mem -> spi -> controller );
15151518 bool all_true , all_false ;
15161519
15171520 /*
@@ -1538,6 +1541,9 @@ static bool cqspi_supports_mem_op(struct spi_mem *mem,
15381541 /* A single opcode is supported, it will be repeated */
15391542 if ((op -> cmd .opcode >> 8 ) != (op -> cmd .opcode & 0xFF ))
15401543 return false;
1544+
1545+ if (cqspi -> is_rzn1 )
1546+ return false;
15411547 } else if (!all_false ) {
15421548 /* Mixed DTR modes are not supported. */
15431549 return false;
@@ -1591,18 +1597,20 @@ static int cqspi_of_get_pdata(struct cqspi_st *cqspi)
15911597
15921598 cqspi -> is_decoded_cs = of_property_read_bool (np , "cdns,is-decoded-cs" );
15931599
1594- if (of_property_read_u32 (np , "cdns,fifo-depth" , & cqspi -> fifo_depth )) {
1595- /* Zero signals FIFO depth should be runtime detected. */
1596- cqspi -> fifo_depth = 0 ;
1597- }
1600+ if (!(cqspi -> ddata && cqspi -> ddata -> quirks & CQSPI_NO_INDIRECT_MODE )) {
1601+ if (of_property_read_u32 (np , "cdns,fifo-depth" , & cqspi -> fifo_depth )) {
1602+ /* Zero signals FIFO depth should be runtime detected. */
1603+ cqspi -> fifo_depth = 0 ;
1604+ }
15981605
1599- if (of_property_read_u32 (np , "cdns,fifo-width" , & cqspi -> fifo_width ))
1600- cqspi -> fifo_width = 4 ;
1606+ if (of_property_read_u32 (np , "cdns,fifo-width" , & cqspi -> fifo_width ))
1607+ cqspi -> fifo_width = 4 ;
16011608
1602- if (of_property_read_u32 (np , "cdns,trigger-address" ,
1603- & cqspi -> trigger_address )) {
1604- dev_err (dev , "couldn't determine trigger-address\n" );
1605- return - ENXIO ;
1609+ if (of_property_read_u32 (np , "cdns,trigger-address" ,
1610+ & cqspi -> trigger_address )) {
1611+ dev_err (dev , "couldn't determine trigger-address\n" );
1612+ return - ENXIO ;
1613+ }
16061614 }
16071615
16081616 if (of_property_read_u32 (np , "num-cs" , & cqspi -> num_chipselect ))
@@ -1666,6 +1674,9 @@ static void cqspi_controller_detect_fifo_depth(struct cqspi_st *cqspi)
16661674 struct device * dev = & cqspi -> pdev -> dev ;
16671675 u32 reg , fifo_depth ;
16681676
1677+ if (cqspi -> ddata && cqspi -> ddata -> quirks & CQSPI_NO_INDIRECT_MODE )
1678+ return ;
1679+
16691680 /*
16701681 * Bits N-1:0 are writable while bits 31:N are read as zero, with 2^N
16711682 * the FIFO depth.
@@ -1790,6 +1801,8 @@ static int cqspi_probe(struct platform_device *pdev)
17901801 cqspi = spi_controller_get_devdata (host );
17911802 if (of_device_is_compatible (pdev -> dev .of_node , "starfive,jh7110-qspi" ))
17921803 cqspi -> is_jh7110 = true;
1804+ if (of_device_is_compatible (pdev -> dev .of_node , "renesas,rzn1-qspi" ))
1805+ cqspi -> is_rzn1 = true;
17931806
17941807 cqspi -> pdev = pdev ;
17951808 cqspi -> host = host ;
@@ -1887,7 +1900,12 @@ static int cqspi_probe(struct platform_device *pdev)
18871900 reset_control_deassert (rstc_ocp );
18881901
18891902 cqspi -> master_ref_clk_hz = clk_get_rate (cqspi -> clks [CLK_QSPI_REF ].clk );
1890- host -> max_speed_hz = cqspi -> master_ref_clk_hz ;
1903+ if (!cqspi -> is_rzn1 ) {
1904+ host -> max_speed_hz = cqspi -> master_ref_clk_hz ;
1905+ } else {
1906+ host -> max_speed_hz = cqspi -> master_ref_clk_hz / 2 ;
1907+ host -> min_speed_hz = cqspi -> master_ref_clk_hz / 32 ;
1908+ }
18911909
18921910 /* write completion is supported by default */
18931911 cqspi -> wr_completion = true;
@@ -1952,7 +1970,7 @@ static int cqspi_probe(struct platform_device *pdev)
19521970 if (ddata && (ddata -> quirks & CQSPI_SUPPORT_DEVICE_RESET ))
19531971 cqspi_device_reset (cqspi );
19541972
1955- if (cqspi -> use_direct_mode ) {
1973+ if (cqspi -> use_direct_mode && ! cqspi -> is_rzn1 ) {
19561974 ret = cqspi_request_mmap_dma (cqspi );
19571975 if (ret == - EPROBE_DEFER ) {
19581976 dev_err_probe (& pdev -> dev , ret , "Failed to request mmap DMA\n" );
@@ -2132,6 +2150,12 @@ static const struct cqspi_driver_platdata mobileye_eyeq5_ospi = {
21322150 CQSPI_RD_NO_IRQ ,
21332151};
21342152
2153+ static const struct cqspi_driver_platdata renesas_rzn1_qspi = {
2154+ .hwcaps_mask = CQSPI_SUPPORTS_QUAD ,
2155+ .quirks = CQSPI_NO_SUPPORT_WR_COMPLETION | CQSPI_RD_NO_IRQ |
2156+ CQSPI_HAS_WR_PROTECT | CQSPI_NO_INDIRECT_MODE ,
2157+ };
2158+
21352159static const struct of_device_id cqspi_dt_ids [] = {
21362160 {
21372161 .compatible = "cdns,qspi-nor" ,
@@ -2173,6 +2197,10 @@ static const struct of_device_id cqspi_dt_ids[] = {
21732197 .compatible = "amd,versal2-ospi" ,
21742198 .data = & versal2_ospi ,
21752199 },
2200+ {
2201+ .compatible = "renesas,rzn1-qspi" ,
2202+ .data = & renesas_rzn1_qspi ,
2203+ },
21762204 { /* end of table */ }
21772205};
21782206
0 commit comments