@@ -870,21 +870,22 @@ static int spi_nor_write_16bit_sr_and_check(struct spi_nor *nor, u8 sr1)
870870 ret = spi_nor_read_cr (nor , & sr_cr [1 ]);
871871 if (ret )
872872 return ret ;
873- } else if (nor -> params -> quad_enable ) {
873+ } else if (spi_nor_get_protocol_width (nor -> read_proto ) == 4 &&
874+ spi_nor_get_protocol_width (nor -> write_proto ) == 4 &&
875+ nor -> params -> quad_enable ) {
874876 /*
875877 * If the Status Register 2 Read command (35h) is not
876878 * supported, we should at least be sure we don't
877879 * change the value of the SR2 Quad Enable bit.
878880 *
879- * We can safely assume that when the Quad Enable method is
880- * set, the value of the QE bit is one, as a consequence of the
881- * nor->params->quad_enable() call.
881+ * When the Quad Enable method is set and the buswidth is 4, we
882+ * can safely assume that the value of the QE bit is one, as a
883+ * consequence of the nor->params->quad_enable() call.
882884 *
883- * We can safely assume that the Quad Enable bit is present in
884- * the Status Register 2 at BIT(1). According to the JESD216
885- * revB standard, BFPT DWORDS[15], bits 22:20, the 16-bit
886- * Write Status (01h) command is available just for the cases
887- * in which the QE bit is described in SR2 at BIT(1).
885+ * According to the JESD216 revB standard, BFPT DWORDS[15],
886+ * bits 22:20, the 16-bit Write Status (01h) command is
887+ * available just for the cases in which the QE bit is
888+ * described in SR2 at BIT(1).
888889 */
889890 sr_cr [1 ] = SR2_QUAD_EN_BIT1 ;
890891 } else {
@@ -2844,6 +2845,9 @@ static void spi_nor_init_flags(struct spi_nor *nor)
28442845 if (of_property_read_bool (np , "broken-flash-reset" ))
28452846 nor -> flags |= SNOR_F_BROKEN_RESET ;
28462847
2848+ if (of_property_read_bool (np , "no-wp" ))
2849+ nor -> flags |= SNOR_F_NO_WP ;
2850+
28472851 if (flags & SPI_NOR_SWP_IS_VOLATILE )
28482852 nor -> flags |= SNOR_F_SWP_IS_VOLATILE ;
28492853
@@ -2897,16 +2901,23 @@ static void spi_nor_init_fixup_flags(struct spi_nor *nor)
28972901 * SFDP standard, or where SFDP tables are not defined at all.
28982902 * Will replace the spi_nor_manufacturer_init_params() method.
28992903 */
2900- static void spi_nor_late_init_params (struct spi_nor * nor )
2904+ static int spi_nor_late_init_params (struct spi_nor * nor )
29012905{
29022906 struct spi_nor_flash_parameter * params = nor -> params ;
2907+ int ret ;
29032908
29042909 if (nor -> manufacturer && nor -> manufacturer -> fixups &&
2905- nor -> manufacturer -> fixups -> late_init )
2906- nor -> manufacturer -> fixups -> late_init (nor );
2910+ nor -> manufacturer -> fixups -> late_init ) {
2911+ ret = nor -> manufacturer -> fixups -> late_init (nor );
2912+ if (ret )
2913+ return ret ;
2914+ }
29072915
2908- if (nor -> info -> fixups && nor -> info -> fixups -> late_init )
2909- nor -> info -> fixups -> late_init (nor );
2916+ if (nor -> info -> fixups && nor -> info -> fixups -> late_init ) {
2917+ ret = nor -> info -> fixups -> late_init (nor );
2918+ if (ret )
2919+ return ret ;
2920+ }
29102921
29112922 /* Default method kept for backward compatibility. */
29122923 if (!params -> set_4byte_addr_mode )
@@ -2924,6 +2935,8 @@ static void spi_nor_late_init_params(struct spi_nor *nor)
29242935
29252936 if (nor -> info -> n_banks > 1 )
29262937 params -> bank_size = div64_u64 (params -> size , nor -> info -> n_banks );
2938+
2939+ return 0 ;
29272940}
29282941
29292942/**
@@ -3082,22 +3095,20 @@ static int spi_nor_init_params(struct spi_nor *nor)
30823095 spi_nor_init_params_deprecated (nor );
30833096 }
30843097
3085- spi_nor_late_init_params (nor );
3086-
3087- return 0 ;
3098+ return spi_nor_late_init_params (nor );
30883099}
30893100
3090- /** spi_nor_octal_dtr_enable () - enable Octal DTR I/O if needed
3101+ /** spi_nor_set_octal_dtr () - enable or disable Octal DTR I/O.
30913102 * @nor: pointer to a 'struct spi_nor'
30923103 * @enable: whether to enable or disable Octal DTR
30933104 *
30943105 * Return: 0 on success, -errno otherwise.
30953106 */
3096- static int spi_nor_octal_dtr_enable (struct spi_nor * nor , bool enable )
3107+ static int spi_nor_set_octal_dtr (struct spi_nor * nor , bool enable )
30973108{
30983109 int ret ;
30993110
3100- if (!nor -> params -> octal_dtr_enable )
3111+ if (!nor -> params -> set_octal_dtr )
31013112 return 0 ;
31023113
31033114 if (!(nor -> read_proto == SNOR_PROTO_8_8_8_DTR &&
@@ -3107,7 +3118,7 @@ static int spi_nor_octal_dtr_enable(struct spi_nor *nor, bool enable)
31073118 if (!(nor -> flags & SNOR_F_IO_MODE_EN_VOLATILE ))
31083119 return 0 ;
31093120
3110- ret = nor -> params -> octal_dtr_enable (nor , enable );
3121+ ret = nor -> params -> set_octal_dtr (nor , enable );
31113122 if (ret )
31123123 return ret ;
31133124
@@ -3168,7 +3179,7 @@ static int spi_nor_init(struct spi_nor *nor)
31683179{
31693180 int err ;
31703181
3171- err = spi_nor_octal_dtr_enable (nor , true);
3182+ err = spi_nor_set_octal_dtr (nor , true);
31723183 if (err ) {
31733184 dev_dbg (nor -> dev , "octal mode not supported\n" );
31743185 return err ;
@@ -3270,7 +3281,7 @@ static int spi_nor_suspend(struct mtd_info *mtd)
32703281 int ret ;
32713282
32723283 /* Disable octal DTR mode if we enabled it. */
3273- ret = spi_nor_octal_dtr_enable (nor , false);
3284+ ret = spi_nor_set_octal_dtr (nor , false);
32743285 if (ret )
32753286 dev_err (nor -> dev , "suspend() failed\n" );
32763287
0 commit comments