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

Pratyush Yadav pratyush at kernel.org
Wed Jul 10 07:58:43 PDT 2024


On Wed, Jul 10 2024, Csókás Bence wrote:

> 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).

Exactly. Since there are no pages, calling the operation "Page Program"
would be a misnomer, no? Byte Program is a fitting name IMO.

Beyond cosmetic reasons, do you see any need for changing this?
Otherwise, I'd rather avoid the churn on something that is in the gray
zone anyway.

>
>> 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.

I see. Then let's _not_ fix what isn't broken!

-- 
Regards,
Pratyush Yadav



More information about the linux-mtd mailing list