Skip to content

Commit

Permalink
drivers/mtd_spi_nor: fix Atmel size calculation
Browse files Browse the repository at this point in the history
Lower bits of the device ID are not the capacity in bytes but mark the
doubling of the base unit (32k):

 4 - 4 Mb
 5 - 8 Mb
 …
  • Loading branch information
benpicco committed Feb 23, 2022
1 parent 5ff0f2d commit acb9760
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/mtd_spi_nor/mtd_spi_nor.c
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,9 @@ static uint32_t mtd_spi_nor_get_size(const mtd_jedec_id_t *id)
if (mtd_spi_manuf_match(id, SPI_NOR_JEDEC_ATMEL) &&
/* ID 2 is used to encode the product version, usually 1 or 2 */
(id->device[1] & ~0x3) == 0) {
return (0x1F & id->device[0]) * MBIT_AS_BYTES;
/* 4 - 4 Mb */
/* 5 - 8 Mb */
return (32 * 1024) << (0x1F & id->device[0]);
}
if (mtd_spi_manuf_match(id, SPI_NOR_JEDEC_MICROCHIP)) {
switch (id->device[1]) {
Expand Down

0 comments on commit acb9760

Please sign in to comment.