diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2016-01-13 14:25:54 -0500 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2016-01-13 14:25:54 -0500 |
| commit | ac53b2e053fffc74372da94e734b92f37e70d32c (patch) | |
| tree | cda82af0fcded5d230e9f56104d3988b7a75c8aa /include/linux | |
| parent | cf09112d160e6db21ff8427ce696f819b957423b (diff) | |
| parent | 9146cbd52b11d4ade62dba8f238ec5e421c3fa2b (diff) | |
Merge tag 'for-linus-20160112' of git://git.infradead.org/linux-mtd
Pull MTD updates from Brian Norris:
"Generic MTD:
- populate the MTD device 'of_node' field (and get a proper 'of_node'
symlink in sysfs)
This yielded some new helper functions, and changes across a
variety of drivers
- partitioning cleanups, to prepare for better device-tree based
partitioning in the future
Eliminate a lot of boilerplate for drivers that want to use
OF-based partition parsing
The DT bindings for this didn't settle yet, so most non-cleanup
portions are deferred for a future release
NAND:
- embed a struct mtd_info inside struct nand_chip
This is really long overdue; too many drivers have to do the same
silly boilerplate to allocate and link up two "independent"
structs, when in fact, everyone is assuming there is an exact 1:1
relationship between a NAND chips struct and its underlying MTD.
This aids improved helpers and should make certain abstractions
easier in the future.
Also causes a lot of churn, helped along by some automated code
transformations
- add more core support for detecting (and "correcting") bitflips in
erased pages; requires opt-in by drivers, but at least we kill a
few bad implementations and hopefully stave off future ones
- pxa3xx_nand: cleanups, a few fixes, and PM improvements
- new JZ4780 NAND driver
SPI NOR:
- provide default erase function, for controllers that just want to
send the SECTOR_ERASE command directly
- fix some module auto-loading issues with device tree
("jedec,spi-nor")
- error handling fixes
- new Mediatek QSPI flash driver
Other:
- cfi: force valid geometry Kconfig (finally!)
This one used to trip up randconfigs occasionally, since bots
aren't deterred by big scary "advanced configuration" menus
More? Probably. See the commit logs"
* tag 'for-linus-20160112' of git://git.infradead.org/linux-mtd: (168 commits)
mtd: jz4780_nand: replace if/else blocks with switch/case
mtd: nand: jz4780: Update ecc correction error codes
mtd: nandsim: use nand_get_controller_data()
mtd: jz4780_nand: remove useless mtd->priv = chip assignment
staging: mt29f_spinand: make use of nand_set/get_controller_data() helpers
mtd: nand: make use of nand_set/get_controller_data() helpers
ARM: make use of nand_set/get_controller_data() helpers
mtd: nand: add helpers to access ->priv
mtd: nand: jz4780: driver for NAND devices on JZ4780 SoCs
mtd: nand: jz4740: remove custom 'erased check' implementation
mtd: nand: diskonchip: remove custom 'erased check' implementation
mtd: nand: davinci: remove custom 'erased check' implementation
mtd: nand: use nand_check_erased_ecc_chunk in default ECC read functions
mtd: nand: return consistent error codes in ecc.correct() implementations
doc: dt: mtd: new binding for jz4780-{nand,bch}
mtd: cfi_cmdset_0001: fixing memory leak and handling failed kmalloc
mtd: spi-nor: wait until lock/unlock operations are ready
mtd: tests: consolidate kmalloc/memset 0 call to kzalloc
jffs2: use to_delayed_work
mtd: nand: assign reasonable default name for NAND drivers
...
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/bcma/bcma_driver_chipcommon.h | 6 | ||||
| -rw-r--r-- | include/linux/mtd/map.h | 2 | ||||
| -rw-r--r-- | include/linux/mtd/mtd.h | 11 | ||||
| -rw-r--r-- | include/linux/mtd/nand.h | 71 | ||||
| -rw-r--r-- | include/linux/mtd/nand_bch.h | 2 | ||||
| -rw-r--r-- | include/linux/mtd/partitions.h | 27 | ||||
| -rw-r--r-- | include/linux/mtd/sh_flctl.h | 4 | ||||
| -rw-r--r-- | include/linux/mtd/spi-nor.h | 19 |
8 files changed, 108 insertions, 34 deletions
diff --git a/include/linux/bcma/bcma_driver_chipcommon.h b/include/linux/bcma/bcma_driver_chipcommon.h index cf038431a5cc..db51a6ffb7d6 100644 --- a/include/linux/bcma/bcma_driver_chipcommon.h +++ b/include/linux/bcma/bcma_driver_chipcommon.h | |||
| @@ -579,6 +579,8 @@ struct bcma_pflash { | |||
| 579 | }; | 579 | }; |
| 580 | 580 | ||
| 581 | #ifdef CONFIG_BCMA_SFLASH | 581 | #ifdef CONFIG_BCMA_SFLASH |
| 582 | struct mtd_info; | ||
| 583 | |||
| 582 | struct bcma_sflash { | 584 | struct bcma_sflash { |
| 583 | bool present; | 585 | bool present; |
| 584 | u32 window; | 586 | u32 window; |
| @@ -592,13 +594,9 @@ struct bcma_sflash { | |||
| 592 | #endif | 594 | #endif |
| 593 | 595 | ||
| 594 | #ifdef CONFIG_BCMA_NFLASH | 596 | #ifdef CONFIG_BCMA_NFLASH |
| 595 | struct mtd_info; | ||
| 596 | |||
| 597 | struct bcma_nflash { | 597 | struct bcma_nflash { |
| 598 | bool present; | 598 | bool present; |
| 599 | bool boot; /* This is the flash the SoC boots from */ | 599 | bool boot; /* This is the flash the SoC boots from */ |
| 600 | |||
| 601 | struct mtd_info *mtd; | ||
| 602 | }; | 600 | }; |
| 603 | #endif | 601 | #endif |
| 604 | 602 | ||
diff --git a/include/linux/mtd/map.h b/include/linux/mtd/map.h index 366cf77953b5..58f3ba709ade 100644 --- a/include/linux/mtd/map.h +++ b/include/linux/mtd/map.h | |||
| @@ -142,7 +142,9 @@ | |||
| 142 | #endif | 142 | #endif |
| 143 | 143 | ||
| 144 | #ifndef map_bankwidth | 144 | #ifndef map_bankwidth |
| 145 | #ifdef CONFIG_MTD | ||
| 145 | #warning "No CONFIG_MTD_MAP_BANK_WIDTH_xx selected. No NOR chip support can work" | 146 | #warning "No CONFIG_MTD_MAP_BANK_WIDTH_xx selected. No NOR chip support can work" |
| 147 | #endif | ||
| 146 | static inline int map_bankwidth(void *map) | 148 | static inline int map_bankwidth(void *map) |
| 147 | { | 149 | { |
| 148 | BUG(); | 150 | BUG(); |
diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h index f17fa75809aa..cc84923011c0 100644 --- a/include/linux/mtd/mtd.h +++ b/include/linux/mtd/mtd.h | |||
| @@ -254,6 +254,17 @@ struct mtd_info { | |||
| 254 | int usecount; | 254 | int usecount; |
| 255 | }; | 255 | }; |
| 256 | 256 | ||
| 257 | static inline void mtd_set_of_node(struct mtd_info *mtd, | ||
| 258 | struct device_node *np) | ||
| 259 | { | ||
| 260 | mtd->dev.of_node = np; | ||
| 261 | } | ||
| 262 | |||
| 263 | static inline struct device_node *mtd_get_of_node(struct mtd_info *mtd) | ||
| 264 | { | ||
| 265 | return mtd->dev.of_node; | ||
| 266 | } | ||
| 267 | |||
| 257 | int mtd_erase(struct mtd_info *mtd, struct erase_info *instr); | 268 | int mtd_erase(struct mtd_info *mtd, struct erase_info *instr); |
| 258 | int mtd_point(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, | 269 | int mtd_point(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, |
| 259 | void **virt, resource_size_t *phys); | 270 | void **virt, resource_size_t *phys); |
diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h index 5a9d1d4c2487..bdd68e22b5a5 100644 --- a/include/linux/mtd/nand.h +++ b/include/linux/mtd/nand.h | |||
| @@ -129,6 +129,14 @@ typedef enum { | |||
| 129 | /* Enable Hardware ECC before syndrome is read back from flash */ | 129 | /* Enable Hardware ECC before syndrome is read back from flash */ |
| 130 | #define NAND_ECC_READSYN 2 | 130 | #define NAND_ECC_READSYN 2 |
| 131 | 131 | ||
| 132 | /* | ||
| 133 | * Enable generic NAND 'page erased' check. This check is only done when | ||
| 134 | * ecc.correct() returns -EBADMSG. | ||
| 135 | * Set this flag if your implementation does not fix bitflips in erased | ||
| 136 | * pages and you want to rely on the default implementation. | ||
| 137 | */ | ||
| 138 | #define NAND_ECC_GENERIC_ERASED_CHECK BIT(0) | ||
| 139 | |||
| 132 | /* Bit mask for flags passed to do_nand_read_ecc */ | 140 | /* Bit mask for flags passed to do_nand_read_ecc */ |
| 133 | #define NAND_GET_DEVICE 0x80 | 141 | #define NAND_GET_DEVICE 0x80 |
| 134 | 142 | ||
| @@ -276,15 +284,15 @@ struct nand_onfi_params { | |||
| 276 | __le16 t_r; | 284 | __le16 t_r; |
| 277 | __le16 t_ccs; | 285 | __le16 t_ccs; |
| 278 | __le16 src_sync_timing_mode; | 286 | __le16 src_sync_timing_mode; |
| 279 | __le16 src_ssync_features; | 287 | u8 src_ssync_features; |
| 280 | __le16 clk_pin_capacitance_typ; | 288 | __le16 clk_pin_capacitance_typ; |
| 281 | __le16 io_pin_capacitance_typ; | 289 | __le16 io_pin_capacitance_typ; |
| 282 | __le16 input_pin_capacitance_typ; | 290 | __le16 input_pin_capacitance_typ; |
| 283 | u8 input_pin_capacitance_max; | 291 | u8 input_pin_capacitance_max; |
| 284 | u8 driver_strength_support; | 292 | u8 driver_strength_support; |
| 285 | __le16 t_int_r; | 293 | __le16 t_int_r; |
| 286 | __le16 t_ald; | 294 | __le16 t_adl; |
| 287 | u8 reserved4[7]; | 295 | u8 reserved4[8]; |
| 288 | 296 | ||
| 289 | /* vendor */ | 297 | /* vendor */ |
| 290 | __le16 vendor_revision; | 298 | __le16 vendor_revision; |
| @@ -407,7 +415,7 @@ struct nand_jedec_params { | |||
| 407 | __le16 input_pin_capacitance_typ; | 415 | __le16 input_pin_capacitance_typ; |
| 408 | __le16 clk_pin_capacitance_typ; | 416 | __le16 clk_pin_capacitance_typ; |
| 409 | u8 driver_strength_support; | 417 | u8 driver_strength_support; |
| 410 | __le16 t_ald; | 418 | __le16 t_adl; |
| 411 | u8 reserved4[36]; | 419 | u8 reserved4[36]; |
| 412 | 420 | ||
| 413 | /* ECC and endurance block */ | 421 | /* ECC and endurance block */ |
| @@ -451,12 +459,19 @@ struct nand_hw_control { | |||
| 451 | * @total: total number of ECC bytes per page | 459 | * @total: total number of ECC bytes per page |
| 452 | * @prepad: padding information for syndrome based ECC generators | 460 | * @prepad: padding information for syndrome based ECC generators |
| 453 | * @postpad: padding information for syndrome based ECC generators | 461 | * @postpad: padding information for syndrome based ECC generators |
| 462 | * @options: ECC specific options (see NAND_ECC_XXX flags defined above) | ||
| 454 | * @layout: ECC layout control struct pointer | 463 | * @layout: ECC layout control struct pointer |
| 455 | * @priv: pointer to private ECC control data | 464 | * @priv: pointer to private ECC control data |
| 456 | * @hwctl: function to control hardware ECC generator. Must only | 465 | * @hwctl: function to control hardware ECC generator. Must only |
| 457 | * be provided if an hardware ECC is available | 466 | * be provided if an hardware ECC is available |
| 458 | * @calculate: function for ECC calculation or readback from ECC hardware | 467 | * @calculate: function for ECC calculation or readback from ECC hardware |
| 459 | * @correct: function for ECC correction, matching to ECC generator (sw/hw) | 468 | * @correct: function for ECC correction, matching to ECC generator (sw/hw). |
| 469 | * Should return a positive number representing the number of | ||
| 470 | * corrected bitflips, -EBADMSG if the number of bitflips exceed | ||
| 471 | * ECC strength, or any other error code if the error is not | ||
| 472 | * directly related to correction. | ||
| 473 | * If -EBADMSG is returned the input buffers should be left | ||
| 474 | * untouched. | ||
| 460 | * @read_page_raw: function to read a raw page without ECC. This function | 475 | * @read_page_raw: function to read a raw page without ECC. This function |
| 461 | * should hide the specific layout used by the ECC | 476 | * should hide the specific layout used by the ECC |
| 462 | * controller and always return contiguous in-band and | 477 | * controller and always return contiguous in-band and |
| @@ -494,6 +509,7 @@ struct nand_ecc_ctrl { | |||
| 494 | int strength; | 509 | int strength; |
| 495 | int prepad; | 510 | int prepad; |
| 496 | int postpad; | 511 | int postpad; |
| 512 | unsigned int options; | ||
| 497 | struct nand_ecclayout *layout; | 513 | struct nand_ecclayout *layout; |
| 498 | void *priv; | 514 | void *priv; |
| 499 | void (*hwctl)(struct mtd_info *mtd, int mode); | 515 | void (*hwctl)(struct mtd_info *mtd, int mode); |
| @@ -540,11 +556,11 @@ struct nand_buffers { | |||
| 540 | 556 | ||
| 541 | /** | 557 | /** |
| 542 | * struct nand_chip - NAND Private Flash Chip Data | 558 | * struct nand_chip - NAND Private Flash Chip Data |
| 559 | * @mtd: MTD device registered to the MTD framework | ||
| 543 | * @IO_ADDR_R: [BOARDSPECIFIC] address to read the 8 I/O lines of the | 560 | * @IO_ADDR_R: [BOARDSPECIFIC] address to read the 8 I/O lines of the |
| 544 | * flash device | 561 | * flash device |
| 545 | * @IO_ADDR_W: [BOARDSPECIFIC] address to write the 8 I/O lines of the | 562 | * @IO_ADDR_W: [BOARDSPECIFIC] address to write the 8 I/O lines of the |
| 546 | * flash device. | 563 | * flash device. |
| 547 | * @flash_node: [BOARDSPECIFIC] device node describing this instance | ||
| 548 | * @read_byte: [REPLACEABLE] read one byte from the chip | 564 | * @read_byte: [REPLACEABLE] read one byte from the chip |
| 549 | * @read_word: [REPLACEABLE] read one word from the chip | 565 | * @read_word: [REPLACEABLE] read one word from the chip |
| 550 | * @write_byte: [REPLACEABLE] write a single byte to the chip on the | 566 | * @write_byte: [REPLACEABLE] write a single byte to the chip on the |
| @@ -640,11 +656,10 @@ struct nand_buffers { | |||
| 640 | */ | 656 | */ |
| 641 | 657 | ||
| 642 | struct nand_chip { | 658 | struct nand_chip { |
| 659 | struct mtd_info mtd; | ||
| 643 | void __iomem *IO_ADDR_R; | 660 | void __iomem *IO_ADDR_R; |
| 644 | void __iomem *IO_ADDR_W; | 661 | void __iomem *IO_ADDR_W; |
| 645 | 662 | ||
| 646 | struct device_node *flash_node; | ||
| 647 | |||
| 648 | uint8_t (*read_byte)(struct mtd_info *mtd); | 663 | uint8_t (*read_byte)(struct mtd_info *mtd); |
| 649 | u16 (*read_word)(struct mtd_info *mtd); | 664 | u16 (*read_word)(struct mtd_info *mtd); |
| 650 | void (*write_byte)(struct mtd_info *mtd, uint8_t byte); | 665 | void (*write_byte)(struct mtd_info *mtd, uint8_t byte); |
| @@ -719,6 +734,37 @@ struct nand_chip { | |||
| 719 | void *priv; | 734 | void *priv; |
| 720 | }; | 735 | }; |
| 721 | 736 | ||
| 737 | static inline void nand_set_flash_node(struct nand_chip *chip, | ||
| 738 | struct device_node *np) | ||
| 739 | { | ||
| 740 | mtd_set_of_node(&chip->mtd, np); | ||
| 741 | } | ||
| 742 | |||
| 743 | static inline struct device_node *nand_get_flash_node(struct nand_chip *chip) | ||
| 744 | { | ||
| 745 | return mtd_get_of_node(&chip->mtd); | ||
| 746 | } | ||
| 747 | |||
| 748 | static inline struct nand_chip *mtd_to_nand(struct mtd_info *mtd) | ||
| 749 | { | ||
| 750 | return container_of(mtd, struct nand_chip, mtd); | ||
| 751 | } | ||
| 752 | |||
| 753 | static inline struct mtd_info *nand_to_mtd(struct nand_chip *chip) | ||
| 754 | { | ||
| 755 | return &chip->mtd; | ||
| 756 | } | ||
| 757 | |||
| 758 | static inline void *nand_get_controller_data(struct nand_chip *chip) | ||
| 759 | { | ||
| 760 | return chip->priv; | ||
| 761 | } | ||
| 762 | |||
| 763 | static inline void nand_set_controller_data(struct nand_chip *chip, void *priv) | ||
| 764 | { | ||
| 765 | chip->priv = priv; | ||
| 766 | } | ||
| 767 | |||
| 722 | /* | 768 | /* |
| 723 | * NAND Flash Manufacturer ID Codes | 769 | * NAND Flash Manufacturer ID Codes |
| 724 | */ | 770 | */ |
| @@ -907,15 +953,6 @@ struct platform_nand_data { | |||
| 907 | struct platform_nand_ctrl ctrl; | 953 | struct platform_nand_ctrl ctrl; |
| 908 | }; | 954 | }; |
| 909 | 955 | ||
| 910 | /* Some helpers to access the data structures */ | ||
| 911 | static inline | ||
| 912 | struct platform_nand_chip *get_platform_nandchip(struct mtd_info *mtd) | ||
| 913 | { | ||
| 914 | struct nand_chip *chip = mtd->priv; | ||
| 915 | |||
| 916 | return chip->priv; | ||
| 917 | } | ||
| 918 | |||
| 919 | /* return the supported features. */ | 956 | /* return the supported features. */ |
| 920 | static inline int onfi_feature(struct nand_chip *chip) | 957 | static inline int onfi_feature(struct nand_chip *chip) |
| 921 | { | 958 | { |
diff --git a/include/linux/mtd/nand_bch.h b/include/linux/mtd/nand_bch.h index 74acf5367556..fb0bc3420a10 100644 --- a/include/linux/mtd/nand_bch.h +++ b/include/linux/mtd/nand_bch.h | |||
| @@ -55,7 +55,7 @@ static inline int | |||
| 55 | nand_bch_correct_data(struct mtd_info *mtd, unsigned char *buf, | 55 | nand_bch_correct_data(struct mtd_info *mtd, unsigned char *buf, |
| 56 | unsigned char *read_ecc, unsigned char *calc_ecc) | 56 | unsigned char *read_ecc, unsigned char *calc_ecc) |
| 57 | { | 57 | { |
| 58 | return -1; | 58 | return -ENOTSUPP; |
| 59 | } | 59 | } |
| 60 | 60 | ||
| 61 | static inline struct nand_bch_control * | 61 | static inline struct nand_bch_control * |
diff --git a/include/linux/mtd/partitions.h b/include/linux/mtd/partitions.h index 6a35e6de5da1..70736e1e6c8f 100644 --- a/include/linux/mtd/partitions.h +++ b/include/linux/mtd/partitions.h | |||
| @@ -41,7 +41,6 @@ struct mtd_partition { | |||
| 41 | uint64_t size; /* partition size */ | 41 | uint64_t size; /* partition size */ |
| 42 | uint64_t offset; /* offset within the master MTD space */ | 42 | uint64_t offset; /* offset within the master MTD space */ |
| 43 | uint32_t mask_flags; /* master MTD flags to mask out for this partition */ | 43 | uint32_t mask_flags; /* master MTD flags to mask out for this partition */ |
| 44 | struct nand_ecclayout *ecclayout; /* out of band layout for this partition (NAND only) */ | ||
| 45 | }; | 44 | }; |
| 46 | 45 | ||
| 47 | #define MTDPART_OFS_RETAIN (-3) | 46 | #define MTDPART_OFS_RETAIN (-3) |
| @@ -56,11 +55,9 @@ struct device_node; | |||
| 56 | /** | 55 | /** |
| 57 | * struct mtd_part_parser_data - used to pass data to MTD partition parsers. | 56 | * struct mtd_part_parser_data - used to pass data to MTD partition parsers. |
| 58 | * @origin: for RedBoot, start address of MTD device | 57 | * @origin: for RedBoot, start address of MTD device |
| 59 | * @of_node: for OF parsers, device node containing partitioning information | ||
| 60 | */ | 58 | */ |
| 61 | struct mtd_part_parser_data { | 59 | struct mtd_part_parser_data { |
| 62 | unsigned long origin; | 60 | unsigned long origin; |
| 63 | struct device_node *of_node; | ||
| 64 | }; | 61 | }; |
| 65 | 62 | ||
| 66 | 63 | ||
| @@ -72,13 +69,33 @@ struct mtd_part_parser { | |||
| 72 | struct list_head list; | 69 | struct list_head list; |
| 73 | struct module *owner; | 70 | struct module *owner; |
| 74 | const char *name; | 71 | const char *name; |
| 75 | int (*parse_fn)(struct mtd_info *, struct mtd_partition **, | 72 | int (*parse_fn)(struct mtd_info *, const struct mtd_partition **, |
| 76 | struct mtd_part_parser_data *); | 73 | struct mtd_part_parser_data *); |
| 74 | void (*cleanup)(const struct mtd_partition *pparts, int nr_parts); | ||
| 77 | }; | 75 | }; |
| 78 | 76 | ||
| 79 | extern void register_mtd_parser(struct mtd_part_parser *parser); | 77 | /* Container for passing around a set of parsed partitions */ |
| 78 | struct mtd_partitions { | ||
| 79 | const struct mtd_partition *parts; | ||
| 80 | int nr_parts; | ||
| 81 | const struct mtd_part_parser *parser; | ||
| 82 | }; | ||
| 83 | |||
| 84 | extern int __register_mtd_parser(struct mtd_part_parser *parser, | ||
| 85 | struct module *owner); | ||
| 86 | #define register_mtd_parser(parser) __register_mtd_parser(parser, THIS_MODULE) | ||
| 87 | |||
| 80 | extern void deregister_mtd_parser(struct mtd_part_parser *parser); | 88 | extern void deregister_mtd_parser(struct mtd_part_parser *parser); |
| 81 | 89 | ||
| 90 | /* | ||
| 91 | * module_mtd_part_parser() - Helper macro for MTD partition parsers that don't | ||
| 92 | * do anything special in module init/exit. Each driver may only use this macro | ||
| 93 | * once, and calling it replaces module_init() and module_exit(). | ||
| 94 | */ | ||
| 95 | #define module_mtd_part_parser(__mtd_part_parser) \ | ||
| 96 | module_driver(__mtd_part_parser, register_mtd_parser, \ | ||
| 97 | deregister_mtd_parser) | ||
| 98 | |||
| 82 | int mtd_is_partition(const struct mtd_info *mtd); | 99 | int mtd_is_partition(const struct mtd_info *mtd); |
| 83 | int mtd_add_partition(struct mtd_info *master, const char *name, | 100 | int mtd_add_partition(struct mtd_info *master, const char *name, |
| 84 | long long offset, long long length); | 101 | long long offset, long long length); |
diff --git a/include/linux/mtd/sh_flctl.h b/include/linux/mtd/sh_flctl.h index 1c28f8879b1c..2251add65fa7 100644 --- a/include/linux/mtd/sh_flctl.h +++ b/include/linux/mtd/sh_flctl.h | |||
| @@ -143,11 +143,11 @@ enum flctl_ecc_res_t { | |||
| 143 | struct dma_chan; | 143 | struct dma_chan; |
| 144 | 144 | ||
| 145 | struct sh_flctl { | 145 | struct sh_flctl { |
| 146 | struct mtd_info mtd; | ||
| 147 | struct nand_chip chip; | 146 | struct nand_chip chip; |
| 148 | struct platform_device *pdev; | 147 | struct platform_device *pdev; |
| 149 | struct dev_pm_qos_request pm_qos; | 148 | struct dev_pm_qos_request pm_qos; |
| 150 | void __iomem *reg; | 149 | void __iomem *reg; |
| 150 | resource_size_t fifo; | ||
| 151 | 151 | ||
| 152 | uint8_t done_buff[2048 + 64]; /* max size 2048 + 64 */ | 152 | uint8_t done_buff[2048 + 64]; /* max size 2048 + 64 */ |
| 153 | int read_bytes; | 153 | int read_bytes; |
| @@ -186,7 +186,7 @@ struct sh_flctl_platform_data { | |||
| 186 | 186 | ||
| 187 | static inline struct sh_flctl *mtd_to_flctl(struct mtd_info *mtdinfo) | 187 | static inline struct sh_flctl *mtd_to_flctl(struct mtd_info *mtdinfo) |
| 188 | { | 188 | { |
| 189 | return container_of(mtdinfo, struct sh_flctl, mtd); | 189 | return container_of(mtd_to_nand(mtdinfo), struct sh_flctl, chip); |
| 190 | } | 190 | } |
| 191 | 191 | ||
| 192 | #endif /* __SH_FLCTL_H__ */ | 192 | #endif /* __SH_FLCTL_H__ */ |
diff --git a/include/linux/mtd/spi-nor.h b/include/linux/mtd/spi-nor.h index bc742dac7d3a..62356d50815b 100644 --- a/include/linux/mtd/spi-nor.h +++ b/include/linux/mtd/spi-nor.h | |||
| @@ -12,6 +12,7 @@ | |||
| 12 | 12 | ||
| 13 | #include <linux/bitops.h> | 13 | #include <linux/bitops.h> |
| 14 | #include <linux/mtd/cfi.h> | 14 | #include <linux/mtd/cfi.h> |
| 15 | #include <linux/mtd/mtd.h> | ||
| 15 | 16 | ||
| 16 | /* | 17 | /* |
| 17 | * Manufacturer IDs | 18 | * Manufacturer IDs |
| @@ -117,14 +118,11 @@ enum spi_nor_option_flags { | |||
| 117 | SNOR_F_USE_FSR = BIT(0), | 118 | SNOR_F_USE_FSR = BIT(0), |
| 118 | }; | 119 | }; |
| 119 | 120 | ||
| 120 | struct mtd_info; | ||
| 121 | |||
| 122 | /** | 121 | /** |
| 123 | * struct spi_nor - Structure for defining a the SPI NOR layer | 122 | * struct spi_nor - Structure for defining a the SPI NOR layer |
| 124 | * @mtd: point to a mtd_info structure | 123 | * @mtd: point to a mtd_info structure |
| 125 | * @lock: the lock for the read/write/erase/lock/unlock operations | 124 | * @lock: the lock for the read/write/erase/lock/unlock operations |
| 126 | * @dev: point to a spi device, or a spi nor controller device. | 125 | * @dev: point to a spi device, or a spi nor controller device. |
| 127 | * @flash_node: point to a device node describing this flash instance. | ||
| 128 | * @page_size: the page size of the SPI NOR | 126 | * @page_size: the page size of the SPI NOR |
| 129 | * @addr_width: number of address bytes | 127 | * @addr_width: number of address bytes |
| 130 | * @erase_opcode: the opcode for erasing a sector | 128 | * @erase_opcode: the opcode for erasing a sector |
| @@ -144,7 +142,8 @@ struct mtd_info; | |||
| 144 | * @read: [DRIVER-SPECIFIC] read data from the SPI NOR | 142 | * @read: [DRIVER-SPECIFIC] read data from the SPI NOR |
| 145 | * @write: [DRIVER-SPECIFIC] write data to the SPI NOR | 143 | * @write: [DRIVER-SPECIFIC] write data to the SPI NOR |
| 146 | * @erase: [DRIVER-SPECIFIC] erase a sector of the SPI NOR | 144 | * @erase: [DRIVER-SPECIFIC] erase a sector of the SPI NOR |
| 147 | * at the offset @offs | 145 | * at the offset @offs; if not provided by the driver, |
| 146 | * spi-nor will send the erase opcode via write_reg() | ||
| 148 | * @flash_lock: [FLASH-SPECIFIC] lock a region of the SPI NOR | 147 | * @flash_lock: [FLASH-SPECIFIC] lock a region of the SPI NOR |
| 149 | * @flash_unlock: [FLASH-SPECIFIC] unlock a region of the SPI NOR | 148 | * @flash_unlock: [FLASH-SPECIFIC] unlock a region of the SPI NOR |
| 150 | * @flash_is_locked: [FLASH-SPECIFIC] check if a region of the SPI NOR is | 149 | * @flash_is_locked: [FLASH-SPECIFIC] check if a region of the SPI NOR is |
| @@ -155,7 +154,6 @@ struct spi_nor { | |||
| 155 | struct mtd_info mtd; | 154 | struct mtd_info mtd; |
| 156 | struct mutex lock; | 155 | struct mutex lock; |
| 157 | struct device *dev; | 156 | struct device *dev; |
| 158 | struct device_node *flash_node; | ||
| 159 | u32 page_size; | 157 | u32 page_size; |
| 160 | u8 addr_width; | 158 | u8 addr_width; |
| 161 | u8 erase_opcode; | 159 | u8 erase_opcode; |
| @@ -185,6 +183,17 @@ struct spi_nor { | |||
| 185 | void *priv; | 183 | void *priv; |
| 186 | }; | 184 | }; |
| 187 | 185 | ||
| 186 | static inline void spi_nor_set_flash_node(struct spi_nor *nor, | ||
| 187 | struct device_node *np) | ||
| 188 | { | ||
| 189 | mtd_set_of_node(&nor->mtd, np); | ||
| 190 | } | ||
| 191 | |||
| 192 | static inline struct device_node *spi_nor_get_flash_node(struct spi_nor *nor) | ||
| 193 | { | ||
| 194 | return mtd_get_of_node(&nor->mtd); | ||
| 195 | } | ||
| 196 | |||
| 188 | /** | 197 | /** |
| 189 | * spi_nor_scan() - scan the SPI NOR | 198 | * spi_nor_scan() - scan the SPI NOR |
| 190 | * @nor: the spi_nor structure | 199 | * @nor: the spi_nor structure |
