Lines Matching refs:td
90 static int check_pattern_no_oob(uint8_t *buf, struct nand_bbt_descr *td) in check_pattern_no_oob() argument
92 if (memcmp(buf, td->pattern, td->len)) in check_pattern_no_oob()
107 static int check_pattern(uint8_t *buf, int len, int paglen, struct nand_bbt_descr *td) in check_pattern() argument
109 if (td->options & NAND_BBT_NO_OOB) in check_pattern()
110 return check_pattern_no_oob(buf, td); in check_pattern()
113 if (memcmp(buf + paglen + td->offs, td->pattern, td->len)) in check_pattern()
128 static int check_short_pattern(uint8_t *buf, struct nand_bbt_descr *td) in check_short_pattern() argument
131 if (memcmp(buf + td->offs, td->pattern, td->len)) in check_short_pattern()
142 static u32 add_marker_len(struct nand_bbt_descr *td) in add_marker_len() argument
146 if (!(td->options & NAND_BBT_NO_OOB)) in add_marker_len()
149 len = td->len; in add_marker_len()
150 if (td->options & NAND_BBT_VERSION) in add_marker_len()
167 struct nand_bbt_descr *td, int offs) in read_bbt() argument
173 int bits = td->options & NAND_BBT_NRBITS_MSK; in read_bbt()
176 int reserved_block_code = td->reserved_block_code; in read_bbt()
179 marker_len = add_marker_len(td); in read_bbt()
260 struct nand_bbt_descr *td, int chip) in read_abs_bbt() argument
266 if (td->options & NAND_BBT_PERCHIP) { in read_abs_bbt()
270 res = read_bbt(this, buf, td->pages[i], in read_abs_bbt()
272 td, offs); in read_abs_bbt()
278 res = read_bbt(this, buf, td->pages[0], in read_abs_bbt()
279 mtd->size >> this->bbt_erase_shift, td, 0); in read_abs_bbt()
288 struct nand_bbt_descr *td) in scan_read_data() argument
294 len = td->len; in scan_read_data()
295 if (td->options & NAND_BBT_VERSION) in scan_read_data()
344 size_t len, struct nand_bbt_descr *td) in scan_read() argument
346 if (td->options & NAND_BBT_NO_OOB) in scan_read()
347 return scan_read_data(this, buf, offs, td); in scan_read()
369 static u32 bbt_get_ver_offs(struct nand_chip *this, struct nand_bbt_descr *td) in bbt_get_ver_offs() argument
372 u32 ver_offs = td->veroffs; in bbt_get_ver_offs()
374 if (!(td->options & NAND_BBT_NO_OOB)) in bbt_get_ver_offs()
390 struct nand_bbt_descr *td, struct nand_bbt_descr *md) in read_abs_bbts() argument
395 if (td->options & NAND_BBT_VERSION) { in read_abs_bbts()
396 scan_read(this, buf, (loff_t)td->pages[0] << this->page_shift, in read_abs_bbts()
397 mtd->writesize, td); in read_abs_bbts()
398 td->version[0] = buf[bbt_get_ver_offs(this, td)]; in read_abs_bbts()
400 td->pages[0], td->version[0]); in read_abs_bbts()
451 static int bbt_block_checkbad(struct nand_chip *this, struct nand_bbt_descr *td, in bbt_block_checkbad() argument
461 if (!(td->options & NAND_BBT_NO_OOB) && in bbt_block_checkbad()
462 td->offs >= bd->offs && td->offs < bd->offs + bd->len) in bbt_block_checkbad()
553 struct nand_bbt_descr *td) in search_bbt() argument
564 if (td->options & NAND_BBT_LASTBLOCK) { in search_bbt()
573 if (td->options & NAND_BBT_PERCHIP) { in search_bbt()
584 td->version[i] = 0; in search_bbt()
585 td->pages[i] = -1; in search_bbt()
587 for (block = 0; block < td->maxblocks; block++) { in search_bbt()
593 if (bbt_block_checkbad(this, td, offs, buf)) in search_bbt()
597 scan_read(this, buf, offs, mtd->writesize, td); in search_bbt()
598 if (!check_pattern(buf, scanlen, mtd->writesize, td)) { in search_bbt()
599 td->pages[i] = actblock << blocktopage; in search_bbt()
600 if (td->options & NAND_BBT_VERSION) { in search_bbt()
601 offs = bbt_get_ver_offs(this, td); in search_bbt()
602 td->version[i] = buf[offs]; in search_bbt()
611 if (td->pages[i] == -1) in search_bbt()
615 td->pages[i], td->version[i]); in search_bbt()
630 struct nand_bbt_descr *td, in search_read_bbts() argument
634 search_bbt(this, buf, td); in search_read_bbts()
654 static int get_bbt_block(struct nand_chip *this, struct nand_bbt_descr *td, in get_bbt_block() argument
665 if (td->pages[chip] != -1) in get_bbt_block()
666 return td->pages[chip] >> in get_bbt_block()
670 if (!(td->options & NAND_BBT_PERCHIP)) in get_bbt_block()
677 if (td->options & NAND_BBT_LASTBLOCK) { in get_bbt_block()
685 for (i = 0; i < td->maxblocks; i++) { in get_bbt_block()
718 struct nand_bbt_descr *td, in mark_bbt_block_bad() argument
732 td->pages[chip] = -1; in mark_bbt_block_bad()
746 struct nand_bbt_descr *td, struct nand_bbt_descr *md, in write_bbt() argument
756 uint8_t rcode = td->reserved_block_code; in write_bbt()
769 if (td->options & NAND_BBT_PERCHIP) { in write_bbt()
787 block = get_bbt_block(this, td, md, chip); in write_bbt()
801 bits = td->options & NAND_BBT_NRBITS_MSK; in write_bbt()
822 if (td->options & NAND_BBT_SAVECONTENT) { in write_bbt()
848 } else if (td->options & NAND_BBT_NO_OOB) { in write_bbt()
850 offs = td->len; in write_bbt()
852 if (td->options & NAND_BBT_VERSION) in write_bbt()
862 memcpy(buf, td->pattern, td->len); in write_bbt()
874 memcpy(&buf[ooboffs + td->offs], td->pattern, td->len); in write_bbt()
877 if (td->options & NAND_BBT_VERSION) in write_bbt()
878 buf[ooboffs + td->veroffs] = td->version[chip]; in write_bbt()
896 mark_bbt_block_bad(this, td, chip, block); in write_bbt()
901 td->options & NAND_BBT_NO_OOB ? in write_bbt()
906 mark_bbt_block_bad(this, td, chip, block); in write_bbt()
911 (unsigned long long)to, td->version[chip]); in write_bbt()
914 td->pages[chip++] = page; in write_bbt()
954 struct nand_bbt_descr *td = this->bbt_td; in check_create() local
959 if (td->options & NAND_BBT_PERCHIP) in check_create()
971 chipsel = (td->options & NAND_BBT_PERCHIP) ? i : -1; in check_create()
974 if (td->pages[i] == -1 && md->pages[i] == -1) { in check_create()
977 } else if (td->pages[i] == -1) { in check_create()
981 rd = td; in check_create()
983 } else if (td->version[i] == md->version[i]) { in check_create()
984 rd = td; in check_create()
985 if (!(td->options & NAND_BBT_VERSION)) in check_create()
987 } else if (((int8_t)(td->version[i] - md->version[i])) > 0) { in check_create()
988 rd = td; in check_create()
995 if (td->pages[i] == -1) { in check_create()
999 rd = td; in check_create()
1005 if (!(td->options & NAND_BBT_CREATE)) in check_create()
1012 td->version[i] = 1; in check_create()
1046 td->version[i] = max(td->version[i], md->version[i]); in check_create()
1047 md->version[i] = td->version[i]; in check_create()
1051 if ((writeops & 0x01) && (td->options & NAND_BBT_WRITE)) { in check_create()
1052 res = write_bbt(this, buf, td, md, chipsel); in check_create()
1059 res = write_bbt(this, buf, md, td, chipsel); in check_create()
1080 struct nand_bbt_descr *td = this->bbt_td; in nand_update_bbt() local
1083 if (!this->bbt || !td) in nand_update_bbt()
1094 if (td->options & NAND_BBT_PERCHIP) { in nand_update_bbt()
1102 td->version[chip]++; in nand_update_bbt()
1107 if (td->options & NAND_BBT_WRITE) { in nand_update_bbt()
1108 res = write_bbt(this, buf, td, md, chipsel); in nand_update_bbt()
1114 res = write_bbt(this, buf, md, td, chipsel); in nand_update_bbt()
1130 static void mark_bbt_region(struct nand_chip *this, struct nand_bbt_descr *td) in mark_bbt_region() argument
1138 if (td->options & NAND_BBT_PERCHIP) { in mark_bbt_region()
1147 if ((td->options & NAND_BBT_ABSPAGE) || in mark_bbt_region()
1148 !(td->options & NAND_BBT_WRITE)) { in mark_bbt_region()
1149 if (td->pages[i] == -1) in mark_bbt_region()
1151 block = td->pages[i] >> (this->bbt_erase_shift - this->page_shift); in mark_bbt_region()
1155 td->reserved_block_code) in mark_bbt_region()
1161 if (td->options & NAND_BBT_LASTBLOCK) in mark_bbt_region()
1162 block = ((i + 1) * nrblocks) - td->maxblocks; in mark_bbt_region()
1165 for (j = 0; j < td->maxblocks; j++) { in mark_bbt_region()
1177 if (update && td->reserved_block_code) in mark_bbt_region()
1249 struct nand_bbt_descr *td = this->bbt_td; in nand_scan_bbt() local
1265 if (!td) { in nand_scan_bbt()
1272 verify_bbt_descr(this, td); in nand_scan_bbt()
1285 if (td->options & NAND_BBT_ABSPAGE) { in nand_scan_bbt()
1286 read_abs_bbts(this, buf, td, md); in nand_scan_bbt()
1289 search_read_bbts(this, buf, td, md); in nand_scan_bbt()
1297 mark_bbt_region(this, td); in nand_scan_bbt()