Skip to contentSkip to conversation

mtd: spi-nor: add support for Winbond W25Q512JV

PATCH In review David Bauer 3 participants 7 messages Feb 13, 2021 – May 5, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mtd: spi-nor: add support for Winbond W25Q512JV

The Winbond W25Q512JV is a 512mb SPI-NOR chip. It supports 4K sectors as well as block protection and Dual-/Quad-read.

Tested on: Ubiquiti UniFi 6 LR

---
 drivers/mtd/spi-nor/winbond.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/mtd/spi-nor/winbond.c +4 -0
index e5dfa786f190..49d0d7993368 100644
@@ -95,6 +95,10 @@ static const struct flash_info winbond_parts[] = {
 			     SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
 	{ "w25q256jw", INFO(0xef6019, 0, 64 * 1024, 512,
 			     SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
+	{ "w25q512jv", INFO(0xef4020, 0, 64 * 1024, 1024,
+			    SECT_4K | SPI_NOR_QUAD_READ | SPI_NOR_DUAL_READ |
+			    SPI_NOR_HAS_TB | SPI_NOR_TB_SR_BIT6 |
+			    SPI_NOR_HAS_LOCK | SPI_NOR_4BIT_BP) },
 	{ "w25m512jv", INFO(0xef7119, 0, 64 * 1024, 1024,
 			    SECT_4K | SPI_NOR_QUAD_READ | SPI_NOR_DUAL_READ) },
 };
Signature · 6 lines
2.30.1


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
#1 lore raw
Quoted 8 lines · David Bauer

EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe

The Winbond W25Q512JV is a 512mb SPI-NOR chip. It supports 4K sectors as well as block protection and Dual-/Quad-read.

Tested on: Ubiquiti UniFi 6 LR

David, I'll take Shuhao's patch because he sent it first:
https://patchwork.ozlabs.org/project/linux-mtd/patch/[email protected]/

Would you make an incremental patch on top op Shuhao's, to add the locking support?

Shuhao, can you please test the locking ops with mtd-utils?

Quoted 9 lines
---
 drivers/mtd/spi-nor/winbond.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/mtd/spi-nor/winbond.c +0 -0
index e5dfa786f190..49d0d7993368 100644

drivers/mtd/spi-nor/winbond.c static const struct flash_info winbond_parts[] = { · line 101

Quoted 7 lines
drivers/mtd/spi-nor/winbond.c +4 -0
@@ -95,6 +95,10 @@ static const struct flash_info winbond_parts[] = {
                             SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
        { "w25q256jw", INFO(0xef6019, 0, 64 * 1024, 512,
                             SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
+       { "w25q512jv", INFO(0xef4020, 0, 64 * 1024, 1024,
+                           SECT_4K | SPI_NOR_QUAD_READ | SPI_NOR_DUAL_READ |
+                           SPI_NOR_HAS_TB | SPI_NOR_TB_SR_BIT6 |
+                           SPI_NOR_HAS_LOCK | SPI_NOR_4BIT_BP) },

Looks good. Let's put these flags in some king of order:

SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | SPI_NOR_HAS_LOCK | SPI_NOR_HAS_TB | SPI_NOR_TB_SR_BIT6 | SPI_NOR_4BIT_BP

Cheers,
ta

Quoted 6 lines
drivers/mtd/spi-nor/winbond.c +0 -1
        { "w25m512jv", INFO(0xef7119, 0, 64 * 1024, 1024,
                            SECT_4K | SPI_NOR_QUAD_READ | SPI_NOR_DUAL_READ) },
 };
--

2.30.1

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

#2 lore raw

Hi Tudor,

Quoted 6 lines · On 3/8/21 6:50 AM, [email protected] wrote:
Quoted 5 lines · David Bauer

EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe

The Winbond W25Q512JV is a 512mb SPI-NOR chip. It supports 4K sectors as well as block protection and Dual-/Quad-read.

Quoted 6 lines
Quoted 3 lines

Tested on: Ubiquiti UniFi 6 LR

David, I'll take Shuhao's patch because he sent it first:
https://patchwork.ozlabs.org/project/linux-mtd/patch/[email protected]/

Fine with me, I have not found this patch :)

Quoted 3 lines

Would you make an incremental patch on top op Shuhao's, to add the locking support?

Sure, It's necessary for the board (UniFi 6 LR), as the bootloader locks the flash on boot.

I'll send a new patch for the lock support.

Best
David

Quoted 23 lines

Shuhao, can you please test the locking ops with mtd-utils?

Quoted 9 lines
---
 drivers/mtd/spi-nor/winbond.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/mtd/spi-nor/winbond.c +0 -0
index e5dfa786f190..49d0d7993368 100644

drivers/mtd/spi-nor/winbond.c static const struct flash_info winbond_parts[] = { · line 101

Quoted 7 lines
drivers/mtd/spi-nor/winbond.c +4 -0
@@ -95,6 +95,10 @@ static const struct flash_info winbond_parts[] = {
                             SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
        { "w25q256jw", INFO(0xef6019, 0, 64 * 1024, 512,
                             SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
+       { "w25q512jv", INFO(0xef4020, 0, 64 * 1024, 1024,
+                           SECT_4K | SPI_NOR_QUAD_READ | SPI_NOR_DUAL_READ |
+                           SPI_NOR_HAS_TB | SPI_NOR_TB_SR_BIT6 |
+                           SPI_NOR_HAS_LOCK | SPI_NOR_4BIT_BP) },

Looks good. Let's put these flags in some king of order:

Quoted 15 lines

SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | SPI_NOR_HAS_LOCK | SPI_NOR_HAS_TB | SPI_NOR_TB_SR_BIT6 | SPI_NOR_4BIT_BP

Cheers,
ta

Quoted 6 lines
drivers/mtd/spi-nor/winbond.c +0 -1
        { "w25m512jv", INFO(0xef7119, 0, 64 * 1024, 1024,
                            SECT_4K | SPI_NOR_QUAD_READ | SPI_NOR_DUAL_READ) },
 };
--

2.30.1

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

#3 lore raw
Quoted 18 lines · David Bauer

EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe

Hi Tudor,

Quoted 6 lines · On 3/8/21 6:50 AM, [email protected] wrote:
Quoted 5 lines · David Bauer

EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe

The Winbond W25Q512JV is a 512mb SPI-NOR chip. It supports 4K sectors as well as block protection and Dual-/Quad-read.

Quoted 6 lines
Quoted 3 lines

Tested on: Ubiquiti UniFi 6 LR

David, I'll take Shuhao's patch because he sent it first:
https://patchwork.ozlabs.org/project/linux-mtd/patch/[email protected]/

Quoted 7 lines

Fine with me, I have not found this patch :)

Quoted 3 lines

Would you make an incremental patch on top op Shuhao's, to add the locking support?

Sure, It's necessary for the board (UniFi 6 LR), as the bootloader locks the flash on boot.

Is it necessary to unlock the flash at boot time? You can unlock the flash from user-space, using mtd-utils.

Have you tried to lock/unlock portions of the flash using mtd-utils, and check if what was locked corresponds to what the datasheet indicates?

Quoted 3 lines

I'll send a new patch for the lock support.

Great, thanks!
ta
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

#4 lore raw
Quoted 30 lines · On Tue, Mar 09, 2021 at 07:53:59AM +0000, [email protected] wrote:
Quoted 18 lines · David Bauer

EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe

Hi Tudor,

Quoted 6 lines · On 3/8/21 6:50 AM, [email protected] wrote:
Quoted 5 lines · David Bauer

EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe

The Winbond W25Q512JV is a 512mb SPI-NOR chip. It supports 4K sectors as well as block protection and Dual-/Quad-read.

Quoted 6 lines
Quoted 3 lines

Tested on: Ubiquiti UniFi 6 LR

David, I'll take Shuhao's patch because he sent it first:
https://patchwork.ozlabs.org/project/linux-mtd/patch/[email protected]/

Quoted 7 lines

Fine with me, I have not found this patch :)

Quoted 3 lines

Would you make an incremental patch on top op Shuhao's, to add the locking support?

Sure, It's necessary for the board (UniFi 6 LR), as the bootloader locks the flash on boot.

Is it necessary to unlock the flash at boot time? You can unlock the flash from user-space, using mtd-utils.

Quoted 8 lines

Have you tried to lock/unlock portions of the flash using mtd-utils, and check if what was locked corresponds to what the datasheet indicates?

Quoted 3 lines

I'll send a new patch for the lock support.

Great, thanks!
ta

Hi Tudor and David,

I made a quick test on flash_lock with kernel 5.8.18 and mtd-utils v2.1.2. It returns "could not lock device: /dev/mtd0" and "error 22 (Invalid argument)".

Could be the error caused by my test environment, if it's functional on UniFi 6 LR.

Sincerely
Shuhao

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

#5 lore raw

Hi Shuhao,

Sorry for coming back late to this.

Quoted 43 lines · Shuhao Mai
Quoted 30 lines · On Tue, Mar 09, 2021 at 07:53:59AM +0000, [email protected] wrote:
Quoted 18 lines · David Bauer

EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe

Hi Tudor,

Quoted 6 lines · On 3/8/21 6:50 AM, [email protected] wrote:
Quoted 5 lines · David Bauer

EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe

The Winbond W25Q512JV is a 512mb SPI-NOR chip. It supports 4K sectors as well as block protection and Dual-/Quad-read.

Quoted 6 lines
Quoted 3 lines

Tested on: Ubiquiti UniFi 6 LR

David, I'll take Shuhao's patch because he sent it first:
https://patchwork.ozlabs.org/project/linux-mtd/patch/[email protected]/

Quoted 7 lines

Fine with me, I have not found this patch :)

Quoted 3 lines

Would you make an incremental patch on top op Shuhao's, to add the locking support?

Sure, It's necessary for the board (UniFi 6 LR), as the bootloader locks the flash on boot.

Is it necessary to unlock the flash at boot time? You can unlock the flash from user-space, using mtd-utils.

Quoted 8 lines

Have you tried to lock/unlock portions of the flash using mtd-utils, and check if what was locked corresponds to what the datasheet indicates?

Quoted 3 lines

I'll send a new patch for the lock support.

Great, thanks!
ta

Hi Tudor and David,

Quoted 6 lines

I made a quick test on flash_lock with kernel 5.8.18 and mtd-utils v2.1.2. It returns "could not lock device: /dev/mtd0" and "error 22 (Invalid argument)".

Could be the error caused by my test environment, if it's functional on UniFi 6 LR.

Were these partitions starting with the first / ending with the last block on the flash chip? Locking / unlocking mtd partitions not aligned at the beginning / end of the chip sound will return invalid argument.

For the UniFi 6 LR, these flags are required, as otherwise the lower half of the flash remains write protected (the bootloader actively enables this protection for whatever reason).

I'll send a rebased patch adding the required flags shortly.

Best wishes
David

Quoted 5 lines

Sincerely
Shuhao

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

#6 lore raw
Quoted 58 lines · David Bauer

Hi Shuhao,

Sorry for coming back late to this.

Quoted 43 lines · Shuhao Mai
Quoted 30 lines · On Tue, Mar 09, 2021 at 07:53:59AM +0000, [email protected] wrote:
Quoted 18 lines · David Bauer

EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe

Hi Tudor,

Quoted 6 lines · On 3/8/21 6:50 AM, [email protected] wrote:
Quoted 5 lines · David Bauer

EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe

The Winbond W25Q512JV is a 512mb SPI-NOR chip. It supports 4K sectors as well as block protection and Dual-/Quad-read.

Quoted 6 lines
Quoted 3 lines

Tested on: Ubiquiti UniFi 6 LR

David, I'll take Shuhao's patch because he sent it first:
https://patchwork.ozlabs.org/project/linux-mtd/patch/[email protected]/

Quoted 7 lines

Fine with me, I have not found this patch :)

Quoted 3 lines

Would you make an incremental patch on top op Shuhao's, to add the locking support?

Sure, It's necessary for the board (UniFi 6 LR), as the bootloader locks the flash on boot.

Is it necessary to unlock the flash at boot time? You can unlock the flash from user-space, using mtd-utils.

Quoted 8 lines

Have you tried to lock/unlock portions of the flash using mtd-utils, and check if what was locked corresponds to what the datasheet indicates?

Quoted 3 lines

I'll send a new patch for the lock support.

Great, thanks!
ta

Hi Tudor and David,

Quoted 6 lines

I made a quick test on flash_lock with kernel 5.8.18 and mtd-utils v2.1.2. It returns "could not lock device: /dev/mtd0" and "error 22 (Invalid argument)".

Could be the error caused by my test environment, if it's functional on UniFi 6 LR.

Were these partitions starting with the first / ending with the last block on the flash chip? Locking / unlocking mtd partitions not aligned at the beginning / end of the chip sound will return invalid argument.

Quoted 8 lines

For the UniFi 6 LR, these flags are required, as otherwise the lower half of the flash remains write protected (the bootloader actively enables this protection for whatever reason).

I'll send a rebased patch adding the required flags shortly.

Best wishes
David

Hi David,

Thanks for advise, but the invalid argument is not caused by partition alignment. I traced the flow of flash_lock, and it does relate to my choice of platform.

In the function 'spi_nor_write_16bit_sr_and_check()', it will try to read SR2 before writing to SR1. However, there's no handler for reading SR2 in 'spi-nor/controllers/intel-spi.c'. It will return Invalid argument if we try to do any operation to SR2 on Intel's platform currently.

Best Regards,
Shuhao

Quoted 5 lines
Quoted 5 lines

Sincerely
Shuhao

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/