diff options
author | David Woodhouse <dwmw2@infradead.org> | 2006-05-13 13:07:53 -0400 |
---|---|---|
committer | David Woodhouse <dwmw2@infradead.org> | 2006-05-13 13:07:53 -0400 |
commit | e0c7d7675331140e5186d2d1a0efce1d3877d379 (patch) | |
tree | 45247eb5029382c64392aa641e8b0e5506ed152f /drivers/mtd/nand/diskonchip.c | |
parent | 6943f8af7d6583be57d67bba8b2644371f6a10ca (diff) |
[MTD NAND] Indent all of drivers/mtd/nand/*.c.
It was just too painful to deal with.
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
Diffstat (limited to 'drivers/mtd/nand/diskonchip.c')
-rw-r--r-- | drivers/mtd/nand/diskonchip.c | 415 |
1 files changed, 211 insertions, 204 deletions
diff --git a/drivers/mtd/nand/diskonchip.c b/drivers/mtd/nand/diskonchip.c index ec5e45e4e4ef..a2391c66a63f 100644 --- a/drivers/mtd/nand/diskonchip.c +++ b/drivers/mtd/nand/diskonchip.c | |||
@@ -58,10 +58,10 @@ static unsigned long __initdata doc_locations[] = { | |||
58 | 0xe4000000, | 58 | 0xe4000000, |
59 | #elif defined(CONFIG_MOMENCO_OCELOT) | 59 | #elif defined(CONFIG_MOMENCO_OCELOT) |
60 | 0x2f000000, | 60 | 0x2f000000, |
61 | 0xff000000, | 61 | 0xff000000, |
62 | #elif defined(CONFIG_MOMENCO_OCELOT_G) || defined (CONFIG_MOMENCO_OCELOT_C) | 62 | #elif defined(CONFIG_MOMENCO_OCELOT_G) || defined (CONFIG_MOMENCO_OCELOT_C) |
63 | 0xff000000, | 63 | 0xff000000, |
64 | ##else | 64 | #else |
65 | #warning Unknown architecture for DiskOnChip. No default probe locations defined | 65 | #warning Unknown architecture for DiskOnChip. No default probe locations defined |
66 | #endif | 66 | #endif |
67 | 0xffffffff }; | 67 | 0xffffffff }; |
@@ -73,7 +73,7 @@ struct doc_priv { | |||
73 | unsigned long physadr; | 73 | unsigned long physadr; |
74 | u_char ChipID; | 74 | u_char ChipID; |
75 | u_char CDSNControl; | 75 | u_char CDSNControl; |
76 | int chips_per_floor; /* The number of chips detected on each floor */ | 76 | int chips_per_floor; /* The number of chips detected on each floor */ |
77 | int curfloor; | 77 | int curfloor; |
78 | int curchip; | 78 | int curchip; |
79 | int mh0_page; | 79 | int mh0_page; |
@@ -84,6 +84,7 @@ struct doc_priv { | |||
84 | /* This is the syndrome computed by the HW ecc generator upon reading an empty | 84 | /* This is the syndrome computed by the HW ecc generator upon reading an empty |
85 | page, one with all 0xff for data and stored ecc code. */ | 85 | page, one with all 0xff for data and stored ecc code. */ |
86 | static u_char empty_read_syndrome[6] = { 0x26, 0xff, 0x6d, 0x47, 0x73, 0x7a }; | 86 | static u_char empty_read_syndrome[6] = { 0x26, 0xff, 0x6d, 0x47, 0x73, 0x7a }; |
87 | |||
87 | /* This is the ecc value computed by the HW ecc generator upon writing an empty | 88 | /* This is the ecc value computed by the HW ecc generator upon writing an empty |
88 | page, one with all 0xff for data. */ | 89 | page, one with all 0xff for data. */ |
89 | static u_char empty_write_ecc[6] = { 0x4b, 0x00, 0xe2, 0x0e, 0x93, 0xf7 }; | 90 | static u_char empty_write_ecc[6] = { 0x4b, 0x00, 0xe2, 0x0e, 0x93, 0xf7 }; |
@@ -97,25 +98,25 @@ static u_char empty_write_ecc[6] = { 0x4b, 0x00, 0xe2, 0x0e, 0x93, 0xf7 }; | |||
97 | static void doc200x_hwcontrol(struct mtd_info *mtd, int cmd); | 98 | static void doc200x_hwcontrol(struct mtd_info *mtd, int cmd); |
98 | static void doc200x_select_chip(struct mtd_info *mtd, int chip); | 99 | static void doc200x_select_chip(struct mtd_info *mtd, int chip); |
99 | 100 | ||
100 | static int debug=0; | 101 | static int debug = 0; |
101 | module_param(debug, int, 0); | 102 | module_param(debug, int, 0); |
102 | 103 | ||
103 | static int try_dword=1; | 104 | static int try_dword = 1; |
104 | module_param(try_dword, int, 0); | 105 | module_param(try_dword, int, 0); |
105 | 106 | ||
106 | static int no_ecc_failures=0; | 107 | static int no_ecc_failures = 0; |
107 | module_param(no_ecc_failures, int, 0); | 108 | module_param(no_ecc_failures, int, 0); |
108 | 109 | ||
109 | static int no_autopart=0; | 110 | static int no_autopart = 0; |
110 | module_param(no_autopart, int, 0); | 111 | module_param(no_autopart, int, 0); |
111 | 112 | ||
112 | static int show_firmware_partition=0; | 113 | static int show_firmware_partition = 0; |
113 | module_param(show_firmware_partition, int, 0); | 114 | module_param(show_firmware_partition, int, 0); |
114 | 115 | ||
115 | #ifdef MTD_NAND_DISKONCHIP_BBTWRITE | 116 | #ifdef MTD_NAND_DISKONCHIP_BBTWRITE |
116 | static int inftl_bbt_write=1; | 117 | static int inftl_bbt_write = 1; |
117 | #else | 118 | #else |
118 | static int inftl_bbt_write=0; | 119 | static int inftl_bbt_write = 0; |
119 | #endif | 120 | #endif |
120 | module_param(inftl_bbt_write, int, 0); | 121 | module_param(inftl_bbt_write, int, 0); |
121 | 122 | ||
@@ -123,7 +124,6 @@ static unsigned long doc_config_location = CONFIG_MTD_NAND_DISKONCHIP_PROBE_ADDR | |||
123 | module_param(doc_config_location, ulong, 0); | 124 | module_param(doc_config_location, ulong, 0); |
124 | MODULE_PARM_DESC(doc_config_location, "Physical memory address at which to probe for DiskOnChip"); | 125 | MODULE_PARM_DESC(doc_config_location, "Physical memory address at which to probe for DiskOnChip"); |
125 | 126 | ||
126 | |||
127 | /* Sector size for HW ECC */ | 127 | /* Sector size for HW ECC */ |
128 | #define SECTOR_SIZE 512 | 128 | #define SECTOR_SIZE 512 |
129 | /* The sector bytes are packed into NB_DATA 10 bit words */ | 129 | /* The sector bytes are packed into NB_DATA 10 bit words */ |
@@ -147,7 +147,7 @@ static struct rs_control *rs_decoder; | |||
147 | * some comments, improved a minor bit and converted it to make use | 147 | * some comments, improved a minor bit and converted it to make use |
148 | * of the generic Reed-Solomon libary. tglx | 148 | * of the generic Reed-Solomon libary. tglx |
149 | */ | 149 | */ |
150 | static int doc_ecc_decode (struct rs_control *rs, uint8_t *data, uint8_t *ecc) | 150 | static int doc_ecc_decode(struct rs_control *rs, uint8_t *data, uint8_t *ecc) |
151 | { | 151 | { |
152 | int i, j, nerr, errpos[8]; | 152 | int i, j, nerr, errpos[8]; |
153 | uint8_t parity; | 153 | uint8_t parity; |
@@ -168,18 +168,18 @@ static int doc_ecc_decode (struct rs_control *rs, uint8_t *data, uint8_t *ecc) | |||
168 | * s[i] = ds[3]x^3 + ds[2]x^2 + ds[1]x^1 + ds[0] | 168 | * s[i] = ds[3]x^3 + ds[2]x^2 + ds[1]x^1 + ds[0] |
169 | * where x = alpha^(FCR + i) | 169 | * where x = alpha^(FCR + i) |
170 | */ | 170 | */ |
171 | for(j = 1; j < NROOTS; j++) { | 171 | for (j = 1; j < NROOTS; j++) { |
172 | if(ds[j] == 0) | 172 | if (ds[j] == 0) |
173 | continue; | 173 | continue; |
174 | tmp = rs->index_of[ds[j]]; | 174 | tmp = rs->index_of[ds[j]]; |
175 | for(i = 0; i < NROOTS; i++) | 175 | for (i = 0; i < NROOTS; i++) |
176 | s[i] ^= rs->alpha_to[rs_modnn(rs, tmp + (FCR + i) * j)]; | 176 | s[i] ^= rs->alpha_to[rs_modnn(rs, tmp + (FCR + i) * j)]; |
177 | } | 177 | } |
178 | 178 | ||
179 | /* Calc s[i] = s[i] / alpha^(v + i) */ | 179 | /* Calc s[i] = s[i] / alpha^(v + i) */ |
180 | for (i = 0; i < NROOTS; i++) { | 180 | for (i = 0; i < NROOTS; i++) { |
181 | if (syn[i]) | 181 | if (syn[i]) |
182 | syn[i] = rs_modnn(rs, rs->index_of[s[i]] + (NN - FCR - i)); | 182 | syn[i] = rs_modnn(rs, rs->index_of[s[i]] + (NN - FCR - i)); |
183 | } | 183 | } |
184 | /* Call the decoder library */ | 184 | /* Call the decoder library */ |
185 | nerr = decode_rs16(rs, NULL, NULL, 1019, syn, 0, errpos, 0, errval); | 185 | nerr = decode_rs16(rs, NULL, NULL, 1019, syn, 0, errpos, 0, errval); |
@@ -193,7 +193,7 @@ static int doc_ecc_decode (struct rs_control *rs, uint8_t *data, uint8_t *ecc) | |||
193 | * but they are given by the design of the de/encoder circuit | 193 | * but they are given by the design of the de/encoder circuit |
194 | * in the DoC ASIC's. | 194 | * in the DoC ASIC's. |
195 | */ | 195 | */ |
196 | for(i = 0;i < nerr; i++) { | 196 | for (i = 0; i < nerr; i++) { |
197 | int index, bitpos, pos = 1015 - errpos[i]; | 197 | int index, bitpos, pos = 1015 - errpos[i]; |
198 | uint8_t val; | 198 | uint8_t val; |
199 | if (pos >= NB_DATA && pos < 1019) | 199 | if (pos >= NB_DATA && pos < 1019) |
@@ -205,8 +205,7 @@ static int doc_ecc_decode (struct rs_control *rs, uint8_t *data, uint8_t *ecc) | |||
205 | can be modified since pos is even */ | 205 | can be modified since pos is even */ |
206 | index = (pos >> 3) ^ 1; | 206 | index = (pos >> 3) ^ 1; |
207 | bitpos = pos & 7; | 207 | bitpos = pos & 7; |
208 | if ((index >= 0 && index < SECTOR_SIZE) || | 208 | if ((index >= 0 && index < SECTOR_SIZE) || index == (SECTOR_SIZE + 1)) { |
209 | index == (SECTOR_SIZE + 1)) { | ||
210 | val = (uint8_t) (errval[i] >> (2 + bitpos)); | 209 | val = (uint8_t) (errval[i] >> (2 + bitpos)); |
211 | parity ^= val; | 210 | parity ^= val; |
212 | if (index < SECTOR_SIZE) | 211 | if (index < SECTOR_SIZE) |
@@ -216,9 +215,8 @@ static int doc_ecc_decode (struct rs_control *rs, uint8_t *data, uint8_t *ecc) | |||
216 | bitpos = (bitpos + 10) & 7; | 215 | bitpos = (bitpos + 10) & 7; |
217 | if (bitpos == 0) | 216 | if (bitpos == 0) |
218 | bitpos = 8; | 217 | bitpos = 8; |
219 | if ((index >= 0 && index < SECTOR_SIZE) || | 218 | if ((index >= 0 && index < SECTOR_SIZE) || index == (SECTOR_SIZE + 1)) { |
220 | index == (SECTOR_SIZE + 1)) { | 219 | val = (uint8_t) (errval[i] << (8 - bitpos)); |
221 | val = (uint8_t)(errval[i] << (8 - bitpos)); | ||
222 | parity ^= val; | 220 | parity ^= val; |
223 | if (index < SECTOR_SIZE) | 221 | if (index < SECTOR_SIZE) |
224 | data[index] ^= val; | 222 | data[index] ^= val; |
@@ -250,10 +248,11 @@ static void DoC_Delay(struct doc_priv *doc, unsigned short cycles) | |||
250 | /* DOC_WaitReady: Wait for RDY line to be asserted by the flash chip */ | 248 | /* DOC_WaitReady: Wait for RDY line to be asserted by the flash chip */ |
251 | static int _DoC_WaitReady(struct doc_priv *doc) | 249 | static int _DoC_WaitReady(struct doc_priv *doc) |
252 | { | 250 | { |
253 | void __iomem *docptr = doc->virtadr; | 251 | void __iomem *docptr = doc->virtadr; |
254 | unsigned long timeo = jiffies + (HZ * 10); | 252 | unsigned long timeo = jiffies + (HZ * 10); |
255 | 253 | ||
256 | if(debug) printk("_DoC_WaitReady...\n"); | 254 | if (debug) |
255 | printk("_DoC_WaitReady...\n"); | ||
257 | /* Out-of-line routine to wait for chip response */ | 256 | /* Out-of-line routine to wait for chip response */ |
258 | if (DoC_is_MillenniumPlus(doc)) { | 257 | if (DoC_is_MillenniumPlus(doc)) { |
259 | while ((ReadDOC(docptr, Mplus_FlashControl) & CDSN_CTRL_FR_B_MASK) != CDSN_CTRL_FR_B_MASK) { | 258 | while ((ReadDOC(docptr, Mplus_FlashControl) & CDSN_CTRL_FR_B_MASK) != CDSN_CTRL_FR_B_MASK) { |
@@ -280,7 +279,7 @@ static int _DoC_WaitReady(struct doc_priv *doc) | |||
280 | 279 | ||
281 | static inline int DoC_WaitReady(struct doc_priv *doc) | 280 | static inline int DoC_WaitReady(struct doc_priv *doc) |
282 | { | 281 | { |
283 | void __iomem *docptr = doc->virtadr; | 282 | void __iomem *docptr = doc->virtadr; |
284 | int ret = 0; | 283 | int ret = 0; |
285 | 284 | ||
286 | if (DoC_is_MillenniumPlus(doc)) { | 285 | if (DoC_is_MillenniumPlus(doc)) { |
@@ -298,7 +297,8 @@ static inline int DoC_WaitReady(struct doc_priv *doc) | |||
298 | DoC_Delay(doc, 2); | 297 | DoC_Delay(doc, 2); |
299 | } | 298 | } |
300 | 299 | ||
301 | if(debug) printk("DoC_WaitReady OK\n"); | 300 | if (debug) |
301 | printk("DoC_WaitReady OK\n"); | ||
302 | return ret; | 302 | return ret; |
303 | } | 303 | } |
304 | 304 | ||
@@ -306,9 +306,10 @@ static void doc2000_write_byte(struct mtd_info *mtd, u_char datum) | |||
306 | { | 306 | { |
307 | struct nand_chip *this = mtd->priv; | 307 | struct nand_chip *this = mtd->priv; |
308 | struct doc_priv *doc = this->priv; | 308 | struct doc_priv *doc = this->priv; |
309 | void __iomem *docptr = doc->virtadr; | 309 | void __iomem *docptr = doc->virtadr; |
310 | 310 | ||
311 | if(debug)printk("write_byte %02x\n", datum); | 311 | if (debug) |
312 | printk("write_byte %02x\n", datum); | ||
312 | WriteDOC(datum, docptr, CDSNSlowIO); | 313 | WriteDOC(datum, docptr, CDSNSlowIO); |
313 | WriteDOC(datum, docptr, 2k_CDSN_IO); | 314 | WriteDOC(datum, docptr, 2k_CDSN_IO); |
314 | } | 315 | } |
@@ -317,77 +318,78 @@ static u_char doc2000_read_byte(struct mtd_info *mtd) | |||
317 | { | 318 | { |
318 | struct nand_chip *this = mtd->priv; | 319 | struct nand_chip *this = mtd->priv; |
319 | struct doc_priv *doc = this->priv; | 320 | struct doc_priv *doc = this->priv; |
320 | void __iomem *docptr = doc->virtadr; | 321 | void __iomem *docptr = doc->virtadr; |
321 | u_char ret; | 322 | u_char ret; |
322 | 323 | ||
323 | ReadDOC(docptr, CDSNSlowIO); | 324 | ReadDOC(docptr, CDSNSlowIO); |
324 | DoC_Delay(doc, 2); | 325 | DoC_Delay(doc, 2); |
325 | ret = ReadDOC(docptr, 2k_CDSN_IO); | 326 | ret = ReadDOC(docptr, 2k_CDSN_IO); |
326 | if (debug) printk("read_byte returns %02x\n", ret); | 327 | if (debug) |
328 | printk("read_byte returns %02x\n", ret); | ||
327 | return ret; | 329 | return ret; |
328 | } | 330 | } |
329 | 331 | ||
330 | static void doc2000_writebuf(struct mtd_info *mtd, | 332 | static void doc2000_writebuf(struct mtd_info *mtd, const u_char *buf, int len) |
331 | const u_char *buf, int len) | ||
332 | { | 333 | { |
333 | struct nand_chip *this = mtd->priv; | 334 | struct nand_chip *this = mtd->priv; |
334 | struct doc_priv *doc = this->priv; | 335 | struct doc_priv *doc = this->priv; |
335 | void __iomem *docptr = doc->virtadr; | 336 | void __iomem *docptr = doc->virtadr; |
336 | int i; | 337 | int i; |
337 | if (debug)printk("writebuf of %d bytes: ", len); | 338 | if (debug) |
338 | for (i=0; i < len; i++) { | 339 | printk("writebuf of %d bytes: ", len); |
340 | for (i = 0; i < len; i++) { | ||
339 | WriteDOC_(buf[i], docptr, DoC_2k_CDSN_IO + i); | 341 | WriteDOC_(buf[i], docptr, DoC_2k_CDSN_IO + i); |
340 | if (debug && i < 16) | 342 | if (debug && i < 16) |
341 | printk("%02x ", buf[i]); | 343 | printk("%02x ", buf[i]); |
342 | } | 344 | } |
343 | if (debug) printk("\n"); | 345 | if (debug) |
346 | printk("\n"); | ||
344 | } | 347 | } |
345 | 348 | ||
346 | static void doc2000_readbuf(struct mtd_info *mtd, | 349 | static void doc2000_readbuf(struct mtd_info *mtd, u_char *buf, int len) |
347 | u_char *buf, int len) | ||
348 | { | 350 | { |
349 | struct nand_chip *this = mtd->priv; | 351 | struct nand_chip *this = mtd->priv; |
350 | struct doc_priv *doc = this->priv; | 352 | struct doc_priv *doc = this->priv; |
351 | void __iomem *docptr = doc->virtadr; | 353 | void __iomem *docptr = doc->virtadr; |
352 | int i; | 354 | int i; |
353 | 355 | ||
354 | if (debug)printk("readbuf of %d bytes: ", len); | 356 | if (debug) |
357 | printk("readbuf of %d bytes: ", len); | ||
355 | 358 | ||
356 | for (i=0; i < len; i++) { | 359 | for (i = 0; i < len; i++) { |
357 | buf[i] = ReadDOC(docptr, 2k_CDSN_IO + i); | 360 | buf[i] = ReadDOC(docptr, 2k_CDSN_IO + i); |
358 | } | 361 | } |
359 | } | 362 | } |
360 | 363 | ||
361 | static void doc2000_readbuf_dword(struct mtd_info *mtd, | 364 | static void doc2000_readbuf_dword(struct mtd_info *mtd, u_char *buf, int len) |
362 | u_char *buf, int len) | ||
363 | { | 365 | { |
364 | struct nand_chip *this = mtd->priv; | 366 | struct nand_chip *this = mtd->priv; |
365 | struct doc_priv *doc = this->priv; | 367 | struct doc_priv *doc = this->priv; |
366 | void __iomem *docptr = doc->virtadr; | 368 | void __iomem *docptr = doc->virtadr; |
367 | int i; | 369 | int i; |
368 | 370 | ||
369 | if (debug) printk("readbuf_dword of %d bytes: ", len); | 371 | if (debug) |
372 | printk("readbuf_dword of %d bytes: ", len); | ||
370 | 373 | ||
371 | if (unlikely((((unsigned long)buf)|len) & 3)) { | 374 | if (unlikely((((unsigned long)buf) | len) & 3)) { |
372 | for (i=0; i < len; i++) { | 375 | for (i = 0; i < len; i++) { |
373 | *(uint8_t *)(&buf[i]) = ReadDOC(docptr, 2k_CDSN_IO + i); | 376 | *(uint8_t *) (&buf[i]) = ReadDOC(docptr, 2k_CDSN_IO + i); |
374 | } | 377 | } |
375 | } else { | 378 | } else { |
376 | for (i=0; i < len; i+=4) { | 379 | for (i = 0; i < len; i += 4) { |
377 | *(uint32_t*)(&buf[i]) = readl(docptr + DoC_2k_CDSN_IO + i); | 380 | *(uint32_t *) (&buf[i]) = readl(docptr + DoC_2k_CDSN_IO + i); |
378 | } | 381 | } |
379 | } | 382 | } |
380 | } | 383 | } |
381 | 384 | ||
382 | static int doc2000_verifybuf(struct mtd_info *mtd, | 385 | static int doc2000_verifybuf(struct mtd_info *mtd, const u_char *buf, int len) |
383 | const u_char *buf, int len) | ||
384 | { | 386 | { |
385 | struct nand_chip *this = mtd->priv; | 387 | struct nand_chip *this = mtd->priv; |
386 | struct doc_priv *doc = this->priv; | 388 | struct doc_priv *doc = this->priv; |
387 | void __iomem *docptr = doc->virtadr; | 389 | void __iomem *docptr = doc->virtadr; |
388 | int i; | 390 | int i; |
389 | 391 | ||
390 | for (i=0; i < len; i++) | 392 | for (i = 0; i < len; i++) |
391 | if (buf[i] != ReadDOC(docptr, 2k_CDSN_IO)) | 393 | if (buf[i] != ReadDOC(docptr, 2k_CDSN_IO)) |
392 | return -EFAULT; | 394 | return -EFAULT; |
393 | return 0; | 395 | return 0; |
@@ -482,7 +484,7 @@ static void doc2001_write_byte(struct mtd_info *mtd, u_char datum) | |||
482 | { | 484 | { |
483 | struct nand_chip *this = mtd->priv; | 485 | struct nand_chip *this = mtd->priv; |
484 | struct doc_priv *doc = this->priv; | 486 | struct doc_priv *doc = this->priv; |
485 | void __iomem *docptr = doc->virtadr; | 487 | void __iomem *docptr = doc->virtadr; |
486 | 488 | ||
487 | WriteDOC(datum, docptr, CDSNSlowIO); | 489 | WriteDOC(datum, docptr, CDSNSlowIO); |
488 | WriteDOC(datum, docptr, Mil_CDSN_IO); | 490 | WriteDOC(datum, docptr, Mil_CDSN_IO); |
@@ -493,7 +495,7 @@ static u_char doc2001_read_byte(struct mtd_info *mtd) | |||
493 | { | 495 | { |
494 | struct nand_chip *this = mtd->priv; | 496 | struct nand_chip *this = mtd->priv; |
495 | struct doc_priv *doc = this->priv; | 497 | struct doc_priv *doc = this->priv; |
496 | void __iomem *docptr = doc->virtadr; | 498 | void __iomem *docptr = doc->virtadr; |
497 | 499 | ||
498 | //ReadDOC(docptr, CDSNSlowIO); | 500 | //ReadDOC(docptr, CDSNSlowIO); |
499 | /* 11.4.5 -- delay twice to allow extended length cycle */ | 501 | /* 11.4.5 -- delay twice to allow extended length cycle */ |
@@ -503,50 +505,47 @@ static u_char doc2001_read_byte(struct mtd_info *mtd) | |||
503 | return ReadDOC(docptr, LastDataRead); | 505 | return ReadDOC(docptr, LastDataRead); |
504 | } | 506 | } |
505 | 507 | ||
506 | static void doc2001_writebuf(struct mtd_info *mtd, | 508 | static void doc2001_writebuf(struct mtd_info *mtd, const u_char *buf, int len) |
507 | const u_char *buf, int len) | ||
508 | { | 509 | { |
509 | struct nand_chip *this = mtd->priv; | 510 | struct nand_chip *this = mtd->priv; |
510 | struct doc_priv *doc = this->priv; | 511 | struct doc_priv *doc = this->priv; |
511 | void __iomem *docptr = doc->virtadr; | 512 | void __iomem *docptr = doc->virtadr; |
512 | int i; | 513 | int i; |
513 | 514 | ||
514 | for (i=0; i < len; i++) | 515 | for (i = 0; i < len; i++) |
515 | WriteDOC_(buf[i], docptr, DoC_Mil_CDSN_IO + i); | 516 | WriteDOC_(buf[i], docptr, DoC_Mil_CDSN_IO + i); |
516 | /* Terminate write pipeline */ | 517 | /* Terminate write pipeline */ |
517 | WriteDOC(0x00, docptr, WritePipeTerm); | 518 | WriteDOC(0x00, docptr, WritePipeTerm); |
518 | } | 519 | } |
519 | 520 | ||
520 | static void doc2001_readbuf(struct mtd_info *mtd, | 521 | static void doc2001_readbuf(struct mtd_info *mtd, u_char *buf, int len) |
521 | u_char *buf, int len) | ||
522 | { | 522 | { |
523 | struct nand_chip *this = mtd->priv; | 523 | struct nand_chip *this = mtd->priv; |
524 | struct doc_priv *doc = this->priv; | 524 | struct doc_priv *doc = this->priv; |
525 | void __iomem *docptr = doc->virtadr; | 525 | void __iomem *docptr = doc->virtadr; |
526 | int i; | 526 | int i; |
527 | 527 | ||
528 | /* Start read pipeline */ | 528 | /* Start read pipeline */ |
529 | ReadDOC(docptr, ReadPipeInit); | 529 | ReadDOC(docptr, ReadPipeInit); |
530 | 530 | ||
531 | for (i=0; i < len-1; i++) | 531 | for (i = 0; i < len - 1; i++) |
532 | buf[i] = ReadDOC(docptr, Mil_CDSN_IO + (i & 0xff)); | 532 | buf[i] = ReadDOC(docptr, Mil_CDSN_IO + (i & 0xff)); |
533 | 533 | ||
534 | /* Terminate read pipeline */ | 534 | /* Terminate read pipeline */ |
535 | buf[i] = ReadDOC(docptr, LastDataRead); | 535 | buf[i] = ReadDOC(docptr, LastDataRead); |
536 | } | 536 | } |
537 | 537 | ||
538 | static int doc2001_verifybuf(struct mtd_info *mtd, | 538 | static int doc2001_verifybuf(struct mtd_info *mtd, const u_char *buf, int len) |
539 | const u_char *buf, int len) | ||
540 | { | 539 | { |
541 | struct nand_chip *this = mtd->priv; | 540 | struct nand_chip *this = mtd->priv; |
542 | struct doc_priv *doc = this->priv; | 541 | struct doc_priv *doc = this->priv; |
543 | void __iomem *docptr = doc->virtadr; | 542 | void __iomem *docptr = doc->virtadr; |
544 | int i; | 543 | int i; |
545 | 544 | ||
546 | /* Start read pipeline */ | 545 | /* Start read pipeline */ |
547 | ReadDOC(docptr, ReadPipeInit); | 546 | ReadDOC(docptr, ReadPipeInit); |
548 | 547 | ||
549 | for (i=0; i < len-1; i++) | 548 | for (i = 0; i < len - 1; i++) |
550 | if (buf[i] != ReadDOC(docptr, Mil_CDSN_IO)) { | 549 | if (buf[i] != ReadDOC(docptr, Mil_CDSN_IO)) { |
551 | ReadDOC(docptr, LastDataRead); | 550 | ReadDOC(docptr, LastDataRead); |
552 | return i; | 551 | return i; |
@@ -560,87 +559,90 @@ static u_char doc2001plus_read_byte(struct mtd_info *mtd) | |||
560 | { | 559 | { |
561 | struct nand_chip *this = mtd->priv; | 560 | struct nand_chip *this = mtd->priv; |
562 | struct doc_priv *doc = this->priv; | 561 | struct doc_priv *doc = this->priv; |
563 | void __iomem *docptr = doc->virtadr; | 562 | void __iomem *docptr = doc->virtadr; |
564 | u_char ret; | 563 | u_char ret; |
565 | 564 | ||
566 | ReadDOC(docptr, Mplus_ReadPipeInit); | 565 | ReadDOC(docptr, Mplus_ReadPipeInit); |
567 | ReadDOC(docptr, Mplus_ReadPipeInit); | 566 | ReadDOC(docptr, Mplus_ReadPipeInit); |
568 | ret = ReadDOC(docptr, Mplus_LastDataRead); | 567 | ret = ReadDOC(docptr, Mplus_LastDataRead); |
569 | if (debug) printk("read_byte returns %02x\n", ret); | 568 | if (debug) |
569 | printk("read_byte returns %02x\n", ret); | ||
570 | return ret; | 570 | return ret; |
571 | } | 571 | } |
572 | 572 | ||
573 | static void doc2001plus_writebuf(struct mtd_info *mtd, | 573 | static void doc2001plus_writebuf(struct mtd_info *mtd, const u_char *buf, int len) |
574 | const u_char *buf, int len) | ||
575 | { | 574 | { |
576 | struct nand_chip *this = mtd->priv; | 575 | struct nand_chip *this = mtd->priv; |
577 | struct doc_priv *doc = this->priv; | 576 | struct doc_priv *doc = this->priv; |
578 | void __iomem *docptr = doc->virtadr; | 577 | void __iomem *docptr = doc->virtadr; |
579 | int i; | 578 | int i; |
580 | 579 | ||
581 | if (debug)printk("writebuf of %d bytes: ", len); | 580 | if (debug) |
582 | for (i=0; i < len; i++) { | 581 | printk("writebuf of %d bytes: ", len); |
582 | for (i = 0; i < len; i++) { | ||
583 | WriteDOC_(buf[i], docptr, DoC_Mil_CDSN_IO + i); | 583 | WriteDOC_(buf[i], docptr, DoC_Mil_CDSN_IO + i); |
584 | if (debug && i < 16) | 584 | if (debug && i < 16) |
585 | printk("%02x ", buf[i]); | 585 | printk("%02x ", buf[i]); |
586 | } | 586 | } |
587 | if (debug) printk("\n"); | 587 | if (debug) |
588 | printk("\n"); | ||
588 | } | 589 | } |
589 | 590 | ||
590 | static void doc2001plus_readbuf(struct mtd_info *mtd, | 591 | static void doc2001plus_readbuf(struct mtd_info *mtd, u_char *buf, int len) |
591 | u_char *buf, int len) | ||
592 | { | 592 | { |
593 | struct nand_chip *this = mtd->priv; | 593 | struct nand_chip *this = mtd->priv; |
594 | struct doc_priv *doc = this->priv; | 594 | struct doc_priv *doc = this->priv; |
595 | void __iomem *docptr = doc->virtadr; | 595 | void __iomem *docptr = doc->virtadr; |
596 | int i; | 596 | int i; |
597 | 597 | ||
598 | if (debug)printk("readbuf of %d bytes: ", len); | 598 | if (debug) |
599 | printk("readbuf of %d bytes: ", len); | ||
599 | 600 | ||
600 | /* Start read pipeline */ | 601 | /* Start read pipeline */ |
601 | ReadDOC(docptr, Mplus_ReadPipeInit); | 602 | ReadDOC(docptr, Mplus_ReadPipeInit); |
602 | ReadDOC(docptr, Mplus_ReadPipeInit); | 603 | ReadDOC(docptr, Mplus_ReadPipeInit); |
603 | 604 | ||
604 | for (i=0; i < len-2; i++) { | 605 | for (i = 0; i < len - 2; i++) { |
605 | buf[i] = ReadDOC(docptr, Mil_CDSN_IO); | 606 | buf[i] = ReadDOC(docptr, Mil_CDSN_IO); |
606 | if (debug && i < 16) | 607 | if (debug && i < 16) |
607 | printk("%02x ", buf[i]); | 608 | printk("%02x ", buf[i]); |
608 | } | 609 | } |
609 | 610 | ||
610 | /* Terminate read pipeline */ | 611 | /* Terminate read pipeline */ |
611 | buf[len-2] = ReadDOC(docptr, Mplus_LastDataRead); | 612 | buf[len - 2] = ReadDOC(docptr, Mplus_LastDataRead); |
612 | if (debug && i < 16) | 613 | if (debug && i < 16) |
613 | printk("%02x ", buf[len-2]); | 614 | printk("%02x ", buf[len - 2]); |
614 | buf[len-1] = ReadDOC(docptr, Mplus_LastDataRead); | 615 | buf[len - 1] = ReadDOC(docptr, Mplus_LastDataRead); |
615 | if (debug && i < 16) | 616 | if (debug && i < 16) |
616 | printk("%02x ", buf[len-1]); | 617 | printk("%02x ", buf[len - 1]); |
617 | if (debug) printk("\n"); | 618 | if (debug) |
619 | printk("\n"); | ||
618 | } | 620 | } |
619 | 621 | ||
620 | static int doc2001plus_verifybuf(struct mtd_info *mtd, | 622 | static int doc2001plus_verifybuf(struct mtd_info *mtd, const u_char *buf, int len) |
621 | const u_char *buf, int len) | ||
622 | { | 623 | { |
623 | struct nand_chip *this = mtd->priv; | 624 | struct nand_chip *this = mtd->priv; |
624 | struct doc_priv *doc = this->priv; | 625 | struct doc_priv *doc = this->priv; |
625 | void __iomem *docptr = doc->virtadr; | 626 | void __iomem *docptr = doc->virtadr; |
626 | int i; | 627 | int i; |
627 | 628 | ||
628 | if (debug)printk("verifybuf of %d bytes: ", len); | 629 | if (debug) |
630 | printk("verifybuf of %d bytes: ", len); | ||
629 | 631 | ||
630 | /* Start read pipeline */ | 632 | /* Start read pipeline */ |
631 | ReadDOC(docptr, Mplus_ReadPipeInit); | 633 | ReadDOC(docptr, Mplus_ReadPipeInit); |
632 | ReadDOC(docptr, Mplus_ReadPipeInit); | 634 | ReadDOC(docptr, Mplus_ReadPipeInit); |
633 | 635 | ||
634 | for (i=0; i < len-2; i++) | 636 | for (i = 0; i < len - 2; i++) |
635 | if (buf[i] != ReadDOC(docptr, Mil_CDSN_IO)) { | 637 | if (buf[i] != ReadDOC(docptr, Mil_CDSN_IO)) { |
636 | ReadDOC(docptr, Mplus_LastDataRead); | 638 | ReadDOC(docptr, Mplus_LastDataRead); |
637 | ReadDOC(docptr, Mplus_LastDataRead); | 639 | ReadDOC(docptr, Mplus_LastDataRead); |
638 | return i; | 640 | return i; |
639 | } | 641 | } |
640 | if (buf[len-2] != ReadDOC(docptr, Mplus_LastDataRead)) | 642 | if (buf[len - 2] != ReadDOC(docptr, Mplus_LastDataRead)) |
641 | return len-2; | 643 | return len - 2; |
642 | if (buf[len-1] != ReadDOC(docptr, Mplus_LastDataRead)) | 644 | if (buf[len - 1] != ReadDOC(docptr, Mplus_LastDataRead)) |
643 | return len-1; | 645 | return len - 1; |
644 | return 0; | 646 | return 0; |
645 | } | 647 | } |
646 | 648 | ||
@@ -648,10 +650,11 @@ static void doc2001plus_select_chip(struct mtd_info *mtd, int chip) | |||
648 | { | 650 | { |
649 | struct nand_chip *this = mtd->priv; | 651 | struct nand_chip *this = mtd->priv; |
650 | struct doc_priv *doc = this->priv; | 652 | struct doc_priv *doc = this->priv; |
651 | void __iomem *docptr = doc->virtadr; | 653 | void __iomem *docptr = doc->virtadr; |
652 | int floor = 0; | 654 | int floor = 0; |
653 | 655 | ||
654 | if(debug)printk("select chip (%d)\n", chip); | 656 | if (debug) |
657 | printk("select chip (%d)\n", chip); | ||
655 | 658 | ||
656 | if (chip == -1) { | 659 | if (chip == -1) { |
657 | /* Disable flash internally */ | 660 | /* Disable flash internally */ |
@@ -660,7 +663,7 @@ static void doc2001plus_select_chip(struct mtd_info *mtd, int chip) | |||
660 | } | 663 | } |
661 | 664 | ||
662 | floor = chip / doc->chips_per_floor; | 665 | floor = chip / doc->chips_per_floor; |
663 | chip -= (floor * doc->chips_per_floor); | 666 | chip -= (floor * doc->chips_per_floor); |
664 | 667 | ||
665 | /* Assert ChipEnable and deassert WriteProtect */ | 668 | /* Assert ChipEnable and deassert WriteProtect */ |
666 | WriteDOC((DOC_FLASH_CE), docptr, Mplus_FlashSelect); | 669 | WriteDOC((DOC_FLASH_CE), docptr, Mplus_FlashSelect); |
@@ -674,16 +677,17 @@ static void doc200x_select_chip(struct mtd_info *mtd, int chip) | |||
674 | { | 677 | { |
675 | struct nand_chip *this = mtd->priv; | 678 | struct nand_chip *this = mtd->priv; |
676 | struct doc_priv *doc = this->priv; | 679 | struct doc_priv *doc = this->priv; |
677 | void __iomem *docptr = doc->virtadr; | 680 | void __iomem *docptr = doc->virtadr; |
678 | int floor = 0; | 681 | int floor = 0; |
679 | 682 | ||
680 | if(debug)printk("select chip (%d)\n", chip); | 683 | if (debug) |
684 | printk("select chip (%d)\n", chip); | ||
681 | 685 | ||
682 | if (chip == -1) | 686 | if (chip == -1) |
683 | return; | 687 | return; |
684 | 688 | ||
685 | floor = chip / doc->chips_per_floor; | 689 | floor = chip / doc->chips_per_floor; |
686 | chip -= (floor * doc->chips_per_floor); | 690 | chip -= (floor * doc->chips_per_floor); |
687 | 691 | ||
688 | /* 11.4.4 -- deassert CE before changing chip */ | 692 | /* 11.4.4 -- deassert CE before changing chip */ |
689 | doc200x_hwcontrol(mtd, NAND_CTL_CLRNCE); | 693 | doc200x_hwcontrol(mtd, NAND_CTL_CLRNCE); |
@@ -701,9 +705,9 @@ static void doc200x_hwcontrol(struct mtd_info *mtd, int cmd) | |||
701 | { | 705 | { |
702 | struct nand_chip *this = mtd->priv; | 706 | struct nand_chip *this = mtd->priv; |
703 | struct doc_priv *doc = this->priv; | 707 | struct doc_priv *doc = this->priv; |
704 | void __iomem *docptr = doc->virtadr; | 708 | void __iomem *docptr = doc->virtadr; |
705 | 709 | ||
706 | switch(cmd) { | 710 | switch (cmd) { |
707 | case NAND_CTL_SETNCE: | 711 | case NAND_CTL_SETNCE: |
708 | doc->CDSNControl |= CDSN_CTRL_CE; | 712 | doc->CDSNControl |= CDSN_CTRL_CE; |
709 | break; | 713 | break; |
@@ -729,17 +733,18 @@ static void doc200x_hwcontrol(struct mtd_info *mtd, int cmd) | |||
729 | doc->CDSNControl &= ~CDSN_CTRL_WP; | 733 | doc->CDSNControl &= ~CDSN_CTRL_WP; |
730 | break; | 734 | break; |
731 | } | 735 | } |
732 | if (debug)printk("hwcontrol(%d): %02x\n", cmd, doc->CDSNControl); | 736 | if (debug) |
737 | printk("hwcontrol(%d): %02x\n", cmd, doc->CDSNControl); | ||
733 | WriteDOC(doc->CDSNControl, docptr, CDSNControl); | 738 | WriteDOC(doc->CDSNControl, docptr, CDSNControl); |
734 | /* 11.4.3 -- 4 NOPs after CSDNControl write */ | 739 | /* 11.4.3 -- 4 NOPs after CSDNControl write */ |
735 | DoC_Delay(doc, 4); | 740 | DoC_Delay(doc, 4); |
736 | } | 741 | } |
737 | 742 | ||
738 | static void doc2001plus_command (struct mtd_info *mtd, unsigned command, int column, int page_addr) | 743 | static void doc2001plus_command(struct mtd_info *mtd, unsigned command, int column, int page_addr) |
739 | { | 744 | { |
740 | struct nand_chip *this = mtd->priv; | 745 | struct nand_chip *this = mtd->priv; |
741 | struct doc_priv *doc = this->priv; | 746 | struct doc_priv *doc = this->priv; |
742 | void __iomem *docptr = doc->virtadr; | 747 | void __iomem *docptr = doc->virtadr; |
743 | 748 | ||
744 | /* | 749 | /* |
745 | * Must terminate write pipeline before sending any commands | 750 | * Must terminate write pipeline before sending any commands |
@@ -782,25 +787,26 @@ static void doc2001plus_command (struct mtd_info *mtd, unsigned command, int col | |||
782 | WriteDOC(column, docptr, Mplus_FlashAddress); | 787 | WriteDOC(column, docptr, Mplus_FlashAddress); |
783 | } | 788 | } |
784 | if (page_addr != -1) { | 789 | if (page_addr != -1) { |
785 | WriteDOC((unsigned char) (page_addr & 0xff), docptr, Mplus_FlashAddress); | 790 | WriteDOC((unsigned char)(page_addr & 0xff), docptr, Mplus_FlashAddress); |
786 | WriteDOC((unsigned char) ((page_addr >> 8) & 0xff), docptr, Mplus_FlashAddress); | 791 | WriteDOC((unsigned char)((page_addr >> 8) & 0xff), docptr, Mplus_FlashAddress); |
787 | /* One more address cycle for higher density devices */ | 792 | /* One more address cycle for higher density devices */ |
788 | if (this->chipsize & 0x0c000000) { | 793 | if (this->chipsize & 0x0c000000) { |
789 | WriteDOC((unsigned char) ((page_addr >> 16) & 0x0f), docptr, Mplus_FlashAddress); | 794 | WriteDOC((unsigned char)((page_addr >> 16) & 0x0f), docptr, Mplus_FlashAddress); |
790 | printk("high density\n"); | 795 | printk("high density\n"); |
791 | } | 796 | } |
792 | } | 797 | } |
793 | WriteDOC(0, docptr, Mplus_WritePipeTerm); | 798 | WriteDOC(0, docptr, Mplus_WritePipeTerm); |
794 | WriteDOC(0, docptr, Mplus_WritePipeTerm); | 799 | WriteDOC(0, docptr, Mplus_WritePipeTerm); |
795 | /* deassert ALE */ | 800 | /* deassert ALE */ |
796 | if (command == NAND_CMD_READ0 || command == NAND_CMD_READ1 || command == NAND_CMD_READOOB || command == NAND_CMD_READID) | 801 | if (command == NAND_CMD_READ0 || command == NAND_CMD_READ1 || |
802 | command == NAND_CMD_READOOB || command == NAND_CMD_READID) | ||
797 | WriteDOC(0, docptr, Mplus_FlashControl); | 803 | WriteDOC(0, docptr, Mplus_FlashControl); |
798 | } | 804 | } |
799 | 805 | ||
800 | /* | 806 | /* |
801 | * program and erase have their own busy handlers | 807 | * program and erase have their own busy handlers |
802 | * status and sequential in needs no delay | 808 | * status and sequential in needs no delay |
803 | */ | 809 | */ |
804 | switch (command) { | 810 | switch (command) { |
805 | 811 | ||
806 | case NAND_CMD_PAGEPROG: | 812 | case NAND_CMD_PAGEPROG: |
@@ -817,55 +823,57 @@ static void doc2001plus_command (struct mtd_info *mtd, unsigned command, int col | |||
817 | WriteDOC(NAND_CMD_STATUS, docptr, Mplus_FlashCmd); | 823 | WriteDOC(NAND_CMD_STATUS, docptr, Mplus_FlashCmd); |
818 | WriteDOC(0, docptr, Mplus_WritePipeTerm); | 824 | WriteDOC(0, docptr, Mplus_WritePipeTerm); |
819 | WriteDOC(0, docptr, Mplus_WritePipeTerm); | 825 | WriteDOC(0, docptr, Mplus_WritePipeTerm); |
820 | while ( !(this->read_byte(mtd) & 0x40)); | 826 | while (!(this->read_byte(mtd) & 0x40)) ; |
821 | return; | 827 | return; |
822 | 828 | ||
823 | /* This applies to read commands */ | 829 | /* This applies to read commands */ |
824 | default: | 830 | default: |
825 | /* | 831 | /* |
826 | * If we don't have access to the busy pin, we apply the given | 832 | * If we don't have access to the busy pin, we apply the given |
827 | * command delay | 833 | * command delay |
828 | */ | 834 | */ |
829 | if (!this->dev_ready) { | 835 | if (!this->dev_ready) { |
830 | udelay (this->chip_delay); | 836 | udelay(this->chip_delay); |
831 | return; | 837 | return; |
832 | } | 838 | } |
833 | } | 839 | } |
834 | 840 | ||
835 | /* Apply this short delay always to ensure that we do wait tWB in | 841 | /* Apply this short delay always to ensure that we do wait tWB in |
836 | * any case on any machine. */ | 842 | * any case on any machine. */ |
837 | ndelay (100); | 843 | ndelay(100); |
838 | /* wait until command is processed */ | 844 | /* wait until command is processed */ |
839 | while (!this->dev_ready(mtd)); | 845 | while (!this->dev_ready(mtd)) ; |
840 | } | 846 | } |
841 | 847 | ||
842 | static int doc200x_dev_ready(struct mtd_info *mtd) | 848 | static int doc200x_dev_ready(struct mtd_info *mtd) |
843 | { | 849 | { |
844 | struct nand_chip *this = mtd->priv; | 850 | struct nand_chip *this = mtd->priv; |
845 | struct doc_priv *doc = this->priv; | 851 | struct doc_priv *doc = this->priv; |
846 | void __iomem *docptr = doc->virtadr; | 852 | void __iomem *docptr = doc->virtadr; |
847 | 853 | ||
848 | if (DoC_is_MillenniumPlus(doc)) { | 854 | if (DoC_is_MillenniumPlus(doc)) { |
849 | /* 11.4.2 -- must NOP four times before checking FR/B# */ | 855 | /* 11.4.2 -- must NOP four times before checking FR/B# */ |
850 | DoC_Delay(doc, 4); | 856 | DoC_Delay(doc, 4); |
851 | if ((ReadDOC(docptr, Mplus_FlashControl) & CDSN_CTRL_FR_B_MASK) != CDSN_CTRL_FR_B_MASK) { | 857 | if ((ReadDOC(docptr, Mplus_FlashControl) & CDSN_CTRL_FR_B_MASK) != CDSN_CTRL_FR_B_MASK) { |
852 | if(debug) | 858 | if (debug) |
853 | printk("not ready\n"); | 859 | printk("not ready\n"); |
854 | return 0; | 860 | return 0; |
855 | } | 861 | } |
856 | if (debug)printk("was ready\n"); | 862 | if (debug) |
863 | printk("was ready\n"); | ||
857 | return 1; | 864 | return 1; |
858 | } else { | 865 | } else { |
859 | /* 11.4.2 -- must NOP four times before checking FR/B# */ | 866 | /* 11.4.2 -- must NOP four times before checking FR/B# */ |
860 | DoC_Delay(doc, 4); | 867 | DoC_Delay(doc, 4); |
861 | if (!(ReadDOC(docptr, CDSNControl) & CDSN_CTRL_FR_B)) { | 868 | if (!(ReadDOC(docptr, CDSNControl) & CDSN_CTRL_FR_B)) { |
862 | if(debug) | 869 | if (debug) |
863 | printk("not ready\n"); | 870 | printk("not ready\n"); |
864 | return 0; | 871 | return 0; |
865 | } | 872 | } |
866 | /* 11.4.2 -- Must NOP twice if it's ready */ | 873 | /* 11.4.2 -- Must NOP twice if it's ready */ |
867 | DoC_Delay(doc, 2); | 874 | DoC_Delay(doc, 2); |
868 | if (debug)printk("was ready\n"); | 875 | if (debug) |
876 | printk("was ready\n"); | ||
869 | return 1; | 877 | return 1; |
870 | } | 878 | } |
871 | } | 879 | } |
@@ -881,10 +889,10 @@ static void doc200x_enable_hwecc(struct mtd_info *mtd, int mode) | |||
881 | { | 889 | { |
882 | struct nand_chip *this = mtd->priv; | 890 | struct nand_chip *this = mtd->priv; |
883 | struct doc_priv *doc = this->priv; | 891 | struct doc_priv *doc = this->priv; |
884 | void __iomem *docptr = doc->virtadr; | 892 | void __iomem *docptr = doc->virtadr; |
885 | 893 | ||
886 | /* Prime the ECC engine */ | 894 | /* Prime the ECC engine */ |
887 | switch(mode) { | 895 | switch (mode) { |
888 | case NAND_ECC_READ: | 896 | case NAND_ECC_READ: |
889 | WriteDOC(DOC_ECC_RESET, docptr, ECCConf); | 897 | WriteDOC(DOC_ECC_RESET, docptr, ECCConf); |
890 | WriteDOC(DOC_ECC_EN, docptr, ECCConf); | 898 | WriteDOC(DOC_ECC_EN, docptr, ECCConf); |
@@ -900,10 +908,10 @@ static void doc2001plus_enable_hwecc(struct mtd_info *mtd, int mode) | |||
900 | { | 908 | { |
901 | struct nand_chip *this = mtd->priv; | 909 | struct nand_chip *this = mtd->priv; |
902 | struct doc_priv *doc = this->priv; | 910 | struct doc_priv *doc = this->priv; |
903 | void __iomem *docptr = doc->virtadr; | 911 | void __iomem *docptr = doc->virtadr; |
904 | 912 | ||
905 | /* Prime the ECC engine */ | 913 | /* Prime the ECC engine */ |
906 | switch(mode) { | 914 | switch (mode) { |
907 | case NAND_ECC_READ: | 915 | case NAND_ECC_READ: |
908 | WriteDOC(DOC_ECC_RESET, docptr, Mplus_ECCConf); | 916 | WriteDOC(DOC_ECC_RESET, docptr, Mplus_ECCConf); |
909 | WriteDOC(DOC_ECC_EN, docptr, Mplus_ECCConf); | 917 | WriteDOC(DOC_ECC_EN, docptr, Mplus_ECCConf); |
@@ -916,12 +924,11 @@ static void doc2001plus_enable_hwecc(struct mtd_info *mtd, int mode) | |||
916 | } | 924 | } |
917 | 925 | ||
918 | /* This code is only called on write */ | 926 | /* This code is only called on write */ |
919 | static int doc200x_calculate_ecc(struct mtd_info *mtd, const u_char *dat, | 927 | static int doc200x_calculate_ecc(struct mtd_info *mtd, const u_char *dat, unsigned char *ecc_code) |
920 | unsigned char *ecc_code) | ||
921 | { | 928 | { |
922 | struct nand_chip *this = mtd->priv; | 929 | struct nand_chip *this = mtd->priv; |
923 | struct doc_priv *doc = this->priv; | 930 | struct doc_priv *doc = this->priv; |
924 | void __iomem *docptr = doc->virtadr; | 931 | void __iomem *docptr = doc->virtadr; |
925 | int i; | 932 | int i; |
926 | int emptymatch = 1; | 933 | int emptymatch = 1; |
927 | 934 | ||
@@ -961,7 +968,8 @@ static int doc200x_calculate_ecc(struct mtd_info *mtd, const u_char *dat, | |||
961 | often. It could be optimized away by examining the data in | 968 | often. It could be optimized away by examining the data in |
962 | the writebuf routine, and remembering the result. */ | 969 | the writebuf routine, and remembering the result. */ |
963 | for (i = 0; i < 512; i++) { | 970 | for (i = 0; i < 512; i++) { |
964 | if (dat[i] == 0xff) continue; | 971 | if (dat[i] == 0xff) |
972 | continue; | ||
965 | emptymatch = 0; | 973 | emptymatch = 0; |
966 | break; | 974 | break; |
967 | } | 975 | } |
@@ -969,7 +977,8 @@ static int doc200x_calculate_ecc(struct mtd_info *mtd, const u_char *dat, | |||
969 | /* If emptymatch still =1, we do have an all-0xff data buffer. | 977 | /* If emptymatch still =1, we do have an all-0xff data buffer. |
970 | Return all-0xff ecc value instead of the computed one, so | 978 | Return all-0xff ecc value instead of the computed one, so |
971 | it'll look just like a freshly-erased page. */ | 979 | it'll look just like a freshly-erased page. */ |
972 | if (emptymatch) memset(ecc_code, 0xff, 6); | 980 | if (emptymatch) |
981 | memset(ecc_code, 0xff, 6); | ||
973 | #endif | 982 | #endif |
974 | return 0; | 983 | return 0; |
975 | } | 984 | } |
@@ -979,7 +988,7 @@ static int doc200x_correct_data(struct mtd_info *mtd, u_char *dat, u_char *read_ | |||
979 | int i, ret = 0; | 988 | int i, ret = 0; |
980 | struct nand_chip *this = mtd->priv; | 989 | struct nand_chip *this = mtd->priv; |
981 | struct doc_priv *doc = this->priv; | 990 | struct doc_priv *doc = this->priv; |
982 | void __iomem *docptr = doc->virtadr; | 991 | void __iomem *docptr = doc->virtadr; |
983 | volatile u_char dummy; | 992 | volatile u_char dummy; |
984 | int emptymatch = 1; | 993 | int emptymatch = 1; |
985 | 994 | ||
@@ -1012,18 +1021,20 @@ static int doc200x_correct_data(struct mtd_info *mtd, u_char *dat, u_char *read_ | |||
1012 | all-0xff data and stored ecc block. Check the stored ecc. */ | 1021 | all-0xff data and stored ecc block. Check the stored ecc. */ |
1013 | if (emptymatch) { | 1022 | if (emptymatch) { |
1014 | for (i = 0; i < 6; i++) { | 1023 | for (i = 0; i < 6; i++) { |
1015 | if (read_ecc[i] == 0xff) continue; | 1024 | if (read_ecc[i] == 0xff) |
1025 | continue; | ||
1016 | emptymatch = 0; | 1026 | emptymatch = 0; |
1017 | break; | 1027 | break; |
1018 | } | 1028 | } |
1019 | } | 1029 | } |
1020 | /* If emptymatch still =1, check the data block. */ | 1030 | /* If emptymatch still =1, check the data block. */ |
1021 | if (emptymatch) { | 1031 | if (emptymatch) { |
1022 | /* Note: this somewhat expensive test should not be triggered | 1032 | /* Note: this somewhat expensive test should not be triggered |
1023 | often. It could be optimized away by examining the data in | 1033 | often. It could be optimized away by examining the data in |
1024 | the readbuf routine, and remembering the result. */ | 1034 | the readbuf routine, and remembering the result. */ |
1025 | for (i = 0; i < 512; i++) { | 1035 | for (i = 0; i < 512; i++) { |
1026 | if (dat[i] == 0xff) continue; | 1036 | if (dat[i] == 0xff) |
1037 | continue; | ||
1027 | emptymatch = 0; | 1038 | emptymatch = 0; |
1028 | break; | 1039 | break; |
1029 | } | 1040 | } |
@@ -1032,7 +1043,8 @@ static int doc200x_correct_data(struct mtd_info *mtd, u_char *dat, u_char *read_ | |||
1032 | erased block, in which case the ECC will not come out right. | 1043 | erased block, in which case the ECC will not come out right. |
1033 | We'll suppress the error and tell the caller everything's | 1044 | We'll suppress the error and tell the caller everything's |
1034 | OK. Because it is. */ | 1045 | OK. Because it is. */ |
1035 | if (!emptymatch) ret = doc_ecc_decode (rs_decoder, dat, calc_ecc); | 1046 | if (!emptymatch) |
1047 | ret = doc_ecc_decode(rs_decoder, dat, calc_ecc); | ||
1036 | if (ret > 0) | 1048 | if (ret > 0) |
1037 | printk(KERN_ERR "doc200x_correct_data corrected %d errors\n", ret); | 1049 | printk(KERN_ERR "doc200x_correct_data corrected %d errors\n", ret); |
1038 | } | 1050 | } |
@@ -1060,10 +1072,10 @@ static int doc200x_correct_data(struct mtd_info *mtd, u_char *dat, u_char *read_ | |||
1060 | * be able to handle out-of-order segments. | 1072 | * be able to handle out-of-order segments. |
1061 | */ | 1073 | */ |
1062 | static struct nand_oobinfo doc200x_oobinfo = { | 1074 | static struct nand_oobinfo doc200x_oobinfo = { |
1063 | .useecc = MTD_NANDECC_AUTOPLACE, | 1075 | .useecc = MTD_NANDECC_AUTOPLACE, |
1064 | .eccbytes = 6, | 1076 | .eccbytes = 6, |
1065 | .eccpos = {0, 1, 2, 3, 4, 5}, | 1077 | .eccpos = {0, 1, 2, 3, 4, 5}, |
1066 | .oobfree = { {8, 8}, {6, 2} } | 1078 | .oobfree = {{8, 8}, {6, 2}} |
1067 | }; | 1079 | }; |
1068 | 1080 | ||
1069 | /* Find the (I)NFTL Media Header, and optionally also the mirror media header. | 1081 | /* Find the (I)NFTL Media Header, and optionally also the mirror media header. |
@@ -1072,8 +1084,7 @@ static struct nand_oobinfo doc200x_oobinfo = { | |||
1072 | either "ANAND" or "BNAND". If findmirror=1, also look for the mirror media | 1084 | either "ANAND" or "BNAND". If findmirror=1, also look for the mirror media |
1073 | header. The page #s of the found media headers are placed in mh0_page and | 1085 | header. The page #s of the found media headers are placed in mh0_page and |
1074 | mh1_page in the DOC private structure. */ | 1086 | mh1_page in the DOC private structure. */ |
1075 | static int __init find_media_headers(struct mtd_info *mtd, u_char *buf, | 1087 | static int __init find_media_headers(struct mtd_info *mtd, u_char *buf, const char *id, int findmirror) |
1076 | const char *id, int findmirror) | ||
1077 | { | 1088 | { |
1078 | struct nand_chip *this = mtd->priv; | 1089 | struct nand_chip *this = mtd->priv; |
1079 | struct doc_priv *doc = this->priv; | 1090 | struct doc_priv *doc = this->priv; |
@@ -1083,16 +1094,18 @@ static int __init find_media_headers(struct mtd_info *mtd, u_char *buf, | |||
1083 | 1094 | ||
1084 | for (offs = 0; offs < mtd->size; offs += mtd->erasesize) { | 1095 | for (offs = 0; offs < mtd->size; offs += mtd->erasesize) { |
1085 | ret = mtd->read(mtd, offs, mtd->oobblock, &retlen, buf); | 1096 | ret = mtd->read(mtd, offs, mtd->oobblock, &retlen, buf); |
1086 | if (retlen != mtd->oobblock) continue; | 1097 | if (retlen != mtd->oobblock) |
1098 | continue; | ||
1087 | if (ret) { | 1099 | if (ret) { |
1088 | printk(KERN_WARNING "ECC error scanning DOC at 0x%x\n", | 1100 | printk(KERN_WARNING "ECC error scanning DOC at 0x%x\n", offs); |
1089 | offs); | ||
1090 | } | 1101 | } |
1091 | if (memcmp(buf, id, 6)) continue; | 1102 | if (memcmp(buf, id, 6)) |
1103 | continue; | ||
1092 | printk(KERN_INFO "Found DiskOnChip %s Media Header at 0x%x\n", id, offs); | 1104 | printk(KERN_INFO "Found DiskOnChip %s Media Header at 0x%x\n", id, offs); |
1093 | if (doc->mh0_page == -1) { | 1105 | if (doc->mh0_page == -1) { |
1094 | doc->mh0_page = offs >> this->page_shift; | 1106 | doc->mh0_page = offs >> this->page_shift; |
1095 | if (!findmirror) return 1; | 1107 | if (!findmirror) |
1108 | return 1; | ||
1096 | continue; | 1109 | continue; |
1097 | } | 1110 | } |
1098 | doc->mh1_page = offs >> this->page_shift; | 1111 | doc->mh1_page = offs >> this->page_shift; |
@@ -1114,8 +1127,7 @@ static int __init find_media_headers(struct mtd_info *mtd, u_char *buf, | |||
1114 | return 1; | 1127 | return 1; |
1115 | } | 1128 | } |
1116 | 1129 | ||
1117 | static inline int __init nftl_partscan(struct mtd_info *mtd, | 1130 | static inline int __init nftl_partscan(struct mtd_info *mtd, struct mtd_partition *parts) |
1118 | struct mtd_partition *parts) | ||
1119 | { | 1131 | { |
1120 | struct nand_chip *this = mtd->priv; | 1132 | struct nand_chip *this = mtd->priv; |
1121 | struct doc_priv *doc = this->priv; | 1133 | struct doc_priv *doc = this->priv; |
@@ -1132,8 +1144,9 @@ static inline int __init nftl_partscan(struct mtd_info *mtd, | |||
1132 | printk(KERN_ERR "DiskOnChip mediaheader kmalloc failed!\n"); | 1144 | printk(KERN_ERR "DiskOnChip mediaheader kmalloc failed!\n"); |
1133 | return 0; | 1145 | return 0; |
1134 | } | 1146 | } |
1135 | if (!(numheaders=find_media_headers(mtd, buf, "ANAND", 1))) goto out; | 1147 | if (!(numheaders = find_media_headers(mtd, buf, "ANAND", 1))) |
1136 | mh = (struct NFTLMediaHeader *) buf; | 1148 | goto out; |
1149 | mh = (struct NFTLMediaHeader *)buf; | ||
1137 | 1150 | ||
1138 | mh->NumEraseUnits = le16_to_cpu(mh->NumEraseUnits); | 1151 | mh->NumEraseUnits = le16_to_cpu(mh->NumEraseUnits); |
1139 | mh->FirstPhysicalEUN = le16_to_cpu(mh->FirstPhysicalEUN); | 1152 | mh->FirstPhysicalEUN = le16_to_cpu(mh->FirstPhysicalEUN); |
@@ -1155,8 +1168,8 @@ static inline int __init nftl_partscan(struct mtd_info *mtd, | |||
1155 | /* Auto-determine UnitSizeFactor. The constraints are: | 1168 | /* Auto-determine UnitSizeFactor. The constraints are: |
1156 | - There can be at most 32768 virtual blocks. | 1169 | - There can be at most 32768 virtual blocks. |
1157 | - There can be at most (virtual block size - page size) | 1170 | - There can be at most (virtual block size - page size) |
1158 | virtual blocks (because MediaHeader+BBT must fit in 1). | 1171 | virtual blocks (because MediaHeader+BBT must fit in 1). |
1159 | */ | 1172 | */ |
1160 | mh->UnitSizeFactor = 0xff; | 1173 | mh->UnitSizeFactor = 0xff; |
1161 | while (blocks > maxblocks) { | 1174 | while (blocks > maxblocks) { |
1162 | blocks >>= 1; | 1175 | blocks >>= 1; |
@@ -1211,14 +1224,13 @@ static inline int __init nftl_partscan(struct mtd_info *mtd, | |||
1211 | } | 1224 | } |
1212 | 1225 | ||
1213 | ret = numparts; | 1226 | ret = numparts; |
1214 | out: | 1227 | out: |
1215 | kfree(buf); | 1228 | kfree(buf); |
1216 | return ret; | 1229 | return ret; |
1217 | } | 1230 | } |
1218 | 1231 | ||
1219 | /* This is a stripped-down copy of the code in inftlmount.c */ | 1232 | /* This is a stripped-down copy of the code in inftlmount.c */ |
1220 | static inline int __init inftl_partscan(struct mtd_info *mtd, | 1233 | static inline int __init inftl_partscan(struct mtd_info *mtd, struct mtd_partition *parts) |
1221 | struct mtd_partition *parts) | ||
1222 | { | 1234 | { |
1223 | struct nand_chip *this = mtd->priv; | 1235 | struct nand_chip *this = mtd->priv; |
1224 | struct doc_priv *doc = this->priv; | 1236 | struct doc_priv *doc = this->priv; |
@@ -1241,9 +1253,10 @@ static inline int __init inftl_partscan(struct mtd_info *mtd, | |||
1241 | return 0; | 1253 | return 0; |
1242 | } | 1254 | } |
1243 | 1255 | ||
1244 | if (!find_media_headers(mtd, buf, "BNAND", 0)) goto out; | 1256 | if (!find_media_headers(mtd, buf, "BNAND", 0)) |
1257 | goto out; | ||
1245 | doc->mh1_page = doc->mh0_page + (4096 >> this->page_shift); | 1258 | doc->mh1_page = doc->mh0_page + (4096 >> this->page_shift); |
1246 | mh = (struct INFTLMediaHeader *) buf; | 1259 | mh = (struct INFTLMediaHeader *)buf; |
1247 | 1260 | ||
1248 | mh->NoOfBootImageBlocks = le32_to_cpu(mh->NoOfBootImageBlocks); | 1261 | mh->NoOfBootImageBlocks = le32_to_cpu(mh->NoOfBootImageBlocks); |
1249 | mh->NoOfBinaryPartitions = le32_to_cpu(mh->NoOfBinaryPartitions); | 1262 | mh->NoOfBinaryPartitions = le32_to_cpu(mh->NoOfBinaryPartitions); |
@@ -1319,8 +1332,10 @@ static inline int __init inftl_partscan(struct mtd_info *mtd, | |||
1319 | parts[numparts].offset = ip->firstUnit << vshift; | 1332 | parts[numparts].offset = ip->firstUnit << vshift; |
1320 | parts[numparts].size = (1 + ip->lastUnit - ip->firstUnit) << vshift; | 1333 | parts[numparts].size = (1 + ip->lastUnit - ip->firstUnit) << vshift; |
1321 | numparts++; | 1334 | numparts++; |
1322 | if (ip->lastUnit > lastvunit) lastvunit = ip->lastUnit; | 1335 | if (ip->lastUnit > lastvunit) |
1323 | if (ip->flags & INFTL_LAST) break; | 1336 | lastvunit = ip->lastUnit; |
1337 | if (ip->flags & INFTL_LAST) | ||
1338 | break; | ||
1324 | } | 1339 | } |
1325 | lastvunit++; | 1340 | lastvunit++; |
1326 | if ((lastvunit << vshift) < end) { | 1341 | if ((lastvunit << vshift) < end) { |
@@ -1330,7 +1345,7 @@ static inline int __init inftl_partscan(struct mtd_info *mtd, | |||
1330 | numparts++; | 1345 | numparts++; |
1331 | } | 1346 | } |
1332 | ret = numparts; | 1347 | ret = numparts; |
1333 | out: | 1348 | out: |
1334 | kfree(buf); | 1349 | kfree(buf); |
1335 | return ret; | 1350 | return ret; |
1336 | } | 1351 | } |
@@ -1342,11 +1357,12 @@ static int __init nftl_scan_bbt(struct mtd_info *mtd) | |||
1342 | struct doc_priv *doc = this->priv; | 1357 | struct doc_priv *doc = this->priv; |
1343 | struct mtd_partition parts[2]; | 1358 | struct mtd_partition parts[2]; |
1344 | 1359 | ||
1345 | memset((char *) parts, 0, sizeof(parts)); | 1360 | memset((char *)parts, 0, sizeof(parts)); |
1346 | /* On NFTL, we have to find the media headers before we can read the | 1361 | /* On NFTL, we have to find the media headers before we can read the |
1347 | BBTs, since they're stored in the media header eraseblocks. */ | 1362 | BBTs, since they're stored in the media header eraseblocks. */ |
1348 | numparts = nftl_partscan(mtd, parts); | 1363 | numparts = nftl_partscan(mtd, parts); |
1349 | if (!numparts) return -EIO; | 1364 | if (!numparts) |
1365 | return -EIO; | ||
1350 | this->bbt_td->options = NAND_BBT_ABSPAGE | NAND_BBT_8BIT | | 1366 | this->bbt_td->options = NAND_BBT_ABSPAGE | NAND_BBT_8BIT | |
1351 | NAND_BBT_SAVECONTENT | NAND_BBT_WRITE | | 1367 | NAND_BBT_SAVECONTENT | NAND_BBT_WRITE | |
1352 | NAND_BBT_VERSION; | 1368 | NAND_BBT_VERSION; |
@@ -1393,8 +1409,7 @@ static int __init inftl_scan_bbt(struct mtd_info *mtd) | |||
1393 | this->bbt_td->pages[0] = 2; | 1409 | this->bbt_td->pages[0] = 2; |
1394 | this->bbt_md = NULL; | 1410 | this->bbt_md = NULL; |
1395 | } else { | 1411 | } else { |
1396 | this->bbt_td->options = NAND_BBT_LASTBLOCK | NAND_BBT_8BIT | | 1412 | this->bbt_td->options = NAND_BBT_LASTBLOCK | NAND_BBT_8BIT | NAND_BBT_VERSION; |
1397 | NAND_BBT_VERSION; | ||
1398 | if (inftl_bbt_write) | 1413 | if (inftl_bbt_write) |
1399 | this->bbt_td->options |= NAND_BBT_WRITE; | 1414 | this->bbt_td->options |= NAND_BBT_WRITE; |
1400 | this->bbt_td->offs = 8; | 1415 | this->bbt_td->offs = 8; |
@@ -1404,8 +1419,7 @@ static int __init inftl_scan_bbt(struct mtd_info *mtd) | |||
1404 | this->bbt_td->reserved_block_code = 0x01; | 1419 | this->bbt_td->reserved_block_code = 0x01; |
1405 | this->bbt_td->pattern = "MSYS_BBT"; | 1420 | this->bbt_td->pattern = "MSYS_BBT"; |
1406 | 1421 | ||
1407 | this->bbt_md->options = NAND_BBT_LASTBLOCK | NAND_BBT_8BIT | | 1422 | this->bbt_md->options = NAND_BBT_LASTBLOCK | NAND_BBT_8BIT | NAND_BBT_VERSION; |
1408 | NAND_BBT_VERSION; | ||
1409 | if (inftl_bbt_write) | 1423 | if (inftl_bbt_write) |
1410 | this->bbt_md->options |= NAND_BBT_WRITE; | 1424 | this->bbt_md->options |= NAND_BBT_WRITE; |
1411 | this->bbt_md->offs = 8; | 1425 | this->bbt_md->offs = 8; |
@@ -1420,12 +1434,13 @@ static int __init inftl_scan_bbt(struct mtd_info *mtd) | |||
1420 | At least as nand_bbt.c is currently written. */ | 1434 | At least as nand_bbt.c is currently written. */ |
1421 | if ((ret = nand_scan_bbt(mtd, NULL))) | 1435 | if ((ret = nand_scan_bbt(mtd, NULL))) |
1422 | return ret; | 1436 | return ret; |
1423 | memset((char *) parts, 0, sizeof(parts)); | 1437 | memset((char *)parts, 0, sizeof(parts)); |
1424 | numparts = inftl_partscan(mtd, parts); | 1438 | numparts = inftl_partscan(mtd, parts); |
1425 | /* At least for now, require the INFTL Media Header. We could probably | 1439 | /* At least for now, require the INFTL Media Header. We could probably |
1426 | do without it for non-INFTL use, since all it gives us is | 1440 | do without it for non-INFTL use, since all it gives us is |
1427 | autopartitioning, but I want to give it more thought. */ | 1441 | autopartitioning, but I want to give it more thought. */ |
1428 | if (!numparts) return -EIO; | 1442 | if (!numparts) |
1443 | return -EIO; | ||
1429 | add_mtd_device(mtd); | 1444 | add_mtd_device(mtd); |
1430 | #ifdef CONFIG_MTD_PARTITIONS | 1445 | #ifdef CONFIG_MTD_PARTITIONS |
1431 | if (!no_autopart) | 1446 | if (!no_autopart) |
@@ -1535,20 +1550,16 @@ static int __init doc_probe(unsigned long physadr) | |||
1535 | save_control = ReadDOC(virtadr, DOCControl); | 1550 | save_control = ReadDOC(virtadr, DOCControl); |
1536 | 1551 | ||
1537 | /* Reset the DiskOnChip ASIC */ | 1552 | /* Reset the DiskOnChip ASIC */ |
1538 | WriteDOC(DOC_MODE_CLR_ERR | DOC_MODE_MDWREN | DOC_MODE_RESET, | 1553 | WriteDOC(DOC_MODE_CLR_ERR | DOC_MODE_MDWREN | DOC_MODE_RESET, virtadr, DOCControl); |
1539 | virtadr, DOCControl); | 1554 | WriteDOC(DOC_MODE_CLR_ERR | DOC_MODE_MDWREN | DOC_MODE_RESET, virtadr, DOCControl); |
1540 | WriteDOC(DOC_MODE_CLR_ERR | DOC_MODE_MDWREN | DOC_MODE_RESET, | ||
1541 | virtadr, DOCControl); | ||
1542 | 1555 | ||
1543 | /* Enable the DiskOnChip ASIC */ | 1556 | /* Enable the DiskOnChip ASIC */ |
1544 | WriteDOC(DOC_MODE_CLR_ERR | DOC_MODE_MDWREN | DOC_MODE_NORMAL, | 1557 | WriteDOC(DOC_MODE_CLR_ERR | DOC_MODE_MDWREN | DOC_MODE_NORMAL, virtadr, DOCControl); |
1545 | virtadr, DOCControl); | 1558 | WriteDOC(DOC_MODE_CLR_ERR | DOC_MODE_MDWREN | DOC_MODE_NORMAL, virtadr, DOCControl); |
1546 | WriteDOC(DOC_MODE_CLR_ERR | DOC_MODE_MDWREN | DOC_MODE_NORMAL, | ||
1547 | virtadr, DOCControl); | ||
1548 | 1559 | ||
1549 | ChipID = ReadDOC(virtadr, ChipID); | 1560 | ChipID = ReadDOC(virtadr, ChipID); |
1550 | 1561 | ||
1551 | switch(ChipID) { | 1562 | switch (ChipID) { |
1552 | case DOC_ChipID_Doc2k: | 1563 | case DOC_ChipID_Doc2k: |
1553 | reg = DoC_2k_ECCStatus; | 1564 | reg = DoC_2k_ECCStatus; |
1554 | break; | 1565 | break; |
@@ -1564,15 +1575,13 @@ static int __init doc_probe(unsigned long physadr) | |||
1564 | ReadDOC(virtadr, Mplus_Power); | 1575 | ReadDOC(virtadr, Mplus_Power); |
1565 | 1576 | ||
1566 | /* Reset the Millennium Plus ASIC */ | 1577 | /* Reset the Millennium Plus ASIC */ |
1567 | tmp = DOC_MODE_RESET | DOC_MODE_MDWREN | DOC_MODE_RST_LAT | | 1578 | tmp = DOC_MODE_RESET | DOC_MODE_MDWREN | DOC_MODE_RST_LAT | DOC_MODE_BDECT; |
1568 | DOC_MODE_BDECT; | ||
1569 | WriteDOC(tmp, virtadr, Mplus_DOCControl); | 1579 | WriteDOC(tmp, virtadr, Mplus_DOCControl); |
1570 | WriteDOC(~tmp, virtadr, Mplus_CtrlConfirm); | 1580 | WriteDOC(~tmp, virtadr, Mplus_CtrlConfirm); |
1571 | 1581 | ||
1572 | mdelay(1); | 1582 | mdelay(1); |
1573 | /* Enable the Millennium Plus ASIC */ | 1583 | /* Enable the Millennium Plus ASIC */ |
1574 | tmp = DOC_MODE_NORMAL | DOC_MODE_MDWREN | DOC_MODE_RST_LAT | | 1584 | tmp = DOC_MODE_NORMAL | DOC_MODE_MDWREN | DOC_MODE_RST_LAT | DOC_MODE_BDECT; |
1575 | DOC_MODE_BDECT; | ||
1576 | WriteDOC(tmp, virtadr, Mplus_DOCControl); | 1585 | WriteDOC(tmp, virtadr, Mplus_DOCControl); |
1577 | WriteDOC(~tmp, virtadr, Mplus_CtrlConfirm); | 1586 | WriteDOC(~tmp, virtadr, Mplus_CtrlConfirm); |
1578 | mdelay(1); | 1587 | mdelay(1); |
@@ -1596,7 +1605,7 @@ static int __init doc_probe(unsigned long physadr) | |||
1596 | goto notfound; | 1605 | goto notfound; |
1597 | } | 1606 | } |
1598 | /* Check the TOGGLE bit in the ECC register */ | 1607 | /* Check the TOGGLE bit in the ECC register */ |
1599 | tmp = ReadDOC_(virtadr, reg) & DOC_TOGGLE_BIT; | 1608 | tmp = ReadDOC_(virtadr, reg) & DOC_TOGGLE_BIT; |
1600 | tmpb = ReadDOC_(virtadr, reg) & DOC_TOGGLE_BIT; | 1609 | tmpb = ReadDOC_(virtadr, reg) & DOC_TOGGLE_BIT; |
1601 | tmpc = ReadDOC_(virtadr, reg) & DOC_TOGGLE_BIT; | 1610 | tmpc = ReadDOC_(virtadr, reg) & DOC_TOGGLE_BIT; |
1602 | if ((tmp == tmpb) || (tmp != tmpc)) { | 1611 | if ((tmp == tmpb) || (tmp != tmpc)) { |
@@ -1626,11 +1635,11 @@ static int __init doc_probe(unsigned long physadr) | |||
1626 | if (ChipID == DOC_ChipID_DocMilPlus16) { | 1635 | if (ChipID == DOC_ChipID_DocMilPlus16) { |
1627 | WriteDOC(~newval, virtadr, Mplus_AliasResolution); | 1636 | WriteDOC(~newval, virtadr, Mplus_AliasResolution); |
1628 | oldval = ReadDOC(doc->virtadr, Mplus_AliasResolution); | 1637 | oldval = ReadDOC(doc->virtadr, Mplus_AliasResolution); |
1629 | WriteDOC(newval, virtadr, Mplus_AliasResolution); // restore it | 1638 | WriteDOC(newval, virtadr, Mplus_AliasResolution); // restore it |
1630 | } else { | 1639 | } else { |
1631 | WriteDOC(~newval, virtadr, AliasResolution); | 1640 | WriteDOC(~newval, virtadr, AliasResolution); |
1632 | oldval = ReadDOC(doc->virtadr, AliasResolution); | 1641 | oldval = ReadDOC(doc->virtadr, AliasResolution); |
1633 | WriteDOC(newval, virtadr, AliasResolution); // restore it | 1642 | WriteDOC(newval, virtadr, AliasResolution); // restore it |
1634 | } | 1643 | } |
1635 | newval = ~newval; | 1644 | newval = ~newval; |
1636 | if (oldval == newval) { | 1645 | if (oldval == newval) { |
@@ -1642,10 +1651,8 @@ static int __init doc_probe(unsigned long physadr) | |||
1642 | printk(KERN_NOTICE "DiskOnChip found at 0x%lx\n", physadr); | 1651 | printk(KERN_NOTICE "DiskOnChip found at 0x%lx\n", physadr); |
1643 | 1652 | ||
1644 | len = sizeof(struct mtd_info) + | 1653 | len = sizeof(struct mtd_info) + |
1645 | sizeof(struct nand_chip) + | 1654 | sizeof(struct nand_chip) + sizeof(struct doc_priv) + (2 * sizeof(struct nand_bbt_descr)); |
1646 | sizeof(struct doc_priv) + | 1655 | mtd = kmalloc(len, GFP_KERNEL); |
1647 | (2 * sizeof(struct nand_bbt_descr)); | ||
1648 | mtd = kmalloc(len, GFP_KERNEL); | ||
1649 | if (!mtd) { | 1656 | if (!mtd) { |
1650 | printk(KERN_ERR "DiskOnChip kmalloc (%d bytes) failed!\n", len); | 1657 | printk(KERN_ERR "DiskOnChip kmalloc (%d bytes) failed!\n", len); |
1651 | ret = -ENOMEM; | 1658 | ret = -ENOMEM; |
@@ -1707,18 +1714,18 @@ static int __init doc_probe(unsigned long physadr) | |||
1707 | doclist = mtd; | 1714 | doclist = mtd; |
1708 | return 0; | 1715 | return 0; |
1709 | 1716 | ||
1710 | notfound: | 1717 | notfound: |
1711 | /* Put back the contents of the DOCControl register, in case it's not | 1718 | /* Put back the contents of the DOCControl register, in case it's not |
1712 | actually a DiskOnChip. */ | 1719 | actually a DiskOnChip. */ |
1713 | WriteDOC(save_control, virtadr, DOCControl); | 1720 | WriteDOC(save_control, virtadr, DOCControl); |
1714 | fail: | 1721 | fail: |
1715 | iounmap(virtadr); | 1722 | iounmap(virtadr); |
1716 | return ret; | 1723 | return ret; |
1717 | } | 1724 | } |
1718 | 1725 | ||
1719 | static void release_nanddoc(void) | 1726 | static void release_nanddoc(void) |
1720 | { | 1727 | { |
1721 | struct mtd_info *mtd, *nextmtd; | 1728 | struct mtd_info *mtd, *nextmtd; |
1722 | struct nand_chip *nand; | 1729 | struct nand_chip *nand; |
1723 | struct doc_priv *doc; | 1730 | struct doc_priv *doc; |
1724 | 1731 | ||
@@ -1747,8 +1754,8 @@ static int __init init_nanddoc(void) | |||
1747 | * generator polinomial degree = 4 | 1754 | * generator polinomial degree = 4 |
1748 | */ | 1755 | */ |
1749 | rs_decoder = init_rs(10, 0x409, FCR, 1, NROOTS); | 1756 | rs_decoder = init_rs(10, 0x409, FCR, 1, NROOTS); |
1750 | if (!rs_decoder) { | 1757 | if (!rs_decoder) { |
1751 | printk (KERN_ERR "DiskOnChip: Could not create a RS decoder\n"); | 1758 | printk(KERN_ERR "DiskOnChip: Could not create a RS decoder\n"); |
1752 | return -ENOMEM; | 1759 | return -ENOMEM; |
1753 | } | 1760 | } |
1754 | 1761 | ||
@@ -1758,7 +1765,7 @@ static int __init init_nanddoc(void) | |||
1758 | if (ret < 0) | 1765 | if (ret < 0) |
1759 | goto outerr; | 1766 | goto outerr; |
1760 | } else { | 1767 | } else { |
1761 | for (i=0; (doc_locations[i] != 0xffffffff); i++) { | 1768 | for (i = 0; (doc_locations[i] != 0xffffffff); i++) { |
1762 | doc_probe(doc_locations[i]); | 1769 | doc_probe(doc_locations[i]); |
1763 | } | 1770 | } |
1764 | } | 1771 | } |
@@ -1770,7 +1777,7 @@ static int __init init_nanddoc(void) | |||
1770 | goto outerr; | 1777 | goto outerr; |
1771 | } | 1778 | } |
1772 | return 0; | 1779 | return 0; |
1773 | outerr: | 1780 | outerr: |
1774 | free_rs(rs_decoder); | 1781 | free_rs(rs_decoder); |
1775 | return ret; | 1782 | return ret; |
1776 | } | 1783 | } |