From 44a30a74576f45e031ea6e823188907dfdeba8c5 Mon Sep 17 00:00:00 2001 From: Gwenhael Goavec-Merou Date: Fri, 23 Aug 2024 08:55:42 +0200 Subject: [PATCH] spiFlashdb: added quad register/offset support --- src/spiFlashdb.hpp | 206 ++++++++++++++++++++++++++++++--------------- 1 file changed, 138 insertions(+), 68 deletions(-) diff --git a/src/spiFlashdb.hpp b/src/spiFlashdb.hpp index 846096b96..af94c1271 100644 --- a/src/spiFlashdb.hpp +++ b/src/spiFlashdb.hpp @@ -31,6 +31,8 @@ typedef struct { tb_loc_t tb_register; /**< TOP/BOTTOM location (register) */ uint8_t bp_len; /**< BPx length */ uint8_t bp_offset[4]; /**< BP[0:3] bit offset */ + tb_loc_t quad_register; /**< TOP/BOTTOM bit offset */ + uint16_t quad_offset; /** Quad Enable bit offset */ } flash_t; static std::map flash_list = { @@ -45,8 +47,10 @@ static std::map flash_list = { .tb_offset = (1 << 5), .tb_register = CONFR, .bp_len = 3, - .bp_offset = {(1 << 2), (1 << 3), (1 << 4), 0}} - }, + .bp_offset = {(1 << 2), (1 << 3), (1 << 4), 0}, + .quad_register = NONER, + .quad_offset = 0, + }}, {0x010219, { /* https://www.mouser.fr/datasheet/2/196/Infineon_S25FL128SS25FL256S_128_Mb__16_MB_256_Mb__-3363490.pdf */ .manufacturer = "spansion", @@ -59,8 +63,10 @@ static std::map flash_list = { .tb_offset = (1 << 5), .tb_register = CONFR, .bp_len = 3, - .bp_offset = {(1 << 2), (1 << 3), (1 << 4), 0}} - }, + .bp_offset = {(1 << 2), (1 << 3), (1 << 4), 0}, + .quad_register = CONFR, + .quad_offset = (1 << 1), + }}, {0x010220, { .manufacturer = "spansion", .model = "S25FL512S", @@ -72,8 +78,10 @@ static std::map flash_list = { .tb_offset = (1 << 5), .tb_register = CONFR, .bp_len = 3, - .bp_offset = {(1 << 2), (1 << 3), (1 << 4), 0}} - }, + .bp_offset = {(1 << 2), (1 << 3), (1 << 4), 0}, + .quad_register = NONER, + .quad_offset = 0, + }}, {0x012018, { .manufacturer = "spansion", .model = "S25FL128S", @@ -85,8 +93,10 @@ static std::map flash_list = { .tb_offset = (1 << 5), .tb_register = CONFR, .bp_len = 3, - .bp_offset = {(1 << 2), (1 << 3), (1 << 4), 0}} - }, + .bp_offset = {(1 << 2), (1 << 3), (1 << 4), 0}, + .quad_register = NONER, + .quad_offset = 0, + }}, {0x016018, { .manufacturer = "spansion", .model = "S25FL128L", @@ -98,8 +108,10 @@ static std::map flash_list = { .tb_offset = (1 << 6), .tb_register = STATR, .bp_len = 4, - .bp_offset = {(1 << 2), (1 << 3), (1 << 4), (1 << 5)}} - }, + .bp_offset = {(1 << 2), (1 << 3), (1 << 4), (1 << 5)}, + .quad_register = NONER, + .quad_offset = 0, + }}, {0x016019, { .manufacturer = "spansion", .model = "S25FL256L", @@ -111,8 +123,10 @@ static std::map flash_list = { .tb_offset = (1 << 6), .tb_register = STATR, .bp_len = 4, - .bp_offset = {(1 << 2), (1 << 3), (1 << 4), (1 << 5)}} - }, + .bp_offset = {(1 << 2), (1 << 3), (1 << 4), (1 << 5)}, + .quad_register = NONER, + .quad_offset = 0, + }}, {0x202014, { /* https://pdf1.alldatasheet.com/datasheet-pdf/download/22807/STMICROELECTRONICS/M25P80.html */ .manufacturer = "ST", @@ -125,8 +139,10 @@ static std::map flash_list = { .tb_offset = 0, // unused .tb_register = STATR, .bp_len = 3, - .bp_offset = {(1 << 2), (1 << 3), (1 << 4), 0}} - }, + .bp_offset = {(1 << 2), (1 << 3), (1 << 4), 0}, + .quad_register = NONER, + .quad_offset = 0, + }}, {0x202015, { /* https://datasheet.octopart.com/M25P16-VME6G-STMicroelectronics-datasheet-7623188.pdf */ .manufacturer = "ST", @@ -139,8 +155,10 @@ static std::map flash_list = { .tb_offset = 0, // unused .tb_register = STATR, .bp_len = 3, - .bp_offset = {(1 << 2), (1 << 3), (1 << 4), 0}} - }, + .bp_offset = {(1 << 2), (1 << 3), (1 << 4), 0}, + .quad_register = NONER, + .quad_offset = 0, + }}, {0x202016, { /* https://pdf1.alldatasheet.com/datasheet-pdf/download/104949/STMICROELECTRONICS/M25P32.html */ .manufacturer = "ST", @@ -153,8 +171,10 @@ static std::map flash_list = { .tb_offset = 0, // unused .tb_register = STATR, .bp_len = 3, - .bp_offset = {(1 << 2), (1 << 3), (1 << 4), 0}} - }, + .bp_offset = {(1 << 2), (1 << 3), (1 << 4), 0}, + .quad_register = NONER, + .quad_offset = 0, + }}, {0x20ba16, { /* https://www.digikey.co.uk/htmldatasheets/production/1283198/0/0/1/N25Q032A-32Mb-1-8V.pdf */ .manufacturer = "micron", @@ -167,8 +187,10 @@ static std::map flash_list = { .tb_offset = (1 << 5), .tb_register = STATR, .bp_len = 3, - .bp_offset = {(1 << 2), (1 << 3), (1 << 4), 0}} - }, + .bp_offset = {(1 << 2), (1 << 3), (1 << 4), 0}, + .quad_register = NONER, + .quad_offset = 0, + }}, {0x20ba17, { .manufacturer = "micron", .model = "N25Q64", @@ -180,8 +202,10 @@ static std::map flash_list = { .tb_offset = (1 << 5), .tb_register = STATR, .bp_len = 4, - .bp_offset = {(1 << 2), (1 << 3), (1 << 4), (1 << 6)}} - }, + .bp_offset = {(1 << 2), (1 << 3), (1 << 4), (1 << 6)}, + .quad_register = NONER, + .quad_offset = 0, + }}, {0x20ba18, { /* https://media-www.micron.com/-/media/client/global/documents/products/data-sheet/nor-flash/serial-nor/n25q/n25q_128mb_3v_65nm.pdf */ .manufacturer = "micron", @@ -194,8 +218,10 @@ static std::map flash_list = { .tb_offset = (1 << 5), .tb_register = STATR, .bp_len = 4, - .bp_offset = {(1 << 2), (1 << 3), (1 << 4), (1 << 6)}} - }, + .bp_offset = {(1 << 2), (1 << 3), (1 << 4), (1 << 6)}, + .quad_register = NONER, + .quad_offset = 0, + }}, {0x20ba19, { .manufacturer = "micron", .model = "N25Q256", @@ -207,8 +233,10 @@ static std::map flash_list = { .tb_offset = (1 << 5), .tb_register = STATR, .bp_len = 4, - .bp_offset = {(1 << 2), (1 << 3), (1 << 4), (1 << 6)}} - }, + .bp_offset = {(1 << 2), (1 << 3), (1 << 4), (1 << 6)}, + .quad_register = NONER, + .quad_offset = 0, + }}, {0x20bb18, { /* https://www.micron.com/-/media/client/global/documents/products/data-sheet/nor-flash/serial-nor/n25q/n25q_128mb_1_8v_65nm.pdf */ /* MT25QU128ABA has the same JEDEC-standard signature: https://media-www.micron.com/-/media/client/global/documents/products/data-sheet/nor-flash/serial-nor/mt25q/die-rev-a/mt25q_qlhs_u_128_aba_0.pdf */ @@ -223,8 +251,10 @@ static std::map flash_list = { .tb_offset = (1 << 5), .tb_register = STATR, .bp_len = 4, - .bp_offset = {(1 << 2), (1 << 3), (1 << 4), (1 << 6)}} - }, + .bp_offset = {(1 << 2), (1 << 3), (1 << 4), (1 << 6)}, + .quad_register = NONER, + .quad_offset = 0, + }}, {0x20bb19, { .manufacturer = "micron", .model = "N25Q256A", @@ -236,8 +266,10 @@ static std::map flash_list = { .tb_offset = (1 << 5), .tb_register = STATR, .bp_len = 4, - .bp_offset = {(1 << 2), (1 << 3), (1 << 4), (1 << 6)}} - }, + .bp_offset = {(1 << 2), (1 << 3), (1 << 4), (1 << 6)}, + .quad_register = NONER, + .quad_offset = 0, + }}, {0x20bb21, { .manufacturer = "micron", .model = "MT25QU01G", @@ -249,8 +281,10 @@ static std::map flash_list = { .tb_offset = (1 << 5), .tb_register = STATR, .bp_len = 4, - .bp_offset = {(1 << 2), (1 << 3), (1 << 4), (1 << 6)}} - }, + .bp_offset = {(1 << 2), (1 << 3), (1 << 4), (1 << 6)}, + .quad_register = NONER, + .quad_offset = 0, + }}, {0x20bb22, { .manufacturer = "micron", .model = "MT25QU02G", @@ -262,8 +296,10 @@ static std::map flash_list = { .tb_offset = (1 << 5), .tb_register = STATR, .bp_len = 4, - .bp_offset = {(1 << 2), (1 << 3), (1 << 4), (1 << 6)}} - }, + .bp_offset = {(1 << 2), (1 << 3), (1 << 4), (1 << 6)}, + .quad_register = NONER, + .quad_offset = 0, + }}, {0x9d6016, { .manufacturer = "ISSI", .model = "IS25LP032", @@ -275,8 +311,10 @@ static std::map flash_list = { .tb_offset = (1 << 1), .tb_register = FUNCR, .bp_len = 4, - .bp_offset = {(1 << 2), (1 << 3), (1 << 4), (1 << 5)}} - }, + .bp_offset = {(1 << 2), (1 << 3), (1 << 4), (1 << 5)}, + .quad_register = NONER, + .quad_offset = 0, + }}, {0x9d6017, { .manufacturer = "ISSI", .model = "IS25LP064", @@ -288,8 +326,10 @@ static std::map flash_list = { .tb_offset = (1 << 1), .tb_register = FUNCR, .bp_len = 4, - .bp_offset = {(1 << 2), (1 << 3), (1 << 4), (1 << 5)}} - }, + .bp_offset = {(1 << 2), (1 << 3), (1 << 4), (1 << 5)}, + .quad_register = NONER, + .quad_offset = 0, + }}, {0x9d6018, { .manufacturer = "ISSI", .model = "IS25LP128", @@ -301,8 +341,10 @@ static std::map flash_list = { .tb_offset = (1 << 1), .tb_register = FUNCR, .bp_len = 4, - .bp_offset = {(1 << 2), (1 << 3), (1 << 4), (1 << 5)}} - }, + .bp_offset = {(1 << 2), (1 << 3), (1 << 4), (1 << 5)}, + .quad_register = NONER, + .quad_offset = 0, + }}, {0x9d6019, { /* https://www.issi.com/WW/pdf/IS25LP(WP)256D.pdf */ .manufacturer = "ISSI", @@ -315,8 +357,10 @@ static std::map flash_list = { .tb_offset = (1 << 1), .tb_register = FUNCR, .bp_len = 4, - .bp_offset = {(1 << 2), (1 << 3), (1 << 4), (1 << 5)}} - }, + .bp_offset = {(1 << 2), (1 << 3), (1 << 4), (1 << 5)}, + .quad_register = NONER, + .quad_offset = 0, + }}, {0xba6015, { .manufacturer = "Zetta", .model = "ZD25WQ16CSIGT", @@ -328,8 +372,10 @@ static std::map flash_list = { .tb_offset = (1 << 5), .tb_register = STATR, .bp_len = 3, - .bp_offset = {(1 << 2), (1 << 3), (1 << 4), 0}} - }, + .bp_offset = {(1 << 2), (1 << 3), (1 << 4), 0}, + .quad_register = NONER, + .quad_offset = 0, + }}, {0xbf258d, { .manufacturer = "microchip", .model = "SST25VF040B", @@ -341,8 +387,10 @@ static std::map flash_list = { .tb_offset = 0, // unused .tb_register = NONER, .bp_len = 4, - .bp_offset = {(1 << 2), (1 << 3), (1 << 4), (1 << 5)}} - }, + .bp_offset = {(1 << 2), (1 << 3), (1 << 4), (1 << 5)}, + .quad_register = NONER, + .quad_offset = 0, + }}, {0xbf2642, { .manufacturer = "microchip", .model = "SST26VF032B", @@ -354,8 +402,10 @@ static std::map flash_list = { .tb_offset = 0, // unused .tb_register = NONER, .bp_len = 0, - .bp_offset = {0, 0, 0, 0}} - }, + .bp_offset = {0, 0, 0, 0}, + .quad_register = NONER, + .quad_offset = 0, + }}, {0xbf2643, { .manufacturer = "microchip", .model = "SST26VF064B", @@ -367,8 +417,10 @@ static std::map flash_list = { .tb_offset = 0, // unused .tb_register = NONER, .bp_len = 0, - .bp_offset = {0, 0, 0, 0}} - }, + .bp_offset = {0, 0, 0, 0}, + .quad_register = NONER, + .quad_offset = 0, + }}, {0xc22016, { /* https://www.macronix.com/Lists/Datasheet/Attachments/8933/MX25L3233F,%203V,%2032Mb,%20v1.7.pdf */ .manufacturer = "Macronix", @@ -381,8 +433,10 @@ static std::map flash_list = { .tb_offset = (1 << 3), .tb_register = CONFR, .bp_len = 5, - .bp_offset = {(1 << 2), (1 << 3), (1 << 4), (1 << 5)}} - }, + .bp_offset = {(1 << 2), (1 << 3), (1 << 4), (1 << 5)}, + .quad_register = NONER, + .quad_offset = 0, + }}, {0xc22018, { /* https://www.macronix.com/Lists/Datasheet/Attachments/8934/MX25L12833F,%203V,%20128Mb,%20v1.0.pdf */ .manufacturer = "Macronix", @@ -395,8 +449,10 @@ static std::map flash_list = { .tb_offset = (1 << 3), .tb_register = CONFR, .bp_len = 5, - .bp_offset = {(1 << 2), (1 << 3), (1 << 4), (1 << 5)}} - }, + .bp_offset = {(1 << 2), (1 << 3), (1 << 4), (1 << 5)}, + .quad_register = NONER, + .quad_offset = 0, + }}, {0xc2201a, { /* https://www.macronix.com/Lists/Datasheet/Attachments/8745/MX25L51245G,%203V,%20512Mb,%20v1.7.pdf */ .manufacturer = "Macronix", @@ -409,8 +465,10 @@ static std::map flash_list = { .tb_offset = (1 << 3), .tb_register = CONFR, .bp_len = 5, - .bp_offset = {(1 << 2), (1 << 3), (1 << 4), (1 << 5)}} - }, + .bp_offset = {(1 << 2), (1 << 3), (1 << 4), (1 << 5)}, + .quad_register = NONER, + .quad_offset = 0, + }}, {0xc22817, { /* https://www.macronix.com/Lists/Datasheet/Attachments/8868/MX25R6435F,%20Wide%20Range,%2064Mb,%20v1.6.pdf */ .manufacturer = "Macronix", @@ -423,8 +481,10 @@ static std::map flash_list = { .tb_offset = (1 << 3), .tb_register = CONFR, .bp_len = 4, - .bp_offset = {(1 << 2), (1 << 3), (1 << 4), (1 << 5)}} - }, + .bp_offset = {(1 << 2), (1 << 3), (1 << 4), (1 << 5)}, + .quad_register = NONER, + .quad_offset = 0, + }}, {0xef4014, { /* https://cdn-shop.adafruit.com/datasheets/W25Q80BV.pdf */ .manufacturer = "Winbond", @@ -437,8 +497,10 @@ static std::map flash_list = { .tb_offset = (1 << 5), .tb_register = STATR, .bp_len = 3, - .bp_offset = {(1 << 2), (1 << 3), (1 << 4), 0}} - }, + .bp_offset = {(1 << 2), (1 << 3), (1 << 4), 0}, + .quad_register = NONER, + .quad_offset = 0, + }}, {0xef4015, { .manufacturer = "Winbond", .model = "W25Q16", @@ -450,8 +512,10 @@ static std::map flash_list = { .tb_offset = (1 << 5), .tb_register = STATR, .bp_len = 3, - .bp_offset = {(1 << 2), (1 << 3), (1 << 4), 0}} - }, + .bp_offset = {(1 << 2), (1 << 3), (1 << 4), 0}, + .quad_register = NONER, + .quad_offset = 0, + }}, {0xef4016, { .manufacturer = "Winbond", .model = "W25Q32", @@ -463,8 +527,10 @@ static std::map flash_list = { .tb_offset = (1 << 5), .tb_register = STATR, .bp_len = 3, - .bp_offset = {(1 << 2), (1 << 3), (1 << 4), 0}} - }, + .bp_offset = {(1 << 2), (1 << 3), (1 << 4), 0}, + .quad_register = NONER, + .quad_offset = 0, + }}, {0xef4017, { .manufacturer = "Winbond", .model = "W25Q64", @@ -476,8 +542,10 @@ static std::map flash_list = { .tb_offset = (1 << 5), .tb_register = STATR, .bp_len = 3, - .bp_offset = {(1 << 2), (1 << 3), (1 << 4), 0}} - }, + .bp_offset = {(1 << 2), (1 << 3), (1 << 4), 0}, + .quad_register = NONER, + .quad_offset = 0, + }}, {0xef4018, { .manufacturer = "Winbond", .model = "W25Q128", @@ -489,8 +557,10 @@ static std::map flash_list = { .tb_offset = (1 << 5), .tb_register = STATR, .bp_len = 3, - .bp_offset = {(1 << 2), (1 << 3), (1 << 4), 0}} - }, + .bp_offset = {(1 << 2), (1 << 3), (1 << 4), 0}, + .quad_register = NONER, + .quad_offset = 0, + }}, };