diff mbox series

[V8] mtd: spi-nor: winbond: add support for W25Q512NW-IM

Message ID 1648191975-1366-1-git-send-email-quic_c_sbhanu@quicinc.com
State Changes Requested
Delegated to: Pratyush Yadav
Headers show
Series [V8] mtd: spi-nor: winbond: add support for W25Q512NW-IM | expand

Commit Message

Shaik Sajida Bhanu March 25, 2022, 7:06 a.m. UTC
Add support for winbond W25Q512NW-IM chip.

Below are the tests done:

1. Verified flashing binary image on spi card using flashrom tool.
2. Verified OTP support, below are the test results:

 localhost / # cat
 /sys/bus/platform/devices/soc\@0/88dc000.spi/spi_master/spi16/
 spi16.0/spi-nor/jedec_id
 ef8020

 localhost / # cat
 /sys/bus/platform/devices/soc\@0/88dc000.spi/spi_master/spi16/
 spi16.0/spi-nor/manufacturer
 winbond

 localhost / # cat
 /sys/bus/platform/devices/soc\@0/88dc000.spi/spi_master/spi16/
 spi16.0/spi-nor/partname
 w25q512nwm

 localhost / # hexdump
 /sys/bus/platform/devices/soc\@0/88dc000.spi/spi_master/sp
 i16/spi16.0/spi-nor/sfdp
 0000000 4653 5044 0106 ff01 0600 1001 0080 ff00
 0000010 0084 0201 00d0 ff00 ffff ffff ffff ffff
 0000020 6800 6c65 6f6c 7720 726f 646c ffff ffff
 0000030 ffff ffff ffff ffff ffff ffff ffff ffff
 *
 0000080 20e5 fffb ffff 1fff eb44 6b08 3b08 bb42
 0000090 fffe ffff ffff 0000 ffff eb40 200c 520f
 00000a0 d810 0000 0233 00a6 e781 d914 63e9 3376
 00000b0 757a 757a bdf7 5cd5 f719 ff5d 70e9 a5f9
 00000c0 ffff ffff ffff ffff ffff ffff ffff ffff
 00000d0 0aff fff0 ff21 ffdc
 00000d8

 localhost / # md5sum
 /sys/bus/platform/devices/soc\@0/88dc000.spi/spi_master/spi
 16/spi16.0/spi-nor/sfdp
 106d89d6c049110bc94c01517cb4ce24
 /sys/bus/platform/devices/soc@0/88dc000.spi/
 spi_master/spi16/spi16.0/spi-nor/sfdp

3. Tested flash lock, below are the test results (looks like the lock is
 not working as expected, so when we do lock the whole card and tried to
 write, write was successful without any errors.)

 localhost ~ # flash_lock -i /dev/mtd0
 Device: /dev/mtd0
 Start: 0
 Len: 0x4000000
 Lock status: locked
 Return code: 1
 localhost ~ # mtd_debug erase /dev/mtd0 0x400000 4096
 Erased 4096 bytes from address 0x00400000 in flash
 localhost ~ # mtd_debug read /dev/mtd0 0x400000 4096
 temp
 Copied 4096 bytes from address 0x00400000 in flash
 to temp
 localhost ~ # mtd_debug write /dev/mtd0 0x400000
 4096 temp
 Copied 4096 bytes from temp to address 0x00400000
 in flash
 localhost ~ # flash_lock -u /dev/mtd0
 localhost ~ # flash_lock -i /dev/mtd0
 Device: /dev/mtd0
 Start: 0
 Len: 0x4000000
 Lock status: unlocked
 Return code: 0
 localhost ~ # mtd_debug erase /dev/mtd0 0x400000 4096
 Erased 4096 bytes from address 0x00400000 in flash
 localhost ~ # mtd_debug read /dev/mtd0 0x400000
 4096 tempCopied 4096 bytes from address 0x00400000 in
 flash to temp
 localhost ~ # mtd_debug write /dev/mtd0 0x400000 4096 temp
 Copied 4096 bytes from temp to address 0x00400000 in flash
 localhost ~ #

Signed-off-by: Shaik Sajida Bhanu <quic_c_sbhanu@quicinc.com>
Reviewed-by: Doug Anderson <dianders@chromium.org>
Reviewed-by: Michael Walle <michael@walle.cc>
---

localhost / # cat
/sys/bus/platform/devices/soc\@0/88dc000.spi/spi_master/spi16/
spi16.0/spi-nor/jedec_id
ef8020

localhost / # cat
/sys/bus/platform/devices/soc\@0/88dc000.spi/spi_master/spi16/
spi16.0/spi-nor/manufacturer
winbond

localhost / # cat
/sys/bus/platform/devices/soc\@0/88dc000.spi/spi_master/spi16/
spi16.0/spi-nor/partname
w25q512nwm

localhost / # hexdump
/sys/bus/platform/devices/soc\@0/88dc000.spi/spi_master/sp
i16/spi16.0/spi-nor/sfdp
0000000 4653 5044 0106 ff01 0600 1001 0080 ff00
0000010 0084 0201 00d0 ff00 ffff ffff ffff ffff
0000020 6800 6c65 6f6c 7720 726f 646c ffff ffff
0000030 ffff ffff ffff ffff ffff ffff ffff ffff
*
0000080 20e5 fffb ffff 1fff eb44 6b08 3b08 bb42
0000090 fffe ffff ffff 0000 ffff eb40 200c 520f
00000a0 d810 0000 0233 00a6 e781 d914 63e9 3376
00000b0 757a 757a bdf7 5cd5 f719 ff5d 70e9 a5f9
00000c0 ffff ffff ffff ffff ffff ffff ffff ffff
00000d0 0aff fff0 ff21 ffdc
00000d8

localhost / # md5sum
/sys/bus/platform/devices/soc\@0/88dc000.spi/spi_master/spi
16/spi16.0/spi-nor/sfdp
106d89d6c049110bc94c01517cb4ce24
/sys/bus/platform/devices/soc@0/88dc000.spi/
spi_master/spi16/spi16.0/spi-nor/sfdp

Changes since V1:
	- Added space before name of the flash part as suggested by
	  Doug.

Changes since V2:
	- Updated chip name as w25q512nwm as suggested by Doug.

Changes since V3:
	- Updated flash_info flags passing according to
	  below patch.

Changes since V4:
	- Added OTP support for SPI card as suggested by Michael Walle.
	- Updated SFDP flags passing as suggested by Pratyush Yadav.

Changes since V5:
	- Reordered flags passing info for spi nor as suggested by
	  Michael Walle.
	- Added SFDP dump info in commit as suggested by Michael Walle.

Changes since V6:
	- Updated commit subject and added md5sum in commit as suggested by
	  Michael Walle.
	- Reordered flags passing info for spi nor which has missed in V5 patch
	  as suggested by Michael Walle.

Changes since V7:
	- Updated commit message with test cases info as suggested by
	  Tudor Ambarus.
---
 drivers/mtd/spi-nor/winbond.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Pratyush Yadav April 19, 2022, 4:27 a.m. UTC | #1
On 25/03/22 12:36PM, Shaik Sajida Bhanu wrote:
> Add support for winbond W25Q512NW-IM chip.
> 
> Below are the tests done:
> 
> 1. Verified flashing binary image on spi card using flashrom tool.
> 2. Verified OTP support, below are the test results:
> 
>  localhost / # cat
>  /sys/bus/platform/devices/soc\@0/88dc000.spi/spi_master/spi16/
>  spi16.0/spi-nor/jedec_id
>  ef8020
> 
>  localhost / # cat
>  /sys/bus/platform/devices/soc\@0/88dc000.spi/spi_master/spi16/
>  spi16.0/spi-nor/manufacturer
>  winbond
> 
>  localhost / # cat
>  /sys/bus/platform/devices/soc\@0/88dc000.spi/spi_master/spi16/
>  spi16.0/spi-nor/partname
>  w25q512nwm
> 
>  localhost / # hexdump
>  /sys/bus/platform/devices/soc\@0/88dc000.spi/spi_master/sp
>  i16/spi16.0/spi-nor/sfdp
>  0000000 4653 5044 0106 ff01 0600 1001 0080 ff00
>  0000010 0084 0201 00d0 ff00 ffff ffff ffff ffff
>  0000020 6800 6c65 6f6c 7720 726f 646c ffff ffff
>  0000030 ffff ffff ffff ffff ffff ffff ffff ffff
>  *
>  0000080 20e5 fffb ffff 1fff eb44 6b08 3b08 bb42
>  0000090 fffe ffff ffff 0000 ffff eb40 200c 520f
>  00000a0 d810 0000 0233 00a6 e781 d914 63e9 3376
>  00000b0 757a 757a bdf7 5cd5 f719 ff5d 70e9 a5f9
>  00000c0 ffff ffff ffff ffff ffff ffff ffff ffff
>  00000d0 0aff fff0 ff21 ffdc
>  00000d8
> 
>  localhost / # md5sum
>  /sys/bus/platform/devices/soc\@0/88dc000.spi/spi_master/spi
>  16/spi16.0/spi-nor/sfdp
>  106d89d6c049110bc94c01517cb4ce24
>  /sys/bus/platform/devices/soc@0/88dc000.spi/
>  spi_master/spi16/spi16.0/spi-nor/sfdp
> 
> 3. Tested flash lock, below are the test results (looks like the lock is
>  not working as expected, so when we do lock the whole card and tried to
>  write, write was successful without any errors.)

What should we do with this then? Drop the locking support? Or is there 
something wrong/missing in SPI NOR core that needs to be fixed first so 
locking for this flash works?

> 
>  localhost ~ # flash_lock -i /dev/mtd0
>  Device: /dev/mtd0
>  Start: 0
>  Len: 0x4000000
>  Lock status: locked
>  Return code: 1
>  localhost ~ # mtd_debug erase /dev/mtd0 0x400000 4096
>  Erased 4096 bytes from address 0x00400000 in flash
>  localhost ~ # mtd_debug read /dev/mtd0 0x400000 4096
>  temp
>  Copied 4096 bytes from address 0x00400000 in flash
>  to temp
>  localhost ~ # mtd_debug write /dev/mtd0 0x400000
>  4096 temp
>  Copied 4096 bytes from temp to address 0x00400000
>  in flash
>  localhost ~ # flash_lock -u /dev/mtd0
>  localhost ~ # flash_lock -i /dev/mtd0
>  Device: /dev/mtd0
>  Start: 0
>  Len: 0x4000000
>  Lock status: unlocked
>  Return code: 0
>  localhost ~ # mtd_debug erase /dev/mtd0 0x400000 4096
>  Erased 4096 bytes from address 0x00400000 in flash
>  localhost ~ # mtd_debug read /dev/mtd0 0x400000
>  4096 tempCopied 4096 bytes from address 0x00400000 in
>  flash to temp
>  localhost ~ # mtd_debug write /dev/mtd0 0x400000 4096 temp
>  Copied 4096 bytes from temp to address 0x00400000 in flash
>  localhost ~ #
> 
> Signed-off-by: Shaik Sajida Bhanu <quic_c_sbhanu@quicinc.com>
> Reviewed-by: Doug Anderson <dianders@chromium.org>
> Reviewed-by: Michael Walle <michael@walle.cc>
[...]
Tudor Ambarus April 19, 2022, 7:32 a.m. UTC | #2
On 4/19/22 07:27, Pratyush Yadav wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
> 
> On 25/03/22 12:36PM, Shaik Sajida Bhanu wrote:
>> Add support for winbond W25Q512NW-IM chip.
>>
>> Below are the tests done:
>>
>> 1. Verified flashing binary image on spi card using flashrom tool.
>> 2. Verified OTP support, below are the test results:
>>
>>  localhost / # cat
>>  /sys/bus/platform/devices/soc\@0/88dc000.spi/spi_master/spi16/
>>  spi16.0/spi-nor/jedec_id
>>  ef8020
>>
>>  localhost / # cat
>>  /sys/bus/platform/devices/soc\@0/88dc000.spi/spi_master/spi16/
>>  spi16.0/spi-nor/manufacturer
>>  winbond
>>
>>  localhost / # cat
>>  /sys/bus/platform/devices/soc\@0/88dc000.spi/spi_master/spi16/
>>  spi16.0/spi-nor/partname
>>  w25q512nwm
>>
>>  localhost / # hexdump
>>  /sys/bus/platform/devices/soc\@0/88dc000.spi/spi_master/sp
>>  i16/spi16.0/spi-nor/sfdp
>>  0000000 4653 5044 0106 ff01 0600 1001 0080 ff00
>>  0000010 0084 0201 00d0 ff00 ffff ffff ffff ffff
>>  0000020 6800 6c65 6f6c 7720 726f 646c ffff ffff
>>  0000030 ffff ffff ffff ffff ffff ffff ffff ffff
>>  *
>>  0000080 20e5 fffb ffff 1fff eb44 6b08 3b08 bb42
>>  0000090 fffe ffff ffff 0000 ffff eb40 200c 520f
>>  00000a0 d810 0000 0233 00a6 e781 d914 63e9 3376
>>  00000b0 757a 757a bdf7 5cd5 f719 ff5d 70e9 a5f9
>>  00000c0 ffff ffff ffff ffff ffff ffff ffff ffff
>>  00000d0 0aff fff0 ff21 ffdc
>>  00000d8
>>
>>  localhost / # md5sum
>>  /sys/bus/platform/devices/soc\@0/88dc000.spi/spi_master/spi
>>  16/spi16.0/spi-nor/sfdp
>>  106d89d6c049110bc94c01517cb4ce24
>>  /sys/bus/platform/devices/soc@0/88dc000.spi/
>>  spi_master/spi16/spi16.0/spi-nor/sfdp
>>
>> 3. Tested flash lock, below are the test results (looks like the lock is
>>  not working as expected, so when we do lock the whole card and tried to
>>  write, write was successful without any errors.)
> 
> What should we do with this then? Drop the locking support? Or is there
> something wrong/missing in SPI NOR core that needs to be fixed first so
> locking for this flash works?
> 

If the locking isn't working for this flash, please drop the locking flags
until you identify the problem and fix it.

>>
>>  localhost ~ # flash_lock -i /dev/mtd0
>>  Device: /dev/mtd0
>>  Start: 0
>>  Len: 0x4000000
>>  Lock status: locked
>>  Return code: 1
>>  localhost ~ # mtd_debug erase /dev/mtd0 0x400000 4096
>>  Erased 4096 bytes from address 0x00400000 in flash
>>  localhost ~ # mtd_debug read /dev/mtd0 0x400000 4096
>>  temp
>>  Copied 4096 bytes from address 0x00400000 in flash
>>  to temp
>>  localhost ~ # mtd_debug write /dev/mtd0 0x400000
>>  4096 temp
>>  Copied 4096 bytes from temp to address 0x00400000
>>  in flash
>>  localhost ~ # flash_lock -u /dev/mtd0
>>  localhost ~ # flash_lock -i /dev/mtd0
>>  Device: /dev/mtd0
>>  Start: 0
>>  Len: 0x4000000
>>  Lock status: unlocked
>>  Return code: 0
>>  localhost ~ # mtd_debug erase /dev/mtd0 0x400000 4096
>>  Erased 4096 bytes from address 0x00400000 in flash
>>  localhost ~ # mtd_debug read /dev/mtd0 0x400000
>>  4096 tempCopied 4096 bytes from address 0x00400000 in
>>  flash to temp
>>  localhost ~ # mtd_debug write /dev/mtd0 0x400000 4096 temp
>>  Copied 4096 bytes from temp to address 0x00400000 in flash
>>  localhost ~ #
>>
>> Signed-off-by: Shaik Sajida Bhanu <quic_c_sbhanu@quicinc.com>
>> Reviewed-by: Doug Anderson <dianders@chromium.org>
>> Reviewed-by: Michael Walle <michael@walle.cc>
> [...]
> 
> --
> Regards,
> Pratyush Yadav
> Texas Instruments Inc.
Michael Walle April 21, 2022, 9:48 p.m. UTC | #3
Am 2022-03-25 08:06, schrieb Shaik Sajida Bhanu:

> 0000000 4653 5044 0106 ff01 0600 1001 0080 ff00
> 0000010 0084 0201 00d0 ff00 ffff ffff ffff ffff
> 0000020 6800 6c65 6f6c 7720 726f 646c ffff ffff
> 0000030 ffff ffff ffff ffff ffff ffff ffff ffff
> *
> 0000080 20e5 fffb ffff 1fff eb44 6b08 3b08 bb42
> 0000090 fffe ffff ffff 0000 ffff eb40 200c 520f
> 00000a0 d810 0000 0233 00a6 e781 d914 63e9 3376
> 00000b0 757a 757a bdf7 5cd5 f719 ff5d 70e9 a5f9
> 00000c0 ffff ffff ffff ffff ffff ffff ffff ffff
> 00000d0 0aff fff0 ff21 ffdc
> 00000d8

00000000  53 46 44 50 06 01 01 ff  00 06 01 10 80 00 00 ff  
|SFDP............|
00000010  84 00 01 02 d0 00 00 ff  ff ff ff ff ff ff ff ff  
|................|
00000020  00 68 65 6c 6c 6f 20 77  6f 72 6c 64 ff ff ff ff  |.hello 
world....|
00000030  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  
|................|
*
00000080  e5 20 fb ff ff ff ff 1f  44 eb 08 6b 08 3b 42 bb  |. 
......D..k.;B.|
00000090  fe ff ff ff ff ff 00 00  ff ff 40 eb 0c 20 0f 52  
|..........@.. .R|
000000a0  10 d8 00 00 33 02 a6 00  81 e7 14 d9 e9 63 76 33  
|....3........cv3|
000000b0  7a 75 7a 75 f7 bd d5 5c  19 f7 5d ff e9 70 f9 a5  
|zuzu...\..]..p..|
000000c0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  
|................|
000000d0  ff 0a f0 ff 21 ff dc ff                           |....!...|

Hello World!

-michael
Shaik Sajida Bhanu April 29, 2022, 11:35 a.m. UTC | #4
Hi,

Thanks for the review.

Please find the inline comments.

Thanks,
Sajida

On 4/19/2022 1:02 PM, Tudor.Ambarus@microchip.com wrote:

> On 4/19/22 07:27, Pratyush Yadav wrote:
>> EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
>>
>> On 25/03/22 12:36PM, Shaik Sajida Bhanu wrote:
>>> Add support for winbond W25Q512NW-IM chip.
>>>
>>> Below are the tests done:
>>>
>>> 1. Verified flashing binary image on spi card using flashrom tool.
>>> 2. Verified OTP support, below are the test results:
>>>
>>>   localhost / # cat
>>>   /sys/bus/platform/devices/soc\@0/88dc000.spi/spi_master/spi16/
>>>   spi16.0/spi-nor/jedec_id
>>>   ef8020
>>>
>>>   localhost / # cat
>>>   /sys/bus/platform/devices/soc\@0/88dc000.spi/spi_master/spi16/
>>>   spi16.0/spi-nor/manufacturer
>>>   winbond
>>>
>>>   localhost / # cat
>>>   /sys/bus/platform/devices/soc\@0/88dc000.spi/spi_master/spi16/
>>>   spi16.0/spi-nor/partname
>>>   w25q512nwm
>>>
>>>   localhost / # hexdump
>>>   /sys/bus/platform/devices/soc\@0/88dc000.spi/spi_master/sp
>>>   i16/spi16.0/spi-nor/sfdp
>>>   0000000 4653 5044 0106 ff01 0600 1001 0080 ff00
>>>   0000010 0084 0201 00d0 ff00 ffff ffff ffff ffff
>>>   0000020 6800 6c65 6f6c 7720 726f 646c ffff ffff
>>>   0000030 ffff ffff ffff ffff ffff ffff ffff ffff
>>>   *
>>>   0000080 20e5 fffb ffff 1fff eb44 6b08 3b08 bb42
>>>   0000090 fffe ffff ffff 0000 ffff eb40 200c 520f
>>>   00000a0 d810 0000 0233 00a6 e781 d914 63e9 3376
>>>   00000b0 757a 757a bdf7 5cd5 f719 ff5d 70e9 a5f9
>>>   00000c0 ffff ffff ffff ffff ffff ffff ffff ffff
>>>   00000d0 0aff fff0 ff21 ffdc
>>>   00000d8
>>>
>>>   localhost / # md5sum
>>>   /sys/bus/platform/devices/soc\@0/88dc000.spi/spi_master/spi
>>>   16/spi16.0/spi-nor/sfdp
>>>   106d89d6c049110bc94c01517cb4ce24
>>>   /sys/bus/platform/devices/soc@0/88dc000.spi/
>>>   spi_master/spi16/spi16.0/spi-nor/sfdp
>>>
>>> 3. Tested flash lock, below are the test results (looks like the lock is
>>>   not working as expected, so when we do lock the whole card and tried to
>>>   write, write was successful without any errors.)
>> What should we do with this then? Drop the locking support? Or is there
>> something wrong/missing in SPI NOR core that needs to be fixed first so
>> locking for this flash works?
>>
> If the locking isn't working for this flash, please drop the locking flags
> until you identify the problem and fix it.
Okay for now dropping locking flag.
>>>   localhost ~ # flash_lock -i /dev/mtd0
>>>   Device: /dev/mtd0
>>>   Start: 0
>>>   Len: 0x4000000
>>>   Lock status: locked
>>>   Return code: 1
>>>   localhost ~ # mtd_debug erase /dev/mtd0 0x400000 4096
>>>   Erased 4096 bytes from address 0x00400000 in flash
>>>   localhost ~ # mtd_debug read /dev/mtd0 0x400000 4096
>>>   temp
>>>   Copied 4096 bytes from address 0x00400000 in flash
>>>   to temp
>>>   localhost ~ # mtd_debug write /dev/mtd0 0x400000
>>>   4096 temp
>>>   Copied 4096 bytes from temp to address 0x00400000
>>>   in flash
>>>   localhost ~ # flash_lock -u /dev/mtd0
>>>   localhost ~ # flash_lock -i /dev/mtd0
>>>   Device: /dev/mtd0
>>>   Start: 0
>>>   Len: 0x4000000
>>>   Lock status: unlocked
>>>   Return code: 0
>>>   localhost ~ # mtd_debug erase /dev/mtd0 0x400000 4096
>>>   Erased 4096 bytes from address 0x00400000 in flash
>>>   localhost ~ # mtd_debug read /dev/mtd0 0x400000
>>>   4096 tempCopied 4096 bytes from address 0x00400000 in
>>>   flash to temp
>>>   localhost ~ # mtd_debug write /dev/mtd0 0x400000 4096 temp
>>>   Copied 4096 bytes from temp to address 0x00400000 in flash
>>>   localhost ~ #
>>>
>>> Signed-off-by: Shaik Sajida Bhanu <quic_c_sbhanu@quicinc.com>
>>> Reviewed-by: Doug Anderson <dianders@chromium.org>
>>> Reviewed-by: Michael Walle <michael@walle.cc>
>> [...]
>>
>> --
>> Regards,
>> Pratyush Yadav
>> Texas Instruments Inc.
diff mbox series

Patch

diff --git a/drivers/mtd/spi-nor/winbond.c b/drivers/mtd/spi-nor/winbond.c
index fe80dff..048ffb4 100644
--- a/drivers/mtd/spi-nor/winbond.c
+++ b/drivers/mtd/spi-nor/winbond.c
@@ -124,6 +124,10 @@  static const struct flash_info winbond_nor_parts[] = {
 	{ "w25m512jv", INFO(0xef7119, 0, 64 * 1024, 1024)
 		NO_SFDP_FLAGS(SECT_4K | SPI_NOR_QUAD_READ |
 			      SPI_NOR_DUAL_READ) },
+	{ "w25q512nwm", INFO(0xef8020, 0, 64 * 1024, 1024)
+		PARSE_SFDP
+		FLAGS(SPI_NOR_HAS_LOCK | SPI_NOR_HAS_TB)
+		OTP_INFO(256, 3, 0x1000, 0x1000) },
 	{ "w25q512jvq", INFO(0xef4020, 0, 64 * 1024, 1024)
 		NO_SFDP_FLAGS(SECT_4K | SPI_NOR_DUAL_READ |
 			      SPI_NOR_QUAD_READ) },