Skip to content

Commit

Permalink
Add support for W25N02K 2Gbit/256Mbyte FLASH (betaflight#13677)
Browse files Browse the repository at this point in the history
* Add support for W25N02K 2Gbit/256Mbyte FLASH

* Remove duplicate defintion check

* Rename W25N01G_BB_*_BLOCK macros

* Remove debug

* Create unified driver for W25N01G and W25N02K devices

* Put device parameters in a table

* Add W25N01GV to stacked die driver
  • Loading branch information
SteveCEvans authored Jun 8, 2024
1 parent 6080bff commit ab022b0
Show file tree
Hide file tree
Showing 7 changed files with 272 additions and 260 deletions.
2 changes: 1 addition & 1 deletion mk/source.mk
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ RX_SRC = \
FLASH_SRC += \
drivers/flash.c \
drivers/flash_m25p16.c \
drivers/flash_w25n01g.c \
drivers/flash_w25n.c \
drivers/flash_w25q128fv.c \
drivers/flash_w25m.c \
io/flashfs.c
Expand Down
12 changes: 6 additions & 6 deletions src/main/drivers/flash.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#include "flash.h"
#include "flash_impl.h"
#include "flash_m25p16.h"
#include "flash_w25n01g.h"
#include "flash_w25n.h"
#include "flash_w25q128fv.h"
#include "flash_w25m.h"
#include "drivers/bus_spi.h"
Expand Down Expand Up @@ -162,8 +162,8 @@ MMFLASH_CODE_NOINLINE static bool flashOctoSpiInit(const flashConfig_t *flashCon
#ifdef USE_OCTOSPI_EXPERIMENTAL
if (!memoryMappedModeEnabledOnBoot) {
// These flash chips DO NOT support memory mapped mode; suitable flash read commands must be available.
#if defined(USE_FLASH_W25N01G)
if (!detected && w25n01g_identify(&flashDevice, jedecID)) {
#if defined(USE_FLASH_W25N01G) || defined(USE_FLASH_W25N02K)
if (!detected && w25n_identify(&flashDevice, jedecID)) {
detected = true;
}
#endif
Expand Down Expand Up @@ -247,7 +247,7 @@ static bool flashQuadSpiInit(const flashConfig_t *flashConfig)

if (offset == 1) {
#if defined(USE_FLASH_W25N01G)
if (!detected && w25n01g_identify(&flashDevice, jedecID)) {
if (!detected && w25n_identify(&flashDevice, jedecID)) {
detected = true;
}
#endif
Expand Down Expand Up @@ -333,8 +333,8 @@ static bool flashSpiInit(const flashConfig_t *flashConfig)
jedecID = (readIdResponse[1] << 16) | (readIdResponse[2] << 8) | (readIdResponse[3]);
}

#ifdef USE_FLASH_W25N01G
if (!detected && w25n01g_identify(&flashDevice, jedecID)) {
#ifdef USE_FLASH_W25N
if (!detected && w25n_identify(&flashDevice, jedecID)) {
detected = true;
}
#endif
Expand Down
5 changes: 3 additions & 2 deletions src/main/drivers/flash_w25m.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@

#include "flash_m25p16.h"
#include "flash_w25m.h"
#include "flash_w25n01g.h"
#include "flash_w25n.h"

#include "pg/flash.h"

Expand All @@ -52,6 +52,7 @@
#define JEDEC_ID_WINBOND_W25M512 0xEF7119 // W25Q256 x 2
#define JEDEC_ID_WINBOND_W25M02G 0xEFAB21 // W25N01G x 2
#define JEDEC_ID_WINBOND_W25Q256 0xEF4019
#define JEDEC_ID_WINBOND_W25N01GV 0xEFAA21

static const flashVTable_t w25m_vTable;

Expand Down Expand Up @@ -143,7 +144,7 @@ bool w25m_identify(flashDevice_t *fdevice, uint32_t jedecID)
w25m_dieSelect(fdevice->io.handle.dev, die);
dieDevice[die].io.handle.dev = fdevice->io.handle.dev;
dieDevice[die].io.mode = fdevice->io.mode;
w25n01g_identify(&dieDevice[die], JEDEC_ID_WINBOND_W25N01GV);
w25n_identify(&dieDevice[die], JEDEC_ID_WINBOND_W25N01GV);
}

fdevice->geometry.flashType = FLASH_TYPE_NAND;
Expand Down
Loading

0 comments on commit ab022b0

Please sign in to comment.