aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2016-05-24 14:00:20 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2016-05-24 14:00:20 -0400
commit8bc4d5f394a3facbad6af2f18940f1db3b1a0844 (patch)
tree14838a236e87126d4b84d22b9049b9a6f0be878f /include
parent29567292c0b5b2fb484125c280a2175141fe2205 (diff)
parente5366a266a8cd4cd6b0fe66876462cca2e1c6a89 (diff)
Merge tag 'for-linus-20160523' of git://git.infradead.org/linux-mtd
Pull MTD updates from Brian Norris: "First cycle with Boris as NAND maintainer! Many (most) bullets stolen from him. Generic: - Migrated NAND LED trigger to be a generic MTD trigger NAND: - Introduction of the "ECC algorithm" concept, to avoid overloading the ECC mode field too much more - Replaced the nand_ecclayout infrastructure with something a little more flexible (finally!) and future proof - Rework of the OMAP GPMC and NAND drivers; the TI folks pulled some of this into their own tree as well - Prepare the sunxi NAND driver to receive DMA support - Handle bitflips in erased pages on GPMI revisions that do not support this in hardware. SPI NOR: - Start using the spi_flash_read() API for SPI drivers that support it (i.e., SPI drivers with special memory-mapped flash modes) And other small scattered improvments" * tag 'for-linus-20160523' of git://git.infradead.org/linux-mtd: (155 commits) mtd: spi-nor: support GigaDevice gd25lq64c mtd: nand_bch: fix spelling of "probably" mtd: brcmnand: respect ECC algorithm set by NAND subsystem gpmi-nand: Handle ECC Errors in erased pages Documentation: devicetree: deprecate "soft_bch" nand-ecc-mode value mtd: nand: add support for "nand-ecc-algo" DT property mtd: mtd: drop NAND_ECC_SOFT_BCH enum value mtd: drop support for NAND_ECC_SOFT_BCH as "soft_bch" mapping mtd: nand: read ECC algorithm from the new field mtd: nand: fsmc: validate ECC setup by checking algorithm directly mtd: nand: set ECC algorithm to Hamming on fallback staging: mt29f_spinand: set ECC algorithm explicitly CRIS v32: nand: set ECC algorithm explicitly mtd: nand: atmel: set ECC algorithm explicitly mtd: nand: davinci: set ECC algorithm explicitly mtd: nand: bf5xx: set ECC algorithm explicitly mtd: nand: omap2: Fix high memory dma prefetch transfer mtd: nand: omap2: Start dma request before enabling prefetch mtd: nandsim: add __init attribute mtd: nand: move of_get_nand_xxx() helpers into nand_base.c ...
Diffstat (limited to 'include')
-rw-r--r--include/linux/bcma/bcma_driver_chipcommon.h1
-rw-r--r--include/linux/fsl_ifc.h45
-rw-r--r--include/linux/mtd/fsmc.h18
-rw-r--r--include/linux/mtd/map.h19
-rw-r--r--include/linux/mtd/mtd.h63
-rw-r--r--include/linux/mtd/nand.h28
-rw-r--r--include/linux/mtd/onenand.h2
-rw-r--r--include/linux/mtd/sharpsl.h2
-rw-r--r--include/linux/mtd/spi-nor.h1
-rw-r--r--include/linux/of_mtd.h50
-rw-r--r--include/linux/omap-gpmc.h172
-rw-r--r--include/linux/platform_data/gpmc-omap.h172
-rw-r--r--include/linux/platform_data/mtd-nand-omap2.h12
-rw-r--r--include/uapi/mtd/mtd-abi.h2
14 files changed, 329 insertions, 258 deletions
diff --git a/include/linux/bcma/bcma_driver_chipcommon.h b/include/linux/bcma/bcma_driver_chipcommon.h
index 846513c73606..a5ac2cad5cb7 100644
--- a/include/linux/bcma/bcma_driver_chipcommon.h
+++ b/include/linux/bcma/bcma_driver_chipcommon.h
@@ -587,7 +587,6 @@ struct mtd_info;
587 587
588struct bcma_sflash { 588struct bcma_sflash {
589 bool present; 589 bool present;
590 u32 window;
591 u32 blocksize; 590 u32 blocksize;
592 u16 numblocks; 591 u16 numblocks;
593 u32 size; 592 u32 size;
diff --git a/include/linux/fsl_ifc.h b/include/linux/fsl_ifc.h
index 0023088b253b..3f9778cbc79d 100644
--- a/include/linux/fsl_ifc.h
+++ b/include/linux/fsl_ifc.h
@@ -39,6 +39,10 @@
39#define FSL_IFC_VERSION_MASK 0x0F0F0000 39#define FSL_IFC_VERSION_MASK 0x0F0F0000
40#define FSL_IFC_VERSION_1_0_0 0x01000000 40#define FSL_IFC_VERSION_1_0_0 0x01000000
41#define FSL_IFC_VERSION_1_1_0 0x01010000 41#define FSL_IFC_VERSION_1_1_0 0x01010000
42#define FSL_IFC_VERSION_2_0_0 0x02000000
43
44#define PGOFFSET_64K (64*1024)
45#define PGOFFSET_4K (4*1024)
42 46
43/* 47/*
44 * CSPR - Chip Select Property Register 48 * CSPR - Chip Select Property Register
@@ -723,20 +727,26 @@ struct fsl_ifc_nand {
723 __be32 nand_evter_en; 727 __be32 nand_evter_en;
724 u32 res17[0x2]; 728 u32 res17[0x2];
725 __be32 nand_evter_intr_en; 729 __be32 nand_evter_intr_en;
726 u32 res18[0x2]; 730 __be32 nand_vol_addr_stat;
731 u32 res18;
727 __be32 nand_erattr0; 732 __be32 nand_erattr0;
728 __be32 nand_erattr1; 733 __be32 nand_erattr1;
729 u32 res19[0x10]; 734 u32 res19[0x10];
730 __be32 nand_fsr; 735 __be32 nand_fsr;
731 u32 res20; 736 u32 res20[0x3];
732 __be32 nand_eccstat[4]; 737 __be32 nand_eccstat[6];
733 u32 res21[0x20]; 738 u32 res21[0x1c];
734 __be32 nanndcr; 739 __be32 nanndcr;
735 u32 res22[0x2]; 740 u32 res22[0x2];
736 __be32 nand_autoboot_trgr; 741 __be32 nand_autoboot_trgr;
737 u32 res23; 742 u32 res23;
738 __be32 nand_mdr; 743 __be32 nand_mdr;
739 u32 res24[0x5C]; 744 u32 res24[0x1C];
745 __be32 nand_dll_lowcfg0;
746 __be32 nand_dll_lowcfg1;
747 u32 res25;
748 __be32 nand_dll_lowstat;
749 u32 res26[0x3c];
740}; 750};
741 751
742/* 752/*
@@ -771,13 +781,12 @@ struct fsl_ifc_gpcm {
771 __be32 gpcm_erattr1; 781 __be32 gpcm_erattr1;
772 __be32 gpcm_erattr2; 782 __be32 gpcm_erattr2;
773 __be32 gpcm_stat; 783 __be32 gpcm_stat;
774 u32 res4[0x1F3];
775}; 784};
776 785
777/* 786/*
778 * IFC Controller Registers 787 * IFC Controller Registers
779 */ 788 */
780struct fsl_ifc_regs { 789struct fsl_ifc_global {
781 __be32 ifc_rev; 790 __be32 ifc_rev;
782 u32 res1[0x2]; 791 u32 res1[0x2];
783 struct { 792 struct {
@@ -803,21 +812,26 @@ struct fsl_ifc_regs {
803 } ftim_cs[FSL_IFC_BANK_COUNT]; 812 } ftim_cs[FSL_IFC_BANK_COUNT];
804 u32 res9[0x30]; 813 u32 res9[0x30];
805 __be32 rb_stat; 814 __be32 rb_stat;
806 u32 res10[0x2]; 815 __be32 rb_map;
816 __be32 wb_map;
807 __be32 ifc_gcr; 817 __be32 ifc_gcr;
808 u32 res11[0x2]; 818 u32 res10[0x2];
809 __be32 cm_evter_stat; 819 __be32 cm_evter_stat;
810 u32 res12[0x2]; 820 u32 res11[0x2];
811 __be32 cm_evter_en; 821 __be32 cm_evter_en;
812 u32 res13[0x2]; 822 u32 res12[0x2];
813 __be32 cm_evter_intr_en; 823 __be32 cm_evter_intr_en;
814 u32 res14[0x2]; 824 u32 res13[0x2];
815 __be32 cm_erattr0; 825 __be32 cm_erattr0;
816 __be32 cm_erattr1; 826 __be32 cm_erattr1;
817 u32 res15[0x2]; 827 u32 res14[0x2];
818 __be32 ifc_ccr; 828 __be32 ifc_ccr;
819 __be32 ifc_csr; 829 __be32 ifc_csr;
820 u32 res16[0x2EB]; 830 __be32 ddr_ccr_low;
831};
832
833
834struct fsl_ifc_runtime {
821 struct fsl_ifc_nand ifc_nand; 835 struct fsl_ifc_nand ifc_nand;
822 struct fsl_ifc_nor ifc_nor; 836 struct fsl_ifc_nor ifc_nor;
823 struct fsl_ifc_gpcm ifc_gpcm; 837 struct fsl_ifc_gpcm ifc_gpcm;
@@ -831,7 +845,8 @@ extern int fsl_ifc_find(phys_addr_t addr_base);
831struct fsl_ifc_ctrl { 845struct fsl_ifc_ctrl {
832 /* device info */ 846 /* device info */
833 struct device *dev; 847 struct device *dev;
834 struct fsl_ifc_regs __iomem *regs; 848 struct fsl_ifc_global __iomem *gregs;
849 struct fsl_ifc_runtime __iomem *rregs;
835 int irq; 850 int irq;
836 int nand_irq; 851 int nand_irq;
837 spinlock_t lock; 852 spinlock_t lock;
diff --git a/include/linux/mtd/fsmc.h b/include/linux/mtd/fsmc.h
index c8be32e9fc49..ad3c3488073c 100644
--- a/include/linux/mtd/fsmc.h
+++ b/include/linux/mtd/fsmc.h
@@ -103,24 +103,6 @@
103 103
104#define FSMC_BUSY_WAIT_TIMEOUT (1 * HZ) 104#define FSMC_BUSY_WAIT_TIMEOUT (1 * HZ)
105 105
106/*
107 * There are 13 bytes of ecc for every 512 byte block in FSMC version 8
108 * and it has to be read consecutively and immediately after the 512
109 * byte data block for hardware to generate the error bit offsets
110 * Managing the ecc bytes in the following way is easier. This way is
111 * similar to oobfree structure maintained already in u-boot nand driver
112 */
113#define MAX_ECCPLACE_ENTRIES 32
114
115struct fsmc_nand_eccplace {
116 uint8_t offset;
117 uint8_t length;
118};
119
120struct fsmc_eccplace {
121 struct fsmc_nand_eccplace eccplace[MAX_ECCPLACE_ENTRIES];
122};
123
124struct fsmc_nand_timings { 106struct fsmc_nand_timings {
125 uint8_t tclr; 107 uint8_t tclr;
126 uint8_t tar; 108 uint8_t tar;
diff --git a/include/linux/mtd/map.h b/include/linux/mtd/map.h
index 5e0eb7ccabd4..3aa56e3104bb 100644
--- a/include/linux/mtd/map.h
+++ b/include/linux/mtd/map.h
@@ -122,18 +122,13 @@
122#endif 122#endif
123 123
124#ifdef CONFIG_MTD_MAP_BANK_WIDTH_32 124#ifdef CONFIG_MTD_MAP_BANK_WIDTH_32
125# ifdef map_bankwidth 125/* always use indirect access for 256-bit to preserve kernel stack */
126# undef map_bankwidth 126# undef map_bankwidth
127# define map_bankwidth(map) ((map)->bankwidth) 127# define map_bankwidth(map) ((map)->bankwidth)
128# undef map_bankwidth_is_large 128# undef map_bankwidth_is_large
129# define map_bankwidth_is_large(map) (map_bankwidth(map) > BITS_PER_LONG/8) 129# define map_bankwidth_is_large(map) (map_bankwidth(map) > BITS_PER_LONG/8)
130# undef map_words 130# undef map_words
131# define map_words(map) map_calc_words(map) 131# define map_words(map) map_calc_words(map)
132# else
133# define map_bankwidth(map) 32
134# define map_bankwidth_is_large(map) (1)
135# define map_words(map) map_calc_words(map)
136# endif
137#define map_bankwidth_is_32(map) (map_bankwidth(map) == 32) 132#define map_bankwidth_is_32(map) (map_bankwidth(map) == 32)
138#undef MAX_MAP_BANKWIDTH 133#undef MAX_MAP_BANKWIDTH
139#define MAX_MAP_BANKWIDTH 32 134#define MAX_MAP_BANKWIDTH 32
diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h
index ef9fea4fc400..29a170612203 100644
--- a/include/linux/mtd/mtd.h
+++ b/include/linux/mtd/mtd.h
@@ -96,16 +96,35 @@ struct mtd_oob_ops {
96 96
97#define MTD_MAX_OOBFREE_ENTRIES_LARGE 32 97#define MTD_MAX_OOBFREE_ENTRIES_LARGE 32
98#define MTD_MAX_ECCPOS_ENTRIES_LARGE 640 98#define MTD_MAX_ECCPOS_ENTRIES_LARGE 640
99/**
100 * struct mtd_oob_region - oob region definition
101 * @offset: region offset
102 * @length: region length
103 *
104 * This structure describes a region of the OOB area, and is used
105 * to retrieve ECC or free bytes sections.
106 * Each section is defined by an offset within the OOB area and a
107 * length.
108 */
109struct mtd_oob_region {
110 u32 offset;
111 u32 length;
112};
113
99/* 114/*
100 * Internal ECC layout control structure. For historical reasons, there is a 115 * struct mtd_ooblayout_ops - NAND OOB layout operations
101 * similar, smaller struct nand_ecclayout_user (in mtd-abi.h) that is retained 116 * @ecc: function returning an ECC region in the OOB area.
102 * for export to user-space via the ECCGETLAYOUT ioctl. 117 * Should return -ERANGE if %section exceeds the total number of
103 * nand_ecclayout should be expandable in the future simply by the above macros. 118 * ECC sections.
119 * @free: function returning a free region in the OOB area.
120 * Should return -ERANGE if %section exceeds the total number of
121 * free sections.
104 */ 122 */
105struct nand_ecclayout { 123struct mtd_ooblayout_ops {
106 __u32 eccbytes; 124 int (*ecc)(struct mtd_info *mtd, int section,
107 __u32 eccpos[MTD_MAX_ECCPOS_ENTRIES_LARGE]; 125 struct mtd_oob_region *oobecc);
108 struct nand_oobfree oobfree[MTD_MAX_OOBFREE_ENTRIES_LARGE]; 126 int (*free)(struct mtd_info *mtd, int section,
127 struct mtd_oob_region *oobfree);
109}; 128};
110 129
111struct module; /* only needed for owner field in mtd_info */ 130struct module; /* only needed for owner field in mtd_info */
@@ -166,8 +185,8 @@ struct mtd_info {
166 const char *name; 185 const char *name;
167 int index; 186 int index;
168 187
169 /* ECC layout structure pointer - read only! */ 188 /* OOB layout description */
170 struct nand_ecclayout *ecclayout; 189 const struct mtd_ooblayout_ops *ooblayout;
171 190
172 /* the ecc step size. */ 191 /* the ecc step size. */
173 unsigned int ecc_step_size; 192 unsigned int ecc_step_size;
@@ -253,6 +272,30 @@ struct mtd_info {
253 int usecount; 272 int usecount;
254}; 273};
255 274
275int mtd_ooblayout_ecc(struct mtd_info *mtd, int section,
276 struct mtd_oob_region *oobecc);
277int mtd_ooblayout_find_eccregion(struct mtd_info *mtd, int eccbyte,
278 int *section,
279 struct mtd_oob_region *oobregion);
280int mtd_ooblayout_get_eccbytes(struct mtd_info *mtd, u8 *eccbuf,
281 const u8 *oobbuf, int start, int nbytes);
282int mtd_ooblayout_set_eccbytes(struct mtd_info *mtd, const u8 *eccbuf,
283 u8 *oobbuf, int start, int nbytes);
284int mtd_ooblayout_free(struct mtd_info *mtd, int section,
285 struct mtd_oob_region *oobfree);
286int mtd_ooblayout_get_databytes(struct mtd_info *mtd, u8 *databuf,
287 const u8 *oobbuf, int start, int nbytes);
288int mtd_ooblayout_set_databytes(struct mtd_info *mtd, const u8 *databuf,
289 u8 *oobbuf, int start, int nbytes);
290int mtd_ooblayout_count_freebytes(struct mtd_info *mtd);
291int mtd_ooblayout_count_eccbytes(struct mtd_info *mtd);
292
293static inline void mtd_set_ooblayout(struct mtd_info *mtd,
294 const struct mtd_ooblayout_ops *ooblayout)
295{
296 mtd->ooblayout = ooblayout;
297}
298
256static inline void mtd_set_of_node(struct mtd_info *mtd, 299static inline void mtd_set_of_node(struct mtd_info *mtd,
257 struct device_node *np) 300 struct device_node *np)
258{ 301{
diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h
index 56574ba36555..fbe8e164a4ee 100644
--- a/include/linux/mtd/nand.h
+++ b/include/linux/mtd/nand.h
@@ -116,9 +116,14 @@ typedef enum {
116 NAND_ECC_HW, 116 NAND_ECC_HW,
117 NAND_ECC_HW_SYNDROME, 117 NAND_ECC_HW_SYNDROME,
118 NAND_ECC_HW_OOB_FIRST, 118 NAND_ECC_HW_OOB_FIRST,
119 NAND_ECC_SOFT_BCH,
120} nand_ecc_modes_t; 119} nand_ecc_modes_t;
121 120
121enum nand_ecc_algo {
122 NAND_ECC_UNKNOWN,
123 NAND_ECC_HAMMING,
124 NAND_ECC_BCH,
125};
126
122/* 127/*
123 * Constants for Hardware ECC 128 * Constants for Hardware ECC
124 */ 129 */
@@ -458,6 +463,7 @@ struct nand_hw_control {
458/** 463/**
459 * struct nand_ecc_ctrl - Control structure for ECC 464 * struct nand_ecc_ctrl - Control structure for ECC
460 * @mode: ECC mode 465 * @mode: ECC mode
466 * @algo: ECC algorithm
461 * @steps: number of ECC steps per page 467 * @steps: number of ECC steps per page
462 * @size: data bytes per ECC step 468 * @size: data bytes per ECC step
463 * @bytes: ECC bytes per step 469 * @bytes: ECC bytes per step
@@ -466,7 +472,6 @@ struct nand_hw_control {
466 * @prepad: padding information for syndrome based ECC generators 472 * @prepad: padding information for syndrome based ECC generators
467 * @postpad: padding information for syndrome based ECC generators 473 * @postpad: padding information for syndrome based ECC generators
468 * @options: ECC specific options (see NAND_ECC_XXX flags defined above) 474 * @options: ECC specific options (see NAND_ECC_XXX flags defined above)
469 * @layout: ECC layout control struct pointer
470 * @priv: pointer to private ECC control data 475 * @priv: pointer to private ECC control data
471 * @hwctl: function to control hardware ECC generator. Must only 476 * @hwctl: function to control hardware ECC generator. Must only
472 * be provided if an hardware ECC is available 477 * be provided if an hardware ECC is available
@@ -508,6 +513,7 @@ struct nand_hw_control {
508 */ 513 */
509struct nand_ecc_ctrl { 514struct nand_ecc_ctrl {
510 nand_ecc_modes_t mode; 515 nand_ecc_modes_t mode;
516 enum nand_ecc_algo algo;
511 int steps; 517 int steps;
512 int size; 518 int size;
513 int bytes; 519 int bytes;
@@ -516,7 +522,6 @@ struct nand_ecc_ctrl {
516 int prepad; 522 int prepad;
517 int postpad; 523 int postpad;
518 unsigned int options; 524 unsigned int options;
519 struct nand_ecclayout *layout;
520 void *priv; 525 void *priv;
521 void (*hwctl)(struct mtd_info *mtd, int mode); 526 void (*hwctl)(struct mtd_info *mtd, int mode);
522 int (*calculate)(struct mtd_info *mtd, const uint8_t *dat, 527 int (*calculate)(struct mtd_info *mtd, const uint8_t *dat,
@@ -740,6 +745,9 @@ struct nand_chip {
740 void *priv; 745 void *priv;
741}; 746};
742 747
748extern const struct mtd_ooblayout_ops nand_ooblayout_sp_ops;
749extern const struct mtd_ooblayout_ops nand_ooblayout_lp_ops;
750
743static inline void nand_set_flash_node(struct nand_chip *chip, 751static inline void nand_set_flash_node(struct nand_chip *chip,
744 struct device_node *np) 752 struct device_node *np)
745{ 753{
@@ -1070,4 +1078,18 @@ int nand_check_erased_ecc_chunk(void *data, int datalen,
1070 void *ecc, int ecclen, 1078 void *ecc, int ecclen,
1071 void *extraoob, int extraooblen, 1079 void *extraoob, int extraooblen,
1072 int threshold); 1080 int threshold);
1081
1082/* Default write_oob implementation */
1083int nand_write_oob_std(struct mtd_info *mtd, struct nand_chip *chip, int page);
1084
1085/* Default write_oob syndrome implementation */
1086int nand_write_oob_syndrome(struct mtd_info *mtd, struct nand_chip *chip,
1087 int page);
1088
1089/* Default read_oob implementation */
1090int nand_read_oob_std(struct mtd_info *mtd, struct nand_chip *chip, int page);
1091
1092/* Default read_oob syndrome implementation */
1093int nand_read_oob_syndrome(struct mtd_info *mtd, struct nand_chip *chip,
1094 int page);
1073#endif /* __LINUX_MTD_NAND_H */ 1095#endif /* __LINUX_MTD_NAND_H */
diff --git a/include/linux/mtd/onenand.h b/include/linux/mtd/onenand.h
index 4596503c9da9..0aaa98b219a4 100644
--- a/include/linux/mtd/onenand.h
+++ b/include/linux/mtd/onenand.h
@@ -80,7 +80,6 @@ struct onenand_bufferram {
80 * @page_buf: [INTERN] page main data buffer 80 * @page_buf: [INTERN] page main data buffer
81 * @oob_buf: [INTERN] page oob data buffer 81 * @oob_buf: [INTERN] page oob data buffer
82 * @subpagesize: [INTERN] holds the subpagesize 82 * @subpagesize: [INTERN] holds the subpagesize
83 * @ecclayout: [REPLACEABLE] the default ecc placement scheme
84 * @bbm: [REPLACEABLE] pointer to Bad Block Management 83 * @bbm: [REPLACEABLE] pointer to Bad Block Management
85 * @priv: [OPTIONAL] pointer to private chip date 84 * @priv: [OPTIONAL] pointer to private chip date
86 */ 85 */
@@ -134,7 +133,6 @@ struct onenand_chip {
134#endif 133#endif
135 134
136 int subpagesize; 135 int subpagesize;
137 struct nand_ecclayout *ecclayout;
138 136
139 void *bbm; 137 void *bbm;
140 138
diff --git a/include/linux/mtd/sharpsl.h b/include/linux/mtd/sharpsl.h
index 25f4d2a845c1..65e91d0fa981 100644
--- a/include/linux/mtd/sharpsl.h
+++ b/include/linux/mtd/sharpsl.h
@@ -14,7 +14,7 @@
14 14
15struct sharpsl_nand_platform_data { 15struct sharpsl_nand_platform_data {
16 struct nand_bbt_descr *badblock_pattern; 16 struct nand_bbt_descr *badblock_pattern;
17 struct nand_ecclayout *ecc_layout; 17 const struct mtd_ooblayout_ops *ecc_layout;
18 struct mtd_partition *partitions; 18 struct mtd_partition *partitions;
19 unsigned int nr_partitions; 19 unsigned int nr_partitions;
20}; 20};
diff --git a/include/linux/mtd/spi-nor.h b/include/linux/mtd/spi-nor.h
index 3c36113a88e1..7f041bd88b82 100644
--- a/include/linux/mtd/spi-nor.h
+++ b/include/linux/mtd/spi-nor.h
@@ -21,6 +21,7 @@
21 * Sometimes these are the same as CFI IDs, but sometimes they aren't. 21 * Sometimes these are the same as CFI IDs, but sometimes they aren't.
22 */ 22 */
23#define SNOR_MFR_ATMEL CFI_MFR_ATMEL 23#define SNOR_MFR_ATMEL CFI_MFR_ATMEL
24#define SNOR_MFR_GIGADEVICE 0xc8
24#define SNOR_MFR_INTEL CFI_MFR_INTEL 25#define SNOR_MFR_INTEL CFI_MFR_INTEL
25#define SNOR_MFR_MICRON CFI_MFR_ST /* ST Micro <--> Micron */ 26#define SNOR_MFR_MICRON CFI_MFR_ST /* ST Micro <--> Micron */
26#define SNOR_MFR_MACRONIX CFI_MFR_MACRONIX 27#define SNOR_MFR_MACRONIX CFI_MFR_MACRONIX
diff --git a/include/linux/of_mtd.h b/include/linux/of_mtd.h
deleted file mode 100644
index e266caa36402..000000000000
--- a/include/linux/of_mtd.h
+++ /dev/null
@@ -1,50 +0,0 @@
1/*
2 * Copyright 2012 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
3 *
4 * OF helpers for mtd.
5 *
6 * This file is released under the GPLv2
7 */
8
9#ifndef __LINUX_OF_MTD_H
10#define __LINUX_OF_MTD_H
11
12#ifdef CONFIG_OF_MTD
13
14#include <linux/of.h>
15int of_get_nand_ecc_mode(struct device_node *np);
16int of_get_nand_ecc_step_size(struct device_node *np);
17int of_get_nand_ecc_strength(struct device_node *np);
18int of_get_nand_bus_width(struct device_node *np);
19bool of_get_nand_on_flash_bbt(struct device_node *np);
20
21#else /* CONFIG_OF_MTD */
22
23static inline int of_get_nand_ecc_mode(struct device_node *np)
24{
25 return -ENOSYS;
26}
27
28static inline int of_get_nand_ecc_step_size(struct device_node *np)
29{
30 return -ENOSYS;
31}
32
33static inline int of_get_nand_ecc_strength(struct device_node *np)
34{
35 return -ENOSYS;
36}
37
38static inline int of_get_nand_bus_width(struct device_node *np)
39{
40 return -ENOSYS;
41}
42
43static inline bool of_get_nand_on_flash_bbt(struct device_node *np)
44{
45 return false;
46}
47
48#endif /* CONFIG_OF_MTD */
49
50#endif /* __LINUX_OF_MTD_H */
diff --git a/include/linux/omap-gpmc.h b/include/linux/omap-gpmc.h
index d833eb4dd446..9e9d79e8efa5 100644
--- a/include/linux/omap-gpmc.h
+++ b/include/linux/omap-gpmc.h
@@ -7,161 +7,53 @@
7 * option) any later version. 7 * option) any later version.
8 */ 8 */
9 9
10/* Maximum Number of Chip Selects */ 10#include <linux/platform_data/gpmc-omap.h>
11#define GPMC_CS_NUM 8
12 11
13#define GPMC_CONFIG_WP 0x00000005 12#define GPMC_CONFIG_WP 0x00000005
14 13
15#define GPMC_IRQ_FIFOEVENTENABLE 0x01 14/* IRQ numbers in GPMC IRQ domain for legacy boot use */
16#define GPMC_IRQ_COUNT_EVENT 0x02 15#define GPMC_IRQ_FIFOEVENTENABLE 0
17 16#define GPMC_IRQ_COUNT_EVENT 1
18#define GPMC_BURST_4 4 /* 4 word burst */
19#define GPMC_BURST_8 8 /* 8 word burst */
20#define GPMC_BURST_16 16 /* 16 word burst */
21#define GPMC_DEVWIDTH_8BIT 1 /* 8-bit device width */
22#define GPMC_DEVWIDTH_16BIT 2 /* 16-bit device width */
23#define GPMC_MUX_AAD 1 /* Addr-Addr-Data multiplex */
24#define GPMC_MUX_AD 2 /* Addr-Data multiplex */
25
26/* bool type time settings */
27struct gpmc_bool_timings {
28 bool cycle2cyclediffcsen;
29 bool cycle2cyclesamecsen;
30 bool we_extra_delay;
31 bool oe_extra_delay;
32 bool adv_extra_delay;
33 bool cs_extra_delay;
34 bool time_para_granularity;
35};
36 17
37/* 18/**
38 * Note that all values in this struct are in nanoseconds except sync_clk 19 * gpmc_nand_ops - Interface between NAND and GPMC
39 * (which is in picoseconds), while the register values are in gpmc_fck cycles. 20 * @nand_write_buffer_empty: get the NAND write buffer empty status.
40 */ 21 */
41struct gpmc_timings { 22struct gpmc_nand_ops {
42 /* Minimum clock period for synchronous mode (in picoseconds) */ 23 bool (*nand_writebuffer_empty)(void);
43 u32 sync_clk;
44
45 /* Chip-select signal timings corresponding to GPMC_CS_CONFIG2 */
46 u32 cs_on; /* Assertion time */
47 u32 cs_rd_off; /* Read deassertion time */
48 u32 cs_wr_off; /* Write deassertion time */
49
50 /* ADV signal timings corresponding to GPMC_CONFIG3 */
51 u32 adv_on; /* Assertion time */
52 u32 adv_rd_off; /* Read deassertion time */
53 u32 adv_wr_off; /* Write deassertion time */
54 u32 adv_aad_mux_on; /* ADV assertion time for AAD */
55 u32 adv_aad_mux_rd_off; /* ADV read deassertion time for AAD */
56 u32 adv_aad_mux_wr_off; /* ADV write deassertion time for AAD */
57
58 /* WE signals timings corresponding to GPMC_CONFIG4 */
59 u32 we_on; /* WE assertion time */
60 u32 we_off; /* WE deassertion time */
61
62 /* OE signals timings corresponding to GPMC_CONFIG4 */
63 u32 oe_on; /* OE assertion time */
64 u32 oe_off; /* OE deassertion time */
65 u32 oe_aad_mux_on; /* OE assertion time for AAD */
66 u32 oe_aad_mux_off; /* OE deassertion time for AAD */
67
68 /* Access time and cycle time timings corresponding to GPMC_CONFIG5 */
69 u32 page_burst_access; /* Multiple access word delay */
70 u32 access; /* Start-cycle to first data valid delay */
71 u32 rd_cycle; /* Total read cycle time */
72 u32 wr_cycle; /* Total write cycle time */
73
74 u32 bus_turnaround;
75 u32 cycle2cycle_delay;
76
77 u32 wait_monitoring;
78 u32 clk_activation;
79
80 /* The following are only on OMAP3430 */
81 u32 wr_access; /* WRACCESSTIME */
82 u32 wr_data_mux_bus; /* WRDATAONADMUXBUS */
83
84 struct gpmc_bool_timings bool_timings;
85}; 24};
86 25
87/* Device timings in picoseconds */ 26struct gpmc_nand_regs;
88struct gpmc_device_timings {
89 u32 t_ceasu; /* address setup to CS valid */
90 u32 t_avdasu; /* address setup to ADV valid */
91 /* XXX: try to combine t_avdp_r & t_avdp_w. Issue is
92 * of tusb using these timings even for sync whilst
93 * ideally for adv_rd/(wr)_off it should have considered
94 * t_avdh instead. This indirectly necessitates r/w
95 * variations of t_avdp as it is possible to have one
96 * sync & other async
97 */
98 u32 t_avdp_r; /* ADV low time (what about t_cer ?) */
99 u32 t_avdp_w;
100 u32 t_aavdh; /* address hold time */
101 u32 t_oeasu; /* address setup to OE valid */
102 u32 t_aa; /* access time from ADV assertion */
103 u32 t_iaa; /* initial access time */
104 u32 t_oe; /* access time from OE assertion */
105 u32 t_ce; /* access time from CS asertion */
106 u32 t_rd_cycle; /* read cycle time */
107 u32 t_cez_r; /* read CS deassertion to high Z */
108 u32 t_cez_w; /* write CS deassertion to high Z */
109 u32 t_oez; /* OE deassertion to high Z */
110 u32 t_weasu; /* address setup to WE valid */
111 u32 t_wpl; /* write assertion time */
112 u32 t_wph; /* write deassertion time */
113 u32 t_wr_cycle; /* write cycle time */
114
115 u32 clk;
116 u32 t_bacc; /* burst access valid clock to output delay */
117 u32 t_ces; /* CS setup time to clk */
118 u32 t_avds; /* ADV setup time to clk */
119 u32 t_avdh; /* ADV hold time from clk */
120 u32 t_ach; /* address hold time from clk */
121 u32 t_rdyo; /* clk to ready valid */
122
123 u32 t_ce_rdyz; /* XXX: description ?, or use t_cez instead */
124 u32 t_ce_avd; /* CS on to ADV on delay */
125
126 /* XXX: check the possibility of combining
127 * cyc_aavhd_oe & cyc_aavdh_we
128 */
129 u8 cyc_aavdh_oe;/* read address hold time in cycles */
130 u8 cyc_aavdh_we;/* write address hold time in cycles */
131 u8 cyc_oe; /* access time from OE assertion in cycles */
132 u8 cyc_wpl; /* write deassertion time in cycles */
133 u32 cyc_iaa; /* initial access time in cycles */
134
135 /* extra delays */
136 bool ce_xdelay;
137 bool avd_xdelay;
138 bool oe_xdelay;
139 bool we_xdelay;
140};
141 27
142struct gpmc_settings { 28#if IS_ENABLED(CONFIG_OMAP_GPMC)
143 bool burst_wrap; /* enables wrap bursting */ 29struct gpmc_nand_ops *gpmc_omap_get_nand_ops(struct gpmc_nand_regs *regs,
144 bool burst_read; /* enables read page/burst mode */ 30 int cs);
145 bool burst_write; /* enables write page/burst mode */ 31#else
146 bool device_nand; /* device is NAND */ 32static inline gpmc_nand_ops *gpmc_omap_get_nand_ops(struct gpmc_nand_regs *regs,
147 bool sync_read; /* enables synchronous reads */ 33 int cs)
148 bool sync_write; /* enables synchronous writes */ 34{
149 bool wait_on_read; /* monitor wait on reads */ 35 return NULL;
150 bool wait_on_write; /* monitor wait on writes */ 36}
151 u32 burst_len; /* page/burst length */ 37#endif /* CONFIG_OMAP_GPMC */
152 u32 device_width; /* device bus width (8 or 16 bit) */ 38
153 u32 mux_add_data; /* multiplex address & data */ 39/*--------------------------------*/
154 u32 wait_pin; /* wait-pin to be used */ 40
155}; 41/* deprecated APIs */
42#if IS_ENABLED(CONFIG_OMAP_GPMC)
43void gpmc_update_nand_reg(struct gpmc_nand_regs *reg, int cs);
44#else
45static inline void gpmc_update_nand_reg(struct gpmc_nand_regs *reg, int cs)
46{
47}
48#endif /* CONFIG_OMAP_GPMC */
49/*--------------------------------*/
156 50
157extern int gpmc_calc_timings(struct gpmc_timings *gpmc_t, 51extern int gpmc_calc_timings(struct gpmc_timings *gpmc_t,
158 struct gpmc_settings *gpmc_s, 52 struct gpmc_settings *gpmc_s,
159 struct gpmc_device_timings *dev_t); 53 struct gpmc_device_timings *dev_t);
160 54
161struct gpmc_nand_regs;
162struct device_node; 55struct device_node;
163 56
164extern void gpmc_update_nand_reg(struct gpmc_nand_regs *reg, int cs);
165extern int gpmc_get_client_irq(unsigned irq_config); 57extern int gpmc_get_client_irq(unsigned irq_config);
166 58
167extern unsigned int gpmc_ticks_to_ns(unsigned int ticks); 59extern unsigned int gpmc_ticks_to_ns(unsigned int ticks);
diff --git a/include/linux/platform_data/gpmc-omap.h b/include/linux/platform_data/gpmc-omap.h
new file mode 100644
index 000000000000..67ccdb0e1606
--- /dev/null
+++ b/include/linux/platform_data/gpmc-omap.h
@@ -0,0 +1,172 @@
1/*
2 * OMAP GPMC Platform data
3 *
4 * Copyright (C) 2014 Texas Instruments, Inc. - http://www.ti.com
5 * Roger Quadros <rogerq@ti.com>
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms and conditions of the GNU General Public License,
9 * version 2, as published by the Free Software Foundation.
10 */
11
12#ifndef _GPMC_OMAP_H_
13#define _GPMC_OMAP_H_
14
15/* Maximum Number of Chip Selects */
16#define GPMC_CS_NUM 8
17
18/* bool type time settings */
19struct gpmc_bool_timings {
20 bool cycle2cyclediffcsen;
21 bool cycle2cyclesamecsen;
22 bool we_extra_delay;
23 bool oe_extra_delay;
24 bool adv_extra_delay;
25 bool cs_extra_delay;
26 bool time_para_granularity;
27};
28
29/*
30 * Note that all values in this struct are in nanoseconds except sync_clk
31 * (which is in picoseconds), while the register values are in gpmc_fck cycles.
32 */
33struct gpmc_timings {
34 /* Minimum clock period for synchronous mode (in picoseconds) */
35 u32 sync_clk;
36
37 /* Chip-select signal timings corresponding to GPMC_CS_CONFIG2 */
38 u32 cs_on; /* Assertion time */
39 u32 cs_rd_off; /* Read deassertion time */
40 u32 cs_wr_off; /* Write deassertion time */
41
42 /* ADV signal timings corresponding to GPMC_CONFIG3 */
43 u32 adv_on; /* Assertion time */
44 u32 adv_rd_off; /* Read deassertion time */
45 u32 adv_wr_off; /* Write deassertion time */
46 u32 adv_aad_mux_on; /* ADV assertion time for AAD */
47 u32 adv_aad_mux_rd_off; /* ADV read deassertion time for AAD */
48 u32 adv_aad_mux_wr_off; /* ADV write deassertion time for AAD */
49
50 /* WE signals timings corresponding to GPMC_CONFIG4 */
51 u32 we_on; /* WE assertion time */
52 u32 we_off; /* WE deassertion time */
53
54 /* OE signals timings corresponding to GPMC_CONFIG4 */
55 u32 oe_on; /* OE assertion time */
56 u32 oe_off; /* OE deassertion time */
57 u32 oe_aad_mux_on; /* OE assertion time for AAD */
58 u32 oe_aad_mux_off; /* OE deassertion time for AAD */
59
60 /* Access time and cycle time timings corresponding to GPMC_CONFIG5 */
61 u32 page_burst_access; /* Multiple access word delay */
62 u32 access; /* Start-cycle to first data valid delay */
63 u32 rd_cycle; /* Total read cycle time */
64 u32 wr_cycle; /* Total write cycle time */
65
66 u32 bus_turnaround;
67 u32 cycle2cycle_delay;
68
69 u32 wait_monitoring;
70 u32 clk_activation;
71
72 /* The following are only on OMAP3430 */
73 u32 wr_access; /* WRACCESSTIME */
74 u32 wr_data_mux_bus; /* WRDATAONADMUXBUS */
75
76 struct gpmc_bool_timings bool_timings;
77};
78
79/* Device timings in picoseconds */
80struct gpmc_device_timings {
81 u32 t_ceasu; /* address setup to CS valid */
82 u32 t_avdasu; /* address setup to ADV valid */
83 /* XXX: try to combine t_avdp_r & t_avdp_w. Issue is
84 * of tusb using these timings even for sync whilst
85 * ideally for adv_rd/(wr)_off it should have considered
86 * t_avdh instead. This indirectly necessitates r/w
87 * variations of t_avdp as it is possible to have one
88 * sync & other async
89 */
90 u32 t_avdp_r; /* ADV low time (what about t_cer ?) */
91 u32 t_avdp_w;
92 u32 t_aavdh; /* address hold time */
93 u32 t_oeasu; /* address setup to OE valid */
94 u32 t_aa; /* access time from ADV assertion */
95 u32 t_iaa; /* initial access time */
96 u32 t_oe; /* access time from OE assertion */
97 u32 t_ce; /* access time from CS asertion */
98 u32 t_rd_cycle; /* read cycle time */
99 u32 t_cez_r; /* read CS deassertion to high Z */
100 u32 t_cez_w; /* write CS deassertion to high Z */
101 u32 t_oez; /* OE deassertion to high Z */
102 u32 t_weasu; /* address setup to WE valid */
103 u32 t_wpl; /* write assertion time */
104 u32 t_wph; /* write deassertion time */
105 u32 t_wr_cycle; /* write cycle time */
106
107 u32 clk;
108 u32 t_bacc; /* burst access valid clock to output delay */
109 u32 t_ces; /* CS setup time to clk */
110 u32 t_avds; /* ADV setup time to clk */
111 u32 t_avdh; /* ADV hold time from clk */
112 u32 t_ach; /* address hold time from clk */
113 u32 t_rdyo; /* clk to ready valid */
114
115 u32 t_ce_rdyz; /* XXX: description ?, or use t_cez instead */
116 u32 t_ce_avd; /* CS on to ADV on delay */
117
118 /* XXX: check the possibility of combining
119 * cyc_aavhd_oe & cyc_aavdh_we
120 */
121 u8 cyc_aavdh_oe;/* read address hold time in cycles */
122 u8 cyc_aavdh_we;/* write address hold time in cycles */
123 u8 cyc_oe; /* access time from OE assertion in cycles */
124 u8 cyc_wpl; /* write deassertion time in cycles */
125 u32 cyc_iaa; /* initial access time in cycles */
126
127 /* extra delays */
128 bool ce_xdelay;
129 bool avd_xdelay;
130 bool oe_xdelay;
131 bool we_xdelay;
132};
133
134#define GPMC_BURST_4 4 /* 4 word burst */
135#define GPMC_BURST_8 8 /* 8 word burst */
136#define GPMC_BURST_16 16 /* 16 word burst */
137#define GPMC_DEVWIDTH_8BIT 1 /* 8-bit device width */
138#define GPMC_DEVWIDTH_16BIT 2 /* 16-bit device width */
139#define GPMC_MUX_AAD 1 /* Addr-Addr-Data multiplex */
140#define GPMC_MUX_AD 2 /* Addr-Data multiplex */
141
142struct gpmc_settings {
143 bool burst_wrap; /* enables wrap bursting */
144 bool burst_read; /* enables read page/burst mode */
145 bool burst_write; /* enables write page/burst mode */
146 bool device_nand; /* device is NAND */
147 bool sync_read; /* enables synchronous reads */
148 bool sync_write; /* enables synchronous writes */
149 bool wait_on_read; /* monitor wait on reads */
150 bool wait_on_write; /* monitor wait on writes */
151 u32 burst_len; /* page/burst length */
152 u32 device_width; /* device bus width (8 or 16 bit) */
153 u32 mux_add_data; /* multiplex address & data */
154 u32 wait_pin; /* wait-pin to be used */
155};
156
157/* Data for each chip select */
158struct gpmc_omap_cs_data {
159 bool valid; /* data is valid */
160 bool is_nand; /* device within this CS is NAND */
161 struct gpmc_settings *settings;
162 struct gpmc_device_timings *device_timings;
163 struct gpmc_timings *gpmc_timings;
164 struct platform_device *pdev; /* device within this CS region */
165 unsigned int pdata_size;
166};
167
168struct gpmc_omap_platform_data {
169 struct gpmc_omap_cs_data cs[GPMC_CS_NUM];
170};
171
172#endif /* _GPMC_OMAP_H */
diff --git a/include/linux/platform_data/mtd-nand-omap2.h b/include/linux/platform_data/mtd-nand-omap2.h
index 090bbab0130a..17d57a18bac5 100644
--- a/include/linux/platform_data/mtd-nand-omap2.h
+++ b/include/linux/platform_data/mtd-nand-omap2.h
@@ -45,7 +45,6 @@ enum omap_ecc {
45}; 45};
46 46
47struct gpmc_nand_regs { 47struct gpmc_nand_regs {
48 void __iomem *gpmc_status;
49 void __iomem *gpmc_nand_command; 48 void __iomem *gpmc_nand_command;
50 void __iomem *gpmc_nand_address; 49 void __iomem *gpmc_nand_address;
51 void __iomem *gpmc_nand_data; 50 void __iomem *gpmc_nand_data;
@@ -64,21 +63,24 @@ struct gpmc_nand_regs {
64 void __iomem *gpmc_bch_result4[GPMC_BCH_NUM_REMAINDER]; 63 void __iomem *gpmc_bch_result4[GPMC_BCH_NUM_REMAINDER];
65 void __iomem *gpmc_bch_result5[GPMC_BCH_NUM_REMAINDER]; 64 void __iomem *gpmc_bch_result5[GPMC_BCH_NUM_REMAINDER];
66 void __iomem *gpmc_bch_result6[GPMC_BCH_NUM_REMAINDER]; 65 void __iomem *gpmc_bch_result6[GPMC_BCH_NUM_REMAINDER];
66 /* Deprecated. Do not use */
67 void __iomem *gpmc_status;
67}; 68};
68 69
69struct omap_nand_platform_data { 70struct omap_nand_platform_data {
70 int cs; 71 int cs;
71 struct mtd_partition *parts; 72 struct mtd_partition *parts;
72 int nr_parts; 73 int nr_parts;
73 bool dev_ready;
74 bool flash_bbt; 74 bool flash_bbt;
75 enum nand_io xfer_type; 75 enum nand_io xfer_type;
76 int devsize; 76 int devsize;
77 enum omap_ecc ecc_opt; 77 enum omap_ecc ecc_opt;
78 struct gpmc_nand_regs reg;
79 78
80 /* for passing the partitions */
81 struct device_node *of_node;
82 struct device_node *elm_of_node; 79 struct device_node *elm_of_node;
80
81 /* deprecated */
82 struct gpmc_nand_regs reg;
83 struct device_node *of_node;
84 bool dev_ready;
83}; 85};
84#endif 86#endif
diff --git a/include/uapi/mtd/mtd-abi.h b/include/uapi/mtd/mtd-abi.h
index 763bb6950402..0ec1da2ef652 100644
--- a/include/uapi/mtd/mtd-abi.h
+++ b/include/uapi/mtd/mtd-abi.h
@@ -228,7 +228,7 @@ struct nand_oobfree {
228 * complete set of ECC information. The ioctl truncates the larger internal 228 * complete set of ECC information. The ioctl truncates the larger internal
229 * structure to retain binary compatibility with the static declaration of the 229 * structure to retain binary compatibility with the static declaration of the
230 * ioctl. Note that the "MTD_MAX_..._ENTRIES" macros represent the max size of 230 * ioctl. Note that the "MTD_MAX_..._ENTRIES" macros represent the max size of
231 * the user struct, not the MAX size of the internal struct nand_ecclayout. 231 * the user struct, not the MAX size of the internal OOB layout representation.
232 */ 232 */
233struct nand_ecclayout_user { 233struct nand_ecclayout_user {
234 __u32 eccbytes; 234 __u32 eccbytes;