[PATCH v2] mtd: spi-nor: atmel: add at25ff321a entry

From: nicolas.ferre
Date: Tue Sep 26 2023 - 09:17:59 EST


From: Nicolas Ferre <nicolas.ferre@xxxxxxxxxxxxx>

Add the at25ff321a 4MB SPI flash which is able to provide
SFDP informations.
Datasheet: https://www.renesas.com/us/en/document/dst/at25ff321a-datasheet

Signed-off-by: Nicolas Ferre <nicolas.ferre@xxxxxxxxxxxxx>
---
v1 -> v2: - adapt to new struct flash_info atmel_nor_parts init
- don't set the no_sfdp_flags property

Hi,

This flash is present on the MikoE flash 10 Click board and was tested on
sama7g5-ek at spi frequency of 80 MHz:

Here are the tests that I ran:
root@sama5d27-wlsom1-ek-sd:~# dd if=/dev/urandom of=./spi_test bs=1M count=3
3+0 records in
3+0 records out
3145728 bytes (3.1 MB, 3.0 MiB) copied, 0.285407 s, 11.0 MB/s
root@sama5d27-wlsom1-ek-sd:~# mtd_debug write /dev/mtd0 0 3145728 spi_test
Copied 3145728 bytes from spi_test to address 0x00000000 in flash
root@sama5d27-wlsom1-ek-sd:~# mtd_debug erase /dev/mtd0 0 3145728
Erased 3145728 bytes from address 0x00000000 in flash
root@sama5d27-wlsom1-ek-sd:~# mtd_debug read /dev/mtd0 0 3145728 spi_read
Copied 3145728 bytes from address 0x00000000 in flash to spi_read
root@sama5d27-wlsom1-ek-sd:~# hexdump spi_read
0000000 ffff ffff ffff ffff ffff ffff ffff ffff
*
0300000
root@sama5d27-wlsom1-ek-sd:~# mtd_debug write /dev/mtd0 0 3145728 spi_test
Copied 3145728 bytes from spi_test to address 0x00000000 in flash
root@sama5d27-wlsom1-ek-sd:~# mtd_debug read /dev/mtd0 0 3145728 spi_read
Copied 3145728 bytes from address 0x00000000 in flash to spi_read
root@sama5d27-wlsom1-ek-sd:~# sha1sum spi_test spi_read
4de5dbe39ab24b169e9dad01a8cc12c4756270a2 spi_test
4de5dbe39ab24b169e9dad01a8cc12c4756270a2 spi_read

root@sama5d27-wlsom1-ek-sd:~# cat /sys/bus/spi/devices/spi0.1/spi-nor/partname
at25ff321a
root@sama5d27-wlsom1-ek-sd:~# cat /sys/bus/spi/devices/spi0.1/spi-nor/jedec_id
1f4708
root@sama5d27-wlsom1-ek-sd:~# cat /sys/bus/spi/devices/spi0.1/spi-nor/manufacturer
atmel
root@sama5d27-wlsom1-ek-sd:~# hexdump -C /sys/bus/spi/devices/spi0.1/spi-nor/sfdp
00000000 53 46 44 50 06 01 00 ff 00 06 01 10 10 00 00 ff |SFDP............|
00000010 e5 20 e1 ff ff ff ff 01 40 eb 08 6b 08 3b 00 ff |. ......@..k.;..|
00000020 ee ff ff ff ff ff 00 ff ff ff 00 ff 0c 20 0f 52 |............. .R|
00000030 10 d8 00 ff 50 2a 2a 01 82 ff 9c d2 64 c1 08 46 |....P**.....d..F|
00000040 7a 75 7a 75 f7 c4 d5 5c 00 06 51 ff 88 30 00 00 |zuzu...\..Q..0..|
00000050
root@sama5d27-wlsom1-ek-sd:~# md5sum /sys/bus/spi/devices/spi0.1/spi-nor/sfdp
d540f07cbfb7c9c19654c453b561b311 /sys/bus/spi/devices/spi0.1/spi-nor/sfdp

# # CONFIG_MTD_SPI_NOR_USE_4K_SECTORS is not set
root@sama5d27-wlsom1-ek-sd:~# mtdinfo /dev/mtd0
mtd0
Name: spi0.1
Type: nor
Eraseblock size: 65536 bytes, 64.0 KiB
Amount of eraseblocks: 64 (4194304 bytes, 4.0 MiB)
Minimum input/output unit size: 1 byte
Sub-page size: 1 byte
Character device major/minor: 90:0
Bad blocks are allowed: false
Device is writable: true

Best regards,
Nicolas

drivers/mtd/spi-nor/atmel.c | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/drivers/mtd/spi-nor/atmel.c b/drivers/mtd/spi-nor/atmel.c
index 95f0e139284e..e13b8d2dd50a 100644
--- a/drivers/mtd/spi-nor/atmel.c
+++ b/drivers/mtd/spi-nor/atmel.c
@@ -213,6 +213,11 @@ static const struct flash_info atmel_nor_parts[] = {
.flags = SPI_NOR_HAS_LOCK | SPI_NOR_SWP_IS_VOLATILE,
.no_sfdp_flags = SECT_4K,
.fixups = &atmel_nor_global_protection_fixups
+ }, {
+ .id = SNOR_ID(0x1f, 0x47, 0x08),
+ .name = "at25ff321a",
+ .flags = SPI_NOR_HAS_LOCK | SPI_NOR_SWP_IS_VOLATILE,
+ .fixups = &atmel_nor_global_protection_fixups
}, {
.id = SNOR_ID(0x1f, 0x48, 0x00),
.name = "at25df641",
--
2.39.2