Commit 68748340c8613877d71b444c0dffe63b536d5a5f
Committed by
Stefano Babic
1 parent
502bdc6b4f
Exists in
smarc_8mq_lf_v2020.04
and in
11 other branches
mtd: nand: mxs_nand: move structs into header file
Move structs into header file so we can use a separate compile unit for device tree support. Signed-off-by: Stefan Agner <stefan.agner@toradex.com>
Showing 2 changed files with 65 additions and 60 deletions Side-by-side Diff
drivers/mtd/nand/mxs_nand.c
... | ... | @@ -13,12 +13,11 @@ |
13 | 13 | */ |
14 | 14 | |
15 | 15 | #include <common.h> |
16 | -#include <linux/mtd/mtd.h> | |
16 | +#include <dm.h> | |
17 | 17 | #include <linux/mtd/rawnand.h> |
18 | 18 | #include <linux/sizes.h> |
19 | 19 | #include <linux/types.h> |
20 | 20 | #include <malloc.h> |
21 | -#include <nand.h> | |
22 | 21 | #include <linux/errno.h> |
23 | 22 | #include <asm/io.h> |
24 | 23 | #include <asm/arch/clock.h> |
... | ... | @@ -26,7 +25,6 @@ |
26 | 25 | #include <asm/mach-imx/regs-bch.h> |
27 | 26 | #include <asm/mach-imx/regs-gpmi.h> |
28 | 27 | #include <asm/arch/sys_proto.h> |
29 | -#include <asm/mach-imx/dma.h> | |
30 | 28 | #include "mxs_nand.h" |
31 | 29 | |
32 | 30 | #define MXS_NAND_DMA_DESCRIPTOR_COUNT 4 |
... | ... | @@ -47,61 +45,6 @@ |
47 | 45 | |
48 | 46 | #define MXS_NAND_BCH_TIMEOUT 10000 |
49 | 47 | |
50 | -/** | |
51 | - * @gf_len: The length of Galois Field. (e.g., 13 or 14) | |
52 | - * @ecc_strength: A number that describes the strength of the ECC | |
53 | - * algorithm. | |
54 | - * @ecc_chunk_size: The size, in bytes, of a single ECC chunk. Note | |
55 | - * the first chunk in the page includes both data and | |
56 | - * metadata, so it's a bit larger than this value. | |
57 | - * @ecc_chunk_count: The number of ECC chunks in the page, | |
58 | - * @block_mark_byte_offset: The byte offset in the ECC-based page view at | |
59 | - * which the underlying physical block mark appears. | |
60 | - * @block_mark_bit_offset: The bit offset into the ECC-based page view at | |
61 | - * which the underlying physical block mark appears. | |
62 | - */ | |
63 | -struct bch_geometry { | |
64 | - unsigned int gf_len; | |
65 | - unsigned int ecc_strength; | |
66 | - unsigned int ecc_chunk_size; | |
67 | - unsigned int ecc_chunk_count; | |
68 | - unsigned int block_mark_byte_offset; | |
69 | - unsigned int block_mark_bit_offset; | |
70 | -}; | |
71 | - | |
72 | -struct mxs_nand_info { | |
73 | - struct nand_chip chip; | |
74 | - unsigned int max_ecc_strength_supported; | |
75 | - bool use_minimum_ecc; | |
76 | - int cur_chip; | |
77 | - | |
78 | - uint32_t cmd_queue_len; | |
79 | - uint32_t data_buf_size; | |
80 | - struct bch_geometry bch_geometry; | |
81 | - | |
82 | - uint8_t *cmd_buf; | |
83 | - uint8_t *data_buf; | |
84 | - uint8_t *oob_buf; | |
85 | - | |
86 | - uint8_t marking_block_bad; | |
87 | - uint8_t raw_oob_mode; | |
88 | - | |
89 | - struct mxs_gpmi_regs *gpmi_regs; | |
90 | - struct mxs_bch_regs *bch_regs; | |
91 | - | |
92 | - /* Functions with altered behaviour */ | |
93 | - int (*hooked_read_oob)(struct mtd_info *mtd, | |
94 | - loff_t from, struct mtd_oob_ops *ops); | |
95 | - int (*hooked_write_oob)(struct mtd_info *mtd, | |
96 | - loff_t to, struct mtd_oob_ops *ops); | |
97 | - int (*hooked_block_markbad)(struct mtd_info *mtd, | |
98 | - loff_t ofs); | |
99 | - | |
100 | - /* DMA descriptors */ | |
101 | - struct mxs_dma_desc **desc; | |
102 | - uint32_t desc_index; | |
103 | -}; | |
104 | - | |
105 | 48 | struct nand_ecclayout fake_ecc_layout; |
106 | 49 | |
107 | 50 | /* |
... | ... | @@ -1233,7 +1176,7 @@ |
1233 | 1176 | return 0; |
1234 | 1177 | } |
1235 | 1178 | |
1236 | -int mxs_nand_init(struct mxs_nand_info *nand_info) | |
1179 | +int mxs_nand_init_ctrl(struct mxs_nand_info *nand_info) | |
1237 | 1180 | { |
1238 | 1181 | struct mtd_info *mtd; |
1239 | 1182 | struct nand_chip *nand; |
... | ... | @@ -1328,7 +1271,7 @@ |
1328 | 1271 | nand_info->use_minimum_ecc = true; |
1329 | 1272 | #endif |
1330 | 1273 | |
1331 | - if (mxs_nand_init(nand_info) < 0) | |
1274 | + if (mxs_nand_init_ctrl(nand_info) < 0) | |
1332 | 1275 | goto err; |
1333 | 1276 | |
1334 | 1277 | return; |
drivers/mtd/nand/mxs_nand.h
... | ... | @@ -7,6 +7,68 @@ |
7 | 7 | * Stefan Agner <stefan.agner@toradex.com> |
8 | 8 | */ |
9 | 9 | |
10 | +#include <linux/mtd/mtd.h> | |
11 | +#include <asm/cache.h> | |
12 | +#include <nand.h> | |
13 | +#include <asm/mach-imx/dma.h> | |
14 | + | |
15 | +/** | |
16 | + * @gf_len: The length of Galois Field. (e.g., 13 or 14) | |
17 | + * @ecc_strength: A number that describes the strength of the ECC | |
18 | + * algorithm. | |
19 | + * @ecc_chunk_size: The size, in bytes, of a single ECC chunk. Note | |
20 | + * the first chunk in the page includes both data and | |
21 | + * metadata, so it's a bit larger than this value. | |
22 | + * @ecc_chunk_count: The number of ECC chunks in the page, | |
23 | + * @block_mark_byte_offset: The byte offset in the ECC-based page view at | |
24 | + * which the underlying physical block mark appears. | |
25 | + * @block_mark_bit_offset: The bit offset into the ECC-based page view at | |
26 | + * which the underlying physical block mark appears. | |
27 | + */ | |
28 | +struct bch_geometry { | |
29 | + unsigned int gf_len; | |
30 | + unsigned int ecc_strength; | |
31 | + unsigned int ecc_chunk_size; | |
32 | + unsigned int ecc_chunk_count; | |
33 | + unsigned int block_mark_byte_offset; | |
34 | + unsigned int block_mark_bit_offset; | |
35 | +}; | |
36 | + | |
37 | +struct mxs_nand_info { | |
38 | + struct nand_chip chip; | |
39 | + struct udevice *dev; | |
40 | + unsigned int max_ecc_strength_supported; | |
41 | + bool use_minimum_ecc; | |
42 | + int cur_chip; | |
43 | + | |
44 | + uint32_t cmd_queue_len; | |
45 | + uint32_t data_buf_size; | |
46 | + struct bch_geometry bch_geometry; | |
47 | + | |
48 | + uint8_t *cmd_buf; | |
49 | + uint8_t *data_buf; | |
50 | + uint8_t *oob_buf; | |
51 | + | |
52 | + uint8_t marking_block_bad; | |
53 | + uint8_t raw_oob_mode; | |
54 | + | |
55 | + struct mxs_gpmi_regs *gpmi_regs; | |
56 | + struct mxs_bch_regs *bch_regs; | |
57 | + | |
58 | + /* Functions with altered behaviour */ | |
59 | + int (*hooked_read_oob)(struct mtd_info *mtd, | |
60 | + loff_t from, struct mtd_oob_ops *ops); | |
61 | + int (*hooked_write_oob)(struct mtd_info *mtd, | |
62 | + loff_t to, struct mtd_oob_ops *ops); | |
63 | + int (*hooked_block_markbad)(struct mtd_info *mtd, | |
64 | + loff_t ofs); | |
65 | + | |
66 | + /* DMA descriptors */ | |
67 | + struct mxs_dma_desc **desc; | |
68 | + uint32_t desc_index; | |
69 | +}; | |
70 | + | |
71 | +int mxs_nand_init_ctrl(struct mxs_nand_info *nand_info); | |
10 | 72 | int mxs_nand_init_spl(struct nand_chip *nand); |
11 | 73 | int mxs_nand_setup_ecc(struct mtd_info *mtd); |