Re: [PATCH] mtd: spi-nor: sst: Factor out common write operation to `sst_nor_write_data()`

From: Csókás Bence
Date: Wed Jul 10 2024 - 09:35:54 EST


Hi!

On 7/10/24 15:04, Pratyush Yadav wrote:
Notes:
RFC: I'm thinking of removing SPINOR_OP_BP in favor of
SPINOR_OP_PP (they have the same value). SPINOR_OP_PP
is the "standard" name for the elementary unit-sized
(1 byte, in the case of NOR) write operation. I find it
confusing to have two names for the same operation,
so in a followup I plan to remove the vendor-specific
name in favor of the standard one.

Even though the operations have the same opcode, I see them as different
operations. One is a byte program: it can only write one byte at a time.
The other is a page program: it can write up to one page (256 bytes
usually) at a time.

So I would actually find it more confusing if you use page program in a
situation where the operation is actually a byte program, and attempting
to program the whole page will fail.

Yes, SST engineers took some _unconventional_ steps when designing this family... However, there are no 256 byte pages in these chips. You either program it one byte at a time, or as a sequence of two byte values. So, in my eyes, that makes it a Flash where the page size is 1 byte, and the vendor-specific write is something extra added on (and mind you, that's not a page program either, you just feed it an *arbitrary* even number of bytes, there really are no pages here at all, only erase sectors).

Not directly related to this patch, but when reviewing this patch I
noticed another small improvement you can make. [...]
Here, we do a write disable. Then if a one-byte write is needed, do a
write enable again, write the data and write disable.

Do we really need to toggle write enable between these? If not, it can
be simplified to only do the write disable after all bytes have been
written.

Honestly, I'm not sure, I was too afraid to touch that part. However, from the datasheet of SST25VF040B I presume that if we did not toggle it, then the Flash chip would interpret the 0x02 opcode and its argument as another 2 bytes of data to write at the end. Byte Program takes exactly 1 argument, so it can be followed by another command, but AAI WP goes on until ~CS goes high.

> Reviewed-by: Pratyush Yadav <pratyush@xxxxxxxxxx>

Thanks!

Bence