drivers:mtd: Adds support for W25 2Mbit memories.

Tested with W25Q20CL.
This commit is contained in:
Daniel P. Carvalho 2023-11-21 16:08:44 -03:00 committed by Alan Carvalho de Assis
parent ea0be3b490
commit ed877fd494

View File

@ -107,12 +107,14 @@
#define W25Q_JEDEC_MEMORY_TYPE_C 0x50 /* W25Q memory type */
#define W25Q_JEDEC_MEMORY_TYPE_D 0x70 /* W25QJV memory type (backward compatible) */
#define W25_JEDEC_CAPACITY_2MBIT 0x12 /* 256x1024 = 2Mbit memory capacity */
#define W25_JEDEC_CAPACITY_8MBIT 0x14 /* 256x4096 = 8Mbit memory capacity */
#define W25_JEDEC_CAPACITY_16MBIT 0x15 /* 512x4096 = 16Mbit memory capacity */
#define W25_JEDEC_CAPACITY_32MBIT 0x16 /* 1024x4096 = 32Mbit memory capacity */
#define W25_JEDEC_CAPACITY_64MBIT 0x17 /* 2048x4096 = 64Mbit memory capacity */
#define W25_JEDEC_CAPACITY_128MBIT 0x18 /* 4096x4096 = 128Mbit memory capacity */
#define NSECTORS_2MBIT 64 /* 64 sectors x 4096 bytes/sector = 256Kb */
#define NSECTORS_8MBIT 256 /* 256 sectors x 4096 bytes/sector = 1Mb */
#define NSECTORS_16MBIT 512 /* 512 sectors x 4096 bytes/sector = 2Mb */
#define NSECTORS_32MBIT 1024 /* 1024 sectors x 4096 bytes/sector = 4Mb */
@ -402,12 +404,22 @@ static inline int w25_readid(struct w25_dev_s *priv)
* the FLASH capacity.
*/
/* 2M-bit / 256K-byte
*
* W25Q20CL
*/
if (capacity == W25_JEDEC_CAPACITY_2MBIT)
{
priv->nsectors = NSECTORS_2MBIT;
}
/* 8M-bit / 1M-byte
*
* W25Q80BV
*/
if (capacity == W25_JEDEC_CAPACITY_8MBIT)
else if (capacity == W25_JEDEC_CAPACITY_8MBIT)
{
priv->nsectors = NSECTORS_8MBIT;
}