1
2
3
4
5
6
7
8 #ifndef __DRIVERS_MTD_NAND_GPMI_NAND_H
9 #define __DRIVERS_MTD_NAND_GPMI_NAND_H
10
11 #include <linux/mtd/rawnand.h>
12 #include <linux/platform_device.h>
13 #include <linux/dma-mapping.h>
14 #include <linux/dmaengine.h>
15
16 #define GPMI_CLK_MAX 5
17 struct resources {
18 void __iomem *gpmi_regs;
19 void __iomem *bch_regs;
20 unsigned int dma_low_channel;
21 unsigned int dma_high_channel;
22 struct clk *clock[GPMI_CLK_MAX];
23 };
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46 struct bch_geometry {
47 unsigned int gf_len;
48 unsigned int ecc_strength;
49 unsigned int page_size;
50 unsigned int metadata_size;
51 unsigned int ecc_chunk_size;
52 unsigned int ecc_chunk_count;
53 unsigned int payload_size;
54 unsigned int auxiliary_size;
55 unsigned int auxiliary_status_offset;
56 unsigned int block_mark_byte_offset;
57 unsigned int block_mark_bit_offset;
58 };
59
60
61
62
63
64
65
66 struct boot_rom_geometry {
67 unsigned int stride_size_in_pages;
68 unsigned int search_area_stride_exponent;
69 };
70
71 enum gpmi_type {
72 IS_MX23,
73 IS_MX28,
74 IS_MX6Q,
75 IS_MX6SX,
76 IS_MX7D,
77 };
78
79 struct gpmi_devdata {
80 enum gpmi_type type;
81 int bch_max_ecc_strength;
82 int max_chain_delay;
83 const char * const *clks;
84 const int clks_count;
85 };
86
87
88
89
90
91
92
93
94
95
96
97
98 struct gpmi_nfc_hardware_timing {
99 bool must_apply_timings;
100 unsigned long int clk_rate;
101 u32 timing0;
102 u32 timing1;
103 u32 ctrl1n;
104 };
105
106 #define GPMI_MAX_TRANSFERS 8
107
108 struct gpmi_transfer {
109 u8 cmdbuf[8];
110 struct scatterlist sgl;
111 enum dma_data_direction direction;
112 };
113
114 struct gpmi_nand_data {
115
116 const struct gpmi_devdata *devdata;
117
118
119 struct device *dev;
120 struct platform_device *pdev;
121
122
123 struct resources resources;
124
125
126 struct gpmi_nfc_hardware_timing hw;
127
128
129 struct bch_geometry bch_geometry;
130 struct completion bch_done;
131
132
133 bool swap_block_mark;
134 struct boot_rom_geometry rom_geometry;
135
136
137 struct nand_controller base;
138 struct nand_chip nand;
139
140 struct gpmi_transfer transfers[GPMI_MAX_TRANSFERS];
141 int ntransfers;
142
143 bool bch;
144 uint32_t bch_flashlayout0;
145 uint32_t bch_flashlayout1;
146
147 char *data_buffer_dma;
148
149 void *auxiliary_virt;
150 dma_addr_t auxiliary_phys;
151
152 void *raw_buffer;
153
154
155 #define DMA_CHANS 8
156 struct dma_chan *dma_chans[DMA_CHANS];
157 struct completion dma_done;
158 };
159
160
161 #define STATUS_GOOD 0x00
162 #define STATUS_ERASED 0xff
163 #define STATUS_UNCORRECTABLE 0xfe
164
165
166 #define GPMI_IS_MX23(x) ((x)->devdata->type == IS_MX23)
167 #define GPMI_IS_MX28(x) ((x)->devdata->type == IS_MX28)
168 #define GPMI_IS_MX6Q(x) ((x)->devdata->type == IS_MX6Q)
169 #define GPMI_IS_MX6SX(x) ((x)->devdata->type == IS_MX6SX)
170 #define GPMI_IS_MX7D(x) ((x)->devdata->type == IS_MX7D)
171
172 #define GPMI_IS_MX6(x) (GPMI_IS_MX6Q(x) || GPMI_IS_MX6SX(x) || \
173 GPMI_IS_MX7D(x))
174 #define GPMI_IS_MXS(x) (GPMI_IS_MX23(x) || GPMI_IS_MX28(x))
175 #endif