mirror of
https://github.com/LineageOS/android_kernel_fxtec_sm6115.git
synced 2026-08-18 11:41:01 +00:00
mtd: spi-nor: sst: Fix write enable before AAI sequence
[ Upstream commit a0f64241d3566a49c0a9b33ba7ae458ae22003a9 ]
When writing to SST flash starting at an odd address, a single byte is
first programmed using the byte program (BP) command. After this
operation completes, the flash hardware automatically clears the Write
Enable Latch (WEL) bit.
If an AAI (Auto Address Increment) word program sequence follows, it
requires WEL to be set. Without re-enabling writes, the AAI sequence
fails.
Add spi_nor_write_enable() after the odd-address byte program when more
data needs to be written. Use a local boolean for clarity.
Fixes: b199489d37 ("mtd: spi-nor: add the framework for SPI NOR")
Cc: stable@vger.kernel.org
Signed-off-by: Sanjaikumar V S <sanjaikumar.vs@dicortech.com>
Tested-by: Hendrik Donner <hd@os-cillation.de>
Reviewed-by: Hendrik Donner <hd@os-cillation.de>
Signed-off-by: Pratyush Yadav (Google) <pratyush@kernel.org>
[ kept inline `nor->program_opcode = SPINOR_OP_BP;` ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
[uli: backport to 4.19]
Signed-off-by: Ulrich Hecht <uli@kernel.org>
Reviewed-by: Pavel Machek <pavel@nabladev.com>
This commit is contained in:
committed by
Ulrich Hecht
parent
e540b44c91
commit
880c87d784
@ -1350,6 +1350,8 @@ static int sst_write(struct mtd_info *mtd, loff_t to, size_t len,
|
||||
actual = to % 2;
|
||||
/* Start write from odd address. */
|
||||
if (actual) {
|
||||
bool needs_write_enable = (len > 1);
|
||||
|
||||
nor->program_opcode = SPINOR_OP_BP;
|
||||
|
||||
/* write one byte. */
|
||||
@ -1361,6 +1363,17 @@ static int sst_write(struct mtd_info *mtd, loff_t to, size_t len,
|
||||
ret = spi_nor_wait_till_ready(nor);
|
||||
if (ret)
|
||||
goto sst_write_err;
|
||||
|
||||
/*
|
||||
* Byte program clears the write enable latch. If more
|
||||
* data needs to be written using the AAI sequence,
|
||||
* re-enable writes.
|
||||
*/
|
||||
if (needs_write_enable) {
|
||||
ret = write_enable(nor);
|
||||
if (ret)
|
||||
goto sst_write_err;
|
||||
}
|
||||
}
|
||||
to += actual;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user