Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 195970
b: refs/heads/master
c: b60b08b
h: refs/heads/master
v: v3
  • Loading branch information
Kevin Cernekee authored and David Woodhouse committed May 14, 2010
1 parent f3728aa commit ed271a2
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 426c457a3216fac74e3d44dd39729b0689f4c7ab
refs/heads/master: b60b08b02ca8d9575985ae6711bd656dd67e9039
15 changes: 15 additions & 0 deletions trunk/drivers/mtd/nand/nand_base.c
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,9 @@ static int nand_block_bad(struct mtd_info *mtd, loff_t ofs, int getchip)
struct nand_chip *chip = mtd->priv;
u16 bad;

if (chip->options & NAND_BB_LAST_PAGE)
ofs += mtd->erasesize - mtd->writesize;

page = (int)(ofs >> chip->page_shift) & chip->pagemask;

if (getchip) {
Expand Down Expand Up @@ -396,6 +399,9 @@ static int nand_default_block_markbad(struct mtd_info *mtd, loff_t ofs)
uint8_t buf[2] = { 0, 0 };
int block, ret;

if (chip->options & NAND_BB_LAST_PAGE)
ofs += mtd->erasesize - mtd->writesize;

/* Get block number */
block = (int)(ofs >> chip->bbt_erase_shift);
if (chip->bbt)
Expand Down Expand Up @@ -2933,6 +2939,15 @@ static struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd,
if (*maf_id != NAND_MFR_SAMSUNG && !type->pagesize)
chip->options &= ~NAND_SAMSUNG_LP_OPTIONS;

/*
* Bad block marker is stored in the last page of each block
* on Samsung and Hynix MLC devices
*/
if ((chip->cellinfo & NAND_CI_CELLTYPE_MSK) &&
(*maf_id == NAND_MFR_SAMSUNG ||
*maf_id == NAND_MFR_HYNIX))
chip->options |= NAND_BB_LAST_PAGE;

/* Check for AND chips with 4 page planes */
if (chip->options & NAND_4PAGE_ARRAY)
chip->erase_cmd = multi_erase_cmd;
Expand Down
3 changes: 3 additions & 0 deletions trunk/drivers/mtd/nand/nand_bbt.c
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,9 @@ static int create_bbt(struct mtd_info *mtd, uint8_t *buf,
from = (loff_t)startblock << (this->bbt_erase_shift - 1);
}

if (this->options & NAND_BB_LAST_PAGE)
from += mtd->erasesize - (mtd->writesize * len);

for (i = startblock; i < numblocks;) {
int ret;

Expand Down
2 changes: 2 additions & 0 deletions trunk/include/linux/mtd/nand.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,8 @@ typedef enum {
#define NAND_NO_READRDY 0x00000100
/* Chip does not allow subpage writes */
#define NAND_NO_SUBPAGE_WRITE 0x00000200
/* Chip stores bad block marker on the last page of the eraseblock */
#define NAND_BB_LAST_PAGE 0x00000400

/* Device is one of 'new' xD cards that expose fake nand command set */
#define NAND_BROKEN_XD 0x00000400
Expand Down

0 comments on commit ed271a2

Please sign in to comment.