diff options
author | Joern Engel <joern@wh.fh-wedel.de> | 2006-05-22 17:18:05 -0400 |
---|---|---|
committer | Joern Engel <joern@wh.fh-wedel.de> | 2006-05-22 17:18:05 -0400 |
commit | 28318776a80bc3261f9af91ef79e6e38bb9f5bec (patch) | |
tree | 36ef9144accf19db9d51019aa479807e80aeb8fd /drivers/mtd/nand/nand_base.c | |
parent | 8ca9ed5db3aea8d27989c239e8a2f79b839f1e99 (diff) |
[MTD] Introduce writesize
At least two flashes exists that have the concept of a minimum write unit,
similar to NAND pages, but no other NAND characteristics. Therefore, rename
the minimum write unit to "writesize" for all flashes, including NAND.
Signed-off-by: Joern Engel <joern@wh.fh-wedel.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 08dffb7a9389..055f6608a2ec 100644 --- a/drivers/mtd/nand/nand_base.c +++ b/drivers/mtd/nand/nand_base.c | |||
@@ -560,9 +560,9 @@ static void nand_command(struct mtd_info *mtd, unsigned command, int column, int | |||
560 | if (command == NAND_CMD_SEQIN) { | 560 | if (command == NAND_CMD_SEQIN) { |
561 | int readcmd; | 561 | int readcmd; |
562 | 562 | ||
563 | if (column >= mtd->oobblock) { | 563 | if (column >= mtd->writesize) { |
564 | /* OOB area */ | 564 | /* OOB area */ |
565 | column -= mtd->oobblock; | 565 | column -= mtd->writesize; |
566 | readcmd = NAND_CMD_READOOB; | 566 | readcmd = NAND_CMD_READOOB; |
567 | } else if (column < 256) { | 567 | } else if (column < 256) { |
568 | /* First 256 bytes --> READ0 */ | 568 | /* First 256 bytes --> READ0 */ |
@@ -658,7 +658,7 @@ static void nand_command_lp(struct mtd_info *mtd, unsigned command, int column, | |||
658 | 658 | ||
659 | /* Emulate NAND_CMD_READOOB */ | 659 | /* Emulate NAND_CMD_READOOB */ |
660 | if (command == NAND_CMD_READOOB) { | 660 | if (command == NAND_CMD_READOOB) { |
661 | column += mtd->oobblock; | 661 | column += mtd->writesize; |
662 | command = NAND_CMD_READ0; | 662 | command = NAND_CMD_READ0; |
663 | } | 663 | } |
664 | 664 | ||
@@ -889,7 +889,7 @@ static int nand_write_page(struct mtd_info *mtd, struct nand_chip *this, int pag | |||
889 | /* No ecc, write all */ | 889 | /* No ecc, write all */ |
890 | case NAND_ECC_NONE: | 890 | case NAND_ECC_NONE: |
891 | printk(KERN_WARNING "Writing data without ECC to NAND-FLASH is not recommended\n"); | 891 | printk(KERN_WARNING "Writing data without ECC to NAND-FLASH is not recommended\n"); |
892 | this->write_buf(mtd, this->data_poi, mtd->oobblock); | 892 | this->write_buf(mtd, this->data_poi, mtd->writesize); |
893 | break; | 893 | break; |
894 | 894 | ||
895 | /* Software ecc 3/256, write all */ | 895 | /* Software ecc 3/256, write all */ |
@@ -900,7 +900,7 @@ static int nand_write_page(struct mtd_info *mtd, struct nand_chip *this, int pag | |||
900 | oob_buf[oob_config[eccidx]] = ecc_code[i]; | 900 | oob_buf[oob_config[eccidx]] = ecc_code[i]; |
901 | datidx += this->eccsize; | 901 | datidx += this->eccsize; |
902 | } | 902 | } |
903 | this->write_buf(mtd, this->data_poi, mtd->oobblock); | 903 | this->write_buf(mtd, this->data_poi, mtd->writesize); |
904 | break; | 904 | break; |
905 | default: | 905 | default: |
906 | eccbytes = this->eccbytes; | 906 | eccbytes = this->eccbytes; |
@@ -1161,9 +1161,9 @@ int nand_do_read_ecc(struct mtd_info *mtd, loff_t from, size_t len, | |||
1161 | page = realpage & this->pagemask; | 1161 | page = realpage & this->pagemask; |
1162 | 1162 | ||
1163 | /* Get raw starting column */ | 1163 | /* Get raw starting column */ |
1164 | col = from & (mtd->oobblock - 1); | 1164 | col = from & (mtd->writesize - 1); |
1165 | 1165 | ||
1166 | end = mtd->oobblock; | 1166 | end = mtd->writesize; |
1167 | ecc = this->eccsize; | 1167 | ecc = this->eccsize; |
1168 | eccbytes = this->eccbytes; | 1168 | eccbytes = this->eccbytes; |
1169 | 1169 | ||
@@ -1321,7 +1321,7 @@ int nand_do_read_ecc(struct mtd_info *mtd, loff_t from, size_t len, | |||
1321 | buf[read++] = data_poi[j]; | 1321 | buf[read++] = data_poi[j]; |
1322 | this->pagebuf = realpage; | 1322 | this->pagebuf = realpage; |
1323 | } else | 1323 | } else |
1324 | read += mtd->oobblock; | 1324 | read += mtd->writesize; |
1325 | 1325 | ||
1326 | /* Apply delay or wait for ready/busy pin | 1326 | /* Apply delay or wait for ready/busy pin |
1327 | * Do this before the AUTOINCR check, so no problems | 1327 | * Do this before the AUTOINCR check, so no problems |
@@ -1479,7 +1479,7 @@ int nand_read_raw(struct mtd_info *mtd, uint8_t *buf, loff_t from, size_t len, s | |||
1479 | int chip = (int)(from >> this->chip_shift); | 1479 | int chip = (int)(from >> this->chip_shift); |
1480 | int sndcmd = 1; | 1480 | int sndcmd = 1; |
1481 | int cnt = 0; | 1481 | int cnt = 0; |
1482 | int pagesize = mtd->oobblock + mtd->oobsize; | 1482 | int pagesize = mtd->writesize + mtd->oobsize; |
1483 | int blockcheck = (1 << (this->phys_erase_shift - this->page_shift)) - 1; | 1483 | int blockcheck = (1 << (this->phys_erase_shift - this->page_shift)) - 1; |
1484 | 1484 | ||
1485 | /* Do not allow reads past end of device */ | 1485 | /* Do not allow reads past end of device */ |
@@ -1581,7 +1581,7 @@ static u_char *nand_prepare_oobbuf(struct mtd_info *mtd, u_char *fsbuf, struct n | |||
1581 | return this->oob_buf; | 1581 | return this->oob_buf; |
1582 | } | 1582 | } |
1583 | 1583 | ||
1584 | #define NOTALIGNED(x) (x & (mtd->oobblock-1)) != 0 | 1584 | #define NOTALIGNED(x) (x & (mtd->writesize-1)) != 0 |
1585 | 1585 | ||
1586 | /** | 1586 | /** |
1587 | * nand_write - [MTD Interface] compability function for nand_write_ecc | 1587 | * nand_write - [MTD Interface] compability function for nand_write_ecc |
@@ -1694,7 +1694,7 @@ static int nand_write_ecc(struct mtd_info *mtd, loff_t to, size_t len, | |||
1694 | /* Next oob page */ | 1694 | /* Next oob page */ |
1695 | oob += mtd->oobsize; | 1695 | oob += mtd->oobsize; |
1696 | /* Update written bytes count */ | 1696 | /* Update written bytes count */ |
1697 | written += mtd->oobblock; | 1697 | written += mtd->writesize; |
1698 | if (written == len) | 1698 | if (written == len) |
1699 | goto cmp; | 1699 | goto cmp; |
1700 | 1700 | ||
@@ -1805,7 +1805,7 @@ static int nand_write_oob(struct mtd_info *mtd, loff_t to, size_t len, size_t *r | |||
1805 | 1805 | ||
1806 | if (NAND_MUST_PAD(this)) { | 1806 | if (NAND_MUST_PAD(this)) { |
1807 | /* Write out desired data */ | 1807 | /* Write out desired data */ |
1808 | this->cmdfunc(mtd, NAND_CMD_SEQIN, mtd->oobblock, page & this->pagemask); | 1808 | this->cmdfunc(mtd, NAND_CMD_SEQIN, mtd->writesize, page & this->pagemask); |
1809 | /* prepad 0xff for partial programming */ | 1809 | /* prepad 0xff for partial programming */ |
1810 | this->write_buf(mtd, ffchars, column); | 1810 | this->write_buf(mtd, ffchars, column); |
1811 | /* write data */ | 1811 | /* write data */ |
@@ -1814,7 +1814,7 @@ static int nand_write_oob(struct mtd_info *mtd, loff_t to, size_t len, size_t *r | |||
1814 | this->write_buf(mtd, ffchars, mtd->oobsize - (len + column)); | 1814 | this->write_buf(mtd, ffchars, mtd->oobsize - (len + column)); |
1815 | } else { | 1815 | } else { |
1816 | /* Write out desired data */ | 1816 | /* Write out desired data */ |
1817 | this->cmdfunc(mtd, NAND_CMD_SEQIN, mtd->oobblock + column, page & this->pagemask); | 1817 | this->cmdfunc(mtd, NAND_CMD_SEQIN, mtd->writesize + column, page & this->pagemask); |
1818 | /* write data */ | 1818 | /* write data */ |
1819 | this->write_buf(mtd, buf, len); | 1819 | this->write_buf(mtd, buf, len); |
1820 | } | 1820 | } |
@@ -1947,7 +1947,7 @@ static int nand_writev_ecc(struct mtd_info *mtd, const struct kvec *vecs, unsign | |||
1947 | /* If the given tuple is >= pagesize then | 1947 | /* If the given tuple is >= pagesize then |
1948 | * write it out from the iov | 1948 | * write it out from the iov |
1949 | */ | 1949 | */ |
1950 | if ((vecs->iov_len - len) >= mtd->oobblock) { | 1950 | if ((vecs->iov_len - len) >= mtd->writesize) { |
1951 | /* Calc number of pages we can write | 1951 | /* Calc number of pages we can write |
1952 | * out of this iov in one go */ | 1952 | * out of this iov in one go */ |
1953 | numpages = (vecs->iov_len - len) >> this->page_shift; | 1953 | numpages = (vecs->iov_len - len) >> this->page_shift; |
@@ -1967,8 +1967,8 @@ static int nand_writev_ecc(struct mtd_info *mtd, const struct kvec *vecs, unsign | |||
1967 | &oobbuf[oob], oobsel, i != numpages); | 1967 | &oobbuf[oob], oobsel, i != numpages); |
1968 | if (ret) | 1968 | if (ret) |
1969 | goto out; | 1969 | goto out; |
1970 | this->data_poi += mtd->oobblock; | 1970 | this->data_poi += mtd->writesize; |
1971 | len += mtd->oobblock; | 1971 | len += mtd->writesize; |
1972 | oob += mtd->oobsize; | 1972 | oob += mtd->oobsize; |
1973 | page++; | 1973 | page++; |
1974 | } | 1974 | } |
@@ -1983,7 +1983,7 @@ static int nand_writev_ecc(struct mtd_info *mtd, const struct kvec *vecs, unsign | |||
1983 | * tuple until we have a full page to write | 1983 | * tuple until we have a full page to write |
1984 | */ | 1984 | */ |
1985 | int cnt = 0; | 1985 | int cnt = 0; |
1986 | while (cnt < mtd->oobblock) { | 1986 | while (cnt < mtd->writesize) { |
1987 | if (vecs->iov_base != NULL && vecs->iov_len) | 1987 | if (vecs->iov_base != NULL && vecs->iov_len) |
1988 | this->data_buf[cnt++] = ((u_char *) vecs->iov_base)[len++]; | 1988 | this->data_buf[cnt++] = ((u_char *) vecs->iov_base)[len++]; |
1989 | /* Check, if we have to switch to the next tuple */ | 1989 | /* Check, if we have to switch to the next tuple */ |
@@ -2009,7 +2009,7 @@ static int nand_writev_ecc(struct mtd_info *mtd, const struct kvec *vecs, unsign | |||
2009 | if (ret) | 2009 | if (ret) |
2010 | goto out; | 2010 | goto out; |
2011 | 2011 | ||
2012 | written += mtd->oobblock * numpages; | 2012 | written += mtd->writesize * numpages; |
2013 | /* All done ? */ | 2013 | /* All done ? */ |
2014 | if (!count) | 2014 | if (!count) |
2015 | break; | 2015 | break; |
@@ -2411,10 +2411,10 @@ int nand_scan(struct mtd_info *mtd, int maxchips) | |||
2411 | /* The 4th id byte is the important one */ | 2411 | /* The 4th id byte is the important one */ |
2412 | extid = this->read_byte(mtd); | 2412 | extid = this->read_byte(mtd); |
2413 | /* Calc pagesize */ | 2413 | /* Calc pagesize */ |
2414 | mtd->oobblock = 1024 << (extid & 0x3); | 2414 | mtd->writesize = 1024 << (extid & 0x3); |
2415 | extid >>= 2; | 2415 | extid >>= 2; |
2416 | /* Calc oobsize */ | 2416 | /* Calc oobsize */ |
2417 | mtd->oobsize = (8 << (extid & 0x01)) * (mtd->oobblock >> 9); | 2417 | mtd->oobsize = (8 << (extid & 0x01)) * (mtd->writesize >> 9); |
2418 | extid >>= 2; | 2418 | extid >>= 2; |
2419 | /* Calc blocksize. Blocksize is multiples of 64KiB */ | 2419 | /* Calc blocksize. Blocksize is multiples of 64KiB */ |
2420 | mtd->erasesize = (64 * 1024) << (extid & 0x03); | 2420 | mtd->erasesize = (64 * 1024) << (extid & 0x03); |
@@ -2426,8 +2426,8 @@ int nand_scan(struct mtd_info *mtd, int maxchips) | |||
2426 | /* Old devices have this data hardcoded in the | 2426 | /* Old devices have this data hardcoded in the |
2427 | * device id table */ | 2427 | * device id table */ |
2428 | mtd->erasesize = nand_flash_ids[i].erasesize; | 2428 | mtd->erasesize = nand_flash_ids[i].erasesize; |
2429 | mtd->oobblock = nand_flash_ids[i].pagesize; | 2429 | mtd->writesize = nand_flash_ids[i].pagesize; |
2430 | mtd->oobsize = mtd->oobblock / 32; | 2430 | mtd->oobsize = mtd->writesize / 32; |
2431 | busw = nand_flash_ids[i].options & NAND_BUSWIDTH_16; | 2431 | busw = nand_flash_ids[i].options & NAND_BUSWIDTH_16; |
2432 | } | 2432 | } |
2433 | 2433 | ||
@@ -2451,12 +2451,12 @@ int nand_scan(struct mtd_info *mtd, int maxchips) | |||
2451 | } | 2451 | } |
2452 | 2452 | ||
2453 | /* Calculate the address shift from the page size */ | 2453 | /* Calculate the address shift from the page size */ |
2454 | this->page_shift = ffs(mtd->oobblock) - 1; | 2454 | this->page_shift = ffs(mtd->writesize) - 1; |
2455 | this->bbt_erase_shift = this->phys_erase_shift = ffs(mtd->erasesize) - 1; | 2455 | this->bbt_erase_shift = this->phys_erase_shift = ffs(mtd->erasesize) - 1; |
2456 | this->chip_shift = ffs(this->chipsize) - 1; | 2456 | this->chip_shift = ffs(this->chipsize) - 1; |
2457 | 2457 | ||
2458 | /* Set the bad block position */ | 2458 | /* Set the bad block position */ |
2459 | this->badblockpos = mtd->oobblock > 512 ? NAND_LARGE_BADBLOCK_POS : NAND_SMALL_BADBLOCK_POS; | 2459 | this->badblockpos = mtd->writesize > 512 ? NAND_LARGE_BADBLOCK_POS : NAND_SMALL_BADBLOCK_POS; |
2460 | 2460 | ||
2461 | /* Get chip options, preserve non chip based options */ | 2461 | /* Get chip options, preserve non chip based options */ |
2462 | this->options &= ~NAND_CHIPOPTIONS_MSK; | 2462 | this->options &= ~NAND_CHIPOPTIONS_MSK; |
@@ -2476,7 +2476,7 @@ int nand_scan(struct mtd_info *mtd, int maxchips) | |||
2476 | this->erase_cmd = single_erase_cmd; | 2476 | this->erase_cmd = single_erase_cmd; |
2477 | 2477 | ||
2478 | /* Do not replace user supplied command function ! */ | 2478 | /* Do not replace user supplied command function ! */ |
2479 | if (mtd->oobblock > 512 && this->cmdfunc == nand_command) | 2479 | if (mtd->writesize > 512 && this->cmdfunc == nand_command) |
2480 | this->cmdfunc = nand_command_lp; | 2480 | this->cmdfunc = nand_command_lp; |
2481 | 2481 | ||
2482 | printk(KERN_INFO "NAND device: Manufacturer ID:" | 2482 | printk(KERN_INFO "NAND device: Manufacturer ID:" |
@@ -2519,7 +2519,7 @@ int nand_scan(struct mtd_info *mtd, int maxchips) | |||
2519 | 2519 | ||
2520 | if (!this->data_buf) { | 2520 | if (!this->data_buf) { |
2521 | size_t len; | 2521 | size_t len; |
2522 | len = mtd->oobblock + mtd->oobsize; | 2522 | len = mtd->writesize + mtd->oobsize; |
2523 | this->data_buf = kmalloc(len, GFP_KERNEL); | 2523 | this->data_buf = kmalloc(len, GFP_KERNEL); |
2524 | if (!this->data_buf) { | 2524 | if (!this->data_buf) { |
2525 | if (this->options & NAND_OOBBUF_ALLOC) | 2525 | if (this->options & NAND_OOBBUF_ALLOC) |
@@ -2575,9 +2575,9 @@ int nand_scan(struct mtd_info *mtd, int maxchips) | |||
2575 | 2575 | ||
2576 | switch (this->eccmode) { | 2576 | switch (this->eccmode) { |
2577 | case NAND_ECC_HW12_2048: | 2577 | case NAND_ECC_HW12_2048: |
2578 | if (mtd->oobblock < 2048) { | 2578 | if (mtd->writesize < 2048) { |
2579 | printk(KERN_WARNING "2048 byte HW ECC not possible on %d byte page size, fallback to SW ECC\n", | 2579 | printk(KERN_WARNING "2048 byte HW ECC not possible on %d byte page size, fallback to SW ECC\n", |
2580 | mtd->oobblock); | 2580 | mtd->writesize); |
2581 | this->eccmode = NAND_ECC_SOFT; | 2581 | this->eccmode = NAND_ECC_SOFT; |
2582 | this->calculate_ecc = nand_calculate_ecc; | 2582 | this->calculate_ecc = nand_calculate_ecc; |
2583 | this->correct_data = nand_correct_data; | 2583 | this->correct_data = nand_correct_data; |
@@ -2588,7 +2588,7 @@ int nand_scan(struct mtd_info *mtd, int maxchips) | |||
2588 | case NAND_ECC_HW3_512: | 2588 | case NAND_ECC_HW3_512: |
2589 | case NAND_ECC_HW6_512: | 2589 | case NAND_ECC_HW6_512: |
2590 | case NAND_ECC_HW8_512: | 2590 | case NAND_ECC_HW8_512: |
2591 | if (mtd->oobblock == 256) { | 2591 | if (mtd->writesize == 256) { |
2592 | printk(KERN_WARNING "512 byte HW ECC not possible on 256 Byte pagesize, fallback to SW ECC \n"); | 2592 | printk(KERN_WARNING "512 byte HW ECC not possible on 256 Byte pagesize, fallback to SW ECC \n"); |
2593 | this->eccmode = NAND_ECC_SOFT; | 2593 | this->eccmode = NAND_ECC_SOFT; |
2594 | this->calculate_ecc = nand_calculate_ecc; | 2594 | this->calculate_ecc = nand_calculate_ecc; |
@@ -2638,16 +2638,16 @@ int nand_scan(struct mtd_info *mtd, int maxchips) | |||
2638 | /* Set the number of read / write steps for one page to ensure ECC generation */ | 2638 | /* Set the number of read / write steps for one page to ensure ECC generation */ |
2639 | switch (this->eccmode) { | 2639 | switch (this->eccmode) { |
2640 | case NAND_ECC_HW12_2048: | 2640 | case NAND_ECC_HW12_2048: |
2641 | this->eccsteps = mtd->oobblock / 2048; | 2641 | this->eccsteps = mtd->writesize / 2048; |
2642 | break; | 2642 | break; |
2643 | case NAND_ECC_HW3_512: | 2643 | case NAND_ECC_HW3_512: |
2644 | case NAND_ECC_HW6_512: | 2644 | case NAND_ECC_HW6_512: |
2645 | case NAND_ECC_HW8_512: | 2645 | case NAND_ECC_HW8_512: |
2646 | this->eccsteps = mtd->oobblock / 512; | 2646 | this->eccsteps = mtd->writesize / 512; |
2647 | break; | 2647 | break; |
2648 | case NAND_ECC_HW3_256: | 2648 | case NAND_ECC_HW3_256: |
2649 | case NAND_ECC_SOFT: | 2649 | case NAND_ECC_SOFT: |
2650 | this->eccsteps = mtd->oobblock / 256; | 2650 | this->eccsteps = mtd->writesize / 256; |
2651 | break; | 2651 | break; |
2652 | 2652 | ||
2653 | case NAND_ECC_NONE: | 2653 | case NAND_ECC_NONE: |