Lines Matching refs:this

139 #define nand_select()	this->hwcontrol(NAND_CTL_SETNCE);
141 #define nand_deselect() this->hwcontrol(NAND_CTL_CLRNCE);
173 static int nand_write_page (struct mtd_info *mtd, struct nand_chip *this, int page, int col,
180 register struct nand_chip *this = mtd->priv; in nand_command() local
181 register unsigned long NAND_IO_ADDR = this->IO_ADDR_W; in nand_command()
184 this->hwcontrol (NAND_CTL_SETCLE); in nand_command()
212 this->hwcontrol (NAND_CTL_CLRCLE); in nand_command()
215 this->hwcontrol (NAND_CTL_SETALE); in nand_command()
228 this->hwcontrol (NAND_CTL_CLRALE); in nand_command()
245 if (this->dev_ready) in nand_command()
247 this->hwcontrol (NAND_CTL_SETCLE); in nand_command()
249 this->hwcontrol (NAND_CTL_CLRCLE); in nand_command()
250 while ( !(readb (this->IO_ADDR_R) & 0x40)); in nand_command()
259 if (!this->dev_ready) { in nand_command()
260 udelay (this->chip_delay); in nand_command()
266 while (!this->dev_ready()); in nand_command()
272 static inline void nand_get_chip (struct nand_chip *this, struct mtd_info *mtd, int new_state, int … in nand_get_chip() argument
283 spin_lock_bh (&this->chip_lock); in nand_get_chip()
285 if (this->state == FL_READY) { in nand_get_chip()
286 this->state = new_state; in nand_get_chip()
288 spin_unlock_bh (&this->chip_lock); in nand_get_chip()
292 if (this->state == FL_ERASING) { in nand_get_chip()
294 this->state = new_state; in nand_get_chip()
295 spin_unlock_bh (&this->chip_lock); in nand_get_chip()
297 this->cmdfunc(mtd, NAND_CMD_RESET, -1, -1); in nand_get_chip()
303 add_wait_queue (&this->wq, &wait); in nand_get_chip()
304 spin_unlock_bh (&this->chip_lock); in nand_get_chip()
306 remove_wait_queue (&this->wq, &wait); in nand_get_chip()
316 static int nand_wait(struct mtd_info *mtd, struct nand_chip *this, int state) in nand_wait() argument
327 spin_lock_bh (&this->chip_lock); in nand_wait()
328 this->cmdfunc (mtd, NAND_CMD_STATUS, -1, -1); in nand_wait()
332 if (this->state != state) { in nand_wait()
333 spin_unlock_bh (&this->chip_lock); in nand_wait()
336 if (this->dev_ready) { in nand_wait()
337 if (this->dev_ready ()) in nand_wait()
340 if (readb (this->IO_ADDR_R) & 0x40) in nand_wait()
343 spin_unlock_bh (&this->chip_lock); in nand_wait()
345 spin_lock_bh (&this->chip_lock); in nand_wait()
347 status = (int) readb (this->IO_ADDR_R); in nand_wait()
348 spin_unlock_bh (&this->chip_lock); in nand_wait()
356 static int nand_write_page (struct mtd_info *mtd, struct nand_chip *this, in nand_write_page() argument
361 int eccmode = oobsel ? this->eccmode : NAND_ECC_NONE; in nand_write_page()
366 oob_data = &this->data_buf[mtd->oobblock]; in nand_write_page()
376 this->cmdfunc (mtd, NAND_CMD_READ0, 0, page); in nand_write_page()
378 this->data_poi[i] = readb (this->IO_ADDR_R); in nand_write_page()
380 if ((col < this->eccsize) && (last >= this->eccsize)) { in nand_write_page()
381 this->calculate_ecc (&this->data_poi[0], &(ecc_code[0])); in nand_write_page()
387 this->calculate_ecc (&this->data_poi[256], &(ecc_code[3])); in nand_write_page()
399 this->data_poi[i] = 0xff; in nand_write_page()
403 this->data_poi[i] = 0xff; in nand_write_page()
406 this->cmdfunc (mtd, NAND_CMD_SEQIN, 0x00, page); in nand_write_page()
409 switch (this->eccmode) { in nand_write_page()
414 writeb ( this->data_poi[i] , this->IO_ADDR_W); in nand_write_page()
419 this->enable_hwecc (NAND_ECC_WRITE); /* enable hardware ecc logic for write */ in nand_write_page()
421 writeb ( this->data_poi[i] , this->IO_ADDR_W); in nand_write_page()
423 this->calculate_ecc (NULL, &(ecc_code[0])); in nand_write_page()
428 this->enable_hwecc (NAND_ECC_WRITE); /* enable hardware ecc logic for write*/ in nand_write_page()
430 writeb ( this->data_poi[i] , this->IO_ADDR_W); in nand_write_page()
431 this->calculate_ecc (NULL, &(ecc_code[3])); in nand_write_page()
439 this->enable_hwecc (NAND_ECC_WRITE); /* enable hardware ecc logic */ in nand_write_page()
441 writeb ( this->data_poi[i] , this->IO_ADDR_W); in nand_write_page()
442 this->calculate_ecc (NULL, &(ecc_code[0])); in nand_write_page()
449 this->enable_hwecc (NAND_ECC_WRITE); /* enable hardware ecc logic */ in nand_write_page()
451 writeb ( this->data_poi[i] , this->IO_ADDR_W); in nand_write_page()
452 this->calculate_ecc (NULL, &(ecc_code[0])); in nand_write_page()
458 printk (KERN_WARNING "Invalid NAND_ECC_MODE %d\n", this->eccmode); in nand_write_page()
464 writeb ( oob_data[i] , this->IO_ADDR_W); in nand_write_page()
467 this->cmdfunc (mtd, NAND_CMD_PAGEPROG, -1, -1); in nand_write_page()
470 status = this->waitfunc (mtd, this, FL_WRITING); in nand_write_page()
493 this->cmdfunc (mtd, NAND_CMD_READ0, col, page); in nand_write_page()
496 if (this->data_poi[i] != readb (this->IO_ADDR_R)) { in nand_write_page()
505 if (oob_data[i] != readb (this->IO_ADDR_R)) { in nand_write_page()
514 switch (this->eccmode) { in nand_write_page()
522 oob_data[i] = readb (this->IO_ADDR_R); in nand_write_page()
556 struct nand_chip *this = mtd->priv; in nand_read_ecc() local
560 int eccmode = oobsel ? this->eccmode : NAND_ECC_NONE; in nand_read_ecc()
574 nand_get_chip (this, mtd ,FL_READING, &erase_state); in nand_read_ecc()
580 page = from >> this->page_shift; in nand_read_ecc()
589 this->cmdfunc (mtd, NAND_CMD_READ0, 0x00, page); in nand_read_ecc()
596 if (!this->dev_ready) in nand_read_ecc()
597 udelay (this->chip_delay); in nand_read_ecc()
599 while (!this->dev_ready()); in nand_read_ecc()
609 data_poi = this->data_buf; in nand_read_ecc()
613 oob_data = &this->data_buf[end]; in nand_read_ecc()
621 data_poi[j++] = readb (this->IO_ADDR_R); in nand_read_ecc()
626 data_poi[j++] = readb (this->IO_ADDR_R); in nand_read_ecc()
627 this->calculate_ecc (&data_poi[0], &ecc_calc[0]); in nand_read_ecc()
629 this->calculate_ecc (&data_poi[256], &ecc_calc[3]); in nand_read_ecc()
633 this->enable_hwecc (NAND_ECC_READ); in nand_read_ecc()
635 data_poi[j++] = readb (this->IO_ADDR_R); in nand_read_ecc()
636 this->calculate_ecc (&data_poi[0], &ecc_calc[0]); /* read from hardware */ in nand_read_ecc()
639 this->enable_hwecc (NAND_ECC_READ); in nand_read_ecc()
641 data_poi[j++] = readb (this->IO_ADDR_R); in nand_read_ecc()
642 this->calculate_ecc (&data_poi[256], &ecc_calc[3]); /* read from hardware */ in nand_read_ecc()
648 this->enable_hwecc (NAND_ECC_READ); in nand_read_ecc()
650 data_poi[j++] = readb (this->IO_ADDR_R); in nand_read_ecc()
651 this->calculate_ecc (&data_poi[0], &ecc_calc[0]); /* read from hardware */ in nand_read_ecc()
655 printk (KERN_WARNING "Invalid NAND_ECC_MODE %d\n", this->eccmode); in nand_read_ecc()
661 oob_data[oob + j] = readb (this->IO_ADDR_R); in nand_read_ecc()
672 ecc_status = this->correct_data (&data_poi[0], &ecc_code[0], &ecc_calc[0]); in nand_read_ecc()
685 ecc_status = this->correct_data (&data_poi[256], &ecc_code[3], &ecc_calc[3]); in nand_read_ecc()
711 spin_lock_bh (&this->chip_lock); in nand_read_ecc()
712 this->state = FL_READY; in nand_read_ecc()
713 wake_up (&this->wq); in nand_read_ecc()
714 spin_unlock_bh (&this->chip_lock); in nand_read_ecc()
732 struct nand_chip *this = mtd->priv; in nand_read_oob() local
737 page = ((int) from) >> this->page_shift; in nand_read_oob()
753 nand_get_chip (this, mtd , FL_READING, &erase_state); in nand_read_oob()
759 this->cmdfunc (mtd, NAND_CMD_READOOB, col, page); in nand_read_oob()
765 buf[i] = readb (this->IO_ADDR_R); in nand_read_oob()
767 udelay (this->chip_delay); in nand_read_oob()
773 spin_lock_bh (&this->chip_lock); in nand_read_oob()
774 this->state = FL_READY; in nand_read_oob()
775 wake_up (&this->wq); in nand_read_oob()
776 spin_unlock_bh (&this->chip_lock); in nand_read_oob()
797 struct nand_chip *this = mtd->priv; in nand_write_ecc() local
808 page = ((int) to) >> this->page_shift; in nand_write_ecc()
814 nand_get_chip (this, mtd, FL_WRITING, NULL); in nand_write_ecc()
820 this->cmdfunc (mtd, NAND_CMD_STATUS, -1, -1); in nand_write_ecc()
821 if (!(readb (this->IO_ADDR_R) & 0x80)) { in nand_write_ecc()
834 this->data_poi = (u_char*) &buf[written]; in nand_write_ecc()
839 this->data_buf[i] = buf[written + i]; in nand_write_ecc()
842 this->data_poi = this->data_buf; in nand_write_ecc()
846 ret = nand_write_page (mtd, this, page, col, cnt ,&eccbuf[oob], oobsel); in nand_write_ecc()
849 ret = nand_write_page (mtd, this, page, col, cnt, NULL, oobsel); in nand_write_ecc()
867 spin_lock_bh (&this->chip_lock); in nand_write_ecc()
868 this->state = FL_READY; in nand_write_ecc()
869 wake_up (&this->wq); in nand_write_ecc()
870 spin_unlock_bh (&this->chip_lock); in nand_write_ecc()
882 struct nand_chip *this = mtd->priv; in nand_write_oob() local
887 page = ((int) to) >> this->page_shift; in nand_write_oob()
902 nand_get_chip (this, mtd, FL_WRITING, NULL); in nand_write_oob()
908 this->cmdfunc (mtd, NAND_CMD_STATUS, -1, -1); in nand_write_oob()
909 if (!(readb (this->IO_ADDR_R) & 0x80)) { in nand_write_oob()
916 this->cmdfunc (mtd, NAND_CMD_SEQIN, mtd->oobblock, page); in nand_write_oob()
919 writeb (0xff, this->IO_ADDR_W); in nand_write_oob()
922 writeb (buf[i], this->IO_ADDR_W); in nand_write_oob()
925 writeb (0xff, this->IO_ADDR_W); in nand_write_oob()
928 this->cmdfunc (mtd, NAND_CMD_PAGEPROG, -1, -1); in nand_write_oob()
930 status = this->waitfunc (mtd, this, FL_WRITING); in nand_write_oob()
943 this->cmdfunc (mtd, NAND_CMD_READOOB, column, page); in nand_write_oob()
947 if (buf[i] != readb (this->IO_ADDR_R)) { in nand_write_oob()
960 spin_lock_bh (&this->chip_lock); in nand_write_oob()
961 this->state = FL_READY; in nand_write_oob()
962 wake_up (&this->wq); in nand_write_oob()
963 spin_unlock_bh (&this->chip_lock); in nand_write_oob()
982 struct nand_chip *this = mtd->priv; in nand_writev_ecc() local
999 page = ((int) to) >> this->page_shift; in nand_writev_ecc()
1005 nand_get_chip (this, mtd, FL_WRITING, NULL); in nand_writev_ecc()
1011 this->cmdfunc (mtd, NAND_CMD_STATUS, -1, -1); in nand_writev_ecc()
1012 if (!(readb (this->IO_ADDR_R) & 0x80)) { in nand_writev_ecc()
1031 this->data_poi = (u_char *) vecs->iov_base; in nand_writev_ecc()
1032 this->data_poi += len; in nand_writev_ecc()
1047 this->data_buf[cnt++] = ((u_char *) vecs->iov_base)[len++]; in nand_writev_ecc()
1056 this->data_poi = this->data_buf; in nand_writev_ecc()
1060 ret = nand_write_page (mtd, this, page, col, cnt, NULL, oobsel); in nand_writev_ecc()
1079 spin_lock_bh (&this->chip_lock); in nand_writev_ecc()
1080 this->state = FL_READY; in nand_writev_ecc()
1081 wake_up (&this->wq); in nand_writev_ecc()
1082 spin_unlock_bh (&this->chip_lock); in nand_writev_ecc()
1094 struct nand_chip *this = mtd->priv; in nand_erase() local
1119 nand_get_chip (this, mtd, FL_ERASING, NULL); in nand_erase()
1122 page = (int) (instr->addr >> this->page_shift); in nand_erase()
1131 this->cmdfunc (mtd, NAND_CMD_STATUS, -1, -1); in nand_erase()
1132 if (!(readb (this->IO_ADDR_R) & 0x80)) { in nand_erase()
1145 this->cmdfunc (mtd, NAND_CMD_READOOB, NAND_BADBLOCK_POS, page); in nand_erase()
1146 if (readb (this->IO_ADDR_R) != 0xff) { in nand_erase()
1153 this->cmdfunc (mtd, NAND_CMD_ERASE1, -1, page); in nand_erase()
1154 this->cmdfunc (mtd, NAND_CMD_ERASE2, -1, -1); in nand_erase()
1156 spin_unlock_bh (&this->chip_lock); in nand_erase()
1157 status = this->waitfunc (mtd, this, FL_ERASING); in nand_erase()
1160 spin_lock_bh (&this->chip_lock); in nand_erase()
1169 if (this->state == FL_ERASING) { in nand_erase()
1175 spin_unlock_bh (&this->chip_lock); in nand_erase()
1177 spin_lock_bh (&this->chip_lock); in nand_erase()
1179 if (this->state == FL_ERASING || this->state == FL_READY) { in nand_erase()
1181 this->state = FL_ERASING; in nand_erase()
1186 add_wait_queue (&this->wq, &wait); in nand_erase()
1187 spin_unlock_bh (&this->chip_lock); in nand_erase()
1189 remove_wait_queue (&this->wq, &wait); in nand_erase()
1198 spin_unlock_bh (&this->chip_lock); in nand_erase()
1206 spin_lock_bh (&this->chip_lock); in nand_erase()
1207 this->state = FL_READY; in nand_erase()
1208 spin_unlock_bh (&this->chip_lock); in nand_erase()
1219 struct nand_chip *this = mtd->priv; in nand_sync() local
1226 spin_lock_bh (&this->chip_lock); in nand_sync()
1229 switch (this->state) { in nand_sync()
1232 this->state = FL_SYNCING; in nand_sync()
1233 spin_unlock_bh (&this->chip_lock); in nand_sync()
1238 add_wait_queue (&this->wq, &wait); in nand_sync()
1239 spin_unlock_bh (&this->chip_lock); in nand_sync()
1242 remove_wait_queue (&this->wq, &wait); in nand_sync()
1247 spin_lock_bh (&this->chip_lock); in nand_sync()
1250 if (this->state == FL_SYNCING) { in nand_sync()
1251 this->state = FL_READY; in nand_sync()
1252 wake_up (&this->wq); in nand_sync()
1256 spin_unlock_bh (&this->chip_lock); in nand_sync()
1265 struct nand_chip *this = mtd->priv; in nand_scan() local
1268 if (!this->chip_delay) in nand_scan()
1269 this->chip_delay = 20; in nand_scan()
1272 if (this->cmdfunc == NULL) in nand_scan()
1273 this->cmdfunc = nand_command; in nand_scan()
1276 if (this->waitfunc == NULL) in nand_scan()
1277 this->waitfunc = nand_wait; in nand_scan()
1283 this->cmdfunc (mtd, NAND_CMD_READID, 0x00, -1); in nand_scan()
1286 nand_maf_id = readb (this->IO_ADDR_R); in nand_scan()
1287 nand_dev_id = readb (this->IO_ADDR_R); in nand_scan()
1299 this->page_shift = 8; in nand_scan()
1303 this->page_shift = 9; in nand_scan()
1322 this->eccsize = 256; /* set default eccsize */ in nand_scan()
1324 switch (this->eccmode) { in nand_scan()
1329 this->eccmode = NAND_ECC_SOFT; in nand_scan()
1330 this->calculate_ecc = nand_calculate_ecc; in nand_scan()
1331 this->correct_data = nand_correct_data; in nand_scan()
1334 this->eccsize = 512; /* set eccsize to 512 and fall through for function check */ in nand_scan()
1337 if (this->calculate_ecc && this->correct_data && this->enable_hwecc) in nand_scan()
1343 this->eccmode = NAND_ECC_NONE; in nand_scan()
1347 this->calculate_ecc = nand_calculate_ecc; in nand_scan()
1348 this->correct_data = nand_correct_data; in nand_scan()
1352 printk (KERN_WARNING "Invalid NAND_ECC_MODE %d\n", this->eccmode); in nand_scan()
1357 this->state = FL_READY; in nand_scan()
1358 init_waitqueue_head (&this->wq); in nand_scan()
1359 spin_lock_init (&this->chip_lock); in nand_scan()