Date:2010-06-28 00:05:15 (13 years 5 months ago)
Author:Lars C.
Commit:1e2d11fda4717094823d225377e84aebbedd6d79
Message:MTD: NAND: jz4740: Minor cleanups

Files: drivers/mtd/nand/jz4740_nand.c (8 diffs)

Change Details

drivers/mtd/nand/jz4740_nand.c
11/*
22 * Copyright (C) 2009-2010, Lars-Peter Clausen <lars@metafoo.de>
3 * JZ4740 SoC NAND controller driver
3 * JZ4740 SoC NAND controller driver
44 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
88 * option) any later version.
99 *
10 * You should have received a copy of the GNU General Public License along
11 * with this program; if not, write to the Free Software Foundation, Inc.,
10 * You should have received a copy of the GNU General Public License along
11 * with this program; if not, write to the Free Software Foundation, Inc.,
1212 * 675 Mass Ave, Cambridge, MA 02139, USA.
1313 *
1414 */
...... 
108108    struct jz_nand *nand = mtd_to_jz_nand(mtd);
109109    uint32_t reg;
110110
111
112111    writel(0, nand->base + JZ_REG_NAND_IRQ_STAT);
113112    reg = readl(nand->base + JZ_REG_NAND_ECC_CTRL);
114113
...... 
132131    writel(reg, nand->base + JZ_REG_NAND_ECC_CTRL);
133132}
134133
135
136134static int jz_nand_calculate_ecc_rs(struct mtd_info *mtd, const uint8_t *dat,
137135    uint8_t *ecc_code)
138136{
...... 
164162    return 0;
165163}
166164
167/*#define printkd printk*/
168#define printkd(...)
169
170165static void correct_data(uint8_t *dat, int index, int mask)
171166{
172167    int offset = index & 0x7;
173168    uint16_t data;
174    printkd("correct: ");
175169
176170    index += (index >> 3);
177171
178172    data = dat[index];
179173    data |= dat[index+1] << 8;
180174
181    printkd("0x%x -> ", data);
182
183175    mask ^= (data >> offset) & 0x1ff;
184176    data &= ~(0x1ff << offset);
185177    data |= (mask << offset);
186178
187    printkd("0x%x\n", data);
188
189179    dat[index] = data & 0xff;
190180    dat[index+1] = (data >> 8) & 0xff;
191181}
...... 
232222    writel(reg, nand->base + JZ_REG_NAND_ECC_CTRL);
233223
234224    if (status & JZ_NAND_STATUS_ERROR) {
235        if (status & JZ_NAND_STATUS_UNCOR_ERROR) {
236            printkd("uncorrectable ecc:");
237            for (i = 0; i < 9; ++i)
238                printkd(" 0x%x", read_ecc[i]);
239            printkd("\n");
240            printkd("uncorrectable data:");
241            for (i = 0; i < 32; ++i)
242                printkd(" 0x%x", dat[i]);
243            printkd("\n");
225        if (status & JZ_NAND_STATUS_UNCOR_ERROR)
244226            return -1;
245        }
246227
247228        error_count = (status & JZ_NAND_STATUS_ERR_COUNT) >> 29;
248229
249        printkd("error_count: %d %x\n", error_count, status);
250
251230        for (i = 0; i < error_count; ++i) {
252231            error = readl(nand->base + JZ_REG_NAND_ERR(i));
253232            index = ((error >> 16) & 0x1ff) - 1;
...... 
294273
295274    nand->mem = request_mem_region(nand->mem->start,
296275                    resource_size(nand->mem), pdev->name);
297
298276    if (!nand->mem) {
299277        dev_err(&pdev->dev, "Failed to request mmio memory region\n");
300278        ret = -EBUSY;
...... 
302280    }
303281
304282    nand->base = ioremap(nand->mem->start, resource_size(nand->mem));
305
306283    if (!nand->base) {
307284        dev_err(&pdev->dev, "Failed to ioremap mmio memory region\n");
308285        ret = -EBUSY;
...... 
401378    return ret;
402379}
403380
404static void __devexit jz_nand_remove(struct platform_device *pdev)
381static int __devexit jz_nand_remove(struct platform_device *pdev)
405382{
406383    struct jz_nand *nand = platform_get_drvdata(pdev);
407384
408385    nand_release(&nand->mtd);
409386
410387    iounmap(nand->base);
411
412388    release_mem_region(nand->mem->start, resource_size(nand->mem));
413389
414390    platform_set_drvdata(pdev, NULL);
415391    kfree(nand);
392
393    return 0;
416394}
417395
418396struct platform_driver jz_nand_driver = {
419397    .probe = jz_nand_probe,
420    .remove = __devexit_p(jz_nand_probe),
398    .remove = __devexit_p(jz_nand_remove),
421399    .driver = {
422400        .name = "jz4740-nand",
423401        .owner = THIS_MODULE,

Archive Download the corresponding diff file



interactive