Date:2010-06-28 00:06:10 (13 years 5 months ago)
Author:Lars C.
Commit:87577b6d4b915699143120cce6c55ef4d8487ad3
Message:MTD: NAND: jz4740: Add custom nand read/write callbacks

The default read/write callbacks only support 64 ecc bytes, but we need to
support more.
Files: drivers/mtd/nand/jz4740_nand.c (2 diffs)

Change Details

drivers/mtd/nand/jz4740_nand.c
241241}
242242
243243
244/* Copy paste of nand_read_page_hwecc_oob_first except for different eccpos
245 * handling. The ecc area is for 4k chips 72 bytes long and thus does not fit
246 * into the eccpos array. */
247static int jz_nand_read_page_hwecc_oob_first(struct mtd_info *mtd,
248    struct nand_chip *chip, uint8_t *buf, int page)
249{
250    int i, eccsize = chip->ecc.size;
251    int eccbytes = chip->ecc.bytes;
252    int eccsteps = chip->ecc.steps;
253    uint8_t *p = buf;
254    unsigned int ecc_offset = chip->page_shift;
255
256    /* Read the OOB area first */
257    chip->cmdfunc(mtd, NAND_CMD_READOOB, 0, page);
258    chip->read_buf(mtd, chip->oob_poi, mtd->oobsize);
259    chip->cmdfunc(mtd, NAND_CMD_READ0, 0, page);
260
261    for (i = ecc_offset; eccsteps; eccsteps--, i += eccbytes, p += eccsize) {
262        int stat;
263
264        chip->ecc.hwctl(mtd, NAND_ECC_READ);
265        chip->read_buf(mtd, p, eccsize);
266
267        stat = chip->ecc.correct(mtd, p, &chip->oob_poi[i], NULL);
268        if (stat < 0)
269            mtd->ecc_stats.failed++;
270        else
271            mtd->ecc_stats.corrected += stat;
272    }
273    return 0;
274}
275
276/* Copy-and-paste of nand_write_page_hwecc with different eccpos handling. */
277static void jz_nand_write_page_hwecc(struct mtd_info *mtd,
278    struct nand_chip *chip, const uint8_t *buf)
279{
280    int i, eccsize = chip->ecc.size;
281    int eccbytes = chip->ecc.bytes;
282    int eccsteps = chip->ecc.steps;
283    const uint8_t *p = buf;
284    unsigned int ecc_offset = chip->page_shift;
285
286    for (i = ecc_offset; eccsteps; eccsteps--, i += eccbytes, p += eccsize) {
287        chip->ecc.hwctl(mtd, NAND_ECC_WRITE);
288        chip->write_buf(mtd, p, eccsize);
289        chip->ecc.calculate(mtd, p, &chip->oob_poi[i]);
290    }
291
292    chip->write_buf(mtd, chip->oob_poi, mtd->oobsize);
293}
244294
245295#ifdef CONFIG_MTD_CMDLINE_PARTS
246296static const char *part_probes[] = {"cmdline", NULL};
...... 
308358    chip->ecc.mode = NAND_ECC_HW_OOB_FIRST;
309359    chip->ecc.size = 512;
310360    chip->ecc.bytes = 9;
361
362    chip->ecc.read_page = jz_nand_read_page_hwecc_oob_first;
363    chip->ecc.write_page = jz_nand_write_page_hwecc;
364
311365    if (pdata)
312366        chip->ecc.layout = pdata->ecc_layout;
313367

Archive Download the corresponding diff file



interactive