mtd: spi-nor: atmel: remove global SNOR_F_HAS_LOCK
RFC PATCH 1/2 mtd: spi-nor: atmel: remove global SNOR_F_HAS_LOCK
This is considered bad for the following reasons:
(1) We only support the block protection with BPn bits for write protection. Not all Atmel parts support this.
(2) Newly added flash chip will automatically inherit the "has locking" support and thus needs to explicitly tested. Better be opt-in instead of opt-out.
(3) There are already supported flashes which don't support the locking scheme. So I assume this wasn't properly tested before adding that chip; which enforces my previous argument that locking support should be an opt-in.
Remove the global flag and add individual flags to all flashes which supports BP locking. In particular the following flashes don't support the BP scheme:
- AT26F004
- AT25SL321
- AT45DB081D
--- drivers/mtd/spi-nor/atmel.c | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-)
drivers/mtd/spi-nor/atmel.c +9 -19
@@ -10,37 +10,27 @@static const struct flash_info atmel_parts[] = {/* Atmel -- some are (confusingly) marketed as "DataFlash" */ - {"at25fs010" ,INFO (0x1f6601 ,0 ,32 *1024 ,4 ,SECT_4K ) }, - {"at25fs040" ,INFO (0x1f6604 ,0 ,64 *1024 ,8 ,SECT_4K ) }, + {"at25fs010" ,INFO (0x1f6601 ,0 ,32 *1024 ,4 ,SECT_4K |SPI_NOR_HAS_LOCK ) }, + {"at25fs040" ,INFO (0x1f6604 ,0 ,64 *1024 ,8 ,SECT_4K |SPI_NOR_HAS_LOCK ) }, - {"at25df041a" ,INFO (0x1f4401 ,0 ,64 *1024 ,8 ,SECT_4K ) }, - {"at25df321" ,INFO (0x1f4700 ,0 ,64 *1024 ,64 ,SECT_4K ) }, - {"at25df321a" ,INFO (0x1f4701 ,0 ,64 *1024 ,64 ,SECT_4K ) }, - {"at25df641" ,INFO (0x1f4800 ,0 ,64 *1024 ,128 ,SECT_4K ) }, + {"at25df041a" ,INFO (0x1f4401 ,0 ,64 *1024 ,8 ,SECT_4K |SPI_NOR_HAS_LOCK ) }, + {"at25df321" ,INFO (0x1f4700 ,0 ,64 *1024 ,64 ,SECT_4K |SPI_NOR_HAS_LOCK ) }, + {"at25df321a" ,INFO (0x1f4701 ,0 ,64 *1024 ,64 ,SECT_4K |SPI_NOR_HAS_LOCK ) }, + {"at25df641" ,INFO (0x1f4800 ,0 ,64 *1024 ,128 ,SECT_4K |SPI_NOR_HAS_LOCK ) }, {"at25sl321" ,INFO (0x1f4216 ,0 ,64 *1024 ,64 ,SECT_4K |SPI_NOR_DUAL_READ |SPI_NOR_QUAD_READ ) }, {"at26f004" ,INFO (0x1f0400 ,0 ,64 *1024 ,8 ,SECT_4K ) }, - {"at26df081a" ,INFO (0x1f4501 ,0 ,64 *1024 ,16 ,SECT_4K ) }, - {"at26df161a" ,INFO (0x1f4601 ,0 ,64 *1024 ,32 ,SECT_4K ) }, - {"at26df321" ,INFO (0x1f4700 ,0 ,64 *1024 ,64 ,SECT_4K ) }, + {"at26df081a" ,INFO (0x1f4501 ,0 ,64 *1024 ,16 ,SECT_4K |SPI_NOR_HAS_LOCK ) }, + {"at26df161a" ,INFO (0x1f4601 ,0 ,64 *1024 ,32 ,SECT_4K |SPI_NOR_HAS_LOCK ) }, + {"at26df321" ,INFO (0x1f4700 ,0 ,64 *1024 ,64 ,SECT_4K |SPI_NOR_HAS_LOCK ) }, {"at45db081d" ,INFO (0x1f2500 ,0 ,64 *1024 ,16 ,SECT_4K ) }, }; -static void atmel_default_init (struct spi_nor *nor) -{ - nor->flags |=SNOR_F_HAS_LOCK ; -} - -static const struct spi_nor_fixups atmel_fixups = { - .default_init = atmel_default_init, -}; -const struct spi_nor_manufacturer spi_nor_atmel = { .name ="atmel" , .parts = atmel_parts, .nparts =ARRAY_SIZE (atmel_parts), - .fixups = &atmel_fixups, };
Signature · 1 line
2.20.1
RFC PATCH 2/2 mtd: spi-nor: sst: remove global SNOR_F_HAS_LOCK
This is considered bad for the following reasons:
(1) We only support the block protection with BPn bits for write protection. Not all SST parts support this.
(2) Newly added flash chip will automatically inherit the "has locking" support and thus needs to explicitly tested. Better be opt-in instead of opt-out.
(3) There are already supported flashes which don't support the locking scheme. So I assume this wasn't properly tested before adding that chip; which enforces my previous argument that locking support should be an opt-in.
Remove the global flag and add individual flags to all flashes which supports BP locking. In particular the following flashes don't support the BP scheme:
- SST26VF016B
- SST26WF016B
- SST26VF064B
--- drivers/mtd/spi-nor/sst.c | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-)
drivers/mtd/spi-nor/sst.c +12 -18
@@ -11,26 +11,26 @@static const struct flash_info sst_parts[] = {/* SST -- large erase sizes are "overlays", "sectors" are 4K */ {"sst25vf040b" ,INFO (0xbf258d ,0 ,64 *1024 ,8 , -SECT_4K |SST_WRITE ) }, +SECT_4K |SST_WRITE |SPI_NOR_HAS_LOCK ) }, {"sst25vf080b" ,INFO (0xbf258e ,0 ,64 *1024 ,16 , -SECT_4K |SST_WRITE ) }, +SECT_4K |SST_WRITE |SPI_NOR_HAS_LOCK ) }, {"sst25vf016b" ,INFO (0xbf2541 ,0 ,64 *1024 ,32 , -SECT_4K |SST_WRITE ) }, +SECT_4K |SST_WRITE |SPI_NOR_HAS_LOCK ) }, {"sst25vf032b" ,INFO (0xbf254a ,0 ,64 *1024 ,64 , -SECT_4K |SST_WRITE ) }, - {"sst25vf064c" ,INFO (0xbf254b ,0 ,64 *1024 ,128 ,SECT_4K ) }, +SECT_4K |SST_WRITE |SPI_NOR_HAS_LOCK ) }, + {"sst25vf064c" ,INFO (0xbf254b ,0 ,64 *1024 ,128 ,SECT_4K |SPI_NOR_HAS_LOCK ) }, {"sst25wf512" ,INFO (0xbf2501 ,0 ,64 *1024 ,1 , -SECT_4K |SST_WRITE ) }, +SECT_4K |SST_WRITE |SPI_NOR_HAS_LOCK ) }, {"sst25wf010" ,INFO (0xbf2502 ,0 ,64 *1024 ,2 , -SECT_4K |SST_WRITE ) }, +SECT_4K |SST_WRITE |SPI_NOR_HAS_LOCK ) }, {"sst25wf020" ,INFO (0xbf2503 ,0 ,64 *1024 ,4 , -SECT_4K |SST_WRITE ) }, - {"sst25wf020a" ,INFO (0x621612 ,0 ,64 *1024 ,4 ,SECT_4K ) }, - {"sst25wf040b" ,INFO (0x621613 ,0 ,64 *1024 ,8 ,SECT_4K ) }, +SECT_4K |SST_WRITE |SPI_NOR_HAS_LOCK ) }, + {"sst25wf020a" ,INFO (0x621612 ,0 ,64 *1024 ,4 ,SECT_4K |SPI_NOR_HAS_LOCK ) }, + {"sst25wf040b" ,INFO (0x621613 ,0 ,64 *1024 ,8 ,SECT_4K |SPI_NOR_HAS_LOCK ) }, {"sst25wf040" ,INFO (0xbf2504 ,0 ,64 *1024 ,8 , -SECT_4K |SST_WRITE ) }, +SECT_4K |SST_WRITE |SPI_NOR_HAS_LOCK ) }, {"sst25wf080" ,INFO (0xbf2505 ,0 ,64 *1024 ,16 , -SECT_4K |SST_WRITE ) }, +SECT_4K |SST_WRITE |SPI_NOR_HAS_LOCK ) }, {"sst26wf016b" ,INFO (0xbf2651 ,0 ,64 *1024 ,32 ,SECT_4K |SPI_NOR_DUAL_READ |SPI_NOR_QUAD_READ ) },
@@ -127,11 +127,6 @@ static int sst_write(struct mtd_info *mtd, loff_t to, size_t len,return ret; } -static void sst_default_init (struct spi_nor *nor) -{ - nor->flags |=SNOR_F_HAS_LOCK ; -} -static void sst_post_sfdp_fixups (struct spi_nor *nor) {if (nor->info->flags &SST_WRITE )
@@ -139,7 +134,6 @@ static void sst_post_sfdp_fixups(struct spi_nor *nor) }static const struct spi_nor_fixups sst_fixups = { - .default_init = sst_default_init, .post_sfdp = sst_post_sfdp_fixups, };
Signature · 1 line
2.20.1
Quoted 13 lines · Michael Walle
EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
This is considered bad for the following reasons:
(1) We only support the block protection with BPn bits for write protection. Not all Atmel parts support this.
(2) Newly added flash chip will automatically inherit the "has locking" support and thus needs to explicitly tested. Better be opt-in instead of opt-out.
(3) There are already supported flashes which don't support the locking scheme. So I assume this wasn't properly tested before adding that chip; which enforces my previous argument that locking support should be an opt-in.
Quoted 7 lines
Remove the global flag and add individual flags to all flashes which supports BP locking. In particular the following flashes don't support the BP scheme:
- AT26F004
- AT25SL321
- AT45DB081D
I like the idea. Thanks for the effort. Will check all those datasheets and get back to you.
Quoted 59 lines
Signed-off-by Michael Walle <[email protected]>--- drivers/mtd/spi-nor/atmel.c | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-)drivers/mtd/spi-nor/atmel.c +9
-20@@ -10,37 +10,27 @@static const struct flash_info atmel_parts[] = {/* Atmel -- some are (confusingly) marketed as "DataFlash" */ - {"at25fs010" ,INFO (0x1f6601 ,0 ,32 *1024 ,4 ,SECT_4K ) }, - {"at25fs040" ,INFO (0x1f6604 ,0 ,64 *1024 ,8 ,SECT_4K ) }, + {"at25fs010" ,INFO (0x1f6601 ,0 ,32 *1024 ,4 ,SECT_4K |SPI_NOR_HAS_LOCK ) }, + {"at25fs040" ,INFO (0x1f6604 ,0 ,64 *1024 ,8 ,SECT_4K |SPI_NOR_HAS_LOCK ) }, - {"at25df041a" ,INFO (0x1f4401 ,0 ,64 *1024 ,8 ,SECT_4K ) }, - {"at25df321" ,INFO (0x1f4700 ,0 ,64 *1024 ,64 ,SECT_4K ) }, - {"at25df321a" ,INFO (0x1f4701 ,0 ,64 *1024 ,64 ,SECT_4K ) }, - {"at25df641" ,INFO (0x1f4800 ,0 ,64 *1024 ,128 ,SECT_4K ) }, + {"at25df041a" ,INFO (0x1f4401 ,0 ,64 *1024 ,8 ,SECT_4K |SPI_NOR_HAS_LOCK ) }, + {"at25df321" ,INFO (0x1f4700 ,0 ,64 *1024 ,64 ,SECT_4K |SPI_NOR_HAS_LOCK ) }, + {"at25df321a" ,INFO (0x1f4701 ,0 ,64 *1024 ,64 ,SECT_4K |SPI_NOR_HAS_LOCK ) }, + {"at25df641" ,INFO (0x1f4800 ,0 ,64 *1024 ,128 ,SECT_4K |SPI_NOR_HAS_LOCK ) }, {"at25sl321" ,INFO (0x1f4216 ,0 ,64 *1024 ,64 ,SECT_4K |SPI_NOR_DUAL_READ |SPI_NOR_QUAD_READ ) }, {"at26f004" ,INFO (0x1f0400 ,0 ,64 *1024 ,8 ,SECT_4K ) }, - {"at26df081a" ,INFO (0x1f4501 ,0 ,64 *1024 ,16 ,SECT_4K ) }, - {"at26df161a" ,INFO (0x1f4601 ,0 ,64 *1024 ,32 ,SECT_4K ) }, - {"at26df321" ,INFO (0x1f4700 ,0 ,64 *1024 ,64 ,SECT_4K ) }, + {"at26df081a" ,INFO (0x1f4501 ,0 ,64 *1024 ,16 ,SECT_4K |SPI_NOR_HAS_LOCK ) }, + {"at26df161a" ,INFO (0x1f4601 ,0 ,64 *1024 ,32 ,SECT_4K |SPI_NOR_HAS_LOCK ) }, + {"at26df321" ,INFO (0x1f4700 ,0 ,64 *1024 ,64 ,SECT_4K |SPI_NOR_HAS_LOCK ) }, {"at45db081d" ,INFO (0x1f2500 ,0 ,64 *1024 ,16 ,SECT_4K ) }, }; -static void atmel_default_init (struct spi_nor *nor) -{ - nor->flags |=SNOR_F_HAS_LOCK ; -} - -static const struct spi_nor_fixups atmel_fixups = { - .default_init = atmel_default_init, -}; -const struct spi_nor_manufacturer spi_nor_atmel = { .name ="atmel" , .parts = atmel_parts, .nparts =ARRAY_SIZE (atmel_parts), - .fixups = &atmel_fixups, }; --2.20.1
Quoted 30 lines · Michael Walle
EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
This is considered bad for the following reasons:
(1) We only support the block protection with BPn bits for write protection. Not all Atmel parts support this.
(2) Newly added flash chip will automatically inherit the "has locking" support and thus needs to explicitly tested. Better be opt-in instead of opt-out.
(3) There are already supported flashes which don't support the locking scheme. So I assume this wasn't properly tested before adding that chip; which enforces my previous argument that locking support should be an opt-in.Remove the global flag and add individual flags to all flashes which supports BP locking. In particular the following flashes don't support the BP scheme:
- AT26F004
- AT25SL321
- AT45DB081DSigned-off-by Michael Walle <[email protected]>--- drivers/mtd/spi-nor/atmel.c | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-)drivers/mtd/spi-nor/atmel.c +0
-0
drivers/mtd/spi-nor/atmel.c line 14
Quoted 7 lines
drivers/mtd/spi-nor/atmel.c +2
-2@@ -10,37 +10,27 @@static const struct flash_info atmel_parts[] = {/* Atmel -- some are (confusingly) marketed as "DataFlash" */ - {"at25fs010" ,INFO (0x1f6601 ,0 ,32 *1024 ,4 ,SECT_4K ) }, - {"at25fs040" ,INFO (0x1f6604 ,0 ,64 *1024 ,8 ,SECT_4K ) }, + {"at25fs010" ,INFO (0x1f6601 ,0 ,32 *1024 ,4 ,SECT_4K |SPI_NOR_HAS_LOCK ) }, + {"at25fs040" ,INFO (0x1f6604 ,0 ,64 *1024 ,8 ,SECT_4K |SPI_NOR_HAS_LOCK ) },
after a quick look in the datasheets of these flashes, I suspect that what we have now in the SPI NOR core for SR locking does not work for them. They probably supported just "unlock all", clearing all the BP bits. Anyway, different problem.
drivers/mtd/spi-nor/atmel.c line 16
Quoted 6 lines
drivers/mtd/spi-nor/atmel.c +1
-4- { "at25df041a", INFO(0x1f4401, 0, 64 * 1024, 8, SECT_4K) }, - { "at25df321", INFO(0x1f4700, 0, 64 * 1024, 64, SECT_4K) }, - { "at25df321a", INFO(0x1f4701, 0, 64 * 1024, 64, SECT_4K) }, - { "at25df641", INFO(0x1f4800, 0, 64 * 1024, 128, SECT_4K) }, + { "at25df041a", INFO(0x1f4401, 0, 64 * 1024, 8, SECT_4K | SPI_NOR_HAS_LOCK) },
this one does not support BP locking: https://www.adestotech.com/wp-content/uploads/doc3668.pdf
drivers/mtd/spi-nor/atmel.c line 17
Quoted 1 line
drivers/mtd/spi-nor/atmel.c +1
-0+ { "at25df321", INFO(0x1f4700, 0, 64 * 1024, 64, SECT_4K | SPI_NOR_HAS_LOCK) },
neither this one: https://datasheet.octopart.com/AT25DF321-S3U-Atmel-datasheet-8700896.pdf
drivers/mtd/spi-nor/atmel.c line 18
Quoted 1 line
drivers/mtd/spi-nor/atmel.c +1
-0+ { "at25df321a", INFO(0x1f4701, 0, 64 * 1024, 64, SECT_4K | SPI_NOR_HAS_LOCK) },
nor this one: https://www.adestotech.com/wp-content/uploads/doc3686.pdf
drivers/mtd/spi-nor/atmel.c line 19
Quoted 1 line
drivers/mtd/spi-nor/atmel.c +1
-0+ { "at25df641", INFO(0x1f4800, 0, 64 * 1024, 128, SECT_4K | SPI_NOR_HAS_LOCK) },
nor this one: https://www.adestotech.com/wp-content/uploads/doc3680.pdf
I stop here.
Quoted 33 lines
drivers/mtd/spi-nor/atmel.c +3
-14{"at25sl321" ,INFO (0x1f4216 ,0 ,64 *1024 ,64 , SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) }, { "at26f004", INFO(0x1f0400, 0, 64 * 1024, 8, SECT_4K) }, - { "at26df081a", INFO(0x1f4501, 0, 64 * 1024, 16, SECT_4K) }, - { "at26df161a", INFO(0x1f4601, 0, 64 * 1024, 32, SECT_4K) }, - { "at26df321", INFO(0x1f4700, 0, 64 * 1024, 64, SECT_4K) }, + { "at26df081a", INFO(0x1f4501, 0, 64 * 1024, 16, SECT_4K | SPI_NOR_HAS_LOCK) }, + { "at26df161a", INFO(0x1f4601, 0, 64 * 1024, 32, SECT_4K | SPI_NOR_HAS_LOCK) }, + { "at26df321", INFO(0x1f4700, 0, 64 * 1024, 64, SECT_4K | SPI_NOR_HAS_LOCK) }, { "at45db081d", INFO(0x1f2500, 0, 64 * 1024, 16, SECT_4K) }, }; -static void atmel_default_init (struct spi_nor *nor) -{ - nor->flags |=SNOR_F_HAS_LOCK ; -} - -static const struct spi_nor_fixups atmel_fixups = { - .default_init = atmel_default_init, -}; -const struct spi_nor_manufacturer spi_nor_atmel = { .name ="atmel" , .parts = atmel_parts, .nparts =ARRAY_SIZE (atmel_parts), - .fixups = &atmel_fixups, }; --2.20.1
Am 2020-10-01 16:06, schrieb [email protected]:
Quoted 68 lines · Michael Walle
Quoted 33 lines
EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
This is considered bad for the following reasons:
(1) We only support the block protection with BPn bits for write protection. Not all Atmel parts support this.
(2) Newly added flash chip will automatically inherit the "has locking" support and thus needs to explicitly tested. Better be opt-in instead of opt-out.
(3) There are already supported flashes which don't support the
locking
scheme. So I assume this wasn't properly tested before adding
that
chip; which enforces my previous argument that locking
support should
be an opt-in.Remove the global flag and add individual flags to all flashes which supports BP locking. In particular the following flashes don't support the BP scheme:
- AT26F004
- AT25SL321
- AT45DB081DSigned-off-by Michael Walle <[email protected]>--- drivers/mtd/spi-nor/atmel.c | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-)drivers/mtd/spi-nor/atmel.c +0
-0drivers/mtd/spi-nor/atmel.c line 16
Quoted 9 lines
drivers/mtd/spi-nor/atmel.c +2
-2@@ -10,37 +10,27 @@static const struct flash_info atmel_parts[] = {/* Atmel -- some are (confusingly) marketed as "DataFlash" */ - {"at25fs010" ,INFO (0x1f6601 ,0 ,32 *1024 ,4 ,SECT_4K ) }, - {"at25fs040" ,INFO (0x1f6604 ,0 ,64 *1024 ,8 ,SECT_4K ) }, + {"at25fs010" ,INFO (0x1f6601 ,0 ,32 *1024 ,4 ,SECT_4K |SPI_NOR_HAS_LOCK ) }, + {"at25fs040" ,INFO (0x1f6604 ,0 ,64 *1024 ,8 ,SECT_4K |SPI_NOR_HAS_LOCK ) },after a quick look in the datasheets of these flashes, I suspect that what we have now in the SPI NOR core for SR locking does not work for them. They probably supported just "unlock all", clearing all the BP bits. Anyway, different problem.
drivers/mtd/spi-nor/atmel.c
Quoted 7 lines
drivers/mtd/spi-nor/atmel.c +1
-4- { "at25df041a", INFO(0x1f4401, 0, 64 * 1024, 8, SECT_4K) }, - { "at25df321", INFO(0x1f4700, 0, 64 * 1024, 64, SECT_4K) }, - { "at25df321a", INFO(0x1f4701, 0, 64 * 1024, 64, SECT_4K) }, - { "at25df641", INFO(0x1f4800, 0, 64 * 1024, 128, SECT_4K) }, + {"at25df041a" ,INFO (0x1f4401 ,0 ,64 *1024 ,8 ,SECT_4K | SPI_NOR_HAS_LOCK) },this one does not support BP locking:
https://www.adestotech.com/wp-content/uploads/doc3668.pdfdrivers/mtd/spi-nor/atmel.c line 20
Quoted 2 lines
drivers/mtd/spi-nor/atmel.c +1
-0+ {"at25df321" ,INFO (0x1f4700 ,0 ,64 *1024 ,64 ,SECT_4K | SPI_NOR_HAS_LOCK) },neither this one:
https://datasheet.octopart.com/AT25DF321-S3U-Atmel-datasheet-8700896.pdfdrivers/mtd/spi-nor/atmel.c line 22
Quoted 2 lines
drivers/mtd/spi-nor/atmel.c +1
-0+ {"at25df321a" ,INFO (0x1f4701 ,0 ,64 *1024 ,64 ,SECT_4K | SPI_NOR_HAS_LOCK) },
Quoted 8 lines
nor this one: https://www.adestotech.com/wp-content/uploads/doc3686.pdf
drivers/mtd/spi-nor/atmel.c line 24
Quoted 2 lines
drivers/mtd/spi-nor/atmel.c +1
-0+ {"at25df641" ,INFO (0x1f4800 ,0 ,64 *1024 ,128 ,SECT_4K | SPI_NOR_HAS_LOCK) },nor this one: https://www.adestotech.com/wp-content/uploads/doc3680.pdf
I stop here.
These are all the ones which use the global unlock. I cannot just skip the HAS_LOCK bit here, because otherwise this patch wouldn't be backwards compatibe. Yes I missed that in the commit log, my bad.
-michael
Quoted 77 lines · Michael Walle
EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
Am 2020-10-01 16:06, schrieb [email protected]:
Quoted 74 lines · Michael Walle
Quoted 34 lines
EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
This is considered bad for the following reasons:
(1) We only support the block protection with BPn bits for write protection. Not all Atmel parts support this.
(2) Newly added flash chip will automatically inherit the "has locking" support and thus needs to explicitly tested. Better be opt-in instead of opt-out.
(3) There are already supported flashes which don't support the locking
scheme. So I assume this wasn't properly tested before adding that
chip; which enforces my previous argument that locking support should
be an opt-in.Remove the global flag and add individual flags to all flashes which supports BP locking. In particular the following flashes don't support the BP scheme:
- AT26F004
- AT25SL321
- AT45DB081DSigned-off-by Michael Walle <[email protected]>---
drivers/mtd/spi-nor/atmel.c | 28 +++++++++-------------------1 file changed, 9 insertions(+), 19 deletions(-)drivers/mtd/spi-nor/atmel.c +0
-0drivers/mtd/spi-nor/atmel.c line 16
Quoted 9 lines
drivers/mtd/spi-nor/atmel.c +2
-2@@ -10,37 +10,27 @@ static const struct flash_info atmel_parts[] = { /* Atmel -- some are (confusingly) marketed as "DataFlash" */ - { "at25fs010", INFO(0x1f6601, 0, 32 * 1024, 4, SECT_4K) }, - { "at25fs040", INFO(0x1f6604, 0, 64 * 1024, 8, SECT_4K) }, + { "at25fs010", INFO(0x1f6601, 0, 32 * 1024, 4, SECT_4K |SPI_NOR_HAS_LOCK ) }, + { "at25fs040", INFO(0x1f6604, 0, 64 * 1024, 8, SECT_4K |SPI_NOR_HAS_LOCK ) },after a quick look in the datasheets of these flashes, I suspect that what we have now in the SPI NOR core for SR locking does not work for them. They probably supported just "unlock all", clearing all the BP bits. Anyway, different problem.
drivers/mtd/spi-nor/atmel.c
Quoted 7 lines
drivers/mtd/spi-nor/atmel.c +1
-4- { "at25df041a", INFO(0x1f4401, 0, 64 * 1024, 8, SECT_4K) }, - { "at25df321", INFO(0x1f4700, 0, 64 * 1024, 64, SECT_4K) }, - { "at25df321a", INFO(0x1f4701, 0, 64 * 1024, 64, SECT_4K) }, - { "at25df641", INFO(0x1f4800, 0, 64 * 1024, 128, SECT_4K) }, + { "at25df041a", INFO(0x1f4401, 0, 64 * 1024, 8, SECT_4K | SPI_NOR_HAS_LOCK) },this one does not support BP locking:
https://www.adestotech.com/wp-content/uploads/doc3668.pdfdrivers/mtd/spi-nor/atmel.c line 20
Quoted 2 lines
drivers/mtd/spi-nor/atmel.c +1
-0+ { "at25df321", INFO(0x1f4700, 0, 64 * 1024, 64, SECT_4K | SPI_NOR_HAS_LOCK) },neither this one:
https://datasheet.octopart.com/AT25DF321-S3U-Atmel-datasheet-8700896.pdfdrivers/mtd/spi-nor/atmel.c line 22
Quoted 2 lines
drivers/mtd/spi-nor/atmel.c +1
-0+ { "at25df321a", INFO(0x1f4701, 0, 64 * 1024, 64, SECT_4K | SPI_NOR_HAS_LOCK) },nor this one: https://www.adestotech.com/wp-content/uploads/doc3686.pdf
Quoted 2 lines
drivers/mtd/spi-nor/atmel.c +1
-0+ { "at25df641", INFO(0x1f4800, 0, 64 * 1024, 128, SECT_4K | SPI_NOR_HAS_LOCK) },
Quoted 9 lines
Quoted 3 lines
nor this one: https://www.adestotech.com/wp-content/uploads/doc3680.pdf
I stop here.
These are all the ones which use the global unlock. I cannot just skip the
HAS_LOCKbit here, because otherwise this patch wouldn't be backwards
compatibe. Yes I missed that in the commit log, my bad.
No worries.
"unlock all at boot" just cleared the SR bits. Clearing the SR bits unlocks these flashes?
Cheers,
ta
Am 2020-10-01 16:25, schrieb [email protected]:
Quoted 94 lines · Michael Walle
Quoted 83 lines
EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
Am 2020-10-01 16:06, schrieb [email protected]:
Quoted 80 lines · Michael Walle
Quoted 35 lines
EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
This is considered bad for the following reasons:
(1) We only support the block protection with BPn bits for write protection. Not all Atmel parts support this.
(2) Newly added flash chip will automatically inherit the "has locking" support and thus needs to explicitly tested. Better be opt-in instead of opt-out.
(3) There are already supported flashes which don't support the locking
scheme. So I assume this wasn't properly tested before adding that
chip; which enforces my previous argument that locking support should
be an opt-in.Remove the global flag and add individual flags to all flashes which supports BP locking. In particular the following flashes don't support the BP scheme:
- AT26F004
- AT25SL321
- AT45DB081DSigned-off-by Michael Walle <[email protected]>---
drivers/mtd/spi-nor/atmel.c | 28 +++++++++-------------------1 file changed, 9 insertions(+), 19 deletions(-)drivers/mtd/spi-nor/atmel.c +0
-0@@ -10,37 +10,27 @@drivers/mtd/spi-nor/atmel.c line 18
Quoted 10 lines
drivers/mtd/spi-nor/atmel.c +2
-2static const struct flash_info atmel_parts[] = { /* Atmel -- some are (confusingly) marketed as "DataFlash" */ - { "at25fs010", INFO(0x1f6601, 0, 32 * 1024, 4, SECT_4K) }, - { "at25fs040", INFO(0x1f6604, 0, 64 * 1024, 8, SECT_4K) }, + { "at25fs010", INFO(0x1f6601, 0, 32 * 1024, 4, SECT_4K | SPI_NOR_HAS_LOCK) }, + { "at25fs040", INFO(0x1f6604, 0, 64 * 1024, 8, SECT_4K | SPI_NOR_HAS_LOCK) },after a quick look in the datasheets of these flashes, I suspect that what we have now in the SPI NOR core for SR locking does not work for them. They probably supported just "unlock all", clearing all the BP bits. Anyway, different problem.
drivers/mtd/spi-nor/atmel.c line 24
Quoted 11 lines
drivers/mtd/spi-nor/atmel.c +1
-4- { "at25df041a", INFO(0x1f4401, 0, 64 * 1024, 8, SECT_4K) }, - { "at25df321", INFO(0x1f4700, 0, 64 * 1024, 64, SECT_4K) }, - { "at25df321a", INFO(0x1f4701, 0, 64 * 1024, 64, SECT_4K) }, - { "at25df641", INFO(0x1f4800, 0, 64 * 1024, 128, SECT_4K) }, + { "at25df041a", INFO(0x1f4401, 0, 64 * 1024, 8, SECT_4K | SPI_NOR_HAS_LOCK) },this one does not support BP locking:
https://www.adestotech.com/wp-content/uploads/doc3668.pdfdrivers/mtd/spi-nor/atmel.c line 26
Quoted 2 lines
drivers/mtd/spi-nor/atmel.c +1
-0+ { "at25df321", INFO(0x1f4700, 0, 64 * 1024, 64, SECT_4K | SPI_NOR_HAS_LOCK) },neither this one:
https://datasheet.octopart.com/AT25DF321-S3U-Atmel-datasheet-8700896.pdfdrivers/mtd/spi-nor/atmel.c line 28
Quoted 2 lines
drivers/mtd/spi-nor/atmel.c +1
-0+ { "at25df321a", INFO(0x1f4701, 0, 64 * 1024, 64, SECT_4K | SPI_NOR_HAS_LOCK) },nor this one: https://www.adestotech.com/wp-content/uploads/doc3686.pdf
Quoted 2 lines
drivers/mtd/spi-nor/atmel.c +1
-0+ { "at25df641", INFO(0x1f4800, 0, 64 * 1024, 128, SECT_4K | SPI_NOR_HAS_LOCK) },Quoted 9 lines
Quoted 3 lines
nor this one: https://www.adestotech.com/wp-content/uploads/doc3680.pdf
I stop here.
These are all the ones which use the global unlock. I cannot just skip the
HAS_LOCKbit here, because otherwise this patch wouldn't be backwards
compatibe. Yes I missed that in the commit log, my bad.
Quoted 4 lines
No worries.
"unlock all at boot" just cleared the SR bits. Clearing the SR bits unlocks these flashes?
Clearing bits 5,4,3,2, yes (with SPRL=0)
Conversely, to perform a Global Unprotect, the same WP and SPRL
conditions
must be met but the system must write a Logical 0 to bits 5, 4, 3, and
2
of the first byte of the Status Register.
This will hopefully be cleaned up by my "mtd: spi-nor: keep lock bits if they are non-volatile" patch.
-michael
Quoted 104 lines · Michael Walle
EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
Am 2020-10-01 16:25, schrieb [email protected]:
Quoted 101 lines · Michael Walle
Quoted 99 lines
EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
Am 2020-10-01 16:06, schrieb [email protected]:
Quoted 82 lines · Michael Walle
Quoted 39 lines
EXTERNAL EMAIL: Do not click links or open attachments unless you know
the content is safeThis is considered bad for the following reasons:
(1) We only support the block protection with BPn bits for write protection. Not all Atmel parts support this.
(2) Newly added flash chip will automatically inherit the "has locking" support and thus needs to explicitly tested. Better be opt-in instead of opt-out.
(3) There are already supported flashes which don't support the locking
scheme. So I assume this wasn't properly tested before adding
that
chip; which enforces my previous argument that locking support should
be an opt-in.Remove the global flag and add individual flags to all flashes which supports BP locking. In particular the following flashes don't support the BP scheme:
- AT26F004
- AT25SL321
- AT45DB081DSigned-off-by Michael Walle <[email protected]>---
drivers/mtd/spi-nor/atmel.c | 28 +++++++++-------------------1 file changed, 9 insertions(+), 19 deletions(-)drivers/mtd/spi-nor/atmel.c +0
-0@@ -10,37 +10,27 @@ static const struct flash_info atmel_parts[] = {drivers/mtd/spi-nor/atmel.c line 19
Quoted 10 lines
drivers/mtd/spi-nor/atmel.c +2
-2/* Atmel -- some are (confusingly) marketed as "DataFlash"*/ - { "at25fs010", INFO(0x1f6601, 0, 32 * 1024, 4, SECT_4K) }, - { "at25fs040", INFO(0x1f6604, 0, 64 * 1024, 8, SECT_4K) }, + { "at25fs010", INFO(0x1f6601, 0, 32 * 1024, 4, SECT_4K | SPI_NOR_HAS_LOCK) }, + { "at25fs040", INFO(0x1f6604, 0, 64 * 1024, 8, SECT_4K | SPI_NOR_HAS_LOCK) },after a quick look in the datasheets of these flashes, I suspect that what we have now in the SPI NOR core for SR locking does not work for them. They probably supported just "unlock all", clearing all the BP bits. Anyway, different problem.
drivers/mtd/spi-nor/atmel.c line 25
Quoted 11 lines
drivers/mtd/spi-nor/atmel.c +1
-4- { "at25df041a", INFO(0x1f4401, 0, 64 * 1024, 8, SECT_4K) }, - { "at25df321", INFO(0x1f4700, 0, 64 * 1024, 64, SECT_4K) }, - { "at25df321a", INFO(0x1f4701, 0, 64 * 1024, 64, SECT_4K) }, - { "at25df641", INFO(0x1f4800, 0, 64 * 1024, 128, SECT_4K) }, + { "at25df041a", INFO(0x1f4401, 0, 64 * 1024, 8, SECT_4K | SPI_NOR_HAS_LOCK) },this one does not support BP locking:
https://www.adestotech.com/wp-content/uploads/doc3668.pdfdrivers/mtd/spi-nor/atmel.c line 27
Quoted 2 lines
drivers/mtd/spi-nor/atmel.c +1
-0+ { "at25df321", INFO(0x1f4700, 0, 64 * 1024, 64, SECT_4K | SPI_NOR_HAS_LOCK) },neither this one:
https://datasheet.octopart.com/AT25DF321-S3U-Atmel-datasheet-8700896.pdfdrivers/mtd/spi-nor/atmel.c line 29
Quoted 2 lines
drivers/mtd/spi-nor/atmel.c +1
-0+ { "at25df321a", INFO(0x1f4701, 0, 64 * 1024, 64, SECT_4K | SPI_NOR_HAS_LOCK) },nor this one:
https://www.adestotech.com/wp-content/uploads/doc3686.pdfQuoted 7 lines
drivers/mtd/spi-nor/atmel.c line 31
Quoted 2 lines
drivers/mtd/spi-nor/atmel.c +1
-0+ { "at25df641", INFO(0x1f4800, 0, 64 * 1024, 128, SECT_4K | SPI_NOR_HAS_LOCK) },nor this one:
https://www.adestotech.com/wp-content/uploads/doc3680.pdfI stop here.
These are all the ones which use the global unlock. I cannot just skip the
HAS_LOCKbit here, because otherwise this patch wouldn't be backwards
compatibe. Yes I missed that in the commit log, my bad.
Quoted 7 lines
Quoted 5 lines
No worries.
"unlock all at boot" just cleared the SR bits. Clearing the SR bits unlocks
these flashes?Clearing bits 5,4,3,2, yes (with SPRL=0)
oh, the horror. Those bits are described as Read Only when describing Status Register. I'll re-read the datasheets.
Quoted 6 lines
Conversely, to perform a Global Unprotect, the same WP and SPRL conditions
must be met but the system must write a Logical 0 to bits 5, 4, 3, and 2
of the first byte of the Status Register.
OK. I see this under "Global unprotect" section. Strange. Will get back to you.
Cheers,
ta
Quoted 6 lines
This will hopefully be cleaned up by my "mtd: spi-nor: keep lock bits if they
are non-volatile" patch.-michael