Message ID | 1359971785-11783-1-git-send-email-dantesu@gmail.com |
---|---|
State | New |
Headers | show |
On Mon, Feb 4, 2013 at 7:56 PM, Kuo-Jung Su <dantesu@gmail.com> wrote: > From: Kuo-Jung Su <dantesu@faraday-tech.com> > > Atmel, SST and Intel/Numonyx serial flash tend to power up > with the software protection bits set. > And thus the new m25p80.c in linux kernel would always tries > to use WREN(0x06) + WRSR(0x01) to turn-off the protection. > > The WEL(0x02) of status register is supposed to be cleared after > WRSR(0x01). There are also some drivers (i.e mine for RTOSes) > would check the WEL(0x02) in status register to make sure the > protection is correctly turned off. > > Signed-off-by: Kuo-Jung Su <dantesu@faraday-tech.com> Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com> > Cc: Peter Crosthwaite <peter.crosthwaite@xilinx.com> > Cc: Peter Maydell <peter.maydell@linaro.org> > Cc: Edgar E. Iglesias <edgar.iglesias@gmail.com> > --- > Changes for v3: > - remove s->state = STATE_IDLE in complete_collecting_data() > > Changes for v2: > - coding style fix > > hw/m25p80.c | 15 +++++++++++++++ > 1 file changed, 15 insertions(+) > > diff --git a/hw/m25p80.c b/hw/m25p80.c > index 788c196..461b41c 100644 > --- a/hw/m25p80.c > +++ b/hw/m25p80.c > @@ -184,6 +184,7 @@ static const FlashPartInfo known_devices[] = { > > typedef enum { > NOP = 0, > + WRSR = 0x1, > WRDI = 0x4, > RDSR = 0x5, > WREN = 0x6, > @@ -379,6 +380,11 @@ static void complete_collecting_data(Flash *s) > case ERASE_SECTOR: > flash_erase(s, s->cur_addr, s->cmd_in_progress); > break; > + case WRSR: > + if (s->write_enable) { > + s->write_enable = false; > + } > + break; > default: > break; > } > @@ -443,6 +449,15 @@ static void decode_new_cmd(Flash *s, uint32_t value) > s->state = STATE_COLLECTING_DATA; > break; > > + case WRSR: > + if (s->write_enable) { > + s->needed_bytes = 1; > + s->pos = 0; > + s->len = 0; > + s->state = STATE_COLLECTING_DATA; > + } > + break; > + > case WRDI: > s->write_enable = false; > break; > -- > 1.7.9.5 > >
On Mon, Feb 04, 2013 at 05:56:25PM +0800, Kuo-Jung Su wrote: > From: Kuo-Jung Su <dantesu@faraday-tech.com> > > Atmel, SST and Intel/Numonyx serial flash tend to power up > with the software protection bits set. > And thus the new m25p80.c in linux kernel would always tries > to use WREN(0x06) + WRSR(0x01) to turn-off the protection. > > The WEL(0x02) of status register is supposed to be cleared after > WRSR(0x01). There are also some drivers (i.e mine for RTOSes) > would check the WEL(0x02) in status register to make sure the > protection is correctly turned off. > > Signed-off-by: Kuo-Jung Su <dantesu@faraday-tech.com> > Cc: Peter Crosthwaite <peter.crosthwaite@xilinx.com> > Cc: Peter Maydell <peter.maydell@linaro.org> > Cc: Edgar E. Iglesias <edgar.iglesias@gmail.com> Applied, thanks! > --- > Changes for v3: > - remove s->state = STATE_IDLE in complete_collecting_data() > > Changes for v2: > - coding style fix > > hw/m25p80.c | 15 +++++++++++++++ > 1 file changed, 15 insertions(+) > > diff --git a/hw/m25p80.c b/hw/m25p80.c > index 788c196..461b41c 100644 > --- a/hw/m25p80.c > +++ b/hw/m25p80.c > @@ -184,6 +184,7 @@ static const FlashPartInfo known_devices[] = { > > typedef enum { > NOP = 0, > + WRSR = 0x1, > WRDI = 0x4, > RDSR = 0x5, > WREN = 0x6, > @@ -379,6 +380,11 @@ static void complete_collecting_data(Flash *s) > case ERASE_SECTOR: > flash_erase(s, s->cur_addr, s->cmd_in_progress); > break; > + case WRSR: > + if (s->write_enable) { > + s->write_enable = false; > + } > + break; > default: > break; > } > @@ -443,6 +449,15 @@ static void decode_new_cmd(Flash *s, uint32_t value) > s->state = STATE_COLLECTING_DATA; > break; > > + case WRSR: > + if (s->write_enable) { > + s->needed_bytes = 1; > + s->pos = 0; > + s->len = 0; > + s->state = STATE_COLLECTING_DATA; > + } > + break; > + > case WRDI: > s->write_enable = false; > break; > -- > 1.7.9.5 >
diff --git a/hw/m25p80.c b/hw/m25p80.c index 788c196..461b41c 100644 --- a/hw/m25p80.c +++ b/hw/m25p80.c @@ -184,6 +184,7 @@ static const FlashPartInfo known_devices[] = { typedef enum { NOP = 0, + WRSR = 0x1, WRDI = 0x4, RDSR = 0x5, WREN = 0x6, @@ -379,6 +380,11 @@ static void complete_collecting_data(Flash *s) case ERASE_SECTOR: flash_erase(s, s->cur_addr, s->cmd_in_progress); break; + case WRSR: + if (s->write_enable) { + s->write_enable = false; + } + break; default: break; } @@ -443,6 +449,15 @@ static void decode_new_cmd(Flash *s, uint32_t value) s->state = STATE_COLLECTING_DATA; break; + case WRSR: + if (s->write_enable) { + s->needed_bytes = 1; + s->pos = 0; + s->len = 0; + s->state = STATE_COLLECTING_DATA; + } + break; + case WRDI: s->write_enable = false; break;