diff options
author | Thomas Gleixner <tglx@cruncher.tec.linutronix.de> | 2006-05-23 06:37:31 -0400 |
---|---|---|
committer | Thomas Gleixner <tglx@cruncher.tec.linutronix.de> | 2006-05-23 06:37:31 -0400 |
commit | 4cbb9b80e171107c6c34116283fe38e5a396c68b (patch) | |
tree | 9463f2e4774f14752cf4bb52431e14e569256f72 /drivers/mtd/nand/nand_base.c | |
parent | 6dfc6d250d0b7ebaa6423c44dcd09fcfe68deabd (diff) | |
parent | 9fe4854cd1f60273f9a3ece053f4789605f58a5e (diff) |
Merge branch 'master' of /home/tglx/work/kernel/git/mtd-2.6/
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'drivers/mtd/nand/nand_base.c')
-rw-r--r-- | drivers/mtd/nand/nand_base.c | 64 |
1 files changed, 32 insertions, 32 deletions
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c index 98792ec4c2dc..778535006c83 100644 --- a/drivers/mtd/nand/nand_base.c +++ b/drivers/mtd/nand/nand_base.c | |||
@@ -572,9 +572,9 @@ static void nand_command(struct mtd_info *mtd, unsigned command, int column, | |||
572 | if (command == NAND_CMD_SEQIN) { | 572 | if (command == NAND_CMD_SEQIN) { |
573 | int readcmd; | 573 | int readcmd; |
574 | 574 | ||
575 | if (column >= mtd->oobblock) { | 575 | if (column >= mtd->writesize) { |
576 | /* OOB area */ | 576 | /* OOB area */ |
577 | column -= mtd->oobblock; | 577 | column -= mtd->writesize; |
578 | readcmd = NAND_CMD_READOOB; | 578 | readcmd = NAND_CMD_READOOB; |
579 | } else if (column < 256) { | 579 | } else if (column < 256) { |
580 | /* First 256 bytes --> READ0 */ | 580 | /* First 256 bytes --> READ0 */ |
@@ -670,7 +670,7 @@ static void nand_command_lp(struct mtd_info *mtd, unsigned command, int column, | |||
670 | 670 | ||
671 | /* Emulate NAND_CMD_READOOB */ | 671 | /* Emulate NAND_CMD_READOOB */ |
672 | if (command == NAND_CMD_READOOB) { | 672 | if (command == NAND_CMD_READOOB) { |
673 | column += mtd->oobblock; | 673 | column += mtd->writesize; |
674 | command = NAND_CMD_READ0; | 674 | command = NAND_CMD_READ0; |
675 | } | 675 | } |
676 | 676 | ||
@@ -895,7 +895,7 @@ static int nand_write_page(struct mtd_info *mtd, struct nand_chip *this, int pag | |||
895 | /* No ecc, write all */ | 895 | /* No ecc, write all */ |
896 | case NAND_ECC_NONE: | 896 | case NAND_ECC_NONE: |
897 | printk(KERN_WARNING "Writing data without ECC to NAND-FLASH is not recommended\n"); | 897 | printk(KERN_WARNING "Writing data without ECC to NAND-FLASH is not recommended\n"); |
898 | this->write_buf(mtd, this->data_poi, mtd->oobblock); | 898 | this->write_buf(mtd, this->data_poi, mtd->writesize); |
899 | break; | 899 | break; |
900 | 900 | ||
901 | /* Software ecc 3/256, write all */ | 901 | /* Software ecc 3/256, write all */ |
@@ -906,7 +906,7 @@ static int nand_write_page(struct mtd_info *mtd, struct nand_chip *this, int pag | |||
906 | oob_buf[oob_config[eccidx]] = ecc_code[i]; | 906 | oob_buf[oob_config[eccidx]] = ecc_code[i]; |
907 | datidx += this->ecc.size; | 907 | datidx += this->ecc.size; |
908 | } | 908 | } |
909 | this->write_buf(mtd, this->data_poi, mtd->oobblock); | 909 | this->write_buf(mtd, this->data_poi, mtd->writesize); |
910 | break; | 910 | break; |
911 | default: | 911 | default: |
912 | eccbytes = this->ecc.bytes; | 912 | eccbytes = this->ecc.bytes; |
@@ -1167,9 +1167,9 @@ int nand_do_read_ecc(struct mtd_info *mtd, loff_t from, size_t len, | |||
1167 | page = realpage & this->pagemask; | 1167 | page = realpage & this->pagemask; |
1168 | 1168 | ||
1169 | /* Get raw starting column */ | 1169 | /* Get raw starting column */ |
1170 | col = from & (mtd->oobblock - 1); | 1170 | col = from & (mtd->writesize - 1); |
1171 | 1171 | ||
1172 | end = mtd->oobblock; | 1172 | end = mtd->writesize; |
1173 | ecc = this->ecc.size; | 1173 | ecc = this->ecc.size; |
1174 | eccbytes = this->ecc.bytes; | 1174 | eccbytes = this->ecc.bytes; |
1175 | 1175 | ||
@@ -1327,7 +1327,7 @@ int nand_do_read_ecc(struct mtd_info *mtd, loff_t from, size_t len, | |||
1327 | buf[read++] = data_poi[j]; | 1327 | buf[read++] = data_poi[j]; |
1328 | this->pagebuf = realpage; | 1328 | this->pagebuf = realpage; |
1329 | } else | 1329 | } else |
1330 | read += mtd->oobblock; | 1330 | read += mtd->writesize; |
1331 | 1331 | ||
1332 | /* Apply delay or wait for ready/busy pin | 1332 | /* Apply delay or wait for ready/busy pin |
1333 | * Do this before the AUTOINCR check, so no problems | 1333 | * Do this before the AUTOINCR check, so no problems |
@@ -1485,7 +1485,7 @@ int nand_read_raw(struct mtd_info *mtd, uint8_t *buf, loff_t from, size_t len, s | |||
1485 | int chip = (int)(from >> this->chip_shift); | 1485 | int chip = (int)(from >> this->chip_shift); |
1486 | int sndcmd = 1; | 1486 | int sndcmd = 1; |
1487 | int cnt = 0; | 1487 | int cnt = 0; |
1488 | int pagesize = mtd->oobblock + mtd->oobsize; | 1488 | int pagesize = mtd->writesize + mtd->oobsize; |
1489 | int blockcheck = (1 << (this->phys_erase_shift - this->page_shift)) - 1; | 1489 | int blockcheck = (1 << (this->phys_erase_shift - this->page_shift)) - 1; |
1490 | 1490 | ||
1491 | /* Do not allow reads past end of device */ | 1491 | /* Do not allow reads past end of device */ |
@@ -1587,7 +1587,7 @@ static uint8_t *nand_prepare_oobbuf(struct mtd_info *mtd, uint8_t *fsbuf, struct | |||
1587 | return this->oob_buf; | 1587 | return this->oob_buf; |
1588 | } | 1588 | } |
1589 | 1589 | ||
1590 | #define NOTALIGNED(x) (x & (mtd->oobblock-1)) != 0 | 1590 | #define NOTALIGNED(x) (x & (mtd->writesize-1)) != 0 |
1591 | 1591 | ||
1592 | /** | 1592 | /** |
1593 | * nand_write - [MTD Interface] compability function for nand_write_ecc | 1593 | * nand_write - [MTD Interface] compability function for nand_write_ecc |
@@ -1700,7 +1700,7 @@ static int nand_write_ecc(struct mtd_info *mtd, loff_t to, size_t len, | |||
1700 | /* Next oob page */ | 1700 | /* Next oob page */ |
1701 | oob += mtd->oobsize; | 1701 | oob += mtd->oobsize; |
1702 | /* Update written bytes count */ | 1702 | /* Update written bytes count */ |
1703 | written += mtd->oobblock; | 1703 | written += mtd->writesize; |
1704 | if (written == len) | 1704 | if (written == len) |
1705 | goto cmp; | 1705 | goto cmp; |
1706 | 1706 | ||
@@ -1811,7 +1811,7 @@ static int nand_write_oob(struct mtd_info *mtd, loff_t to, size_t len, size_t *r | |||
1811 | 1811 | ||
1812 | if (NAND_MUST_PAD(this)) { | 1812 | if (NAND_MUST_PAD(this)) { |
1813 | /* Write out desired data */ | 1813 | /* Write out desired data */ |
1814 | this->cmdfunc(mtd, NAND_CMD_SEQIN, mtd->oobblock, page & this->pagemask); | 1814 | this->cmdfunc(mtd, NAND_CMD_SEQIN, mtd->writesize, page & this->pagemask); |
1815 | /* prepad 0xff for partial programming */ | 1815 | /* prepad 0xff for partial programming */ |
1816 | this->write_buf(mtd, ffchars, column); | 1816 | this->write_buf(mtd, ffchars, column); |
1817 | /* write data */ | 1817 | /* write data */ |
@@ -1820,7 +1820,7 @@ static int nand_write_oob(struct mtd_info *mtd, loff_t to, size_t len, size_t *r | |||
1820 | this->write_buf(mtd, ffchars, mtd->oobsize - (len + column)); | 1820 | this->write_buf(mtd, ffchars, mtd->oobsize - (len + column)); |
1821 | } else { | 1821 | } else { |
1822 | /* Write out desired data */ | 1822 | /* Write out desired data */ |
1823 | this->cmdfunc(mtd, NAND_CMD_SEQIN, mtd->oobblock + column, page & this->pagemask); | 1823 | this->cmdfunc(mtd, NAND_CMD_SEQIN, mtd->writesize + column, page & this->pagemask); |
1824 | /* write data */ | 1824 | /* write data */ |
1825 | this->write_buf(mtd, buf, len); | 1825 | this->write_buf(mtd, buf, len); |
1826 | } | 1826 | } |
@@ -1953,7 +1953,7 @@ static int nand_writev_ecc(struct mtd_info *mtd, const struct kvec *vecs, unsign | |||
1953 | /* If the given tuple is >= pagesize then | 1953 | /* If the given tuple is >= pagesize then |
1954 | * write it out from the iov | 1954 | * write it out from the iov |
1955 | */ | 1955 | */ |
1956 | if ((vecs->iov_len - len) >= mtd->oobblock) { | 1956 | if ((vecs->iov_len - len) >= mtd->writesize) { |
1957 | /* Calc number of pages we can write | 1957 | /* Calc number of pages we can write |
1958 | * out of this iov in one go */ | 1958 | * out of this iov in one go */ |
1959 | numpages = (vecs->iov_len - len) >> this->page_shift; | 1959 | numpages = (vecs->iov_len - len) >> this->page_shift; |
@@ -1973,8 +1973,8 @@ static int nand_writev_ecc(struct mtd_info *mtd, const struct kvec *vecs, unsign | |||
1973 | &oobbuf[oob], oobsel, i != numpages); | 1973 | &oobbuf[oob], oobsel, i != numpages); |
1974 | if (ret) | 1974 | if (ret) |
1975 | goto out; | 1975 | goto out; |
1976 | this->data_poi += mtd->oobblock; | 1976 | this->data_poi += mtd->writesize; |
1977 | len += mtd->oobblock; | 1977 | len += mtd->writesize; |
1978 | oob += mtd->oobsize; | 1978 | oob += mtd->oobsize; |
1979 | page++; | 1979 | page++; |
1980 | } | 1980 | } |
@@ -1989,7 +1989,7 @@ static int nand_writev_ecc(struct mtd_info *mtd, const struct kvec *vecs, unsign | |||
1989 | * tuple until we have a full page to write | 1989 | * tuple until we have a full page to write |
1990 | */ | 1990 | */ |
1991 | int cnt = 0; | 1991 | int cnt = 0; |
1992 | while (cnt < mtd->oobblock) { | 1992 | while (cnt < mtd->writesize) { |
1993 | if (vecs->iov_base != NULL && vecs->iov_len) | 1993 | if (vecs->iov_base != NULL && vecs->iov_len) |
1994 | this->data_buf[cnt++] = ((uint8_t *) vecs->iov_base)[len++]; | 1994 | this->data_buf[cnt++] = ((uint8_t *) vecs->iov_base)[len++]; |
1995 | /* Check, if we have to switch to the next tuple */ | 1995 | /* Check, if we have to switch to the next tuple */ |
@@ -2015,7 +2015,7 @@ static int nand_writev_ecc(struct mtd_info *mtd, const struct kvec *vecs, unsign | |||
2015 | if (ret) | 2015 | if (ret) |
2016 | goto out; | 2016 | goto out; |
2017 | 2017 | ||
2018 | written += mtd->oobblock * numpages; | 2018 | written += mtd->writesize * numpages; |
2019 | /* All done ? */ | 2019 | /* All done ? */ |
2020 | if (!count) | 2020 | if (!count) |
2021 | break; | 2021 | break; |
@@ -2351,7 +2351,7 @@ static int nand_allocate_kmem(struct mtd_info *mtd, struct nand_chip *this) | |||
2351 | } | 2351 | } |
2352 | 2352 | ||
2353 | if (!this->data_buf) { | 2353 | if (!this->data_buf) { |
2354 | len = mtd->oobblock + mtd->oobsize; | 2354 | len = mtd->writesize + mtd->oobsize; |
2355 | this->data_buf = kmalloc(len, GFP_KERNEL); | 2355 | this->data_buf = kmalloc(len, GFP_KERNEL); |
2356 | if (!this->data_buf) | 2356 | if (!this->data_buf) |
2357 | goto outerr; | 2357 | goto outerr; |
@@ -2455,10 +2455,10 @@ static struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd, | |||
2455 | /* The 4th id byte is the important one */ | 2455 | /* The 4th id byte is the important one */ |
2456 | extid = this->read_byte(mtd); | 2456 | extid = this->read_byte(mtd); |
2457 | /* Calc pagesize */ | 2457 | /* Calc pagesize */ |
2458 | mtd->oobblock = 1024 << (extid & 0x3); | 2458 | mtd->writesize = 1024 << (extid & 0x3); |
2459 | extid >>= 2; | 2459 | extid >>= 2; |
2460 | /* Calc oobsize */ | 2460 | /* Calc oobsize */ |
2461 | mtd->oobsize = (8 << (extid & 0x01)) * (mtd->oobblock >> 9); | 2461 | mtd->oobsize = (8 << (extid & 0x01)) * (mtd->writesize >> 9); |
2462 | extid >>= 2; | 2462 | extid >>= 2; |
2463 | /* Calc blocksize. Blocksize is multiples of 64KiB */ | 2463 | /* Calc blocksize. Blocksize is multiples of 64KiB */ |
2464 | mtd->erasesize = (64 * 1024) << (extid & 0x03); | 2464 | mtd->erasesize = (64 * 1024) << (extid & 0x03); |
@@ -2471,8 +2471,8 @@ static struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd, | |||
2471 | * Old devices have this data hardcoded in the device id table | 2471 | * Old devices have this data hardcoded in the device id table |
2472 | */ | 2472 | */ |
2473 | mtd->erasesize = nand_flash_ids[i].erasesize; | 2473 | mtd->erasesize = nand_flash_ids[i].erasesize; |
2474 | mtd->oobblock = nand_flash_ids[i].pagesize; | 2474 | mtd->writesize = nand_flash_ids[i].pagesize; |
2475 | mtd->oobsize = mtd->oobblock / 32; | 2475 | mtd->oobsize = mtd->writesize / 32; |
2476 | busw = nand_flash_ids[i].options & NAND_BUSWIDTH_16; | 2476 | busw = nand_flash_ids[i].options & NAND_BUSWIDTH_16; |
2477 | } | 2477 | } |
2478 | 2478 | ||
@@ -2497,7 +2497,7 @@ static struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd, | |||
2497 | } | 2497 | } |
2498 | 2498 | ||
2499 | /* Calculate the address shift from the page size */ | 2499 | /* Calculate the address shift from the page size */ |
2500 | this->page_shift = ffs(mtd->oobblock) - 1; | 2500 | this->page_shift = ffs(mtd->writesize) - 1; |
2501 | /* Convert chipsize to number of pages per chip -1. */ | 2501 | /* Convert chipsize to number of pages per chip -1. */ |
2502 | this->pagemask = (this->chipsize >> this->page_shift) - 1; | 2502 | this->pagemask = (this->chipsize >> this->page_shift) - 1; |
2503 | 2503 | ||
@@ -2506,7 +2506,7 @@ static struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd, | |||
2506 | this->chip_shift = ffs(this->chipsize) - 1; | 2506 | this->chip_shift = ffs(this->chipsize) - 1; |
2507 | 2507 | ||
2508 | /* Set the bad block position */ | 2508 | /* Set the bad block position */ |
2509 | this->badblockpos = mtd->oobblock > 512 ? | 2509 | this->badblockpos = mtd->writesize > 512 ? |
2510 | NAND_LARGE_BADBLOCK_POS : NAND_SMALL_BADBLOCK_POS; | 2510 | NAND_LARGE_BADBLOCK_POS : NAND_SMALL_BADBLOCK_POS; |
2511 | 2511 | ||
2512 | /* Get chip options, preserve non chip based options */ | 2512 | /* Get chip options, preserve non chip based options */ |
@@ -2531,7 +2531,7 @@ static struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd, | |||
2531 | this->erase_cmd = single_erase_cmd; | 2531 | this->erase_cmd = single_erase_cmd; |
2532 | 2532 | ||
2533 | /* Do not replace user supplied command function ! */ | 2533 | /* Do not replace user supplied command function ! */ |
2534 | if (mtd->oobblock > 512 && this->cmdfunc == nand_command) | 2534 | if (mtd->writesize > 512 && this->cmdfunc == nand_command) |
2535 | this->cmdfunc = nand_command_lp; | 2535 | this->cmdfunc = nand_command_lp; |
2536 | 2536 | ||
2537 | printk(KERN_INFO "NAND device: Manufacturer ID:" | 2537 | printk(KERN_INFO "NAND device: Manufacturer ID:" |
@@ -2657,11 +2657,11 @@ int nand_scan(struct mtd_info *mtd, int maxchips) | |||
2657 | "Hardware ECC not possible\n"); | 2657 | "Hardware ECC not possible\n"); |
2658 | BUG(); | 2658 | BUG(); |
2659 | } | 2659 | } |
2660 | if (mtd->oobblock >= this->ecc.size) | 2660 | if (mtd->writesize >= this->ecc.size) |
2661 | break; | 2661 | break; |
2662 | printk(KERN_WARNING "%d byte HW ECC not possible on " | 2662 | printk(KERN_WARNING "%d byte HW ECC not possible on " |
2663 | "%d byte page size, fallback to SW ECC\n", | 2663 | "%d byte page size, fallback to SW ECC\n", |
2664 | this->ecc.size, mtd->oobblock); | 2664 | this->ecc.size, mtd->writesize); |
2665 | this->ecc.mode = NAND_ECC_SOFT; | 2665 | this->ecc.mode = NAND_ECC_SOFT; |
2666 | 2666 | ||
2667 | case NAND_ECC_SOFT: | 2667 | case NAND_ECC_SOFT: |
@@ -2674,7 +2674,7 @@ int nand_scan(struct mtd_info *mtd, int maxchips) | |||
2674 | case NAND_ECC_NONE: | 2674 | case NAND_ECC_NONE: |
2675 | printk(KERN_WARNING "NAND_ECC_NONE selected by board driver. " | 2675 | printk(KERN_WARNING "NAND_ECC_NONE selected by board driver. " |
2676 | "This is not recommended !!\n"); | 2676 | "This is not recommended !!\n"); |
2677 | this->ecc.size = mtd->oobblock; | 2677 | this->ecc.size = mtd->writesize; |
2678 | this->ecc.bytes = 0; | 2678 | this->ecc.bytes = 0; |
2679 | break; | 2679 | break; |
2680 | default: | 2680 | default: |
@@ -2687,8 +2687,8 @@ int nand_scan(struct mtd_info *mtd, int maxchips) | |||
2687 | * Set the number of read / write steps for one page depending on ECC | 2687 | * Set the number of read / write steps for one page depending on ECC |
2688 | * mode | 2688 | * mode |
2689 | */ | 2689 | */ |
2690 | this->ecc.steps = mtd->oobblock / this->ecc.size; | 2690 | this->ecc.steps = mtd->writesize / this->ecc.size; |
2691 | if(this->ecc.steps * this->ecc.size != mtd->oobblock) { | 2691 | if(this->ecc.steps * this->ecc.size != mtd->writesize) { |
2692 | printk(KERN_WARNING "Invalid ecc parameters\n"); | 2692 | printk(KERN_WARNING "Invalid ecc parameters\n"); |
2693 | BUG(); | 2693 | BUG(); |
2694 | } | 2694 | } |
@@ -2706,7 +2706,7 @@ int nand_scan(struct mtd_info *mtd, int maxchips) | |||
2706 | 2706 | ||
2707 | /* Fill in remaining MTD driver data */ | 2707 | /* Fill in remaining MTD driver data */ |
2708 | mtd->type = MTD_NANDFLASH; | 2708 | mtd->type = MTD_NANDFLASH; |
2709 | mtd->flags = MTD_CAP_NANDFLASH | MTD_ECC; | 2709 | mtd->flags = MTD_CAP_NANDFLASH; |
2710 | mtd->ecctype = MTD_ECC_SW; | 2710 | mtd->ecctype = MTD_ECC_SW; |
2711 | mtd->erase = nand_erase; | 2711 | mtd->erase = nand_erase; |
2712 | mtd->point = NULL; | 2712 | mtd->point = NULL; |