diff options
author | Artem Bityutskiy <artem.bityutskiy@linux.intel.com> | 2013-03-04 09:26:56 -0500 |
---|---|---|
committer | David Woodhouse <David.Woodhouse@intel.com> | 2013-04-05 07:04:22 -0400 |
commit | 8e12b474f9a2349bcaebda65bdc38e8398ff408e (patch) | |
tree | 75a435b77c734f93465354cfa501587150f8fd4d /include/linux/mtd/nand.h | |
parent | 8dbfae1ef04311ba19d6b6c9a4d8fdddbb90ab0f (diff) |
mtd: nand: provision full ID support
Up until now we identified NAND chips by the 'device ID' part of the full chip
ID array, which is the second full ID array byte. However, the newest flashes
use the same device ID for chips with identical page and eraseblock sizes, but
different OOB sizes. And unfortunately, it is not clear if there is a
"standard" way to fetch the OOB size from chip's full ID array. Here is an
example:
Toshiba TC58NVG2S0F: 0x98, 0xdc, 0x90, 0x26, 0x76, 0x15, 0x01, 0x08
Toshiba TC58NVG3S0F: 0x98, 0xd3, 0x90, 0x26, 0x76, 0x15, 0x02, 0x08
The first one is a 512MiB NAND chip with 4KiB NAND pages, 256KiB eraseblock
size and 224 bytes OOB. The second one is a 1GiB NAND chip with the same page
and eraseblock sizes, but with 232 bytes OOB.
This means that we have to store full ID in our NAND flashes table in order to
distinguish between these 2.
This patch adds the 'id[8]' field to the 'struct nand_flash_dev' structure, and
it makes it to be a part of anonymous union, where the second member is a
structure containing the 'mfr_id' and 'dev_id' bytes. The union makes sure that
'mfr_id' refers the same RAM address as 'id[0]' and 'dev_id' refers the same
RAM address as 'id[1]'. The only motivation for the union is an assumption that
'type->dev_id' is more readable than 'type->id[1]'.
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Diffstat (limited to 'include/linux/mtd/nand.h')
-rw-r--r-- | include/linux/mtd/nand.h | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h index 63b319a6f98c..9a1b74c85044 100644 --- a/include/linux/mtd/nand.h +++ b/include/linux/mtd/nand.h | |||
@@ -551,9 +551,9 @@ struct nand_chip { | |||
551 | * defined the chip, including the geometry (chip size, eraseblock size, page | 551 | * defined the chip, including the geometry (chip size, eraseblock size, page |
552 | * size). | 552 | * size). |
553 | */ | 553 | */ |
554 | #define LEGACY_ID_NAND(nm, devid, pagesz, chipsz, erasesz, opts) \ | 554 | #define LEGACY_ID_NAND(nm, devid, pagesz, chipsz, erasesz, opts) \ |
555 | { .name = (nm), .dev_id = (devid), .pagesize = (pagesz), \ | 555 | { .name = (nm), {{ .dev_id = (devid) }}, .pagesize = (pagesz), \ |
556 | .chipsize = (chipsz), .erasesize = (erasesz), \ | 556 | .chipsize = (chipsz), .erasesize = (erasesz), \ |
557 | .options = (opts) } | 557 | .options = (opts) } |
558 | 558 | ||
559 | /* | 559 | /* |
@@ -566,14 +566,19 @@ struct nand_chip { | |||
566 | * buswidth), and the page size, eraseblock size, and OOB size could vary while | 566 | * buswidth), and the page size, eraseblock size, and OOB size could vary while |
567 | * using the same device ID. | 567 | * using the same device ID. |
568 | */ | 568 | */ |
569 | #define EXTENDED_ID_NAND(nm, devid, chipsz, opts) \ | 569 | #define EXTENDED_ID_NAND(nm, devid, chipsz, opts) \ |
570 | { .name = (nm), .dev_id = (devid), .chipsize = (chipsz), \ | 570 | { .name = (nm), {{ .dev_id = (devid) }}, .chipsize = (chipsz), \ |
571 | .options = (opts) } | 571 | .options = (opts) } |
572 | 572 | ||
573 | /** | 573 | /** |
574 | * struct nand_flash_dev - NAND Flash Device ID Structure | 574 | * struct nand_flash_dev - NAND Flash Device ID Structure |
575 | * @name: a human-readable name of the NAND chip | 575 | * @name: a human-readable name of the NAND chip |
576 | * @dev_id: the device ID (the second byte of the full chip ID array) | 576 | * @dev_id: the device ID (the second byte of the full chip ID array) |
577 | * @mfr_id: manufecturer ID part of the full chip ID array (refers the same | ||
578 | * memory address as @id[0]) | ||
579 | * @dev_id: device ID part of the full chip ID array (refers the same memory | ||
580 | * address as @id[1]) | ||
581 | * @id: full device ID array | ||
577 | * @pagesize: size of the NAND page in bytes; if 0, then the real page size (as | 582 | * @pagesize: size of the NAND page in bytes; if 0, then the real page size (as |
578 | * well as the eraseblock size) is determined from the extended NAND | 583 | * well as the eraseblock size) is determined from the extended NAND |
579 | * chip ID array) | 584 | * chip ID array) |
@@ -583,7 +588,13 @@ struct nand_chip { | |||
583 | */ | 588 | */ |
584 | struct nand_flash_dev { | 589 | struct nand_flash_dev { |
585 | char *name; | 590 | char *name; |
586 | int dev_id; | 591 | union { |
592 | struct { | ||
593 | uint8_t mfr_id; | ||
594 | uint8_t dev_id; | ||
595 | }; | ||
596 | uint8_t id[8]; | ||
597 | }; | ||
587 | unsigned long pagesize; | 598 | unsigned long pagesize; |
588 | unsigned long chipsize; | 599 | unsigned long chipsize; |
589 | unsigned long erasesize; | 600 | unsigned long erasesize; |