Hi! On Wed, Nov 11, 2015 at 06:53:33PM +0800, Weijie Gao wrote: > 2015-11-08 4:42 GMT+08:00 Shonn Lu <countryside...@qq.com>: > > > Signed-off-by: Shonn Lu <countryside...@qq.com> > > --- > > .../0064-reset-m25p80-when-shutdown.patch | 24 > > ++++++++++++++++++++++ > > 1 file changed, 24 insertions(+) > > create mode 100644 > > target/linux/ramips/patches-3.18/0064-reset-m25p80-when-shutdown.patch > > > > diff --git > > a/target/linux/ramips/patches-3.18/0064-reset-m25p80-when-shutdown.patch > > b/target/linux/ramips/patches-3.18/0064-reset-m25p80-when-shutdown.patch > > new file mode 100644 > > index 0000000..76f916a > > --- /dev/null > > +++ > > b/target/linux/ramips/patches-3.18/0064-reset-m25p80-when-shutdown.patch > > @@ -0,0 +1,24 @@ > > +--- a/drivers/mtd/devices/m25p80.c > > ++++ b/drivers/mtd/devices/m25p80.c > > +@@ -319,6 +319,12 @@ > > + { > > + struct m25p *flash = spi_get_drvdata(spi); > > + > > ++ // play4fun: add spi flash reset code > > ++ flash->command[0] = 0x66; > > ++ spi_write(flash->spi, flash->command, 1); > > ++ flash->command[0] = 0x99; > > ++ spi_write(flash->spi, flash->command, 1); > > ++ > > + /* Clean up MTD stuff. */ > > + return mtd_device_unregister(&flash->mtd); > > + } > > +@@ -382,6 +388,8 @@ > > + .id_table = m25p_ids, > > + .probe = m25p_probe, > > + .remove = m25p_remove, > > ++ // play4fun add shutdown method to reset spi flash > > ++ .shutdown = m25p_remove, > > + > > + /* REVISIT: many of these chips have deep power-down modes, which > > + * should clearly be entered on suspend() to minimize power use. > > -- > > 1.9.1 > > _______________________________________________ > > openwrt-devel mailing list > > openwrt-devel@lists.openwrt.org > > https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel > > > This is not enough for w25q256. > The Extended Address Register (EAR) must be cleared, or the higher half > 16MB may be accessed in 3-byte addressing mode, and this will cause a boot > failure.
At least on Macronix SPI chips, using 0x66, 0x99 to reset the chip is not nough as that will not clear the adressing-mode bits. Using 0xE9 (EX4B; exit 4-byte mode) instead fixes the issue eg. on MX25L256. Also note, that while it's helpful to find out the details by directly writing values to the SPI bus, this is probably not acceptable upstream. I reckon we'll need a generic shutdown function in spi-nor.c calling set_4byte(nor, info, 0) We can then use that in m25p_remove. Cheers Daniel _______________________________________________ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel