Skip to content

Commit

Permalink
spiFlash: added MX25L enable/disable quad + display status register
Browse files Browse the repository at this point in the history
  • Loading branch information
trabucayre committed Sep 22, 2024
1 parent 2a46ab9 commit e56cfb4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
15 changes: 13 additions & 2 deletions src/spiFlash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#define FLASH_4SE 0x21
/* read configuration register */
#define FLASH_RDCR 0x35
#define MX25L_RDCR 0x15
/* write function register (at least ISSI) */
#define FLASH_WRFR 0x42
/* read function register (at least ISSI) */
Expand Down Expand Up @@ -632,7 +633,7 @@ void SPIFlash::display_status_reg(uint8_t reg)
printf("BPNV : %d\n", ((reg >> 3) & 0x01));
printf("TBPROT : %d\n", ((reg >> 5) & 0x01));
if (dev_id == 0x0120)
printf("LC : %d\n", ((reg >> 6) & 0x02));
printf("LC : %d\n", ((reg >> 6) & 0x03));
break;
case 0x0160:
_spi->spi_put(FLASH_RDCR, NULL, &reg, 1);
Expand All @@ -658,6 +659,13 @@ void SPIFlash::display_status_reg(uint8_t reg)
printf("DUAL : %d\n", ((nv_reg >> 2) & 0x01));
/* 1:0: reserved */
break;
case 0xC220:
_spi->spi_put(MX25L_RDCR, NULL, &reg, 1);
printf("\nConfiguration Register\n");
printf("RDCR : %02x\n", reg);
printf("DC : %d\n", ((reg >> 6) & 0x03));
printf("TB : %d\n", ((reg >> 3) & 0x01));
printf("ODS : %d\n", ((reg >> 0) & 0x07));
}
}

Expand Down Expand Up @@ -993,7 +1001,10 @@ int8_t SPIFlash::get_tb()
_spi->spi_put(FLASH_RDFR, NULL, &status, 1);
break;
case CONFR: // function register
_spi->spi_put(FLASH_RDCR, NULL, &status, 1);
if ((_jedec_id >> 8) == 0xC220)
_spi->spi_put(MX25L_RDCR, NULL, &status, 1);
else
_spi->spi_put(FLASH_RDCR, NULL, &status, 1);
break;
case NONER: // no TB bit
return 0;
Expand Down
12 changes: 6 additions & 6 deletions src/spiFlashdb.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -437,8 +437,8 @@ static std::map <uint32_t, flash_t> flash_list = {
.tb_register = CONFR,
.bp_len = 5,
.bp_offset = {(1 << 2), (1 << 3), (1 << 4), (1 << 5)},
.quad_register = NONER,
.quad_mask = 0,
.quad_register = STATR,
.quad_mask = (1 << 6),
}},
{0xc22018, {
/* https://www.macronix.com/Lists/Datasheet/Attachments/8934/MX25L12833F,%203V,%20128Mb,%20v1.0.pdf */
Expand All @@ -453,8 +453,8 @@ static std::map <uint32_t, flash_t> flash_list = {
.tb_register = CONFR,
.bp_len = 5,
.bp_offset = {(1 << 2), (1 << 3), (1 << 4), (1 << 5)},
.quad_register = NONER,
.quad_mask = 0,
.quad_register = STATR,
.quad_mask = (1 << 6),
}},
{0xc2201a, {
/* https://www.macronix.com/Lists/Datasheet/Attachments/8745/MX25L51245G,%203V,%20512Mb,%20v1.7.pdf */
Expand All @@ -469,8 +469,8 @@ static std::map <uint32_t, flash_t> flash_list = {
.tb_register = CONFR,
.bp_len = 5,
.bp_offset = {(1 << 2), (1 << 3), (1 << 4), (1 << 5)},
.quad_register = NONER,
.quad_mask = 0,
.quad_register = STATR,
.quad_mask = (1 << 6),
}},
{0xc22817, {
/* https://www.macronix.com/Lists/Datasheet/Attachments/8868/MX25R6435F,%20Wide%20Range,%2064Mb,%20v1.6.pdf */
Expand Down

0 comments on commit e56cfb4

Please sign in to comment.