Message ID | tencent_1E5C4D386767A0A673F08993@qq.com |
---|---|
State | Changes Requested |
Headers | show |
Hi, one more request On 16/11/2015 18:03, 未命名 wrote: > Instead of use the set_4byte function in spi-nor.c, I use this patch > for simplest modification. In fact, set_4byte also send 0xe9 command to > the spi flash. > > Signed-off-by: Shonn Lu <countrysideboy@qq.com> > --- > .../0064-reset-m25p80-when-shutdown.patch | 27 > ++++++++++++++++++++++ > 1 file changed, 27 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..aca758d > --- /dev/null > +++ b/target/linux/ramips/patches-3.18/0064-reset-m25p80-when-shutdown.patch > @@ -0,0 +1,27 @@ > +--- a/drivers/mtd/devices/m25p80.c > ++++ b/drivers/mtd/devices/m25p80.c > +@@ -322,6 +322,16 @@ > + { > + struct m25p *flash = spi_get_drvdata(spi); > + > ++ if ((&flash->spi_nor)->addr_width > 3) { > ++ printk(KERN_INFO "m25p80: exit 4-byte address mode\n"); > ++ flash->command[0] = SPINOR_OP_EX4B; // exit 4-byte address mode: 0xe9 > ++ spi_write(flash->spi, flash->command, 1); > ++ flash->command[0] = 0x66; // enable reset > ++ spi_write(flash->spi, flash->command, 1); > ++ flash->command[0] = 0x99; // reset > ++ spi_write(flash->spi, flash->command, 1); this needs to be indented with tabs John > ++ } > ++ > + /* Clean up MTD stuff. */ > + return mtd_device_unregister(&flash->mtd); > + } > +@@ -385,6 +395,7 @@ > + .id_table = m25p_ids, > + .probe = m25p_probe, > + .remove = m25p_remove, > ++ .shutdown = m25p_remove, // add shutdown method to reset spi flash > + > + /* 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 >
On Sat, Nov 21, 2015 at 09:41:25PM +0100, John Crispin wrote: > Hi, > > one more request > > On 16/11/2015 18:03, 未命名 wrote: > > Instead of use the set_4byte function in spi-nor.c, I use this patch > > for simplest modification. In fact, set_4byte also send 0xe9 command to > > the spi flash. Using set_4byte also already contains the logic to check which vendor- specific 4-byte mode to use (EN4B/EX4B or via explicite read4/write4 commands). Surely, having spi-nor provide a generic shutdown functions using set_4byte and then using that in m25p80 is less simple than implementing the work-around only in m25p80... > > > > Signed-off-by: Shonn Lu <countrysideboy@qq.com> > > --- > > .../0064-reset-m25p80-when-shutdown.patch | 27 > > ++++++++++++++++++++++ > > 1 file changed, 27 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..aca758d > > --- /dev/null > > +++ b/target/linux/ramips/patches-3.18/0064-reset-m25p80-when-shutdown.patch > > @@ -0,0 +1,27 @@ > > +--- a/drivers/mtd/devices/m25p80.c > > ++++ b/drivers/mtd/devices/m25p80.c > > +@@ -322,6 +322,16 @@ > > + { > > + struct m25p *flash = spi_get_drvdata(spi); > > + > > ++ if ((&flash->spi_nor)->addr_width > 3) { > > ++ printk(KERN_INFO "m25p80: exit 4-byte address mode\n"); > > ++ flash->command[0] = SPINOR_OP_EX4B; // exit 4-byte address mode: 0xe9 > > ++ spi_write(flash->spi, flash->command, 1); > > ++ flash->command[0] = 0x66; // enable reset > > ++ spi_write(flash->spi, flash->command, 1); > > ++ flash->command[0] = 0x99; // reset > > ++ spi_write(flash->spi, flash->command, 1); Are you sure the reset is actually needed? When I tested on some Rt5350 boards, SPINOR_OP_EX4B (0xE9) did the job and no subsequent reset was needed. > > this needs to be indented with tabs > > John > Cheers Daniel
Reset the flash is not absolutely necessary, this command should reset all the register, but some flash donot exit 4byte address mode with it.Of cause, SPINOR_OP_EX4B is already sufficient to resolve the soft reboot problem, I want to reset every register not only the address mode bit.Well, I will export a function from spi-nor.c and call it. Cheers Shonn ---原始邮件--- 发件人: "Daniel Golle"<daniel@makrotopia.org> 发送时间: 2015年11月22日 09:26:02 收件人: "John Crispin"<blogic@openwrt.org>; 抄送: "openwrt-devel"<openwrt-devel@lists.openwrt.org>;"未命名"<countrysideboy@qq.com>; 主题: Re: [OpenWrt-Devel] 回复:[PATCH]ramips: reset m25p80 when shutdown On Sat, Nov 21, 2015 at 09:41:25PM +0100, John Crispin wrote: > Hi, > > one more request > > On 16/11/2015 18:03, 未命名 wrote: > > Instead of use the set_4byte function in spi-nor.c, I use this patch > > for simplest modification. In fact, set_4byte also send 0xe9 command to > > the spi flash. Using set_4byte also already contains the logic to check which vendor- specific 4-byte mode to use (EN4B/EX4B or via explicite read4/write4 commands). Surely, having spi-nor provide a generic shutdown functions using set_4byte and then using that in m25p80 is less simple than implementing the work-around only in m25p80... > > > > Signed-off-by: Shonn Lu <countrysideboy@qq.com> > > --- > > .../0064-reset-m25p80-when-shutdown.patch | 27 > > ++++++++++++++++++++++ > > 1 file changed, 27 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..aca758d > > --- /dev/null > > +++ b/target/linux/ramips/patches-3.18/0064-reset-m25p80-when-shutdown.patch > > @@ -0,0 +1,27 @@ > > +--- a/drivers/mtd/devices/m25p80.c > > ++++ b/drivers/mtd/devices/m25p80.c > > +@@ -322,6 +322,16 @@ > > + { > > + struct m25p *flash = spi_get_drvdata(spi); > > + > > ++ if ((&flash->spi_nor)->addr_width > 3) { > > ++ printk(KERN_INFO "m25p80: exit 4-byte address mode\n"); > > ++ flash->command[0] = SPINOR_OP_EX4B; // exit 4-byte address mode: 0xe9 > > ++ spi_write(flash->spi, flash->command, 1); > > ++ flash->command[0] = 0x66; // enable reset > > ++ spi_write(flash->spi, flash->command, 1); > > ++ flash->command[0] = 0x99; // reset > > ++ spi_write(flash->spi, flash->command, 1); Are you sure the reset is actually needed? When I tested on some Rt5350 boards, SPINOR_OP_EX4B (0xE9) did the job and no subsequent reset was needed. > > this needs to be indented with tabs > > John > Cheers Daniel
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..aca758d --- /dev/null +++ b/target/linux/ramips/patches-3.18/0064-reset-m25p80-when-shutdown.patch @@ -0,0 +1,27 @@ +--- a/drivers/mtd/devices/m25p80.c ++++ b/drivers/mtd/devices/m25p80.c +@@ -322,6 +322,16 @@ + { + struct m25p *flash = spi_get_drvdata(spi); + ++ if ((&flash->spi_nor)->addr_width > 3) { ++ printk(KERN_INFO "m25p80: exit 4-byte address mode\n"); ++ flash->command[0] = SPINOR_OP_EX4B; // exit 4-byte address mode: 0xe9 ++ spi_write(flash->spi, flash->command, 1); ++ flash->command[0] = 0x66; // enable reset ++ spi_write(flash->spi, flash->command, 1); ++ flash->command[0] = 0x99; // reset ++ spi_write(flash->spi, flash->command, 1); ++ } ++ + /* Clean up MTD stuff. */ + return mtd_device_unregister(&flash->mtd); + } +@@ -385,6 +395,7 @@ + .id_table = m25p_ids, + .probe = m25p_probe, + .remove = m25p_remove, ++ .shutdown = m25p_remove, // add shutdown method to reset spi flash + + /* REVISIT: many of these chips have deep power-down modes, which + * should clearly be entered on suspend() to minimize power use.
Instead of use the set_4byte function in spi-nor.c, I use this patch for simplest modification. In fact, set_4byte also send 0xe9 command to the spi flash. Signed-off-by: Shonn Lu <countrysideboy@qq.com> --- .../0064-reset-m25p80-when-shutdown.patch | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 target/linux/ramips/patches-3.18/0064-reset-m25p80-when-shutdown.patch -- 1.9.1