@@ -139,30 +139,15 @@ static int cypress_nor_octal_dtr_dis(struct spi_nor *nor)
139139 return 0 ;
140140}
141141
142- /**
143- * cypress_nor_quad_enable_volatile() - enable Quad I/O mode in volatile
144- * register.
145- * @nor: pointer to a 'struct spi_nor'
146- *
147- * It is recommended to update volatile registers in the field application due
148- * to a risk of the non-volatile registers corruption by power interrupt. This
149- * function sets Quad Enable bit in CFR1 volatile. If users set the Quad Enable
150- * bit in the CFR1 non-volatile in advance (typically by a Flash programmer
151- * before mounting Flash on PCB), the Quad Enable bit in the CFR1 volatile is
152- * also set during Flash power-up.
153- *
154- * Return: 0 on success, -errno otherwise.
155- */
156- static int cypress_nor_quad_enable_volatile (struct spi_nor * nor )
142+ static int cypress_nor_quad_enable_volatile_reg (struct spi_nor * nor , u64 addr )
157143{
158144 struct spi_mem_op op ;
159145 u8 addr_mode_nbytes = nor -> params -> addr_mode_nbytes ;
160146 u8 cfr1v_written ;
161147 int ret ;
162148
163149 op = (struct spi_mem_op )
164- CYPRESS_NOR_RD_ANY_REG_OP (addr_mode_nbytes ,
165- SPINOR_REG_CYPRESS_CFR1V , 0 ,
150+ CYPRESS_NOR_RD_ANY_REG_OP (addr_mode_nbytes , addr , 0 ,
166151 nor -> bouncebuf );
167152
168153 ret = spi_nor_read_any_reg (nor , & op , nor -> reg_proto );
@@ -175,8 +160,7 @@ static int cypress_nor_quad_enable_volatile(struct spi_nor *nor)
175160 /* Update the Quad Enable bit. */
176161 nor -> bouncebuf [0 ] |= SPINOR_REG_CYPRESS_CFR1_QUAD_EN ;
177162 op = (struct spi_mem_op )
178- CYPRESS_NOR_WR_ANY_REG_OP (addr_mode_nbytes ,
179- SPINOR_REG_CYPRESS_CFR1V , 1 ,
163+ CYPRESS_NOR_WR_ANY_REG_OP (addr_mode_nbytes , addr , 1 ,
180164 nor -> bouncebuf );
181165 ret = spi_nor_write_any_volatile_reg (nor , & op , nor -> reg_proto );
182166 if (ret )
@@ -186,8 +170,7 @@ static int cypress_nor_quad_enable_volatile(struct spi_nor *nor)
186170
187171 /* Read back and check it. */
188172 op = (struct spi_mem_op )
189- CYPRESS_NOR_RD_ANY_REG_OP (addr_mode_nbytes ,
190- SPINOR_REG_CYPRESS_CFR1V , 0 ,
173+ CYPRESS_NOR_RD_ANY_REG_OP (addr_mode_nbytes , addr , 0 ,
191174 nor -> bouncebuf );
192175 ret = spi_nor_read_any_reg (nor , & op , nor -> reg_proto );
193176 if (ret )
@@ -201,6 +184,41 @@ static int cypress_nor_quad_enable_volatile(struct spi_nor *nor)
201184 return 0 ;
202185}
203186
187+ /**
188+ * cypress_nor_quad_enable_volatile() - enable Quad I/O mode in volatile
189+ * register.
190+ * @nor: pointer to a 'struct spi_nor'
191+ *
192+ * It is recommended to update volatile registers in the field application due
193+ * to a risk of the non-volatile registers corruption by power interrupt. This
194+ * function sets Quad Enable bit in CFR1 volatile. If users set the Quad Enable
195+ * bit in the CFR1 non-volatile in advance (typically by a Flash programmer
196+ * before mounting Flash on PCB), the Quad Enable bit in the CFR1 volatile is
197+ * also set during Flash power-up.
198+ *
199+ * Return: 0 on success, -errno otherwise.
200+ */
201+ static int cypress_nor_quad_enable_volatile (struct spi_nor * nor )
202+ {
203+ struct spi_nor_flash_parameter * params = nor -> params ;
204+ u64 addr ;
205+ u8 i ;
206+ int ret ;
207+
208+ if (!params -> n_dice )
209+ return cypress_nor_quad_enable_volatile_reg (nor ,
210+ SPINOR_REG_CYPRESS_CFR1V );
211+
212+ for (i = 0 ; i < params -> n_dice ; i ++ ) {
213+ addr = params -> vreg_offset [i ] + SPINOR_REG_CYPRESS_CFR1 ;
214+ ret = cypress_nor_quad_enable_volatile_reg (nor , addr );
215+ if (ret )
216+ return ret ;
217+ }
218+
219+ return 0 ;
220+ }
221+
204222/**
205223 * cypress_nor_determine_addr_mode_by_sr1() - Determine current address mode
206224 * (3 or 4-byte) by querying status
0 commit comments