diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2019-05-12 17:57:52 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2019-05-12 17:57:52 -0400 |
| commit | 4dbf09fea60d158e60a30c419e0cfa1ea138dd57 (patch) | |
| tree | 9530efcb3ca37e6664b9df41e8a33ea7286dba50 /include/linux | |
| parent | 983dfa4b6ee556563f7963348e4e2f97fc8a15b8 (diff) | |
| parent | 3008ba87093852f3756c5d33f584602e5e2a4aa4 (diff) | |
Merge tag 'mtd/for-5.2' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/mtd/linux
Pull MTD updates from Richard Weinberger:
"MTD core changes:
- New AFS partition parser
- Update MAINTAINERS entry
- Use of fall-throughs markers
NAND core changes:
- Support having the bad block markers in either the first, second or
last page of a block. The combination of all three location is now
possible.
- Constification of NAND_OP_PARSER(_PATTERN) elements.
- Generic NAND DT bindings changed to yaml format (can be used to
check the proposed bindings. First platform to be fully supported:
sunxi.
- Stopped using several legacy hooks.
- Preparation to use the generic NAND layer with the addition of
several helpers and the removal of the struct nand_chip from
generic functions.
- Kconfig cleanup to prepare the introduction of external ECC engines
support.
- Fallthrough comments.
- Introduction of the SPI-mem dirmap API for SPI-NAND devices.
Raw NAND controller drivers changes:
- nandsim:
- Switch to ->exec-op().
- meson:
- Misc cleanups and fixes.
- New OOB layout.
- Sunxi:
- A23/A33 NAND DMA support.
- Ingenic:
- Full reorganization and cleanup.
- Clear separation between NAND controller and ECC engine.
- Support JZ4740 an JZ4725B.
- Denali:
- Clear controller/chip separation.
- ->exec_op() migration.
- Various cleanups.
- fsl_elbc:
- Enable software ECC support.
- Atmel:
- Sam9x60 support.
- GPMI:
- Introduce the GPMI_IS_MXS() macro.
- Various trivial/spelling/coding style fixes.
SPI NOR core changes:
- Print all JEDEC ID bytes on error
- Fix comment of spi_nor_find_best_erase_type()
- Add region locking flags for s25fl512s
SPI NOR controller drivers changes:
- intel-spi:
- Avoid crossing 4K address boundary on read/write
- Add support for Intel Comet Lake SPI serial flash"
* tag 'mtd/for-5.2' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/mtd/linux: (120 commits)
mtd: part: fix incorrect format specifier for an unsigned long long
mtd: lpddr_cmds: Mark expected switch fall-through
mtd: phram: Mark expected switch fall-throughs
mtd: cfi_cmdset_0002: Mark expected switch fall-throughs
mtd: cfi_util: mark expected switch fall-throughs
MAINTAINERS: MTD Git repository is hosted on kernel.org
MAINTAINERS: Update jffs2 entry
mtd: afs: add v2 partition parsing
mtd: afs: factor the IIS read into partition parser
mtd: afs: factor footer parsing into the v1 part parsing
mtd: factor out v1 partition parsing
mtd: afs: simplify partition detection
mtd: afs: simplify partition parsing
mtd: partitions: Add OF support to AFS partitions
mtd: partitions: Add AFS partitions DT bindings
mtd: afs: Move AFS partition parser to parsers subdir
mtd: maps: Make uclinux_ram_map static
mtd: maps: Allow MTD_PHYSMAP with MTD_RAM
MAINTAINERS: Add myself as MTD maintainer
MAINTAINERS: Remove my name from the MTD and NAND entries
...
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/mtd/bbm.h | 14 | ||||
| -rw-r--r-- | include/linux/mtd/nand.h | 32 | ||||
| -rw-r--r-- | include/linux/mtd/nand_bch.h | 6 | ||||
| -rw-r--r-- | include/linux/mtd/onenand.h | 3 | ||||
| -rw-r--r-- | include/linux/mtd/rawnand.h | 122 | ||||
| -rw-r--r-- | include/linux/mtd/spinand.h | 7 | ||||
| -rw-r--r-- | include/linux/platform_data/elm.h | 2 |
7 files changed, 119 insertions, 67 deletions
diff --git a/include/linux/mtd/bbm.h b/include/linux/mtd/bbm.h index 3102bd754d18..010bc5544c54 100644 --- a/include/linux/mtd/bbm.h +++ b/include/linux/mtd/bbm.h | |||
| @@ -93,10 +93,7 @@ struct nand_bbt_descr { | |||
| 93 | #define NAND_BBT_WRITE 0x00002000 | 93 | #define NAND_BBT_WRITE 0x00002000 |
| 94 | /* Read and write back block contents when writing bbt */ | 94 | /* Read and write back block contents when writing bbt */ |
| 95 | #define NAND_BBT_SAVECONTENT 0x00004000 | 95 | #define NAND_BBT_SAVECONTENT 0x00004000 |
| 96 | /* Search good / bad pattern on the first and the second page */ | 96 | |
| 97 | #define NAND_BBT_SCAN2NDPAGE 0x00008000 | ||
| 98 | /* Search good / bad pattern on the last page of the eraseblock */ | ||
| 99 | #define NAND_BBT_SCANLASTPAGE 0x00010000 | ||
| 100 | /* | 97 | /* |
| 101 | * Use a flash based bad block table. By default, OOB identifier is saved in | 98 | * Use a flash based bad block table. By default, OOB identifier is saved in |
| 102 | * OOB area. This option is passed to the default bad block table function. | 99 | * OOB area. This option is passed to the default bad block table function. |
| @@ -124,13 +121,6 @@ struct nand_bbt_descr { | |||
| 124 | #define NAND_BBT_SCAN_MAXBLOCKS 4 | 121 | #define NAND_BBT_SCAN_MAXBLOCKS 4 |
| 125 | 122 | ||
| 126 | /* | 123 | /* |
| 127 | * Constants for oob configuration | ||
| 128 | */ | ||
| 129 | #define NAND_SMALL_BADBLOCK_POS 5 | ||
| 130 | #define NAND_LARGE_BADBLOCK_POS 0 | ||
| 131 | #define ONENAND_BADBLOCK_POS 0 | ||
| 132 | |||
| 133 | /* | ||
| 134 | * Bad block scanning errors | 124 | * Bad block scanning errors |
| 135 | */ | 125 | */ |
| 136 | #define ONENAND_BBT_READ_ERROR 1 | 126 | #define ONENAND_BBT_READ_ERROR 1 |
| @@ -140,7 +130,6 @@ struct nand_bbt_descr { | |||
| 140 | /** | 130 | /** |
| 141 | * struct bbm_info - [GENERIC] Bad Block Table data structure | 131 | * struct bbm_info - [GENERIC] Bad Block Table data structure |
| 142 | * @bbt_erase_shift: [INTERN] number of address bits in a bbt entry | 132 | * @bbt_erase_shift: [INTERN] number of address bits in a bbt entry |
| 143 | * @badblockpos: [INTERN] position of the bad block marker in the oob area | ||
| 144 | * @options: options for this descriptor | 133 | * @options: options for this descriptor |
| 145 | * @bbt: [INTERN] bad block table pointer | 134 | * @bbt: [INTERN] bad block table pointer |
| 146 | * @isbad_bbt: function to determine if a block is bad | 135 | * @isbad_bbt: function to determine if a block is bad |
| @@ -150,7 +139,6 @@ struct nand_bbt_descr { | |||
| 150 | */ | 139 | */ |
| 151 | struct bbm_info { | 140 | struct bbm_info { |
| 152 | int bbt_erase_shift; | 141 | int bbt_erase_shift; |
| 153 | int badblockpos; | ||
| 154 | int options; | 142 | int options; |
| 155 | 143 | ||
| 156 | uint8_t *bbt; | 144 | uint8_t *bbt; |
diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h index 7f53ece2c039..cebc38b6d6f5 100644 --- a/include/linux/mtd/nand.h +++ b/include/linux/mtd/nand.h | |||
| @@ -19,6 +19,7 @@ | |||
| 19 | * @oobsize: OOB area size | 19 | * @oobsize: OOB area size |
| 20 | * @pages_per_eraseblock: number of pages per eraseblock | 20 | * @pages_per_eraseblock: number of pages per eraseblock |
| 21 | * @eraseblocks_per_lun: number of eraseblocks per LUN (Logical Unit Number) | 21 | * @eraseblocks_per_lun: number of eraseblocks per LUN (Logical Unit Number) |
| 22 | * @max_bad_eraseblocks_per_lun: maximum number of eraseblocks per LUN | ||
| 22 | * @planes_per_lun: number of planes per LUN | 23 | * @planes_per_lun: number of planes per LUN |
| 23 | * @luns_per_target: number of LUN per target (target is a synonym for die) | 24 | * @luns_per_target: number of LUN per target (target is a synonym for die) |
| 24 | * @ntargets: total number of targets exposed by the NAND device | 25 | * @ntargets: total number of targets exposed by the NAND device |
| @@ -29,18 +30,20 @@ struct nand_memory_organization { | |||
| 29 | unsigned int oobsize; | 30 | unsigned int oobsize; |
| 30 | unsigned int pages_per_eraseblock; | 31 | unsigned int pages_per_eraseblock; |
| 31 | unsigned int eraseblocks_per_lun; | 32 | unsigned int eraseblocks_per_lun; |
| 33 | unsigned int max_bad_eraseblocks_per_lun; | ||
| 32 | unsigned int planes_per_lun; | 34 | unsigned int planes_per_lun; |
| 33 | unsigned int luns_per_target; | 35 | unsigned int luns_per_target; |
| 34 | unsigned int ntargets; | 36 | unsigned int ntargets; |
| 35 | }; | 37 | }; |
| 36 | 38 | ||
| 37 | #define NAND_MEMORG(bpc, ps, os, ppe, epl, ppl, lpt, nt) \ | 39 | #define NAND_MEMORG(bpc, ps, os, ppe, epl, mbb, ppl, lpt, nt) \ |
| 38 | { \ | 40 | { \ |
| 39 | .bits_per_cell = (bpc), \ | 41 | .bits_per_cell = (bpc), \ |
| 40 | .pagesize = (ps), \ | 42 | .pagesize = (ps), \ |
| 41 | .oobsize = (os), \ | 43 | .oobsize = (os), \ |
| 42 | .pages_per_eraseblock = (ppe), \ | 44 | .pages_per_eraseblock = (ppe), \ |
| 43 | .eraseblocks_per_lun = (epl), \ | 45 | .eraseblocks_per_lun = (epl), \ |
| 46 | .max_bad_eraseblocks_per_lun = (mbb), \ | ||
| 44 | .planes_per_lun = (ppl), \ | 47 | .planes_per_lun = (ppl), \ |
| 45 | .luns_per_target = (lpt), \ | 48 | .luns_per_target = (lpt), \ |
| 46 | .ntargets = (nt), \ | 49 | .ntargets = (nt), \ |
| @@ -269,6 +272,20 @@ nanddev_pages_per_eraseblock(const struct nand_device *nand) | |||
| 269 | } | 272 | } |
| 270 | 273 | ||
| 271 | /** | 274 | /** |
| 275 | * nanddev_pages_per_target() - Get the number of pages per target | ||
| 276 | * @nand: NAND device | ||
| 277 | * | ||
| 278 | * Return: the number of pages per target. | ||
| 279 | */ | ||
| 280 | static inline unsigned int | ||
| 281 | nanddev_pages_per_target(const struct nand_device *nand) | ||
| 282 | { | ||
| 283 | return nand->memorg.pages_per_eraseblock * | ||
| 284 | nand->memorg.eraseblocks_per_lun * | ||
| 285 | nand->memorg.luns_per_target; | ||
| 286 | } | ||
| 287 | |||
| 288 | /** | ||
| 272 | * nanddev_per_page_oobsize() - Get NAND erase block size | 289 | * nanddev_per_page_oobsize() - Get NAND erase block size |
| 273 | * @nand: NAND device | 290 | * @nand: NAND device |
| 274 | * | 291 | * |
| @@ -292,6 +309,18 @@ nanddev_eraseblocks_per_lun(const struct nand_device *nand) | |||
| 292 | } | 309 | } |
| 293 | 310 | ||
| 294 | /** | 311 | /** |
| 312 | * nanddev_eraseblocks_per_target() - Get the number of eraseblocks per target | ||
| 313 | * @nand: NAND device | ||
| 314 | * | ||
| 315 | * Return: the number of eraseblocks per target. | ||
| 316 | */ | ||
| 317 | static inline unsigned int | ||
| 318 | nanddev_eraseblocks_per_target(const struct nand_device *nand) | ||
| 319 | { | ||
| 320 | return nand->memorg.eraseblocks_per_lun * nand->memorg.luns_per_target; | ||
| 321 | } | ||
| 322 | |||
| 323 | /** | ||
| 295 | * nanddev_target_size() - Get the total size provided by a single target/die | 324 | * nanddev_target_size() - Get the total size provided by a single target/die |
| 296 | * @nand: NAND device | 325 | * @nand: NAND device |
| 297 | * | 326 | * |
| @@ -729,5 +758,6 @@ static inline bool nanddev_bbt_is_initialized(struct nand_device *nand) | |||
| 729 | 758 | ||
| 730 | /* MTD -> NAND helper functions. */ | 759 | /* MTD -> NAND helper functions. */ |
| 731 | int nanddev_mtd_erase(struct mtd_info *mtd, struct erase_info *einfo); | 760 | int nanddev_mtd_erase(struct mtd_info *mtd, struct erase_info *einfo); |
| 761 | int nanddev_mtd_max_bad_blocks(struct mtd_info *mtd, loff_t offs, size_t len); | ||
| 732 | 762 | ||
| 733 | #endif /* __LINUX_MTD_NAND_H */ | 763 | #endif /* __LINUX_MTD_NAND_H */ |
diff --git a/include/linux/mtd/nand_bch.h b/include/linux/mtd/nand_bch.h index b8106651f807..a8a6909b594e 100644 --- a/include/linux/mtd/nand_bch.h +++ b/include/linux/mtd/nand_bch.h | |||
| @@ -15,7 +15,7 @@ struct mtd_info; | |||
| 15 | struct nand_chip; | 15 | struct nand_chip; |
| 16 | struct nand_bch_control; | 16 | struct nand_bch_control; |
| 17 | 17 | ||
| 18 | #if defined(CONFIG_MTD_NAND_ECC_BCH) | 18 | #if IS_ENABLED(CONFIG_MTD_NAND_ECC_SW_BCH) |
| 19 | 19 | ||
| 20 | static inline int mtd_nand_has_bch(void) { return 1; } | 20 | static inline int mtd_nand_has_bch(void) { return 1; } |
| 21 | 21 | ||
| @@ -39,7 +39,7 @@ struct nand_bch_control *nand_bch_init(struct mtd_info *mtd); | |||
| 39 | */ | 39 | */ |
| 40 | void nand_bch_free(struct nand_bch_control *nbc); | 40 | void nand_bch_free(struct nand_bch_control *nbc); |
| 41 | 41 | ||
| 42 | #else /* !CONFIG_MTD_NAND_ECC_BCH */ | 42 | #else /* !CONFIG_MTD_NAND_ECC_SW_BCH */ |
| 43 | 43 | ||
| 44 | static inline int mtd_nand_has_bch(void) { return 0; } | 44 | static inline int mtd_nand_has_bch(void) { return 0; } |
| 45 | 45 | ||
| @@ -64,6 +64,6 @@ static inline struct nand_bch_control *nand_bch_init(struct mtd_info *mtd) | |||
| 64 | 64 | ||
| 65 | static inline void nand_bch_free(struct nand_bch_control *nbc) {} | 65 | static inline void nand_bch_free(struct nand_bch_control *nbc) {} |
| 66 | 66 | ||
| 67 | #endif /* CONFIG_MTD_NAND_ECC_BCH */ | 67 | #endif /* CONFIG_MTD_NAND_ECC_SW_BCH */ |
| 68 | 68 | ||
| 69 | #endif /* __MTD_NAND_BCH_H__ */ | 69 | #endif /* __MTD_NAND_BCH_H__ */ |
diff --git a/include/linux/mtd/onenand.h b/include/linux/mtd/onenand.h index 0aaa98b219a4..bfe9e10fae04 100644 --- a/include/linux/mtd/onenand.h +++ b/include/linux/mtd/onenand.h | |||
| @@ -94,6 +94,7 @@ struct onenand_chip { | |||
| 94 | unsigned int technology; | 94 | unsigned int technology; |
| 95 | unsigned int density_mask; | 95 | unsigned int density_mask; |
| 96 | unsigned int options; | 96 | unsigned int options; |
| 97 | unsigned int badblockpos; | ||
| 97 | 98 | ||
| 98 | unsigned int erase_shift; | 99 | unsigned int erase_shift; |
| 99 | unsigned int page_shift; | 100 | unsigned int page_shift; |
| @@ -188,6 +189,8 @@ struct onenand_chip { | |||
| 188 | /* Check byte access in OneNAND */ | 189 | /* Check byte access in OneNAND */ |
| 189 | #define ONENAND_CHECK_BYTE_ACCESS(addr) (addr & 0x1) | 190 | #define ONENAND_CHECK_BYTE_ACCESS(addr) (addr & 0x1) |
| 190 | 191 | ||
| 192 | #define ONENAND_BADBLOCK_POS 0 | ||
| 193 | |||
| 191 | /* | 194 | /* |
| 192 | * Options bits | 195 | * Options bits |
| 193 | */ | 196 | */ |
diff --git a/include/linux/mtd/rawnand.h b/include/linux/mtd/rawnand.h index b7445a44a814..dbfffa5bec7b 100644 --- a/include/linux/mtd/rawnand.h +++ b/include/linux/mtd/rawnand.h | |||
| @@ -20,6 +20,7 @@ | |||
| 20 | #include <linux/mtd/flashchip.h> | 20 | #include <linux/mtd/flashchip.h> |
| 21 | #include <linux/mtd/bbm.h> | 21 | #include <linux/mtd/bbm.h> |
| 22 | #include <linux/mtd/jedec.h> | 22 | #include <linux/mtd/jedec.h> |
| 23 | #include <linux/mtd/nand.h> | ||
| 23 | #include <linux/mtd/onfi.h> | 24 | #include <linux/mtd/onfi.h> |
| 24 | #include <linux/mutex.h> | 25 | #include <linux/mutex.h> |
| 25 | #include <linux/of.h> | 26 | #include <linux/of.h> |
| @@ -168,6 +169,21 @@ enum nand_ecc_algo { | |||
| 168 | /* Macros to identify the above */ | 169 | /* Macros to identify the above */ |
| 169 | #define NAND_HAS_SUBPAGE_READ(chip) ((chip->options & NAND_SUBPAGE_READ)) | 170 | #define NAND_HAS_SUBPAGE_READ(chip) ((chip->options & NAND_SUBPAGE_READ)) |
| 170 | 171 | ||
| 172 | /* | ||
| 173 | * There are different places where the manufacturer stores the factory bad | ||
| 174 | * block markers. | ||
| 175 | * | ||
| 176 | * Position within the block: Each of these pages needs to be checked for a | ||
| 177 | * bad block marking pattern. | ||
| 178 | */ | ||
| 179 | #define NAND_BBM_FIRSTPAGE 0x01000000 | ||
| 180 | #define NAND_BBM_SECONDPAGE 0x02000000 | ||
| 181 | #define NAND_BBM_LASTPAGE 0x04000000 | ||
| 182 | |||
| 183 | /* Position within the OOB data of the page */ | ||
| 184 | #define NAND_BBM_POS_SMALL 5 | ||
| 185 | #define NAND_BBM_POS_LARGE 0 | ||
| 186 | |||
| 171 | /* Non chip related options */ | 187 | /* Non chip related options */ |
| 172 | /* This option skips the bbt scan during initialization. */ | 188 | /* This option skips the bbt scan during initialization. */ |
| 173 | #define NAND_SKIP_BBTSCAN 0x00010000 | 189 | #define NAND_SKIP_BBTSCAN 0x00010000 |
| @@ -805,7 +821,7 @@ struct nand_op_parser_pattern { | |||
| 805 | #define NAND_OP_PARSER_PATTERN(_exec, ...) \ | 821 | #define NAND_OP_PARSER_PATTERN(_exec, ...) \ |
| 806 | { \ | 822 | { \ |
| 807 | .exec = _exec, \ | 823 | .exec = _exec, \ |
| 808 | .elems = (struct nand_op_parser_pattern_elem[]) { __VA_ARGS__ }, \ | 824 | .elems = (const struct nand_op_parser_pattern_elem[]) { __VA_ARGS__ }, \ |
| 809 | .nelems = sizeof((struct nand_op_parser_pattern_elem[]) { __VA_ARGS__ }) / \ | 825 | .nelems = sizeof((struct nand_op_parser_pattern_elem[]) { __VA_ARGS__ }) / \ |
| 810 | sizeof(struct nand_op_parser_pattern_elem), \ | 826 | sizeof(struct nand_op_parser_pattern_elem), \ |
| 811 | } | 827 | } |
| @@ -831,7 +847,7 @@ struct nand_op_parser { | |||
| 831 | 847 | ||
| 832 | #define NAND_OP_PARSER(...) \ | 848 | #define NAND_OP_PARSER(...) \ |
| 833 | { \ | 849 | { \ |
| 834 | .patterns = (struct nand_op_parser_pattern[]) { __VA_ARGS__ }, \ | 850 | .patterns = (const struct nand_op_parser_pattern[]) { __VA_ARGS__ }, \ |
| 835 | .npatterns = sizeof((struct nand_op_parser_pattern[]) { __VA_ARGS__ }) / \ | 851 | .npatterns = sizeof((struct nand_op_parser_pattern[]) { __VA_ARGS__ }) / \ |
| 836 | sizeof(struct nand_op_parser_pattern), \ | 852 | sizeof(struct nand_op_parser_pattern), \ |
| 837 | } | 853 | } |
| @@ -860,6 +876,7 @@ struct nand_operation { | |||
| 860 | int nand_op_parser_exec_op(struct nand_chip *chip, | 876 | int nand_op_parser_exec_op(struct nand_chip *chip, |
| 861 | const struct nand_op_parser *parser, | 877 | const struct nand_op_parser *parser, |
| 862 | const struct nand_operation *op, bool check_only); | 878 | const struct nand_operation *op, bool check_only); |
| 879 | |||
| 863 | /** | 880 | /** |
| 864 | * struct nand_controller_ops - Controller operations | 881 | * struct nand_controller_ops - Controller operations |
| 865 | * | 882 | * |
| @@ -962,7 +979,7 @@ struct nand_legacy { | |||
| 962 | 979 | ||
| 963 | /** | 980 | /** |
| 964 | * struct nand_chip - NAND Private Flash Chip Data | 981 | * struct nand_chip - NAND Private Flash Chip Data |
| 965 | * @mtd: MTD device registered to the MTD framework | 982 | * @base: Inherit from the generic NAND device |
| 966 | * @legacy: All legacy fields/hooks. If you develop a new driver, | 983 | * @legacy: All legacy fields/hooks. If you develop a new driver, |
| 967 | * don't even try to use any of these fields/hooks, and if | 984 | * don't even try to use any of these fields/hooks, and if |
| 968 | * you're modifying an existing driver that is using those | 985 | * you're modifying an existing driver that is using those |
| @@ -990,37 +1007,26 @@ struct nand_legacy { | |||
| 990 | * @badblockbits: [INTERN] minimum number of set bits in a good block's | 1007 | * @badblockbits: [INTERN] minimum number of set bits in a good block's |
| 991 | * bad block marker position; i.e., BBM == 11110111b is | 1008 | * bad block marker position; i.e., BBM == 11110111b is |
| 992 | * not bad when badblockbits == 7 | 1009 | * not bad when badblockbits == 7 |
| 993 | * @bits_per_cell: [INTERN] number of bits per cell. i.e., 1 means SLC. | ||
| 994 | * @ecc_strength_ds: [INTERN] ECC correctability from the datasheet. | ||
| 995 | * Minimum amount of bit errors per @ecc_step_ds guaranteed | ||
| 996 | * to be correctable. If unknown, set to zero. | ||
| 997 | * @ecc_step_ds: [INTERN] ECC step required by the @ecc_strength_ds, | ||
| 998 | * also from the datasheet. It is the recommended ECC step | ||
| 999 | * size, if known; if unknown, set to zero. | ||
| 1000 | * @onfi_timing_mode_default: [INTERN] default ONFI timing mode. This field is | 1010 | * @onfi_timing_mode_default: [INTERN] default ONFI timing mode. This field is |
| 1001 | * set to the actually used ONFI mode if the chip is | 1011 | * set to the actually used ONFI mode if the chip is |
| 1002 | * ONFI compliant or deduced from the datasheet if | 1012 | * ONFI compliant or deduced from the datasheet if |
| 1003 | * the NAND chip is not ONFI compliant. | 1013 | * the NAND chip is not ONFI compliant. |
| 1004 | * @numchips: [INTERN] number of physical chips | ||
| 1005 | * @chipsize: [INTERN] the size of one chip for multichip arrays | ||
| 1006 | * @pagemask: [INTERN] page number mask = number of (pages / chip) - 1 | 1014 | * @pagemask: [INTERN] page number mask = number of (pages / chip) - 1 |
| 1007 | * @data_buf: [INTERN] buffer for data, size is (page size + oobsize). | 1015 | * @data_buf: [INTERN] buffer for data, size is (page size + oobsize). |
| 1008 | * @pagebuf: [INTERN] holds the pagenumber which is currently in | 1016 | * @pagecache: Structure containing page cache related fields |
| 1009 | * data_buf. | 1017 | * @pagecache.bitflips: Number of bitflips of the cached page |
| 1010 | * @pagebuf_bitflips: [INTERN] holds the bitflip count for the page which is | 1018 | * @pagecache.page: Page number currently in the cache. -1 means no page is |
| 1011 | * currently in data_buf. | 1019 | * currently cached |
| 1012 | * @subpagesize: [INTERN] holds the subpagesize | 1020 | * @subpagesize: [INTERN] holds the subpagesize |
| 1013 | * @id: [INTERN] holds NAND ID | 1021 | * @id: [INTERN] holds NAND ID |
| 1014 | * @parameters: [INTERN] holds generic parameters under an easily | 1022 | * @parameters: [INTERN] holds generic parameters under an easily |
| 1015 | * readable form. | 1023 | * readable form. |
| 1016 | * @max_bb_per_die: [INTERN] the max number of bad blocks each die of a | ||
| 1017 | * this nand device will encounter their life times. | ||
| 1018 | * @blocks_per_die: [INTERN] The number of PEBs in a die | ||
| 1019 | * @data_interface: [INTERN] NAND interface timing information | 1024 | * @data_interface: [INTERN] NAND interface timing information |
| 1020 | * @cur_cs: currently selected target. -1 means no target selected, | 1025 | * @cur_cs: currently selected target. -1 means no target selected, |
| 1021 | * otherwise we should always have cur_cs >= 0 && | 1026 | * otherwise we should always have cur_cs >= 0 && |
| 1022 | * cur_cs < numchips. NAND Controller drivers should not | 1027 | * cur_cs < nanddev_ntargets(). NAND Controller drivers |
| 1023 | * modify this value, but they're allowed to read it. | 1028 | * should not modify this value, but they're allowed to |
| 1029 | * read it. | ||
| 1024 | * @read_retries: [INTERN] the number of read retry modes supported | 1030 | * @read_retries: [INTERN] the number of read retry modes supported |
| 1025 | * @lock: lock protecting the suspended field. Also used to | 1031 | * @lock: lock protecting the suspended field. Also used to |
| 1026 | * serialize accesses to the NAND device. | 1032 | * serialize accesses to the NAND device. |
| @@ -1041,7 +1047,7 @@ struct nand_legacy { | |||
| 1041 | */ | 1047 | */ |
| 1042 | 1048 | ||
| 1043 | struct nand_chip { | 1049 | struct nand_chip { |
| 1044 | struct mtd_info mtd; | 1050 | struct nand_device base; |
| 1045 | 1051 | ||
| 1046 | struct nand_legacy legacy; | 1052 | struct nand_legacy legacy; |
| 1047 | 1053 | ||
| @@ -1054,24 +1060,21 @@ struct nand_chip { | |||
| 1054 | int phys_erase_shift; | 1060 | int phys_erase_shift; |
| 1055 | int bbt_erase_shift; | 1061 | int bbt_erase_shift; |
| 1056 | int chip_shift; | 1062 | int chip_shift; |
| 1057 | int numchips; | ||
| 1058 | uint64_t chipsize; | ||
| 1059 | int pagemask; | 1063 | int pagemask; |
| 1060 | u8 *data_buf; | 1064 | u8 *data_buf; |
| 1061 | int pagebuf; | 1065 | |
| 1062 | unsigned int pagebuf_bitflips; | 1066 | struct { |
| 1067 | unsigned int bitflips; | ||
| 1068 | int page; | ||
| 1069 | } pagecache; | ||
| 1070 | |||
| 1063 | int subpagesize; | 1071 | int subpagesize; |
| 1064 | uint8_t bits_per_cell; | ||
| 1065 | uint16_t ecc_strength_ds; | ||
| 1066 | uint16_t ecc_step_ds; | ||
| 1067 | int onfi_timing_mode_default; | 1072 | int onfi_timing_mode_default; |
| 1068 | int badblockpos; | 1073 | unsigned int badblockpos; |
| 1069 | int badblockbits; | 1074 | int badblockbits; |
| 1070 | 1075 | ||
| 1071 | struct nand_id id; | 1076 | struct nand_id id; |
| 1072 | struct nand_parameters parameters; | 1077 | struct nand_parameters parameters; |
| 1073 | u16 max_bb_per_die; | ||
| 1074 | u32 blocks_per_die; | ||
| 1075 | 1078 | ||
| 1076 | struct nand_data_interface data_interface; | 1079 | struct nand_data_interface data_interface; |
| 1077 | 1080 | ||
| @@ -1105,25 +1108,14 @@ struct nand_chip { | |||
| 1105 | extern const struct mtd_ooblayout_ops nand_ooblayout_sp_ops; | 1108 | extern const struct mtd_ooblayout_ops nand_ooblayout_sp_ops; |
| 1106 | extern const struct mtd_ooblayout_ops nand_ooblayout_lp_ops; | 1109 | extern const struct mtd_ooblayout_ops nand_ooblayout_lp_ops; |
| 1107 | 1110 | ||
| 1108 | static inline void nand_set_flash_node(struct nand_chip *chip, | ||
| 1109 | struct device_node *np) | ||
| 1110 | { | ||
| 1111 | mtd_set_of_node(&chip->mtd, np); | ||
| 1112 | } | ||
| 1113 | |||
| 1114 | static inline struct device_node *nand_get_flash_node(struct nand_chip *chip) | ||
| 1115 | { | ||
| 1116 | return mtd_get_of_node(&chip->mtd); | ||
| 1117 | } | ||
| 1118 | |||
| 1119 | static inline struct nand_chip *mtd_to_nand(struct mtd_info *mtd) | 1111 | static inline struct nand_chip *mtd_to_nand(struct mtd_info *mtd) |
| 1120 | { | 1112 | { |
| 1121 | return container_of(mtd, struct nand_chip, mtd); | 1113 | return container_of(mtd, struct nand_chip, base.mtd); |
| 1122 | } | 1114 | } |
| 1123 | 1115 | ||
| 1124 | static inline struct mtd_info *nand_to_mtd(struct nand_chip *chip) | 1116 | static inline struct mtd_info *nand_to_mtd(struct nand_chip *chip) |
| 1125 | { | 1117 | { |
| 1126 | return &chip->mtd; | 1118 | return &chip->base.mtd; |
| 1127 | } | 1119 | } |
| 1128 | 1120 | ||
| 1129 | static inline void *nand_get_controller_data(struct nand_chip *chip) | 1121 | static inline void *nand_get_controller_data(struct nand_chip *chip) |
| @@ -1147,6 +1139,17 @@ static inline void *nand_get_manufacturer_data(struct nand_chip *chip) | |||
| 1147 | return chip->manufacturer.priv; | 1139 | return chip->manufacturer.priv; |
| 1148 | } | 1140 | } |
| 1149 | 1141 | ||
| 1142 | static inline void nand_set_flash_node(struct nand_chip *chip, | ||
| 1143 | struct device_node *np) | ||
| 1144 | { | ||
| 1145 | mtd_set_of_node(nand_to_mtd(chip), np); | ||
| 1146 | } | ||
| 1147 | |||
| 1148 | static inline struct device_node *nand_get_flash_node(struct nand_chip *chip) | ||
| 1149 | { | ||
| 1150 | return mtd_get_of_node(nand_to_mtd(chip)); | ||
| 1151 | } | ||
| 1152 | |||
| 1150 | /* | 1153 | /* |
| 1151 | * A helper for defining older NAND chips where the second ID byte fully | 1154 | * A helper for defining older NAND chips where the second ID byte fully |
| 1152 | * defined the chip, including the geometry (chip size, eraseblock size, page | 1155 | * defined the chip, including the geometry (chip size, eraseblock size, page |
| @@ -1180,9 +1183,9 @@ static inline void *nand_get_manufacturer_data(struct nand_chip *chip) | |||
| 1180 | * @name: a human-readable name of the NAND chip | 1183 | * @name: a human-readable name of the NAND chip |
| 1181 | * @dev_id: the device ID (the second byte of the full chip ID array) | 1184 | * @dev_id: the device ID (the second byte of the full chip ID array) |
| 1182 | * @mfr_id: manufecturer ID part of the full chip ID array (refers the same | 1185 | * @mfr_id: manufecturer ID part of the full chip ID array (refers the same |
| 1183 | * memory address as @id[0]) | 1186 | * memory address as ``id[0]``) |
| 1184 | * @dev_id: device ID part of the full chip ID array (refers the same memory | 1187 | * @dev_id: device ID part of the full chip ID array (refers the same memory |
| 1185 | * address as @id[1]) | 1188 | * address as ``id[1]``) |
| 1186 | * @id: full device ID array | 1189 | * @id: full device ID array |
| 1187 | * @pagesize: size of the NAND page in bytes; if 0, then the real page size (as | 1190 | * @pagesize: size of the NAND page in bytes; if 0, then the real page size (as |
| 1188 | * well as the eraseblock size) is determined from the extended NAND | 1191 | * well as the eraseblock size) is determined from the extended NAND |
| @@ -1235,9 +1238,9 @@ int nand_create_bbt(struct nand_chip *chip); | |||
| 1235 | */ | 1238 | */ |
| 1236 | static inline bool nand_is_slc(struct nand_chip *chip) | 1239 | static inline bool nand_is_slc(struct nand_chip *chip) |
| 1237 | { | 1240 | { |
| 1238 | WARN(chip->bits_per_cell == 0, | 1241 | WARN(nanddev_bits_per_cell(&chip->base) == 0, |
| 1239 | "chip->bits_per_cell is used uninitialized\n"); | 1242 | "chip->bits_per_cell is used uninitialized\n"); |
| 1240 | return chip->bits_per_cell == 1; | 1243 | return nanddev_bits_per_cell(&chip->base) == 1; |
| 1241 | } | 1244 | } |
| 1242 | 1245 | ||
| 1243 | /** | 1246 | /** |
| @@ -1348,4 +1351,25 @@ int nand_gpio_waitrdy(struct nand_chip *chip, struct gpio_desc *gpiod, | |||
| 1348 | void nand_select_target(struct nand_chip *chip, unsigned int cs); | 1351 | void nand_select_target(struct nand_chip *chip, unsigned int cs); |
| 1349 | void nand_deselect_target(struct nand_chip *chip); | 1352 | void nand_deselect_target(struct nand_chip *chip); |
| 1350 | 1353 | ||
| 1354 | /** | ||
| 1355 | * nand_get_data_buf() - Get the internal page buffer | ||
| 1356 | * @chip: NAND chip object | ||
| 1357 | * | ||
| 1358 | * Returns the pre-allocated page buffer after invalidating the cache. This | ||
| 1359 | * function should be used by drivers that do not want to allocate their own | ||
| 1360 | * bounce buffer and still need such a buffer for specific operations (most | ||
| 1361 | * commonly when reading OOB data only). | ||
| 1362 | * | ||
| 1363 | * Be careful to never call this function in the write/write_oob path, because | ||
| 1364 | * the core may have placed the data to be written out in this buffer. | ||
| 1365 | * | ||
| 1366 | * Return: pointer to the page cache buffer | ||
| 1367 | */ | ||
| 1368 | static inline void *nand_get_data_buf(struct nand_chip *chip) | ||
| 1369 | { | ||
| 1370 | chip->pagecache.page = -1; | ||
| 1371 | |||
| 1372 | return chip->data_buf; | ||
| 1373 | } | ||
| 1374 | |||
| 1351 | #endif /* __LINUX_MTD_RAWNAND_H */ | 1375 | #endif /* __LINUX_MTD_RAWNAND_H */ |
diff --git a/include/linux/mtd/spinand.h b/include/linux/mtd/spinand.h index b92e2aa955b6..507f7e289bd1 100644 --- a/include/linux/mtd/spinand.h +++ b/include/linux/mtd/spinand.h | |||
| @@ -302,6 +302,11 @@ struct spinand_info { | |||
| 302 | __VA_ARGS__ \ | 302 | __VA_ARGS__ \ |
| 303 | } | 303 | } |
| 304 | 304 | ||
| 305 | struct spinand_dirmap { | ||
| 306 | struct spi_mem_dirmap_desc *wdesc; | ||
| 307 | struct spi_mem_dirmap_desc *rdesc; | ||
| 308 | }; | ||
| 309 | |||
| 305 | /** | 310 | /** |
| 306 | * struct spinand_device - SPI NAND device instance | 311 | * struct spinand_device - SPI NAND device instance |
| 307 | * @base: NAND device instance | 312 | * @base: NAND device instance |
| @@ -341,6 +346,8 @@ struct spinand_device { | |||
| 341 | const struct spi_mem_op *update_cache; | 346 | const struct spi_mem_op *update_cache; |
| 342 | } op_templates; | 347 | } op_templates; |
| 343 | 348 | ||
| 349 | struct spinand_dirmap *dirmaps; | ||
| 350 | |||
| 344 | int (*select_target)(struct spinand_device *spinand, | 351 | int (*select_target)(struct spinand_device *spinand, |
| 345 | unsigned int target); | 352 | unsigned int target); |
| 346 | unsigned int cur_target; | 353 | unsigned int cur_target; |
diff --git a/include/linux/platform_data/elm.h b/include/linux/platform_data/elm.h index b8686c00f15f..fef4b081b736 100644 --- a/include/linux/platform_data/elm.h +++ b/include/linux/platform_data/elm.h | |||
| @@ -60,6 +60,6 @@ static inline int elm_config(struct device *dev, enum bch_ecc bch_type, | |||
| 60 | { | 60 | { |
| 61 | return -ENOSYS; | 61 | return -ENOSYS; |
| 62 | } | 62 | } |
| 63 | #endif /* CONFIG_MTD_NAND_ECC_BCH */ | 63 | #endif /* CONFIG_MTD_NAND_OMAP_BCH */ |
| 64 | 64 | ||
| 65 | #endif /* __ELM_H */ | 65 | #endif /* __ELM_H */ |
