[PATCH v2 2/6] mtd: spi-nor: add erase die (chip) capability

Tudor Ambarus tudor.ambarus at linaro.org
Thu Nov 2 11:56:23 PDT 2023



On 11/2/23 18:46, Tudor Ambarus wrote:
> 
> 
> On 11/2/23 18:33, Fabio Estevam wrote:
>> On 02/11/2023 15:21, Tudor Ambarus wrote:
>>
>>> Let's see what gets to the SPI controller. Which SPI controller do you
>>> use?
>>
>> I am using i.MX8MP, which has drivers/spi/spi-nxp-fspi.c.
>>
>> Here is the result:
>>
>> root at mcde3000a:~# flash_erase /dev/mtd0 0 0
>> Erasing 131072 Kibyte @ 0 --  0 [   26.040903] spi-nor spi0.0: *****
>> nor->reg_proto = 0x00010101
>> % complete [   26.049570] spi-nor spi0.0: *****
>> [   26.053849] spi-nor spi0.0: ***** op.cmd.nbytes = 0x01
>> [   26.059118] spi-nor spi0.0: ***** op.cmd.buswidth = 0x01
>> [   26.064539] spi-nor spi0.0: ***** op.cmd.opcode = 0xc4
>> [   26.069787] spi-nor spi0.0: *****
>> [   26.073118] spi-nor spi0.0: ***** op.addr.nbytes = 0x04
>> [   26.078451] spi-nor spi0.0: ***** op.addr.buswidth = 0x01
>> [   26.083949] spi-nor spi0.0: ***** op.addr.buswidth = 0x0
>> [   26.089368] spi-nor spi0.0: *****
>> [   26.092699] spi-nor spi0.0: ***** op.dummy.nbytes = 0x00
>> [   26.098123] spi-nor spi0.0: ***** op.dummy.buswidth = 0x00
>> [   26.103713] spi-nor spi0.0: *****
>> [   26.107045] spi-nor spi0.0: ***** op.data.buswidth = 0x00
>> [   26.112549] spi-nor spi0.0: ***** op.data.nbytes = 0
>> [   26.117727] spi-nor spi0.0: ***** nor->reg_proto = 0x00010101
>> [   26.123589] spi-nor spi0.0: *****
>> [   26.127012] spi-nor spi0.0: ***** op.cmd.nbytes = 0x01
>> [   26.132274] spi-nor spi0.0: ***** op.cmd.buswidth = 0x01
>> [   26.137706] spi-nor spi0.0: ***** op.cmd.opcode = 0xc4
>> [   26.142956] spi-nor spi0.0: *****
>> [   26.146290] spi-nor spi0.0: ***** op.addr.nbytes = 0x04
>> [   26.151625] spi-nor spi0.0: ***** op.addr.buswidth = 0x01
>> [   26.157132] spi-nor spi0.0: ***** op.addr.buswidth = 0x4000000
>> [   26.163065] spi-nor spi0.0: *****
>> [   26.166402] spi-nor spi0.0: ***** op.dummy.nbytes = 0x00
>> [   26.171815] spi-nor spi0.0: ***** op.dummy.buswidth = 0x00
>> [   26.177405] spi-nor spi0.0: *****
>> [   26.180737] spi-nor spi0.0: ***** op.data.buswidth = 0x00
>> [   26.186241] spi-nor spi0.0: ***** op.data.nbytes = 0
>> Erasing 131072 Kibyte @ 0 -- 100 % complete
>>
> 
> It looks good ...
> 
>> root at mcde3000a:~# hexdump /dev/mtd0
>> 0000000 a1d4 168c 4dad dfb2 2a3d c2af 0aae c18a
>> 0000010 2d5f 177a c39f 46a4 f9cd b880 331e 2543
> 
> but the patient is dead :). Would be good if Takahiro can test on IFX
> too. In the meantime I'll try to find a n25q00, I remember I had one in
> the past.


Let's try something else:
diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c
index 5584bf9cbfd1..a0af7a7eb727 100644
--- a/drivers/mtd/spi-nor/core.c
+++ b/drivers/mtd/spi-nor/core.c
@@ -1074,7 +1074,7 @@ static int spi_nor_erase_die(struct spi_nor *nor,
loff_t addr, size_t die_size)

        if (nor->spimem) {
                struct spi_mem_op op =
-                       SPI_NOR_DIE_ERASE_OP(nor->params->die_erase_opcode,
+                       SPI_NOR_DIE_ERASE_OP(nor->erase_opcode,
                                             nor->addr_nbytes, addr,
multi_die);

                spi_nor_spimem_setup_op(nor, &op, nor->reg_proto);

I expect that with this the first sector from each die will be erased.



More information about the linux-mtd mailing list